]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java
1. Merge ModuleDefinitions to MsaHeader
[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
298 v.addElement(id);
299 }
300 Sort.sortModules(v, DataType.SORT_TYPE_ASCENDING);
301 return v;
302 }
303
304 /**
305 Get all module basic information form the FrameworkDatabase.db file
306
307 @return vModuleList A vector includes all modules' basic information
308
309 */
310 public Vector<ModuleIdentification> getAllModules() {
311 return GlobalData.vModuleList;
312 }
313
314 /**
315 Get all platform basic information form the FrameworkDatabase.db file
316
317 @return vplatformList A vector includes all platforms' basic information
318
319 */
320 public Vector<PlatformIdentification> getAllPlatforms() {
321 return GlobalData.vPlatformList;
322 }
323
324 /**
325 Get all Library Class Definitions from a package
326
327 @return Vector
328 **/
329 public Vector<String> getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd) {
330 Vector<String> vector = new Vector<String>();
331 if (spd.getLibraryClassDeclarations() != null) {
332 if (spd.getLibraryClassDeclarations().getLibraryClassList().size() > 0) {
333 for (int index = 0; index < spd.getLibraryClassDeclarations().getLibraryClassList().size(); index++) {
334 vector.addElement(spd.getLibraryClassDeclarations().getLibraryClassList().get(index).getName());
335 }
336 }
337 }
338 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
339 return vector;
340 }
341
342 /**
343 Get all Protocol Definitions from a package
344
345 @return Vector
346 **/
347 public Vector<String> getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd) {
348 Vector<String> vector = new Vector<String>();
349 if (spd.getProtocolDeclarations() != null) {
350 if (spd.getProtocolDeclarations().getEntryList().size() > 0) {
351 for (int index = 0; index < spd.getProtocolDeclarations().getEntryList().size(); index++) {
352 vector.addElement(spd.getProtocolDeclarations().getEntryList().get(index).getCName());
353 }
354 }
355 }
356 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
357 return vector;
358 }
359
360 /**
361 Get all Ppi Definitions from a package
362
363 @return Vector
364 **/
365 public Vector<String> getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd) {
366 Vector<String> vector = new Vector<String>();
367 if (spd.getPpiDeclarations() != null) {
368 if (spd.getPpiDeclarations().getEntryList().size() > 0) {
369 for (int index = 0; index < spd.getPpiDeclarations().getEntryList().size(); index++) {
370 vector.addElement(spd.getPpiDeclarations().getEntryList().get(index).getCName());
371 }
372 }
373 }
374 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
375 return vector;
376 }
377
378 /**
379 Get all Guid Definitions from a package
380
381 @return Vector
382 **/
383 public Vector<String> getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd) {
384 Vector<String> vector = new Vector<String>();
385 if (spd.getGuidDeclarations() != null) {
386 if (spd.getGuidDeclarations().getEntryList().size() > 0) {
387 for (int index = 0; index < spd.getGuidDeclarations().getEntryList().size(); index++) {
388 vector.addElement(spd.getGuidDeclarations().getEntryList().get(index).getCName());
389 }
390 }
391 }
392 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
393 return vector;
394 }
395
396 /**
397 Get all Pcd Definitions from a package
398
399 @return Vector
400 **/
401 public PcdVector getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd) {
402 PcdVector vector = new PcdVector();
403 if (spd.getPcdDeclarations() != null) {
404 if (spd.getPcdDeclarations().getPcdEntryList().size() > 0) {
405 for (int index = 0; index < spd.getPcdDeclarations().getPcdEntryList().size(); index++) {
406 String name = spd.getPcdDeclarations().getPcdEntryList().get(index).getCName();
407 String guidCName = spd.getPcdDeclarations().getPcdEntryList().get(index).getTokenSpaceGuidCName();
408 String help = spd.getPcdDeclarations().getPcdEntryList().get(index).getHelpText();
409 Vector<String> type = Tools.convertListToVector(spd.getPcdDeclarations().getPcdEntryList()
410 .get(index).getValidUsage());
411
412 vector.addPcd(new PcdIdentification(name, guidCName, help, type));
413 }
414 }
415 }
416 Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING);
417 return vector;
418 }
419
420 public Vector<String> getAllLibraryClassDefinitionsFromWorkspace() {
421 Vector<String> vector = new Vector<String>();
422 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
423 Vector<String> v = getAllLibraryClassDefinitionsFromPackage(GlobalData.openingPackageList
424 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
425 .get(index)));
426 if (v != null && v.size() > 0) {
427 vector.addAll(v);
428 }
429
430 }
431 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
432 return vector;
433 }
434
435 public Vector<String> getAllProtocolDeclarationsFromWorkspace() {
436 Vector<String> vector = new Vector<String>();
437 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
438 Vector<String> v = getAllProtocolDeclarationsFromPackage(GlobalData.openingPackageList
439 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
440 .get(index)));
441 if (v != null && v.size() > 0) {
442 vector.addAll(v);
443 }
444 }
445 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
446 return vector;
447 }
448
449 public Vector<String> getAllPpiDeclarationsFromWorkspace() {
450 Vector<String> vector = new Vector<String>();
451 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
452 Vector<String> v = getAllPpiDeclarationsFromPackage(GlobalData.openingPackageList
453 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
454 .get(index)));
455 if (v != null && v.size() > 0) {
456 vector.addAll(v);
457 }
458 }
459 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
460 return vector;
461 }
462
463 public Vector<String> getAllGuidDeclarationsFromWorkspace() {
464 Vector<String> vector = new Vector<String>();
465 for (int index = 0; index < GlobalData.vPackageList.size(); index++) {
466 Vector<String> v = getAllGuidDeclarationsFromPackage(GlobalData.openingPackageList
467 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
468 .get(index)));
469 if (v != null && v.size() > 0) {
470 vector.addAll(v);
471 }
472
473 }
474 Sort.sortVectorString(vector, DataType.SORT_TYPE_ASCENDING);
475 return vector;
476 }
477
478 public PcdVector getAllPcdDeclarationsFromWorkspace() {
479 PcdVector vector = new PcdVector();
480 for (int index = 0; index < GlobalData.openingPackageList.size(); index++) {
481 PcdVector v = getAllPcdDeclarationsFromPackage(GlobalData.openingPackageList
482 .getPackageSurfaceAreaFromId(GlobalData.vPackageList
483 .get(index)));
484 if (v != null && v.size() > 0) {
485 vector.addAll(v);
486 }
487
488 }
489 Sort.sortPcds(vector, DataType.SORT_TYPE_ASCENDING);
490 return vector;
491 }
492
493 /**
494 Find a module's package's id
495
496 @param id input module id
497 @return package id
498
499 **/
500 public PackageIdentification getPackageIdByModuleId(Identification id) {
501 Vector<String> modulePaths = new Vector<String>();
502 Identification mid = null;
503 String packagePath = null;
504 String modulePath = null;
505
506 //
507 // For each package, get all modules list
508 //
509 for (int indexI = 0; indexI < GlobalData.vPackageList.size(); indexI++) {
510 packagePath = GlobalData.vPackageList.elementAt(indexI).getPath();
511 modulePaths = this.getAllModulesOfPackage(packagePath);
512 for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {
513 modulePath = modulePaths.get(indexJ);
514 mid = GlobalData.openingModuleList.getIdByPath(modulePath);
515 //
516 // Check id
517 //
518 if (mid.equals(id)) {
519 return GlobalData.vPackageList.elementAt(indexI);
520 }
521
522 }
523 }
524
525 return null;
526 }
527
528 /**
529 Add module information to package surface area
530
531 @param mid
532 @throws IOException
533 @throws XmlException
534 @throws Exception
535
536 **/
537 public void addModuleToPackage(ModuleIdentification mid, PackageSurfaceArea spd) throws IOException, XmlException,
538 Exception {
539 String packagePath = mid.getPackageId().getPath();
540 String modulePath = mid.getPath();
541 if (spd == null) {
542 spd = OpenFile.openSpdFile(packagePath);
543 }
544 MsaFiles msaFile = spd.getMsaFiles();
545 if (msaFile == null) {
546 msaFile = MsaFiles.Factory.newInstance();
547 }
548 packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR));
549 String fn = Tools.getRelativePath(modulePath, packagePath);
550 msaFile.addNewFilename();
551 msaFile.setFilenameArray(msaFile.getFilenameList().size() - 1, fn);
552 spd.setMsaFiles(msaFile);
553 SaveFile.saveSpdFile(mid.getPackageId().getPath(), spd);
554 }
555
556 /**
557 Add input package into database
558
559 @param id
560 * @throws Exception
561
562 **/
563 public void addPackageToDatabase(PackageIdentification id) throws Exception {
564 String path = id.getPath();
565 path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
566
567 DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
568 filename.setStringValue(path);
569 GlobalData.fdb.getPackageList().addNewFilename();
570 GlobalData.fdb.getPackageList().setFilenameArray(GlobalData.fdb.getPackageList().sizeOfFilenameArray() - 1,
571 filename);
572 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
573 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
574 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
575 }
576
577 /**
578 Add input package into database
579
580 @param id
581 * @throws Exception
582
583 **/
584 public void addPlatformToDatabase(PlatformIdentification id) throws Exception {
585 String path = id.getPath();
586 path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace());
587
588 DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance();
589 filename.setStringValue(path);
590 GlobalData.fdb.getPlatformList().addNewFilename();
591 GlobalData.fdb.getPlatformList().setFilenameArray(GlobalData.fdb.getPlatformList().sizeOfFilenameArray() - 1,
592 filename);
593 String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();
594 strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);
595 SaveFile.saveDbFile(strFrameworkDbFilePath, GlobalData.fdb);
596 }
597
598 /**
599 Get all file's path from one module
600
601 @param path
602 @return
603 @throws IOException
604 @throws XmlException
605 @throws Exception
606
607 **/
608 public Vector<String> getAllFilesPathOfModule(String path) {
609 Vector<String> v = new Vector<String>();
610 path = Tools.convertPathToCurrentOsType(path);
611 v.addElement(path);
612 ModuleSurfaceArea msa = GlobalData.openingModuleList
613 .getModuleSurfaceAreaFromId(GlobalData.openingModuleList
614 .getIdByPath(path));
615 if (msa != null) {
616 //
617 // Get all files' path of a module
618 //
619 SourceFiles sf = msa.getSourceFiles();
620 if (sf != null) {
621 for (int index = 0; index < sf.getFilenameList().size(); index++) {
622 String temp = sf.getFilenameList().get(index).getStringValue();
623 temp = Tools.addFileSeparator(Tools.getFilePathOnly(path)) + temp;
624 v.addElement(Tools.convertPathToCurrentOsType(temp));
625 }
626 }
627 }
628
629 return v;
630 }
631
632 /**
633 Get all file's path from one package
634
635 @param path
636 @return
637 @throws IOException
638 @throws XmlException
639 @throws Exception
640
641 **/
642 public Vector<String> getAllFilesPathOfPakcage(String path) {
643 Vector<String> v = new Vector<String>();
644 path = Tools.convertPathToCurrentOsType(path);
645 //
646 // First add package
647 //
648 v.addElement(path);
649
650 //
651 // Add the package's industry std includes one by one
652 //
653 Vector<String> f1 = new Vector<String>();
654 f1 = getAllIndustryStdIncludesOfPackage(path);
655 for (int index = 0; index < f1.size(); index++) {
656 v.addElement(f1.get(index));
657 }
658
659 //
660 // Add module's files one by one
661 //
662 f1 = new Vector<String>();
663 f1 = getAllModulesOfPackage(path);
664 for (int indexI = 0; indexI < f1.size(); indexI++) {
665 Vector<String> f2 = getAllFilesPathOfModule(f1.get(indexI));
666 for (int indexJ = 0; indexJ < f2.size(); indexJ++) {
667 v.addElement(f2.get(indexJ));
668 }
669 }
670
671 return v;
672 }
673 }