X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdFrameworkModules.java;h=ae74471c21c6dcc0935eb55afa53d19e910601d2;hp=e6a372a36e0b0e76e810949686928bef59efd79c;hb=a0783edc77ae576d8032461935362f43293bc467;hpb=a8a9de7cbbfc0146a1c6c5c9a9dc4abfe48fca6e diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index e6a372a36e..ae74471c21 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -1,3 +1,17 @@ +/** @file + + The file is used to create, update FrameworkModules of Fpd file + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ package org.tianocore.frameworkwizard.platform.ui; import java.awt.BorderLayout; @@ -11,30 +25,34 @@ import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JButton; import javax.swing.ListSelectionModel; +import javax.swing.event.TableModelEvent; import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; import org.tianocore.frameworkwizard.common.ui.IInternalFrame; -import org.tianocore.frameworkwizard.platform.ui.global.GlobalData; -import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; -import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; +import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery; +import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import java.awt.FlowLayout; -import java.io.File; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.Set; import java.util.Vector; public class FpdFrameworkModules extends IInternalFrame { /** - * + * Initialize Globals */ private static final long serialVersionUID = 1L; + + public static final int forceDbgColForFpdModTable = 7; static JFrame frame; @@ -68,7 +86,7 @@ public class FpdFrameworkModules extends IInternalFrame { private NonEditableTableModel modelAllModules = null; - private NonEditableTableModel modelFpdModules = null; + private FpdModulesTableModel modelFpdModules = null; private FpdModuleSA settingDlg = null; @@ -79,51 +97,95 @@ public class FpdFrameworkModules extends IInternalFrame { private Map> fpdMsa = null; private ArrayList miList = null; + + /** + * Column settings for displaying all modules in workspace + */ + private final int modNameColForAllModTable = 0; + + private final int pkgNameColForAllModTable = 1; + + private final int pathColForAllModTable = 2; + + private final int typeColForAllModTable = 3; + + private final int pkgVerColForAllModTable = 5; + + private final int modVerColForAllModTable = 4; + + /** + * Column settings for display modules in the FPD file + */ + private final int modNameColForFpdModTable = 0; + + private final int pkgNameColForFpdModTable = 1; + + private final int pathColForFpdModTable = 2; + + private final int archColForFpdModTable = 3; + + private final int pkgVerColForFpdModTable = 6; - private final int ModNameCol = 0; - - private final int ModVerCol = 1; - - private final int PkgNameCol = 2; - - private final int PkgVerCol = 3; - - private final int ArchCol = 4; - - private final int Path4Col = 4; - - private final int Path5Col = 5; + private final int modVerColForFpdModTable = 5; + + private final int typeColForFpdModTable = 4; + + /** + * FpdFileContents structure + */ + private final int ffcModGuid = 0; + + private final int ffcModVer = 1; + + private final int ffcPkgGuid = 2; + + private final int ffcPkgVer = 3; + + private final int ffcModArch = 4; + + /** + * Set Column Widths, Only the PATH should not have a max width. + */ + private final int modNameMinWidth = 168; - private final int ModNameMinWidth = 168; + private final int modNamePrefWidth = 200; - private final int ModNamePrefWidth = 200; + private final int modNameMaxWidth = 350; - private final int PkgNameMinWidth = 100; + private final int pkgNameMinWidth = 100; + + private final int pkgNamePrefWidth = 130; + + private final int pkgNameMaxWidth = 150; - private final int PkgNamePrefWidth = 110; + private final int verMinWidth = 60; - private final int PkgNameMaxWidth = 150; + private final int verMaxWidth = 80; - private final int VerMinWidth = 50; + private final int verPrefWidth = 70; - private final int VerMaxWidth = 80; + private final int pathPrefWidth = 600; - private final int VerPrefWidth = 60; + private final int pathMinWidth = 280; - private final int PathPrefWidth = 320; + private final int archPrefWidth = 80; - private final int PathMinWidth = 280; + private final int archMinWidth = 60; - private final int ArchPrefWidth = 80; + private final int archMaxWidth = 100; - private final int ArchMinWidth = 60; + private final int typePrefWidth = 145; - private final int ArchMaxWidth = 100; + private final int typeMinWidth = 100; + + private final int typeMaxWidth = 155; /** - * This method initializes jSplitPane + * This method initializes jSplitPane + * + * This is the main edit window * - * @return javax.swing.JSplitPane + * @return javax.swing.JSplitPane jSplitPane */ private JSplitPane getJSplitPane() { if (jSplitPane == null) { @@ -137,14 +199,16 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jPanel + * This method initializes jPanelTop + * + * This panel contains the All Modules Table * - * @return javax.swing.JPanel + * @return javax.swing.JPanel jPanelTop */ private JPanel getJPanelTop() { if (jPanelTop == null) { jLabel = new JLabel(); - jLabel.setText("Modules in Workspace"); + jLabel.setText(" Modules in Workspace"); jPanelTop = new JPanel(); jPanelTop.setLayout(new BorderLayout()); jPanelTop.add(jLabel, java.awt.BorderLayout.NORTH); @@ -155,14 +219,16 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jPanel1 + * This method initializes jPanelBottom * - * @return javax.swing.JPanel + * This panel contains the FPD Modules Table + * + * @return javax.swing.JPanel jPanelBottom */ private JPanel getJPanelBottom() { if (jPanelBottom == null) { jLabelModulesAdded = new JLabel(); - jLabelModulesAdded.setText("Modules Added"); + jLabelModulesAdded.setText(" Modules Added into Platform"); jPanelBottom = new JPanel(); jPanelBottom.setLayout(new BorderLayout()); jPanelBottom.add(jLabelModulesAdded, java.awt.BorderLayout.NORTH); @@ -173,9 +239,9 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jScrollPane + * This method initializes jScrollPaneAllModules * - * @return javax.swing.JScrollPane + * @return javax.swing.JScrollPane jScrollPaneAllModules */ private JScrollPane getJScrollPaneAllModules() { if (jScrollPaneAllModules == null) { @@ -187,9 +253,9 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jTable + * This method initializes jTableAllModules * - * @return javax.swing.JTable + * @return javax.swing.JTable jTableAllModules */ private JTable getJTableAllModules() { if (jTableAllModules == null) { @@ -199,39 +265,62 @@ public class FpdFrameworkModules extends IInternalFrame { sorter.setTableHeader(jTableAllModules.getTableHeader()); jTableAllModules.setRowHeight(20); modelAllModules.addColumn("Module
Name"); - modelAllModules.addColumn("Module
Version"); modelAllModules.addColumn("Package
Name"); - modelAllModules.addColumn("Package
Version"); modelAllModules.addColumn("Path"); + modelAllModules.addColumn("Module
Type"); + modelAllModules.addColumn("Module
Version"); + modelAllModules.addColumn("Package
Version"); + javax.swing.table.TableColumn column = null; - column = jTableAllModules.getColumnModel().getColumn(ModNameCol); - column.setPreferredWidth(ModNamePrefWidth); - column.setMinWidth(ModNameMinWidth); - column = jTableAllModules.getColumnModel().getColumn(ModVerCol); - column.setPreferredWidth(VerPrefWidth); - column.setMaxWidth(VerMaxWidth); - column.setMinWidth(VerMinWidth); - column = jTableAllModules.getColumnModel().getColumn(PkgNameCol); - column.setPreferredWidth(PkgNamePrefWidth); - column.setMinWidth(PkgNameMinWidth); - column.setMaxWidth(PkgNameMaxWidth); - column = jTableAllModules.getColumnModel().getColumn(PkgVerCol); - column.setPreferredWidth(VerPrefWidth); - column.setMaxWidth(VerMaxWidth); - column.setMinWidth(VerMinWidth); - column = jTableAllModules.getColumnModel().getColumn(Path4Col); - column.setPreferredWidth(PathPrefWidth); - column.setMinWidth(PathMinWidth); + column = jTableAllModules.getColumnModel().getColumn(modNameColForAllModTable); + column.setPreferredWidth(modNamePrefWidth); + column.setMinWidth(modNameMinWidth); + column.setMaxWidth(modNameMaxWidth); + column = jTableAllModules.getColumnModel().getColumn(modVerColForAllModTable); + column.setPreferredWidth(verPrefWidth); + column.setMaxWidth(verMaxWidth); + column.setMinWidth(verMinWidth); + column = jTableAllModules.getColumnModel().getColumn(pkgNameColForAllModTable); + column.setPreferredWidth(pkgNamePrefWidth); + column.setMinWidth(pkgNameMinWidth); + column.setMaxWidth(pkgNameMaxWidth); + column = jTableAllModules.getColumnModel().getColumn(pkgVerColForAllModTable); + column.setPreferredWidth(verPrefWidth); + column.setMaxWidth(verMaxWidth); + column.setMinWidth(verMinWidth); + column = jTableAllModules.getColumnModel().getColumn(typeColForAllModTable); + column.setPreferredWidth(typePrefWidth); + column.setMaxWidth(typeMaxWidth); + column.setMinWidth(typeMinWidth); + column = jTableAllModules.getColumnModel().getColumn(pathColForAllModTable); + column.setPreferredWidth(pathPrefWidth); + column.setMinWidth(pathMinWidth); jTableAllModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jTableAllModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jTableAllModules.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + java.awt.Point p = e.getPoint(); + int rowIndex = jTableAllModules.rowAtPoint(p); + TableSorter sorter = (TableSorter) jTableAllModules.getModel(); + rowIndex = sorter.getModelRowIndex(rowIndex); + addModuleIntoPlatform (rowIndex); + } + } + }); + + } return jTableAllModules; } /** - * This method initializes jPanel2 - * - * @return javax.swing.JPanel + * This method initializes jPanelTopSouth + * + * This panel contains the ADD button + * + * @return javax.swing.JPanel jPanelTopSouth */ private JPanel getJPanelTopSouth() { if (jPanelTopSouth == null) { @@ -243,11 +332,114 @@ public class FpdFrameworkModules extends IInternalFrame { } return jPanelTopSouth; } + + private void addModuleIntoPlatform (int selectedRow) { + String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + ""; + ModuleIdentification mi = miList.get(selectedRow); + Vector vArchs = null; + try { + vArchs = WorkspaceProfile.getModuleSupArchs(mi); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + } + + if (vArchs == null) { + JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file."); + return; + } + + String archsAdded = ""; + String mg = mi.getGuid(); + String mv = mi.getVersion(); + String pg = mi.getPackageId().getGuid(); + String pv = mi.getPackageId().getVersion(); + String mType = SurfaceAreaQuery.getModuleType(mi); + + ArrayList al = fpdMsa.get(mg + mv + pg + pv); + if (al == null) { + // + // if existing ModuleSA does not specify version info. + // + al = fpdMsa.get(mg + "null" + pg + "null"); + if (al == null) { + al = fpdMsa.get(mg + "null" + pg + pv); + if (al == null){ + al = fpdMsa.get(mg + mv + pg + "null"); + if (al == null) { + al = new ArrayList(); + fpdMsa.put(mg + mv + pg + pv, al); + } + } + } + } + // + // filter from module SupArchs what archs has been added. + // + for (int i = 0; i < al.size(); ++i) { + vArchs.remove(al.get(i)); + } + // + // check whether archs conform to SupArch of platform. + // + Vector platformSupArch = new Vector(); + ffc.getPlatformDefsSupportedArchs(platformSupArch); + vArchs.retainAll(platformSupArch); + // + // Archs this Module supported have already been added. + // + if (vArchs.size() == 0) { + JOptionPane.showMessageDialog(frame, "This Module has already been added."); + return; + } + //ToDo put Arch instead of null + boolean errorOccurred = false; + for (int i = 0; i < vArchs.size(); ++i) { + String arch = vArchs.get(i); + al.add(arch); + archsAdded += arch + " "; + String[] row = { "", "", "", "", "", "", "" }; + + if (mi != null) { + row[modNameColForFpdModTable] = mi.getName(); + row[pkgNameColForFpdModTable] = mi.getPackageId().getName(); + row[pathColForFpdModTable] = path; + row[archColForFpdModTable] = arch; + row[pkgVerColForFpdModTable] = pv; + row[modVerColForFpdModTable] = mv; + row[typeColForFpdModTable] = mType; + + } + modelFpdModules.addRow(row); + + docConsole.setSaved(false); + try { + //ToDo : specify archs need to add. + ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null); + } catch (Exception exception) { + JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch + + ": " + exception.getMessage()); + errorOccurred = true; + } + } + + String s = "This Module with Architecture " + archsAdded; + if (errorOccurred) { + s += " was added with Error. Platform may NOT Build."; + } else { + s += " was added Successfully."; + } + JOptionPane.showMessageDialog(frame, s); + TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel(); + int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1]; + jTableFpdModules.changeSelection(viewIndex, 0, false, false); + + } /** - * This method initializes jButton + * This method initializes jButtonAddModule * - * @return javax.swing.JButton + * @return javax.swing.JButton jButtonAddModule */ private JButton getJButtonAddModule() { if (jButtonAddModule == null) { @@ -262,77 +454,8 @@ public class FpdFrameworkModules extends IInternalFrame { } TableSorter sorter = (TableSorter) jTableAllModules.getModel(); - selectedRow = sorter.modelIndex(selectedRow); - String path = modelAllModules.getValueAt(selectedRow, Path4Col) + ""; - ModuleIdentification mi = miList.get(selectedRow); - Vector vArchs = null; - try { - vArchs = GlobalData.getModuleSupArchs(mi); - } - catch (Exception exp) { - JOptionPane.showMessageDialog(frame, exp.getMessage()); - } - - if (vArchs == null) { - JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file."); - return; - } - - String archsAdded = ""; - String mg = mi.getGuid(); - String mv = mi.getVersion(); - String pg = mi.getPackage().getGuid(); - String pv = mi.getPackage().getVersion(); - - ArrayList al = fpdMsa.get(mg + mv + pg + pv); - if (al == null) { - al = new ArrayList(); - fpdMsa.put(mg + mv + pg + pv, al); - } - for (int i = 0; i < al.size(); ++i) { - vArchs.remove(al.get(i)); - } - // - // Archs this Module supported have already been added. - // - if (vArchs.size() == 0) { - JOptionPane.showMessageDialog(frame, "This Module has already been added."); - return; - } - //ToDo put Arch instead of null - boolean errorOccurred = false; - for (int i = 0; i < vArchs.size(); ++i) { - String arch = vArchs.get(i); - al.add(arch); - archsAdded += arch + " "; - String[] row = { "", mv, "", pv, arch, path }; - - if (mi != null) { - row[ModNameCol] = mi.getName(); - row[PkgNameCol] = mi.getPackage().getName(); - - } - modelFpdModules.addRow(row); - - docConsole.setSaved(false); - try { - //ToDo : specify archs need to add. - ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null); - } catch (Exception exception) { - JOptionPane.showMessageDialog(frame, "Adding " + row[ModNameCol] + " with SupArch " + arch - + ": " + exception.getMessage()); - errorOccurred = true; - } - } - - String s = "This Module with Architecture " + archsAdded; - if (errorOccurred) { - s += " was added with Error. Platform may NOT Build."; - } else { - s += " was added Successfully."; - } - JOptionPane.showMessageDialog(frame, s); - jTableFpdModules.changeSelection(modelFpdModules.getRowCount() - 1, 0, false, false); + selectedRow = sorter.getModelRowIndex(selectedRow); + addModuleIntoPlatform (selectedRow); } }); } @@ -340,9 +463,11 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jPanel3 + * This method initializes jPanelBottomSouth + * + * This panel contains the Settings and Remove Buttons * - * @return javax.swing.JPanel + * @return javax.swing.JPanel jPanelBottomSouth */ private JPanel getJPanelBottomSouth() { if (jPanelBottomSouth == null) { @@ -357,9 +482,9 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jScrollPane1 + * This method initializes jScrollPaneFpdModules * - * @return javax.swing.JScrollPane + * @return javax.swing.JScrollPane jScrollPaneFpdModules */ private JScrollPane getJScrollPaneFpdModules() { if (jScrollPaneFpdModules == null) { @@ -371,56 +496,120 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jTable1 + * This method initializes jTableFpdModules * - * @return javax.swing.JTable + * @return javax.swing.JTable jTableFpdModules */ private JTable getJTableFpdModules() { if (jTableFpdModules == null) { - modelFpdModules = new NonEditableTableModel(); + modelFpdModules = new FpdModulesTableModel(); TableSorter sorter = new TableSorter(modelFpdModules); jTableFpdModules = new JTable(sorter); sorter.setTableHeader(jTableFpdModules.getTableHeader()); jTableFpdModules.setRowHeight(20); modelFpdModules.addColumn("Module
Name"); - modelFpdModules.addColumn("Module
Version"); modelFpdModules.addColumn("Package
Name"); - modelFpdModules.addColumn("Package
Version"); - modelFpdModules.addColumn("Supported
Architectures"); modelFpdModules.addColumn("Path"); + modelFpdModules.addColumn("Supported
Architectures"); + modelFpdModules.addColumn("Module
Type"); + modelFpdModules.addColumn("Module
Version"); + modelFpdModules.addColumn("Package
Version"); + modelFpdModules.addColumn("Force
Debug"); + javax.swing.table.TableColumn column = null; - column = jTableFpdModules.getColumnModel().getColumn(ModNameCol); - column.setPreferredWidth(ModNamePrefWidth); - column.setMinWidth(ModNameMinWidth); - column = jTableFpdModules.getColumnModel().getColumn(ModVerCol); - column.setPreferredWidth(VerPrefWidth); - column.setMaxWidth(VerMaxWidth); - column.setMinWidth(VerMinWidth); - column = jTableFpdModules.getColumnModel().getColumn(PkgNameCol); - column.setPreferredWidth(PkgNamePrefWidth); - column.setMinWidth(PkgNameMinWidth); - column.setMaxWidth(PkgNameMaxWidth); - column = jTableFpdModules.getColumnModel().getColumn(PkgVerCol); - column.setPreferredWidth(VerPrefWidth); - column.setMaxWidth(VerMaxWidth); - column.setMinWidth(VerMinWidth); - column = jTableFpdModules.getColumnModel().getColumn(ArchCol); - column.setPreferredWidth(ArchPrefWidth); - column.setMaxWidth(ArchMaxWidth); - column.setMinWidth(ArchMinWidth); - column = jTableFpdModules.getColumnModel().getColumn(Path5Col); - column.setPreferredWidth(PathPrefWidth); - column.setMinWidth(PathMinWidth); + column = jTableFpdModules.getColumnModel().getColumn(modNameColForFpdModTable); + column.setPreferredWidth(modNamePrefWidth); + column.setMinWidth(modNameMinWidth); + column.setMaxWidth(modNameMaxWidth); + column = jTableFpdModules.getColumnModel().getColumn(modVerColForFpdModTable); + column.setPreferredWidth(verPrefWidth); + column.setMaxWidth(verMaxWidth); + column.setMinWidth(verMinWidth); + column = jTableFpdModules.getColumnModel().getColumn(pkgNameColForFpdModTable); + column.setPreferredWidth(pkgNamePrefWidth); + column.setMinWidth(pkgNameMinWidth); + column.setMaxWidth(pkgNameMaxWidth); + column = jTableFpdModules.getColumnModel().getColumn(pkgVerColForFpdModTable); + column.setPreferredWidth(verPrefWidth); + column.setMaxWidth(verMaxWidth); + column.setMinWidth(verMinWidth); + column = jTableFpdModules.getColumnModel().getColumn(archColForFpdModTable); + column.setPreferredWidth(archPrefWidth); + column.setMaxWidth(archMaxWidth); + column.setMinWidth(archMinWidth); + column = jTableFpdModules.getColumnModel().getColumn(pathColForFpdModTable); + column.setPreferredWidth(pathPrefWidth); + column.setMinWidth(pathMinWidth); + column = jTableFpdModules.getColumnModel().getColumn(typeColForFpdModTable); + column.setPreferredWidth(typePrefWidth); + column.setMaxWidth(typeMaxWidth); + column.setMinWidth(typeMinWidth); jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jTableFpdModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + + jTableFpdModules.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + java.awt.Point p = e.getPoint(); + int rowIndex = jTableFpdModules.rowAtPoint(p); + TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); + rowIndex = sorter.getModelRowIndex(rowIndex); + showSettingsDlg (rowIndex); + } + } + }); + + jTableFpdModules.getModel().addTableModelListener(this); } return jTableFpdModules; } + public void tableChanged(TableModelEvent arg0) { + if (arg0.getType() == TableModelEvent.UPDATE){ + int row = arg0.getFirstRow(); + int column = arg0.getColumn(); + TableModel m = (TableModel)arg0.getSource(); + + if (column != forceDbgColForFpdModTable) { + return; + } + String s = m.getValueAt(row, column)+""; + boolean dbgEnable = new Boolean(s); + ffc.setModuleSAForceDebug(row, dbgEnable); + docConsole.setSaved(false); + } + } + + private void showSettingsDlg (int row) { + try { + if (ffc.adjustPcd(row)) { + docConsole.setSaved(false); + } + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + return; + } + + if (settingDlg == null) { + settingDlg = new FpdModuleSA(ffc); + } + + String[] sa = new String[5]; + ffc.getFrameworkModuleInfo(row, sa); + String mg = sa[ffcModGuid]; + String mv = sa[ffcModVer]; + String pg = sa[ffcPkgGuid]; + String pv = sa[ffcPkgVer]; + String arch = sa[ffcModArch]; + settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, row, docConsole); + settingDlg.setVisible(true); + } /** - * This method initializes jButton1 + * This method initializes jButtonSettings * - * @return javax.swing.JButton + * @return javax.swing.JButton jButtonSettings */ private JButton getJButtonSettings() { if (jButtonSettings == null) { @@ -435,30 +624,8 @@ public class FpdFrameworkModules extends IInternalFrame { } TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); - selectedRow = sorter.modelIndex(selectedRow); - try { - if (ffc.adjustPcd(selectedRow)) { - docConsole.setSaved(false); - } - } - catch (Exception exp) { - JOptionPane.showMessageDialog(frame, exp.getMessage()); - return; - } - - if (settingDlg == null) { - settingDlg = new FpdModuleSA(ffc); - } - - String[] sa = new String[5]; - ffc.getFrameworkModuleInfo(selectedRow, sa); - String mg = sa[ModNameCol]; - String mv = sa[ModVerCol]; - String pg = sa[PkgNameCol]; - String pv = sa[PkgVerCol]; - String arch = sa[ArchCol]; - settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole); - settingDlg.setVisible(true); + selectedRow = sorter.getModelRowIndex(selectedRow); + showSettingsDlg (selectedRow); } }); } @@ -466,9 +633,9 @@ public class FpdFrameworkModules extends IInternalFrame { } /** - * This method initializes jButton2 + * This method initializes jButtonRemoveModule * - * @return javax.swing.JButton + * @return javax.swing.JButton jButtonRemoveModule */ private JButton getJButtonRemoveModule() { if (jButtonRemoveModule == null) { @@ -481,36 +648,60 @@ public class FpdFrameworkModules extends IInternalFrame { if (selectedRow < 0) { return; } + TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); - selectedRow = sorter.modelIndex(selectedRow); + selectedRow = sorter.getModelRowIndex(selectedRow); String[] sa = new String[5]; ffc.getFrameworkModuleInfo(selectedRow, sa); - String mg = sa[ModNameCol]; - String mv = sa[ModVerCol]; - String pg = sa[PkgNameCol]; - String pv = sa[PkgVerCol]; - String arch = sa[ArchCol]; - ModuleIdentification mi = GlobalData.getModuleId(sa[ModNameCol] + " " + sa[ModVerCol] + " " - + sa[PkgNameCol] + " " + sa[PkgVerCol] + " " - + sa[ArchCol]); - mv = mi.getVersion(); - pv = mi.getPackage().getVersion(); - modelFpdModules.removeRow(selectedRow); + String mg = sa[ffcModGuid]; + String mv = sa[ffcModVer]; + String pg = sa[ffcPkgGuid]; + String pv = sa[ffcPkgVer]; + String arch = sa[ffcModArch]; + // + // sync. module order list in BuildOptions-UserExtensions. + // + String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch; + String fvBindings = ffc.getFvBinding(moduleKey); + if (fvBindings != null) { + String[] fvArray = fvBindings.split(" "); + for (int i = 0; i < fvArray.length; ++i) { + ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), mg, mv, pg, pv, arch); + } + } + + ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch); + if (mi != null) { + mv = mi.getVersion(); + pv = mi.getPackageId().getVersion(); + } + + try { + ffc.removeModuleSA(selectedRow); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getCause() + exp.getMessage()); + return; + } + if (arch == null) { // if no arch specified in ModuleSA fpdMsa.remove(mg + mv + pg + pv); + } else { ArrayList al = fpdMsa.get(mg + mv + pg + pv); - al.remove(arch); - if (al.size() == 0) { - fpdMsa.remove(mg + mv + pg + pv); + if (al != null) { + al.remove(arch); + if (al.size() == 0) { + fpdMsa.remove(mg + mv + pg + pv); + } } } - + + modelFpdModules.removeRow(selectedRow); docConsole.setSaved(false); - ffc.removeModuleSA(selectedRow); } }); } @@ -518,10 +709,11 @@ public class FpdFrameworkModules extends IInternalFrame { } /** + * * @param args */ public static void main(String[] args) { - // TODO Auto-generated method stub + // Set the pane visable new FpdFrameworkModules().setVisible(true); } @@ -545,12 +737,6 @@ public class FpdFrameworkModules extends IInternalFrame { } private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { - try { - GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE")); - } - catch(Exception e){ - JOptionPane.showMessageDialog(frame, "Error occurred when getting module data."); - } if (ffc == null) { ffc = new FpdFileContents(fpd); @@ -565,33 +751,44 @@ public class FpdFrameworkModules extends IInternalFrame { String[][] saa = new String[ffc.getFrameworkModulesCount()][5]; ffc.getFrameworkModulesInfo(saa); for (int i = 0; i < saa.length; ++i) { - ModuleIdentification mi = GlobalData.getModuleId(saa[i][ModNameCol] + " " + saa[i][ModVerCol] + " " - + saa[i][PkgNameCol] + " " + saa[i][PkgVerCol]); - String[] row = { "", "", "", "", "", "" }; + ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " " + + saa[i][ffcPkgGuid] + " " + saa[i][ffcPkgVer]); + Object[] row = { "", "", "", "", "", "", "", "" }; if (mi != null) { - row[ModNameCol] = mi.getName(); - row[ModVerCol] = mi.getVersion(); - row[PkgNameCol] = mi.getPackage().getName(); - row[PkgVerCol] = mi.getPackage().getVersion(); - row[ArchCol] = saa[i][ArchCol]; + row[modNameColForFpdModTable] = mi.getName(); + row[modVerColForFpdModTable] = mi.getVersion(); + row[typeColForFpdModTable] = SurfaceAreaQuery.getModuleType(mi); + row[pkgNameColForFpdModTable] = mi.getPackageId().getName(); + row[pkgVerColForFpdModTable] = mi.getPackageId().getVersion(); + row[archColForFpdModTable] = saa[i][ffcModArch]; try { - row[Path5Col] = GlobalData.getMsaFile(mi).getPath().substring( - System.getenv("WORKSPACE") - .length() + 1); + row[pathColForFpdModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); } catch (Exception e) { JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage()); } + + String fpdMsaKey = saa[i][ffcModGuid] + row[modVerColForFpdModTable] + + saa[i][ffcPkgGuid] + row[pkgVerColForFpdModTable]; + ArrayList al = fpdMsa.get(fpdMsaKey); + if (al == null) { + al = new ArrayList(); + fpdMsa.put(fpdMsaKey, al); + } + al.add(saa[i][ffcModArch]); } - modelFpdModules.addRow(row); - ArrayList al = fpdMsa.get(saa[i][ModNameCol] + row[ModVerCol] + saa[i][PkgNameCol] - + row[PkgVerCol]); - if (al == null) { - al = new ArrayList(); - fpdMsa.put(saa[i][ModNameCol] + row[ModVerCol] + saa[i][PkgNameCol] + row[PkgVerCol], al); + else { + row[modNameColForFpdModTable] = saa[i][ffcModGuid]; + row[modVerColForFpdModTable] = saa[i][ffcModVer]; + row[pkgNameColForFpdModTable] = saa[i][ffcPkgGuid]; + row[pkgVerColForFpdModTable] = saa[i][ffcPkgVer]; + row[archColForFpdModTable] = saa[i][ffcModArch]; } - al.add(saa[i][Path4Col]); + row[forceDbgColForFpdModTable] = ffc.getModuleSAForceDebug(i); + modelFpdModules.addRow(row); } + TableSorter sorter = (TableSorter)jTableFpdModules.getModel(); + sorter.setSortState(modNameColForFpdModTable, TableSorter.ASCENDING); } showAllModules(); @@ -603,31 +800,29 @@ public class FpdFrameworkModules extends IInternalFrame { if (miList == null) { miList = new ArrayList(); } - Set spi = GlobalData.getPackageList(); - Iterator ispi = spi.iterator(); - - while (ispi.hasNext()) { - PackageIdentification pi = (PackageIdentification) ispi.next(); - String[] s = { "", "", "", "", "" }; - Set smi = GlobalData.getModules(pi); - Iterator ismi = smi.iterator(); + String[] s = { "", "", "", "", "", "" }; + + Iterator ismi = GlobalData.vModuleList.iterator(); while (ismi.hasNext()) { ModuleIdentification mi = (ModuleIdentification) ismi.next(); - s[ModNameCol] = mi.getName(); - s[ModVerCol] = mi.getVersion(); - s[PkgNameCol] = pi.getName(); - s[PkgVerCol] = pi.getVersion(); + s[modNameColForAllModTable] = mi.getName(); + s[modVerColForAllModTable] = mi.getVersion(); + s[typeColForAllModTable] = SurfaceAreaQuery.getModuleType(mi); + s[pkgNameColForAllModTable] = mi.getPackageId().getName(); + s[pkgVerColForAllModTable] = mi.getPackageId().getVersion(); try { - s[Path4Col] = GlobalData.getMsaFile(mi).getPath() - .substring(System.getenv("WORKSPACE").length() + 1); + s[pathColForAllModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); } catch (Exception e) { JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage()); } modelAllModules.addRow(s); miList.add(mi); } - } + + + TableSorter sorter = (TableSorter)jTableAllModules.getModel(); + sorter.setSortState(modNameColForAllModTable, TableSorter.ASCENDING); } /** @@ -655,3 +850,25 @@ class NonEditableTableModel extends DefaultTableModel { return false; } } + +class FpdModulesTableModel extends DefaultTableModel { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public Class getColumnClass (int c) { + if (getValueAt(0, c) != null){ + return getValueAt(0, c).getClass(); + } + return String.class; + } + + public boolean isCellEditable (int row, int col) { + if (col == FpdFrameworkModules.forceDbgColForFpdModTable) { + return true; + } + return false; + } +}