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
293 msa
.getPackageGuid(),
295 .getPackageVersion());
300 + moduleSaId
.getName()
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
;
321 DynamicPcdBuildDefinitions dpbd
= fpd
.getDynamicPcdBuildDefinitions();
323 for (int indexOfDpbd
= 0; indexOfDpbd
< dpbd
.getPcdBuildDataList().size(); indexOfDpbd
++) {
324 PcdBuildData pbd
= dpbd
.getPcdBuildDataList().get(indexOfDpbd
);
326 if (pbd
.getCName().equals(name
)) {
328 // Write Dynamic Pcd Build Definition
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
);
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
;
354 // If not empty, write this platform info
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
);
364 return reportContent
;
368 // Create detailed information report for library
376 private String
createReport(FindResultId frid
) {
378 String name
= frid
.getName();
386 // Write Provided Package
388 writeReportLn(TAB
+ "Provided by: " + frid
.getDeclaredBy().getName() + " ("
389 + Tools
.getRelativePath(frid
.getDeclaredBy().getPath(), Workspace
.getCurrentWorkspace()) + ")");
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
));
400 // Write Supported Module Types
402 writeReportLn(TAB
+ "Supported Module Types: " + Tools
.convertVectorToString(frid
.getModuleType()));
405 // Write Supported Arch
407 writeReportLn(TAB
+ "Supported Architectures: " + Tools
.convertVectorToString(frid
.getArch()));
412 writeReportLn(TAB
+ "Help Text: ");
413 writeReportLn(TAB
+ TAB
+ frid
.getHelp());
416 // Write an empty line
423 writeReportLn("Library Instances:");
426 // Write Instances One by One
428 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
429 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
430 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
433 // Write Instance Name
435 if (msa
.getMsaHeader() != null) {
436 writeReportLn(TAB
+ msa
.getMsaHeader().getModuleName());
440 // Write Msa File Name
442 writeReportLn(TAB
+ TAB
+ "Provided by: "
443 + Tools
.getRelativePath(mid
.getPath(), Workspace
.getCurrentWorkspace()));
446 // Find the produced library class
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
)) {
453 // Write Supported Module Types
455 writeReportLn(TAB
+ TAB
+ "Supported Module Types: "
456 + Tools
.convertListToString(lc
.getSupModuleList()));
459 // Write Supported Arch
461 writeReportLn(TAB
+ TAB
+ "Supported Architectures: "
462 + Tools
.convertListToString(lc
.getSupArchList()));
467 writeReportLn(TAB
+ TAB
+ "Help Text: ");
468 writeReportLn(TAB
+ TAB
+ (lc
.getHelpText() == null ?
"" : lc
.getHelpText()));
477 // Write an empty line
482 // Write all modules which consumed this library
484 writeReportLn("Modules Requiring " + name
+ ":");
485 for (int index
= 0; index
< frid
.getConsumedModules().size(); index
++) {
490 + frid
.getConsumedModules().get(index
).getName()
492 + Tools
.getRelativePath(frid
.getConsumedModules().get(index
).getPath(),
493 Workspace
.getCurrentWorkspace()) + ")");
497 // Write an empty line
502 // Write platforms using the library class instances
504 writeReportLn("Platforms Using " + name
+ ":");
507 // Write Instances One by One as Using Platforms
509 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
510 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
513 // Write Instance Name
515 writeReportLn(TAB
+ mid
.getName());
518 // Go through each platform one by one
520 for (int indexOfPlatform
= 0; indexOfPlatform
< GlobalData
.openingPlatformList
.size(); indexOfPlatform
++) {
521 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
523 PlatformIdentification pid
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
525 Vector
<ModuleIdentification
> vModuleSa
= new Vector
<ModuleIdentification
>();
527 FrameworkModules fm
= fpd
.getFrameworkModules();
529 for (int indexOfModule
= 0; indexOfModule
< fm
.getModuleSAList().size(); indexOfModule
++) {
530 ModuleSA msa
= fm
.getModuleSAList().get(indexOfModule
);
532 Libraries l
= msa
.getLibraries();
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
548 .getPackageVersion());
549 if (moduleSaId
!= null) {
550 vModuleSa
.addElement(moduleSaId
);
560 // Get finded moduleSa in this spd
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
++) {
569 + vModuleSa
.elementAt(indexOfModuleSa
).getName()
571 + Tools
.getRelativePath(vModuleSa
.elementAt(indexOfModuleSa
).getPath(),
572 Workspace
.getCurrentWorkspace()) + ")");
581 return this.reportContent
;
585 * This method initializes this
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
);
600 * This method initializes jContentPane
602 * @return javax.swing.JPanel
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);
612 jContentPane
.setPreferredSize(new java
.awt
.Dimension(550, 340));
618 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
620 * Override windowClosing to popup warning message to confirm quit
623 public void windowClosing(WindowEvent arg0
) {
628 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
630 * Override componentResized to resize all components when frame's size is changed
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
;
638 Tools
.resizeComponent(this.jScrollPane
, intCurrentWidth
, intCurrentHeight
, intPreferredWidth
,
640 Tools
.centerComponent(this.jButtonClose
, intCurrentWidth
, intCurrentHeight
, intPreferredHeight
,
641 DataType
.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON
);
645 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
648 public void actionPerformed(ActionEvent arg0
) {
649 if (arg0
.getSource() == this.jButtonClose
) {
654 private void writeReportLn(String line
) {
655 this.reportContent
= this.reportContent
+ line
+ DataType
.LINE_SEPARATOR
;