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