X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdBuildOptions.java;h=f273d8db66718e16d2ff1324a609386a446ed145;hp=af0c95cadd394ad61e7ccc864925a2f6d07fa130;hb=af25df1662fe283b6215086799b3915131575ce2;hpb=f3b0ed9a12ec287bb336b9672a0937667f1958ec diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java index af0c95cadd..f273d8db66 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java @@ -26,6 +26,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.DefaultCellEditor; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.JButton; import javax.swing.JScrollPane; @@ -39,20 +42,25 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.DataValidation; +import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; import org.tianocore.frameworkwizard.common.ui.IInternalFrame; + +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Set; import java.util.Vector; +import java.awt.Dimension; public class FpdBuildOptions extends IInternalFrame { private static final long serialVersionUID = 1L; + static JFrame frame; private JPanel jContentPane = null; private JPanel jPanel = null; private JPanel jPanel1 = null; @@ -105,7 +113,7 @@ public class FpdBuildOptions extends IInternalFrame { private JButton jButton17 = null; private JButton jButton18 = null; private FpdFileContents ffc = null; - private JButton jButton19 = null; + private OpeningPlatformType docConsole = null; private JCheckBox jCheckBox9 = null; private JCheckBox jCheckBox10 = null; private JCheckBox jCheckBox11 = null; @@ -140,6 +148,8 @@ public class FpdBuildOptions extends IInternalFrame { private JButton jButton7 = null; private JScrollPane jScrollPane4 = null; private JTable jTable6 = null; + private JButton jButton12 = null; + private JTextField jTextField1 = null; /** * This method initializes jPanel * @@ -239,6 +249,7 @@ public class FpdBuildOptions extends IInternalFrame { jPanel9.setLayout(flowLayout8); jPanel9.add(jLabel, null); jPanel9.add(getJTextField2(), null); + jPanel9.add(getJButton12(), null); jPanel9.add(jLabel3, null); jPanel9.add(getJTextField3(), null); } @@ -319,12 +330,16 @@ public class FpdBuildOptions extends IInternalFrame { jButton4.setText("Add"); jButton4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + if (!DataValidation.isInt(jTextField3.getText()) || jTextField3.getText().length() != 8) { + JOptionPane.showMessageDialog(frame, "ID must be an 8-digit integer."); + return; + } Object[] o = {jTextField3.getText(), null, null}; o[1] = jTextField2.getText(); o[2] = jTextField4.getText(); - ffc.genBuildOptionsUserDefAntTask(o[0]+"", null, o[2]+""); + ffc.genBuildOptionsUserDefAntTask(o[0]+"", o[1]+"", o[2]+""); antTaskTableModel.addRow(o); - + docConsole.setSaved(false); } }); } @@ -344,6 +359,7 @@ public class FpdBuildOptions extends IInternalFrame { jButton5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (selectedRow >= 0) { + docConsole.setSaved(false); antTaskTableModel.removeRow(selectedRow); ffc.removeBuildOptionsUserDefAntTask(selectedRow); } @@ -544,7 +560,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTextField6 == null) { jTextField6 = new JTextField(); jTextField6.setPreferredSize(new java.awt.Dimension(100,20)); - jTextField6.setEditable(false); + jTextField6.setEditable(true); jTextField6.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent e) { if (jTable.getSelectedRow() < 0) { @@ -577,6 +593,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTextField6.getText().length() > 0) { String[] row = {jTextField6.getText()}; ffsTableModel.addRow(row); + docConsole.setSaved(false); ffc.genBuildOptionsFfs(jTextField6.getText(), jTextField.getText()); } } @@ -605,6 +622,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); ffc.removeBuildOptionsFfs(jTable.getSelectedRow()); } }); @@ -657,6 +675,7 @@ public class FpdBuildOptions extends IInternalFrame { if (value.length() == 0){ return; } + docConsole.setSaved(false); ffc.updateBuildOptionsFfsAttribute(jTable.getSelectedRow(), row, name, value); } } @@ -722,6 +741,7 @@ public class FpdBuildOptions extends IInternalFrame { jPanel20.add(jLabel14, null); jPanel20.add(getJTextField12(), null); jPanel20.add(jLabel10, null); + jPanel20.add(getJTextField1(), null); jPanel20.add(getJComboBox2(), null); jPanel20.add(jLabel12, null); jPanel20.add(getJTextField8(), null); @@ -738,7 +758,6 @@ public class FpdBuildOptions extends IInternalFrame { jPanel20.add(getJTextField7(), null); jPanel20.add(getJButton10(), null); jPanel20.add(getJButton11(), null); - jPanel20.add(getJButton19(), null); jPanel20.add(getJScrollPane6(), null); } return jPanel20; @@ -771,6 +790,7 @@ public class FpdBuildOptions extends IInternalFrame { jComboBox2.addItem("CYGWIN"); jComboBox2.addItem("INTEL"); jComboBox2.setSelectedIndex(0); + jComboBox2.setVisible(false); } return jComboBox2; } @@ -819,14 +839,21 @@ public class FpdBuildOptions extends IInternalFrame { optionsTableModel.addColumn("TagName"); optionsTableModel.addColumn("Contents"); - TableColumn toolFamilyCol = jTable5.getColumnModel().getColumn(1); - JComboBox cb = new JComboBox(); - cb.addItem("MSFT"); - cb.addItem("GCC"); - cb.addItem("CYGWIN"); - cb.addItem("INTEL"); - toolFamilyCol.setCellEditor(new DefaultCellEditor(cb)); - +// TableColumn toolFamilyCol = jTable5.getColumnModel().getColumn(1); +// JComboBox cb = new JComboBox(); +// cb.addItem("MSFT"); +// cb.addItem("GCC"); +// cb.addItem("CYGWIN"); +// cb.addItem("INTEL"); +// toolFamilyCol.setCellEditor(new DefaultCellEditor(cb)); + Vector vArch = new Vector(); + vArch.add("IA32"); + vArch.add("X64"); + vArch.add("IPF"); + vArch.add("EBC"); + vArch.add("ARM"); + vArch.add("PPC"); + jTable5.getColumnModel().getColumn(2).setCellEditor(new ListEditor(vArch)); jTable5.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTable5.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e) { @@ -859,17 +886,19 @@ public class FpdBuildOptions extends IInternalFrame { } String toolChain = m.getValueAt(row, 1) + ""; String archs = m.getValueAt(row, 2) + ""; - Vector supArch = new Vector(); - String[] sArray1 = archs.split("( )+"); - for (int i = 0; i < sArray1.length; ++i) { - supArch.add(sArray1[i]); - } - if (supArch.size() == 0) { - supArch.add("IA32"); + Vector supArch = null; + if (archs.length() > 0) { + supArch = new Vector(); + String[] sArray1 = archs.split("( )+"); + for (int i = 0; i < sArray1.length; ++i) { + supArch.add(sArray1[i]); + } } + String toolCmd = m.getValueAt(row, 3) + ""; String tagName = m.getValueAt(row, 4) + ""; String contents = m.getValueAt(row, 5) + ""; + docConsole.setSaved(false); ffc.updateBuildOptionsOpt(row, targetName, toolChain, tagName, toolCmd, supArch, contents); } } @@ -887,7 +916,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jButton10 == null) { jButton10 = new JButton(); jButton10.setText("Add"); - jButton10.setPreferredSize(new java.awt.Dimension(70,20)); + jButton10.setPreferredSize(new java.awt.Dimension(90,20)); jButton10.addActionListener(new AbstractAction() { /** * @@ -898,11 +927,11 @@ public class FpdBuildOptions extends IInternalFrame { boolean[] boolArray = {jCheckBox9.isSelected(),jCheckBox10.isSelected(),jCheckBox11.isSelected(), jCheckBox12.isSelected(),jCheckBox13.isSelected(),jCheckBox14.isSelected()}; String s = boolToList(boolArray); - Object[] o = {jTextField12.getText(), jComboBox2.getSelectedItem(), s, + Object[] o = {jTextField12.getText(), jTextField1.getText(), s, jTextField8.getText(), jTextField13.getText(), jTextField7.getText()}; optionsTableModel.addRow(o); - - ffc.genBuildOptionsOpt(stringToVector(jTextField12.getText()), jComboBox2.getSelectedItem()+"", jTextField13.getText(), jTextField8.getText(), stringToVector(s), jTextField7.getText()); + docConsole.setSaved(false); + ffc.genBuildOptionsOpt(stringToVector(jTextField12.getText()), jTextField1.getText(), jTextField13.getText(), jTextField8.getText(), stringToVector(s), jTextField7.getText()); } }); } @@ -911,9 +940,12 @@ public class FpdBuildOptions extends IInternalFrame { private Vector stringToVector(String s) { String[] sArray = s.split(" "); - Vector v = new Vector(); - for (int i = 0; i < sArray.length; ++i) { - v.add(sArray[i]); + Vector v = null; + if (s.length() > 0) { + v = new Vector(); + for (int i = 0; i < sArray.length; ++i) { + v.add(sArray[i]); + } } return v; } @@ -953,7 +985,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jButton11 == null) { jButton11 = new JButton(); jButton11.setText("Delete"); - jButton11.setPreferredSize(new java.awt.Dimension(70,20)); + jButton11.setPreferredSize(new java.awt.Dimension(90,20)); jButton11.addActionListener(new AbstractAction() { /** * @@ -963,6 +995,7 @@ public class FpdBuildOptions extends IInternalFrame { public void actionPerformed(java.awt.event.ActionEvent e) { if (selectedRow >= 0) { optionsTableModel.removeRow(selectedRow); + docConsole.setSaved(false); ffc.removeBuildOptionsOpt(selectedRow); } } @@ -993,6 +1026,7 @@ public class FpdBuildOptions extends IInternalFrame { } Object[] o = {"", ""}; ffsAttributesTableModel.addRow(o); + docConsole.setSaved(false); ffc.genBuildOptionsFfsAttribute(jTable.getSelectedRow(), "", ""); } }); @@ -1021,6 +1055,7 @@ public class FpdBuildOptions extends IInternalFrame { return; } if (jTable4.getSelectedRow() >= 0){ + docConsole.setSaved(false); ffsAttributesTableModel.removeRow(jTable4.getSelectedRow()); ffc.removeBuildOptionsFfsAttribute(jTable.getSelectedRow(), jTable4.getSelectedRow()); } @@ -1030,21 +1065,6 @@ public class FpdBuildOptions extends IInternalFrame { return jButton18; } - /** - * This method initializes jButton19 - * - * @return javax.swing.JButton - */ - private JButton getJButton19() { - if (jButton19 == null) { - jButton19 = new JButton(); - jButton19.setPreferredSize(new java.awt.Dimension(75,20)); - jButton19.setEnabled(false); - jButton19.setText("Update"); - } - return jButton19; - } - /** * This method initializes jCheckBox9 * @@ -1240,7 +1260,7 @@ public class FpdBuildOptions extends IInternalFrame { if (id.length() == 0) { return; } - + docConsole.setSaved(false); ffc.updateBuildOptionsFfsKey(row, id); } } @@ -1304,7 +1324,7 @@ public class FpdBuildOptions extends IInternalFrame { if (arg0.getType() == TableModelEvent.UPDATE){ //ToDo Data Validition check. String type = m.getValueAt(row, 0) + ""; - + docConsole.setSaved(false); ffc.updateBuildOptionsFfsSectionsSection(jTable.getSelectedRow(), row, type); } } @@ -1366,6 +1386,7 @@ public class FpdBuildOptions extends IInternalFrame { if (arg0.getType() == TableModelEvent.UPDATE){ //ToDo Data Validition check. String type = m.getValueAt(row, 0) + ""; + docConsole.setSaved(false); ffc.updateBuildOptionsFfsSectionsSectionsSection(jTable.getSelectedRow(), jTable6.getSelectedRow(), row, type); } } @@ -1425,6 +1446,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); String[] row = {"EFI_SECTION_RAW"}; sectionTableModel.addRow(row); ffc.genBuildOptionsFfsSectionsSection(jTable.getSelectedRow(), row[0]); @@ -1450,6 +1472,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0 || jTable1.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); sectionTableModel.removeRow(jTable1.getSelectedRow()); ffc.removeBuildOptionsFfsSectionsSection(jTable.getSelectedRow(), jTable1.getSelectedRow()); } @@ -1473,6 +1496,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0 || jTable6.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); String[] row = {"EFI_SECTION_RAW"}; subsectionsTableModel.addRow(row); ffc.genBuildOptionsFfsSectionsSectionsSection(jTable.getSelectedRow(), jTable6.getSelectedRow(), row[0]); @@ -1498,6 +1522,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0 || jTable6.getSelectedRow() < 0 || jTable3.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); subsectionsTableModel.removeRow(jTable3.getSelectedRow()); ffc.removeBuildOptionsFfsSectionsSectionsSection(jTable.getSelectedRow(), jTable6.getSelectedRow(), jTable3.getSelectedRow()); } @@ -1521,6 +1546,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); String[] row = {""}; sectionsTableModel.addRow(row); ffc.genBuildOptionsFfsSectionsSections(jTable.getSelectedRow(), ""); @@ -1545,6 +1571,7 @@ public class FpdBuildOptions extends IInternalFrame { if (jTable.getSelectedRow() < 0 || jTable6.getSelectedRow() < 0) { return; } + docConsole.setSaved(false); sectionsTableModel.removeRow(jTable6.getSelectedRow()); ffc.removeBuildOptionsFfsSectionsSections(jTable.getSelectedRow(), jTable6.getSelectedRow()); } @@ -1612,6 +1639,7 @@ public class FpdBuildOptions extends IInternalFrame { if (arg0.getType() == TableModelEvent.UPDATE){ //ToDo Data Validition check. String encapType = m.getValueAt(row, 0) + ""; + docConsole.setSaved(false); ffc.updateBuildOptionsFfsSectionsSections(jTable.getSelectedRow(), row, encapType); } } @@ -1620,6 +1648,67 @@ public class FpdBuildOptions extends IInternalFrame { return jTable6; } + /** + * This method initializes jButton12 + * + * @return javax.swing.JButton + */ + private JButton getJButton12() { + if (jButton12 == null) { + jButton12 = new JButton(); + jButton12.setPreferredSize(new Dimension(90, 20)); + jButton12.setText("Browse"); + jButton12.addActionListener(new AbstractAction() { + private static final long serialVersionUID = 1L; + + public void actionPerformed(ActionEvent arg0) { + // + // Select files from current workspace + // + String dirPrefix = System.getenv("WORKSPACE"); + JFileChooser chooser = new JFileChooser(dirPrefix); + File theFile = null; + String headerDest = null; + + chooser.setMultiSelectionEnabled(false); + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + int retval = chooser.showOpenDialog(frame); + if (retval == JFileChooser.APPROVE_OPTION) { + + theFile = chooser.getSelectedFile(); + String file = theFile.getPath(); + if (!file.startsWith(dirPrefix)) { + JOptionPane.showMessageDialog(frame, "You can only select files in current package!"); + return; + } + } + else { + return; + } + + headerDest = theFile.getPath(); + jTextField2.setText(headerDest.substring(dirPrefix.length()).replace('\\', '/')); + + } + + }); + } + return jButton12; + } + + /** + * This method initializes jTextField1 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField1() { + if (jTextField1 == null) { + jTextField1 = new JTextField(); + jTextField1.setPreferredSize(new java.awt.Dimension(85,20)); + } + return jTextField1; + } + /** * @param args */ @@ -1642,6 +1731,11 @@ public class FpdBuildOptions extends IInternalFrame { ffc = new FpdFileContents(fpd); init(ffc); } + + public FpdBuildOptions(OpeningPlatformType opt) { + this(opt.getXmlFpd()); + docConsole = opt; + } private void init(FpdFileContents ffc) { initOptionTable();