]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java
1. Fix EDKT463: When wizard new or clone a msa/spd/fpd, should follow these rules
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / find / FindResultDetailInfo.java
1 /** @file
2
3 The file is used to show detailed information of one of find results
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.awt.event.ActionEvent;
18 import java.awt.event.ComponentEvent;
19 import java.awt.event.WindowEvent;
20 import java.util.Vector;
21
22 import javax.swing.JButton;
23 import javax.swing.JFrame;
24 import javax.swing.JPanel;
25 import javax.swing.JScrollPane;
26 import javax.swing.JTextArea;
27
28 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;
29 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo;
30 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData;
31 import org.tianocore.FrameworkModulesDocument.FrameworkModules;
32 import org.tianocore.LibrariesDocument.Libraries;
33 import org.tianocore.LibrariesDocument.Libraries.Instance;
34 import org.tianocore.LibraryClassDocument.LibraryClass;
35 import org.tianocore.ModuleSADocument.ModuleSA;
36 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
37 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
38 import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;
39 import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData;
40 import org.tianocore.PcdCodedDocument.PcdCoded;
41 import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
42 import org.tianocore.frameworkwizard.common.DataType;
43 import org.tianocore.frameworkwizard.common.GlobalData;
44 import org.tianocore.frameworkwizard.common.Tools;
45 import org.tianocore.frameworkwizard.common.ui.IFrame;
46 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
47 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
48 import org.tianocore.frameworkwizard.workspace.Workspace;
49 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
50
51 public class FindResultDetailInfo extends IFrame {
52
53 ///
54 /// Define class Serial Version UID
55 ///
56 private static final long serialVersionUID = -4888295869041881282L;
57
58 private JPanel jContentPane = null;
59
60 private JScrollPane jScrollPane = null;
61
62 private JTextArea jTextArea = null;
63
64 private JButton jButtonClose = null;
65
66 //
67 // Not for UI
68 //
69 private static String TAB = " ";
70
71 private String reportContent = "";
72
73 private WorkspaceTools wt = new WorkspaceTools();
74
75 /**
76 * This method initializes jScrollPane
77 *
78 * @return javax.swing.JScrollPane
79 */
80 private JScrollPane getJScrollPane() {
81 if (jScrollPane == null) {
82 jScrollPane = new JScrollPane();
83 jScrollPane.setBounds(new java.awt.Rectangle(5, 5, 535, 280));
84 jScrollPane.setPreferredSize(new java.awt.Dimension(535, 280));
85 jScrollPane.setViewportView(getJTextArea());
86 }
87 return jScrollPane;
88 }
89
90 /**
91 * This method initializes jTextArea
92 *
93 * @return javax.swing.JTextArea
94 */
95 private JTextArea getJTextArea() {
96 if (jTextArea == null) {
97 jTextArea = new JTextArea();
98 jTextArea.setEditable(false);
99 }
100 return jTextArea;
101 }
102
103 /**
104 * This method initializes jButtonClose
105 *
106 * @return javax.swing.JButton
107 */
108 private JButton getJButtonClose() {
109 if (jButtonClose == null) {
110 jButtonClose = new JButton();
111 jButtonClose.setBounds(new java.awt.Rectangle(240, 290, 80, 20));
112 jButtonClose.setPreferredSize(new java.awt.Dimension(80, 20));
113 jButtonClose.addActionListener(this);
114 jButtonClose.setText("Close");
115 }
116 return jButtonClose;
117 }
118
119 /**
120
121 @param lci
122
123 **/
124 public FindResultDetailInfo(FindResultId frid) {
125 super();
126 init();
127 this.setTitle(frid.getName());
128 this.jTextArea.setText(createReport(frid));
129 this.jTextArea.setSelectionStart(0);
130 this.jTextArea.setSelectionEnd(0);
131 }
132
133 /**
134
135 @param lci
136
137 **/
138 public FindResultDetailInfo(PcdFindResultId frid) {
139 super();
140 init();
141 this.setTitle(frid.getName());
142 this.jTextArea.setText(createReport(frid));
143 this.jTextArea.setSelectionStart(0);
144 this.jTextArea.setSelectionEnd(0);
145 }
146
147 /**
148 Create detailed information report for pcd
149
150 @param frid
151 @return
152
153 **/
154 private String createReport(PcdFindResultId frid) {
155 String name = frid.getName();
156
157 //
158 // Write Pcd Name
159 //
160 writeReportLn("PCD C Name: " + name);
161
162 //
163 // Wrtie Declared package
164 //
165 writeReportLn("Declared in Package: " + frid.getDeclaredBy().getName() + " ("
166 + Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace()) + ")");
167
168 //
169 // Write Token Space
170 //
171 writeReportLn("Token Space: " + frid.getTokenSpaceGuidCName());
172
173 //
174 // Write Token
175 //
176 writeReportLn("Token: " + frid.getToken());
177
178 //
179 // Write Datum Type
180 //
181 writeReportLn("Datum Type: " + frid.getDatumType());
182
183 //
184 // Write Default Value
185 //
186 writeReportLn("Default Value: " + frid.getValue());
187
188 //
189 // Write Usages
190 //
191 writeReportLn("Valid Usages: " + frid.getUsage());
192
193 //
194 // Write Help Text
195 //
196 writeReportLn("Help Text: ");
197 writeReportLn(TAB + frid.getHelp());
198
199 //
200 // Write an Empty Line
201 //
202 writeReportLn("");
203
204 //
205 // Wriet all modules which use this PCD:
206 //
207 writeReportLn("Modules Coded to Use This PCD: ");
208
209 Vector<ModuleIdentification> vModules = frid.getConsumedModules();
210 if (vModules != null) {
211 for (int index = 0; index < vModules.size(); index++) {
212 //
213 // Write Module Name and Path
214 //
215 writeReportLn(TAB + vModules.get(index).getName() + " ("
216 + Tools.getRelativePath(vModules.get(index).getPath(), Workspace.getCurrentWorkspace())
217 + ")");
218
219 //
220 // Write Module Pcd Info
221 //
222 ModuleSurfaceArea msa = GlobalData.openingModuleList.getModuleSurfaceAreaFromId(vModules.get(index));
223 if (msa != null) {
224 PcdCoded pcdCoded = msa.getPcdCoded();
225 if (pcdCoded != null) {
226 for (int indexOfPcd = 0; indexOfPcd < pcdCoded.getPcdEntryList().size(); indexOfPcd++) {
227 if (pcdCoded.getPcdEntryList().get(indexOfPcd).getCName().equals(name)) {
228 //
229 // Write Pcd Item Type
230 //
231 writeReportLn(TAB + TAB + "PcdItemType: "
232 + pcdCoded.getPcdEntryList().get(indexOfPcd).getPcdItemType().toString());
233
234 //
235 // Write Help Text
236 //
237 writeReportLn(TAB + TAB + "Help Text: ");
238 writeReportLn(TAB + TAB + TAB
239 + pcdCoded.getPcdEntryList().get(indexOfPcd).getHelpText());
240 }
241 }
242 }
243 }
244
245 //
246 // Write an Empty Line
247 //
248 writeReportLn("");
249 }
250 }
251
252 //
253 // Write an Empty Line
254 //
255 writeReportLn("");
256
257 //
258 // Write All Platforms Specifing this PCD
259 //
260 writeReportLn("Platforms Specifing this PCD: ");
261
262 for (int index = 0; index < GlobalData.openingPlatformList.size(); index++) {
263 PlatformSurfaceArea fpd = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index).getXmlFpd();
264 PlatformIdentification pid = GlobalData.openingPlatformList.getOpeningPlatformByIndex(index).getId();
265
266 String tmp = "";
267 //
268 // Get Non-Dynamic Pcd
269 //
270 FrameworkModules fm = fpd.getFrameworkModules();
271 if (fm != null) {
272 for (int indexOfModuleSa = 0; indexOfModuleSa < fm.getModuleSAList().size(); indexOfModuleSa++) {
273 ModuleSA msa = fm.getModuleSAList().get(indexOfModuleSa);
274 if (msa != null) {
275 PcdBuildDefinition p = msa.getPcdBuildDefinition();
276 if (p != null) {
277 if (p.getPcdDataList() != null) {
278
279 for (int indexOfPcd = 0; indexOfPcd < p.getPcdDataList().size(); indexOfPcd++) {
280 PcdData pd = p.getPcdDataList().get(indexOfPcd);
281 //
282 // Find this PCD
283 //
284 if (pd.getCName().equals(name)) {
285 //
286 // Write Module Sa Info
287 //
288 ModuleIdentification moduleSaId = GlobalData
289 .findModuleId(
290 msa.getModuleGuid(),
291 msa
292 .getModuleVersion(),
293 msa.getPackageGuid(),
294 msa
295 .getPackageVersion());
296 tmp = tmp
297 + TAB
298 + TAB
299 + "Module: "
300 + moduleSaId.getName()
301 + " ("
302 + Tools.getRelativePath(moduleSaId.getPath(),
303 Workspace.getCurrentWorkspace()) + ")"
304 + DataType.UNIX_LINE_SEPARATOR;
305 tmp = tmp + TAB + TAB + TAB + "Implementation: " + pd.getItemType().toString()
306 + DataType.UNIX_LINE_SEPARATOR;
307 tmp = tmp + TAB + TAB + TAB + "Specified / Implementation Value: "
308 + pd.getValue() + DataType.UNIX_LINE_SEPARATOR;
309 tmp = tmp + DataType.UNIX_LINE_SEPARATOR;
310 }
311 }
312 }
313 }
314 }
315 }
316 }
317
318 //
319 // Get Dynamic Pcd
320 //
321 DynamicPcdBuildDefinitions dpbd = fpd.getDynamicPcdBuildDefinitions();
322 if (dpbd != null) {
323 for (int indexOfDpbd = 0; indexOfDpbd < dpbd.getPcdBuildDataList().size(); indexOfDpbd++) {
324 PcdBuildData pbd = dpbd.getPcdBuildDataList().get(indexOfDpbd);
325 if (pbd != null) {
326 if (pbd.getCName().equals(name)) {
327 //
328 // Write Dynamic Pcd Build Definition
329 //
330 tmp = tmp + TAB + TAB + "Dynamic Pcd Build Definition: " + DataType.UNIX_LINE_SEPARATOR;
331 if (pbd.getSkuInfoList() != null) {
332 for (int indexOfPcd = 0; indexOfPcd < pbd.getSkuInfoList().size(); indexOfPcd++) {
333 SkuInfo si = pbd.getSkuInfoList().get(indexOfPcd);
334 if (si != null) {
335 tmp = tmp + TAB + TAB + TAB + "Sku Id: " + si.getSkuId().toString()
336 + DataType.UNIX_LINE_SEPARATOR;
337 tmp = tmp + TAB + TAB + TAB + "Variable Name: " + si.getVariableName()
338 + DataType.UNIX_LINE_SEPARATOR;
339 tmp = tmp + TAB + TAB + TAB + "Variable GUID: " + si.getVariableGuid()
340 + DataType.UNIX_LINE_SEPARATOR;
341 tmp = tmp + TAB + TAB + TAB + "Variable Offset: " + si.getVariableOffset()
342 + DataType.UNIX_LINE_SEPARATOR;
343 tmp = tmp + TAB + TAB + TAB + "Hii Default Value: " + si.getHiiDefaultValue()
344 + DataType.UNIX_LINE_SEPARATOR;
345 }
346 }
347 }
348 }
349 }
350 }
351 }
352
353 //
354 // If not empty, write this platform info
355 //
356 if (!Tools.isEmpty(tmp)) {
357 tmp = TAB + "Platform: " + pid.getName() + " ("
358 + Tools.getRelativePath(pid.getPath(), Workspace.getCurrentWorkspace()) + ")"
359 + DataType.UNIX_LINE_SEPARATOR + tmp;
360 this.writeReportLn(tmp);
361 }
362 }
363
364 return reportContent;
365 }
366
367 //
368 // Create detailed information report for library
369 //
370 /**
371
372 @param frid
373 @return
374
375 **/
376 private String createReport(FindResultId frid) {
377 String tmp = "";
378 String name = frid.getName();
379
380 //
381 // Write Class Name
382 //
383 writeReportLn(name);
384
385 //
386 // Write Provided Package
387 //
388 writeReportLn(TAB + "Provided by: " + frid.getDeclaredBy().getName() + " ("
389 + Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace()) + ")");
390
391 //
392 // Write Header File
393 //
394 PackageSurfaceArea spd = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(frid.getDeclaredBy());
395 tmp = Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace());
396 writeReportLn(TAB + "Header File: " + Tools.getFilePathOnly(tmp)
397 + wt.getHeaderFileFromPackageByLibraryClassName(spd, name));
398
399 //
400 // Write Supported Module Types
401 //
402 writeReportLn(TAB + "Supported Module Types: " + Tools.convertVectorToString(frid.getModuleType()));
403
404 //
405 // Write Supported Arch
406 //
407 writeReportLn(TAB + "Supported Architectures: " + Tools.convertVectorToString(frid.getArch()));
408
409 //
410 // Write Help Text
411 //
412 writeReportLn(TAB + "Help Text: ");
413 writeReportLn(TAB + TAB + frid.getHelp());
414
415 //
416 // Write an empty line
417 //
418 writeReportLn("");
419
420 //
421 // Write Instances
422 //
423 writeReportLn("Library Instances:");
424
425 //
426 // Write Instances One by One
427 //
428 for (int index = 0; index < frid.getProducedModules().size(); index++) {
429 ModuleIdentification mid = frid.getProducedModules().get(index);
430 ModuleSurfaceArea msa = GlobalData.openingModuleList.getModuleSurfaceAreaFromId(mid);
431 if (msa != null) {
432 //
433 // Write Instance Name
434 //
435 if (msa.getMsaHeader() != null) {
436 writeReportLn(TAB + msa.getMsaHeader().getModuleName());
437 }
438
439 //
440 // Write Msa File Name
441 //
442 writeReportLn(TAB + TAB + "Provided by: "
443 + Tools.getRelativePath(mid.getPath(), Workspace.getCurrentWorkspace()));
444
445 //
446 // Find the produced library class
447 //
448 if (msa.getLibraryClassDefinitions() != null) {
449 for (int indexL = 0; indexL < msa.getLibraryClassDefinitions().getLibraryClassList().size(); indexL++) {
450 LibraryClass lc = msa.getLibraryClassDefinitions().getLibraryClassList().get(indexL);
451 if (lc.getKeyword().equals(name)) {
452 //
453 // Write Supported Module Types
454 //
455 writeReportLn(TAB + TAB + "Supported Module Types: "
456 + Tools.convertListToString(lc.getSupModuleList()));
457
458 //
459 // Write Supported Arch
460 //
461 writeReportLn(TAB + TAB + "Supported Architectures: "
462 + Tools.convertListToString(lc.getSupArchList()));
463
464 //
465 // Write Help Text
466 //
467 writeReportLn(TAB + TAB + "Help Text: ");
468 writeReportLn(TAB + TAB + (lc.getHelpText() == null ? "" : lc.getHelpText()));
469 }
470 }
471 }
472
473 }
474 }
475
476 //
477 // Write an empty line
478 //
479 writeReportLn("");
480
481 //
482 // Write all modules which consumed this library
483 //
484 writeReportLn("Modules Requiring " + name + ":");
485 for (int index = 0; index < frid.getConsumedModules().size(); index++) {
486 //
487 // Write
488 //
489 writeReportLn(TAB
490 + frid.getConsumedModules().get(index).getName()
491 + " ("
492 + Tools.getRelativePath(frid.getConsumedModules().get(index).getPath(),
493 Workspace.getCurrentWorkspace()) + ")");
494 }
495
496 //
497 // Write an empty line
498 //
499 writeReportLn("");
500
501 //
502 // Write platforms using the library class instances
503 //
504 writeReportLn("Platforms Using " + name + ":");
505
506 //
507 // Write Instances One by One as Using Platforms
508 //
509 for (int index = 0; index < frid.getProducedModules().size(); index++) {
510 ModuleIdentification mid = frid.getProducedModules().get(index);
511
512 //
513 // Write Instance Name
514 //
515 writeReportLn(TAB + mid.getName());
516
517 //
518 // Go through each platform one by one
519 //
520 for (int indexOfPlatform = 0; indexOfPlatform < GlobalData.openingPlatformList.size(); indexOfPlatform++) {
521 PlatformSurfaceArea fpd = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
522 .getXmlFpd();
523 PlatformIdentification pid = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
524 .getId();
525 Vector<ModuleIdentification> vModuleSa = new Vector<ModuleIdentification>();
526 if (fpd != null) {
527 FrameworkModules fm = fpd.getFrameworkModules();
528 if (fm != null) {
529 for (int indexOfModule = 0; indexOfModule < fm.getModuleSAList().size(); indexOfModule++) {
530 ModuleSA msa = fm.getModuleSAList().get(indexOfModule);
531 if (msa != null) {
532 Libraries l = msa.getLibraries();
533 if (l != null) {
534 if (l.getInstanceList() != null) {
535 for (int indexOfInstance = 0; indexOfInstance < l.getInstanceList().size(); indexOfInstance++) {
536 Instance i = l.getInstanceList().get(indexOfInstance);
537 if (mid.equals(i.getModuleGuid(), i.getModuleVersion(), i.getPackageGuid(),
538 i.getPackageVersion())) {
539 ModuleIdentification moduleSaId = GlobalData
540 .findModuleId(
541 msa
542 .getModuleGuid(),
543 msa
544 .getModuleVersion(),
545 msa
546 .getPackageGuid(),
547 msa
548 .getPackageVersion());
549 if (moduleSaId != null) {
550 vModuleSa.addElement(moduleSaId);
551 }
552 }
553 }
554 }
555 }
556 }
557 }
558
559 //
560 // Get finded moduleSa in this spd
561 //
562 if (vModuleSa.size() > 0) {
563 writeReportLn(TAB + TAB + pid.getName() + " ("
564 + Tools.getRelativePath(pid.getPath(), Workspace.getCurrentWorkspace()) + ")");
565 for (int indexOfModuleSa = 0; indexOfModuleSa < vModuleSa.size(); indexOfModuleSa++) {
566 writeReportLn(TAB
567 + TAB
568 + TAB
569 + vModuleSa.elementAt(indexOfModuleSa).getName()
570 + " ("
571 + Tools.getRelativePath(vModuleSa.elementAt(indexOfModuleSa).getPath(),
572 Workspace.getCurrentWorkspace()) + ")");
573 }
574 }
575 }
576 }
577 }
578 writeReportLn("");
579 }
580
581 return this.reportContent;
582 }
583
584 /**
585 * This method initializes this
586 *
587 * @return void
588 */
589 private void init() {
590 this.setSize(550, 380);
591 this.setContentPane(getJContentPane());
592 this.setTitle("JFrame");
593 this.setResizable(true);
594 this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
595 this.centerWindow();
596
597 }
598
599 /**
600 * This method initializes jContentPane
601 *
602 * @return javax.swing.JPanel
603 */
604 private JPanel getJContentPane() {
605 if (jContentPane == null) {
606 jContentPane = new JPanel();
607 jContentPane.setLayout(null);
608 jContentPane.setSize(new java.awt.Dimension(550, 350));
609 jContentPane.add(getJScrollPane(), null);
610 jContentPane.add(getJButtonClose(), null);
611
612 jContentPane.setPreferredSize(new java.awt.Dimension(550, 340));
613 }
614 return jContentPane;
615 }
616
617 /* (non-Javadoc)
618 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
619 *
620 * Override windowClosing to popup warning message to confirm quit
621 *
622 */
623 public void windowClosing(WindowEvent arg0) {
624 this.dispose();
625 }
626
627 /* (non-Javadoc)
628 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
629 *
630 * Override componentResized to resize all components when frame's size is changed
631 */
632 public void componentResized(ComponentEvent arg0) {
633 int intCurrentWidth = this.getJContentPane().getWidth();
634 int intCurrentHeight = this.getJContentPane().getHeight();
635 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
636 int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
637
638 Tools.resizeComponent(this.jScrollPane, intCurrentWidth, intCurrentHeight, intPreferredWidth,
639 intPreferredHeight);
640 Tools.centerComponent(this.jButtonClose, intCurrentWidth, intCurrentHeight, intPreferredHeight,
641 DataType.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON);
642 }
643
644 /* (non-Javadoc)
645 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
646 *
647 */
648 public void actionPerformed(ActionEvent arg0) {
649 if (arg0.getSource() == this.jButtonClose) {
650 this.dispose();
651 }
652 }
653
654 private void writeReportLn(String line) {
655 this.reportContent = this.reportContent + line + DataType.LINE_SEPARATOR;
656 }
657 }