3 The file is used to create, update FrameworkModules of Fpd file
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
.platform
.ui
;
17 import java
.awt
.BorderLayout
;
18 import java
.awt
.Dimension
;
19 import java
.awt
.FontMetrics
;
21 import javax
.swing
.JFrame
;
22 import javax
.swing
.JOptionPane
;
23 import javax
.swing
.JPanel
;
24 import javax
.swing
.JSplitPane
;
25 import javax
.swing
.JLabel
;
26 import javax
.swing
.JScrollPane
;
27 import javax
.swing
.JTable
;
28 import javax
.swing
.JButton
;
29 import javax
.swing
.ListSelectionModel
;
30 import javax
.swing
.event
.TableModelEvent
;
31 import javax
.swing
.table
.DefaultTableModel
;
32 import javax
.swing
.table
.TableModel
;
34 import org
.tianocore
.PlatformSurfaceAreaDocument
;
35 import org
.tianocore
.frameworkwizard
.common
.GlobalData
;
36 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPlatformType
;
37 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
38 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
39 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
40 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
42 import java
.awt
.FlowLayout
;
43 import java
.awt
.event
.KeyEvent
;
44 import java
.awt
.event
.MouseEvent
;
45 import java
.util
.ArrayList
;
46 import java
.util
.HashMap
;
47 import java
.util
.Iterator
;
49 import java
.util
.Vector
;
51 public class FpdFrameworkModules
extends IInternalFrame
{
56 private static final long serialVersionUID
= 1L;
58 private static final int timeToWait
= 2000;
60 private long savedMs
= 0;
62 String searchField
= "";
64 public static final int forceDbgColForFpdModTable
= 7;
68 private JSplitPane jSplitPane
= null;
70 private JPanel jPanelTop
= null;
72 private JPanel jPanelBottom
= null;
74 private JLabel jLabel
= null;
76 private JScrollPane jScrollPaneAllModules
= null;
78 private JTable jTableAllModules
= null;
80 private JPanel jPanelTopSouth
= null;
82 private JButton jButtonAddModule
= null;
84 private JLabel jLabelModulesAdded
= null;
86 private JPanel jPanelBottomSouth
= null;
88 private JScrollPane jScrollPaneFpdModules
= null;
90 private JTable jTableFpdModules
= null;
92 private JButton jButtonSettings
= null;
94 private JButton jButtonRemoveModule
= null;
96 private NonEditableTableModel modelAllModules
= null;
98 private FpdModulesTableModel modelFpdModules
= null;
100 private FpdModuleSA settingDlg
= null;
102 private FpdFileContents ffc
= null;
104 private OpeningPlatformType docConsole
= null;
106 private Map
<String
, ArrayList
<String
>> fpdMsa
= null;
108 private ArrayList
<ModuleIdentification
> miList
= null;
111 * Column settings for displaying all modules in workspace
113 private final int modNameColForAllModTable
= 0;
115 private final int pkgNameColForAllModTable
= 1;
117 private final int pathColForAllModTable
= 2;
119 private final int typeColForAllModTable
= 3;
121 private final int pkgVerColForAllModTable
= 5;
123 private final int modVerColForAllModTable
= 4;
126 * Column settings for display modules in the FPD file
128 private final int modNameColForFpdModTable
= 0;
130 private final int pkgNameColForFpdModTable
= 1;
132 private final int pathColForFpdModTable
= 2;
134 private final int archColForFpdModTable
= 3;
136 private final int pkgVerColForFpdModTable
= 6;
138 private final int modVerColForFpdModTable
= 5;
140 private final int typeColForFpdModTable
= 4;
143 * FpdFileContents structure
145 private final int ffcModGuid
= 0;
147 private final int ffcModVer
= 1;
149 private final int ffcPkgGuid
= 2;
151 private final int ffcPkgVer
= 3;
153 private final int ffcModArch
= 4;
156 * Set Column Widths, Only the PATH should not have a max width.
158 private final int modNameMinWidth
= 168;
160 private final int modNamePrefWidth
= 200;
162 private final int modNameMaxWidth
= 350;
164 private final int pkgNameMinWidth
= 100;
166 private final int pkgNamePrefWidth
= 130;
168 private final int pkgNameMaxWidth
= 150;
170 private final int verMinWidth
= 60;
172 private final int verMaxWidth
= 80;
174 private final int verPrefWidth
= 70;
176 private final int pathPrefWidth
= 600;
178 private final int pathMinWidth
= 280;
180 private final int archPrefWidth
= 80;
182 private final int archMinWidth
= 60;
184 private final int archMaxWidth
= 100;
186 private final int typePrefWidth
= 145;
188 private final int typeMinWidth
= 100;
190 private final int typeMaxWidth
= 155;
193 * This method initializes jSplitPane
195 * This is the main edit window
197 * @return javax.swing.JSplitPane jSplitPane
199 private JSplitPane
getJSplitPane() {
200 if (jSplitPane
== null) {
201 jSplitPane
= new JSplitPane();
202 jSplitPane
.setOrientation(javax
.swing
.JSplitPane
.VERTICAL_SPLIT
);
203 jSplitPane
.setDividerLocation(250);
204 jSplitPane
.setBottomComponent(getJPanelBottom());
205 jSplitPane
.setTopComponent(getJPanelTop());
211 * This method initializes jPanelTop
213 * This panel contains the All Modules Table
215 * @return javax.swing.JPanel jPanelTop
217 private JPanel
getJPanelTop() {
218 if (jPanelTop
== null) {
219 jLabel
= new JLabel();
220 jLabel
.setText(" Modules in Workspace");
221 jPanelTop
= new JPanel();
222 jPanelTop
.setLayout(new BorderLayout());
223 jPanelTop
.add(jLabel
, java
.awt
.BorderLayout
.NORTH
);
224 jPanelTop
.add(getJScrollPaneAllModules(), java
.awt
.BorderLayout
.CENTER
);
225 jPanelTop
.add(getJPanelTopSouth(), java
.awt
.BorderLayout
.SOUTH
);
231 * This method initializes jPanelBottom
233 * This panel contains the FPD Modules Table
235 * @return javax.swing.JPanel jPanelBottom
237 private JPanel
getJPanelBottom() {
238 if (jPanelBottom
== null) {
239 jLabelModulesAdded
= new JLabel();
240 jLabelModulesAdded
.setText(" Modules Added into Platform");
241 jPanelBottom
= new JPanel();
242 jPanelBottom
.setLayout(new BorderLayout());
243 jPanelBottom
.add(jLabelModulesAdded
, java
.awt
.BorderLayout
.NORTH
);
244 jPanelBottom
.add(getJPanelBottomSouth(), java
.awt
.BorderLayout
.SOUTH
);
245 jPanelBottom
.add(getJScrollPaneFpdModules(), java
.awt
.BorderLayout
.CENTER
);
251 * This method initializes jScrollPaneAllModules
253 * @return javax.swing.JScrollPane jScrollPaneAllModules
255 private JScrollPane
getJScrollPaneAllModules() {
256 if (jScrollPaneAllModules
== null) {
257 jScrollPaneAllModules
= new JScrollPane();
258 jScrollPaneAllModules
.setPreferredSize(new java
.awt
.Dimension(600, 200));
259 jScrollPaneAllModules
.setViewportView(getJTableAllModules());
261 return jScrollPaneAllModules
;
265 * This method initializes jTableAllModules
267 * @return javax.swing.JTable jTableAllModules
269 private JTable
getJTableAllModules() {
270 if (jTableAllModules
== null) {
271 modelAllModules
= new NonEditableTableModel();
272 TableSorter sorter
= new TableSorter(modelAllModules
);
273 jTableAllModules
= new JTable(sorter
);
274 sorter
.setTableHeader(jTableAllModules
.getTableHeader());
275 jTableAllModules
.setRowHeight(20);
276 modelAllModules
.addColumn("<html>Module<br>Name</html>");
277 modelAllModules
.addColumn("<html>Package<br>Name</html>");
278 modelAllModules
.addColumn("Path");
279 modelAllModules
.addColumn("<html>Module<br>Type</html>");
280 modelAllModules
.addColumn("<html>Module<br>Version</html>");
281 modelAllModules
.addColumn("<html>Package<br>Version</html>");
283 javax
.swing
.table
.TableColumn column
= null;
284 column
= jTableAllModules
.getColumnModel().getColumn(modNameColForAllModTable
);
285 column
.setPreferredWidth(modNamePrefWidth
);
286 column
.setMinWidth(modNameMinWidth
);
287 column
.setMaxWidth(modNameMaxWidth
);
288 column
= jTableAllModules
.getColumnModel().getColumn(modVerColForAllModTable
);
289 column
.setPreferredWidth(verPrefWidth
);
290 column
.setMaxWidth(verMaxWidth
);
291 column
.setMinWidth(verMinWidth
);
292 column
= jTableAllModules
.getColumnModel().getColumn(pkgNameColForAllModTable
);
293 column
.setPreferredWidth(pkgNamePrefWidth
);
294 column
.setMinWidth(pkgNameMinWidth
);
295 column
.setMaxWidth(pkgNameMaxWidth
);
296 column
= jTableAllModules
.getColumnModel().getColumn(pkgVerColForAllModTable
);
297 column
.setPreferredWidth(verPrefWidth
);
298 column
.setMaxWidth(verMaxWidth
);
299 column
.setMinWidth(verMinWidth
);
300 column
= jTableAllModules
.getColumnModel().getColumn(typeColForAllModTable
);
301 column
.setPreferredWidth(typePrefWidth
);
302 column
.setMaxWidth(typeMaxWidth
);
303 column
.setMinWidth(typeMinWidth
);
304 column
= jTableAllModules
.getColumnModel().getColumn(pathColForAllModTable
);
305 column
.setPreferredWidth(pathPrefWidth
);
306 column
.setMinWidth(pathMinWidth
);
308 jTableAllModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
309 jTableAllModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
310 jTableAllModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
311 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
312 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
313 java
.awt
.Point p
= e
.getPoint();
314 int rowIndex
= jTableAllModules
.rowAtPoint(p
);
315 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
316 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
317 addModuleIntoPlatform (rowIndex
);
321 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
322 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
323 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
324 int selectedRow
= jTableAllModules
.getSelectedRow();
325 if (selectedRow
< 0) {
328 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
329 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
330 addModuleIntoPlatform (selectedRow
);
335 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
336 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
338 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
339 searchField
+= e
.getKeyChar();
342 searchField
= "" + e
.getKeyChar();
345 int viewIndex
= gotoFoundRow (searchField
, jTableAllModules
);
347 jTableAllModules
.changeSelection(viewIndex
, 0, false, false);
349 savedMs
= System
.currentTimeMillis();
355 return jTableAllModules
;
358 private int gotoFoundRow (String s
, JTable model
) {
359 for (int i
= 0; i
< model
.getRowCount(); ++i
) {
360 if (model
.getValueAt(i
, 0) != null && model
.getValueAt(i
, 0).toString().regionMatches(true, 0, s
, 0, s
.length())) {
368 * This method initializes jPanelTopSouth
370 * This panel contains the ADD button
372 * @return javax.swing.JPanel jPanelTopSouth
374 private JPanel
getJPanelTopSouth() {
375 if (jPanelTopSouth
== null) {
376 FlowLayout flowLayout
= new FlowLayout();
377 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
378 jPanelTopSouth
= new JPanel();
379 jPanelTopSouth
.setLayout(flowLayout
);
380 jPanelTopSouth
.add(getJButtonAddModule(), null);
382 return jPanelTopSouth
;
385 private void addModuleIntoPlatform (int selectedRow
) {
386 String path
= modelAllModules
.getValueAt(selectedRow
, pathColForAllModTable
) + "";
387 ModuleIdentification mi
= miList
.get(selectedRow
);
388 Vector
<String
> vArchs
= null;
390 vArchs
= WorkspaceProfile
.getModuleSupArchs(mi
);
392 catch (Exception exp
) {
393 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
396 if (vArchs
== null) {
397 JOptionPane
.showMessageDialog(frame
, "No Supported Architectures specified in MSA file.");
401 String archsAdded
= "";
402 String mg
= mi
.getGuid();
403 String mv
= mi
.getVersion();
404 String pg
= mi
.getPackageId().getGuid();
405 String pv
= mi
.getPackageId().getVersion();
406 String mType
= SurfaceAreaQuery
.getModuleType(mi
);
408 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
411 // if existing ModuleSA does not specify version info.
413 al
= fpdMsa
.get(mg
+ "null" + pg
+ "null");
415 al
= fpdMsa
.get(mg
+ "null" + pg
+ pv
);
417 al
= fpdMsa
.get(mg
+ mv
+ pg
+ "null");
419 al
= new ArrayList
<String
>();
420 fpdMsa
.put(mg
+ mv
+ pg
+ pv
, al
);
426 // filter from module SupArchs what archs has been added.
428 for (int i
= 0; i
< al
.size(); ++i
) {
429 vArchs
.remove(al
.get(i
));
432 // check whether archs conform to SupArch of platform.
434 Vector
<Object
> platformSupArch
= new Vector
<Object
>();
435 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
436 vArchs
.retainAll(platformSupArch
);
438 // Archs this Module supported have already been added.
440 if (vArchs
.size() == 0) {
441 JOptionPane
.showMessageDialog(frame
, "This Module has already been added.");
444 //ToDo put Arch instead of null
445 boolean errorOccurred
= false;
446 for (int i
= 0; i
< vArchs
.size(); ++i
) {
447 String arch
= vArchs
.get(i
);
449 archsAdded
+= arch
+ " ";
450 String
[] row
= { "", "", "", "", "", "", "" };
453 row
[modNameColForFpdModTable
] = mi
.getName();
454 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
455 row
[pathColForFpdModTable
] = path
;
456 row
[archColForFpdModTable
] = arch
;
457 row
[pkgVerColForFpdModTable
] = pv
;
458 row
[modVerColForFpdModTable
] = mv
;
459 row
[typeColForFpdModTable
] = mType
;
462 modelFpdModules
.addRow(row
);
464 docConsole
.setSaved(false);
466 //ToDo : specify archs need to add.
467 ffc
.addFrameworkModulesPcdBuildDefs(mi
, arch
, null);
468 } catch (Exception exception
) {
469 JOptionPane
.showMessageDialog(frame
, "Adding " + row
[modNameColForFpdModTable
] + " with Supporting Architectures: " + arch
470 + ": " + exception
.getMessage());
471 errorOccurred
= true;
475 String s
= "This Module with Architecture " + archsAdded
;
477 s
+= " was added with Error. Platform may NOT Build.";
479 s
+= " was added Successfully.";
481 JOptionPane
.showMessageDialog(frame
, s
);
482 TableSorter sorterFpdModules
= (TableSorter
)jTableFpdModules
.getModel();
483 int viewIndex
= sorterFpdModules
.getViewIndexArray()[modelFpdModules
.getRowCount() - 1];
484 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
489 * This method initializes jButtonAddModule
491 * @return javax.swing.JButton jButtonAddModule
493 private JButton
getJButtonAddModule() {
494 if (jButtonAddModule
== null) {
495 jButtonAddModule
= new JButton();
496 jButtonAddModule
.setPreferredSize(new java
.awt
.Dimension(130, 20));
497 jButtonAddModule
.setText("Add a Module");
498 jButtonAddModule
.addActionListener(new java
.awt
.event
.ActionListener() {
499 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
500 int selectedRow
= jTableAllModules
.getSelectedRow();
501 if (selectedRow
< 0) {
505 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
506 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
507 addModuleIntoPlatform (selectedRow
);
511 return jButtonAddModule
;
515 * This method initializes jPanelBottomSouth
517 * This panel contains the Settings and Remove Buttons
519 * @return javax.swing.JPanel jPanelBottomSouth
521 private JPanel
getJPanelBottomSouth() {
522 if (jPanelBottomSouth
== null) {
523 FlowLayout flowLayout1
= new FlowLayout();
524 flowLayout1
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
525 jPanelBottomSouth
= new JPanel();
526 jPanelBottomSouth
.setLayout(flowLayout1
);
527 jPanelBottomSouth
.add(getJButtonSettings(), null);
528 jPanelBottomSouth
.add(getJButtonRemoveModule(), null);
530 return jPanelBottomSouth
;
534 * This method initializes jScrollPaneFpdModules
536 * @return javax.swing.JScrollPane jScrollPaneFpdModules
538 private JScrollPane
getJScrollPaneFpdModules() {
539 if (jScrollPaneFpdModules
== null) {
540 jScrollPaneFpdModules
= new JScrollPane();
541 jScrollPaneFpdModules
.setPreferredSize(new java
.awt
.Dimension(453, 200));
542 jScrollPaneFpdModules
.setViewportView(getJTableFpdModules());
544 return jScrollPaneFpdModules
;
548 * This method initializes jTableFpdModules
550 * @return javax.swing.JTable jTableFpdModules
552 private JTable
getJTableFpdModules() {
553 if (jTableFpdModules
== null) {
554 modelFpdModules
= new FpdModulesTableModel();
555 TableSorter sorter
= new TableSorter(modelFpdModules
);
556 jTableFpdModules
= new JTable(sorter
);
557 sorter
.setTableHeader(jTableFpdModules
.getTableHeader());
558 jTableFpdModules
.setRowHeight(20);
559 modelFpdModules
.addColumn("<html>Module<br>Name</html>");
560 modelFpdModules
.addColumn("<html>Package<br>Name</html>");
561 modelFpdModules
.addColumn("Path");
562 modelFpdModules
.addColumn("<html>Supported<br>Architectures</html>");
563 modelFpdModules
.addColumn("<html>Module<br>Type</html>");
564 modelFpdModules
.addColumn("<html>Module<br>Version</html>");
565 modelFpdModules
.addColumn("<html>Package<br>Version</html>");
566 modelFpdModules
.addColumn("<html>Force<br>Debug</html>");
568 javax
.swing
.table
.TableColumn column
= null;
569 column
= jTableFpdModules
.getColumnModel().getColumn(modNameColForFpdModTable
);
570 column
.setPreferredWidth(modNamePrefWidth
);
571 column
.setMinWidth(modNameMinWidth
);
572 column
.setMaxWidth(modNameMaxWidth
);
573 column
= jTableFpdModules
.getColumnModel().getColumn(modVerColForFpdModTable
);
574 column
.setPreferredWidth(verPrefWidth
);
575 column
.setMaxWidth(verMaxWidth
);
576 column
.setMinWidth(verMinWidth
);
577 column
= jTableFpdModules
.getColumnModel().getColumn(pkgNameColForFpdModTable
);
578 column
.setPreferredWidth(pkgNamePrefWidth
);
579 column
.setMinWidth(pkgNameMinWidth
);
580 column
.setMaxWidth(pkgNameMaxWidth
);
581 column
= jTableFpdModules
.getColumnModel().getColumn(pkgVerColForFpdModTable
);
582 column
.setPreferredWidth(verPrefWidth
);
583 column
.setMaxWidth(verMaxWidth
);
584 column
.setMinWidth(verMinWidth
);
585 column
= jTableFpdModules
.getColumnModel().getColumn(archColForFpdModTable
);
586 column
.setPreferredWidth(archPrefWidth
);
587 column
.setMaxWidth(archMaxWidth
);
588 column
.setMinWidth(archMinWidth
);
589 column
= jTableFpdModules
.getColumnModel().getColumn(pathColForFpdModTable
);
590 column
.setPreferredWidth(pathPrefWidth
);
591 column
.setMinWidth(pathMinWidth
);
592 column
= jTableFpdModules
.getColumnModel().getColumn(typeColForFpdModTable
);
593 column
.setPreferredWidth(typePrefWidth
);
594 column
.setMaxWidth(typeMaxWidth
);
595 column
.setMinWidth(typeMinWidth
);
597 jTableFpdModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
598 jTableFpdModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
600 jTableFpdModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
601 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
602 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
603 java
.awt
.Point p
= e
.getPoint();
604 int rowIndex
= jTableFpdModules
.rowAtPoint(p
);
605 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
606 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
607 showSettingsDlg (rowIndex
);
612 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
613 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
614 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
615 int selectedRow
= jTableFpdModules
.getSelectedRow();
616 if (selectedRow
< 0) {
619 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
620 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
621 showSettingsDlg (selectedRow
);
626 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
627 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
629 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
630 searchField
+= e
.getKeyChar();
633 searchField
= "" + e
.getKeyChar();
636 int viewIndex
= gotoFoundRow (searchField
, jTableFpdModules
);
638 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
640 savedMs
= System
.currentTimeMillis();
644 jTableFpdModules
.getModel().addTableModelListener(this);
646 return jTableFpdModules
;
649 public void tableChanged(TableModelEvent arg0
) {
650 if (arg0
.getType() == TableModelEvent
.UPDATE
){
651 int row
= arg0
.getFirstRow();
652 int column
= arg0
.getColumn();
653 TableModel m
= (TableModel
)arg0
.getSource();
655 if (column
!= forceDbgColForFpdModTable
) {
658 String s
= m
.getValueAt(row
, column
)+"";
659 boolean dbgEnable
= new Boolean(s
);
660 ffc
.setModuleSAForceDebug(row
, dbgEnable
);
661 docConsole
.setSaved(false);
665 private void showSettingsDlg (int row
) {
667 if (ffc
.adjustPcd(row
)) {
668 docConsole
.setSaved(false);
671 catch (Exception exp
) {
672 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
676 if (settingDlg
== null) {
677 settingDlg
= new FpdModuleSA(ffc
);
680 String
[] sa
= new String
[5];
681 ffc
.getFrameworkModuleInfo(row
, sa
);
682 String mg
= sa
[ffcModGuid
];
683 String mv
= sa
[ffcModVer
];
684 String pg
= sa
[ffcPkgGuid
];
685 String pv
= sa
[ffcPkgVer
];
686 String arch
= sa
[ffcModArch
];
687 settingDlg
.setKey(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
, row
, docConsole
);
688 settingDlg
.setVisible(true);
691 * This method initializes jButtonSettings
693 * @return javax.swing.JButton jButtonSettings
695 private JButton
getJButtonSettings() {
696 if (jButtonSettings
== null) {
697 jButtonSettings
= new JButton();
698 jButtonSettings
.setPreferredSize(new java
.awt
.Dimension(130,20));
699 jButtonSettings
.setText("Settings");
700 jButtonSettings
.addActionListener(new java
.awt
.event
.ActionListener() {
701 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
702 int selectedRow
= jTableFpdModules
.getSelectedRow();
703 if (selectedRow
< 0) {
707 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
708 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
709 showSettingsDlg (selectedRow
);
713 return jButtonSettings
;
717 * This method initializes jButtonRemoveModule
719 * @return javax.swing.JButton jButtonRemoveModule
721 private JButton
getJButtonRemoveModule() {
722 if (jButtonRemoveModule
== null) {
723 jButtonRemoveModule
= new JButton();
724 jButtonRemoveModule
.setText("Remove Module");
725 FontMetrics fm
= jButtonRemoveModule
.getFontMetrics(jButtonRemoveModule
.getFont());
726 jButtonRemoveModule
.setPreferredSize(new Dimension (fm
.stringWidth(jButtonRemoveModule
.getText()) + 40, 20));
727 jButtonRemoveModule
.addActionListener(new java
.awt
.event
.ActionListener() {
728 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
729 int selectedRow
= jTableFpdModules
.getSelectedRow();
730 if (selectedRow
< 0) {
733 int nextSelection
= selectedRow
;
735 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
736 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
738 String
[] sa
= new String
[5];
739 ffc
.getFrameworkModuleInfo(selectedRow
, sa
);
740 String mg
= sa
[ffcModGuid
];
741 String mv
= sa
[ffcModVer
];
742 String pg
= sa
[ffcPkgGuid
];
743 String pv
= sa
[ffcPkgVer
];
744 String arch
= sa
[ffcModArch
];
746 // sync. module order list in BuildOptions-UserExtensions.
748 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
749 String fvBindings
= ffc
.getFvBinding(moduleKey
);
750 if (fvBindings
!= null) {
751 String
[] fvArray
= fvBindings
.split(" ");
752 for (int i
= 0; i
< fvArray
.length
; ++i
) {
753 ffc
.removeModuleInBuildOptionsUserExtensions(fvArray
[i
].trim(), mg
, mv
, pg
, pv
, arch
);
757 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
);
759 mv
= mi
.getVersion();
760 pv
= mi
.getPackageId().getVersion();
764 ffc
.removeModuleSA(selectedRow
);
766 catch (Exception exp
) {
767 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
772 // if no arch specified in ModuleSA
773 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
776 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
779 if (al
.size() == 0) {
780 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
785 modelFpdModules
.removeRow(selectedRow
);
786 if (nextSelection
>= jTableFpdModules
.getRowCount()) {
787 nextSelection
= jTableFpdModules
.getRowCount() - 1;
789 jTableFpdModules
.changeSelection(nextSelection
, 0, false, false);
790 docConsole
.setSaved(false);
794 return jButtonRemoveModule
;
801 public static void main(String
[] args
) {
802 // Set the pane visable
803 new FpdFrameworkModules().setVisible(true);
807 * This is the default constructor
809 public FpdFrameworkModules() {
814 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
820 public FpdFrameworkModules(OpeningPlatformType opt
) {
821 this(opt
.getXmlFpd());
825 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
828 ffc
= new FpdFileContents(fpd
);
832 if (fpdMsa
== null) {
833 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
836 if (ffc
.getFrameworkModulesCount() > 0) {
837 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
838 ffc
.getFrameworkModulesInfo(saa
);
839 for (int i
= 0; i
< saa
.length
; ++i
) {
840 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
841 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
842 Object
[] row
= { "", "", "", "", "", "", "", "" };
844 row
[modNameColForFpdModTable
] = mi
.getName();
845 row
[modVerColForFpdModTable
] = mi
.getVersion();
846 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
847 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
848 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
849 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
851 row
[pathColForFpdModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
852 } catch (Exception e
) {
853 JOptionPane
.showMessageDialog(frame
, "Show FPD Modules:" + e
.getMessage());
856 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
857 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
858 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
860 al
= new ArrayList
<String
>();
861 fpdMsa
.put(fpdMsaKey
, al
);
863 al
.add(saa
[i
][ffcModArch
]);
866 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
867 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
868 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
869 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
870 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
872 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
873 modelFpdModules
.addRow(row
);
876 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
877 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
884 private void showAllModules() {
886 if (miList
== null) {
887 miList
= new ArrayList
<ModuleIdentification
>();
890 String
[] s
= { "", "", "", "", "", "" };
892 Iterator ismi
= GlobalData
.vModuleList
.iterator();
893 while (ismi
.hasNext()) {
894 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
895 s
[modNameColForAllModTable
] = mi
.getName();
896 s
[modVerColForAllModTable
] = mi
.getVersion();
897 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
898 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
899 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
901 s
[pathColForAllModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
902 } catch (Exception e
) {
903 JOptionPane
.showMessageDialog(frame
, "Show All Modules:" + e
.getMessage());
905 modelAllModules
.addRow(s
);
910 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
911 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
915 * This method initializes this
919 private void initialize() {
920 this.setSize(633, 533);
921 this.setTitle("Framework Modules");
922 this.setContentPane(getJSplitPane());
923 this.setVisible(true);
927 } // @jve:decl-index=0:visual-constraint="10,10"
929 class NonEditableTableModel
extends DefaultTableModel
{
933 private static final long serialVersionUID
= 1L;
935 public boolean isCellEditable(int row
, int col
) {
940 class FpdModulesTableModel
extends DefaultTableModel
{
945 private static final long serialVersionUID
= 1L;
947 public Class
<?
> getColumnClass (int c
) {
948 if (getValueAt(0, c
) != null){
949 return getValueAt(0, c
).getClass();
954 public boolean isCellEditable (int row
, int col
) {
955 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {