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
.FrameworkModulesDocument
.FrameworkModules
;
29 import org
.tianocore
.LibrariesDocument
.Libraries
;
30 import org
.tianocore
.LibrariesDocument
.Libraries
.Instance
;
31 import org
.tianocore
.LibraryClassDocument
.LibraryClass
;
32 import org
.tianocore
.ModuleSADocument
.ModuleSA
;
33 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
34 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
35 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
36 import org
.tianocore
.frameworkwizard
.common
.DataType
;
37 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
38 import org
.tianocore
.frameworkwizard
.common
.Tools
;
39 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
40 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
41 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
42 import org
.tianocore
.frameworkwizard
.workspace
.Workspace
;
43 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
45 public class FindResultDetailInfo
extends IFrame
{
48 /// Define class Serial Version UID
50 private static final long serialVersionUID
= -4888295869041881282L;
52 private JPanel jContentPane
= null;
54 private JScrollPane jScrollPane
= null;
56 private JTextArea jTextArea
= null;
58 private JButton jButtonClose
= null;
63 private static String TAB
= " ";
65 private String reportContent
= "";
67 private WorkspaceTools wt
= new WorkspaceTools();
70 * This method initializes jScrollPane
72 * @return javax.swing.JScrollPane
74 private JScrollPane
getJScrollPane() {
75 if (jScrollPane
== null) {
76 jScrollPane
= new JScrollPane();
77 jScrollPane
.setBounds(new java
.awt
.Rectangle(5, 5, 535, 280));
78 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(535, 280));
79 jScrollPane
.setViewportView(getJTextArea());
85 * This method initializes jTextArea
87 * @return javax.swing.JTextArea
89 private JTextArea
getJTextArea() {
90 if (jTextArea
== null) {
91 jTextArea
= new JTextArea();
92 jTextArea
.setEditable(false);
98 * This method initializes jButtonClose
100 * @return javax.swing.JButton
102 private JButton
getJButtonClose() {
103 if (jButtonClose
== null) {
104 jButtonClose
= new JButton();
105 jButtonClose
.setBounds(new java
.awt
.Rectangle(240, 290, 80, 20));
106 jButtonClose
.setPreferredSize(new java
.awt
.Dimension(80, 20));
107 jButtonClose
.addActionListener(this);
108 jButtonClose
.setText("Close");
118 public FindResultDetailInfo(FindResultId frid
) {
121 this.setTitle(frid
.getName());
122 this.jTextArea
.setText(createReport(frid
));
123 this.jTextArea
.setSelectionStart(0);
124 this.jTextArea
.setSelectionEnd(0);
127 private String
createReport(FindResultId frid
) {
129 String name
= frid
.getName();
137 // Write Provided Package
139 writeReportLn(TAB
+ "Provided by: " + frid
.getDeclaredBy().getName() + " ("
140 + Tools
.getRelativePath(frid
.getDeclaredBy().getPath(), Workspace
.getCurrentWorkspace()) + ")");
145 PackageSurfaceArea spd
= GlobalData
.openingPackageList
.getPackageSurfaceAreaFromId(frid
.getDeclaredBy());
146 tmp
= Tools
.getRelativePath(frid
.getDeclaredBy().getPath(), Workspace
.getCurrentWorkspace());
147 writeReportLn(TAB
+ "Header File: " + Tools
.getFilePathOnly(tmp
)
148 + wt
.getHeaderFileFromPackageByLibraryClassName(spd
, name
));
151 // Write Supported Module Types
153 writeReportLn(TAB
+ "Supported Module Types: " + Tools
.convertVectorToString(frid
.getModuleType()));
156 // Write Supported Arch
158 writeReportLn(TAB
+ "Supported Architectures: " + Tools
.convertVectorToString(frid
.getArch()));
163 writeReportLn(TAB
+ "Help Text: ");
164 writeReportLn(TAB
+ TAB
+ frid
.getHelp());
167 // Write an empty line
174 writeReportLn("Library Instances:");
177 // Write Instances One by One
179 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
180 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
181 ModuleSurfaceArea msa
= GlobalData
.openingModuleList
.getModuleSurfaceAreaFromId(mid
);
184 // Write Instance Name
186 if (msa
.getMsaHeader() != null) {
187 writeReportLn(TAB
+ msa
.getMsaHeader().getModuleName());
191 // Write Msa File Name
193 writeReportLn(TAB
+ TAB
+ "Provided by: "
194 + Tools
.getRelativePath(mid
.getPath(), Workspace
.getCurrentWorkspace()));
197 // Find the produced library class
199 if (msa
.getLibraryClassDefinitions() != null) {
200 for (int indexL
= 0; indexL
< msa
.getLibraryClassDefinitions().getLibraryClassList().size(); indexL
++) {
201 LibraryClass lc
= msa
.getLibraryClassDefinitions().getLibraryClassList().get(indexL
);
202 if (lc
.getKeyword().equals(name
)) {
204 // Write Supported Module Types
206 writeReportLn(TAB
+ TAB
+ "Supported Module Types: "
207 + Tools
.convertListToString(lc
.getSupModuleList()));
210 // Write Supported Arch
212 writeReportLn(TAB
+ TAB
+ "Supported Architectures: "
213 + Tools
.convertListToString(lc
.getSupArchList()));
218 writeReportLn(TAB
+ TAB
+ "Help Text: ");
219 writeReportLn(TAB
+ TAB
+ (lc
.getHelpText() == null ?
"" : lc
.getHelpText()));
228 // Write an empty line
233 // Write all modules which consumed this library
235 writeReportLn("Modules Requiring " + name
+ ":");
236 for (int index
= 0; index
< frid
.getConsumedModules().size(); index
++) {
241 + frid
.getConsumedModules().get(index
).getName()
243 + Tools
.getRelativePath(frid
.getConsumedModules().get(index
).getPath(),
244 Workspace
.getCurrentWorkspace()) + ")");
248 // Write an empty line
253 // Write platforms using the library class instances
255 writeReportLn("Platforms Using " + name
+ ":");
258 // Write Instances One by One as Using Platforms
260 for (int index
= 0; index
< frid
.getProducedModules().size(); index
++) {
261 ModuleIdentification mid
= frid
.getProducedModules().get(index
);
264 // Write Instance Name
266 writeReportLn(TAB
+ mid
.getName());
269 // Go through each platform one by one
271 for (int indexOfPlatform
= 0; indexOfPlatform
< GlobalData
.openingPlatformList
.size(); indexOfPlatform
++) {
272 PlatformSurfaceArea fpd
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
274 PlatformIdentification pid
= GlobalData
.openingPlatformList
.getOpeningPlatformByIndex(indexOfPlatform
)
276 Vector
<ModuleIdentification
> vModuleSa
= new Vector
<ModuleIdentification
>();
278 FrameworkModules fm
= fpd
.getFrameworkModules();
280 for (int indexOfModule
= 0; indexOfModule
< fm
.getModuleSAList().size(); indexOfModule
++) {
281 ModuleSA msa
= fm
.getModuleSAList().get(indexOfModule
);
283 Libraries l
= msa
.getLibraries();
285 if (l
.getInstanceList() != null) {
286 for (int indexOfInstance
= 0; indexOfInstance
< l
.getInstanceList().size(); indexOfInstance
++) {
287 Instance i
= l
.getInstanceList().get(indexOfInstance
);
288 if (mid
.equals(i
.getModuleGuid(), i
.getModuleVersion(), i
.getPackageGuid(),
289 i
.getPackageVersion())) {
290 ModuleIdentification moduleSaId
= GlobalData
291 .findIdByGuidVersion(
299 .getPackageVersion());
300 if (moduleSaId
!= null) {
301 vModuleSa
.addElement(moduleSaId
);
311 // Get finded moduleSa in this spd
313 if (vModuleSa
.size() > 0) {
314 writeReportLn(TAB
+ TAB
+ pid
.getName() + " ("
315 + Tools
.getRelativePath(pid
.getPath(), Workspace
.getCurrentWorkspace()) + ")");
316 for (int indexOfModuleSa
= 0; indexOfModuleSa
< vModuleSa
.size(); indexOfModuleSa
++) {
320 + vModuleSa
.elementAt(indexOfModuleSa
).getName()
322 + Tools
.getRelativePath(vModuleSa
.elementAt(indexOfModuleSa
).getPath(),
323 Workspace
.getCurrentWorkspace()) + ")");
332 return this.reportContent
;
336 * This method initializes this
340 private void init() {
341 this.setSize(550, 380);
342 this.setContentPane(getJContentPane());
343 this.setTitle("JFrame");
344 this.setResizable(true);
345 this.setDefaultCloseOperation(JFrame
.HIDE_ON_CLOSE
);
351 * This method initializes jContentPane
353 * @return javax.swing.JPanel
355 private JPanel
getJContentPane() {
356 if (jContentPane
== null) {
357 jContentPane
= new JPanel();
358 jContentPane
.setLayout(null);
359 jContentPane
.setSize(new java
.awt
.Dimension(550, 350));
360 jContentPane
.add(getJScrollPane(), null);
361 jContentPane
.add(getJButtonClose(), null);
363 jContentPane
.setPreferredSize(new java
.awt
.Dimension(550, 340));
369 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
371 * Override windowClosing to popup warning message to confirm quit
374 public void windowClosing(WindowEvent arg0
) {
379 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
381 * Override componentResized to resize all components when frame's size is changed
383 public void componentResized(ComponentEvent arg0
) {
384 int intCurrentWidth
= this.getJContentPane().getWidth();
385 int intCurrentHeight
= this.getJContentPane().getHeight();
386 int intPreferredWidth
= this.getJContentPane().getPreferredSize().width
;
387 int intPreferredHeight
= this.getJContentPane().getPreferredSize().height
;
389 Tools
.resizeComponent(this.jScrollPane
, intCurrentWidth
, intCurrentHeight
, intPreferredWidth
,
391 Tools
.centerComponent(this.jButtonClose
, intCurrentWidth
, intCurrentHeight
, intPreferredHeight
,
392 DataType
.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON
);
396 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
399 public void actionPerformed(ActionEvent arg0
) {
400 if (arg0
.getSource() == this.jButtonClose
) {
405 private void writeReportLn(String line
) {
406 this.reportContent
= this.reportContent
+ line
+ DataType
.LINE_SEPARATOR
;