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