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
) {
675 // As PCD sync. check is full platform range now during opening FrameworkModules editor,
676 // the following check is no longer needed.
678 // Vector<String> vExceptions = new Vector<String>();
679 // if (ffc.adjustPcd(row, vExceptions)) {
680 // JOptionPane.showMessageDialog(frame, "Pcd entries sync. with those in MSA files.");
681 // docConsole.setSaved(false);
684 // catch (Exception exp) {
685 // JOptionPane.showMessageDialog(frame, exp.getMessage());
688 if (settingDlg
== null) {
689 settingDlg
= new FpdModuleSA(ffc
);
692 String
[] sa
= new String
[5];
693 ffc
.getFrameworkModuleInfo(row
, sa
);
694 String mg
= sa
[ffcModGuid
];
695 String mv
= sa
[ffcModVer
];
696 String pg
= sa
[ffcPkgGuid
];
697 String pv
= sa
[ffcPkgVer
];
698 String arch
= sa
[ffcModArch
];
699 settingDlg
.setKey(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
, row
, docConsole
);
700 settingDlg
.setVisible(true);
703 * This method initializes jButtonSettings
705 * @return javax.swing.JButton jButtonSettings
707 private JButton
getJButtonSettings() {
708 if (jButtonSettings
== null) {
709 jButtonSettings
= new JButton();
710 jButtonSettings
.setPreferredSize(new java
.awt
.Dimension(130,20));
711 jButtonSettings
.setText("Settings");
712 jButtonSettings
.addActionListener(new java
.awt
.event
.ActionListener() {
713 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
714 int selectedRow
= jTableFpdModules
.getSelectedRow();
715 if (selectedRow
< 0) {
719 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
720 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
721 showSettingsDlg (selectedRow
);
725 return jButtonSettings
;
729 * This method initializes jButtonRemoveModule
731 * @return javax.swing.JButton jButtonRemoveModule
733 private JButton
getJButtonRemoveModule() {
734 if (jButtonRemoveModule
== null) {
735 jButtonRemoveModule
= new JButton();
736 jButtonRemoveModule
.setText("Remove Module");
737 FontMetrics fm
= jButtonRemoveModule
.getFontMetrics(jButtonRemoveModule
.getFont());
738 jButtonRemoveModule
.setPreferredSize(new Dimension (fm
.stringWidth(jButtonRemoveModule
.getText()) + 40, 20));
739 jButtonRemoveModule
.addActionListener(new java
.awt
.event
.ActionListener() {
740 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
741 int selectedRow
= jTableFpdModules
.getSelectedRow();
742 if (selectedRow
< 0) {
745 int nextSelection
= selectedRow
;
747 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
748 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
750 String
[] sa
= new String
[5];
751 ffc
.getFrameworkModuleInfo(selectedRow
, sa
);
752 String mg
= sa
[ffcModGuid
];
753 String mv
= sa
[ffcModVer
];
754 String pg
= sa
[ffcPkgGuid
];
755 String pv
= sa
[ffcPkgVer
];
756 String arch
= sa
[ffcModArch
];
758 // sync. module order list in BuildOptions-UserExtensions.
760 String moduleKey
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
761 String fvBindings
= ffc
.getFvBinding(moduleKey
);
762 if (fvBindings
!= null) {
763 String
[] fvArray
= fvBindings
.split(" ");
764 for (int i
= 0; i
< fvArray
.length
; ++i
) {
765 ffc
.removeModuleInBuildOptionsUserExtensions(fvArray
[i
].trim(), "IMAGES", 1, mg
, mv
, pg
, pv
, arch
);
769 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
);
771 mv
= mi
.getVersion();
772 pv
= mi
.getPackageId().getVersion();
776 ffc
.removeModuleSA(selectedRow
);
778 catch (Exception exp
) {
779 JOptionPane
.showMessageDialog(frame
, exp
.getMessage());
784 // if no arch specified in ModuleSA
785 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
788 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
791 if (al
.size() == 0) {
792 fpdMsa
.remove(mg
+ mv
+ pg
+ pv
);
797 modelFpdModules
.removeRow(selectedRow
);
798 if (nextSelection
>= jTableFpdModules
.getRowCount()) {
799 nextSelection
= jTableFpdModules
.getRowCount() - 1;
801 jTableFpdModules
.changeSelection(nextSelection
, 0, false, false);
802 docConsole
.setSaved(false);
806 return jButtonRemoveModule
;
810 * This method initializes jButtonApriori
812 * @return javax.swing.JButton
814 private JButton
getJButtonApriori() {
815 if (jButtonApriori
== null) {
816 jButtonApriori
= new JButton();
817 jButtonApriori
.setText("Apriori Files");
818 FontMetrics fm
= jButtonApriori
.getFontMetrics(jButtonApriori
.getFont());
819 int buttonWidth
= fm
.stringWidth(jButtonApriori
.getText()) + 40;
820 if (jButtonRemoveModule
.getWidth() > buttonWidth
) {
821 buttonWidth
= jButtonRemoveModule
.getWidth();
823 jButtonApriori
.setPreferredSize(new Dimension (buttonWidth
, 20));
824 jButtonApriori
.addActionListener(new java
.awt
.event
.ActionListener() {
825 public void actionPerformed(ActionEvent arg0
) {
826 new GenAprioriFileDialog(ffc
, docConsole
).setVisible(true);
829 return jButtonApriori
;
836 public static void main(String
[] args
) {
837 // Set the pane visable
838 new FpdFrameworkModules().setVisible(true);
842 * This is the default constructor
844 public FpdFrameworkModules() {
849 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
855 public FpdFrameworkModules(OpeningPlatformType opt
) {
856 this(opt
.getXmlFpd());
858 Vector
<String
> vExceptions
= new Vector
<String
>();
859 if (pcdSync(vExceptions
)) {
860 JOptionPane
.showMessageDialog(frame
, "PCD in this platform are synchronized with those in MSA files.");
861 docConsole
.setSaved(false);
863 if (vExceptions
.size() > 0) {
864 String errorMsg
= "";
865 for (int i
= 0; i
< vExceptions
.size(); ++i
) {
866 errorMsg
+= " " + vExceptions
.get(i
) + "\n";
868 JOptionPane
.showMessageDialog(frame
, "Error occurred during synchronization:\n" + errorMsg
);
872 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
875 ffc
= new FpdFileContents(fpd
);
879 if (fpdMsa
== null) {
880 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
883 if (ffc
.getFrameworkModulesCount() > 0) {
884 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
885 ffc
.getFrameworkModulesInfo(saa
);
886 for (int i
= 0; i
< saa
.length
; ++i
) {
887 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
888 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
889 Object
[] row
= { "", "", "", "", "", "", "", "" };
891 row
[modNameColForFpdModTable
] = mi
.getName();
892 row
[modVerColForFpdModTable
] = mi
.getVersion();
893 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
894 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
895 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
896 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
898 row
[pathColForFpdModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
899 } catch (Exception e
) {
900 JOptionPane
.showMessageDialog(frame
, "Show FPD Modules:" + e
.getMessage());
903 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
904 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
905 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
907 al
= new ArrayList
<String
>();
908 fpdMsa
.put(fpdMsaKey
, al
);
910 al
.add(saa
[i
][ffcModArch
]);
913 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
914 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
915 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
916 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
917 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
919 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
920 modelFpdModules
.addRow(row
);
923 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
924 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
931 private boolean pcdSync(Vector
<String
> v
) {
932 boolean synced
= false;
933 for (int i
= 0; i
< jTableFpdModules
.getRowCount(); ++i
) {
935 if (ffc
.adjustPcd(i
, v
)) {
939 catch (Exception exp
) {
940 // JOptionPane.showMessageDialog(frame, exp.getMessage());
948 private void showAllModules() {
950 if (miList
== null) {
951 miList
= new ArrayList
<ModuleIdentification
>();
954 String
[] s
= { "", "", "", "", "", "" };
956 Iterator ismi
= GlobalData
.vModuleList
.iterator();
957 while (ismi
.hasNext()) {
958 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
959 s
[modNameColForAllModTable
] = mi
.getName();
960 s
[modVerColForAllModTable
] = mi
.getVersion();
961 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
962 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
963 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
965 s
[pathColForAllModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
966 } catch (Exception e
) {
967 JOptionPane
.showMessageDialog(frame
, "Show All Modules:" + e
.getMessage());
969 modelAllModules
.addRow(s
);
974 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
975 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
979 * This method initializes this
983 private void initialize() {
984 this.setSize(633, 533);
985 this.setTitle("Framework Modules");
986 this.setContentPane(getJSplitPane());
987 this.setVisible(true);
991 } // @jve:decl-index=0:visual-constraint="10,10"
993 class NonEditableTableModel
extends DefaultTableModel
{
997 private static final long serialVersionUID
= 1L;
999 public boolean isCellEditable(int row
, int col
) {
1004 class FpdModulesTableModel
extends DefaultTableModel
{
1009 private static final long serialVersionUID
= 1L;
1011 public Class
<?
> getColumnClass (int c
) {
1012 if (getValueAt(0, c
) != null){
1013 return getValueAt(0, c
).getClass();
1015 return String
.class;
1018 public boolean isCellEditable (int row
, int col
) {
1019 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {