Flash UI add new FV feature. modify FvImageNames and FvBindings in fpd file if FV name changes.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1416 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-08-31 10:34:14 +00:00
parent 0719317158
commit eb8ea8292e
2 changed files with 273 additions and 45 deletions

View File

@ -746,11 +746,15 @@ public class FpdFileContents {
}
public String getFvBinding(String moduleKey){
ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);
if (msa == null || msa.getModuleSaBuildOptions() == null) {
ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);
return getFvBinding (moduleSa);
}
public String getFvBinding (ModuleSADocument.ModuleSA moduleSa) {
if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {
return null;
}
return msa.getModuleSaBuildOptions().getFvBinding();
return moduleSa.getModuleSaBuildOptions().getFvBinding();
}
public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {
@ -776,6 +780,23 @@ public class FpdFileContents {
setFvBinding (moduleSa, fvBinding);
}
private int fvBindingForModuleSA (ModuleSADocument.ModuleSA moduleSa, String fvName) {
if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {
return -1;
}
String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();
String[] fvNamesArray = fvNameList.split(" ");
int occursAt = -1;
for (int i = 0; i < fvNamesArray.length; ++i) {
if (fvNamesArray[i].equals(fvName)) {
occursAt = i;
break;
}
}
return occursAt;
}
public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {
if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {
return;
@ -821,6 +842,37 @@ public class FpdFileContents {
}
}
public void appendFvBindingAll (String fvName) {
if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
removeElement(getfpdFrameworkModules());
fpdFrameworkModules = null;
return;
}
Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();
while (li.hasNext()) {
ModuleSADocument.ModuleSA moduleSa = li.next();
appendFvBinding (moduleSa, fvName);
}
}
public void appendFvBindingFor (String oldFvName, String newFvName) {
if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){
removeElement(getfpdFrameworkModules());
fpdFrameworkModules = null;
return;
}
Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();
while (li.hasNext()) {
ModuleSADocument.ModuleSA moduleSa = li.next();
String fvBinding = getFvBinding (moduleSa);
if (fvBinding != null && fvBindingForModuleSA (moduleSa, oldFvName) >= 0) {
appendFvBinding (moduleSa, newFvName);
}
}
}
public void appendFvBinding (String moduleKey, String fvName) {
ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);
appendFvBinding (moduleSa, fvName);
@ -1602,23 +1654,28 @@ public class FpdFileContents {
}
public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName elementInfFileName = new QName(xmlNs, "InfFileName");
QName elementModule = new QName(xmlNs, "Module");
UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();
userExts.setUserID("IMAGES");
userExts.setIdentifier(new BigInteger("1"));
XmlCursor cursor = userExts.newCursor();
cursor.toEndToken();
cursor.beginElement("FvName");
cursor.beginElement(elementFvName);
cursor.insertChars(fvName);
cursor.toNextToken();
cursor.beginElement("InfFileName");
cursor.beginElement(elementInfFileName);
cursor.insertChars(fvName + ".inf");
cursor.toNextToken();
cursor.beginElement("IncludeModules");
cursor.beginElement(elementIncludeModules);
for (int i = 0; i < includeModules.size(); ++i) {
cursor.beginElement("Module");
cursor.beginElement(elementModule);
cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);
cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);
cursor.toEndToken();
@ -1632,6 +1689,7 @@ public class FpdFileContents {
return -1;
}
ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
while (li.hasNext()) {
UserExtensionsDocument.UserExtensions ues = li.next();
if (!ues.getUserID().equals("IMAGES")) {
@ -1641,7 +1699,7 @@ public class FpdFileContents {
cursor.toFirstChild();
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
cursor.toNextSibling(new QName("", "IncludeModules"));
cursor.toNextSibling(elementIncludeModules);
if (cursor.toFirstChild()) {
int i = 1;
for (i = 1; cursor.toNextSibling(); ++i);
@ -1660,6 +1718,45 @@ public class FpdFileContents {
if (getfpdBuildOpts().getUserExtensionsList() == null) {
return;
}
XmlCursor cursor = getfpdBuildOpts().newCursor();
QName elementUserExts = new QName (xmlNs, "UserExtensions");
QName attribUserId = new QName ("UserID");
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName attribModuleGuid = new QName("ModuleGuid");
QName attribBaseName = new QName("BaseName");
if (cursor.toChild(elementUserExts)) {
do {
cursor.push();
if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {
cursor.toChild(elementFvName);
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
cursor.toNextSibling(elementIncludeModules);
if (cursor.toFirstChild()) {
int i = 0;
do {
saa[i][0] = cursor.getAttributeText(attribModuleGuid);
saa[i][1] = cursor.getAttributeText(attribBaseName);
++i;
}while (cursor.toNextSibling());
}
break;
}
}
cursor.pop();
}while (cursor.toNextSibling(elementUserExts));
}
cursor.dispose();
}
public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) {
if (getfpdBuildOpts().getUserExtensionsList() == null) {
return;
}
ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
while (li.hasNext()) {
UserExtensionsDocument.UserExtensions ues = li.next();
@ -1669,18 +1766,8 @@ public class FpdFileContents {
XmlCursor cursor = ues.newCursor();
cursor.toFirstChild();
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
cursor.toNextSibling(new QName("", "IncludeModules"));
if (cursor.toFirstChild()) {
int i = 0;
do {
saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid"));
saa[i][1] = cursor.getAttributeText(new QName("BaseName"));
++i;
}while (cursor.toNextSibling());
}
cursor.dispose();
return;
if (elementName.equals(oldFvName)) {
cursor.setTextValue(newFvName);
}
cursor.dispose();
}
@ -2501,6 +2588,31 @@ public class FpdFileContents {
}
}
public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {
}
public void AddFvImageFvImageNames (String[] fvNames) {
FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();
if (fis == null || fis.getFvImageList() == null) {
genFvImagesFvImage (fvNames, "ImageName", null);
return;
}
ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();
while (li.hasNext()) {
FvImagesDocument.FvImages.FvImage fi = li.next();
if (fi.getType().toString().equals("ImageName")) {
for (int i = 0; i < fvNames.length; ++i) {
fi.addFvImageNames(fvNames[i]);
}
return;
}
}
genFvImagesFvImage (fvNames, "ImageName", null);
}
public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {
FvImagesDocument.FvImages fis = null;
@ -2560,6 +2672,32 @@ public class FpdFileContents {
cursor.dispose();
}
public void updateFvImageNameAll (String oldFvName, String newFvName) {
if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
return;
}
ListIterator<FvImagesDocument.FvImages.FvImage> li = getfpdFlash().getFvImages().getFvImageList().listIterator();
while (li.hasNext()) {
FvImagesDocument.FvImages.FvImage fi = li.next();
updateFvImageNamesInFvImage (fi, oldFvName, newFvName);
}
}
public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) {
QName qFvImageNames = new QName(xmlNs, "FvImageNames");
XmlCursor cursor = fi.newCursor();
if (cursor.toChild(qFvImageNames)) {
do {
if (cursor.getTextValue().equals(oldFvName)){
cursor.setTextValue(newFvName);
}
}while (cursor.toNextSibling(qFvImageNames));
}
cursor.dispose();
}
public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){
XmlObject o = getfpdFlash().getFvImages();

View File

@ -75,6 +75,7 @@ public class FpdFlash extends IInternalFrame {
*
*/
private static final long serialVersionUID = 1L;
private final int startIndexOfDynamicTab = 2;
static JFrame frame;
private JPanel jContentPane = null;
private JPanel jPanelContentEast = null;
@ -155,6 +156,9 @@ public class FpdFlash extends IInternalFrame {
private JButton jButtonAddFv = null;
private JButton jButtonDelFv = null;
private JButton jButtonAddFvOptions = null;
private int tabIndexForFv = -1;
private int selectedRowInFvAdditionalTable = -1;
private String oldFvName = null;
public FpdFlash() {
@ -258,6 +262,30 @@ public class FpdFlash extends IInternalFrame {
// jPanelFvImages.add(getJPanelFvImageW(), java.awt.BorderLayout.WEST);
jPanelFvImages.add(getJPanelFvImageS(), java.awt.BorderLayout.SOUTH);
jPanelFvImages.add(getJPanelFvImageC(), java.awt.BorderLayout.CENTER);
jPanelFvImages.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent e) {
fvImageParaTableModel.setRowCount(0);
fvPropertyTableModel.setRowCount(0);
if (ffc.getFvImagesFvImageCount() == 0) {
return;
}
String[][] saa = new String[ffc.getFvImagesFvImageCount()][2];
ffc.getFvImagesFvImages(saa);
int i = 0;
while (i < saa.length) {
fvImageParaTableModel.addRow(saa[i]);
++i;
}
saa = new String[ffc.getFvImagesNameValueCount()][2];
ffc.getFvImagesNameValues(saa);
for (int m = 0; m < saa.length; ++m) {
fvPropertyTableModel.addRow(saa[m]);
}
}
});
}
return jPanelFvImages;
@ -1101,6 +1129,10 @@ public class FpdFlash extends IInternalFrame {
}
return jButtonFdfBrowse;
}
private void initFvAdditionalTable() {
}
private void initFvInFdfTable(String fdfPath){
Vector<FvInfoFromFdf> vFvInfo = new Vector<FvInfoFromFdf>();
@ -1121,10 +1153,9 @@ public class FpdFlash extends IInternalFrame {
private void addTabForFv (FvInfoFromFdf fvInfo) {
String fvName = fvInfo.getFvName();
String outputFile = fvInfo.getEfiFileName();
for (int i = 2; i < jTabbedPane.getTabCount(); ++i) {
if (jTabbedPane.getTitleAt(i).equals(fvName)) {
return;
}
int index = jTabbedPane.indexOfTab(fvName);
if (index >= startIndexOfDynamicTab) {
return;
}
jTabbedPane.addTab(fvName, null, new ModuleOrderPane(fvName, outputFile), null);
}
@ -1560,9 +1591,81 @@ public class FpdFlash extends IInternalFrame {
jTableFvAdditional.setRowHeight(20);
jTableFvAdditional.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
jTableFvAdditional.setModel(getFvAddtionalTableModel());
jTableFvAdditional.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if (lsm.isSelectionEmpty()) {
return;
} else {
selectedRowInFvAdditionalTable = lsm.getMinSelectionIndex();
oldFvName = jTableFvAdditional.getValueAt(selectedRowInFvAdditionalTable, 0)+"";
}
}
});
jTableFvAdditional.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 (col == 0) {
String newFvName = m.getValueAt(row, 0) + "";
if (newFvName.equals(oldFvName)) {
return;
}
if (fvNameExists(newFvName)) {
JOptionPane.showMessageDialog(frame, "This FV already exists. Please choose another FV name.");
m.setValueAt(oldFvName, row, 0);
return;
}
tabIndexForFv = jTabbedPane.indexOfTab(oldFvName);
if (tabIndexForFv >= startIndexOfDynamicTab) {
jTabbedPane.setTitleAt(tabIndexForFv, newFvName);
// change FvName in UserExtensions
ffc.updateBuildOptionsUserExtensions(oldFvName, newFvName);
// change FvBinding in ModuleSA
ffc.appendFvBindingFor(oldFvName, newFvName);
ffc.removeFvBindingAll(oldFvName);
// change FvImageNames in Flash
ffc.updateFvImageNameAll(oldFvName, newFvName);
} else {
jTabbedPane.addTab(newFvName, new ModuleOrderPane(newFvName, ""));
// Add FvImageNames in Flash
String[] fvNames = {newFvName};
ffc.AddFvImageFvImageNames(fvNames);
}
oldFvName = newFvName;
}
docConsole.setSaved(false);
}
}
});
}
return jTableFvAdditional;
}
private boolean fvNameExists (String fvName) {
for (int i = 0; i < jTableFvInFdf.getRowCount(); ++i) {
if (fvInFdfTableModel.getValueAt(i, 0).equals(fvName)) {
return true;
}
}
for (int j = 0; j < jTableFvAdditional.getRowCount(); ++j) {
if (fvAddtionalTableModel.getValueAt(j, 0).equals(fvName) && j != selectedRowInFvAdditionalTable) {
return true;
}
}
return false;
}
/**
* This method initializes fvAddtionalTableModel
@ -1588,11 +1691,15 @@ public class FpdFlash extends IInternalFrame {
if (jButtonAddFv == null) {
jButtonAddFv = new JButton();
jButtonAddFv.setPreferredSize(new java.awt.Dimension(80,20));
jButtonAddFv.setEnabled(false);
jButtonAddFv.setEnabled(true);
jButtonAddFv.setText("New");
jButtonAddFv.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
if (jTableFvAdditional.isEditing()) {
jTableFvAdditional.getCellEditor().stopCellEditing();
}
String[] row = {"", "", ""};
fvAddtionalTableModel.addRow(row);
}
});
}
@ -1673,24 +1780,6 @@ public class FpdFlash extends IInternalFrame {
}
private void init(FpdFileContents ffc) {
if (ffc.getFvImagesFvImageCount() == 0) {
return;
}
String[][] saa = new String[ffc.getFvImagesFvImageCount()][2];
ffc.getFvImagesFvImages(saa);
int i = 0;
while (i < saa.length) {
fvImageParaTableModel.addRow(saa[i]);
++i;
}
saa = new String[ffc.getFvImagesNameValueCount()][2];
ffc.getFvImagesNameValues(saa);
for (int m = 0; m < saa.length; ++m) {
fvPropertyTableModel.addRow(saa[m]);
}
jTextFieldFdf.setText("");
String fdfFile = ffc.getFlashDefinitionFile();
@ -1700,6 +1789,7 @@ public class FpdFlash extends IInternalFrame {
String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;
initFvInFdfTable(fdfPath);
initFvAdditionalTable();
}
private void getOptionNameValue(Map<String, String> m){
@ -2216,7 +2306,7 @@ public class FpdFlash extends IInternalFrame {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
jButtonOk.setText("Save");
jButtonOk.setText("Ok");
jButtonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
// need reset FvBindings in ModuleSA.