3 The file is used to show detailed information of one of find results
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
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.
15 package org
.tianocore
.frameworkwizard
.common
.find
;
17 import java
.awt
.event
.ActionEvent
;
18 import java
.awt
.event
.ComponentEvent
;
19 import java
.awt
.event
.WindowEvent
;
20 import java
.util
.Vector
;
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
;
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
;
51 public class FindResultDetailInfo
extends IFrame
{
54 /// Define class Serial Version UID
56 private static final long serialVersionUID
= -4888295869041881282L;
58 private JPanel jContentPane
= null;
60 private JScrollPane jScrollPane
= null;
62 private JTextArea jTextArea
= null;
64 private JButton jButtonClose
= null;
69 private static String TAB
= " ";
71 private String reportContent
= "";
73 private WorkspaceTools wt
= new WorkspaceTools();
76 * This method initializes jScrollPane
78 * @return javax.swing.JScrollPane
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());
91 * This method initializes jTextArea
93 * @return javax.swing.JTextArea
95 private JTextArea
getJTextArea() {
96 if (jTextArea
== null) {
97 jTextArea
= new JTextArea();
98 jTextArea
.setEditable(false);
104 * This method initializes jButtonClose
106 * @return javax.swing.JButton
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");
124 public FindResultDetailInfo(FindResultId frid
) {
127 this.setTitle(frid
.getName());
128 this.jTextArea
.setText(createReport(frid
));
129 this.jTextArea
.setSelectionStart(0);
130 this.jTextArea
.setSelectionEnd(0);
138 public FindResultDetailInfo(PcdFindResultId frid
) {
141 this.setTitle(frid
.getName());
142 this.jTextArea
.setText(createReport(frid
));
143 this.jTextArea
.setSelectionStart(0);
144 this.jTextArea
.setSelectionEnd(0);
148 Create detailed information report for pcd
154 private String
createReport(PcdFindResultId frid
) {
155 String name
= frid
.getName();
160 writeReportLn("PCD C Name: " + name
);
163 // Wrtie Declared package
165 writeReportLn("Declared in Package: " + frid
.getDeclaredBy().getName() + " ("
166 + Tools
.getRelativePath(frid
.getDeclaredBy().getPath(), Workspace
.getCurrentWorkspace()) + ")");
171 writeReportLn("Token Space: " + frid
.getTokenSpaceGuidCName());
176 writeReportLn("Token: " + frid
.getToken());
181 writeReportLn("Datum Type: " + frid
.getDatumType());
184 // Write Default Value
186 writeReportLn("Default Value: " + frid
.getValue());
191 writeReportLn("Valid Usages: " + frid
.getUsage());
196 writeReportLn("Help Text: ");
197 writeReportLn(TAB
+ frid
.getHelp());
200 // Write an Empty Line
205 // Wriet all modules which use this PCD:
207 writeReportLn("Modules Coded to Use This PCD: ");
209 Vector
<ModuleIdentification
> vModules
= frid
.getConsumedModules();
210 if (vModules
!= null) {
211 for (int index
= 0; index
< vModules
.size(); index
++) {
213 // Write Module Name and Path
215 writeReportLn(TAB
+ vModules
.get(index
).getName() + " ("
216 + Tools
.getRelativePath(vModules
.get(index
).getPath(), Workspace
.getCurrentWorkspace())
220 // Write Module Pcd Info
222 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(vModules
.get(index
));
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
)) {
229 // Write Pcd Item Type
231 writeReportLn(TAB
+ TAB
+ "PcdItemType: "
232 + pcdCoded
.getPcdEntryList().get(indexOfPcd
).getPcdItemType().toString());
237 writeReportLn(TAB
+ TAB
+ "Help Text: ");
238 writeReportLn(TAB
+ TAB
+ TAB
239 + pcdCoded
.getPcdEntryList().get(indexOfPcd
).getHelpText());
246 // Write an Empty Line
253 // Write an Empty Line
258 // Write All Platforms Specifing this PCD
260 writeReportLn("Platforms Specifing this PCD: ");
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();
268 // Get Non-Dynamic Pcd
270 FrameworkModules fm
= fpd
.getFrameworkModules();
272 for (int indexOfModuleSa
= 0; indexOfModuleSa
< fm
.getModuleSAList().size(); indexOfModuleSa
++) {
273 ModuleSA msa
= fm
.getModuleSAList().get(indexOfModuleSa
);
275 PcdBuildDefinition p
= msa
.getPcdBuildDefinition();
277 if (p
.getPcdDataList() != null) {
279 for (int indexOfPcd
= 0; indexOfPcd
< p
.getPcdDataList().size(); indexOfPcd
++) {
280 PcdData pd
= p
.getPcdDataList().get(indexOfPcd
);
284 if (pd
.getCName().equals(name
)) {
286 // Write Module Sa Info
288 ModuleIdentification moduleSaId
= GlobalData
289 .findModuleIdByGuidVersion(
297 .getPackageVersion());
302 + moduleSaId
.getName()
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
;
323 DynamicPcdBuildDefinitions dpbd
= fpd
.getDynamicPcdBuildDefinitions();
325 for (int indexOfDpbd
= 0; indexOfDpbd
< dpbd
.getPcdBuildDataList().size(); indexOfDpbd
++) {
326 PcdBuildData pbd
= dpbd
.getPcdBuildDataList().get(indexOfDpbd
);
328 if (pbd
.getCName().equals(name
)) {
330 // Write Dynamic Pcd Build Definition
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
);
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
;
356 // If not empty, write this platform info
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
);
366 return reportContent
;
370 // Create detailed information report for library
378 private String
createReport(FindResultId frid
) {
380 String name
= frid
.getName();
388 // Write Provided Package
390 writeReportLn(TAB
+ "Provided by: " + frid
.getDeclaredBy().getName() + " ("
391 + Tools
.getRelativePath(frid
.getDeclaredBy().getPath(), Workspace
.getCurrentWorkspace()) + ")");
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
));
402 // Write Supported Module Types
404 writeReportLn(TAB
+ "Supported Module Types: " + Tools
.convertVectorToString(frid
.getModuleType()));
407 // Write Supported Arch
409 writeReportLn(TAB
+ "Supported Architectures: " + Tools
.convertVectorToString(frid
.getArch()));
414 writeReportLn(TAB
+ "Help Text: ");
415 writeReportLn(TAB
+ TAB
+ frid
.getHelp());
418 // Write an empty line
425 writeReportLn("Library Instances:");
428 // Write Instances One by One
430 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
431 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
432 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
435 // Write Instance Name
437 if (msa
.getMsaHeader() != null) {
438 writeReportLn(TAB
+ msa
.getMsaHeader().getModuleName());
442 // Write Msa File Name
444 writeReportLn(TAB
+ TAB
+ "Provided by: "
445 + Tools
.getRelativePath(mid
.getPath(), Workspace
.getCurrentWorkspace()));
448 // Find the produced library class
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
)) {
455 // Write Supported Module Types
457 writeReportLn(TAB
+ TAB
+ "Supported Module Types: "
458 + Tools
.convertListToString(lc
.getSupModuleList()));
461 // Write Supported Arch
463 writeReportLn(TAB
+ TAB
+ "Supported Architectures: "
464 + Tools
.convertListToString(lc
.getSupArchList()));
469 writeReportLn(TAB
+ TAB
+ "Help Text: ");
470 writeReportLn(TAB
+ TAB
+ (lc
.getHelpText() == null ?
"" : lc
.getHelpText()));
479 // Write an empty line
484 // Write all modules which consumed this library
486 writeReportLn("Modules Requiring " + name
+ ":");
487 for (int index
= 0; index
< frid
.getConsumedModules().size(); index
++) {
492 + frid
.getConsumedModules().get(index
).getName()
494 + Tools
.getRelativePath(frid
.getConsumedModules().get(index
).getPath(),
495 Workspace
.getCurrentWorkspace()) + ")");
499 // Write an empty line
504 // Write platforms using the library class instances
506 writeReportLn("Platforms Using " + name
+ ":");
509 // Write Instances One by One as Using Platforms
511 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
512 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
515 // Write Instance Name
517 writeReportLn(TAB
+ mid
.getName());
520 // Go through each platform one by one
522 for (int indexOfPlatform
= 0; indexOfPlatform
< GlobalData
.openingPlatformList
.size(); indexOfPlatform
++) {
523 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
525 PlatformIdentification pid
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
527 Vector
<ModuleIdentification
> vModuleSa
= new Vector
<ModuleIdentification
>();
529 FrameworkModules fm
= fpd
.getFrameworkModules();
531 for (int indexOfModule
= 0; indexOfModule
< fm
.getModuleSAList().size(); indexOfModule
++) {
532 ModuleSA msa
= fm
.getModuleSAList().get(indexOfModule
);
534 Libraries l
= msa
.getLibraries();
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(
550 .getPackageVersion());
551 if (moduleSaId
!= null) {
552 vModuleSa
.addElement(moduleSaId
);
562 // Get finded moduleSa in this spd
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
++) {
571 + vModuleSa
.elementAt(indexOfModuleSa
).getName()
573 + Tools
.getRelativePath(vModuleSa
.elementAt(indexOfModuleSa
).getPath(),
574 Workspace
.getCurrentWorkspace()) + ")");
583 return this.reportContent
;
587 * This method initializes this
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
);
602 * This method initializes jContentPane
604 * @return javax.swing.JPanel
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);
614 jContentPane
.setPreferredSize(new java
.awt
.Dimension(550, 340));
620 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
622 * Override windowClosing to popup warning message to confirm quit
625 public void windowClosing(WindowEvent arg0
) {
630 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
632 * Override componentResized to resize all components when frame's size is changed
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
;
640 Tools
.resizeComponent(this.jScrollPane
, intCurrentWidth
, intCurrentHeight
, intPreferredWidth
,
642 Tools
.centerComponent(this.jButtonClose
, intCurrentWidth
, intCurrentHeight
, intPreferredHeight
,
643 DataType
.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON
);
647 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
650 public void actionPerformed(ActionEvent arg0
) {
651 if (arg0
.getSource() == this.jButtonClose
) {
656 private void writeReportLn(String line
) {
657 this.reportContent
= this.reportContent
+ line
+ DataType
.LINE_SEPARATOR
;