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
.JOptionPane
;
22 import javax
.swing
.JPanel
;
23 import javax
.swing
.JSplitPane
;
24 import javax
.swing
.JLabel
;
25 import javax
.swing
.JScrollPane
;
26 import javax
.swing
.JTable
;
27 import javax
.swing
.JButton
;
28 import javax
.swing
.ListSelectionModel
;
29 import javax
.swing
.event
.TableModelEvent
;
30 import javax
.swing
.table
.DefaultTableModel
;
31 import javax
.swing
.table
.TableModel
;
33 import org
.tianocore
.PlatformSurfaceAreaDocument
;
34 import org
.tianocore
.frameworkwizard
.FrameworkWizardUI
;
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;
68 private JSplitPane jSplitPane
= null;
70 private JPanel jPanelTop
= null;
72 private JPanel jPanelBottom
= null;
74 private JLabel jLabel
= null;
76 private JScrollPane jScrollPaneAllModules
= null;
78 private JTable jTableAllModules
= null;
80 private JPanel jPanelTopSouth
= null;
82 private JButton jButtonAddModule
= null;
84 private JLabel jLabelModulesAdded
= null;
86 private JPanel jPanelBottomSouth
= null;
88 private JScrollPane jScrollPaneFpdModules
= null;
90 private JTable jTableFpdModules
= null;
92 private JButton jButtonSettings
= null;
94 private JButton jButtonRemoveModule
= null;
96 private NonEditableTableModel modelAllModules
= null;
98 private FpdModulesTableModel modelFpdModules
= null;
100 private FpdModuleSA settingDlg
= null;
102 private FpdFileContents ffc
= null;
104 private OpeningPlatformType docConsole
= null;
106 private Map
<String
, ArrayList
<String
>> fpdMsa
= null;
108 private ArrayList
<ModuleIdentification
> miList
= null;
111 * Column settings for displaying all modules in workspace
113 private final int modNameColForAllModTable
= 0;
115 private final int pkgNameColForAllModTable
= 1;
117 private final int pathColForAllModTable
= 2;
119 private final int typeColForAllModTable
= 3;
121 private final int pkgVerColForAllModTable
= 5;
123 private final int modVerColForAllModTable
= 4;
126 * Column settings for display modules in the FPD file
128 private final int modNameColForFpdModTable
= 0;
130 private final int pkgNameColForFpdModTable
= 1;
132 private final int pathColForFpdModTable
= 2;
134 private final int archColForFpdModTable
= 3;
136 private final int pkgVerColForFpdModTable
= 6;
138 private final int modVerColForFpdModTable
= 5;
140 private final int typeColForFpdModTable
= 4;
143 * FpdFileContents structure
145 private final int ffcModGuid
= 0;
147 private final int ffcModVer
= 1;
149 private final int ffcPkgGuid
= 2;
151 private final int ffcPkgVer
= 3;
153 private final int ffcModArch
= 4;
156 * Set Column Widths, Only the PATH should not have a max width.
158 private final int modNameMinWidth
= 168;
160 private final int modNamePrefWidth
= 200;
162 private final int modNameMaxWidth
= 350;
164 private final int pkgNameMinWidth
= 100;
166 private final int pkgNamePrefWidth
= 130;
168 private final int pkgNameMaxWidth
= 150;
170 private final int verMinWidth
= 60;
172 private final int verMaxWidth
= 80;
174 private final int verPrefWidth
= 70;
176 private final int pathPrefWidth
= 600;
178 private final int pathMinWidth
= 280;
180 private final int archPrefWidth
= 80;
182 private final int archMinWidth
= 60;
184 private final int archMaxWidth
= 100;
186 private final int typePrefWidth
= 145;
188 private final int typeMinWidth
= 100;
190 private final int typeMaxWidth
= 155;
192 private JButton jButtonApriori
= null;
195 * This method initializes jSplitPane
197 * This is the main edit window
199 * @return javax.swing.JSplitPane jSplitPane
201 private JSplitPane
getJSplitPane() {
202 if (jSplitPane
== null) {
203 jSplitPane
= new JSplitPane();
204 jSplitPane
.setOrientation(javax
.swing
.JSplitPane
.VERTICAL_SPLIT
);
205 jSplitPane
.setDividerLocation(250);
206 jSplitPane
.setBottomComponent(getJPanelBottom());
207 jSplitPane
.setTopComponent(getJPanelTop());
213 * This method initializes jPanelTop
215 * This panel contains the All Modules Table
217 * @return javax.swing.JPanel jPanelTop
219 private JPanel
getJPanelTop() {
220 if (jPanelTop
== null) {
221 jLabel
= new JLabel();
222 jLabel
.setText(" Modules in Workspace");
223 jPanelTop
= new JPanel();
224 jPanelTop
.setLayout(new BorderLayout());
225 jPanelTop
.add(jLabel
, java
.awt
.BorderLayout
.NORTH
);
226 jPanelTop
.add(getJScrollPaneAllModules(), java
.awt
.BorderLayout
.CENTER
);
227 jPanelTop
.add(getJPanelTopSouth(), java
.awt
.BorderLayout
.SOUTH
);
233 * This method initializes jPanelBottom
235 * This panel contains the FPD Modules Table
237 * @return javax.swing.JPanel jPanelBottom
239 private JPanel
getJPanelBottom() {
240 if (jPanelBottom
== null) {
241 jLabelModulesAdded
= new JLabel();
242 jLabelModulesAdded
.setText(" Modules Added into Platform");
243 jPanelBottom
= new JPanel();
244 jPanelBottom
.setLayout(new BorderLayout());
245 jPanelBottom
.add(jLabelModulesAdded
, java
.awt
.BorderLayout
.NORTH
);
246 jPanelBottom
.add(getJPanelBottomSouth(), java
.awt
.BorderLayout
.SOUTH
);
247 jPanelBottom
.add(getJScrollPaneFpdModules(), java
.awt
.BorderLayout
.CENTER
);
253 * This method initializes jScrollPaneAllModules
255 * @return javax.swing.JScrollPane jScrollPaneAllModules
257 private JScrollPane
getJScrollPaneAllModules() {
258 if (jScrollPaneAllModules
== null) {
259 jScrollPaneAllModules
= new JScrollPane();
260 jScrollPaneAllModules
.setPreferredSize(new java
.awt
.Dimension(600, 200));
261 jScrollPaneAllModules
.setViewportView(getJTableAllModules());
263 return jScrollPaneAllModules
;
267 * This method initializes jTableAllModules
269 * @return javax.swing.JTable jTableAllModules
271 private JTable
getJTableAllModules() {
272 if (jTableAllModules
== null) {
273 modelAllModules
= new NonEditableTableModel();
274 TableSorter sorter
= new TableSorter(modelAllModules
);
275 jTableAllModules
= new JTable(sorter
);
276 sorter
.setTableHeader(jTableAllModules
.getTableHeader());
277 jTableAllModules
.setRowHeight(20);
278 modelAllModules
.addColumn("<html>Module<br>Name</html>");
279 modelAllModules
.addColumn("<html>Package<br>Name</html>");
280 modelAllModules
.addColumn("Path");
281 modelAllModules
.addColumn("<html>Module<br>Type</html>");
282 modelAllModules
.addColumn("<html>Module<br>Version</html>");
283 modelAllModules
.addColumn("<html>Package<br>Version</html>");
285 javax
.swing
.table
.TableColumn column
= null;
286 column
= jTableAllModules
.getColumnModel().getColumn(modNameColForAllModTable
);
287 column
.setPreferredWidth(modNamePrefWidth
);
288 column
.setMinWidth(modNameMinWidth
);
289 column
.setMaxWidth(modNameMaxWidth
);
290 column
= jTableAllModules
.getColumnModel().getColumn(modVerColForAllModTable
);
291 column
.setPreferredWidth(verPrefWidth
);
292 column
.setMaxWidth(verMaxWidth
);
293 column
.setMinWidth(verMinWidth
);
294 column
= jTableAllModules
.getColumnModel().getColumn(pkgNameColForAllModTable
);
295 column
.setPreferredWidth(pkgNamePrefWidth
);
296 column
.setMinWidth(pkgNameMinWidth
);
297 column
.setMaxWidth(pkgNameMaxWidth
);
298 column
= jTableAllModules
.getColumnModel().getColumn(pkgVerColForAllModTable
);
299 column
.setPreferredWidth(verPrefWidth
);
300 column
.setMaxWidth(verMaxWidth
);
301 column
.setMinWidth(verMinWidth
);
302 column
= jTableAllModules
.getColumnModel().getColumn(typeColForAllModTable
);
303 column
.setPreferredWidth(typePrefWidth
);
304 column
.setMaxWidth(typeMaxWidth
);
305 column
.setMinWidth(typeMinWidth
);
306 column
= jTableAllModules
.getColumnModel().getColumn(pathColForAllModTable
);
307 column
.setPreferredWidth(pathPrefWidth
);
308 column
.setMinWidth(pathMinWidth
);
310 jTableAllModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
311 jTableAllModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
312 jTableAllModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
313 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
314 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
315 java
.awt
.Point p
= e
.getPoint();
316 int rowIndex
= jTableAllModules
.rowAtPoint(p
);
317 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
318 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
319 addModuleIntoPlatform (rowIndex
);
323 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
324 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
325 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
326 int selectedRow
= jTableAllModules
.getSelectedRow();
327 if (selectedRow
< 0) {
330 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
331 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
332 addModuleIntoPlatform (selectedRow
);
337 jTableAllModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
338 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
340 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
341 searchField
+= e
.getKeyChar();
344 searchField
= "" + e
.getKeyChar();
347 int viewIndex
= gotoFoundRow (searchField
, jTableAllModules
);
349 jTableAllModules
.changeSelection(viewIndex
, 0, false, false);
351 savedMs
= System
.currentTimeMillis();
357 return jTableAllModules
;
360 private int gotoFoundRow (String s
, JTable model
) {
361 for (int i
= 0; i
< model
.getRowCount(); ++i
) {
362 if (model
.getValueAt(i
, 0) != null && model
.getValueAt(i
, 0).toString().regionMatches(true, 0, s
, 0, s
.length())) {
370 * This method initializes jPanelTopSouth
372 * This panel contains the ADD button
374 * @return javax.swing.JPanel jPanelTopSouth
376 private JPanel
getJPanelTopSouth() {
377 if (jPanelTopSouth
== null) {
378 FlowLayout flowLayout
= new FlowLayout();
379 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
380 jPanelTopSouth
= new JPanel();
381 jPanelTopSouth
.setLayout(flowLayout
);
382 jPanelTopSouth
.add(getJButtonAddModule(), null);
384 return jPanelTopSouth
;
387 private void addModuleIntoPlatform (int selectedRow
) {
388 String path
= modelAllModules
.getValueAt(selectedRow
, pathColForAllModTable
) + "";
389 ModuleIdentification mi
= miList
.get(selectedRow
);
390 Vector
<String
> vArchs
= null;
392 vArchs
= WorkspaceProfile
.getModuleSupArchs(mi
);
394 if (vArchs
== null) {
395 JOptionPane
.showMessageDialog(this, "No Supported Architectures specified in MSA file.");
399 Vector
<Object
> platformSupArch
= new Vector
<Object
>();
400 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
401 platformSupArch
.retainAll(vArchs
);
402 if (platformSupArch
.size() == 0) {
403 JOptionPane
.showMessageDialog(this, "This Module does not support this platform architectures.");
407 String archsAdded
= "";
408 String mg
= mi
.getGuid();
409 String mv
= mi
.getVersion();
410 String pg
= mi
.getPackageId().getGuid();
411 String pv
= mi
.getPackageId().getVersion();
412 String mType
= SurfaceAreaQuery
.getModuleType(mi
);
414 ArrayList
<String
> al
= fpdMsa
.get(mg
+ mv
+ pg
+ pv
);
417 // if existing ModuleSA does not specify version info.
419 al
= fpdMsa
.get(mg
+ "null" + pg
+ "null");
421 al
= fpdMsa
.get(mg
+ "null" + pg
+ pv
);
423 al
= fpdMsa
.get(mg
+ mv
+ pg
+ "null");
425 al
= new ArrayList
<String
>();
426 fpdMsa
.put(mg
+ mv
+ pg
+ pv
, al
);
432 // filter from module SupArchs what archs has been added.
434 for (int i
= 0; i
< al
.size(); ++i
) {
435 vArchs
.remove(al
.get(i
));
438 // check whether archs conform to SupArch of platform.
440 platformSupArch
.removeAllElements();
441 ffc
.getPlatformDefsSupportedArchs(platformSupArch
);
442 vArchs
.retainAll(platformSupArch
);
444 // Archs this Module supported have already been added.
446 if (vArchs
.size() == 0) {
447 JOptionPane
.showMessageDialog(this, "This Module has already been added.");
450 //ToDo put Arch instead of null
451 boolean errorOccurred
= false;
452 for (int i
= 0; i
< vArchs
.size(); ++i
) {
453 String arch
= vArchs
.get(i
);
455 archsAdded
+= arch
+ " ";
456 String
[] row
= { "", "", "", "", "", "", "" };
459 row
[modNameColForFpdModTable
] = mi
.getName();
460 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
461 row
[pathColForFpdModTable
] = path
;
462 row
[archColForFpdModTable
] = arch
;
463 row
[pkgVerColForFpdModTable
] = pv
;
464 row
[modVerColForFpdModTable
] = mv
;
465 row
[typeColForFpdModTable
] = mType
;
468 modelFpdModules
.addRow(row
);
470 docConsole
.setSaved(false);
472 //ToDo : specify archs need to add.
473 ffc
.addFrameworkModulesPcdBuildDefs(mi
, arch
, null);
474 } catch (Exception exception
) {
475 JOptionPane
.showMessageDialog(this, "Adding " + row
[modNameColForFpdModTable
] + " with Supporting Architectures: " + arch
476 + ": " + exception
.getMessage());
477 errorOccurred
= true;
481 String s
= "This Module with Architecture " + archsAdded
;
483 s
+= " was added with Error. Platform may NOT Build.";
485 s
+= " was added Successfully.";
487 JOptionPane
.showMessageDialog(this, s
);
488 TableSorter sorterFpdModules
= (TableSorter
)jTableFpdModules
.getModel();
489 int viewIndex
= sorterFpdModules
.getViewIndexArray()[modelFpdModules
.getRowCount() - 1];
490 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
495 * This method initializes jButtonAddModule
497 * @return javax.swing.JButton jButtonAddModule
499 private JButton
getJButtonAddModule() {
500 if (jButtonAddModule
== null) {
501 jButtonAddModule
= new JButton();
502 jButtonAddModule
.setPreferredSize(new java
.awt
.Dimension(130, 20));
503 jButtonAddModule
.setText("Add a Module");
504 jButtonAddModule
.addActionListener(new java
.awt
.event
.ActionListener() {
505 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
506 int selectedRow
= jTableAllModules
.getSelectedRow();
507 if (selectedRow
< 0) {
511 TableSorter sorter
= (TableSorter
) jTableAllModules
.getModel();
512 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
513 addModuleIntoPlatform (selectedRow
);
517 return jButtonAddModule
;
521 * This method initializes jPanelBottomSouth
523 * This panel contains the Settings and Remove Buttons
525 * @return javax.swing.JPanel jPanelBottomSouth
527 private JPanel
getJPanelBottomSouth() {
528 if (jPanelBottomSouth
== null) {
529 FlowLayout flowLayout1
= new FlowLayout();
530 flowLayout1
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
531 jPanelBottomSouth
= new JPanel();
532 jPanelBottomSouth
.setLayout(flowLayout1
);
533 jPanelBottomSouth
.add(getJButtonSettings(), null);
534 jPanelBottomSouth
.add(getJButtonRemoveModule(), null);
535 jPanelBottomSouth
.add(getJButtonApriori(), null);
537 return jPanelBottomSouth
;
541 * This method initializes jScrollPaneFpdModules
543 * @return javax.swing.JScrollPane jScrollPaneFpdModules
545 private JScrollPane
getJScrollPaneFpdModules() {
546 if (jScrollPaneFpdModules
== null) {
547 jScrollPaneFpdModules
= new JScrollPane();
548 jScrollPaneFpdModules
.setPreferredSize(new java
.awt
.Dimension(453, 200));
549 jScrollPaneFpdModules
.setViewportView(getJTableFpdModules());
551 return jScrollPaneFpdModules
;
555 * This method initializes jTableFpdModules
557 * @return javax.swing.JTable jTableFpdModules
559 private JTable
getJTableFpdModules() {
560 if (jTableFpdModules
== null) {
561 modelFpdModules
= new FpdModulesTableModel();
562 TableSorter sorter
= new TableSorter(modelFpdModules
);
563 jTableFpdModules
= new JTable(sorter
);
564 sorter
.setTableHeader(jTableFpdModules
.getTableHeader());
565 jTableFpdModules
.setRowHeight(20);
566 modelFpdModules
.addColumn("<html>Module<br>Name</html>");
567 modelFpdModules
.addColumn("<html>Package<br>Name</html>");
568 modelFpdModules
.addColumn("Path");
569 modelFpdModules
.addColumn("<html>Supported<br>Architectures</html>");
570 modelFpdModules
.addColumn("<html>Module<br>Type</html>");
571 modelFpdModules
.addColumn("<html>Module<br>Version</html>");
572 modelFpdModules
.addColumn("<html>Package<br>Version</html>");
573 modelFpdModules
.addColumn("<html>Force<br>Debug</html>");
575 javax
.swing
.table
.TableColumn column
= null;
576 column
= jTableFpdModules
.getColumnModel().getColumn(modNameColForFpdModTable
);
577 column
.setPreferredWidth(modNamePrefWidth
);
578 column
.setMinWidth(modNameMinWidth
);
579 column
.setMaxWidth(modNameMaxWidth
);
580 column
= jTableFpdModules
.getColumnModel().getColumn(modVerColForFpdModTable
);
581 column
.setPreferredWidth(verPrefWidth
);
582 column
.setMaxWidth(verMaxWidth
);
583 column
.setMinWidth(verMinWidth
);
584 column
= jTableFpdModules
.getColumnModel().getColumn(pkgNameColForFpdModTable
);
585 column
.setPreferredWidth(pkgNamePrefWidth
);
586 column
.setMinWidth(pkgNameMinWidth
);
587 column
.setMaxWidth(pkgNameMaxWidth
);
588 column
= jTableFpdModules
.getColumnModel().getColumn(pkgVerColForFpdModTable
);
589 column
.setPreferredWidth(verPrefWidth
);
590 column
.setMaxWidth(verMaxWidth
);
591 column
.setMinWidth(verMinWidth
);
592 column
= jTableFpdModules
.getColumnModel().getColumn(archColForFpdModTable
);
593 column
.setPreferredWidth(archPrefWidth
);
594 column
.setMaxWidth(archMaxWidth
);
595 column
.setMinWidth(archMinWidth
);
596 column
= jTableFpdModules
.getColumnModel().getColumn(pathColForFpdModTable
);
597 column
.setPreferredWidth(pathPrefWidth
);
598 column
.setMinWidth(pathMinWidth
);
599 column
= jTableFpdModules
.getColumnModel().getColumn(typeColForFpdModTable
);
600 column
.setPreferredWidth(typePrefWidth
);
601 column
.setMaxWidth(typeMaxWidth
);
602 column
.setMinWidth(typeMinWidth
);
604 jTableFpdModules
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
605 jTableFpdModules
.setAutoResizeMode(JTable
.AUTO_RESIZE_OFF
);
607 jTableFpdModules
.addMouseListener(new java
.awt
.event
.MouseAdapter() {
608 public void mouseClicked(java
.awt
.event
.MouseEvent e
) {
609 if (e
.getButton() == MouseEvent
.BUTTON1
&& e
.getClickCount() == 2) {
610 java
.awt
.Point p
= e
.getPoint();
611 int rowIndex
= jTableFpdModules
.rowAtPoint(p
);
612 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
613 rowIndex
= sorter
.getModelRowIndex(rowIndex
);
614 showSettingsDlg (rowIndex
);
619 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
620 public void keyPressed(java
.awt
.event
.KeyEvent e
) {
621 if (e
.getKeyCode() == KeyEvent
.VK_ENTER
) {
622 int selectedRow
= jTableFpdModules
.getSelectedRow();
623 if (selectedRow
< 0) {
626 TableSorter sorter
= (TableSorter
) jTableFpdModules
.getModel();
627 selectedRow
= sorter
.getModelRowIndex(selectedRow
);
628 showSettingsDlg (selectedRow
);
633 jTableFpdModules
.addKeyListener(new java
.awt
.event
.KeyAdapter() {
634 public void keyTyped(java
.awt
.event
.KeyEvent e
) {
636 if (System
.currentTimeMillis() - savedMs
< timeToWait
) {
637 searchField
+= e
.getKeyChar();
640 searchField
= "" + e
.getKeyChar();
643 int viewIndex
= gotoFoundRow (searchField
, jTableFpdModules
);
645 jTableFpdModules
.changeSelection(viewIndex
, 0, false, false);
647 savedMs
= System
.currentTimeMillis();
651 jTableFpdModules
.getModel().addTableModelListener(this);
653 return jTableFpdModules
;
656 public void tableChanged(TableModelEvent arg0
) {
657 if (arg0
.getType() == TableModelEvent
.UPDATE
){
658 int row
= arg0
.getFirstRow();
659 int column
= arg0
.getColumn();
660 TableModel m
= (TableModel
)arg0
.getSource();
662 if (column
!= forceDbgColForFpdModTable
) {
665 String s
= m
.getValueAt(row
, column
)+"";
666 boolean dbgEnable
= new Boolean(s
);
667 ffc
.setModuleSAForceDebug(row
, dbgEnable
);
668 docConsole
.setSaved(false);
672 private void showSettingsDlg (int row
) {
673 // As PCD sync. check is full platform range now during opening FrameworkModules editor,
674 // the following check is no longer needed.
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());
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(FpdFrameworkModules
.this, 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);
839 private class PcdSyncTask
extends Thread
{
842 Vector
<String
> vExceptions
= new Vector
<String
>();
843 if (pcdSync(vExceptions
)) {
844 JOptionPane
.showMessageDialog(FrameworkWizardUI
.getInstance(), "PCD in this platform are synchronized with those in MSA files.");
845 docConsole
.setSaved(false);
847 if (vExceptions
.size() > 0) {
848 String errorMsg
= "";
849 for (int i
= 0; i
< vExceptions
.size(); ++i
) {
850 errorMsg
+= " " + vExceptions
.get(i
) + "\n";
852 JOptionPane
.showMessageDialog(FrameworkWizardUI
.getInstance(), "Error occurred during synchronization:\n" + errorMsg
);
858 * This is the default constructor
860 public FpdFrameworkModules() {
865 public FpdFrameworkModules(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
871 private PcdSyncTask pst
= null;
872 public FpdFrameworkModules(OpeningPlatformType opt
) {
873 this(opt
.getXmlFpd());
876 pst
= new PcdSyncTask();
881 private void init(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
884 ffc
= new FpdFileContents(fpd
);
888 if (fpdMsa
== null) {
889 fpdMsa
= new HashMap
<String
, ArrayList
<String
>>();
892 if (ffc
.getFrameworkModulesCount() > 0) {
893 String
[][] saa
= new String
[ffc
.getFrameworkModulesCount()][5];
894 ffc
.getFrameworkModulesInfo(saa
);
895 for (int i
= 0; i
< saa
.length
; ++i
) {
896 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(saa
[i
][ffcModGuid
] + " " + saa
[i
][ffcModVer
] + " "
897 + saa
[i
][ffcPkgGuid
] + " " + saa
[i
][ffcPkgVer
]);
898 Object
[] row
= { "", "", "", "", "", "", "", "" };
900 row
[modNameColForFpdModTable
] = mi
.getName();
901 row
[modVerColForFpdModTable
] = mi
.getVersion();
902 row
[typeColForFpdModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
903 row
[pkgNameColForFpdModTable
] = mi
.getPackageId().getName();
904 row
[pkgVerColForFpdModTable
] = mi
.getPackageId().getVersion();
905 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
907 row
[pathColForFpdModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
908 } catch (Exception e
) {
909 JOptionPane
.showMessageDialog(FrameworkWizardUI
.getInstance(), "Show FPD Modules:" + e
.getMessage());
912 String fpdMsaKey
= saa
[i
][ffcModGuid
] + row
[modVerColForFpdModTable
]
913 + saa
[i
][ffcPkgGuid
] + row
[pkgVerColForFpdModTable
];
914 ArrayList
<String
> al
= fpdMsa
.get(fpdMsaKey
);
916 al
= new ArrayList
<String
>();
917 fpdMsa
.put(fpdMsaKey
, al
);
919 al
.add(saa
[i
][ffcModArch
]);
922 row
[modNameColForFpdModTable
] = saa
[i
][ffcModGuid
];
923 row
[modVerColForFpdModTable
] = saa
[i
][ffcModVer
];
924 row
[pkgNameColForFpdModTable
] = saa
[i
][ffcPkgGuid
];
925 row
[pkgVerColForFpdModTable
] = saa
[i
][ffcPkgVer
];
926 row
[archColForFpdModTable
] = saa
[i
][ffcModArch
];
928 row
[forceDbgColForFpdModTable
] = ffc
.getModuleSAForceDebug(i
);
929 modelFpdModules
.addRow(row
);
932 TableSorter sorter
= (TableSorter
)jTableFpdModules
.getModel();
933 sorter
.setSortState(modNameColForFpdModTable
, TableSorter
.ASCENDING
);
940 private boolean pcdSync(Vector
<String
> v
) {
941 boolean synced
= false;
942 String
[] sa
= new String
[5];
943 for (int i
= 0; i
< jTableFpdModules
.getRowCount(); ++i
) {
945 ffc
.getFrameworkModuleInfo(i
, sa
);
946 String mg
= sa
[ffcModGuid
];
947 String mv
= sa
[ffcModVer
];
948 String pg
= sa
[ffcPkgGuid
];
949 String pv
= sa
[ffcPkgVer
];
950 String arch
= sa
[ffcModArch
];
951 String key
= mg
+ " " + mv
+ " " + pg
+ " " + pv
+ " " + arch
;
952 if (ffc
.adjustPcd(key
, v
)) {
956 catch (Exception exp
) {
957 // JOptionPane.showMessageDialog(frame, exp.getMessage());
965 private void showAllModules() {
967 if (miList
== null) {
968 miList
= new ArrayList
<ModuleIdentification
>();
971 String
[] s
= { "", "", "", "", "", "" };
973 Iterator ismi
= GlobalData
.vModuleList
.iterator();
974 while (ismi
.hasNext()) {
975 ModuleIdentification mi
= (ModuleIdentification
) ismi
.next();
976 s
[modNameColForAllModTable
] = mi
.getName();
977 s
[modVerColForAllModTable
] = mi
.getVersion();
978 s
[typeColForAllModTable
] = SurfaceAreaQuery
.getModuleType(mi
);
979 s
[pkgNameColForAllModTable
] = mi
.getPackageId().getName();
980 s
[pkgVerColForAllModTable
] = mi
.getPackageId().getVersion();
982 s
[pathColForAllModTable
] = mi
.getPath().substring(Workspace
.getCurrentWorkspace().length() + 1);
983 } catch (Exception e
) {
984 JOptionPane
.showMessageDialog(FrameworkWizardUI
.getInstance(), "Show All Modules:" + e
.getMessage());
986 modelAllModules
.addRow(s
);
991 TableSorter sorter
= (TableSorter
)jTableAllModules
.getModel();
992 sorter
.setSortState(modNameColForAllModTable
, TableSorter
.ASCENDING
);
996 * This method initializes this
1000 private void initialize() {
1001 this.setSize(633, 533);
1002 this.setTitle("Framework Modules");
1003 this.setContentPane(getJSplitPane());
1004 this.setVisible(true);
1008 } // @jve:decl-index=0:visual-constraint="10,10"
1010 class NonEditableTableModel
extends DefaultTableModel
{
1014 private static final long serialVersionUID
= 1L;
1016 public boolean isCellEditable(int row
, int col
) {
1021 class FpdModulesTableModel
extends DefaultTableModel
{
1026 private static final long serialVersionUID
= 1L;
1028 public Class
<?
> getColumnClass (int c
) {
1029 if (getValueAt(0, c
) != null){
1030 return getValueAt(0, c
).getClass();
1032 return String
.class;
1035 public boolean isCellEditable (int row
, int col
) {
1036 if (col
== FpdFrameworkModules
.forceDbgColForFpdModTable
) {