1. Fix EDKT457 Multiple FPD, MSA or SPD files in a directory is prohibited
[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 .findModuleIdByGuidVersion(
290 msa
291 .getModuleGuid(),
292 msa
293 .getModuleVersion(),
294 msa
295 .getPackageGuid(),
296 msa
297 .getPackageVersion());
298 tmp = tmp
299 + TAB
300 + TAB
301 + "Module: "
302 + moduleSaId.getName()
303 + " ("
304 + Tools.getRelativePath(moduleSaId.getPath(),
305 Workspace.getCurrentWorkspace()) + ")"
306 + DataType.UNIX_LINE_SEPARATOR;
307 tmp = tmp + TAB + TAB + TAB + "Implementation: " + pd.getItemType().toString()
308 + DataType.UNIX_LINE_SEPARATOR;
309 tmp = tmp + TAB + TAB + TAB + "Specified / Implementation Value: "
310 + pd.getValue() + DataType.UNIX_LINE_SEPARATOR;
311 tmp = tmp + DataType.UNIX_LINE_SEPARATOR;
312 }
313 }
314 }
315 }
316 }
317 }
318 }
319
320 //
321 // Get Dynamic Pcd
322 //
323 DynamicPcdBuildDefinitions dpbd = fpd.getDynamicPcdBuildDefinitions();
324 if (dpbd != null) {
325 for (int indexOfDpbd = 0; indexOfDpbd < dpbd.getPcdBuildDataList().size(); indexOfDpbd++) {
326 PcdBuildData pbd = dpbd.getPcdBuildDataList().get(indexOfDpbd);
327 if (pbd != null) {
328 if (pbd.getCName().equals(name)) {
329 //
330 // Write Dynamic Pcd Build Definition
331 //
332 tmp = tmp + TAB + TAB + "Dynamic Pcd Build Definition: " + DataType.UNIX_LINE_SEPARATOR;
333 if (pbd.getSkuInfoList() != null) {
334 for (int indexOfPcd = 0; indexOfPcd < pbd.getSkuInfoList().size(); indexOfPcd++) {
335 SkuInfo si = pbd.getSkuInfoList().get(indexOfPcd);
336 if (si != null) {
337 tmp = tmp + TAB + TAB + TAB + "Sku Id: " + si.getSkuId().toString()
338 + DataType.UNIX_LINE_SEPARATOR;
339 tmp = tmp + TAB + TAB + TAB + "Variable Name: " + si.getVariableName()
340 + DataType.UNIX_LINE_SEPARATOR;
341 tmp = tmp + TAB + TAB + TAB + "Variable GUID: " + si.getVariableGuid()
342 + DataType.UNIX_LINE_SEPARATOR;
343 tmp = tmp + TAB + TAB + TAB + "Variable Offset: " + si.getVariableOffset()
344 + DataType.UNIX_LINE_SEPARATOR;
345 tmp = tmp + TAB + TAB + TAB + "Hii Default Value: " + si.getHiiDefaultValue()
346 + DataType.UNIX_LINE_SEPARATOR;
347 }
348 }
349 }
350 }
351 }
352 }
353 }
354
355 //
356 // If not empty, write this platform info
357 //
358 if (!Tools.isEmpty(tmp)) {
359 tmp = TAB + "Platform: " + pid.getName() + " ("
360 + Tools.getRelativePath(pid.getPath(), Workspace.getCurrentWorkspace()) + ")"
361 + DataType.UNIX_LINE_SEPARATOR + tmp;
362 this.writeReportLn(tmp);
363 }
364 }
365
366 return reportContent;
367 }
368
369 //
370 // Create detailed information report for library
371 //
372 /**
373
374 @param frid
375 @return
376
377 **/
378 private String createReport(FindResultId frid) {
379 String tmp = "";
380 String name = frid.getName();
381
382 //
383 // Write Class Name
384 //
385 writeReportLn(name);
386
387 //
388 // Write Provided Package
389 //
390 writeReportLn(TAB + "Provided by: " + frid.getDeclaredBy().getName() + " ("
391 + Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace()) + ")");
392
393 //
394 // Write Header File
395 //
396 PackageSurfaceArea spd = GlobalData.openingPackageList.getPackageSurfaceAreaFromId(frid.getDeclaredBy());
397 tmp = Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace());
398 writeReportLn(TAB + "Header File: " + Tools.getFilePathOnly(tmp)
399 + wt.getHeaderFileFromPackageByLibraryClassName(spd, name));
400
401 //
402 // Write Supported Module Types
403 //
404 writeReportLn(TAB + "Supported Module Types: " + Tools.convertVectorToString(frid.getModuleType()));
405
406 //
407 // Write Supported Arch
408 //
409 writeReportLn(TAB + "Supported Architectures: " + Tools.convertVectorToString(frid.getArch()));
410
411 //
412 // Write Help Text
413 //
414 writeReportLn(TAB + "Help Text: ");
415 writeReportLn(TAB + TAB + frid.getHelp());
416
417 //
418 // Write an empty line
419 //
420 writeReportLn("");
421
422 //
423 // Write Instances
424 //
425 writeReportLn("Library Instances:");
426
427 //
428 // Write Instances One by One
429 //
430 for (int index = 0; index < frid.getProducedModules().size(); index++) {
431 ModuleIdentification mid = frid.getProducedModules().get(index);
432 ModuleSurfaceArea msa = GlobalData.openingModuleList.getModuleSurfaceAreaFromId(mid);
433 if (msa != null) {
434 //
435 // Write Instance Name
436 //
437 if (msa.getMsaHeader() != null) {
438 writeReportLn(TAB + msa.getMsaHeader().getModuleName());
439 }
440
441 //
442 // Write Msa File Name
443 //
444 writeReportLn(TAB + TAB + "Provided by: "
445 + Tools.getRelativePath(mid.getPath(), Workspace.getCurrentWorkspace()));
446
447 //
448 // Find the produced library class
449 //
450 if (msa.getLibraryClassDefinitions() != null) {
451 for (int indexL = 0; indexL < msa.getLibraryClassDefinitions().getLibraryClassList().size(); indexL++) {
452 LibraryClass lc = msa.getLibraryClassDefinitions().getLibraryClassList().get(indexL);
453 if (lc.getKeyword().equals(name)) {
454 //
455 // Write Supported Module Types
456 //
457 writeReportLn(TAB + TAB + "Supported Module Types: "
458 + Tools.convertListToString(lc.getSupModuleList()));
459
460 //
461 // Write Supported Arch
462 //
463 writeReportLn(TAB + TAB + "Supported Architectures: "
464 + Tools.convertListToString(lc.getSupArchList()));
465
466 //
467 // Write Help Text
468 //
469 writeReportLn(TAB + TAB + "Help Text: ");
470 writeReportLn(TAB + TAB + (lc.getHelpText() == null ? "" : lc.getHelpText()));
471 }
472 }
473 }
474
475 }
476 }
477
478 //
479 // Write an empty line
480 //
481 writeReportLn("");
482
483 //
484 // Write all modules which consumed this library
485 //
486 writeReportLn("Modules Requiring " + name + ":");
487 for (int index = 0; index < frid.getConsumedModules().size(); index++) {
488 //
489 // Write
490 //
491 writeReportLn(TAB
492 + frid.getConsumedModules().get(index).getName()
493 + " ("
494 + Tools.getRelativePath(frid.getConsumedModules().get(index).getPath(),
495 Workspace.getCurrentWorkspace()) + ")");
496 }
497
498 //
499 // Write an empty line
500 //
501 writeReportLn("");
502
503 //
504 // Write platforms using the library class instances
505 //
506 writeReportLn("Platforms Using " + name + ":");
507
508 //
509 // Write Instances One by One as Using Platforms
510 //
511 for (int index = 0; index < frid.getProducedModules().size(); index++) {
512 ModuleIdentification mid = frid.getProducedModules().get(index);
513
514 //
515 // Write Instance Name
516 //
517 writeReportLn(TAB + mid.getName());
518
519 //
520 // Go through each platform one by one
521 //
522 for (int indexOfPlatform = 0; indexOfPlatform < GlobalData.openingPlatformList.size(); indexOfPlatform++) {
523 PlatformSurfaceArea fpd = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
524 .getXmlFpd();
525 PlatformIdentification pid = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
526 .getId();
527 Vector<ModuleIdentification> vModuleSa = new Vector<ModuleIdentification>();
528 if (fpd != null) {
529 FrameworkModules fm = fpd.getFrameworkModules();
530 if (fm != null) {
531 for (int indexOfModule = 0; indexOfModule < fm.getModuleSAList().size(); indexOfModule++) {
532 ModuleSA msa = fm.getModuleSAList().get(indexOfModule);
533 if (msa != null) {
534 Libraries l = msa.getLibraries();
535 if (l != null) {
536 if (l.getInstanceList() != null) {
537 for (int indexOfInstance = 0; indexOfInstance < l.getInstanceList().size(); indexOfInstance++) {
538 Instance i = l.getInstanceList().get(indexOfInstance);
539 if (mid.equals(i.getModuleGuid(), i.getModuleVersion(), i.getPackageGuid(),
540 i.getPackageVersion())) {
541 ModuleIdentification moduleSaId = GlobalData
542 .findModuleIdByGuidVersion(
543 msa
544 .getModuleGuid(),
545 msa
546 .getModuleVersion(),
547 msa
548 .getPackageGuid(),
549 msa
550 .getPackageVersion());
551 if (moduleSaId != null) {
552 vModuleSa.addElement(moduleSaId);
553 }
554 }
555 }
556 }
557 }
558 }
559 }
560
561 //
562 // Get finded moduleSa in this spd
563 //
564 if (vModuleSa.size() > 0) {
565 writeReportLn(TAB + TAB + pid.getName() + " ("
566 + Tools.getRelativePath(pid.getPath(), Workspace.getCurrentWorkspace()) + ")");
567 for (int indexOfModuleSa = 0; indexOfModuleSa < vModuleSa.size(); indexOfModuleSa++) {
568 writeReportLn(TAB
569 + TAB
570 + TAB
571 + vModuleSa.elementAt(indexOfModuleSa).getName()
572 + " ("
573 + Tools.getRelativePath(vModuleSa.elementAt(indexOfModuleSa).getPath(),
574 Workspace.getCurrentWorkspace()) + ")");
575 }
576 }
577 }
578 }
579 }
580 writeReportLn("");
581 }
582
583 return this.reportContent;
584 }
585
586 /**
587 * This method initializes this
588 *
589 * @return void
590 */
591 private void init() {
592 this.setSize(550, 380);
593 this.setContentPane(getJContentPane());
594 this.setTitle("JFrame");
595 this.setResizable(true);
596 this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
597 this.centerWindow();
598
599 }
600
601 /**
602 * This method initializes jContentPane
603 *
604 * @return javax.swing.JPanel
605 */
606 private JPanel getJContentPane() {
607 if (jContentPane == null) {
608 jContentPane = new JPanel();
609 jContentPane.setLayout(null);
610 jContentPane.setSize(new java.awt.Dimension(550, 350));
611 jContentPane.add(getJScrollPane(), null);
612 jContentPane.add(getJButtonClose(), null);
613
614 jContentPane.setPreferredSize(new java.awt.Dimension(550, 340));
615 }
616 return jContentPane;
617 }
618
619 /* (non-Javadoc)
620 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
621 *
622 * Override windowClosing to popup warning message to confirm quit
623 *
624 */
625 public void windowClosing(WindowEvent arg0) {
626 this.dispose();
627 }
628
629 /* (non-Javadoc)
630 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
631 *
632 * Override componentResized to resize all components when frame's size is changed
633 */
634 public void componentResized(ComponentEvent arg0) {
635 int intCurrentWidth = this.getJContentPane().getWidth();
636 int intCurrentHeight = this.getJContentPane().getHeight();
637 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
638 int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
639
640 Tools.resizeComponent(this.jScrollPane, intCurrentWidth, intCurrentHeight, intPreferredWidth,
641 intPreferredHeight);
642 Tools.centerComponent(this.jButtonClose, intCurrentWidth, intCurrentHeight, intPreferredHeight,
643 DataType.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON);
644 }
645
646 /* (non-Javadoc)
647 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
648 *
649 */
650 public void actionPerformed(ActionEvent arg0) {
651 if (arg0.getSource() == this.jButtonClose) {
652 this.dispose();
653 }
654 }
655
656 private void writeReportLn(String line) {
657 this.reportContent = this.reportContent + line + DataType.LINE_SEPARATOR;
658 }
659 }