]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/Find.java
1. Fix EDKT339 Library Class Search need to get info for selected library class
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / find / Find.java
CommitLineData
55e83b18 1/** @file\r
2\r
3 The file is used to provide Find funtions in 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.common.find;\r
16\r
17import java.util.Vector;\r
18\r
419558bb 19import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass;\r
55e83b18 20import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
21import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
22import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;\r
23import org.tianocore.frameworkwizard.common.DataType;\r
24import org.tianocore.frameworkwizard.common.GlobalData;\r
25import org.tianocore.frameworkwizard.common.Sort;\r
26import org.tianocore.frameworkwizard.common.Tools;\r
27import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
28import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsIdentification;\r
29import org.tianocore.frameworkwizard.module.Identifications.Guids.GuidsVector;\r
30import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;\r
31import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;\r
32import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedIdentification;\r
33import org.tianocore.frameworkwizard.module.Identifications.PcdCoded.PcdCodedVector;\r
34import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisIdentification;\r
35import org.tianocore.frameworkwizard.module.Identifications.Ppis.PpisVector;\r
36import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;\r
37import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsVector;\r
38import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
39\r
40public class Find {\r
41\r
42 private final static String SEPERATOR = ".";\r
43\r
44 /**\r
45 Get all ppi entries from workspace\r
46 \r
47 @return\r
48 \r
49 **/\r
50 public static PpisVector getAllPpisVector() {\r
51 PpisVector pv = new PpisVector();\r
52 ModuleSurfaceArea msa = null;\r
53 ModuleIdentification mid = null;\r
54 PpisIdentification pid = null;\r
55\r
56 //\r
57 // Go through each module one by one\r
58 //\r
59 if (GlobalData.openingModuleList.size() > 0) {\r
60 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {\r
61 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();\r
62 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();\r
63\r
64 if (msa.getPPIs() != null) {\r
65 if (msa.getPPIs().getPpiList().size() > 0) {\r
66 for (int index = 0; index < msa.getPPIs().getPpiList().size(); index++) {\r
67 String arg0 = msa.getPPIs().getPpiList().get(index).getPpiCName();\r
68 String arg1 = DataType.PPI_TYPE_PPI;\r
69 String arg2 = null;\r
70 if (msa.getPPIs().getPpiList().get(index).getUsage() != null) {\r
71 arg2 = msa.getPPIs().getPpiList().get(index).getUsage().toString();\r
72 }\r
73\r
74 String arg3 = msa.getPPIs().getPpiList().get(index).getFeatureFlag();\r
75 Vector<String> arg4 = Tools.convertListToVector(msa.getPPIs().getPpiList().get(index)\r
76 .getSupArchList());\r
77 String arg5 = msa.getPPIs().getPpiList().get(index).getHelpText();\r
78\r
79 pid = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
80 pid.setBelongModule(mid);\r
81\r
82 //\r
83 // Find which package declares it\r
84 //\r
85 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
86 PackageSurfaceArea spd = GlobalData.openingPackageList\r
87 .getOpeningPackageByIndex(\r
88 indexOfPackage)\r
89 .getXmlSpd();\r
90 PackageIdentification packageId = GlobalData.openingPackageList\r
91 .getOpeningPackageByIndex(\r
92 indexOfPackage)\r
93 .getId();\r
94 if (spd.getPpiDeclarations() != null) {\r
95 for (int indexOfPpis = 0; indexOfPpis < spd.getPpiDeclarations().getEntryList()\r
96 .size(); indexOfPpis++) {\r
97 if (spd.getPpiDeclarations().getEntryList().get(indexOfPpis).getCName()\r
98 .equals(arg0)) {\r
99 pid.setDeclaredBy(packageId);\r
100 break;\r
101 }\r
102 }\r
103 }\r
104 }\r
105 if (pid.getDeclaredBy() == null) {\r
106 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
107 }\r
108\r
109 pv.addPpis(pid);\r
110 }\r
111 }\r
112 if (msa.getPPIs().getPpiNotifyList().size() > 0) {\r
113 for (int index = 0; index < msa.getPPIs().getPpiNotifyList().size(); index++) {\r
114 String arg0 = msa.getPPIs().getPpiNotifyList().get(index).getPpiNotifyCName();\r
115 String arg1 = DataType.PPI_TYPE_PPI_NOTIFY;\r
116 String arg2 = null;\r
117 if (msa.getPPIs().getPpiNotifyList().get(index).getUsage() != null) {\r
118 arg2 = msa.getPPIs().getPpiNotifyList().get(index).getUsage().toString();\r
119 }\r
120\r
121 String arg3 = msa.getPPIs().getPpiNotifyList().get(index).getFeatureFlag();\r
122 Vector<String> arg4 = Tools.convertListToVector(msa.getPPIs().getPpiNotifyList().get(index)\r
123 .getSupArchList());\r
124 String arg5 = msa.getPPIs().getPpiNotifyList().get(index).getHelpText();\r
125\r
126 pid = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
127 pid.setBelongModule(mid);\r
128\r
129 //\r
130 // Find which package declares it\r
131 //\r
132 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
133 PackageSurfaceArea spd = GlobalData.openingPackageList\r
134 .getOpeningPackageByIndex(\r
135 indexOfPackage)\r
136 .getXmlSpd();\r
137 PackageIdentification packageId = GlobalData.openingPackageList\r
138 .getOpeningPackageByIndex(\r
139 indexOfPackage)\r
140 .getId();\r
141 if (spd.getPpiDeclarations() != null) {\r
142 for (int indexOfPpis = 0; indexOfPpis < spd.getPpiDeclarations().getEntryList()\r
143 .size(); indexOfPpis++) {\r
144 if (spd.getPpiDeclarations().getEntryList().get(indexOfPpis).getCName()\r
145 .equals(arg0)) {\r
146 pid.setDeclaredBy(packageId);\r
147 break;\r
148 }\r
149 }\r
150 }\r
151 }\r
152 if (pid.getDeclaredBy() == null) {\r
153 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
154 }\r
155\r
156 pv.addPpis(pid);\r
157 }\r
158 }\r
159 }\r
160 }\r
161 }\r
162 Sort.sortPpis(pv, DataType.SORT_TYPE_ASCENDING);\r
163 return pv;\r
164 }\r
165\r
166 /**\r
167 Re-org all ppi entries for find table\r
168 \r
169 @return\r
170 \r
171 **/\r
172 public static Vector<PpiId> getAllPpisForFind() {\r
173 Vector<PpiId> ppi = new Vector<PpiId>();\r
174 PpisVector pv = Find.getAllPpisVector();\r
175 boolean isAdded = false;\r
176 boolean isProduced = false;\r
177\r
178 //\r
179 // Go through pv to add item as new format to ppi one by one\r
180 //\r
181 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
182 isAdded = false;\r
183 PpisIdentification pvId = pv.getPpis(indexOfPv);\r
184\r
185 //\r
186 // First check if produced or not\r
187 //\r
188 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
189 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
190 isProduced = true;\r
191 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
192 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
193 isProduced = false;\r
194 }\r
195\r
196 //\r
197 // Get the sting "PackageName.ModuleName" \r
198 //\r
199 String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
200\r
201 //\r
202 // Check if the item has been added in\r
203 // If added, append package name and new module name\r
204 // If not added, add a new one first\r
205 //\r
206 for (int indexOfPpi = 0; indexOfPpi < ppi.size(); indexOfPpi++) {\r
207 PpiId ppiId = ppi.get(indexOfPpi);\r
208\r
209 if (pvId.getName().equals(ppiId.getName())) {\r
210 if (isProduced) {\r
211 ppi.get(indexOfPpi).setProducedModules(ppiId.getProducedModules() + "<br>" + tmp);\r
212 } else if (!isProduced) {\r
213 ppi.get(indexOfPpi).setConsumedModules(ppiId.getConsumedModules() + "<br>" + tmp);\r
214 }\r
215 isAdded = true;\r
216 continue;\r
217 }\r
218 }\r
219\r
220 //\r
221 // Add a new one\r
222 //\r
223 if (!isAdded) {\r
224 if (isProduced) {\r
225 ppi\r
226 .addElement(new PpiId(pvId.getName(), pvId.getType(), tmp, null, pvId.getDeclaredBy().getName()));\r
227 } else if (!isProduced) {\r
228 ppi\r
229 .addElement(new PpiId(pvId.getName(), pvId.getType(), null, tmp, pvId.getDeclaredBy().getName()));\r
230 }\r
231 }\r
232 }\r
233\r
234 return ppi;\r
235 }\r
236\r
237 /**\r
238 Get all protocol entries from workspace\r
239 \r
240 @return\r
241 \r
242 **/\r
243 public static ProtocolsVector getAllProtocolsVector() {\r
244 ProtocolsVector pv = new ProtocolsVector();\r
245 ModuleSurfaceArea msa = null;\r
246 ModuleIdentification mid = null;\r
247 ProtocolsIdentification pid = null;\r
248\r
249 //\r
250 // Go through each module one by one\r
251 //\r
252 if (GlobalData.openingModuleList.size() > 0) {\r
253 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {\r
254 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();\r
255 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();\r
256\r
257 if (msa.getProtocols() != null) {\r
258 if (msa.getProtocols().getProtocolList().size() > 0) {\r
259 for (int index = 0; index < msa.getProtocols().getProtocolList().size(); index++) {\r
260 String arg0 = msa.getProtocols().getProtocolList().get(index).getProtocolCName();\r
261 String arg1 = DataType.PROTOCOL_TYPE_PROTOCOL;\r
262 String arg2 = null;\r
263 if (msa.getProtocols().getProtocolList().get(index).getUsage() != null) {\r
264 arg2 = msa.getProtocols().getProtocolList().get(index).getUsage().toString();\r
265 }\r
266\r
267 String arg3 = msa.getProtocols().getProtocolList().get(index).getFeatureFlag();\r
268 Vector<String> arg4 = Tools.convertListToVector(msa.getProtocols().getProtocolList()\r
269 .get(index).getSupArchList());\r
270 String arg5 = msa.getProtocols().getProtocolList().get(index).getHelpText();\r
271\r
272 pid = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
273 pid.setBelongModule(mid);\r
274\r
275 //\r
276 // Find which package declares it\r
277 //\r
278 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
279 PackageSurfaceArea spd = GlobalData.openingPackageList\r
280 .getOpeningPackageByIndex(\r
281 indexOfPackage)\r
282 .getXmlSpd();\r
283 PackageIdentification packageId = GlobalData.openingPackageList\r
284 .getOpeningPackageByIndex(\r
285 indexOfPackage)\r
286 .getId();\r
287 if (spd.getProtocolDeclarations() != null) {\r
288 for (int indexOfProtocols = 0; indexOfProtocols < spd.getProtocolDeclarations()\r
289 .getEntryList().size(); indexOfProtocols++) {\r
290 if (spd.getProtocolDeclarations().getEntryList().get(indexOfProtocols)\r
291 .getCName().equals(arg0)) {\r
292 pid.setDeclaredBy(packageId);\r
293 break;\r
294 }\r
295 }\r
296 }\r
297 }\r
298 if (pid.getDeclaredBy() == null) {\r
299 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
300 }\r
301 pv.addProtocols(pid);\r
302 }\r
303 }\r
304 if (msa.getProtocols().getProtocolNotifyList().size() > 0) {\r
305 for (int index = 0; index < msa.getProtocols().getProtocolNotifyList().size(); index++) {\r
306 String arg0 = msa.getProtocols().getProtocolNotifyList().get(index)\r
307 .getProtocolNotifyCName();\r
308 String arg1 = DataType.PPI_TYPE_PPI_NOTIFY;\r
309 String arg2 = null;\r
310 if (msa.getProtocols().getProtocolNotifyList().get(index).getUsage() != null) {\r
311 arg2 = msa.getProtocols().getProtocolNotifyList().get(index).getUsage().toString();\r
312 }\r
313\r
314 String arg3 = msa.getProtocols().getProtocolNotifyList().get(index).getFeatureFlag();\r
315 Vector<String> arg4 = Tools.convertListToVector(msa.getProtocols().getProtocolNotifyList()\r
316 .get(index).getSupArchList());\r
317 String arg5 = msa.getProtocols().getProtocolNotifyList().get(index).getHelpText();\r
318\r
319 pid = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
320 pid.setBelongModule(mid);\r
321\r
322 //\r
323 // Find which package declares it\r
324 //\r
325 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
326 PackageSurfaceArea spd = GlobalData.openingPackageList\r
327 .getOpeningPackageByIndex(\r
328 indexOfPackage)\r
329 .getXmlSpd();\r
330 PackageIdentification packageId = GlobalData.openingPackageList\r
331 .getOpeningPackageByIndex(\r
332 indexOfPackage)\r
333 .getId();\r
334 if (spd.getProtocolDeclarations() != null) {\r
335 for (int indexOfProtocols = 0; indexOfProtocols < spd.getProtocolDeclarations()\r
336 .getEntryList().size(); indexOfProtocols++) {\r
337 if (spd.getProtocolDeclarations().getEntryList().get(indexOfProtocols)\r
338 .getCName().equals(arg0)) {\r
339 pid.setDeclaredBy(packageId);\r
340 break;\r
341 }\r
342 }\r
343 }\r
344 }\r
345 if (pid.getDeclaredBy() == null) {\r
346 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
347 }\r
348\r
349 pv.addProtocols(pid);\r
350 }\r
351 }\r
352 }\r
353 }\r
354 }\r
355 Sort.sortProtocols(pv, DataType.SORT_TYPE_ASCENDING);\r
356 return pv;\r
357 }\r
358\r
359 /**\r
360 Re-org all protocol entries for find table\r
361 \r
362 @return\r
363 \r
364 **/\r
365 public static Vector<ProtocolId> getAllProtocolsForFind() {\r
366 Vector<ProtocolId> protocol = new Vector<ProtocolId>();\r
367 ProtocolsVector pv = Find.getAllProtocolsVector();\r
368 boolean isAdded = false;\r
369 boolean isProduced = false;\r
370\r
371 //\r
372 // Go through pv to add item as new format to ppi one by one\r
373 //\r
374 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
375 isAdded = false;\r
376 ProtocolsIdentification pvId = pv.getProtocols(indexOfPv);\r
377\r
378 //\r
379 // First check if produced or not\r
380 //\r
381 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
382 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
383 isProduced = true;\r
384 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
385 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
386 isProduced = false;\r
387 }\r
388\r
389 //\r
390 // Get the sting "PackageName.ModuleName" \r
391 //\r
392 String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
393\r
394 //\r
395 // Check if the item has been added in\r
396 // If added, append package name and new module name\r
397 // If not added, add a new one first\r
398 //\r
399 for (int indexOfProtocol = 0; indexOfProtocol < protocol.size(); indexOfProtocol++) {\r
400 ProtocolId protocolId = protocol.get(indexOfProtocol);\r
401\r
402 if (pvId.getName().equals(protocolId.getName())) {\r
403 if (isProduced) {\r
404 protocol.get(indexOfProtocol)\r
405 .setProducedModules(protocolId.getProducedModules() + "<br>" + tmp);\r
406 } else if (!isProduced) {\r
407 protocol.get(indexOfProtocol)\r
408 .setConsumedModules(protocolId.getConsumedModules() + "<br>" + tmp);\r
409 }\r
410 isAdded = true;\r
411 continue;\r
412 }\r
413 }\r
414\r
415 //\r
416 // Add a new one\r
417 //\r
418 if (!isAdded) {\r
419 if (isProduced) {\r
420 protocol.addElement(new ProtocolId(pvId.getName(), pvId.getType(), tmp, null, pvId.getDeclaredBy()\r
421 .getName()));\r
422 } else if (!isProduced) {\r
423 protocol.addElement(new ProtocolId(pvId.getName(), pvId.getType(), null, tmp, pvId.getDeclaredBy()\r
424 .getName()));\r
425 }\r
426 }\r
427 }\r
428\r
429 return protocol;\r
430 }\r
431\r
432 /**\r
433 Get all protocol entries from workspace\r
434 \r
435 @return\r
436 \r
437 **/\r
438 public static GuidsVector getAllGuidsVector() {\r
439 GuidsVector gv = new GuidsVector();\r
440 ModuleSurfaceArea msa = null;\r
441 ModuleIdentification mid = null;\r
442 GuidsIdentification gid = null;\r
443\r
444 //\r
445 // Go through each module one by one\r
446 //\r
447 if (GlobalData.openingModuleList.size() > 0) {\r
448 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {\r
449 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();\r
450 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();\r
451\r
452 if (msa.getGuids() != null) {\r
453 if (msa.getGuids().getGuidCNamesList().size() > 0) {\r
454 for (int index = 0; index < msa.getGuids().getGuidCNamesList().size(); index++) {\r
455 String arg0 = msa.getGuids().getGuidCNamesList().get(index).getGuidCName();\r
456 String arg1 = null;\r
457 if (msa.getGuids().getGuidCNamesList().get(index).getUsage() != null) {\r
458 arg1 = msa.getGuids().getGuidCNamesList().get(index).getUsage().toString();\r
459 }\r
460\r
461 String arg2 = msa.getGuids().getGuidCNamesList().get(index).getFeatureFlag();\r
462 Vector<String> arg3 = Tools.convertListToVector(msa.getGuids().getGuidCNamesList()\r
463 .get(index).getSupArchList());\r
464 String arg4 = msa.getGuids().getGuidCNamesList().get(index).getHelpText();\r
465\r
466 gid = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);\r
467 gid.setBelongModule(mid);\r
468\r
469 //\r
470 // Find which package declares it\r
471 //\r
472 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
473 PackageSurfaceArea spd = GlobalData.openingPackageList\r
474 .getOpeningPackageByIndex(\r
475 indexOfPackage)\r
476 .getXmlSpd();\r
477 PackageIdentification packageId = GlobalData.openingPackageList\r
478 .getOpeningPackageByIndex(\r
479 indexOfPackage)\r
480 .getId();\r
481 if (spd.getGuidDeclarations() != null) {\r
482 for (int indexOfGuids = 0; indexOfGuids < spd.getGuidDeclarations().getEntryList()\r
483 .size(); indexOfGuids++) {\r
484 if (spd.getGuidDeclarations().getEntryList().get(indexOfGuids).getCName()\r
485 .equals(arg0)) {\r
486 gid.setDeclaredBy(packageId);\r
487 break;\r
488 }\r
489 }\r
490 }\r
491 }\r
492 if (gid.getDeclaredBy() == null) {\r
493 gid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
494 }\r
495\r
496 gv.addGuids(gid);\r
497 }\r
498 }\r
499 }\r
500 }\r
501 }\r
502 Sort.sortGuids(gv, DataType.SORT_TYPE_ASCENDING);\r
503 return gv;\r
504 }\r
505\r
506 /**\r
507 Re-org all guid entries for find table\r
508 \r
509 @return\r
510 \r
511 **/\r
512 public static Vector<GuidId> getAllGuidsForFind() {\r
513 Vector<GuidId> guid = new Vector<GuidId>();\r
514 GuidsVector gv = Find.getAllGuidsVector();\r
515 boolean isAdded = false;\r
516 boolean isProduced = false;\r
517\r
518 //\r
519 // Go through pv to add item as new format to ppi one by one\r
520 //\r
521 for (int indexOfGv = 0; indexOfGv < gv.size(); indexOfGv++) {\r
522 isAdded = false;\r
523 GuidsIdentification gvId = gv.getGuids(indexOfGv);\r
524\r
525 //\r
526 // First check if produced or not\r
527 //\r
528 if (gvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
529 || gvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
530 isProduced = true;\r
531 } else if (gvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
532 || gvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
533 isProduced = false;\r
534 }\r
535\r
536 //\r
537 // Get the sting "PackageName.ModuleName" \r
538 //\r
539 String tmp = gvId.getBelongModule().getPackageId().getName() + SEPERATOR + gvId.getBelongModule().getName();\r
540\r
541 //\r
542 // Check if the item has been added in\r
543 // If added, append package name and new module name\r
544 // If not added, add a new one first\r
545 //\r
546 for (int indexOfGuid = 0; indexOfGuid < guid.size(); indexOfGuid++) {\r
547 GuidId guidId = guid.get(indexOfGuid);\r
548\r
549 if (gvId.getName().equals(guidId.getName())) {\r
550 if (isProduced) {\r
551 guid.get(indexOfGuid).setProducedModules(guidId.getProducedModules() + "<br>" + tmp);\r
552 } else if (!isProduced) {\r
553 guid.get(indexOfGuid).setConsumedModules(guidId.getConsumedModules() + "<br>" + tmp);\r
554 }\r
555 isAdded = true;\r
556 continue;\r
557 }\r
558 }\r
559\r
560 //\r
561 // Add a new one\r
562 //\r
563 if (!isAdded) {\r
564 if (isProduced) {\r
565 guid.addElement(new GuidId(gvId.getName(), "GUID", tmp, null, gvId.getDeclaredBy().getName()));\r
566 } else if (!isProduced) {\r
567 guid.addElement(new GuidId(gvId.getName(), "GUID", null, tmp, gvId.getDeclaredBy().getName()));\r
568 }\r
569 }\r
570 }\r
571\r
572 return guid;\r
573 }\r
574\r
575 /**\r
576 Get all pcd coded entries from workspace\r
577 \r
578 @return\r
579 \r
580 **/\r
581 public static PcdCodedVector getAllPcdCodedVector() {\r
582 PcdCodedVector pv = new PcdCodedVector();\r
583 ModuleSurfaceArea msa = null;\r
584 ModuleIdentification mid = null;\r
585 PcdCodedIdentification pid = null;\r
586\r
587 //\r
588 // Go through each module one by one\r
589 //\r
590 if (GlobalData.openingModuleList.size() > 0) {\r
591 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {\r
592 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();\r
593 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();\r
594\r
595 if (msa.getPcdCoded() != null) {\r
596 if (msa.getPcdCoded().getPcdEntryList().size() > 0) {\r
597 for (int index = 0; index < msa.getPcdCoded().getPcdEntryList().size(); index++) {\r
598\r
599 String arg0 = msa.getPcdCoded().getPcdEntryList().get(index).getCName();\r
600 String arg1 = msa.getPcdCoded().getPcdEntryList().get(index).getTokenSpaceGuidCName();\r
601\r
602 String arg2 = msa.getPcdCoded().getPcdEntryList().get(index).getFeatureFlag();\r
603 Vector<String> arg3 = Tools.convertListToVector(msa.getPcdCoded().getPcdEntryList()\r
604 .get(index).getSupArchList());\r
605\r
606 String arg4 = msa.getPcdCoded().getPcdEntryList().get(index).getDefaultValue();\r
607 String arg5 = msa.getPcdCoded().getPcdEntryList().get(index).getHelpText();\r
608 String arg6 = null;\r
609 if (msa.getPcdCoded().getPcdEntryList().get(index).getPcdItemType() != null) {\r
610 arg6 = msa.getPcdCoded().getPcdEntryList().get(index).getPcdItemType().toString();\r
611 }\r
612 String arg7 = null;\r
613 if (msa.getPcdCoded().getPcdEntryList().get(index).getUsage() != null) {\r
614 arg7 = msa.getPcdCoded().getPcdEntryList().get(index).getUsage().toString();\r
615 }\r
616 pid = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);\r
617 pid.setBelongModule(mid);\r
618\r
619 //\r
620 // Find which package declares it\r
621 //\r
622 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
623 PackageSurfaceArea spd = GlobalData.openingPackageList\r
624 .getOpeningPackageByIndex(\r
625 indexOfPackage)\r
626 .getXmlSpd();\r
627 PackageIdentification packageId = GlobalData.openingPackageList\r
628 .getOpeningPackageByIndex(\r
629 indexOfPackage)\r
630 .getId();\r
631 if (spd.getPcdDeclarations() != null) {\r
632 for (int indexOfPcds = 0; indexOfPcds < spd.getPcdDeclarations().getPcdEntryList()\r
633 .size(); indexOfPcds++) {\r
634 if (spd.getPcdDeclarations().getPcdEntryList().get(indexOfPcds).getCName()\r
635 .equals(arg0)) {\r
636 pid.setDeclaredBy(packageId);\r
637 break;\r
638 }\r
639 }\r
640 }\r
641 }\r
642 if (pid.getDeclaredBy() == null) {\r
643 pid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
644 }\r
645\r
646 pv.addPcdCoded(pid);\r
647 }\r
648 }\r
649 }\r
650 }\r
651 }\r
652 Sort.sortPcdCodeds(pv, DataType.SORT_TYPE_ASCENDING);\r
653 return pv;\r
654 }\r
655\r
656 /**\r
657 Re-org all guid entries for find table\r
658 \r
659 @return\r
660 \r
661 **/\r
662 public static Vector<PcdId> getAllPcdCodedForFind() {\r
663 Vector<PcdId> pcd = new Vector<PcdId>();\r
664 PcdCodedVector pv = Find.getAllPcdCodedVector();\r
665 boolean isAdded = false;\r
666 boolean isProduced = false;\r
667\r
668 //\r
669 // Go through pv to add item as new format to ppi one by one\r
670 //\r
671 for (int indexOfPv = 0; indexOfPv < pv.size(); indexOfPv++) {\r
672 isAdded = false;\r
673 PcdCodedIdentification pvId = pv.getPcdCoded(indexOfPv);\r
674\r
675 //\r
676 // First check if produced or not\r
677 //\r
678 if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
679 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
680 isProduced = true;\r
681 } else if (pvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
682 || pvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
683 isProduced = false;\r
684 }\r
685\r
686 //\r
687 // Get the sting "PackageName.ModuleName" \r
688 //\r
689 String tmp = pvId.getBelongModule().getPackageId().getName() + SEPERATOR + pvId.getBelongModule().getName();\r
690\r
691 //\r
692 // Check if the item has been added in\r
693 // If added, append package name and new module name\r
694 // If not added, add a new one first\r
695 //\r
696 for (int indexOfGuid = 0; indexOfGuid < pcd.size(); indexOfGuid++) {\r
697 PcdId pcdId = pcd.get(indexOfGuid);\r
698\r
699 if (pvId.getName().equals(pcdId.getName())) {\r
700 if (isProduced) {\r
701 pcd.get(indexOfGuid).setProducedModules(pcdId.getProducedModules() + "<br>" + tmp);\r
702 } else if (!isProduced) {\r
703 pcd.get(indexOfGuid).setConsumedModules(pcdId.getConsumedModules() + "<br>" + tmp);\r
704 }\r
705 isAdded = true;\r
706 continue;\r
707 }\r
708 }\r
709\r
710 //\r
711 // Add a new one\r
712 //\r
713 if (!isAdded) {\r
714 if (isProduced) {\r
715 pcd\r
716 .addElement(new PcdId(pvId.getName(), pvId.getType(), tmp, null, pvId.getDeclaredBy().getName()));\r
717 } else if (!isProduced) {\r
718 pcd\r
719 .addElement(new PcdId(pvId.getName(), pvId.getType(), null, tmp, pvId.getDeclaredBy().getName()));\r
720 }\r
721 }\r
722 }\r
723\r
724 return pcd;\r
725 }\r
726\r
727 /**\r
728 Get all library class entries from workspace\r
729 \r
730 @return\r
731 \r
732 **/\r
733 public static LibraryClassVector getAllLibraryClassVector() {\r
734 LibraryClassVector lcv = new LibraryClassVector();\r
735 ModuleSurfaceArea msa = null;\r
736 ModuleIdentification mid = null;\r
737 LibraryClassIdentification lcid = null;\r
738\r
739 //\r
740 // Go through each module one by one\r
741 //\r
742 if (GlobalData.openingModuleList.size() > 0) {\r
743 for (int indexOfModule = 0; indexOfModule < GlobalData.openingModuleList.size(); indexOfModule++) {\r
744 msa = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getXmlMsa();\r
745 mid = GlobalData.openingModuleList.getOpeningModuleByIndex(indexOfModule).getId();\r
746\r
747 if (msa.getLibraryClassDefinitions() != null) {\r
748 LibraryClassDefinitions lcd = msa.getLibraryClassDefinitions();\r
749 if (lcd.getLibraryClassList().size() > 0) {\r
750 for (int index = 0; index < lcd.getLibraryClassList().size(); index++) {\r
751 String name = lcd.getLibraryClassList().get(index).getKeyword();\r
752 String usage = null;\r
753 if (lcd.getLibraryClassList().get(index).getUsage() != null) {\r
754 usage = lcd.getLibraryClassList().get(index).getUsage().toString();\r
755 }\r
756 String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();\r
757 String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();\r
758 String featureFlag = lcd.getLibraryClassList().get(index).getFeatureFlag();\r
759 Vector<String> arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index)\r
760 .getSupArchList());\r
761 Vector<String> module = Tools.convertListToVector(lcd.getLibraryClassList().get(index)\r
762 .getSupModuleList());\r
763 String help = lcd.getLibraryClassList().get(index).getHelpText();\r
764 lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag,\r
765 module, help);\r
766 lcid.setBelongModule(mid);\r
767\r
768 //\r
769 // Find which package declares it\r
770 //\r
771 for (int indexOfPackage = 0; indexOfPackage < GlobalData.openingPackageList.size(); indexOfPackage++) {\r
772 PackageSurfaceArea spd = GlobalData.openingPackageList\r
773 .getOpeningPackageByIndex(\r
774 indexOfPackage)\r
775 .getXmlSpd();\r
776 PackageIdentification packageId = GlobalData.openingPackageList\r
777 .getOpeningPackageByIndex(\r
778 indexOfPackage)\r
779 .getId();\r
780 if (spd.getLibraryClassDeclarations() != null) {\r
781 for (int indexOfLibraryClass = 0; indexOfLibraryClass < spd\r
782 .getLibraryClassDeclarations()\r
783 .getLibraryClassList()\r
784 .size(); indexOfLibraryClass++) {\r
419558bb 785 LibraryClass lc = spd.getLibraryClassDeclarations().getLibraryClassList().get(indexOfLibraryClass);\r
786 if (lc.getName().equals(name)) {\r
787 lcid.setSupArchList(Tools.convertListToVector(lc.getSupArchList()));\r
788 lcid.setSupModuleList(Tools.convertListToVector(lc.getSupModuleList()));\r
789 lcid.setHelp(lc.getHelpText());\r
55e83b18 790 lcid.setDeclaredBy(packageId);\r
791 break;\r
792 }\r
793 }\r
794 }\r
795 }\r
796 if (lcid.getDeclaredBy() == null) {\r
797 lcid.setDeclaredBy(new PackageIdentification("", "", "", ""));\r
798 }\r
799\r
800 lcv.addLibraryClass(lcid);\r
801 }\r
802 }\r
803 }\r
804 }\r
805 }\r
806 Sort.sortLibraryClass(lcv, DataType.SORT_TYPE_ASCENDING);\r
807 return lcv;\r
808 }\r
809\r
810 /**\r
811 Re-org all guid entries for find table\r
812 \r
813 @return\r
814 \r
815 **/\r
419558bb 816 // public static Vector<LibraryClassId> getAllLibraryClassForFind(LibraryClassVector lcv) {\r
817 // Vector<LibraryClassId> libraryClass = new Vector<LibraryClassId>();\r
818 // boolean isAdded = false;\r
819 // boolean isProduced = false;\r
820 //\r
821 // //\r
822 // // Go through pv to add item as new format to ppi one by one\r
823 // //\r
824 // for (int indexOfLcv = 0; indexOfLcv < lcv.size(); indexOfLcv++) {\r
825 // isAdded = false;\r
826 // LibraryClassIdentification lcvId = lcv.getLibraryClass(indexOfLcv);\r
827 //\r
828 // //\r
829 // // First check if produced or not\r
830 // //\r
831 // if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
832 // || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
833 // isProduced = true;\r
834 // } else if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
835 // || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
836 // isProduced = false;\r
837 // }\r
838 //\r
839 // //\r
840 // // Get the string "PackageName.ModuleName" \r
841 // //\r
842 // String tmp = lcvId.getBelongModule().getPackageId().getName() + SEPERATOR\r
843 // + lcvId.getBelongModule().getName();\r
844 //\r
845 // //\r
846 // // Check if the item has been added in\r
847 // // If added, append package name and new module name\r
848 // // If not added, add a new one first\r
849 // //\r
850 // for (int indexOfGuid = 0; indexOfGuid < libraryClass.size(); indexOfGuid++) {\r
851 // LibraryClassId lcId = libraryClass.get(indexOfGuid);\r
852 //\r
853 // if (lcvId.getLibraryClassName().equals(lcId.getName())) {\r
854 // if (isProduced) {\r
855 // libraryClass.get(indexOfGuid).setProducedModules(lcId.getProducedModules() + "<br>" + tmp);\r
856 // } else if (!isProduced) {\r
857 // libraryClass.get(indexOfGuid).setConsumedModules(lcId.getConsumedModules() + "<br>" + tmp);\r
858 // }\r
859 // isAdded = true;\r
860 // continue;\r
861 // }\r
862 // }\r
863 //\r
864 // //\r
865 // // Add a new one\r
866 // //\r
867 // if (!isAdded) {\r
868 // if (isProduced) {\r
869 // libraryClass.addElement(new LibraryClassId(lcvId.getLibraryClassName(), "Library Class", tmp, null,\r
870 // lcvId.getDeclaredBy().getName()));\r
871 // } else if (!isProduced) {\r
872 // libraryClass.addElement(new LibraryClassId(lcvId.getLibraryClassName(), "Library Class", null, tmp,\r
873 // lcvId.getDeclaredBy().getName()));\r
874 // }\r
875 // }\r
876 // }\r
877 //\r
878 // return libraryClass;\r
879 // }\r
880 public static Vector<FindResultId> getAllLibraryClassForFind(LibraryClassVector lcv) {\r
881 Vector<FindResultId> libraryClass = new Vector<FindResultId>();\r
55e83b18 882 boolean isAdded = false;\r
883 boolean isProduced = false;\r
884\r
885 //\r
886 // Go through pv to add item as new format to ppi one by one\r
887 //\r
888 for (int indexOfLcv = 0; indexOfLcv < lcv.size(); indexOfLcv++) {\r
889 isAdded = false;\r
890 LibraryClassIdentification lcvId = lcv.getLibraryClass(indexOfLcv);\r
891\r
892 //\r
893 // First check if produced or not\r
894 //\r
895 if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
896 || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
897 isProduced = true;\r
898 } else if (lcvId.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED)\r
899 || lcvId.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
900 isProduced = false;\r
901 }\r
902\r
55e83b18 903 //\r
904 // Check if the item has been added in\r
905 // If added, append package name and new module name\r
906 // If not added, add a new one first\r
907 //\r
908 for (int indexOfGuid = 0; indexOfGuid < libraryClass.size(); indexOfGuid++) {\r
419558bb 909 FindResultId frId = libraryClass.get(indexOfGuid);\r
55e83b18 910\r
419558bb 911 if (lcvId.getLibraryClassName().equals(frId.getName())) {\r
55e83b18 912 if (isProduced) {\r
419558bb 913 libraryClass.get(indexOfGuid).addProducedModules(lcvId.getBelongModule());\r
55e83b18 914 } else if (!isProduced) {\r
419558bb 915 libraryClass.get(indexOfGuid).addConsumedModules(lcvId.getBelongModule());\r
55e83b18 916 }\r
917 isAdded = true;\r
918 continue;\r
919 }\r
920 }\r
921\r
922 //\r
923 // Add a new one\r
924 //\r
925 if (!isAdded) {\r
419558bb 926 libraryClass.addElement(new FindResultId(lcvId.getLibraryClassName(), "Library Class",\r
927 lcvId.getSupArchList(), lcvId.getHelp(),\r
928 lcvId.getSupModuleList(), lcvId.getDeclaredBy()));\r
55e83b18 929 }\r
930 }\r
931\r
932 return libraryClass;\r
933 }\r
934}\r