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