]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java
1. Fix EDKT339 Library Class Search need to get info for selected library class
[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.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;
44
45 public class FindResultDetailInfo extends IFrame {
46
47 ///
48 /// Define class Serial Version UID
49 ///
50 private static final long serialVersionUID = -4888295869041881282L;
51
52 private JPanel jContentPane = null;
53
54 private JScrollPane jScrollPane = null;
55
56 private JTextArea jTextArea = null;
57
58 private JButton jButtonClose = null;
59
60 //
61 // Not for UI
62 //
63 private static String TAB = " ";
64
65 private String reportContent = "";
66
67 private WorkspaceTools wt = new WorkspaceTools();
68
69 /**
70 * This method initializes jScrollPane
71 *
72 * @return javax.swing.JScrollPane
73 */
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());
80 }
81 return jScrollPane;
82 }
83
84 /**
85 * This method initializes jTextArea
86 *
87 * @return javax.swing.JTextArea
88 */
89 private JTextArea getJTextArea() {
90 if (jTextArea == null) {
91 jTextArea = new JTextArea();
92 jTextArea.setEditable(false);
93 }
94 return jTextArea;
95 }
96
97 /**
98 * This method initializes jButtonClose
99 *
100 * @return javax.swing.JButton
101 */
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");
109 }
110 return jButtonClose;
111 }
112
113 /**
114
115 @param lci
116
117 **/
118 public FindResultDetailInfo(FindResultId frid) {
119 super();
120 init();
121 this.setTitle(frid.getName());
122 this.jTextArea.setText(createReport(frid));
123 this.jTextArea.setSelectionStart(0);
124 this.jTextArea.setSelectionEnd(0);
125 }
126
127 private String createReport(FindResultId frid) {
128 String tmp = "";
129 String name = frid.getName();
130
131 //
132 // Write Class Name
133 //
134 writeReportLn(name);
135
136 //
137 // Write Provided Package
138 //
139 writeReportLn(TAB + "Provided by: " + frid.getDeclaredBy().getName() + " ("
140 + Tools.getRelativePath(frid.getDeclaredBy().getPath(), Workspace.getCurrentWorkspace()) + ")");
141
142 //
143 // Write Header File
144 //
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));
149
150 //
151 // Write Supported Module Types
152 //
153 writeReportLn(TAB + "Supported Module Types: " + Tools.convertVectorToString(frid.getModuleType()));
154
155 //
156 // Write Supported Arch
157 //
158 writeReportLn(TAB + "Supported Architectures: " + Tools.convertVectorToString(frid.getArch()));
159
160 //
161 // Write Help Text
162 //
163 writeReportLn(TAB + "Help Text: ");
164 writeReportLn(TAB + TAB + frid.getHelp());
165
166 //
167 // Write an empty line
168 //
169 writeReportLn("");
170
171 //
172 // Write Instances
173 //
174 writeReportLn("Library Instances:");
175
176 //
177 // Write Instances One by One
178 //
179 for (int index = 0; index < frid.getProducedModules().size(); index++) {
180 ModuleIdentification mid = frid.getProducedModules().get(index);
181 ModuleSurfaceArea msa = GlobalData.openingModuleList.getModuleSurfaceAreaFromId(mid);
182 if (msa != null) {
183 //
184 // Write Instance Name
185 //
186 if (msa.getMsaHeader() != null) {
187 writeReportLn(TAB + msa.getMsaHeader().getModuleName());
188 }
189
190 //
191 // Write Msa File Name
192 //
193 writeReportLn(TAB + TAB + "Provided by: "
194 + Tools.getRelativePath(mid.getPath(), Workspace.getCurrentWorkspace()));
195
196 //
197 // Find the produced library class
198 //
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)) {
203 //
204 // Write Supported Module Types
205 //
206 writeReportLn(TAB + TAB + "Supported Module Types: "
207 + Tools.convertListToString(lc.getSupModuleList()));
208
209 //
210 // Write Supported Arch
211 //
212 writeReportLn(TAB + TAB + "Supported Architectures: "
213 + Tools.convertListToString(lc.getSupArchList()));
214
215 //
216 // Write Help Text
217 //
218 writeReportLn(TAB + TAB + "Help Text: ");
219 writeReportLn(TAB + TAB + (lc.getHelpText() == null ? "" : lc.getHelpText()));
220 }
221 }
222 }
223
224 }
225 }
226
227 //
228 // Write an empty line
229 //
230 writeReportLn("");
231
232 //
233 // Write all modules which consumed this library
234 //
235 writeReportLn("Modules Requiring " + name + ":");
236 for (int index = 0; index < frid.getConsumedModules().size(); index++) {
237 //
238 // Write
239 //
240 writeReportLn(TAB
241 + frid.getConsumedModules().get(index).getName()
242 + " ("
243 + Tools.getRelativePath(frid.getConsumedModules().get(index).getPath(),
244 Workspace.getCurrentWorkspace()) + ")");
245 }
246
247 //
248 // Write an empty line
249 //
250 writeReportLn("");
251
252 //
253 // Write platforms using the library class instances
254 //
255 writeReportLn("Platforms Using " + name + ":");
256
257 //
258 // Write Instances One by One as Using Platforms
259 //
260 for (int index = 0; index < frid.getProducedModules().size(); index++) {
261 ModuleIdentification mid = frid.getProducedModules().get(index);
262
263 //
264 // Write Instance Name
265 //
266 writeReportLn(TAB + mid.getName());
267
268 //
269 // Go through each platform one by one
270 //
271 for (int indexOfPlatform = 0; indexOfPlatform < GlobalData.openingPlatformList.size(); indexOfPlatform++) {
272 PlatformSurfaceArea fpd = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
273 .getXmlFpd();
274 PlatformIdentification pid = GlobalData.openingPlatformList.getOpeningPlatformByIndex(indexOfPlatform)
275 .getId();
276 Vector<ModuleIdentification> vModuleSa = new Vector<ModuleIdentification>();
277 if (fpd != null) {
278 FrameworkModules fm = fpd.getFrameworkModules();
279 if (fm != null) {
280 for (int indexOfModule = 0; indexOfModule < fm.getModuleSAList().size(); indexOfModule++) {
281 ModuleSA msa = fm.getModuleSAList().get(indexOfModule);
282 if (msa != null) {
283 Libraries l = msa.getLibraries();
284 if (l != null) {
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(
292 msa
293 .getModuleGuid(),
294 msa
295 .getModuleVersion(),
296 msa
297 .getPackageGuid(),
298 msa
299 .getPackageVersion());
300 if (moduleSaId != null) {
301 vModuleSa.addElement(moduleSaId);
302 }
303 }
304 }
305 }
306 }
307 }
308 }
309
310 //
311 // Get finded moduleSa in this spd
312 //
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++) {
317 writeReportLn(TAB
318 + TAB
319 + TAB
320 + vModuleSa.elementAt(indexOfModuleSa).getName()
321 + " ("
322 + Tools.getRelativePath(vModuleSa.elementAt(indexOfModuleSa).getPath(),
323 Workspace.getCurrentWorkspace()) + ")");
324 }
325 }
326 }
327 }
328 }
329 writeReportLn("");
330 }
331
332 return this.reportContent;
333 }
334
335 /**
336 * This method initializes this
337 *
338 * @return void
339 */
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);
346 this.centerWindow();
347
348 }
349
350 /**
351 * This method initializes jContentPane
352 *
353 * @return javax.swing.JPanel
354 */
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);
362
363 jContentPane.setPreferredSize(new java.awt.Dimension(550, 340));
364 }
365 return jContentPane;
366 }
367
368 /* (non-Javadoc)
369 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
370 *
371 * Override windowClosing to popup warning message to confirm quit
372 *
373 */
374 public void windowClosing(WindowEvent arg0) {
375 this.dispose();
376 }
377
378 /* (non-Javadoc)
379 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
380 *
381 * Override componentResized to resize all components when frame's size is changed
382 */
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;
388
389 Tools.resizeComponent(this.jScrollPane, intCurrentWidth, intCurrentHeight, intPreferredWidth,
390 intPreferredHeight);
391 Tools.centerComponent(this.jButtonClose, intCurrentWidth, intCurrentHeight, intPreferredHeight,
392 DataType.SPACE_TO_BOTTOM_FOR_CLOSE_BUTTON);
393 }
394
395 /* (non-Javadoc)
396 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
397 *
398 */
399 public void actionPerformed(ActionEvent arg0) {
400 if (arg0.getSource() == this.jButtonClose) {
401 this.dispose();
402 }
403 }
404
405 private void writeReportLn(String line) {
406 this.reportContent = this.reportContent + line + DataType.LINE_SEPARATOR;
407 }
408 }