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