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
.workspace
.Workspace
;
41 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
43 import java
.awt
.FlowLayout
;
44 import java
.awt
.event
.ActionEvent
;
45 import java
.awt
.event
.KeyEvent
;
46 import java
.awt
.event
.MouseEvent
;
47 import java
.util
.ArrayList
;
48 import java
.util
.HashMap
;
49 import java
.util
.Iterator
;
51 import java
.util
.Vector
;
53 public class FpdFrameworkModules
extends IInternalFrame
{
58 private static final long serialVersionUID
= 1L;
60 private static final int timeToWait
= 2000;
62 private long savedMs
= 0;
64 String searchField
= "";
66 public static final int forceDbgColForFpdModTable
= 7;
70 private JSplitPane jSplitPane
= null;
72 private JPanel jPanelTop
= null;
74 private JPanel jPanelBottom
= null;
76 private JLabel jLabel
= null;
78 private JScrollPane jScrollPaneAllModules
= null;
80 private JTable jTableAllModules
= null;
82 private JPanel jPanelTopSouth
= null;
84 private JButton jButtonAddModule
= null;
86 private JLabel jLabelModulesAdded
= null;
88 private JPanel jPanelBottomSouth
= null;
90 private JScrollPane jScrollPaneFpdModules
= null;
92 private JTable jTableFpdModules
= null;
94 private JButton jButtonSettings
= null;
96 private JButton jButtonRemoveModule
= null;
98 private NonEditableTableModel modelAllModules
= null;
100 private FpdModulesTableModel modelFpdModules
= null;
102 private FpdModuleSA settingDlg
= null;
104 private FpdFileContents ffc
= null;
106 private OpeningPlatformType docConsole
= null;
108 private Map
<String
, ArrayList
<String
>> fpdMsa
= null;
110 private ArrayList
<ModuleIdentification
> miList
= null;
113 * Column settings for displaying all modules in workspace
115 private final int modNameColForAllModTable
= 0;
117 private final int pkgNameColForAllModTable
= 1;
119 private final int pathColForAllModTable
= 2;
121 private final int typeColForAllModTable
= 3;
123 private final int pkgVerColForAllModTable
= 5;
125 private final int modVerColForAllModTable
= 4;
128 * Column settings for display modules in the FPD file
130 private final int modNameColForFpdModTable
= 0;
132 private final int pkgNameColForFpdModTable
= 1;
134 private final int pathColForFpdModTable
= 2;
136 private final int archColForFpdModTable
= 3;
138 private final int pkgVerColForFpdModTable
= 6;
140 private final int modVerColForFpdModTable
= 5;
142 private final int typeColForFpdModTable
= 4;
145 * FpdFileContents structure
147 private final int ffcModGuid
= 0;
149 private final int ffcModVer
= 1;
151 private final int ffcPkgGuid
= 2;
153 private final int ffcPkgVer
= 3;
155 private final int ffcModArch
= 4;
158 * Set Column Widths, Only the PATH should not have a max width.
160 private final int modNameMinWidth
= 168;
162 private final int modNamePrefWidth
= 200;
164 private final int modNameMaxWidth
= 350;
166 private final int pkgNameMinWidth
= 100;
168 private final int pkgNamePrefWidth
= 130;
170 private final int pkgNameMaxWidth
= 150;
172 private final int verMinWidth
= 60;
174 private final int verMaxWidth
= 80;
176 private final int verPrefWidth
= 70;
178 private final int pathPrefWidth
= 600;
180 private final int pathMinWidth
= 280;
182 private final int archPrefWidth
= 80;
184 private final int archMinWidth
= 60;
186 private final int archMaxWidth
= 100;
188 private final int typePrefWidth
= 145;
190 private final int typeMinWidth
= 100;
192 private final int typeMaxWidth
= 155;
194 private JButton jButtonApriori
= null;
197 * This method initializes jSplitPane
199 * This is the main edit window
201 * @return javax.swing.JSplitPane jSplitPane
203 private JSplitPane
getJSplitPane() {
204 if (jSplitPane
== null) {
205 jSplitPane
= new JSplitPane();
206 jSplitPane
.setOrientation(javax
.swing
.JSplitPane
.VERTICAL_SPLIT
);
207 jSplitPane
.setDividerLocation(250);
208 jSplitPane
.setBottomComponent(getJPanelBottom());
209 jSplitPane
.setTopComponent(getJPanelTop());
215 * This method initializes jPanelTop
217 * This panel contains the All Modules Table
219 * @return javax.swing.JPanel jPanelTop
221 private JPanel
getJPanelTop() {
222 if (jPanelTop
== null) {
223 jLabel
= new JLabel();
224 jLabel
.setText(" Modules in Workspace");
225 jPanelTop
= new JPanel();
226 jPanelTop
.setLayout(new BorderLayout());
227 jPanelTop
.add(jLabel
, java
.awt
.BorderLayout
.NORTH
);
228 jPanelTop
.add(getJScrollPaneAllModules(), java
.awt
.BorderLayout
.CENTER
);
229 jPanelTop
.add(getJPanelTopSouth(), java
.awt
.BorderLayout
.SOUTH
);
235 * This method initializes jPanelBottom
237 * This panel contains the FPD Modules Table
239 * @return javax.swing.JPanel jPanelBottom
241 private JPanel
getJPanelBottom() {
242 if (jPanelBottom
== null) {
243 jLabelModulesAdded
= new JLabel();
244 jLabelModulesAdded
.setText(" Modules Added into Platform");
245 jPanelBottom
= new JPanel();
246 jPanelBottom
.setLayout(new BorderLayout());
247 jPanelBottom
.add(jLabelModulesAdded
, java
.awt
.BorderLayout
.NORTH
);
248 jPanelBottom
.add(getJPanelBottomSouth(), java
.awt
.BorderLayout
.SOUTH
);
249 jPanelBottom
.add(getJScrollPaneFpdModules(), java
.awt
.BorderLayout
.CENTER
);
255 * This method initializes jScrollPaneAllModules
257 * @return javax.swing.JScrollPane jScrollPaneAllModules
259 private JScrollPane
getJScrollPaneAllModules() {
260 if (jScrollPaneAllModules
== null) {
261 jScrollPaneAllModules
= new JScrollPane();
262 jScrollPaneAllModules
.setPreferredSize(new java
.awt
.Dimension(600, 200));
263 jScrollPaneAllModules
.setViewportView(getJTableAllModules());
265 return jScrollPaneAllModules
;
269 * This method initializes jTableAllModules
271 * @return javax.swing.JTable jTableAllModules
273 private JTable
getJTableAllModules() {
274 if (jTableAllModules
== null) {
275 modelAllModules
= new NonEditableTableModel();
276 TableSorter sorter
= new TableSorter(modelAllModules
);
277 jTableAllModules
= new JTable(sorter
);
278 sorter
.setTableHeader(jTableAllModules
.getTableHeader());
279 jTableAllModules
.setRowHeight(20);
280 modelAllModules
.addColumn("<html>Module<br>Name</html>");
281 modelAllModules
.addColumn("<html>Package<br>Name</html>");
282 modelAllModules
.addColumn("Path");
283 modelAllModules
.addColumn("<html>Module<br>Type</html>");
284 modelAllModules
.addColumn("<html>Module<br>Version</html>");
285 modelAllModules
.addColumn("<html>Package<br>Version</html>");
287 javax
.swing
.table
.TableColumn column
= null;
288 column
= jTableAllModules
.getColumnModel().getColumn(modNameColForAllModTable
);
289 column
.setPreferredWidth(modNamePrefWidth
);
290 column
.setMinWidth(modNameMinWidth
);
291 column
.setMaxWidth(modNameMaxWidth
);
292 column
= jTableAllModules
.getColumnModel().getColumn(modVerColForAllModTable
);
293 column
.setPreferredWidth(verPrefWidth
);
294 column
.setMaxWidth(verMaxWidth
);
295 column
.setMinWidth(verMinWidth
);
296 column
= jTableAllModules
.getColumnModel().getColumn(pkgNameColForAllModTable
);
297 column
.setPreferredWidth(pkgNamePrefWidth
);
298 column
.setMinWidth(pkgNameMinWidth
);
299 column
.setMaxWidth(pkgNameMaxWidth
);
300 column
= jTableAllModules
.getColumnModel().getColumn(pkgVerColForAllModTable
);
301 column
.setPreferredWidth(verPrefWidth
);
302 column
.setMaxWidth(verMaxWidth
);
303 column
.setMinWidth(verMinWidth
);
304 column
= jTableAllModules
.getColumnModel().getColumn(typeColForAllModTable
);
305 column
.setPreferredWidth(typePrefWidth
);
306 column
.setMaxWidth(typeMaxWidth
);
307 column
.setMinWidth(typeMinWidth
);
308 column
= jTableAllModules
.getColumnModel().getColumn(pathColForAllModTable
);
309 column
.setPreferredWidth(pathPrefWidth
);
310 column
.setMinWidth(pathMinWidth
);
312 jTableAllModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
313 jTableAllModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
314 jTableAllModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
315 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
316 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
317 java
.awt
.Point p
= e
.getPoint();
318 int rowIndex
= jTableAllModules
.rowAtPoint(p
);
319 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
320 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
321 addModuleIntoPlatform (rowIndex
);
325 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
326 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
327 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
328 int selectedRow
= jTableAllModules
.getSelectedRow();
329 if (selectedRow
< 0) {
332 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
333 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
334 addModuleIntoPlatform (selectedRow
);
339 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
340 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
342 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
343 searchField
+= e
.getKeyChar();
346 searchField
= "" + e
.getKeyChar();
349 int viewIndex
= gotoFoundRow (searchField
, jTableAllModules
);
351 jTableAllModules
.changeSelection(viewIndex
, 0, false, false);
353 savedMs
= System
.currentTimeMillis();
359 return jTableAllModules
;
362 private int gotoFoundRow (String s
, JTable model
) {
363 for (int i
= 0; i
< model
.getRowCount(); ++i
) {
364 if (model
.getValueAt(i
, 0) != null && model
.getValueAt(i
, 0).toString().regionMatches(true, 0, s
, 0, s
.length())) {
372 * This method initializes jPanelTopSouth
374 * This panel contains the ADD button
376 * @return javax.swing.JPanel jPanelTopSouth
378 private JPanel
getJPanelTopSouth() {
379 if (jPanelTopSouth
== null) {
380 FlowLayout flowLayout
= new FlowLayout();
381 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
382 jPanelTopSouth
= new JPanel();
383 jPanelTopSouth
.setLayout(flowLayout
);
384 jPanelTopSouth
.add(getJButtonAddModule(), null);
386 return jPanelTopSouth
;
389 private void addModuleIntoPlatform (int selectedRow
) {
390 String path
= modelAllModules
.getValueAt(selectedRow
, pathColForAllModTable
) + "";
391 ModuleIdentification mi
= miList
.get(selectedRow
);
392 Vector
<String
> vArchs
= null;
394 vArchs
= WorkspaceProfile
.getModuleSupArchs(mi
);
396 if (vArchs
== null) {
397 JOptionPane
.showMessageDialog(frame
, "No Supported Architectures specified in MSA file.");
401 Vector
<Object
> platformSupArch
= new Vector
<Object
>();
402 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
403 platformSupArch
.retainAll(vArchs
);
404 if (platformSupArch
.size() == 0) {
405 JOptionPane
.showMessageDialog(frame
, "This Module does not support this platform architectures.");
409 String archsAdded
= "";
410 String mg
= mi
.getGuid();
411 String mv
= mi
.getVersion();
412 String pg
= mi
.getPackageId().getGuid();
413 String pv
= mi
.getPackageId().getVersion();
414 String mType
= SurfaceAreaQuery
.getModuleType(mi
);
416 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
419 // if existing ModuleSA does not specify version info.
421 al
= fpdMsa
.get(mg
+ "null" + pg
+ "null");
423 al
= fpdMsa
.get(mg
+ "null" + pg
+ pv
);
425 al
= fpdMsa
.get(mg
+ mv
+ pg
+ "null");
427 al
= new ArrayList
<String
>();
428 fpdMsa
.put(mg
+ mv
+ pg
+ pv
, al
);
434 // filter from module SupArchs what archs has been added.
436 for (int i
= 0; i
< al
.size(); ++i
) {
437 vArchs
.remove(al
.get(i
));
440 // check whether archs conform to SupArch of platform.
442 platformSupArch
.removeAllElements();
443 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
444 vArchs
.retainAll(platformSupArch
);
446 // Archs this Module supported have already been added.
448 if (vArchs
.size() == 0) {
449 JOptionPane
.showMessageDialog(frame
, "This Module has already been added.");
452 //ToDo put Arch instead of null
453 boolean errorOccurred
= false;
454 for (int i
= 0; i
< vArchs
.size(); ++i
) {
455 String arch
= vArchs
.get(i
);
457 archsAdded
+= arch
+ " ";
458 String
[] row
= { "", "", "", "", "", "", "" };
461 row
[modNameColForFpdModTable
] = mi
.getName();
462 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
463 row
[pathColForFpdModTable
] = path
;
464 row
[archColForFpdModTable
] = arch
;
465 row
[pkgVerColForFpdModTable
] = pv
;
466 row
[modVerColForFpdModTable
] = mv
;
467 row
[typeColForFpdModTable
] = mType
;
470 modelFpdModules
.addRow(row
);
472 docConsole
.setSaved(false);
474 //ToDo : specify archs need to add.
475 ffc
.addFrameworkModulesPcdBuildDefs(mi
, arch
, null);
476 } catch (Exception exception
) {
477 JOptionPane
.showMessageDialog(frame
, "Adding " + row
[modNameColForFpdModTable
] + " with Supporting Architectures: " + arch
478 + ": " + exception
.getMessage());
479 errorOccurred
= true;
483 String s
= "This Module with Architecture " + archsAdded
;
485 s
+= " was added with Error. Platform may NOT Build.";
487 s
+= " was added Successfully.";
489 JOptionPane
.showMessageDialog(frame
, s
);
490 TableSorter sorterFpdModules
= (TableSorter
)jTableFpdModules
.getModel();
491 int viewIndex
= sorterFpdModules
.getViewIndexArray()[modelFpdModules
.getRowCount() - 1];
492 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
497 * This method initializes jButtonAddModule
499 * @return javax.swing.JButton jButtonAddModule
501 private JButton
getJButtonAddModule() {
502 if (jButtonAddModule
== null) {
503 jButtonAddModule
= new JButton();
504 jButtonAddModule
.setPreferredSize(new java
.awt
.Dimension(130, 20));
505 jButtonAddModule
.setText("Add a Module");
506 jButtonAddModule
.addActionListener(new java
.awt
.event
.ActionListener() {
507 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
508 int selectedRow
= jTableAllModules
.getSelectedRow();
509 if (selectedRow
< 0) {
513 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
514 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
515 addModuleIntoPlatform (selectedRow
);
519 return jButtonAddModule
;
523 * This method initializes jPanelBottomSouth
525 * This panel contains the Settings and Remove Buttons
527 * @return javax.swing.JPanel jPanelBottomSouth
529 private JPanel
getJPanelBottomSouth() {
530 if (jPanelBottomSouth
== null) {
531 FlowLayout flowLayout1
= new FlowLayout();
532 flowLayout1
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
533 jPanelBottomSouth
= new JPanel();
534 jPanelBottomSouth
.setLayout(flowLayout1
);
535 jPanelBottomSouth
.add(getJButtonSettings(), null);
536 jPanelBottomSouth
.add(getJButtonRemoveModule(), null);
537 jPanelBottomSouth
.add(getJButtonApriori(), null);
539 return jPanelBottomSouth
;
543 * This method initializes jScrollPaneFpdModules
545 * @return javax.swing.JScrollPane jScrollPaneFpdModules
547 private JScrollPane
getJScrollPaneFpdModules() {
548 if (jScrollPaneFpdModules
== null) {
549 jScrollPaneFpdModules
= new JScrollPane();
550 jScrollPaneFpdModules
.setPreferredSize(new java
.awt
.Dimension(453, 200));
551 jScrollPaneFpdModules
.setViewportView(getJTableFpdModules());
553 return jScrollPaneFpdModules
;
557 * This method initializes jTableFpdModules
559 * @return javax.swing.JTable jTableFpdModules
561 private JTable
getJTableFpdModules() {
562 if (jTableFpdModules
== null) {
563 modelFpdModules
= new FpdModulesTableModel();
564 TableSorter sorter
= new TableSorter(modelFpdModules
);
565 jTableFpdModules
= new JTable(sorter
);
566 sorter
.setTableHeader(jTableFpdModules
.getTableHeader());
567 jTableFpdModules
.setRowHeight(20);
568 modelFpdModules
.addColumn("<html>Module<br>Name</html>");
569 modelFpdModules
.addColumn("<html>Package<br>Name</html>");
570 modelFpdModules
.addColumn("Path");
571 modelFpdModules
.addColumn("<html>Supported<br>Architectures</html>");
572 modelFpdModules
.addColumn("<html>Module<br>Type</html>");
573 modelFpdModules
.addColumn("<html>Module<br>Version</html>");
574 modelFpdModules
.addColumn("<html>Package<br>Version</html>");
575 modelFpdModules
.addColumn("<html>Force<br>Debug</html>");
577 javax
.swing
.table
.TableColumn column
= null;
578 column
= jTableFpdModules
.getColumnModel().getColumn(modNameColForFpdModTable
);
579 column
.setPreferredWidth(modNamePrefWidth
);
580 column
.setMinWidth(modNameMinWidth
);
581 column
.setMaxWidth(modNameMaxWidth
);
582 column
= jTableFpdModules
.getColumnModel().getColumn(modVerColForFpdModTable
);
583 column
.setPreferredWidth(verPrefWidth
);
584 column
.setMaxWidth(verMaxWidth
);
585 column
.setMinWidth(verMinWidth
);
586 column
= jTableFpdModules
.getColumnModel().getColumn(pkgNameColForFpdModTable
);
587 column
.setPreferredWidth(pkgNamePrefWidth
);
588 column
.setMinWidth(pkgNameMinWidth
);
589 column
.setMaxWidth(pkgNameMaxWidth
);
590 column
= jTableFpdModules
.getColumnModel().getColumn(pkgVerColForFpdModTable
);
591 column
.setPreferredWidth(verPrefWidth
);
592 column
.setMaxWidth(verMaxWidth
);
593 column
.setMinWidth(verMinWidth
);
594 column
= jTableFpdModules
.getColumnModel().getColumn(archColForFpdModTable
);
595 column
.setPreferredWidth(archPrefWidth
);
596 column
.setMaxWidth(archMaxWidth
);
597 column
.setMinWidth(archMinWidth
);
598 column
= jTableFpdModules
.getColumnModel().getColumn(pathColForFpdModTable
);
599 column
.setPreferredWidth(pathPrefWidth
);
600 column
.setMinWidth(pathMinWidth
);
601 column
= jTableFpdModules
.getColumnModel().getColumn(typeColForFpdModTable
);
602 column
.setPreferredWidth(typePrefWidth
);
603 column
.setMaxWidth(typeMaxWidth
);
604 column
.setMinWidth(typeMinWidth
);
606 jTableFpdModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
607 jTableFpdModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
609 jTableFpdModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
610 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
611 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
612 java
.awt
.Point p
= e
.getPoint();
613 int rowIndex
= jTableFpdModules
.rowAtPoint(p
);
614 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
615 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
616 showSettingsDlg (rowIndex
);
621 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
622 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
623 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
624 int selectedRow
= jTableFpdModules
.getSelectedRow();
625 if (selectedRow
< 0) {
628 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
629 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
630 showSettingsDlg (selectedRow
);
635 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
636 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
638 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
639 searchField
+= e
.getKeyChar();
642 searchField
= "" + e
.getKeyChar();
645 int viewIndex
= gotoFoundRow (searchField
, jTableFpdModules
);
647 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
649 savedMs
= System
.currentTimeMillis();
653 jTableFpdModules
.getModel().addTableModelListener(this);
655 return jTableFpdModules
;
658 public void tableChanged(TableModelEvent arg0
) {
659 if (arg0
.getType() == TableModelEvent
.UPDATE
){
660 int row
= arg0
.getFirstRow();
661 int column
= arg0
.getColumn();
662 TableModel m
= (TableModel
)arg0
.getSource();
664 if (column
!= forceDbgColForFpdModTable
) {
667 String s
= m
.getValueAt(row
, column
)+"";
668 boolean dbgEnable
= new Boolean(s
);
669 ffc
.setModuleSAForceDebug(row
, dbgEnable
);
670 docConsole
.setSaved(false);
674 private void showSettingsDlg (int row
) {
676 Vector
<String
> vExceptions
= new Vector
<String
>();
677 if (ffc
.adjustPcd(row
, vExceptions
)) {
678 JOptionPane
.showMessageDialog(frame
, "Pcd entries sync. with those in MSA files.");
679 docConsole
.setSaved(false);
682 catch (Exception exp
) {
683 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
687 if (settingDlg
== null) {
688 settingDlg
= new FpdModuleSA(ffc
);
691 String
[] sa
= new String
[5];
692 ffc
.getFrameworkModuleInfo(row
, sa
);
693 String mg
= sa
[ffcModGuid
];
694 String mv
= sa
[ffcModVer
];
695 String pg
= sa
[ffcPkgGuid
];
696 String pv
= sa
[ffcPkgVer
];
697 String arch
= sa
[ffcModArch
];
698 settingDlg
.setKey(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
, row
, docConsole
);
699 settingDlg
.setVisible(true);
702 * This method initializes jButtonSettings
704 * @return javax.swing.JButton jButtonSettings
706 private JButton
getJButtonSettings() {
707 if (jButtonSettings
== null) {
708 jButtonSettings
= new JButton();
709 jButtonSettings
.setPreferredSize(new java
.awt
.Dimension(130,20));
710 jButtonSettings
.setText("Settings");
711 jButtonSettings
.addActionListener(new java
.awt
.event
.ActionListener() {
712 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
713 int selectedRow
= jTableFpdModules
.getSelectedRow();
714 if (selectedRow
< 0) {
718 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
719 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
720 showSettingsDlg (selectedRow
);
724 return jButtonSettings
;
728 * This method initializes jButtonRemoveModule
730 * @return javax.swing.JButton jButtonRemoveModule
732 private JButton
getJButtonRemoveModule() {
733 if (jButtonRemoveModule
== null) {
734 jButtonRemoveModule
= new JButton();
735 jButtonRemoveModule
.setText("Remove Module");
736 FontMetrics fm
= jButtonRemoveModule
.getFontMetrics(jButtonRemoveModule
.getFont());
737 jButtonRemoveModule
.setPreferredSize(new Dimension (fm
.stringWidth(jButtonRemoveModule
.getText()) + 40, 20));
738 jButtonRemoveModule
.addActionListener(new java
.awt
.event
.ActionListener() {
739 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
740 int selectedRow
= jTableFpdModules
.getSelectedRow();
741 if (selectedRow
< 0) {
744 int nextSelection
= selectedRow
;
746 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
747 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
749 String
[] sa
= new String
[5];
750 ffc
.getFrameworkModuleInfo(selectedRow
, sa
);
751 String mg
= sa
[ffcModGuid
];
752 String mv
= sa
[ffcModVer
];
753 String pg
= sa
[ffcPkgGuid
];
754 String pv
= sa
[ffcPkgVer
];
755 String arch
= sa
[ffcModArch
];
757 // sync. module order list in BuildOptions-UserExtensions.
759 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
760 String fvBindings
= ffc
.getFvBinding(moduleKey
);
761 if (fvBindings
!= null) {
762 String
[] fvArray
= fvBindings
.split(" ");
763 for (int i
= 0; i
< fvArray
.length
; ++i
) {
764 ffc
.removeModuleInBuildOptionsUserExtensions(fvArray
[i
].trim(), "IMAGES", 1, mg
, mv
, pg
, pv
, arch
);
768 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
);
770 mv
= mi
.getVersion();
771 pv
= mi
.getPackageId().getVersion();
775 ffc
.removeModuleSA(selectedRow
);
777 catch (Exception exp
) {
778 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
783 // if no arch specified in ModuleSA
784 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
787 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
790 if (al
.size() == 0) {
791 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
796 modelFpdModules
.removeRow(selectedRow
);
797 if (nextSelection
>= jTableFpdModules
.getRowCount()) {
798 nextSelection
= jTableFpdModules
.getRowCount() - 1;
800 jTableFpdModules
.changeSelection(nextSelection
, 0, false, false);
801 docConsole
.setSaved(false);
805 return jButtonRemoveModule
;
809 * This method initializes jButtonApriori
811 * @return javax.swing.JButton
813 private JButton
getJButtonApriori() {
814 if (jButtonApriori
== null) {
815 jButtonApriori
= new JButton();
816 jButtonApriori
.setText("Apriori Files");
817 FontMetrics fm
= jButtonApriori
.getFontMetrics(jButtonApriori
.getFont());
818 int buttonWidth
= fm
.stringWidth(jButtonApriori
.getText()) + 40;
819 if (jButtonRemoveModule
.getWidth() > buttonWidth
) {
820 buttonWidth
= jButtonRemoveModule
.getWidth();
822 jButtonApriori
.setPreferredSize(new Dimension (buttonWidth
, 20));
823 jButtonApriori
.addActionListener(new java
.awt
.event
.ActionListener() {
824 public void actionPerformed(ActionEvent arg0
) {
825 new GenAprioriFileDialog(ffc
, docConsole
).setVisible(true);
828 return jButtonApriori
;
835 public static void main(String
[] args
) {
836 // Set the pane visable
837 new FpdFrameworkModules().setVisible(true);
841 * This is the default constructor
843 public FpdFrameworkModules() {
848 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
854 public FpdFrameworkModules(OpeningPlatformType opt
) {
855 this(opt
.getXmlFpd());
857 Vector
<String
> vExceptions
= new Vector
<String
>();
858 if (pcdSync(vExceptions
)) {
859 JOptionPane
.showMessageDialog(frame
, "PCD in this platform are synchronized with those in MSA files.");
860 docConsole
.setSaved(false);
862 if (vExceptions
.size() > 0) {
863 String errorMsg
= "";
864 for (int i
= 0; i
< vExceptions
.size(); ++i
) {
865 errorMsg
+= " " + vExceptions
.get(i
) + "\n";
867 JOptionPane
.showMessageDialog(frame
, "Error occurred during synchronization:" + errorMsg
);
871 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
874 ffc
= new FpdFileContents(fpd
);
878 if (fpdMsa
== null) {
879 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
882 if (ffc
.getFrameworkModulesCount() > 0) {
883 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
884 ffc
.getFrameworkModulesInfo(saa
);
885 for (int i
= 0; i
< saa
.length
; ++i
) {
886 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
887 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
888 Object
[] row
= { "", "", "", "", "", "", "", "" };
890 row
[modNameColForFpdModTable
] = mi
.getName();
891 row
[modVerColForFpdModTable
] = mi
.getVersion();
892 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
893 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
894 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
895 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
897 row
[pathColForFpdModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
898 } catch (Exception e
) {
899 JOptionPane
.showMessageDialog(frame
, "Show FPD Modules:" + e
.getMessage());
902 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
903 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
904 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
906 al
= new ArrayList
<String
>();
907 fpdMsa
.put(fpdMsaKey
, al
);
909 al
.add(saa
[i
][ffcModArch
]);
912 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
913 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
914 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
915 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
916 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
918 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
919 modelFpdModules
.addRow(row
);
922 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
923 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
930 private boolean pcdSync(Vector
<String
> v
) {
931 boolean synced
= false;
932 for (int i
= 0; i
< jTableFpdModules
.getRowCount(); ++i
) {
934 if (ffc
.adjustPcd(i
, v
)) {
938 catch (Exception exp
) {
939 // JOptionPane.showMessageDialog(frame, exp.getMessage());
947 private void showAllModules() {
949 if (miList
== null) {
950 miList
= new ArrayList
<ModuleIdentification
>();
953 String
[] s
= { "", "", "", "", "", "" };
955 Iterator ismi
= GlobalData
.vModuleList
.iterator();
956 while (ismi
.hasNext()) {
957 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
958 s
[modNameColForAllModTable
] = mi
.getName();
959 s
[modVerColForAllModTable
] = mi
.getVersion();
960 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
961 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
962 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
964 s
[pathColForAllModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
965 } catch (Exception e
) {
966 JOptionPane
.showMessageDialog(frame
, "Show All Modules:" + e
.getMessage());
968 modelAllModules
.addRow(s
);
973 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
974 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
978 * This method initializes this
982 private void initialize() {
983 this.setSize(633, 533);
984 this.setTitle("Framework Modules");
985 this.setContentPane(getJSplitPane());
986 this.setVisible(true);
990 } // @jve:decl-index=0:visual-constraint="10,10"
992 class NonEditableTableModel
extends DefaultTableModel
{
996 private static final long serialVersionUID
= 1L;
998 public boolean isCellEditable(int row
, int col
) {
1003 class FpdModulesTableModel
extends DefaultTableModel
{
1008 private static final long serialVersionUID
= 1L;
1010 public Class
<?
> getColumnClass (int c
) {
1011 if (getValueAt(0, c
) != null){
1012 return getValueAt(0, c
).getClass();
1014 return String
.class;
1017 public boolean isCellEditable (int row
, int col
) {
1018 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {