]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java
enhance hoblib function convert
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / workspace / WorkspaceTools.java
1 /** @file
2
3 The file is used to init workspace and get basic information of workspace
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.workspace;
16
17 import java.io.File;
18 import java.io.IOException;
19 import java.util.List;
20 import java.util.Vector;
21
22 import org.apache.xmlbeans.XmlCursor;
23 import org.apache.xmlbeans.XmlException;
24 import org.tianocore.DbPathAndFilename;
25 import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes;
26 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
27 import org.tianocore.MsaFilesDocument.MsaFiles;
28 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
29 import org.tianocore.SourceFilesDocument.SourceFiles;
30 import org.tianocore.frameworkwizard.common.DataType;
31 import org.tianocore.frameworkwizard.common.GlobalData;
32 import org.tianocore.frameworkwizard.common.Log;
33 import org.tianocore.frameworkwizard.common.OpenFile;
34 import org.tianocore.frameworkwizard.common.SaveFile;
35 import org.tianocore.frameworkwizard.common.Sort;
36 import org.tianocore.frameworkwizard.common.Tools;
37 import org.tianocore.frameworkwizard.common.Identifications.Identification;
38 import org.tianocore.frameworkwizard.far.FarHeader;
39 import org.tianocore.frameworkwizard.far.FarIdentification;
40 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
41 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdIdentification;
42 import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdVector;
43 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
44 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
45
46 public class WorkspaceTools {
47
48 public void addFarToDb(List<String> packageList, List<String> platformList, FarHeader far) {
49 //FrameworkDatabase fdb = openFrameworkDb();
50
51 for (int i = 0; i < packageList.size(); i++) {
52 DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();
53 item.setFarGuid(far.getGuidValue());
54 item.setStringValue(packageList.get(i));
55 GlobalData.fdb.getPackageList().getFilenameList().add(item);
56 }
57
58 for (int i = 0; i < platformList.size(); i++) {
59 DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();
60 item.setFarGuid(far.getGuidValue());
61 item.setStringValue(platformList.get(i));
62 GlobalData.fdb.getPlatformList().getFilenameList().add(item);
63 }
64
65 DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance();
66 farItem.setFarGuid(far.getGuidValue());
67 farItem.setStringValue(far.getFarName());
68 GlobalData.fdb.getFarList().getFilenameList().add(farItem);
69
70 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
71 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
72
73 try {
74 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
75 } catch (Exception e) {
76 Log.err("Save Database File", e.getMessage());
77 }
78 }
79
80 public void removeFarFromDb(FarIdentification far) {
81 //
82 // Remove Packages
83 //
84 XmlCursor cursor = GlobalData.fdb.getPackageList().newCursor();
85 cursor.toFirstChild();
86 do {
87 DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
88
89 if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
90 cursor.removeXml();
91 }
92 } while (cursor.toNextSibling());
93 cursor.dispose();
94
95 //
96 // Remove Platforms
97 //
98 cursor = GlobalData.fdb.getPlatformList().newCursor();
99 cursor.toFirstChild();
100 do {
101 DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
102 if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
103 cursor.removeXml();
104 }
105 } while (cursor.toNextSibling());
106
107 //
108 // Remove Far
109 //
110 cursor = GlobalData.fdb.getFarList().newCursor();
111 cursor.toFirstChild();
112 do {
113 DbPathAndFilename item = (DbPathAndFilename) cursor.getObject();
114 if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
115 cursor.removeXml();
116 }
117 } while (cursor.toNextSibling());
118 cursor.dispose();
119
120 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
121 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
122 try {
123 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
124 } catch (Exception e) {
125 Log.err("Save Database File", e.getMessage());
126 }
127 }
128
129 public String getPackageFarGuid(Identification packageId) {
130 for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) {
131 DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index);
132 String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
133 File tempFile = new File(path);
134 if (tempFile.getPath().equalsIgnoreCase(packageId.getPath())) {
135 return GlobalData.fdb.getPackageList().getFilenameArray(index).getFarGuid();
136 }
137 }
138
139 return null;
140 }
141
142 public String getPlatformFarGuid(Identification platformId) {
143 for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) {
144 DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index);
145 String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
146 File tempFile = new File(path);
147 if (tempFile.getPath().equalsIgnoreCase(platformId.getPath())) {
148 return GlobalData.fdb.getPlatformList().getFilenameArray(index).getFarGuid();
149 }
150 }
151
152 return null;
153 }
154
155 public String getModuleFarGuid(Identification moduleId) {
156 PackageIdentification packageId = getPackageIdByModuleId(moduleId);
157 if (packageId != null) {
158 return getPackageFarGuid(packageId);
159 } else {
160 return null;
161 }
162 }
163
164 /**
165 Get all modules' paths from one package
166
167 @return a Vector with all modules' path
168
169 **/
170 public Vector<String> getAllModulesOfPackage(String path) {
171 Vector<String> modulePath = new Vector<String>();
172 PackageIdentification id = new PackageIdentification(null, null, null, path);
173 MsaFiles files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id).getMsaFiles();
174 if (files != null) {
175 for (int index = 0; index < files.getFilenameList().size(); index++) {
176 String msaPath = files.getFilenameList().get(index);
177 msaPath = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + msaPath;
178 msaPath = Tools.convertPathToCurrentOsType(msaPath);
179 modulePath.addElement(msaPath);
180 }
181 }
182
183 return modulePath;
184 }
185
186 /**
187 Get all Industry Std Includes' paths from one package
188
189 @return a Vector with all paths
190
191 **/
192 public Vector<String> getAllIndustryStdIncludesOfPackage(String path) {
193 Vector<String> includePath = new Vector<String>();
194 PackageIdentification id = new PackageIdentification(null, null, null, path);
195 IndustryStdIncludes files = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(id)
196 .getIndustryStdIncludes();
197 if (files != null) {
198 for (int index = 0; index < files.getIndustryStdHeaderList().size(); index++) {
199 String temp = files.getIndustryStdHeaderList().get(index).getIncludeHeader();
200 temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp;
201 temp = Tools.convertPathToCurrentOsType(temp);
202 includePath.addElement(temp);
203 }
204 }
205 return includePath;
206 }
207
208 /**
209 Get all package basic information form the FrameworkDatabase.db file
210
211 @return vPackageList A vector includes all packages' basic information
212
213 */
214 public Vector<PackageIdentification> getAllPackages() {
215 return GlobalData.vPackageList;
216 }
217
218 public Vector<FarIdentification> getAllFars() {
219
220 Vector<FarIdentification> v = new Vector<FarIdentification>();
221 for (int index = 0; index < GlobalData.fdb.getFarList().getFilenameList().size(); index++) {
222 DbPathAndFilename item = GlobalData.fdb.getFarList().getFilenameList().get(index);
223 FarIdentification far = new FarIdentification(item.getFarGuid(), item.getMd5Sum(), item.getStringValue());
224 v.addElement(far);
225 }
226 return v;
227 }
228
229 public Vector<PackageIdentification> getPackagesByFar(FarIdentification far) {
230 Identification id = null;
231
232 Vector<PackageIdentification> v = new Vector<PackageIdentification>();
233
234 for (int index = 0; index < GlobalData.fdb.getPackageList().getFilenameList().size(); index++) {
235 DbPathAndFilename item = GlobalData.fdb.getPackageList().getFilenameArray(index);
236 String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
237 path = Tools.convertPathToCurrentOsType(path);
238
239 if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
240
241 try {
242 id = Tools.getId(path, OpenFile.openSpdFile(path));
243 v.addElement(new PackageIdentification(id));
244 } catch (IOException e) {
245 Log.err("Open Package Surface Area " + path, e.getMessage());
246 } catch (XmlException e) {
247 Log.err("Open Package Surface Area " + path, e.getMessage());
248 } catch (Exception e) {
249 Log.err("Open Package Surface Area " + path, "Invalid file type");
250 }
251 }
252 }
253 return v;
254 }
255
256 public Vector<PlatformIdentification> getPlatformsByFar(FarIdentification far) {
257 Identification id = null;
258
259 Vector<PlatformIdentification> v = new Vector<PlatformIdentification>();
260
261 for (int index = 0; index < GlobalData.fdb.getPlatformList().getFilenameList().size(); index++) {
262 DbPathAndFilename item = GlobalData.fdb.getPlatformList().getFilenameArray(index);
263 String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + item.getStringValue();
264 path = Tools.convertPathToCurrentOsType(path);
265
266 if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {
267 try {
268 id = Tools.getId(path, OpenFile.openFpdFile(path));
269 v.addElement(new PlatformIdentification(id));
270 } catch (IOException e) {
271 Log.err("Open Platform Surface Area " + path, e.getMessage());
272 } catch (XmlException e) {
273 Log.err("Open Platform Surface Area " + path, e.getMessage());
274 } catch (Exception e) {
275 Log.err("Open Platform Surface Area " + path, "Invalid file type");
276 }
277 }
278 }
279 return v;
280 }
281
282 /**
283 Get all module basic information from a package
284
285 @param id Package id
286 @return A vector includes all modules' basic information
287
288 **/
289 public Vector<ModuleIdentification> getAllModules(PackageIdentification pid) {
290 Vector<ModuleIdentification> v = new Vector<ModuleIdentification>();
291 Vector<String> modulePaths = this.getAllModulesOfPackage(pid.getPath());
292 String modulePath = null;
293
294 for (int index = 0; index < modulePaths.size(); index++) {
295 modulePath = modulePaths.get(index);
296 ModuleIdentification id = GlobalData.openingModuleList.getIdByPath(modulePath);
297 if (id != null) {
298 v.addElement(id);
299 }
300 }
301 Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING);
302 return v;
303 }
304
305 /**
306 Get all module basic information form the FrameworkDatabase.db file
307
308 @return vModuleList A vector includes all modules' basic information
309
310 */
311 public Vector<ModuleIdentification> getAllModules() {
312 return GlobalData.vModuleList;
313 }
314
315 /**
316 Get all platform basic information form the FrameworkDatabase.db file
317
318 @return vplatformList A vector includes all platforms' basic information
319
320 */
321 public Vector<PlatformIdentification> getAllPlatforms() {
322 return GlobalData.vPlatformList;
323 }
324
325 /**
326 Get all Library Class Definitions from a package
327
328 @return Vector
329 **/
330 public Vector<String> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd) {
331 Vector<String> vector = new Vector<String>();
332 if (spd.getLibraryClassDeclarations() != null) {
333 if (spd.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
334 for (int index = 0; index < spd.getLibraryClassDeclarations().getLibraryClassList().size(); index++) {
335 vector.addElement(spd.getLibraryClassDeclarations().getLibraryClassList().get(index).getName());
336 }
337 }
338 }
339 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
340 return vector;
341 }
342
343 /**
344 Get all Protocol Definitions from a package
345
346 @return Vector
347 **/
348 public Vector<String> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd) {
349 Vector<String> vector = new Vector<String>();
350 if (spd.getProtocolDeclarations() != null) {
351 if (spd.getProtocolDeclarations().getEntryList().size() > 0) {
352 for (int index = 0; index < spd.getProtocolDeclarations().getEntryList().size(); index++) {
353 vector.addElement(spd.getProtocolDeclarations().getEntryList().get(index).getCName());
354 }
355 }
356 }
357 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
358 return vector;
359 }
360
361 /**
362 Get all Ppi Definitions from a package
363
364 @return Vector
365 **/
366 public Vector<String> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd) {
367 Vector<String> vector = new Vector<String>();
368 if (spd.getPpiDeclarations() != null) {
369 if (spd.getPpiDeclarations().getEntryList().size() > 0) {
370 for (int index = 0; index < spd.getPpiDeclarations().getEntryList().size(); index++) {
371 vector.addElement(spd.getPpiDeclarations().getEntryList().get(index).getCName());
372 }
373 }
374 }
375 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
376 return vector;
377 }
378
379 /**
380 Get all Guid Definitions from a package
381
382 @return Vector
383 **/
384 public Vector<String> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd) {
385 Vector<String> vector = new Vector<String>();
386 if (spd.getGuidDeclarations() != null) {
387 if (spd.getGuidDeclarations().getEntryList().size() > 0) {
388 for (int index = 0; index < spd.getGuidDeclarations().getEntryList().size(); index++) {
389 vector.addElement(spd.getGuidDeclarations().getEntryList().get(index).getCName());
390 }
391 }
392 }
393 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
394 return vector;
395 }
396
397 /**
398 Get all Pcd Definitions from a package
399
400 @return Vector
401 **/
402 public PcdVector getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd) {
403 PcdVector vector = new PcdVector();
404 if (spd.getPcdDeclarations() != null) {
405 if (spd.getPcdDeclarations().getPcdEntryList().size() > 0) {
406 for (int index = 0; index < spd.getPcdDeclarations().getPcdEntryList().size(); index++) {
407 String name = spd.getPcdDeclarations().getPcdEntryList().get(index).getCName();
408 String guidCName = spd.getPcdDeclarations().getPcdEntryList().get(index).getTokenSpaceGuidCName();
409 String help = spd.getPcdDeclarations().getPcdEntryList().get(index).getHelpText();
410 Vector<String> type = Tools.convertListToVector(spd.getPcdDeclarations().getPcdEntryList()
411 .get(index).getValidUsage());
412
413 vector.addPcd(new PcdIdentification(name, guidCName, help, type));
414 }
415 }
416 }
417 Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING);
418 return vector;
419 }
420
421 public Vector<String> getAllLibraryClassDefinitionsFromWorkspace() {
422 Vector<String> vector = new Vector<String>();
423 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
424 Vector<String> v = getAllLibraryClassDefinitionsFromPackage(GlobalData.openingPackageList
425 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
426 .get(index)));
427 if (v != null && v.size() > 0) {
428 vector.addAll(v);
429 }
430
431 }
432 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
433 return vector;
434 }
435
436 public Vector<String> getAllProtocolDeclarationsFromWorkspace() {
437 Vector<String> vector = new Vector<String>();
438 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
439 Vector<String> v = getAllProtocolDeclarationsFromPackage(GlobalData.openingPackageList
440 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
441 .get(index)));
442 if (v != null && v.size() > 0) {
443 vector.addAll(v);
444 }
445 }
446 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
447 return vector;
448 }
449
450 public Vector<String> getAllPpiDeclarationsFromWorkspace() {
451 Vector<String> vector = new Vector<String>();
452 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
453 Vector<String> v = getAllPpiDeclarationsFromPackage(GlobalData.openingPackageList
454 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
455 .get(index)));
456 if (v != null && v.size() > 0) {
457 vector.addAll(v);
458 }
459 }
460 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
461 return vector;
462 }
463
464 public Vector<String> getAllGuidDeclarationsFromWorkspace() {
465 Vector<String> vector = new Vector<String>();
466 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
467 Vector<String> v = getAllGuidDeclarationsFromPackage(GlobalData.openingPackageList
468 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
469 .get(index)));
470 if (v != null && v.size() > 0) {
471 vector.addAll(v);
472 }
473
474 }
475 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
476 return vector;
477 }
478
479 public PcdVector getAllPcdDeclarationsFromWorkspace() {
480 PcdVector vector = new PcdVector();
481 for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {
482 PcdVector v = getAllPcdDeclarationsFromPackage(GlobalData.openingPackageList
483 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
484 .get(index)));
485 if (v != null && v.size() > 0) {
486 vector.addAll(v);
487 }
488
489 }
490 Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING);
491 return vector;
492 }
493
494 /**
495 Find a module's package's id
496
497 @param id input module id
498 @return package id
499
500 **/
501 public PackageIdentification getPackageIdByModuleId(Identification id) {
502 Vector<String> modulePaths = new Vector<String>();
503 Identification mid = null;
504 String packagePath = null;
505 String modulePath = null;
506
507 //
508 // For each package, get all modules list
509 //
510 for (int indexI = 0; indexI < GlobalData.vPackageList.size(); indexI++) {
511 packagePath = GlobalData.vPackageList.elementAt(indexI).getPath();
512 modulePaths = this.getAllModulesOfPackage(packagePath);
513 for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {
514 modulePath = modulePaths.get(indexJ);
515 mid = GlobalData.openingModuleList.getIdByPath(modulePath);
516 //
517 // Check id
518 //
519 if (mid.equals(id)) {
520 return GlobalData.vPackageList.elementAt(indexI);
521 }
522
523 }
524 }
525
526 return null;
527 }
528
529 /**
530 Add module information to package surface area
531
532 @param mid
533 @throws IOException
534 @throws XmlException
535 @throws Exception
536
537 **/
538 public void addModuleToPackage(ModuleIdentification mid, PackageSurfaceArea spd) throws IOException, XmlException,
539 Exception {
540 String packagePath = mid.getPackageId().getPath();
541 String modulePath = mid.getPath();
542 if (spd == null) {
543 spd = OpenFile.openSpdFile(packagePath);
544 }
545 MsaFiles msaFile = spd.getMsaFiles();
546 if (msaFile == null) {
547 msaFile = MsaFiles.Factory.newInstance();
548 }
549 packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR));
550 String fn = Tools.getRelativePath(modulePath, packagePath);
551 msaFile.addNewFilename();
552 msaFile.setFilenameArray(msaFile.getFilenameList().size() - 1, fn);
553 spd.setMsaFiles(msaFile);
554 SaveFile.saveSpdFile(mid.getPackageId().getPath(), spd);
555 }
556
557 /**
558 Add input package into database
559
560 @param id
561 * @throws Exception
562
563 **/
564 public void addPackageToDatabase(PackageIdentification id) throws Exception {
565 String path = id.getPath();
566 path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
567
568 DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
569 filename.setStringValue(path);
570 GlobalData.fdb.getPackageList().addNewFilename();
571 GlobalData.fdb.getPackageList().setFilenameArray(GlobalData.fdb.getPackageList().sizeOfFilenameArray() - 1,
572 filename);
573 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
574 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
575 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
576 }
577
578 /**
579 Add input package into database
580
581 @param id
582 * @throws Exception
583
584 **/
585 public void addPlatformToDatabase(PlatformIdentification id) throws Exception {
586 String path = id.getPath();
587 path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
588
589 DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
590 filename.setStringValue(path);
591 GlobalData.fdb.getPlatformList().addNewFilename();
592 GlobalData.fdb.getPlatformList().setFilenameArray(GlobalData.fdb.getPlatformList().sizeOfFilenameArray() - 1,
593 filename);
594 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
595 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
596 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
597 }
598
599 /**
600 Get all file's path from one module
601
602 @param path
603 @return
604 @throws IOException
605 @throws XmlException
606 @throws Exception
607
608 **/
609 public Vector<String> getAllFilesPathOfModule(String path) {
610 Vector<String> v = new Vector<String>();
611 path = Tools.convertPathToCurrentOsType(path);
612 v.addElement(path);
613 ModuleSurfaceArea msa = GlobalData.openingModuleList
614 .getModuleSurfaceAreaFromId(GlobalData.openingModuleList
615 .getIdByPath(path));
616 if (msa != null) {
617 //
618 // Get all files' path of a module
619 //
620 SourceFiles sf = msa.getSourceFiles();
621 if (sf != null) {
622 for (int index = 0; index < sf.getFilenameList().size(); index++) {
623 String temp = sf.getFilenameList().get(index).getStringValue();
624 temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp;
625 v.addElement(Tools.convertPathToCurrentOsType(temp));
626 }
627 }
628 }
629
630 return v;
631 }
632
633 /**
634 Get all file's path from one package
635
636 @param path
637 @return
638 @throws IOException
639 @throws XmlException
640 @throws Exception
641
642 **/
643 public Vector<String> getAllFilesPathOfPakcage(String path) {
644 Vector<String> v = new Vector<String>();
645 path = Tools.convertPathToCurrentOsType(path);
646 //
647 // First add package
648 //
649 v.addElement(path);
650
651 //
652 // Add the package's industry std includes one by one
653 //
654 Vector<String> f1 = new Vector<String>();
655 f1 = getAllIndustryStdIncludesOfPackage(path);
656 for (int index = 0; index < f1.size(); index++) {
657 v.addElement(f1.get(index));
658 }
659
660 //
661 // Add module's files one by one
662 //
663 f1 = new Vector<String>();
664 f1 = getAllModulesOfPackage(path);
665 for (int indexI = 0; indexI < f1.size(); indexI++) {
666 Vector<String> f2 = getAllFilesPathOfModule(f1.get(indexI));
667 for (int indexJ = 0; indexJ < f2.size(); indexJ++) {
668 v.addElement(f2.get(indexJ));
669 }
670 }
671
672 return v;
673 }
674 }