mirror of https://github.com/acidanthera/audk.git
Add Fv option value edit support;
Give hover hint why some Fv options are not editable. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1874 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
4961f50cc4
commit
0cc00bf06b
|
@ -1531,7 +1531,10 @@ public class FpdFileContents {
|
||||||
if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {
|
if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {
|
||||||
|
|
||||||
if (getDynamicPcdBuildDataCount() == 1) {
|
if (getDynamicPcdBuildDataCount() == 1) {
|
||||||
cursor.toParent();
|
cursor.dispose();
|
||||||
|
removeElement(o);
|
||||||
|
fpdDynPcdBuildDefs = null;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
cursor.removeXml();
|
cursor.removeXml();
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
@ -1548,6 +1551,8 @@ public class FpdFileContents {
|
||||||
public int getDynamicPcdSkuInfoCount(int i){
|
public int getDynamicPcdSkuInfoCount(int i){
|
||||||
if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
|
if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null
|
||||||
|| fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
|
|| fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {
|
||||||
|
removeElement(getfpdDynPcdBuildDefs());
|
||||||
|
fpdDynPcdBuildDefs = null;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1716,9 +1721,11 @@ public class FpdFileContents {
|
||||||
|
|
||||||
public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
|
public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset,
|
||||||
String hiiDefault, String vpdOffset, String value, int i){
|
String hiiDefault, String vpdOffset, String value, int i){
|
||||||
// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
|
if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
|
||||||
// return;
|
removeElement(getfpdDynPcdBuildDefs());
|
||||||
// }
|
fpdDynPcdBuildDefs = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
|
XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();
|
||||||
if (cursor.toFirstChild()) {
|
if (cursor.toFirstChild()) {
|
||||||
|
@ -3278,32 +3285,31 @@ public class FpdFileContents {
|
||||||
* @param name
|
* @param name
|
||||||
* @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, String newName) {
|
||||||
boolean fvImageExists = false;
|
boolean fvImageExists = false;
|
||||||
if (getfpdFlash().getFvImages() == null) {
|
if (getfpdFlash().getFvImages() != null) {
|
||||||
return;
|
|
||||||
}
|
List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();
|
||||||
List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();
|
if (l != null) {
|
||||||
if (l == null) {
|
ListIterator li = l.listIterator();
|
||||||
return;
|
while (li.hasNext()) {
|
||||||
}
|
FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage) li.next();
|
||||||
ListIterator li = l.listIterator();
|
if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {
|
||||||
while(li.hasNext()) {
|
continue;
|
||||||
FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();
|
}
|
||||||
if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {
|
if (!fi.getFvImageNamesList().contains(fvName)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
fvImageExists = true;
|
||||||
|
setFvImagesFvImageNameValue(fi, name, value, newName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!fi.getFvImageNamesList().contains(fvName)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
fvImageExists = true;
|
|
||||||
setFvImagesFvImageNameValue (fi, name, value, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fvImageExists) {
|
if (!fvImageExists) {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
map.put(name, value);
|
map.put(name, value);
|
||||||
genFvImagesFvImage(new String[]{fvName}, type, map);
|
genFvImagesFvImage(new String[] { fvName }, type, map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3359,7 +3365,7 @@ public class FpdFileContents {
|
||||||
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue();
|
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.addNewFvImageOptions().addNewNameValue();
|
||||||
nv.setName(name);
|
nv.setName(name);
|
||||||
nv.setValue(value);
|
nv.setValue(value);
|
||||||
if (newName != null) {
|
if (newName != null && !newName.equals(name)) {
|
||||||
nv.setName(newName);
|
nv.setName(newName);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -3371,7 +3377,7 @@ public class FpdFileContents {
|
||||||
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();
|
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();
|
||||||
if (nv.getName().equals(name)) {
|
if (nv.getName().equals(name)) {
|
||||||
nv.setValue(value);
|
nv.setValue(value);
|
||||||
if (newName != null) {
|
if (newName != null && !newName.equals(name)) {
|
||||||
nv.setName(newName);
|
nv.setName(newName);
|
||||||
}
|
}
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
@ -3383,7 +3389,7 @@ public class FpdFileContents {
|
||||||
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();
|
FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();
|
||||||
nv.setName(name);
|
nv.setName(name);
|
||||||
nv.setValue(value);
|
nv.setValue(value);
|
||||||
if (newName != null) {
|
if (newName != null && !newName.equals(name)) {
|
||||||
nv.setName(newName);
|
nv.setName(newName);
|
||||||
}
|
}
|
||||||
cursor.dispose();
|
cursor.dispose();
|
||||||
|
|
|
@ -1055,9 +1055,16 @@ public class FpdFlash extends IInternalFrame {
|
||||||
jButtonFdfBrowse.setEnabled(true);
|
jButtonFdfBrowse.setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
getFvInFdfTableModel().setRowCount(0);
|
||||||
jTextFieldFdf.setEnabled(false);
|
jTextFieldFdf.setEnabled(false);
|
||||||
|
jTextFieldFdf.setText("");
|
||||||
jButtonFdfBrowse.setEnabled(false);
|
jButtonFdfBrowse.setEnabled(false);
|
||||||
|
ffc.genFlashDefinitionFile("");
|
||||||
|
docConsole.setSaved(false);
|
||||||
|
int selectedBackup = selectedRowInFvAdditionalTable;
|
||||||
|
selectedRowInFvAdditionalTable = -1;
|
||||||
|
initFvAdditionalTable();
|
||||||
|
selectedRowInFvAdditionalTable = selectedBackup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1194,9 +1201,16 @@ public class FpdFlash extends IInternalFrame {
|
||||||
determinedFvBlockSize = blkSize;
|
determinedFvBlockSize = blkSize;
|
||||||
|
|
||||||
getFvInFdfTableModel().setRowCount(0);
|
getFvInFdfTableModel().setRowCount(0);
|
||||||
|
Vector<String> vExistingFvNameInFpd = new Vector<String>();
|
||||||
|
ffc.getFvImagesFvImageFvImageNames(vExistingFvNameInFpd);
|
||||||
for (int j = 0; j < vFvInfo.size(); ++j) {
|
for (int j = 0; j < vFvInfo.size(); ++j) {
|
||||||
FvInfoFromFdf fvInfo = vFvInfo.get(j);
|
FvInfoFromFdf fvInfo = vFvInfo.get(j);
|
||||||
String[] row = {fvInfo.getFvName(), fvInfo.getSize(), fvInfo.getEfiFileName()};
|
String[] row = {fvInfo.getFvName(), fvInfo.getSize(), fvInfo.getEfiFileName()};
|
||||||
|
|
||||||
|
if (row[0].length() > 0 && !vExistingFvNameInFpd.contains(row[0])) {
|
||||||
|
ffc.addFvImageFvImageNames(new String[]{row[0]});
|
||||||
|
}
|
||||||
|
|
||||||
// if FV addtional table contains the same FV from fdf file, remove that row.
|
// if FV addtional table contains the same FV from fdf file, remove that row.
|
||||||
for (int k = 0; k < jTableFvAdditional.getRowCount(); ++k) {
|
for (int k = 0; k < jTableFvAdditional.getRowCount(); ++k) {
|
||||||
if (fvAdditionalTableModel.getValueAt(k, 0).equals(row[0])) {
|
if (fvAdditionalTableModel.getValueAt(k, 0).equals(row[0])) {
|
||||||
|
@ -1221,15 +1235,15 @@ public class FpdFlash extends IInternalFrame {
|
||||||
else {
|
else {
|
||||||
ffc.getFvImagesFvImageOptions(row[0], mOptions);
|
ffc.getFvImagesFvImageOptions(row[0], mOptions);
|
||||||
if (mOptions.get("EFI_BLOCK_SIZE") == null || !mOptions.get("EFI_BLOCK_SIZE").equalsIgnoreCase(blkSize)) {
|
if (mOptions.get("EFI_BLOCK_SIZE") == null || !mOptions.get("EFI_BLOCK_SIZE").equalsIgnoreCase(blkSize)) {
|
||||||
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_BLOCK_SIZE", blkSize);
|
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_BLOCK_SIZE", blkSize, null);
|
||||||
memModified = true;
|
memModified = true;
|
||||||
}
|
}
|
||||||
if (mOptions.get("EFI_NUM_BLOCKS") == null || Integer.decode(mOptions.get("EFI_NUM_BLOCKS")) != numBlocks) {
|
if (mOptions.get("EFI_NUM_BLOCKS") == null || Integer.decode(mOptions.get("EFI_NUM_BLOCKS")) != numBlocks) {
|
||||||
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_NUM_BLOCKS", numBlocks + "");
|
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_NUM_BLOCKS", numBlocks + "", null);
|
||||||
memModified = true;
|
memModified = true;
|
||||||
}
|
}
|
||||||
if (mOptions.get("EFI_FILE_NAME") == null || !mOptions.get("EFI_FILE_NAME").equals(row[2])) {
|
if (mOptions.get("EFI_FILE_NAME") == null || !mOptions.get("EFI_FILE_NAME").equals(row[2])) {
|
||||||
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_FILE_NAME", row[2]);
|
ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_FILE_NAME", row[2], null);
|
||||||
memModified = true;
|
memModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1810,20 +1824,20 @@ public class FpdFlash extends IInternalFrame {
|
||||||
else {
|
else {
|
||||||
blkSize = defaultBlkSize;
|
blkSize = defaultBlkSize;
|
||||||
}
|
}
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", blkSize);
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", blkSize, null);
|
||||||
int fs = Integer.decode(fvSize);
|
int fs = Integer.decode(fvSize);
|
||||||
int bs = Integer.decode(blkSize);
|
int bs = Integer.decode(blkSize);
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
|
||||||
docConsole.setSaved(false);
|
docConsole.setSaved(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {
|
if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {
|
||||||
int retVal = JOptionPane.showConfirmDialog(frame, "Confirm", "FPD file contains error block size format. Would you like to replace it with a default value?", JOptionPane.YES_NO_OPTION);
|
int retVal = JOptionPane.showConfirmDialog(frame, "Confirm", "FPD file contains error block size format. Would you like to replace it with a default value?", JOptionPane.YES_NO_OPTION);
|
||||||
if (retVal == JOptionPane.YES_OPTION) {
|
if (retVal == JOptionPane.YES_OPTION) {
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", defaultBlkSize);
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", defaultBlkSize, null);
|
||||||
int fs = Integer.decode(fvSize);
|
int fs = Integer.decode(fvSize);
|
||||||
int bs = Integer.decode(defaultBlkSize);
|
int bs = Integer.decode(defaultBlkSize);
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
|
||||||
docConsole.setSaved(false);
|
docConsole.setSaved(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1834,13 +1848,13 @@ public class FpdFlash extends IInternalFrame {
|
||||||
}
|
}
|
||||||
int fs = Integer.decode(fvSize);
|
int fs = Integer.decode(fvSize);
|
||||||
int bs = Integer.decode(blkSize);
|
int bs = Integer.decode(blkSize);
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
|
||||||
docConsole.setSaved(false);
|
docConsole.setSaved(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col == 2 && !fileFromOptionDlg) {
|
if (col == 2 && !fileFromOptionDlg) {
|
||||||
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_FILE_NAME", m.getValueAt(row, col)+"");
|
ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_FILE_NAME", m.getValueAt(row, col)+"", null);
|
||||||
docConsole.setSaved(false);
|
docConsole.setSaved(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2269,6 +2283,7 @@ public class FpdFlash extends IInternalFrame {
|
||||||
jTextFieldFdf.setText("");
|
jTextFieldFdf.setText("");
|
||||||
String fdfFile = ffc.getFlashDefinitionFile();
|
String fdfFile = ffc.getFlashDefinitionFile();
|
||||||
if (fdfFile != null && fdfFile.length() > 0) {
|
if (fdfFile != null && fdfFile.length() > 0) {
|
||||||
|
jCheckBoxFdf.setSelected(true);
|
||||||
jTextFieldFdf.setText(fdfFile);
|
jTextFieldFdf.setText(fdfFile);
|
||||||
String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;
|
String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;
|
||||||
initFvInFdfTable(fdfPath);
|
initFvInFdfTable(fdfPath);
|
||||||
|
@ -3181,6 +3196,7 @@ class FvOptsTableModel extends DefaultTableModel {
|
||||||
private Vector<Object> vKeyWords = new Vector<Object>();
|
private Vector<Object> vKeyWords = new Vector<Object>();
|
||||||
|
|
||||||
public boolean isCellEditable(int row, int col) {
|
public boolean isCellEditable(int row, int col) {
|
||||||
|
|
||||||
if (vNonEditableName.size() > 0 || vKeyWords.size() > 0) {
|
if (vNonEditableName.size() > 0 || vKeyWords.size() > 0) {
|
||||||
if (vKeyWords.contains(getValueAt(row, 0))) {
|
if (vKeyWords.contains(getValueAt(row, 0))) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3190,6 +3206,10 @@ class FvOptsTableModel extends DefaultTableModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (col == 0 && getValueAt(row, 0) != null && getValueAt(row, 0).toString().length() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,21 @@ package org.tianocore.frameworkwizard.platform.ui;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.util.HashMap;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.TableModelEvent;
|
import javax.swing.event.TableModelEvent;
|
||||||
import javax.swing.event.TableModelListener;
|
import javax.swing.event.TableModelListener;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
@ -41,6 +48,7 @@ public class FpdFvOptions extends JDialog {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static JFrame frame;
|
||||||
private JPanel jContentPane = null;
|
private JPanel jContentPane = null;
|
||||||
private JPanel jPanelN = null;
|
private JPanel jPanelN = null;
|
||||||
private JPanel jPanelS = null;
|
private JPanel jPanelS = null;
|
||||||
|
@ -53,6 +61,9 @@ public class FpdFvOptions extends JDialog {
|
||||||
private OpeningPlatformType docConsole = null;
|
private OpeningPlatformType docConsole = null;
|
||||||
private JButton jButtonNew = null;
|
private JButton jButtonNew = null;
|
||||||
private JButton jButtonDelete = null;
|
private JButton jButtonDelete = null;
|
||||||
|
private String oldOptionName = "";
|
||||||
|
private int selectedRow = -1;
|
||||||
|
private TableModelListener tableModelListener = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the default constructor
|
* This is the default constructor
|
||||||
|
@ -68,9 +79,19 @@ public class FpdFvOptions extends JDialog {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void processWindowEvent (WindowEvent e) {
|
||||||
|
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||||
|
if (jTableFvOptions.isEditing()) {
|
||||||
|
jTableFvOptions.getCellEditor().stopCellEditing();
|
||||||
|
}
|
||||||
|
tableModel.removeTableModelListener(tableModelListener);
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initOptions() {
|
private void initOptions() {
|
||||||
tableModel.setRowCount(0);
|
tableModel.setRowCount(0);
|
||||||
HashMap<String, String> mOpts = new HashMap<String, String>();
|
LinkedHashMap<String, String> mOpts = new LinkedHashMap<String, String>();
|
||||||
ffc.getFvImagesFvImageOptions(fvName, mOpts);
|
ffc.getFvImagesFvImageOptions(fvName, mOpts);
|
||||||
Set<String> sKey = mOpts.keySet();
|
Set<String> sKey = mOpts.keySet();
|
||||||
Iterator<String> iter = sKey.iterator();
|
Iterator<String> iter = sKey.iterator();
|
||||||
|
@ -80,6 +101,19 @@ public class FpdFvOptions extends JDialog {
|
||||||
tableModel.addRow(new String[]{name, value});
|
tableModel.addRow(new String[]{name, value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean fvOptionNameExists (String name) {
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < jTableFvOptions.getRowCount(); ++i) {
|
||||||
|
if (getTableModel().getValueAt(i, 0).equals(name)) {
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count > 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This method initializes this
|
* This method initializes this
|
||||||
*
|
*
|
||||||
|
@ -87,12 +121,13 @@ public class FpdFvOptions extends JDialog {
|
||||||
*/
|
*/
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
this.setSize(650, 400);
|
this.setSize(650, 400);
|
||||||
this.setModal(true);
|
// this.setModal(true);
|
||||||
this.setTitle("FV Options");
|
this.setTitle("FV Options");
|
||||||
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
|
||||||
this.setContentPane(getJContentPane());
|
this.setContentPane(getJContentPane());
|
||||||
this.centerWindow();
|
this.centerWindow();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,26 +206,81 @@ public class FpdFvOptions extends JDialog {
|
||||||
*/
|
*/
|
||||||
private JTable getJTableFvOptions() {
|
private JTable getJTableFvOptions() {
|
||||||
if (jTableFvOptions == null) {
|
if (jTableFvOptions == null) {
|
||||||
jTableFvOptions = new JTable();
|
jTableFvOptions = new JTable(getTableModel()) {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -1941328952828651192L;
|
||||||
|
|
||||||
|
public String getToolTipText(MouseEvent e) {
|
||||||
|
String tip = null;
|
||||||
|
java.awt.Point p = e.getPoint();
|
||||||
|
int rowIndex = rowAtPoint(p);
|
||||||
|
// int colIndex = columnAtPoint(p);
|
||||||
|
// int realColumnIndex = convertColumnIndexToModel(colIndex);
|
||||||
|
|
||||||
|
TableModel model = getModel();
|
||||||
|
String optName = (String) model.getValueAt(rowIndex, 0);
|
||||||
|
if (((FvOptsTableModel)model).getVKeyWords().contains(optName)){
|
||||||
|
tip = optName + " is from Flash Definition File and it is NOT editable.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return tip;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
jTableFvOptions.setRowHeight(20);
|
jTableFvOptions.setRowHeight(20);
|
||||||
jTableFvOptions.setModel(getTableModel());
|
|
||||||
|
|
||||||
jTableFvOptions.getModel().addTableModelListener(new TableModelListener() {
|
jTableFvOptions.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||||
public void tableChanged(TableModelEvent arg0) {
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
// TODO Auto-generated method stub
|
if (e.getValueIsAdjusting()) {
|
||||||
int row = arg0.getFirstRow();
|
return;
|
||||||
// int col = arg0.getColumn();
|
}
|
||||||
TableModel m = (TableModel) arg0.getSource();
|
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
|
||||||
|
if (lsm.isSelectionEmpty()) {
|
||||||
if (arg0.getType() == TableModelEvent.UPDATE) {
|
return;
|
||||||
if (m.getValueAt(row, 0).equals("")) {
|
} else {
|
||||||
return;
|
selectedRow = lsm.getMinSelectionIndex();
|
||||||
}
|
oldOptionName = getTableModel().getValueAt(selectedRow, 0)+"";
|
||||||
ffc.setTypedNamedFvImageNameValue(fvName, "Options", m.getValueAt(row, 0)+"", m.getValueAt(row, 1)+"");
|
|
||||||
docConsole.setSaved(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tableModelListener = 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) {
|
||||||
|
String newOptionName = m.getValueAt(row, 0) + "";
|
||||||
|
if (col == 0) {
|
||||||
|
if (newOptionName.equals(oldOptionName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fvOptionNameExists(newOptionName)) {
|
||||||
|
JOptionPane.showMessageDialog(frame, "This Option already exists. Please choose another Option name.");
|
||||||
|
m.setValueAt(oldOptionName, row, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ffc.setTypedNamedFvImageNameValue(fvName, "Options", oldOptionName, m.getValueAt(row, 1)+"", newOptionName);
|
||||||
|
docConsole.setSaved(false);
|
||||||
|
oldOptionName = newOptionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (col == 1) {
|
||||||
|
ffc.setTypedNamedFvImageNameValue(fvName, "Options", oldOptionName, m.getValueAt(row, 1)+"", newOptionName);
|
||||||
|
docConsole.setSaved(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
jTableFvOptions.getModel().addTableModelListener(tableModelListener);
|
||||||
}
|
}
|
||||||
return jTableFvOptions;
|
return jTableFvOptions;
|
||||||
}
|
}
|
||||||
|
@ -235,6 +325,7 @@ private JButton getJButtonNew() {
|
||||||
jButtonNew.addActionListener(new java.awt.event.ActionListener() {
|
jButtonNew.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent e) {
|
public void actionPerformed(java.awt.event.ActionEvent e) {
|
||||||
tableModel.addRow(new String[]{"", ""});
|
tableModel.addRow(new String[]{"", ""});
|
||||||
|
oldOptionName = "";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue