FV from FDF file options editor.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1483 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-09-06 09:28:47 +00:00
parent e8a3bee036
commit b411fc1f31
4 changed files with 369 additions and 4 deletions

View File

@ -2847,6 +2847,22 @@ public class FpdFileContents {
} }
} }
public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) {
Vector<FvImagesDocument.FvImages.FvImage> 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<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> 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. /**Add name-value pair to FvImage element with type.
* @param fvName FV name to add name-value pair. * @param fvName FV name to add name-value pair.
* @param type FvImage attribute. * @param type FvImage attribute.
@ -2854,6 +2870,7 @@ public class FpdFileContents {
* @param value * @param value
*/ */
public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) { public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {
boolean fvImageExists = false;
if (getfpdFlash().getFvImages() == null) { if (getfpdFlash().getFvImages() == null) {
return; return;
} }
@ -2870,8 +2887,15 @@ public class FpdFileContents {
if (!fi.getFvImageNamesList().contains(fvName)) { if (!fi.getFvImageNamesList().contains(fvName)) {
continue; continue;
} }
fvImageExists = true;
setFvImagesFvImageNameValue (fi, name, value, null); setFvImagesFvImageNameValue (fi, name, value, null);
} }
if (!fvImageExists) {
HashMap<String, String> map = new HashMap<String, String>();
map.put(name, value);
genFvImagesFvImage(new String[]{fvName}, type, map);
}
} }
/**Add to all FvImage elements with type, the name-value pair. /**Add to all FvImage elements with type, the name-value pair.
@ -2895,6 +2919,7 @@ public class FpdFileContents {
} }
setFvImagesFvImageNameValue (fi, name, value, null); 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. /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.

View File

@ -162,7 +162,8 @@ public class FpdFlash extends IInternalFrame {
private String determinedFvBlockSize = null; private String determinedFvBlockSize = null;
private String erasePolarity = ""; private String erasePolarity = "";
boolean memModified = false; boolean memModified = false;
private FvOptsTableModel fvInFdfOptTableModel = null;
private FvOptsTableModel fvAdditionalOptTableModel = null;
public FpdFlash() { public FpdFlash() {
super(); super();
@ -1171,7 +1172,7 @@ public class FpdFlash extends IInternalFrame {
if (blockSizeWellFormat && numOfBlockWellFormat) { if (blockSizeWellFormat && numOfBlockWellFormat) {
int size = Integer.decode(bSize); int size = Integer.decode(bSize);
int num = Integer.decode(numBlks); int num = Integer.decode(numBlks);
fvSize = size*num + ""; fvSize = "0x" + Integer.toHexString(size*num);
} }
} }
fvAdditionalTableModel.addRow(new String[]{fvName, fvSize, fvFile}); fvAdditionalTableModel.addRow(new String[]{fvName, fvSize, fvFile});
@ -1659,7 +1660,7 @@ public class FpdFlash extends IInternalFrame {
if (jButtonFvInFdfOptions == null) { if (jButtonFvInFdfOptions == null) {
jButtonFvInFdfOptions = new JButton(); jButtonFvInFdfOptions = new JButton();
jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20)); jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20));
jButtonFvInFdfOptions.setEnabled(false); jButtonFvInFdfOptions.setEnabled(true);
jButtonFvInFdfOptions.setText("Options"); jButtonFvInFdfOptions.setText("Options");
jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() { jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) { public void actionPerformed(java.awt.event.ActionEvent e) {
@ -1667,11 +1668,29 @@ public class FpdFlash extends IInternalFrame {
if (selectedRow < 0) { if (selectedRow < 0) {
return; return;
} }
String fvName = jTableFvInFdf.getValueAt(selectedRow, 0)+"";
DefaultTableModel dtm = getFvInFdfOptTableModel();
new FpdFvOptions(fvName, dtm, ffc, docConsole);
} }
}); });
} }
return jButtonFvInFdfOptions; return jButtonFvInFdfOptions;
} }
private DefaultTableModel getFvInFdfOptTableModel() {
if (fvInFdfOptTableModel == null) {
fvInFdfOptTableModel = new FvOptsTableModel();
fvInFdfOptTableModel.addColumn("Name");
fvInFdfOptTableModel.addColumn("Value");
Vector<Object> v = new Vector<Object>();
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 * This method initializes jScrollPaneFvAdditional
@ -1910,7 +1929,7 @@ public class FpdFlash extends IInternalFrame {
if (jButtonAddFvOptions == null) { if (jButtonAddFvOptions == null) {
jButtonAddFvOptions = new JButton(); jButtonAddFvOptions = new JButton();
jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20)); jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20));
jButtonAddFvOptions.setEnabled(false); jButtonAddFvOptions.setEnabled(true);
jButtonAddFvOptions.setText("Options"); jButtonAddFvOptions.setText("Options");
jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() { jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) { 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" } // @jve:decl-index=0:visual-constraint="10,10"
class FvOptsTableModel extends DefaultTableModel {
private static final long serialVersionUID = 1L;
private Vector<Object> vNonEditableName = new Vector<Object>();
private Vector<Object> vKeyWords = new Vector<Object>();
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<Object> getVKeyWords() {
return vKeyWords;
}
/**
* @param keyWords The vKeyWords to set.
*/
protected void setVKeyWords(Vector<Object> keyWords) {
vKeyWords.removeAllElements();
vKeyWords.addAll(keyWords);
}
/**
* @return Returns the vNonEditableName.
*/
protected Vector<Object> getVNonEditableName() {
return vNonEditableName;
}
/**
* @param nonEditableName The vNonEditableName to set.
*/
protected void setVNonEditableName(Vector<Object> nonEditableName) {
vNonEditableName.removeAllElements();
vNonEditableName.addAll(nonEditableName);
}
}
class ImageParaTableModel extends DefaultTableModel { class ImageParaTableModel extends DefaultTableModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -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<String, String> mOpts = new HashMap<String, String>();
ffc.getFvImagesFvImageOptions(fvName, mOpts);
Set<String> sKey = mOpts.keySet();
Iterator<String> 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;
}
}

View File

@ -440,6 +440,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
*/ */
private void initialize() { private void initialize() {
this.setSize(664, 515); this.setSize(664, 515);
this.setResizable(false);
this.centerWindow(); this.centerWindow();
this.setModal(true); this.setModal(true);
this.setTitle("Module Settings"); this.setTitle("Module Settings");