diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java index 20b5c10568..c80d758f28 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -2847,6 +2847,22 @@ public class FpdFileContents { } } + public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) { + Vector vFvImage = getFvImagesFvImageWithName(fvName, type); + for (int i = 0; i < vFvImage.size(); ++i) { + FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i); + if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) { + ListIterator li = fi.getFvImageOptions().getNameValueList().listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next(); + if (nv.getName().equals(optName)) { + li.remove(); + } + } + } + } + } + /**Add name-value pair to FvImage element with type. * @param fvName FV name to add name-value pair. * @param type FvImage attribute. @@ -2854,6 +2870,7 @@ public class FpdFileContents { * @param value */ public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) { + boolean fvImageExists = false; if (getfpdFlash().getFvImages() == null) { return; } @@ -2870,8 +2887,15 @@ public class FpdFileContents { if (!fi.getFvImageNamesList().contains(fvName)) { continue; } + fvImageExists = true; setFvImagesFvImageNameValue (fi, name, value, null); } + + if (!fvImageExists) { + HashMap map = new HashMap(); + map.put(name, value); + genFvImagesFvImage(new String[]{fvName}, type, map); + } } /**Add to all FvImage elements with type, the name-value pair. @@ -2895,6 +2919,7 @@ public class FpdFileContents { } setFvImagesFvImageNameValue (fi, name, value, null); } + } /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before. diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java index 74999ef5ec..ee419d5d0b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java @@ -162,7 +162,8 @@ public class FpdFlash extends IInternalFrame { private String determinedFvBlockSize = null; private String erasePolarity = ""; boolean memModified = false; - + private FvOptsTableModel fvInFdfOptTableModel = null; + private FvOptsTableModel fvAdditionalOptTableModel = null; public FpdFlash() { super(); @@ -1171,7 +1172,7 @@ public class FpdFlash extends IInternalFrame { if (blockSizeWellFormat && numOfBlockWellFormat) { int size = Integer.decode(bSize); int num = Integer.decode(numBlks); - fvSize = size*num + ""; + fvSize = "0x" + Integer.toHexString(size*num); } } fvAdditionalTableModel.addRow(new String[]{fvName, fvSize, fvFile}); @@ -1659,7 +1660,7 @@ public class FpdFlash extends IInternalFrame { if (jButtonFvInFdfOptions == null) { jButtonFvInFdfOptions = new JButton(); jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20)); - jButtonFvInFdfOptions.setEnabled(false); + jButtonFvInFdfOptions.setEnabled(true); jButtonFvInFdfOptions.setText("Options"); jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { @@ -1667,11 +1668,29 @@ public class FpdFlash extends IInternalFrame { if (selectedRow < 0) { return; } + String fvName = jTableFvInFdf.getValueAt(selectedRow, 0)+""; + DefaultTableModel dtm = getFvInFdfOptTableModel(); + new FpdFvOptions(fvName, dtm, ffc, docConsole); } }); } return jButtonFvInFdfOptions; } + + private DefaultTableModel getFvInFdfOptTableModel() { + if (fvInFdfOptTableModel == null) { + fvInFdfOptTableModel = new FvOptsTableModel(); + fvInFdfOptTableModel.addColumn("Name"); + fvInFdfOptTableModel.addColumn("Value"); + Vector v = new Vector(); + v.add("EFI_BLOCK_SIZE"); + v.add("EFI_NUM_BLOCKS"); + v.add("EFI_FILE_NAME"); + fvInFdfOptTableModel.setVKeyWords(v); + fvInFdfOptTableModel.setVNonEditableName(v); + } + return fvInFdfOptTableModel; + } /** * This method initializes jScrollPaneFvAdditional @@ -1910,7 +1929,7 @@ public class FpdFlash extends IInternalFrame { if (jButtonAddFvOptions == null) { jButtonAddFvOptions = new JButton(); jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20)); - jButtonAddFvOptions.setEnabled(false); + jButtonAddFvOptions.setEnabled(true); jButtonAddFvOptions.setText("Options"); jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { @@ -2594,6 +2613,57 @@ public class FpdFlash extends IInternalFrame { } // @jve:decl-index=0:visual-constraint="10,10" +class FvOptsTableModel extends DefaultTableModel { + + private static final long serialVersionUID = 1L; + + private Vector vNonEditableName = new Vector(); + private Vector vKeyWords = new Vector(); + + public boolean isCellEditable(int row, int col) { + if (vNonEditableName.size() > 0 || vKeyWords.size() > 0) { + if (vKeyWords.contains(getValueAt(row, 0))) { + return false; + } + if (vNonEditableName.contains(getValueAt(row, 0)) && col == 0) { + return false; + } + } + + return true; + } + + /** + * @return Returns the vKeyWords. + */ + protected Vector getVKeyWords() { + return vKeyWords; + } + + /** + * @param keyWords The vKeyWords to set. + */ + protected void setVKeyWords(Vector keyWords) { + vKeyWords.removeAllElements(); + vKeyWords.addAll(keyWords); + } + + /** + * @return Returns the vNonEditableName. + */ + protected Vector getVNonEditableName() { + return vNonEditableName; + } + + /** + * @param nonEditableName The vNonEditableName to set. + */ + protected void setVNonEditableName(Vector nonEditableName) { + vNonEditableName.removeAllElements(); + vNonEditableName.addAll(nonEditableName); + } + +} class ImageParaTableModel extends DefaultTableModel { private static final long serialVersionUID = 1L; diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFvOptions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFvOptions.java new file mode 100644 index 0000000000..b09394127d --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFvOptions.java @@ -0,0 +1,269 @@ +/** @file + Java class FpdFvOptions is GUI for FV options in 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; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +import javax.swing.JPanel; +import javax.swing.JDialog; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.JButton; + +import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; + +/** + * + * + */ +public class FpdFvOptions extends JDialog { + + private JPanel jContentPane = null; + private JPanel jPanelN = null; + private JPanel jPanelS = null; + private JPanel jPanelC = null; + private JScrollPane jScrollPaneFvOptions = null; + private JTable jTableFvOptions = null; + private DefaultTableModel tableModel = null; + private String fvName = null; + private FpdFileContents ffc = null; + private OpeningPlatformType docConsole = null; + private JButton jButtonNew = null; + private JButton jButtonDelete = null; + + /** + * This is the default constructor + */ + public FpdFvOptions(String name, DefaultTableModel tm, FpdFileContents ffc, OpeningPlatformType dc) { + super(); + fvName = name; + this.ffc = ffc; + this.docConsole = dc; + setTableModel(tm); + initOptions(); + initialize(); + + } + + private void initOptions() { + tableModel.setRowCount(0); + HashMap mOpts = new HashMap(); + ffc.getFvImagesFvImageOptions(fvName, mOpts); + Set sKey = mOpts.keySet(); + Iterator iter = sKey.iterator(); + while (iter.hasNext()) { + String name = iter.next(); + String value = mOpts.get(name); + tableModel.addRow(new String[]{name, value}); + } + } + /** + * This method initializes this + * + * @return void + */ + private void initialize() { + this.setSize(650, 400); + this.setModal(true); + this.setTitle("FV Options"); + this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + this.setContentPane(getJContentPane()); + this.centerWindow(); + this.setVisible(true); + } + + /** + * This method initializes jContentPane + * + * @return javax.swing.JPanel + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jContentPane = new JPanel(); + jContentPane.setLayout(new BorderLayout()); + jContentPane.add(getJPanelN(), java.awt.BorderLayout.NORTH); + jContentPane.add(getJPanelS(), java.awt.BorderLayout.SOUTH); + jContentPane.add(getJPanelC(), java.awt.BorderLayout.CENTER); + } + return jContentPane; + } + + /** + * This method initializes jPanelN + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelN() { + if (jPanelN == null) { + jPanelN = new JPanel(); + } + return jPanelN; + } + + /** + * This method initializes jPanelS + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelS() { + if (jPanelS == null) { + jPanelS = new JPanel(); + jPanelS.add(getJButtonNew(), null); + jPanelS.add(getJButtonDelete(), null); + } + return jPanelS; + } + + /** + * This method initializes jPanelC + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelC() { + if (jPanelC == null) { + jPanelC = new JPanel(); + jPanelC.add(getJScrollPaneFvOptions(), null); + } + return jPanelC; + } + + /** + * This method initializes jScrollPaneFvOptions + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPaneFvOptions() { + if (jScrollPaneFvOptions == null) { + jScrollPaneFvOptions = new JScrollPane(); + jScrollPaneFvOptions.setPreferredSize(new java.awt.Dimension(600,320)); + jScrollPaneFvOptions.setViewportView(getJTableFvOptions()); + } + return jScrollPaneFvOptions; + } + + /** + * This method initializes jTableFvOptions + * + * @return javax.swing.JTable + */ + private JTable getJTableFvOptions() { + if (jTableFvOptions == null) { + jTableFvOptions = new JTable(); + jTableFvOptions.setRowHeight(20); + jTableFvOptions.setModel(getTableModel()); + + jTableFvOptions.getModel().addTableModelListener(new TableModelListener() { + public void tableChanged(TableModelEvent arg0) { + // TODO Auto-generated method stub + int row = arg0.getFirstRow(); + int col = arg0.getColumn(); + TableModel m = (TableModel) arg0.getSource(); + + if (arg0.getType() == TableModelEvent.UPDATE) { + if (m.getValueAt(row, 0).equals("")) { + return; + } + ffc.setTypedNamedFvImageNameValue(fvName, "Options", m.getValueAt(row, 0)+"", m.getValueAt(row, 1)+""); + docConsole.setSaved(false); + } + } + }); + } + return jTableFvOptions; + } + + protected DefaultTableModel getTableModel() { + return tableModel; + } + + protected void setTableModel(DefaultTableModel tableModel) { + + this.tableModel = tableModel; + + } + + /** + Start the window at the center of screen + + **/ + protected void centerWindow(int intWidth, int intHeight) { + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); + } + + /** + Start the window at the center of screen + + **/ + protected void centerWindow() { + centerWindow(this.getSize().width, this.getSize().height); + } + +/** + * This method initializes jButtonNew + * + * @return javax.swing.JButton + */ +private JButton getJButtonNew() { + if (jButtonNew == null) { + jButtonNew = new JButton(); + jButtonNew.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonNew.setText("New"); + jButtonNew.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + tableModel.addRow(new String[]{"", ""}); + } + }); + } + return jButtonNew; +} + +/** + * This method initializes jButtonDelete + * + * @return javax.swing.JButton + */ +private JButton getJButtonDelete() { + if (jButtonDelete == null) { + jButtonDelete = new JButton(); + jButtonDelete.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonDelete.setText("Delete"); + jButtonDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + int selectedRow = jTableFvOptions.getSelectedRow(); + if (selectedRow < 0) { + return; + } + String optName = tableModel.getValueAt(selectedRow, 0)+""; + if (((FvOptsTableModel)tableModel).getVKeyWords().contains(optName)){ + return; + } + + ffc.removeTypedNamedFvImageNameValue(fvName, "Options", optName); + tableModel.removeRow(selectedRow); + docConsole.setSaved(false); + } + }); + } + return jButtonDelete; +} +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java index 14fd02499f..44cead811a 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java @@ -440,6 +440,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { */ private void initialize() { this.setSize(664, 515); + this.setResizable(false); this.centerWindow(); this.setModal(true); this.setTitle("Module Settings");