Remove empty FfsFileNameGuid element under ModuleSaBuildOptions if user input empty...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdModuleSA.java
index 80369a0..d90d079 100644 (file)
@@ -24,6 +24,8 @@ import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableModel;\r
 \r
 import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.frameworkwizard.common.DataValidation;\r
+import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;\r
 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;\r
 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
@@ -96,11 +98,11 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private HashMap<String, ArrayList<String>> classConsumed = null;\r
     private JPanel jPanel8 = null;\r
     private JLabel jLabel6 = null;\r
-    private JTextField jTextField = null;\r
+    private JTextField jTextFieldFvBinding = null;\r
     private JLabel jLabel7 = null;\r
-    private JTextField jTextField1 = null;\r
+    private JTextField jTextFieldFileGuid = null;\r
     private JLabel jLabel8 = null;\r
-    private JTextField jTextField2 = null;\r
+    private JTextField jTextFieldFfsKey = null;\r
     private JScrollPane jScrollPane6 = null;\r
     private JTable jTable4 = null;\r
     private JButton jButton4 = null;\r
@@ -117,6 +119,8 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JTextField jTextField4 = null;\r
     private JButton jButton6 = null;\r
     private JComboBox jComboBox1 = null;\r
+    private OpeningPlatformType docConsole = null;\r
+    private JLabel jLabel12 = null;\r
     /**\r
      * This is the default constructor\r
      */\r
@@ -129,9 +133,9 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         this.ffc = ffc;\r
     }\r
     \r
-    public void setKey(String k, int i){\r
+    public void setKey(String k, int i, OpeningPlatformType dc){\r
         this.moduleKey = k;\r
-        \r
+        this.docConsole = dc;\r
         jTabbedPane.setSelectedIndex(0);\r
         initPcdBuildDefinition(i);\r
     }\r
@@ -192,15 +196,15 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         //\r
         String fvBinding = ffc.getFvBinding(key);\r
         if (fvBinding != null) {\r
-            jTextField.setText(fvBinding);\r
+            jTextFieldFvBinding.setText(fvBinding);\r
         }\r
         String fileGuid = ffc.getFfsFileNameGuid(key);\r
         if (fileGuid != null) {\r
-            jTextField1.setText(fileGuid);\r
+            jTextFieldFileGuid.setText(fileGuid);\r
         }\r
         String ffsKey = ffc.getFfsFormatKey(key);\r
         if (ffsKey != null) {\r
-            jTextField2.setText(ffsKey);\r
+            jTextFieldFfsKey.setText(ffsKey);\r
         }\r
         \r
         optionsTableModel.setRowCount(0);\r
@@ -900,7 +904,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JScrollPane getJScrollPane4() {\r
         if (jScrollPane4 == null) {\r
             jScrollPane4 = new JScrollPane();\r
-            jScrollPane4.setPreferredSize(new java.awt.Dimension(450,170));\r
+            jScrollPane4.setPreferredSize(new java.awt.Dimension(430,170));\r
             jScrollPane4.setViewportView(getJTable3());\r
         }\r
         return jScrollPane4;\r
@@ -1005,6 +1009,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     if (row < 0) {\r
                         return;\r
                     }\r
+                    docConsole.setSaved(false);\r
                     Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),\r
                                   model3.getValueAt(row, 2), model3.getValueAt(row, 3),\r
                                   model3.getValueAt(row, 4)};\r
@@ -1046,6 +1051,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     if (row < 0) {\r
                         return;\r
                     }\r
+                    docConsole.setSaved(false);\r
                     removeInstance(model1.getValueAt(row, 1) + " " + \r
                                    model1.getValueAt(row, 2) + " " +\r
                                    model1.getValueAt(row, 3) + " " +\r
@@ -1094,9 +1100,6 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             if (jTable4.isEditing()) {\r
                 jTable4.getCellEditor().stopCellEditing();\r
             }\r
-            ffc.setFvBinding(moduleKey, jTextField.getText());\r
-            ffc.setFfsFileNameGuid(moduleKey, jTextField1.getText());\r
-            ffc.setFfsFormatKey(moduleKey, jTextField2.getText());\r
             this.setVisible(false);\r
         }\r
     }\r
@@ -1107,20 +1110,30 @@ public class FpdModuleSA extends JDialog implements ActionListener {
      */\r
     private JPanel getJPanel8() {\r
         if (jPanel8 == null) {\r
+            jLabel12 = new JLabel();\r
+            jLabel12.setText("");\r
+            jLabel12.setPreferredSize(new java.awt.Dimension(250,16));\r
+            FlowLayout flowLayout4 = new FlowLayout();\r
+            flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);\r
             jLabel8 = new JLabel();\r
             jLabel8.setText("FFS Format Key");\r
+            jLabel8.setPreferredSize(new java.awt.Dimension(90,16));\r
             jLabel7 = new JLabel();\r
             jLabel7.setText("FFS File GUID");\r
+            jLabel7.setPreferredSize(new java.awt.Dimension(90,16));\r
             jLabel6 = new JLabel();\r
             jLabel6.setText("FV Binding");\r
+            jLabel6.setPreferredSize(new java.awt.Dimension(90,16));\r
             jPanel8 = new JPanel();\r
+            jPanel8.setLayout(flowLayout4);\r
             jPanel8.add(jLabel6, null);\r
-            jPanel8.add(getJTextField(), null);\r
+            jPanel8.add(getJTextFieldFvBinding(), null);\r
             jPanel8.add(jLabel7, null);\r
-            jPanel8.add(getJTextField1(), null);\r
+            jPanel8.add(getJTextFieldFileGuid(), null);\r
             jPanel8.add(jLabel8, null);\r
-            jPanel8.add(getJTextField2(), null);\r
+            jPanel8.add(getJTextFieldFfsKey(), null);\r
             jPanel8.add(getJScrollPane6(), null);\r
+            jPanel8.add(jLabel12, null);\r
             jPanel8.add(getJButton4(), null);\r
             jPanel8.add(getJButton5(), null);\r
             jPanel8.addComponentListener(new java.awt.event.ComponentAdapter() {\r
@@ -1136,39 +1149,91 @@ public class FpdModuleSA extends JDialog implements ActionListener {
      *         \r
      * @return javax.swing.JTextField  \r
      */\r
-    private JTextField getJTextField() {\r
-        if (jTextField == null) {\r
-            jTextField = new JTextField();\r
-            jTextField.setPreferredSize(new java.awt.Dimension(100,20));\r
+    private JTextField getJTextFieldFvBinding() {\r
+        if (jTextFieldFvBinding == null) {\r
+            jTextFieldFvBinding = new JTextField();\r
+            jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(150,20));\r
+            jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {\r
+                public void focusLost(java.awt.event.FocusEvent e) {\r
+                    String originalFvBinding = ffc.getFvBinding(moduleKey);\r
+                    String newFvBinding = jTextFieldFvBinding.getText();\r
+                    if (newFvBinding.equals(originalFvBinding)) {\r
+                        return;\r
+                    }\r
+                    if (newFvBinding.length() == 0 && originalFvBinding == null) {\r
+                        return;\r
+                    }\r
+                    docConsole.setSaved(false);\r
+                    ffc.setFvBinding(moduleKey, newFvBinding);\r
+                }\r
+            });\r
             \r
         }\r
-        return jTextField;\r
+        return jTextFieldFvBinding;\r
     }\r
     /**\r
      * This method initializes jTextField1     \r
      *         \r
      * @return javax.swing.JTextField  \r
      */\r
-    private JTextField getJTextField1() {\r
-        if (jTextField1 == null) {\r
-            jTextField1 = new JTextField();\r
-            jTextField1.setPreferredSize(new java.awt.Dimension(100,20));\r
+    private JTextField getJTextFieldFileGuid() {\r
+        if (jTextFieldFileGuid == null) {\r
+            jTextFieldFileGuid = new JTextField();\r
+            jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));\r
+            jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {\r
+                public void focusLost(java.awt.event.FocusEvent e) {\r
+                    String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);\r
+                    String newFileGuid = jTextFieldFileGuid.getText();\r
+                    if (newFileGuid.equals(originalFileGuid)) {\r
+                        return;\r
+                    }\r
+                    if (newFileGuid.length() == 0 && originalFileGuid == null) {\r
+                        return;\r
+                    }\r
+                    if (newFileGuid.length() > 0) {\r
+                        if (!DataValidation.isGuid(newFileGuid)) {\r
+                            JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");\r
+                            return;\r
+                        }\r
+                    }\r
+                    \r
+                    docConsole.setSaved(false);\r
+                    if (newFileGuid.length() == 0) {\r
+                        newFileGuid = null;\r
+                    }\r
+                    ffc.setFfsFileNameGuid(moduleKey, newFileGuid);\r
+                }\r
+            });\r
             \r
         }\r
-        return jTextField1;\r
+        return jTextFieldFileGuid;\r
     }\r
     /**\r
-     * This method initializes jTextField2     \r
+     * This method initializes jTextFieldFfsKey        \r
      *         \r
      * @return javax.swing.JTextField  \r
      */\r
-    private JTextField getJTextField2() {\r
-        if (jTextField2 == null) {\r
-            jTextField2 = new JTextField();\r
-            jTextField2.setPreferredSize(new java.awt.Dimension(100,20));\r
+    private JTextField getJTextFieldFfsKey() {\r
+        if (jTextFieldFfsKey == null) {\r
+            jTextFieldFfsKey = new JTextField();\r
+            jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(150,20));\r
+            jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {\r
+                public void focusLost(java.awt.event.FocusEvent e) {\r
+                    String originalFfsKey = ffc.getFfsFormatKey(moduleKey);\r
+                    String newFfsKey = jTextFieldFfsKey.getText();\r
+                    if (newFfsKey.equals(originalFfsKey)) {\r
+                        return;\r
+                    }\r
+                    if (newFfsKey.length() == 0 && originalFfsKey == null) {\r
+                        return;\r
+                    }\r
+                    docConsole.setSaved(false);\r
+                    ffc.setFfsFormatKey(moduleKey, newFfsKey);\r
+                }\r
+            });\r
             \r
         }\r
-        return jTextField2;\r
+        return jTextFieldFfsKey;\r
     }\r
     /**\r
      * This method initializes jScrollPane6    \r
@@ -1241,7 +1306,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                         }\r
                         \r
                         String contents = m.getValueAt(row, 5) + "";\r
-                        \r
+                        docConsole.setSaved(false);\r
                         ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);\r
                     }\r
                 }\r
@@ -1265,7 +1330,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     optionsTableModel.addRow(row);\r
                     Vector<Object> v = new Vector<Object>();\r
                     Vector<Object> v1 = null;\r
-                    \r
+                    docConsole.setSaved(false);\r
                     ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");\r
                 }\r
             });\r
@@ -1287,7 +1352,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     if (jTable4.getSelectedRow() < 0) {\r
                         return;\r
                     }\r
-                    \r
+                    docConsole.setSaved(false);\r
                     ffc.removeModuleSAOptionsOpt(moduleKey, jTable4.getSelectedRow());\r
                     optionsTableModel.removeRow(jTable4.getSelectedRow());\r
                 }\r
@@ -1499,6 +1564,7 @@ private JButton getJButton6() {
                 if (row < 0) {\r
                     return;\r
                 }\r
+                docConsole.setSaved(false);\r
                 model.setValueAt(jComboBox.getSelectedItem(), row, 2);\r
                 model.setValueAt(jTextField3.getText(), row, 4);\r
                 model.setValueAt(jTextField4.isVisible()? jTextField4.getText():jComboBox1.getSelectedItem(), row, 6);\r