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