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