]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
Re-implement sorting algorithm of table and modified FpdFrameworkModules.java to...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFrameworkModules.java
1 /** @file
2
3 The file is used to create, update FrameworkModules of Fpd file
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.platform.ui;
16
17 import java.awt.BorderLayout;
18
19 import javax.swing.JFrame;
20 import javax.swing.JOptionPane;
21 import javax.swing.JPanel;
22 import javax.swing.JSplitPane;
23 import javax.swing.JLabel;
24 import javax.swing.JScrollPane;
25 import javax.swing.JTable;
26 import javax.swing.JButton;
27 import javax.swing.ListSelectionModel;
28 import javax.swing.table.DefaultTableModel;
29
30 import org.tianocore.PlatformSurfaceAreaDocument;
31 import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
32 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
33 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
34 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
35 import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
36
37 import java.awt.FlowLayout;
38 import java.io.File;
39 import java.util.ArrayList;
40 import java.util.HashMap;
41 import java.util.Iterator;
42 import java.util.Map;
43 import java.util.Set;
44 import java.util.Vector;
45
46 public class FpdFrameworkModules extends IInternalFrame {
47
48 /**
49 * Initialize Globals
50 */
51 private static final long serialVersionUID = 1L;
52
53 public static final int forceDbgColForFpdModTable = 7;
54
55 static JFrame frame;
56
57 private JSplitPane jSplitPane = null;
58
59 private JPanel jPanelTop = null;
60
61 private JPanel jPanelBottom = null;
62
63 private JLabel jLabel = null;
64
65 private JScrollPane jScrollPaneAllModules = null;
66
67 private JTable jTableAllModules = null;
68
69 private JPanel jPanelTopSouth = null;
70
71 private JButton jButtonAddModule = null;
72
73 private JLabel jLabelModulesAdded = null;
74
75 private JPanel jPanelBottomSouth = null;
76
77 private JScrollPane jScrollPaneFpdModules = null;
78
79 private JTable jTableFpdModules = null;
80
81 private JButton jButtonSettings = null;
82
83 private JButton jButtonRemoveModule = null;
84
85 private NonEditableTableModel modelAllModules = null;
86
87 private FpdModulesTableModel modelFpdModules = null;
88
89 private FpdModuleSA settingDlg = null;
90
91 private FpdFileContents ffc = null;
92
93 private OpeningPlatformType docConsole = null;
94
95 private Map<String, ArrayList<String>> fpdMsa = null;
96
97 private ArrayList<ModuleIdentification> miList = null;
98
99 /**
100 * Column settings for displaying all modules in workspace
101 */
102 private final int modNameColForAllModTable = 0;
103
104 private final int pkgNameColForAllModTable = 1;
105
106 private final int pathColForAllModTable = 2;
107
108 private final int typeColForAllModTable = 3;
109
110 private final int pkgVerColForAllModTable = 5;
111
112 private final int modVerColForAllModTable = 4;
113
114 /**
115 * Column settings for display modules in the FPD file
116 */
117 private final int modNameColForFpdModTable = 0;
118
119 private final int pkgNameColForFpdModTable = 1;
120
121 private final int pathColForFpdModTable = 2;
122
123 private final int archColForFpdModTable = 3;
124
125 private final int pkgVerColForFpdModTable = 6;
126
127 private final int modVerColForFpdModTable = 5;
128
129 private final int typeColForFpdModTable = 4;
130
131 /**
132 * FpdFileContents structure
133 */
134 private final int ffcModGuid = 0;
135
136 private final int ffcModVer = 1;
137
138 private final int ffcPkgGuid = 2;
139
140 private final int ffcPkgVer = 3;
141
142 private final int ffcModArch = 4;
143
144 /**
145 * Set Column Widths, Only the PATH should not have a max width.
146 */
147 private final int modNameMinWidth = 168;
148
149 private final int modNamePrefWidth = 200;
150
151 private final int modNameMaxWidth = 350;
152
153 private final int pkgNameMinWidth = 100;
154
155 private final int pkgNamePrefWidth = 130;
156
157 private final int pkgNameMaxWidth = 150;
158
159 private final int verMinWidth = 60;
160
161 private final int verMaxWidth = 80;
162
163 private final int verPrefWidth = 70;
164
165 private final int pathPrefWidth = 600;
166
167 private final int pathMinWidth = 280;
168
169 private final int archPrefWidth = 80;
170
171 private final int archMinWidth = 60;
172
173 private final int archMaxWidth = 100;
174
175 private final int typePrefWidth = 145;
176
177 private final int typeMinWidth = 100;
178
179 private final int typeMaxWidth = 155;
180
181 /**
182 * This method initializes jSplitPane
183 *
184 * This is the main edit window
185 *
186 * @return javax.swing.JSplitPane jSplitPane
187 */
188 private JSplitPane getJSplitPane() {
189 if (jSplitPane == null) {
190 jSplitPane = new JSplitPane();
191 jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
192 jSplitPane.setDividerLocation(250);
193 jSplitPane.setBottomComponent(getJPanelBottom());
194 jSplitPane.setTopComponent(getJPanelTop());
195 }
196 return jSplitPane;
197 }
198
199 /**
200 * This method initializes jPanelTop
201 *
202 * This panel contains the All Modules Table
203 *
204 * @return javax.swing.JPanel jPanelTop
205 */
206 private JPanel getJPanelTop() {
207 if (jPanelTop == null) {
208 jLabel = new JLabel();
209 jLabel.setText("Modules in Workspace");
210 jPanelTop = new JPanel();
211 jPanelTop.setLayout(new BorderLayout());
212 jPanelTop.add(jLabel, java.awt.BorderLayout.NORTH);
213 jPanelTop.add(getJScrollPaneAllModules(), java.awt.BorderLayout.CENTER);
214 jPanelTop.add(getJPanelTopSouth(), java.awt.BorderLayout.SOUTH);
215 }
216 return jPanelTop;
217 }
218
219 /**
220 * This method initializes jPanelBottom
221 *
222 * This panel contains the FPD Modules Table
223 *
224 * @return javax.swing.JPanel jPanelBottom
225 */
226 private JPanel getJPanelBottom() {
227 if (jPanelBottom == null) {
228 jLabelModulesAdded = new JLabel();
229 jLabelModulesAdded.setText("Modules Added");
230 jPanelBottom = new JPanel();
231 jPanelBottom.setLayout(new BorderLayout());
232 jPanelBottom.add(jLabelModulesAdded, java.awt.BorderLayout.NORTH);
233 jPanelBottom.add(getJPanelBottomSouth(), java.awt.BorderLayout.SOUTH);
234 jPanelBottom.add(getJScrollPaneFpdModules(), java.awt.BorderLayout.CENTER);
235 }
236 return jPanelBottom;
237 }
238
239 /**
240 * This method initializes jScrollPaneAllModules
241 *
242 * @return javax.swing.JScrollPane jScrollPaneAllModules
243 */
244 private JScrollPane getJScrollPaneAllModules() {
245 if (jScrollPaneAllModules == null) {
246 jScrollPaneAllModules = new JScrollPane();
247 jScrollPaneAllModules.setPreferredSize(new java.awt.Dimension(600, 200));
248 jScrollPaneAllModules.setViewportView(getJTableAllModules());
249 }
250 return jScrollPaneAllModules;
251 }
252
253 /**
254 * This method initializes jTableAllModules
255 *
256 * @return javax.swing.JTable jTableAllModules
257 */
258 private JTable getJTableAllModules() {
259 if (jTableAllModules == null) {
260 modelAllModules = new NonEditableTableModel();
261 TableSorter sorter = new TableSorter(modelAllModules);
262 jTableAllModules = new JTable(sorter);
263 sorter.setTableHeader(jTableAllModules.getTableHeader());
264 jTableAllModules.setRowHeight(20);
265 modelAllModules.addColumn("<html>Module<br>Name</html>");
266 modelAllModules.addColumn("<html>Package<br>Name</html>");
267 modelAllModules.addColumn("Path");
268 modelAllModules.addColumn("<html>Module<br>Type</html>");
269 modelAllModules.addColumn("<html>Module<br>Version</html>");
270 modelAllModules.addColumn("<html>Package<br>Version</html>");
271
272 javax.swing.table.TableColumn column = null;
273 column = jTableAllModules.getColumnModel().getColumn(modNameColForAllModTable);
274 column.setPreferredWidth(modNamePrefWidth);
275 column.setMinWidth(modNameMinWidth);
276 column.setMaxWidth(modNameMaxWidth);
277 column = jTableAllModules.getColumnModel().getColumn(modVerColForAllModTable);
278 column.setPreferredWidth(verPrefWidth);
279 column.setMaxWidth(verMaxWidth);
280 column.setMinWidth(verMinWidth);
281 column = jTableAllModules.getColumnModel().getColumn(pkgNameColForAllModTable);
282 column.setPreferredWidth(pkgNamePrefWidth);
283 column.setMinWidth(pkgNameMinWidth);
284 column.setMaxWidth(pkgNameMaxWidth);
285 column = jTableAllModules.getColumnModel().getColumn(pkgVerColForAllModTable);
286 column.setPreferredWidth(verPrefWidth);
287 column.setMaxWidth(verMaxWidth);
288 column.setMinWidth(verMinWidth);
289 column = jTableAllModules.getColumnModel().getColumn(typeColForAllModTable);
290 column.setPreferredWidth(typePrefWidth);
291 column.setMaxWidth(typeMaxWidth);
292 column.setMinWidth(typeMinWidth);
293 column = jTableAllModules.getColumnModel().getColumn(pathColForAllModTable);
294 column.setPreferredWidth(pathPrefWidth);
295 column.setMinWidth(pathMinWidth);
296
297 jTableAllModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
298 jTableAllModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
299
300 }
301 return jTableAllModules;
302 }
303
304 /**
305 * This method initializes jPanelTopSouth
306 *
307 * This panel contains the ADD button
308 *
309 * @return javax.swing.JPanel jPanelTopSouth
310 */
311 private JPanel getJPanelTopSouth() {
312 if (jPanelTopSouth == null) {
313 FlowLayout flowLayout = new FlowLayout();
314 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
315 jPanelTopSouth = new JPanel();
316 jPanelTopSouth.setLayout(flowLayout);
317 jPanelTopSouth.add(getJButtonAddModule(), null);
318 }
319 return jPanelTopSouth;
320 }
321
322 /**
323 * This method initializes jButtonAddModule
324 *
325 * @return javax.swing.JButton jButtonAddModule
326 */
327 private JButton getJButtonAddModule() {
328 if (jButtonAddModule == null) {
329 jButtonAddModule = new JButton();
330 jButtonAddModule.setPreferredSize(new java.awt.Dimension(130, 20));
331 jButtonAddModule.setText("Add a Module");
332 jButtonAddModule.addActionListener(new java.awt.event.ActionListener() {
333 public void actionPerformed(java.awt.event.ActionEvent e) {
334 int selectedRow = jTableAllModules.getSelectedRow();
335 if (selectedRow < 0) {
336 return;
337 }
338
339 TableSorter sorter = (TableSorter) jTableAllModules.getModel();
340 selectedRow = sorter.getModelRowIndex(selectedRow);
341 String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + "";
342 ModuleIdentification mi = miList.get(selectedRow);
343 Vector<String> vArchs = null;
344 try {
345 vArchs = WorkspaceProfile.getModuleSupArchs(mi);
346 }
347 catch (Exception exp) {
348 JOptionPane.showMessageDialog(frame, exp.getMessage());
349 }
350
351 if (vArchs == null) {
352 JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");
353 return;
354 }
355
356 String archsAdded = "";
357 String mg = mi.getGuid();
358 String mv = mi.getVersion();
359 String pg = mi.getPackage().getGuid();
360 String pv = mi.getPackage().getVersion();
361 String mType = mi.getModuleType();
362
363 ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);
364 if (al == null) {
365 //
366 // if existing ModuleSA does not specify version info.
367 //
368 al = fpdMsa.get(mg + "null" + pg + "null");
369 if (al == null) {
370 al = fpdMsa.get(mg + "null" + pg + pv);
371 if (al == null){
372 al = fpdMsa.get(mg + mv + pg + "null");
373 if (al == null) {
374 al = new ArrayList<String>();
375 fpdMsa.put(mg + mv + pg + pv, al);
376 }
377 }
378 }
379 }
380 //
381 // filter from module SupArchs what archs has been added.
382 //
383 for (int i = 0; i < al.size(); ++i) {
384 vArchs.remove(al.get(i));
385 }
386 //
387 // check whether archs conform to SupArch of platform.
388 //
389 Vector<Object> platformSupArch = new Vector<Object>();
390 ffc.getPlatformDefsSupportedArchs(platformSupArch);
391 vArchs.retainAll(platformSupArch);
392 //
393 // Archs this Module supported have already been added.
394 //
395 if (vArchs.size() == 0) {
396 JOptionPane.showMessageDialog(frame, "This Module has already been added.");
397 return;
398 }
399 //ToDo put Arch instead of null
400 boolean errorOccurred = false;
401 for (int i = 0; i < vArchs.size(); ++i) {
402 String arch = vArchs.get(i);
403 al.add(arch);
404 archsAdded += arch + " ";
405 String[] row = { "", "", "", "", "", "", "" };
406
407 if (mi != null) {
408 row[modNameColForFpdModTable] = mi.getName();
409 row[pkgNameColForFpdModTable] = mi.getPackage().getName();
410 row[pathColForFpdModTable] = path;
411 row[archColForFpdModTable] = arch;
412 row[pkgVerColForFpdModTable] = pv;
413 row[modVerColForFpdModTable] = mv;
414 row[typeColForFpdModTable] = mType;
415
416 }
417 modelFpdModules.addRow(row);
418
419 docConsole.setSaved(false);
420 try {
421 //ToDo : specify archs need to add.
422 ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null);
423 } catch (Exception exception) {
424 JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch
425 + ": " + exception.getMessage());
426 errorOccurred = true;
427 }
428 }
429
430 String s = "This Module with Architecture " + archsAdded;
431 if (errorOccurred) {
432 s += " was added with Error. Platform may NOT Build.";
433 } else {
434 s += " was added Successfully.";
435 }
436 JOptionPane.showMessageDialog(frame, s);
437 TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel();
438 int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1];
439 jTableFpdModules.changeSelection(viewIndex, 0, false, false);
440 }
441 });
442 }
443 return jButtonAddModule;
444 }
445
446 /**
447 * This method initializes jPanelBottomSouth
448 *
449 * This panel contains the Settings and Remove Buttons
450 *
451 * @return javax.swing.JPanel jPanelBottomSouth
452 */
453 private JPanel getJPanelBottomSouth() {
454 if (jPanelBottomSouth == null) {
455 FlowLayout flowLayout1 = new FlowLayout();
456 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
457 jPanelBottomSouth = new JPanel();
458 jPanelBottomSouth.setLayout(flowLayout1);
459 jPanelBottomSouth.add(getJButtonSettings(), null);
460 jPanelBottomSouth.add(getJButtonRemoveModule(), null);
461 }
462 return jPanelBottomSouth;
463 }
464
465 /**
466 * This method initializes jScrollPaneFpdModules
467 *
468 * @return javax.swing.JScrollPane jScrollPaneFpdModules
469 */
470 private JScrollPane getJScrollPaneFpdModules() {
471 if (jScrollPaneFpdModules == null) {
472 jScrollPaneFpdModules = new JScrollPane();
473 jScrollPaneFpdModules.setPreferredSize(new java.awt.Dimension(453, 200));
474 jScrollPaneFpdModules.setViewportView(getJTableFpdModules());
475 }
476 return jScrollPaneFpdModules;
477 }
478
479 /**
480 * This method initializes jTableFpdModules
481 *
482 * @return javax.swing.JTable jTableFpdModules
483 */
484 private JTable getJTableFpdModules() {
485 if (jTableFpdModules == null) {
486 modelFpdModules = new FpdModulesTableModel();
487 TableSorter sorter = new TableSorter(modelFpdModules);
488 jTableFpdModules = new JTable(sorter);
489 sorter.setTableHeader(jTableFpdModules.getTableHeader());
490 jTableFpdModules.setRowHeight(20);
491 modelFpdModules.addColumn("<html>Module<br>Name</html>");
492 modelFpdModules.addColumn("<html>Package<br>Name</html>");
493 modelFpdModules.addColumn("Path");
494 modelFpdModules.addColumn("<html>Supported<br>Architectures</html>");
495 modelFpdModules.addColumn("<html>Module<br>Type</html>");
496 modelFpdModules.addColumn("<html>Module<br>Version</html>");
497 modelFpdModules.addColumn("<html>Package<br>Version</html>");
498 modelFpdModules.addColumn("<html>Force<br>Debug</html>");
499
500 javax.swing.table.TableColumn column = null;
501 column = jTableFpdModules.getColumnModel().getColumn(modNameColForFpdModTable);
502 column.setPreferredWidth(modNamePrefWidth);
503 column.setMinWidth(modNameMinWidth);
504 column.setMaxWidth(modNameMaxWidth);
505 column = jTableFpdModules.getColumnModel().getColumn(modVerColForFpdModTable);
506 column.setPreferredWidth(verPrefWidth);
507 column.setMaxWidth(verMaxWidth);
508 column.setMinWidth(verMinWidth);
509 column = jTableFpdModules.getColumnModel().getColumn(pkgNameColForFpdModTable);
510 column.setPreferredWidth(pkgNamePrefWidth);
511 column.setMinWidth(pkgNameMinWidth);
512 column.setMaxWidth(pkgNameMaxWidth);
513 column = jTableFpdModules.getColumnModel().getColumn(pkgVerColForFpdModTable);
514 column.setPreferredWidth(verPrefWidth);
515 column.setMaxWidth(verMaxWidth);
516 column.setMinWidth(verMinWidth);
517 column = jTableFpdModules.getColumnModel().getColumn(archColForFpdModTable);
518 column.setPreferredWidth(archPrefWidth);
519 column.setMaxWidth(archMaxWidth);
520 column.setMinWidth(archMinWidth);
521 column = jTableFpdModules.getColumnModel().getColumn(pathColForFpdModTable);
522 column.setPreferredWidth(pathPrefWidth);
523 column.setMinWidth(pathMinWidth);
524 column = jTableFpdModules.getColumnModel().getColumn(typeColForFpdModTable);
525 column.setPreferredWidth(typePrefWidth);
526 column.setMaxWidth(typeMaxWidth);
527 column.setMinWidth(typeMinWidth);
528
529 jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
530 jTableFpdModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
531
532 }
533 return jTableFpdModules;
534 }
535
536 /**
537 * This method initializes jButtonSettings
538 *
539 * @return javax.swing.JButton jButtonSettings
540 */
541 private JButton getJButtonSettings() {
542 if (jButtonSettings == null) {
543 jButtonSettings = new JButton();
544 jButtonSettings.setPreferredSize(new java.awt.Dimension(130,20));
545 jButtonSettings.setText("Settings");
546 jButtonSettings.addActionListener(new java.awt.event.ActionListener() {
547 public void actionPerformed(java.awt.event.ActionEvent e) {
548 int selectedRow = jTableFpdModules.getSelectedRow();
549 if (selectedRow < 0) {
550 return;
551 }
552
553 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();
554 selectedRow = sorter.getModelRowIndex(selectedRow);
555 try {
556 if (ffc.adjustPcd(selectedRow)) {
557 docConsole.setSaved(false);
558 }
559 }
560 catch (Exception exp) {
561 JOptionPane.showMessageDialog(frame, exp.getMessage());
562 return;
563 }
564
565 if (settingDlg == null) {
566 settingDlg = new FpdModuleSA(ffc);
567 }
568
569 String[] sa = new String[5];
570 ffc.getFrameworkModuleInfo(selectedRow, sa);
571 String mg = sa[ffcModGuid];
572 String mv = sa[ffcModVer];
573 String pg = sa[ffcPkgGuid];
574 String pv = sa[ffcPkgVer];
575 String arch = sa[ffcModArch];
576 settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole);
577 settingDlg.setVisible(true);
578 }
579 });
580 }
581 return jButtonSettings;
582 }
583
584 /**
585 * This method initializes jButtonRemoveModule
586 *
587 * @return javax.swing.JButton jButtonRemoveModule
588 */
589 private JButton getJButtonRemoveModule() {
590 if (jButtonRemoveModule == null) {
591 jButtonRemoveModule = new JButton();
592 jButtonRemoveModule.setPreferredSize(new java.awt.Dimension(130, 20));
593 jButtonRemoveModule.setText("Remove Module");
594 jButtonRemoveModule.addActionListener(new java.awt.event.ActionListener() {
595 public void actionPerformed(java.awt.event.ActionEvent e) {
596 int selectedRow = jTableFpdModules.getSelectedRow();
597 if (selectedRow < 0) {
598 return;
599 }
600 docConsole.setSaved(false);
601
602 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();
603 selectedRow = sorter.getModelRowIndex(selectedRow);
604
605 String[] sa = new String[5];
606 ffc.getFrameworkModuleInfo(selectedRow, sa);
607 String mg = sa[ffcModGuid];
608 String mv = sa[ffcModVer];
609 String pg = sa[ffcPkgGuid];
610 String pv = sa[ffcPkgVer];
611 String arch = sa[ffcModArch];
612 ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);
613 mv = mi.getVersion();
614 pv = mi.getPackage().getVersion();
615 modelFpdModules.removeRow(selectedRow);
616 if (arch == null) {
617 // if no arch specified in ModuleSA
618 fpdMsa.remove(mg + mv + pg + pv);
619
620 } else {
621 ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);
622 al.remove(arch);
623 if (al.size() == 0) {
624 fpdMsa.remove(mg + mv + pg + pv);
625 }
626 }
627
628 ffc.removeModuleSA(selectedRow);
629 }
630 });
631 }
632 return jButtonRemoveModule;
633 }
634
635 /**
636 *
637 * @param args
638 */
639 public static void main(String[] args) {
640 // Set the pane visable
641 new FpdFrameworkModules().setVisible(true);
642 }
643
644 /**
645 * This is the default constructor
646 */
647 public FpdFrameworkModules() {
648 super();
649 initialize();
650 }
651
652 public FpdFrameworkModules(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
653 this();
654 init(fpd);
655
656 }
657
658 public FpdFrameworkModules(OpeningPlatformType opt) {
659 this(opt.getXmlFpd());
660 docConsole = opt;
661 }
662
663 private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
664 try {
665 WorkspaceProfile.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
666 }
667 catch(Exception e){
668 JOptionPane.showMessageDialog(frame, "Error occurred when getting module data.");
669 }
670
671 if (ffc == null) {
672 ffc = new FpdFileContents(fpd);
673 ffc.initDynPcdMap();
674 }
675
676 if (fpdMsa == null) {
677 fpdMsa = new HashMap<String, ArrayList<String>>();
678 }
679
680 if (ffc.getFrameworkModulesCount() > 0) {
681 String[][] saa = new String[ffc.getFrameworkModulesCount()][5];
682 ffc.getFrameworkModulesInfo(saa);
683 for (int i = 0; i < saa.length; ++i) {
684 ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " "
685 + saa[i][ffcPkgGuid] + " " + saa[i][ffcPkgVer]);
686 Object[] row = { "", "", "", "", "", "", "", "" };
687 if (mi != null) {
688 row[modNameColForFpdModTable] = mi.getName();
689 row[modVerColForFpdModTable] = mi.getVersion();
690 row[typeColForFpdModTable] = mi.getModuleType();
691 row[pkgNameColForFpdModTable] = mi.getPackage().getName();
692 row[pkgVerColForFpdModTable] = mi.getPackage().getVersion();
693 row[archColForFpdModTable] = saa[i][ffcModArch];
694 try {
695 row[pathColForFpdModTable] = WorkspaceProfile.getMsaFile(mi).getPath().substring(
696 System.getenv("WORKSPACE")
697 .length() + 1);
698 } catch (Exception e) {
699 JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());
700 }
701
702 String fpdMsaKey = saa[i][ffcModGuid] + row[modVerColForFpdModTable]
703 + saa[i][ffcPkgGuid] + row[pkgVerColForFpdModTable];
704 ArrayList<String> al = fpdMsa.get(fpdMsaKey);
705 if (al == null) {
706 al = new ArrayList<String>();
707 fpdMsa.put(fpdMsaKey, al);
708 }
709 al.add(saa[i][ffcModArch]);
710 }
711 row[forceDbgColForFpdModTable] = ffc.getModuleSAForceDebug(i);
712 modelFpdModules.addRow(row);
713
714 }
715 TableSorter sorter = (TableSorter)jTableFpdModules.getModel();
716 sorter.setSortState(modNameColForFpdModTable, TableSorter.ASCENDING);
717 }
718
719 showAllModules();
720
721 }
722
723 private void showAllModules() {
724
725 if (miList == null) {
726 miList = new ArrayList<ModuleIdentification>();
727 }
728 Set<PackageIdentification> spi = WorkspaceProfile.getPackageList();
729 Iterator ispi = spi.iterator();
730
731 while (ispi.hasNext()) {
732 PackageIdentification pi = (PackageIdentification) ispi.next();
733 String[] s = { "", "", "", "", "", "" };
734
735 Set<ModuleIdentification> smi = WorkspaceProfile.getModules(pi);
736 Iterator ismi = smi.iterator();
737 while (ismi.hasNext()) {
738 ModuleIdentification mi = (ModuleIdentification) ismi.next();
739 s[modNameColForAllModTable] = mi.getName();
740 s[modVerColForAllModTable] = mi.getVersion();
741 s[typeColForAllModTable] = mi.getModuleType();
742 s[pkgNameColForAllModTable] = pi.getName();
743 s[pkgVerColForAllModTable] = pi.getVersion();
744 try {
745 s[pathColForAllModTable] = WorkspaceProfile.getMsaFile(mi).getPath()
746 .substring(System.getenv("WORKSPACE").length() + 1);
747 } catch (Exception e) {
748 JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());
749 }
750 modelAllModules.addRow(s);
751 miList.add(mi);
752 }
753 }
754
755 TableSorter sorter = (TableSorter)jTableAllModules.getModel();
756 sorter.setSortState(modNameColForAllModTable, TableSorter.ASCENDING);
757 }
758
759 /**
760 * This method initializes this
761 *
762 * @return void
763 */
764 private void initialize() {
765 this.setSize(633, 533);
766 this.setTitle("Framework Modules");
767 this.setContentPane(getJSplitPane());
768 this.setVisible(true);
769
770 }
771
772 } // @jve:decl-index=0:visual-constraint="10,10"
773
774 class NonEditableTableModel extends DefaultTableModel {
775 /**
776 *
777 */
778 private static final long serialVersionUID = 1L;
779
780 public boolean isCellEditable(int row, int col) {
781 return false;
782 }
783 }
784
785 class FpdModulesTableModel extends DefaultTableModel {
786
787 /**
788 *
789 */
790 private static final long serialVersionUID = 1L;
791
792 public Class<?> getColumnClass (int c) {
793 if (getValueAt(0, c) != null){
794 return getValueAt(0, c).getClass();
795 }
796 return String.class;
797 }
798
799 public boolean isCellEditable (int row, int col) {
800 if (col == FpdFrameworkModules.forceDbgColForFpdModTable) {
801 return true;
802 }
803 return false;
804 }
805 }