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
.ActionEvent
;
44 import java
.awt
.event
.KeyEvent
;
45 import java
.awt
.event
.MouseEvent
;
46 import java
.util
.ArrayList
;
47 import java
.util
.HashMap
;
48 import java
.util
.Iterator
;
50 import java
.util
.Vector
;
52 public class FpdFrameworkModules
extends IInternalFrame
{
57 private static final long serialVersionUID
= 1L;
59 private static final int timeToWait
= 2000;
61 private long savedMs
= 0;
63 String searchField
= "";
65 public static final int forceDbgColForFpdModTable
= 7;
69 private JSplitPane jSplitPane
= null;
71 private JPanel jPanelTop
= null;
73 private JPanel jPanelBottom
= null;
75 private JLabel jLabel
= null;
77 private JScrollPane jScrollPaneAllModules
= null;
79 private JTable jTableAllModules
= null;
81 private JPanel jPanelTopSouth
= null;
83 private JButton jButtonAddModule
= null;
85 private JLabel jLabelModulesAdded
= null;
87 private JPanel jPanelBottomSouth
= null;
89 private JScrollPane jScrollPaneFpdModules
= null;
91 private JTable jTableFpdModules
= null;
93 private JButton jButtonSettings
= null;
95 private JButton jButtonRemoveModule
= null;
97 private NonEditableTableModel modelAllModules
= null;
99 private FpdModulesTableModel modelFpdModules
= null;
101 private FpdModuleSA settingDlg
= null;
103 private FpdFileContents ffc
= null;
105 private OpeningPlatformType docConsole
= null;
107 private Map
<String
, ArrayList
<String
>> fpdMsa
= null;
109 private ArrayList
<ModuleIdentification
> miList
= null;
112 * Column settings for displaying all modules in workspace
114 private final int modNameColForAllModTable
= 0;
116 private final int pkgNameColForAllModTable
= 1;
118 private final int pathColForAllModTable
= 2;
120 private final int typeColForAllModTable
= 3;
122 private final int pkgVerColForAllModTable
= 5;
124 private final int modVerColForAllModTable
= 4;
127 * Column settings for display modules in the FPD file
129 private final int modNameColForFpdModTable
= 0;
131 private final int pkgNameColForFpdModTable
= 1;
133 private final int pathColForFpdModTable
= 2;
135 private final int archColForFpdModTable
= 3;
137 private final int pkgVerColForFpdModTable
= 6;
139 private final int modVerColForFpdModTable
= 5;
141 private final int typeColForFpdModTable
= 4;
144 * FpdFileContents structure
146 private final int ffcModGuid
= 0;
148 private final int ffcModVer
= 1;
150 private final int ffcPkgGuid
= 2;
152 private final int ffcPkgVer
= 3;
154 private final int ffcModArch
= 4;
157 * Set Column Widths, Only the PATH should not have a max width.
159 private final int modNameMinWidth
= 168;
161 private final int modNamePrefWidth
= 200;
163 private final int modNameMaxWidth
= 350;
165 private final int pkgNameMinWidth
= 100;
167 private final int pkgNamePrefWidth
= 130;
169 private final int pkgNameMaxWidth
= 150;
171 private final int verMinWidth
= 60;
173 private final int verMaxWidth
= 80;
175 private final int verPrefWidth
= 70;
177 private final int pathPrefWidth
= 600;
179 private final int pathMinWidth
= 280;
181 private final int archPrefWidth
= 80;
183 private final int archMinWidth
= 60;
185 private final int archMaxWidth
= 100;
187 private final int typePrefWidth
= 145;
189 private final int typeMinWidth
= 100;
191 private final int typeMaxWidth
= 155;
193 private JButton jButtonApriori
= null;
196 * This method initializes jSplitPane
198 * This is the main edit window
200 * @return javax.swing.JSplitPane jSplitPane
202 private JSplitPane
getJSplitPane() {
203 if (jSplitPane
== null) {
204 jSplitPane
= new JSplitPane();
205 jSplitPane
.setOrientation(javax
.swing
.JSplitPane
.VERTICAL_SPLIT
);
206 jSplitPane
.setDividerLocation(250);
207 jSplitPane
.setBottomComponent(getJPanelBottom());
208 jSplitPane
.setTopComponent(getJPanelTop());
214 * This method initializes jPanelTop
216 * This panel contains the All Modules Table
218 * @return javax.swing.JPanel jPanelTop
220 private JPanel
getJPanelTop() {
221 if (jPanelTop
== null) {
222 jLabel
= new JLabel();
223 jLabel
.setText(" Modules in Workspace");
224 jPanelTop
= new JPanel();
225 jPanelTop
.setLayout(new BorderLayout());
226 jPanelTop
.add(jLabel
, java
.awt
.BorderLayout
.NORTH
);
227 jPanelTop
.add(getJScrollPaneAllModules(), java
.awt
.BorderLayout
.CENTER
);
228 jPanelTop
.add(getJPanelTopSouth(), java
.awt
.BorderLayout
.SOUTH
);
234 * This method initializes jPanelBottom
236 * This panel contains the FPD Modules Table
238 * @return javax.swing.JPanel jPanelBottom
240 private JPanel
getJPanelBottom() {
241 if (jPanelBottom
== null) {
242 jLabelModulesAdded
= new JLabel();
243 jLabelModulesAdded
.setText(" Modules Added into Platform");
244 jPanelBottom
= new JPanel();
245 jPanelBottom
.setLayout(new BorderLayout());
246 jPanelBottom
.add(jLabelModulesAdded
, java
.awt
.BorderLayout
.NORTH
);
247 jPanelBottom
.add(getJPanelBottomSouth(), java
.awt
.BorderLayout
.SOUTH
);
248 jPanelBottom
.add(getJScrollPaneFpdModules(), java
.awt
.BorderLayout
.CENTER
);
254 * This method initializes jScrollPaneAllModules
256 * @return javax.swing.JScrollPane jScrollPaneAllModules
258 private JScrollPane
getJScrollPaneAllModules() {
259 if (jScrollPaneAllModules
== null) {
260 jScrollPaneAllModules
= new JScrollPane();
261 jScrollPaneAllModules
.setPreferredSize(new java
.awt
.Dimension(600, 200));
262 jScrollPaneAllModules
.setViewportView(getJTableAllModules());
264 return jScrollPaneAllModules
;
268 * This method initializes jTableAllModules
270 * @return javax.swing.JTable jTableAllModules
272 private JTable
getJTableAllModules() {
273 if (jTableAllModules
== null) {
274 modelAllModules
= new NonEditableTableModel();
275 TableSorter sorter
= new TableSorter(modelAllModules
);
276 jTableAllModules
= new JTable(sorter
);
277 sorter
.setTableHeader(jTableAllModules
.getTableHeader());
278 jTableAllModules
.setRowHeight(20);
279 modelAllModules
.addColumn("<html>Module<br>Name</html>");
280 modelAllModules
.addColumn("<html>Package<br>Name</html>");
281 modelAllModules
.addColumn("Path");
282 modelAllModules
.addColumn("<html>Module<br>Type</html>");
283 modelAllModules
.addColumn("<html>Module<br>Version</html>");
284 modelAllModules
.addColumn("<html>Package<br>Version</html>");
286 javax
.swing
.table
.TableColumn column
= null;
287 column
= jTableAllModules
.getColumnModel().getColumn(modNameColForAllModTable
);
288 column
.setPreferredWidth(modNamePrefWidth
);
289 column
.setMinWidth(modNameMinWidth
);
290 column
.setMaxWidth(modNameMaxWidth
);
291 column
= jTableAllModules
.getColumnModel().getColumn(modVerColForAllModTable
);
292 column
.setPreferredWidth(verPrefWidth
);
293 column
.setMaxWidth(verMaxWidth
);
294 column
.setMinWidth(verMinWidth
);
295 column
= jTableAllModules
.getColumnModel().getColumn(pkgNameColForAllModTable
);
296 column
.setPreferredWidth(pkgNamePrefWidth
);
297 column
.setMinWidth(pkgNameMinWidth
);
298 column
.setMaxWidth(pkgNameMaxWidth
);
299 column
= jTableAllModules
.getColumnModel().getColumn(pkgVerColForAllModTable
);
300 column
.setPreferredWidth(verPrefWidth
);
301 column
.setMaxWidth(verMaxWidth
);
302 column
.setMinWidth(verMinWidth
);
303 column
= jTableAllModules
.getColumnModel().getColumn(typeColForAllModTable
);
304 column
.setPreferredWidth(typePrefWidth
);
305 column
.setMaxWidth(typeMaxWidth
);
306 column
.setMinWidth(typeMinWidth
);
307 column
= jTableAllModules
.getColumnModel().getColumn(pathColForAllModTable
);
308 column
.setPreferredWidth(pathPrefWidth
);
309 column
.setMinWidth(pathMinWidth
);
311 jTableAllModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
312 jTableAllModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
313 jTableAllModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
314 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
315 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
316 java
.awt
.Point p
= e
.getPoint();
317 int rowIndex
= jTableAllModules
.rowAtPoint(p
);
318 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
319 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
320 addModuleIntoPlatform (rowIndex
);
324 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
325 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
326 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
327 int selectedRow
= jTableAllModules
.getSelectedRow();
328 if (selectedRow
< 0) {
331 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
332 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
333 addModuleIntoPlatform (selectedRow
);
338 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
339 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
341 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
342 searchField
+= e
.getKeyChar();
345 searchField
= "" + e
.getKeyChar();
348 int viewIndex
= gotoFoundRow (searchField
, jTableAllModules
);
350 jTableAllModules
.changeSelection(viewIndex
, 0, false, false);
352 savedMs
= System
.currentTimeMillis();
358 return jTableAllModules
;
361 private int gotoFoundRow (String s
, JTable model
) {
362 for (int i
= 0; i
< model
.getRowCount(); ++i
) {
363 if (model
.getValueAt(i
, 0) != null && model
.getValueAt(i
, 0).toString().regionMatches(true, 0, s
, 0, s
.length())) {
371 * This method initializes jPanelTopSouth
373 * This panel contains the ADD button
375 * @return javax.swing.JPanel jPanelTopSouth
377 private JPanel
getJPanelTopSouth() {
378 if (jPanelTopSouth
== null) {
379 FlowLayout flowLayout
= new FlowLayout();
380 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
381 jPanelTopSouth
= new JPanel();
382 jPanelTopSouth
.setLayout(flowLayout
);
383 jPanelTopSouth
.add(getJButtonAddModule(), null);
385 return jPanelTopSouth
;
388 private void addModuleIntoPlatform (int selectedRow
) {
389 String path
= modelAllModules
.getValueAt(selectedRow
, pathColForAllModTable
) + "";
390 ModuleIdentification mi
= miList
.get(selectedRow
);
391 Vector
<String
> vArchs
= null;
393 vArchs
= WorkspaceProfile
.getModuleSupArchs(mi
);
395 if (vArchs
== null) {
396 JOptionPane
.showMessageDialog(frame
, "No Supported Architectures specified in MSA file.");
400 Vector
<Object
> platformSupArch
= new Vector
<Object
>();
401 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
402 platformSupArch
.retainAll(vArchs
);
403 if (platformSupArch
.size() == 0) {
404 JOptionPane
.showMessageDialog(frame
, "This Module does not support this platform architectures.");
408 String archsAdded
= "";
409 String mg
= mi
.getGuid();
410 String mv
= mi
.getVersion();
411 String pg
= mi
.getPackageId().getGuid();
412 String pv
= mi
.getPackageId().getVersion();
413 String mType
= SurfaceAreaQuery
.getModuleType(mi
);
415 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
418 // if existing ModuleSA does not specify version info.
420 al
= fpdMsa
.get(mg
+ "null" + pg
+ "null");
422 al
= fpdMsa
.get(mg
+ "null" + pg
+ pv
);
424 al
= fpdMsa
.get(mg
+ mv
+ pg
+ "null");
426 al
= new ArrayList
<String
>();
427 fpdMsa
.put(mg
+ mv
+ pg
+ pv
, al
);
433 // filter from module SupArchs what archs has been added.
435 for (int i
= 0; i
< al
.size(); ++i
) {
436 vArchs
.remove(al
.get(i
));
439 // check whether archs conform to SupArch of platform.
441 platformSupArch
.removeAllElements();
442 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
443 vArchs
.retainAll(platformSupArch
);
445 // Archs this Module supported have already been added.
447 if (vArchs
.size() == 0) {
448 JOptionPane
.showMessageDialog(frame
, "This Module has already been added.");
451 //ToDo put Arch instead of null
452 boolean errorOccurred
= false;
453 for (int i
= 0; i
< vArchs
.size(); ++i
) {
454 String arch
= vArchs
.get(i
);
456 archsAdded
+= arch
+ " ";
457 String
[] row
= { "", "", "", "", "", "", "" };
460 row
[modNameColForFpdModTable
] = mi
.getName();
461 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
462 row
[pathColForFpdModTable
] = path
;
463 row
[archColForFpdModTable
] = arch
;
464 row
[pkgVerColForFpdModTable
] = pv
;
465 row
[modVerColForFpdModTable
] = mv
;
466 row
[typeColForFpdModTable
] = mType
;
469 modelFpdModules
.addRow(row
);
471 docConsole
.setSaved(false);
473 //ToDo : specify archs need to add.
474 ffc
.addFrameworkModulesPcdBuildDefs(mi
, arch
, null);
475 } catch (Exception exception
) {
476 JOptionPane
.showMessageDialog(frame
, "Adding " + row
[modNameColForFpdModTable
] + " with Supporting Architectures: " + arch
477 + ": " + exception
.getMessage());
478 errorOccurred
= true;
482 String s
= "This Module with Architecture " + archsAdded
;
484 s
+= " was added with Error. Platform may NOT Build.";
486 s
+= " was added Successfully.";
488 JOptionPane
.showMessageDialog(frame
, s
);
489 TableSorter sorterFpdModules
= (TableSorter
)jTableFpdModules
.getModel();
490 int viewIndex
= sorterFpdModules
.getViewIndexArray()[modelFpdModules
.getRowCount() - 1];
491 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
496 * This method initializes jButtonAddModule
498 * @return javax.swing.JButton jButtonAddModule
500 private JButton
getJButtonAddModule() {
501 if (jButtonAddModule
== null) {
502 jButtonAddModule
= new JButton();
503 jButtonAddModule
.setPreferredSize(new java
.awt
.Dimension(130, 20));
504 jButtonAddModule
.setText("Add a Module");
505 jButtonAddModule
.addActionListener(new java
.awt
.event
.ActionListener() {
506 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
507 int selectedRow
= jTableAllModules
.getSelectedRow();
508 if (selectedRow
< 0) {
512 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
513 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
514 addModuleIntoPlatform (selectedRow
);
518 return jButtonAddModule
;
522 * This method initializes jPanelBottomSouth
524 * This panel contains the Settings and Remove Buttons
526 * @return javax.swing.JPanel jPanelBottomSouth
528 private JPanel
getJPanelBottomSouth() {
529 if (jPanelBottomSouth
== null) {
530 FlowLayout flowLayout1
= new FlowLayout();
531 flowLayout1
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
532 jPanelBottomSouth
= new JPanel();
533 jPanelBottomSouth
.setLayout(flowLayout1
);
534 jPanelBottomSouth
.add(getJButtonSettings(), null);
535 jPanelBottomSouth
.add(getJButtonRemoveModule(), null);
536 jPanelBottomSouth
.add(getJButtonApriori(), null);
538 return jPanelBottomSouth
;
542 * This method initializes jScrollPaneFpdModules
544 * @return javax.swing.JScrollPane jScrollPaneFpdModules
546 private JScrollPane
getJScrollPaneFpdModules() {
547 if (jScrollPaneFpdModules
== null) {
548 jScrollPaneFpdModules
= new JScrollPane();
549 jScrollPaneFpdModules
.setPreferredSize(new java
.awt
.Dimension(453, 200));
550 jScrollPaneFpdModules
.setViewportView(getJTableFpdModules());
552 return jScrollPaneFpdModules
;
556 * This method initializes jTableFpdModules
558 * @return javax.swing.JTable jTableFpdModules
560 private JTable
getJTableFpdModules() {
561 if (jTableFpdModules
== null) {
562 modelFpdModules
= new FpdModulesTableModel();
563 TableSorter sorter
= new TableSorter(modelFpdModules
);
564 jTableFpdModules
= new JTable(sorter
);
565 sorter
.setTableHeader(jTableFpdModules
.getTableHeader());
566 jTableFpdModules
.setRowHeight(20);
567 modelFpdModules
.addColumn("<html>Module<br>Name</html>");
568 modelFpdModules
.addColumn("<html>Package<br>Name</html>");
569 modelFpdModules
.addColumn("Path");
570 modelFpdModules
.addColumn("<html>Supported<br>Architectures</html>");
571 modelFpdModules
.addColumn("<html>Module<br>Type</html>");
572 modelFpdModules
.addColumn("<html>Module<br>Version</html>");
573 modelFpdModules
.addColumn("<html>Package<br>Version</html>");
574 modelFpdModules
.addColumn("<html>Force<br>Debug</html>");
576 javax
.swing
.table
.TableColumn column
= null;
577 column
= jTableFpdModules
.getColumnModel().getColumn(modNameColForFpdModTable
);
578 column
.setPreferredWidth(modNamePrefWidth
);
579 column
.setMinWidth(modNameMinWidth
);
580 column
.setMaxWidth(modNameMaxWidth
);
581 column
= jTableFpdModules
.getColumnModel().getColumn(modVerColForFpdModTable
);
582 column
.setPreferredWidth(verPrefWidth
);
583 column
.setMaxWidth(verMaxWidth
);
584 column
.setMinWidth(verMinWidth
);
585 column
= jTableFpdModules
.getColumnModel().getColumn(pkgNameColForFpdModTable
);
586 column
.setPreferredWidth(pkgNamePrefWidth
);
587 column
.setMinWidth(pkgNameMinWidth
);
588 column
.setMaxWidth(pkgNameMaxWidth
);
589 column
= jTableFpdModules
.getColumnModel().getColumn(pkgVerColForFpdModTable
);
590 column
.setPreferredWidth(verPrefWidth
);
591 column
.setMaxWidth(verMaxWidth
);
592 column
.setMinWidth(verMinWidth
);
593 column
= jTableFpdModules
.getColumnModel().getColumn(archColForFpdModTable
);
594 column
.setPreferredWidth(archPrefWidth
);
595 column
.setMaxWidth(archMaxWidth
);
596 column
.setMinWidth(archMinWidth
);
597 column
= jTableFpdModules
.getColumnModel().getColumn(pathColForFpdModTable
);
598 column
.setPreferredWidth(pathPrefWidth
);
599 column
.setMinWidth(pathMinWidth
);
600 column
= jTableFpdModules
.getColumnModel().getColumn(typeColForFpdModTable
);
601 column
.setPreferredWidth(typePrefWidth
);
602 column
.setMaxWidth(typeMaxWidth
);
603 column
.setMinWidth(typeMinWidth
);
605 jTableFpdModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
606 jTableFpdModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
608 jTableFpdModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
609 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
610 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
611 java
.awt
.Point p
= e
.getPoint();
612 int rowIndex
= jTableFpdModules
.rowAtPoint(p
);
613 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
614 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
615 showSettingsDlg (rowIndex
);
620 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
621 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
622 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
623 int selectedRow
= jTableFpdModules
.getSelectedRow();
624 if (selectedRow
< 0) {
627 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
628 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
629 showSettingsDlg (selectedRow
);
634 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
635 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
637 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
638 searchField
+= e
.getKeyChar();
641 searchField
= "" + e
.getKeyChar();
644 int viewIndex
= gotoFoundRow (searchField
, jTableFpdModules
);
646 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
648 savedMs
= System
.currentTimeMillis();
652 jTableFpdModules
.getModel().addTableModelListener(this);
654 return jTableFpdModules
;
657 public void tableChanged(TableModelEvent arg0
) {
658 if (arg0
.getType() == TableModelEvent
.UPDATE
){
659 int row
= arg0
.getFirstRow();
660 int column
= arg0
.getColumn();
661 TableModel m
= (TableModel
)arg0
.getSource();
663 if (column
!= forceDbgColForFpdModTable
) {
666 String s
= m
.getValueAt(row
, column
)+"";
667 boolean dbgEnable
= new Boolean(s
);
668 ffc
.setModuleSAForceDebug(row
, dbgEnable
);
669 docConsole
.setSaved(false);
673 private void showSettingsDlg (int row
) {
675 Vector
<String
> vExceptions
= new Vector
<String
>();
676 if (ffc
.adjustPcd(row
, vExceptions
)) {
677 JOptionPane
.showMessageDialog(frame
, "Pcd entries sync. with those in MSA files.");
678 docConsole
.setSaved(false);
681 catch (Exception exp
) {
682 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
686 if (settingDlg
== null) {
687 settingDlg
= new FpdModuleSA(ffc
);
690 String
[] sa
= new String
[5];
691 ffc
.getFrameworkModuleInfo(row
, sa
);
692 String mg
= sa
[ffcModGuid
];
693 String mv
= sa
[ffcModVer
];
694 String pg
= sa
[ffcPkgGuid
];
695 String pv
= sa
[ffcPkgVer
];
696 String arch
= sa
[ffcModArch
];
697 settingDlg
.setKey(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
, row
, docConsole
);
698 settingDlg
.setVisible(true);
701 * This method initializes jButtonSettings
703 * @return javax.swing.JButton jButtonSettings
705 private JButton
getJButtonSettings() {
706 if (jButtonSettings
== null) {
707 jButtonSettings
= new JButton();
708 jButtonSettings
.setPreferredSize(new java
.awt
.Dimension(130,20));
709 jButtonSettings
.setText("Settings");
710 jButtonSettings
.addActionListener(new java
.awt
.event
.ActionListener() {
711 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
712 int selectedRow
= jTableFpdModules
.getSelectedRow();
713 if (selectedRow
< 0) {
717 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
718 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
719 showSettingsDlg (selectedRow
);
723 return jButtonSettings
;
727 * This method initializes jButtonRemoveModule
729 * @return javax.swing.JButton jButtonRemoveModule
731 private JButton
getJButtonRemoveModule() {
732 if (jButtonRemoveModule
== null) {
733 jButtonRemoveModule
= new JButton();
734 jButtonRemoveModule
.setText("Remove Module");
735 FontMetrics fm
= jButtonRemoveModule
.getFontMetrics(jButtonRemoveModule
.getFont());
736 jButtonRemoveModule
.setPreferredSize(new Dimension (fm
.stringWidth(jButtonRemoveModule
.getText()) + 40, 20));
737 jButtonRemoveModule
.addActionListener(new java
.awt
.event
.ActionListener() {
738 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
739 int selectedRow
= jTableFpdModules
.getSelectedRow();
740 if (selectedRow
< 0) {
743 int nextSelection
= selectedRow
;
745 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
746 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
748 String
[] sa
= new String
[5];
749 ffc
.getFrameworkModuleInfo(selectedRow
, sa
);
750 String mg
= sa
[ffcModGuid
];
751 String mv
= sa
[ffcModVer
];
752 String pg
= sa
[ffcPkgGuid
];
753 String pv
= sa
[ffcPkgVer
];
754 String arch
= sa
[ffcModArch
];
756 // sync. module order list in BuildOptions-UserExtensions.
758 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
759 String fvBindings
= ffc
.getFvBinding(moduleKey
);
760 if (fvBindings
!= null) {
761 String
[] fvArray
= fvBindings
.split(" ");
762 for (int i
= 0; i
< fvArray
.length
; ++i
) {
763 ffc
.removeModuleInBuildOptionsUserExtensions(fvArray
[i
].trim(), "IMAGES", 1, mg
, mv
, pg
, pv
, arch
);
767 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
);
769 mv
= mi
.getVersion();
770 pv
= mi
.getPackageId().getVersion();
774 ffc
.removeModuleSA(selectedRow
);
776 catch (Exception exp
) {
777 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
782 // if no arch specified in ModuleSA
783 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
786 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
789 if (al
.size() == 0) {
790 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
795 modelFpdModules
.removeRow(selectedRow
);
796 if (nextSelection
>= jTableFpdModules
.getRowCount()) {
797 nextSelection
= jTableFpdModules
.getRowCount() - 1;
799 jTableFpdModules
.changeSelection(nextSelection
, 0, false, false);
800 docConsole
.setSaved(false);
804 return jButtonRemoveModule
;
808 * This method initializes jButtonApriori
810 * @return javax.swing.JButton
812 private JButton
getJButtonApriori() {
813 if (jButtonApriori
== null) {
814 jButtonApriori
= new JButton();
815 jButtonApriori
.setText("Apriori Files");
816 FontMetrics fm
= jButtonApriori
.getFontMetrics(jButtonApriori
.getFont());
817 int buttonWidth
= fm
.stringWidth(jButtonApriori
.getText()) + 40;
818 if (jButtonRemoveModule
.getWidth() > buttonWidth
) {
819 buttonWidth
= jButtonRemoveModule
.getWidth();
821 jButtonApriori
.setPreferredSize(new Dimension (buttonWidth
, 20));
822 jButtonApriori
.addActionListener(new java
.awt
.event
.ActionListener() {
823 public void actionPerformed(ActionEvent arg0
) {
824 new GenAprioriFileDialog(ffc
, docConsole
).setVisible(true);
827 return jButtonApriori
;
834 public static void main(String
[] args
) {
835 // Set the pane visable
836 new FpdFrameworkModules().setVisible(true);
840 * This is the default constructor
842 public FpdFrameworkModules() {
847 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
853 public FpdFrameworkModules(OpeningPlatformType opt
) {
854 this(opt
.getXmlFpd());
856 Vector
<String
> vExceptions
= new Vector
<String
>();
857 if (pcdSync(vExceptions
)) {
858 JOptionPane
.showMessageDialog(frame
, "PCD in this platform are synchronized with those in MSA files.");
860 if (vExceptions
.size() > 0) {
861 String errorMsg
= "";
862 for (int i
= 0; i
< vExceptions
.size(); ++i
) {
863 errorMsg
+= " " + vExceptions
.get(i
) + "\n";
865 JOptionPane
.showMessageDialog(frame
, "Error occurred during synchronization:" + errorMsg
);
869 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
872 ffc
= new FpdFileContents(fpd
);
876 if (fpdMsa
== null) {
877 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
880 if (ffc
.getFrameworkModulesCount() > 0) {
881 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
882 ffc
.getFrameworkModulesInfo(saa
);
883 for (int i
= 0; i
< saa
.length
; ++i
) {
884 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
885 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
886 Object
[] row
= { "", "", "", "", "", "", "", "" };
888 row
[modNameColForFpdModTable
] = mi
.getName();
889 row
[modVerColForFpdModTable
] = mi
.getVersion();
890 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
891 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
892 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
893 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
895 row
[pathColForFpdModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
896 } catch (Exception e
) {
897 JOptionPane
.showMessageDialog(frame
, "Show FPD Modules:" + e
.getMessage());
900 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
901 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
902 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
904 al
= new ArrayList
<String
>();
905 fpdMsa
.put(fpdMsaKey
, al
);
907 al
.add(saa
[i
][ffcModArch
]);
910 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
911 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
912 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
913 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
914 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
916 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
917 modelFpdModules
.addRow(row
);
920 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
921 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
928 private boolean pcdSync(Vector
<String
> v
) {
929 boolean synced
= false;
930 for (int i
= 0; i
< jTableFpdModules
.getRowCount(); ++i
) {
932 if (ffc
.adjustPcd(i
, v
)) {
936 catch (Exception exp
) {
937 // JOptionPane.showMessageDialog(frame, exp.getMessage());
945 private void showAllModules() {
947 if (miList
== null) {
948 miList
= new ArrayList
<ModuleIdentification
>();
951 String
[] s
= { "", "", "", "", "", "" };
953 Iterator ismi
= GlobalData
.vModuleList
.iterator();
954 while (ismi
.hasNext()) {
955 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
956 s
[modNameColForAllModTable
] = mi
.getName();
957 s
[modVerColForAllModTable
] = mi
.getVersion();
958 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
959 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
960 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
962 s
[pathColForAllModTable
] = mi
.getPath().substring(System
.getenv("WORKSPACE").length() + 1);
963 } catch (Exception e
) {
964 JOptionPane
.showMessageDialog(frame
, "Show All Modules:" + e
.getMessage());
966 modelAllModules
.addRow(s
);
971 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
972 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
976 * This method initializes this
980 private void initialize() {
981 this.setSize(633, 533);
982 this.setTitle("Framework Modules");
983 this.setContentPane(getJSplitPane());
984 this.setVisible(true);
988 } // @jve:decl-index=0:visual-constraint="10,10"
990 class NonEditableTableModel
extends DefaultTableModel
{
994 private static final long serialVersionUID
= 1L;
996 public boolean isCellEditable(int row
, int col
) {
1001 class FpdModulesTableModel
extends DefaultTableModel
{
1006 private static final long serialVersionUID
= 1L;
1008 public Class
<?
> getColumnClass (int c
) {
1009 if (getValueAt(0, c
) != null){
1010 return getValueAt(0, c
).getClass();
1012 return String
.class;
1015 public boolean isCellEditable (int row
, int col
) {
1016 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {