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