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 JOptionPane
.showMessageDialog(frame
, "Pcd entries sync. with those in MSA files.");
669 docConsole
.setSaved(false);
672 catch (Exception exp
) {
673 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
677 if (settingDlg
== null) {
678 settingDlg
= new FpdModuleSA(ffc
);
681 String
[] sa
= new String
[5];
682 ffc
.getFrameworkModuleInfo(row
, sa
);
683 String mg
= sa
[ffcModGuid
];
684 String mv
= sa
[ffcModVer
];
685 String pg
= sa
[ffcPkgGuid
];
686 String pv
= sa
[ffcPkgVer
];
687 String arch
= sa
[ffcModArch
];
688 settingDlg
.setKey(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
, row
, docConsole
);
689 settingDlg
.setVisible(true);
692 * This method initializes jButtonSettings
694 * @return javax.swing.JButton jButtonSettings
696 private JButton
getJButtonSettings() {
697 if (jButtonSettings
== null) {
698 jButtonSettings
= new JButton();
699 jButtonSettings
.setPreferredSize(new java
.awt
.Dimension(130,20));
700 jButtonSettings
.setText("Settings");
701 jButtonSettings
.addActionListener(new java
.awt
.event
.ActionListener() {
702 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
703 int selectedRow
= jTableFpdModules
.getSelectedRow();
704 if (selectedRow
< 0) {
708 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
709 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
710 showSettingsDlg (selectedRow
);
714 return jButtonSettings
;
718 * This method initializes jButtonRemoveModule
720 * @return javax.swing.JButton jButtonRemoveModule
722 private JButton
getJButtonRemoveModule() {
723 if (jButtonRemoveModule
== null) {
724 jButtonRemoveModule
= new JButton();
725 jButtonRemoveModule
.setText("Remove Module");
726 FontMetrics fm
= jButtonRemoveModule
.getFontMetrics(jButtonRemoveModule
.getFont());
727 jButtonRemoveModule
.setPreferredSize(new Dimension (fm
.stringWidth(jButtonRemoveModule
.getText()) + 40, 20));
728 jButtonRemoveModule
.addActionListener(new java
.awt
.event
.ActionListener() {
729 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
730 int selectedRow
= jTableFpdModules
.getSelectedRow();
731 if (selectedRow
< 0) {
734 int nextSelection
= selectedRow
;
736 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
737 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
739 String
[] sa
= new String
[5];
740 ffc
.getFrameworkModuleInfo(selectedRow
, sa
);
741 String mg
= sa
[ffcModGuid
];
742 String mv
= sa
[ffcModVer
];
743 String pg
= sa
[ffcPkgGuid
];
744 String pv
= sa
[ffcPkgVer
];
745 String arch
= sa
[ffcModArch
];
747 // sync. module order list in BuildOptions-UserExtensions.
749 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
750 String fvBindings
= ffc
.getFvBinding(moduleKey
);
751 if (fvBindings
!= null) {
752 String
[] fvArray
= fvBindings
.split(" ");
753 for (int i
= 0; i
< fvArray
.length
; ++i
) {
754 ffc
.removeModuleInBuildOptionsUserExtensions(fvArray
[i
].trim(), mg
, mv
, pg
, pv
, arch
);
758 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
);
760 mv
= mi
.getVersion();
761 pv
= mi
.getPackageId().getVersion();
765 ffc
.removeModuleSA(selectedRow
);
767 catch (Exception exp
) {
768 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
773 // if no arch specified in ModuleSA
774 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
777 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
780 if (al
.size() == 0) {
781 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
786 modelFpdModules
.removeRow(selectedRow
);
787 if (nextSelection
>= jTableFpdModules
.getRowCount()) {
788 nextSelection
= jTableFpdModules
.getRowCount() - 1;
790 jTableFpdModules
.changeSelection(nextSelection
, 0, false, false);
791 docConsole
.setSaved(false);
795 return jButtonRemoveModule
;
802 public static void main(String
[] args
) {
803 // Set the pane visable
804 new FpdFrameworkModules().setVisible(true);
808 * This is the default constructor
810 public FpdFrameworkModules() {
815 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
821 public FpdFrameworkModules(OpeningPlatformType opt
) {
822 this(opt
.getXmlFpd());
826 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
829 ffc
= new FpdFileContents(fpd
);
833 if (fpdMsa
== null) {
834 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
837 if (ffc
.getFrameworkModulesCount() > 0) {
838 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
839 ffc
.getFrameworkModulesInfo(saa
);
840 for (int i
= 0; i
< saa
.length
; ++i
) {
841 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
842 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
843 Object
[] row
= { "", "", "", "", "", "", "", "" };
845 row
[modNameColForFpdModTable
] = mi
.getName();
846 row
[modVerColForFpdModTable
] = mi
.getVersion();
847 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
848 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
849 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
850 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
852 row
[pathColForFpdModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
853 } catch (Exception e
) {
854 JOptionPane
.showMessageDialog(frame
, "Show FPD Modules:" + e
.getMessage());
857 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
858 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
859 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
861 al
= new ArrayList
<String
>();
862 fpdMsa
.put(fpdMsaKey
, al
);
864 al
.add(saa
[i
][ffcModArch
]);
867 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
868 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
869 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
870 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
871 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
873 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
874 modelFpdModules
.addRow(row
);
877 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
878 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
885 private void showAllModules() {
887 if (miList
== null) {
888 miList
= new ArrayList
<ModuleIdentification
>();
891 String
[] s
= { "", "", "", "", "", "" };
893 Iterator ismi
= GlobalData
.vModuleList
.iterator();
894 while (ismi
.hasNext()) {
895 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
896 s
[modNameColForAllModTable
] = mi
.getName();
897 s
[modVerColForAllModTable
] = mi
.getVersion();
898 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
899 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
900 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
902 s
[pathColForAllModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
903 } catch (Exception e
) {
904 JOptionPane
.showMessageDialog(frame
, "Show All Modules:" + e
.getMessage());
906 modelAllModules
.addRow(s
);
911 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
912 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
916 * This method initializes this
920 private void initialize() {
921 this.setSize(633, 533);
922 this.setTitle("Framework Modules");
923 this.setContentPane(getJSplitPane());
924 this.setVisible(true);
928 } // @jve:decl-index=0:visual-constraint="10,10"
930 class NonEditableTableModel
extends DefaultTableModel
{
934 private static final long serialVersionUID
= 1L;
936 public boolean isCellEditable(int row
, int col
) {
941 class FpdModulesTableModel
extends DefaultTableModel
{
946 private static final long serialVersionUID
= 1L;
948 public Class
<?
> getColumnClass (int c
) {
949 if (getValueAt(0, c
) != null){
950 return getValueAt(0, c
).getClass();
955 public boolean isCellEditable (int row
, int col
) {
956 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {