Fix Ffs sections encapsulation type update problem.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 13 Nov 2006 06:56:45 +0000 (06:56 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 13 Nov 2006 06:56:45 +0000 (06:56 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1934 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java
Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java

index bc9a8c23a8dcc1579169d617d1b5ca40e5c7be42..1abfe14032c6052b13a539b983bf5928e0cb8ebc 100644 (file)
@@ -36,6 +36,8 @@ import javax.swing.JScrollPane;
 import javax.swing.JTable;\r
 import javax.swing.JComboBox;\r
 import javax.swing.ListSelectionModel;\r
+import javax.swing.event.DocumentEvent;\r
+import javax.swing.event.DocumentListener;\r
 import javax.swing.event.InternalFrameAdapter;\r
 import javax.swing.event.InternalFrameEvent;\r
 import javax.swing.event.ListSelectionEvent;\r
@@ -167,10 +169,6 @@ public class FpdBuildOptions extends IInternalFrame {
 \r
     private JPanel jPanelFfsTabCenterS = null;\r
 \r
-    private JLabel jLabelFfsKey = null;\r
-\r
-    private JTextField jTextFieldFfsKey = null;\r
-\r
     private JButton jButtonFfsAdd = null;\r
 \r
     private JButton jButtonFfsDel = null;\r
@@ -313,6 +311,8 @@ public class FpdBuildOptions extends IInternalFrame {
     private final int toolCmdCodeWidth = 200;\r
     private final int tagNameWidth = 150;\r
     private final int argWidth = 400;\r
+    \r
+    private boolean ffsSelection = false;\r
 \r
     /**\r
      * This method initializes jPanel  \r
@@ -457,7 +457,6 @@ public class FpdBuildOptions extends IInternalFrame {
         initFfsTable();\r
         this.addInternalFrameListener(new InternalFrameAdapter() {\r
             public void internalFrameDeactivated(InternalFrameEvent e) {\r
-                \r
                 if (jTableAntTasks.isEditing()) {\r
                     jTableAntTasks.getCellEditor().stopCellEditing();\r
                 }\r
@@ -529,12 +528,11 @@ public class FpdBuildOptions extends IInternalFrame {
             jLabelEncapType.setText("Encapsulation Type");\r
             FlowLayout flowLayout5 = new FlowLayout();\r
             flowLayout5.setAlignment(java.awt.FlowLayout.RIGHT);\r
-            jLabelFfsKey = new JLabel();\r
-            jLabelFfsKey.setText("FFS Key");\r
+            \r
             jPanelFfsTabCenterN = new JPanel();\r
             jPanelFfsTabCenterN.setLayout(flowLayout5);\r
-            jPanelFfsTabCenterN.add(jLabelFfsKey, null);\r
-            jPanelFfsTabCenterN.add(getJTextFieldFfsKey(), null);\r
+            \r
+            \r
             jPanelFfsTabCenterN.add(jLabelEncapType, null);\r
             jPanelFfsTabCenterN.add(getJTextFieldEncapType(), null);\r
             jPanelFfsTabCenterN.add(getJButtonFfsAdd(), null);\r
@@ -552,16 +550,12 @@ public class FpdBuildOptions extends IInternalFrame {
         if (jPanelFfsTabCenterS == null) {\r
             jLabelFfsAttribs = new JLabel();\r
             jLabelFfsAttribs.setText("Attributes");\r
-            FlowLayout flowLayout6 = new FlowLayout();\r
-            flowLayout6.setHgap(5);\r
-            flowLayout6.setVgap(20);\r
-            flowLayout6.setAlignment(java.awt.FlowLayout.CENTER);\r
             jPanelFfsTabCenterS = new JPanel();\r
             jPanelFfsTabCenterS.setPreferredSize(new java.awt.Dimension(491, 130));\r
-            jPanelFfsTabCenterS.setLayout(flowLayout6);\r
-            jPanelFfsTabCenterS.add(jLabelFfsAttribs, null);\r
-            jPanelFfsTabCenterS.add(getJScrollPaneFfsAttribs(), null);\r
-            jPanelFfsTabCenterS.add(getJPanelFfsAttribButtonGroup(), null);\r
+            jPanelFfsTabCenterS.setLayout(new BorderLayout());\r
+            jPanelFfsTabCenterS.add(jLabelFfsAttribs, java.awt.BorderLayout.WEST);\r
+            jPanelFfsTabCenterS.add(getJScrollPaneFfsAttribs(), java.awt.BorderLayout.CENTER);\r
+            jPanelFfsTabCenterS.add(getJPanelFfsAttribButtonGroup(), java.awt.BorderLayout.EAST);\r
         }\r
         return jPanelFfsTabCenterS;\r
     }\r
@@ -571,22 +565,7 @@ public class FpdBuildOptions extends IInternalFrame {
      *         \r
      * @return javax.swing.JTextField  \r
      */\r
-    private JTextField getJTextFieldFfsKey() {\r
-        if (jTextFieldFfsKey == null) {\r
-            jTextFieldFfsKey = new JTextField();\r
-            jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(100, 20));\r
-            jTextFieldFfsKey.setEditable(true);\r
-            jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {\r
-                public void focusLost(java.awt.event.FocusEvent e) {\r
-                    if (jTableFfs.getSelectedRow() < 0) {\r
-                        return;\r
-                    }\r
-                    //                    ffc.updateBuildOptionsFfsKey(jTable.getSelectedRow(), jTextField6.getText());\r
-                }\r
-            });\r
-        }\r
-        return jTextFieldFfsKey;\r
-    }\r
+    \r
 \r
     /**\r
      * This method initializes jButton8        \r
@@ -597,7 +576,7 @@ public class FpdBuildOptions extends IInternalFrame {
         if (jButtonFfsAdd == null) {\r
             jButtonFfsAdd = new JButton();\r
             jButtonFfsAdd.setPreferredSize(new java.awt.Dimension(70, 20));\r
-            jButtonFfsAdd.setText("Add");\r
+            jButtonFfsAdd.setText("New");\r
             jButtonFfsAdd.addActionListener(new AbstractAction() {\r
                 /**\r
                  * \r
@@ -605,12 +584,13 @@ public class FpdBuildOptions extends IInternalFrame {
                 private static final long serialVersionUID = -2923720717273384221L;\r
 \r
                 public void actionPerformed(java.awt.event.ActionEvent e) {\r
-                    if (jTextFieldFfsKey.getText().length() > 0) {\r
-                        String[] row = { jTextFieldFfsKey.getText() };\r
+                    \r
+                        String[] row = { "" };\r
                         ffsTableModel.addRow(row);\r
                         docConsole.setSaved(false);\r
-                        ffc.genBuildOptionsFfs(jTextFieldFfsKey.getText(), jTextFieldEncapType.getText());\r
-                    }\r
+                        ffc.genBuildOptionsFfs("", "");\r
+                        jTableFfs.changeSelection(ffsTableModel.getRowCount()-1, 0, false, false);\r
+                    \r
                 }\r
             });\r
         }\r
@@ -659,8 +639,9 @@ public class FpdBuildOptions extends IInternalFrame {
     private JScrollPane getJScrollPaneFfsAttribs() {\r
         if (jScrollPaneFfsAttribs == null) {\r
             jScrollPaneFfsAttribs = new JScrollPane();\r
-            jScrollPaneFfsAttribs.setPreferredSize(new java.awt.Dimension(350, 100));\r
+//            jScrollPaneFfsAttribs.setPreferredSize(new java.awt.Dimension(350, 100));\r
             jScrollPaneFfsAttribs.setViewportView(getJTableFfsAttribs());\r
+            \r
         }\r
         return jScrollPaneFfsAttribs;\r
     }\r
@@ -674,7 +655,7 @@ public class FpdBuildOptions extends IInternalFrame {
         if (jTableFfsAttribs == null) {\r
             ffsAttributesTableModel = new DefaultTableModel();\r
             jTableFfsAttribs = new JTable(ffsAttributesTableModel);\r
-            jTableFfsAttribs.setPreferredSize(new java.awt.Dimension(400, 80));\r
+//            jTableFfsAttribs.setPreferredSize(new java.awt.Dimension(400, 80));\r
             jTableFfsAttribs.setRowHeight(20);\r
             ffsAttributesTableModel.addColumn("Name");\r
             ffsAttributesTableModel.addColumn("Value");\r
@@ -715,6 +696,7 @@ public class FpdBuildOptions extends IInternalFrame {
         for (int i = 0; i < saa.length; ++i) {\r
             ffsTableModel.addRow(saa[i]);\r
         }\r
+        jTableFfs.changeSelection(0, 0, false, false);\r
     }\r
 \r
     /**\r
@@ -788,7 +770,7 @@ public class FpdBuildOptions extends IInternalFrame {
     private JScrollPane getJScrollPaneFfs() {\r
         if (jScrollPaneFfs == null) {\r
             jScrollPaneFfs = new JScrollPane();\r
-            jScrollPaneFfs.setPreferredSize(new java.awt.Dimension(150, 419));\r
+            jScrollPaneFfs.setPreferredSize(new java.awt.Dimension(200,419));\r
             jScrollPaneFfs.setViewportView(getJTableFfs());\r
         }\r
         return jScrollPaneFfs;\r
@@ -828,7 +810,7 @@ public class FpdBuildOptions extends IInternalFrame {
                         ArrayList<String> alSections = new ArrayList<String>();\r
                         ArrayList<String> alSection = new ArrayList<String>();\r
                         ffc.getBuildOptionsFfs(row, sArray, lhm, alSections, alSection);\r
-                        jTextFieldFfsKey.setText(sArray[0]);\r
+                        ffsSelection = true;\r
                         jTextFieldEncapType.setText(sArray[1]);\r
                         for (int i = 0; i < alSection.size(); ++i) {\r
                             String[] sectionRow = { alSection.get(i) };\r
@@ -1008,13 +990,42 @@ public class FpdBuildOptions extends IInternalFrame {
     private JTextField getJTextFieldEncapType() {\r
         if (jTextFieldEncapType == null) {\r
             jTextFieldEncapType = new JTextField();\r
-            jTextFieldEncapType.setPreferredSize(new java.awt.Dimension(100, 20));\r
+            jTextFieldEncapType.setPreferredSize(new java.awt.Dimension(200,20));\r
+            jTextFieldEncapType.getDocument().addDocumentListener(new DocumentListener() {\r
+\r
+                public void insertUpdate(DocumentEvent arg0) {\r
+                    if (ffsSelection) {\r
+                        ffsSelection = false;\r
+                        return;\r
+                    }\r
+                    if (docConsole != null) {\r
+                        docConsole.setSaved(false);\r
+                    }\r
+                }\r
+\r
+                public void removeUpdate(DocumentEvent arg0) {\r
+                    if (ffsSelection) {\r
+                        ffsSelection = false;\r
+                        return;\r
+                    }\r
+                    if (docConsole != null) {\r
+                        docConsole.setSaved(false);\r
+                    }\r
+                }\r
+\r
+                public void changedUpdate(DocumentEvent arg0) {\r
+                    // TODO Auto-generated method stub\r
+                    \r
+                }\r
+                \r
+            });\r
             jTextFieldEncapType.addFocusListener(new java.awt.event.FocusAdapter() {\r
                 public void focusLost(java.awt.event.FocusEvent e) {\r
                     if (jTableFfs.getSelectedRow() < 0) {\r
                         return;\r
                     }\r
                     ffc.updateBuildOptionsFfsSectionsType(jTableFfs.getSelectedRow(), jTextFieldEncapType.getText());\r
+                    \r
                 }\r
             });\r
         }\r
@@ -1165,10 +1176,11 @@ public class FpdBuildOptions extends IInternalFrame {
                         return;\r
                     }\r
                     docConsole.setSaved(false);\r
-                    String[] row = { "" };\r
+                    String[] row = { "Compress" };\r
                     sectionsTableModel.addRow(row);\r
                     ffc.genBuildOptionsFfsSectionsSections(jTableFfs.getSelectedRow(), "");\r
                     JOptionPane.showMessageDialog(frame, "Add Default Section Type EFI_SECTION_PE32 into the New Sections Entry.");\r
+                    jTableFfsSections.changeSelection(sectionsTableModel.getRowCount()-1, 0, false, false);\r
                 }\r
             });\r
         }\r
index 130b625e753a22606fc21ee5a8ac67395be600d6..b59d3420c27e86f68913615d331a64167d323226 100644 (file)
@@ -2391,10 +2391,8 @@ public class FpdFileContents {
     }\r
     \r
     public void updateBuildOptionsFfsSectionsType(int i, String type) {\r
-        BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
-        if (type != null) {\r
-            ffs.addNewSections().setEncapsulationType(type);\r
-        }\r
+        BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
+        ffs.getSections().setEncapsulationType(type);\r
     }\r
     \r
     public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r