]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java
Use table and popup window to add/edit all elements of module instead of original...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / ModuleProtocols.java
index 6c09aa19090b1fcfaa9c8ffdabe7914cb33a61aa..ed55f3ce73e62a1e16d3cf782027404ff6c57a89 100644 (file)
 \r
 package org.tianocore.frameworkwizard.module.ui;\r
 \r
+import java.awt.Dimension;\r
 import java.awt.event.ActionEvent;\r
 import java.awt.event.ComponentEvent;\r
-import java.awt.event.ItemEvent;\r
+import java.awt.event.MouseEvent;\r
 import java.util.Vector;\r
 \r
 import javax.swing.JButton;\r
-import javax.swing.JComboBox;\r
-import javax.swing.JLabel;\r
 import javax.swing.JPanel;\r
 import javax.swing.JScrollPane;\r
-import javax.swing.JTextArea;\r
-import javax.swing.JTextField;\r
+import javax.swing.JTable;\r
+import javax.swing.ListSelectionModel;\r
+import javax.swing.event.ListSelectionEvent;\r
 \r
 import org.tianocore.ProtocolNotifyUsage;\r
 import org.tianocore.ProtocolUsage;\r
@@ -36,17 +36,16 @@ import org.tianocore.ProtocolsDocument.Protocols;
 import org.tianocore.ProtocolsDocument.Protocols.Protocol;\r
 import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
 import org.tianocore.frameworkwizard.common.DataType;\r
-import org.tianocore.frameworkwizard.common.DataValidation;\r
 import org.tianocore.frameworkwizard.common.EnumerationData;\r
+import org.tianocore.frameworkwizard.common.IDefaultTableModel;\r
 import org.tianocore.frameworkwizard.common.Log;\r
 import org.tianocore.frameworkwizard.common.Tools;\r
 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;\r
+import org.tianocore.frameworkwizard.common.ui.IFrame;\r
 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
-import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
 import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsIdentification;\r
 import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsVector;\r
-import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+import org.tianocore.frameworkwizard.module.ui.dialog.ProtocolsDlg;\r
 \r
 /**\r
  The class is used to create, update Protocol of MSA/MBD file\r
@@ -67,28 +66,6 @@ public class ModuleProtocols extends IInternalFrame {
     //\r
     private JPanel jContentPane = null;\r
 \r
-    private JLabel jLabelC_Name = null;\r
-\r
-    private JLabel jLabelFeatureFlag = null;\r
-\r
-    private JTextField jTextFieldFeatureFlag = null;\r
-\r
-    private JLabel jLabelUsage = null;\r
-\r
-    private JComboBox jComboBoxUsage = null;\r
-\r
-    private StarLabel jStarLabel1 = null;\r
-\r
-    private StarLabel jStarLabel2 = null;\r
-\r
-    private JLabel jLabelProtocolType = null;\r
-\r
-    private JLabel jLabelArch = null;\r
-\r
-    private JTextArea jTextAreaList = null;\r
-\r
-    private JComboBox jComboBoxList = null;\r
-\r
     private JButton jButtonAdd = null;\r
 \r
     private JButton jButtonRemove = null;\r
@@ -97,25 +74,13 @@ public class ModuleProtocols extends IInternalFrame {
 \r
     private JScrollPane jScrollPane = null;\r
 \r
-    private JScrollPane jScrollPaneList = null;\r
-\r
-    private JComboBox jComboBoxProtocolType = null;\r
+    private JScrollPane jScrollPaneTable = null;\r
 \r
-    private JComboBox jComboBoxCName = null;\r
-\r
-    private ICheckBoxList iCheckBoxListArch = null;\r
-\r
-    private JScrollPane jScrollPaneArch = null;\r
-    \r
-    private JLabel jLabelHelpText = null;\r
-\r
-    private JTextField jTextFieldHelpText = null;\r
+    private JTable jTable = null;\r
 \r
     //\r
     // Not used by UI\r
     //\r
-    private int intSelectedItemId = 0;\r
-\r
     private OpeningModuleType omt = null;\r
 \r
     private ModuleSurfaceArea msa = null;\r
@@ -126,56 +91,11 @@ public class ModuleProtocols extends IInternalFrame {
 \r
     private ProtocolsVector vid = new ProtocolsVector();\r
 \r
-    private WorkspaceTools wt = new WorkspaceTools();\r
-\r
     private EnumerationData ed = new EnumerationData();\r
 \r
-    /**\r
-     This method initializes jTextFieldFeatureFlag \r
-     \r
-     @return javax.swing.JTextField jTextFieldFeatureFlag\r
-     \r
-     **/\r
-    private JTextField getJTextFieldFeatureFlag() {\r
-        if (jTextFieldFeatureFlag == null) {\r
-            jTextFieldFeatureFlag = new JTextField();\r
-            jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));\r
-            jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r
-        }\r
-        return jTextFieldFeatureFlag;\r
-    }\r
-\r
-    /**\r
-     This method initializes jComboBoxUsage \r
-     \r
-     @return javax.swing.JComboBox jComboBoxUsage\r
-     \r
-     **/\r
-    private JComboBox getJComboBoxProtocolUsage() {\r
-        if (jComboBoxUsage == null) {\r
-            jComboBoxUsage = new JComboBox();\r
-            jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));\r
-            jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r
-        }\r
-        return jComboBoxUsage;\r
-    }\r
+    private IDefaultTableModel model = null;\r
 \r
-    /**\r
-     This method initializes jComboBoxFileList \r
-     \r
-     @return javax.swing.JComboBox jComboBoxFileList\r
-     \r
-     **/\r
-    private JComboBox getJComboBoxList() {\r
-        if (jComboBoxList == null) {\r
-            jComboBoxList = new JComboBox();\r
-            jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));\r
-            jComboBoxList.addItemListener(this);\r
-            jComboBoxList.addActionListener(this);\r
-            jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));\r
-        }\r
-        return jComboBoxList;\r
-    }\r
+    private int selectedRow = -1;\r
 \r
     /**\r
      This method initializes jButtonAdd \r
@@ -222,27 +142,12 @@ public class ModuleProtocols extends IInternalFrame {
             jButtonUpdate = new JButton();\r
             jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));\r
             jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));\r
-            jButtonUpdate.setText("Update");\r
+            jButtonUpdate.setText("Edit");\r
             jButtonUpdate.addActionListener(this);\r
         }\r
         return jButtonUpdate;\r
     }\r
 \r
-    /**\r
-     * This method initializes jScrollPaneFileList   \r
-     *   \r
-     * @return javax.swing.JScrollPane   \r
-     */\r
-    private JScrollPane getJScrollPaneList() {\r
-        if (jScrollPaneList == null) {\r
-            jScrollPaneList = new JScrollPane();\r
-            jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));\r
-            jScrollPaneList.setViewportView(getJTextAreaList());\r
-            jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));\r
-        }\r
-        return jScrollPaneList;\r
-    }\r
-\r
     /**\r
      This method initializes jScrollPane  \r
      \r
@@ -257,94 +162,43 @@ public class ModuleProtocols extends IInternalFrame {
     }\r
 \r
     /**\r
-     * This method initializes jTextAreaFileList \r
-     *   \r
-     * @return javax.swing.JTextArea \r
-     */\r
-    private JTextArea getJTextAreaList() {\r
-        if (jTextAreaList == null) {\r
-            jTextAreaList = new JTextArea();\r
-            jTextAreaList.setEditable(false);\r
-\r
-        }\r
-        return jTextAreaList;\r
-    }\r
-\r
-    /**\r
-     * This method initializes jComboBoxProtocolType   \r
-     *         \r
-     * @return javax.swing.JComboBox   \r
-     */\r
-    private JComboBox getJComboBoxProtocolType() {\r
-        if (jComboBoxProtocolType == null) {\r
-            jComboBoxProtocolType = new JComboBox();\r
-            jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r
-            jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20));\r
-            jComboBoxProtocolType.addItemListener(this);\r
-            jComboBoxProtocolType.setToolTipText("Select Protocol Type");\r
-        }\r
-        return jComboBoxProtocolType;\r
-    }\r
-\r
-    /**\r
-     * This method initializes jComboBoxCName  \r
-     *         \r
-     * @return javax.swing.JComboBox   \r
-     */\r
-    private JComboBox getJComboBoxCName() {\r
-        if (jComboBoxCName == null) {\r
-            jComboBoxCName = new JComboBox();\r
-            jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r
-            jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));\r
-\r
-        }\r
-        return jComboBoxCName;\r
-    }\r
-\r
-    /**\r
-     This method initializes iCheckBoxListArch   \r
+     This method initializes jScrollPaneTable    \r
      \r
-     @return ICheckBoxList   \r
+     @return javax.swing.JScrollPane \r
      **/\r
-    private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r
-        if (iCheckBoxListArch == null) {\r
-            iCheckBoxListArch = new ICheckBoxList();\r
-            iCheckBoxListArch.addFocusListener(this);\r
-            iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
+    private JScrollPane getJScrollPaneTable() {\r
+        if (jScrollPaneTable == null) {\r
+            jScrollPaneTable = new JScrollPane();\r
+            jScrollPaneTable.setBounds(new java.awt.Rectangle(15, 10, 470, 420));\r
+            jScrollPaneTable.setPreferredSize(new Dimension(470, 420));\r
+            jScrollPaneTable.setViewportView(getJTable());\r
         }\r
-        return iCheckBoxListArch;\r
+        return jScrollPaneTable;\r
     }\r
 \r
     /**\r
-     This method initializes jScrollPaneArch \r
-     \r
-     @return javax.swing.JScrollPane \r
+     This method initializes jTable  \r
      \r
+     @return javax.swing.JTable  \r
      **/\r
-    private JScrollPane getJScrollPaneArch() {\r
-        if (jScrollPaneArch == null) {\r
-            jScrollPaneArch = new JScrollPane();\r
-            jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));\r
-            jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));\r
-            jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r
+    private JTable getJTable() {\r
+        if (jTable == null) {\r
+            jTable = new JTable();\r
+            model = new IDefaultTableModel();\r
+            jTable = new JTable(model);\r
+            jTable.setRowHeight(20);\r
+\r
+            model.addColumn("Guid C_Name");\r
+            model.addColumn("Type");\r
+            model.addColumn("Usage");\r
+\r
+            jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+            jTable.getSelectionModel().addListSelectionListener(this);\r
+            jTable.getModel().addTableModelListener(this);\r
+            jTable.addMouseListener(this);\r
         }\r
-        return jScrollPaneArch;\r
+        return jTable;\r
     }\r
-    \r
-    /**\r
-    This method initializes jTextFieldHelpText  \r
-    \r
-    @return javax.swing.JTextField  \r
-    \r
-    **/\r
-   private JTextField getJTextFieldHelpText() {\r
-       if (jTextFieldHelpText == null) {\r
-           jTextFieldHelpText = new JTextField();\r
-           jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));\r
-           jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));\r
-       }\r
-       return jTextFieldHelpText;\r
-   }\r
 \r
     public static void main(String[] args) {\r
 \r
@@ -358,8 +212,6 @@ public class ModuleProtocols extends IInternalFrame {
         this.setSize(500, 515);\r
         this.setContentPane(getJScrollPane());\r
         this.setTitle("Protocols");\r
-        initFrame();\r
-        this.setViewMode(false);\r
     }\r
 \r
     /**\r
@@ -380,9 +232,9 @@ public class ModuleProtocols extends IInternalFrame {
                     String arg1 = ed.getVProtocolType().get(0);\r
                     String arg2 = null;\r
                     if (protocols.getProtocolList().get(index).getUsage() != null) {\r
-                        arg2 = protocols.getProtocolList().get(index).getUsage().toString();    \r
+                        arg2 = protocols.getProtocolList().get(index).getUsage().toString();\r
                     }\r
-                    \r
+\r
                     String arg3 = protocols.getProtocolList().get(index).getFeatureFlag();\r
                     Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolList().get(index)\r
                                                                              .getSupArchList());\r
@@ -397,9 +249,9 @@ public class ModuleProtocols extends IInternalFrame {
                     String arg1 = ed.getVProtocolType().get(1);\r
                     String arg2 = null;\r
                     if (protocols.getProtocolNotifyList().get(index).getUsage() != null) {\r
-                        arg2 = protocols.getProtocolNotifyList().get(index).getUsage().toString();    \r
+                        arg2 = protocols.getProtocolNotifyList().get(index).getUsage().toString();\r
                     }\r
-                    \r
+\r
                     String arg3 = protocols.getProtocolNotifyList().get(index).getFeatureFlag();\r
                     Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolNotifyList().get(index)\r
                                                                              .getSupArchList());\r
@@ -409,11 +261,7 @@ public class ModuleProtocols extends IInternalFrame {
                 }\r
             }\r
         }\r
-        //\r
-        // Update the list\r
-        //\r
-        Tools.generateComboBoxByVector(jComboBoxList, vid.getProtocolsName());\r
-        reloadListArea();\r
+        showTable();\r
     }\r
 \r
     /**\r
@@ -440,19 +288,6 @@ public class ModuleProtocols extends IInternalFrame {
         this.setVisible(true);\r
     }\r
 \r
-    /**\r
-     Disable all components when the mode is view\r
-     \r
-     @param isView true - The view mode; false - The non-view mode\r
-     \r
-     **/\r
-    public void setViewMode(boolean isView) {\r
-        if (isView) {\r
-            this.jComboBoxUsage.setEnabled(!isView);\r
-            this.jTextFieldFeatureFlag.setEnabled(!isView);\r
-        }\r
-    }\r
-\r
     /**\r
      This method initializes jContentPane\r
      \r
@@ -461,69 +296,62 @@ public class ModuleProtocols extends IInternalFrame {
      **/\r
     private JPanel getJContentPane() {\r
         if (jContentPane == null) {\r
-            jLabelHelpText = new JLabel();\r
-            jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));\r
-            jLabelHelpText.setText("Help Text");\r
-            jLabelArch = new JLabel();\r
-            jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));\r
-            jLabelArch.setText("Arch Type");\r
-            jLabelProtocolType = new JLabel();\r
-            jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r
-            jLabelProtocolType.setText("Protocol Type");\r
-            jLabelUsage = new JLabel();\r
-            jLabelUsage.setText("Usage");\r
-            jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r
-            jLabelFeatureFlag = new JLabel();\r
-            jLabelFeatureFlag.setText("Feature Flag");\r
-            jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));\r
-            jLabelC_Name = new JLabel();\r
-            jLabelC_Name.setText("C_Name Type");\r
-            jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r
-\r
             jContentPane = new JPanel();\r
             jContentPane.setLayout(null);\r
-            jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));\r
-\r
-            jContentPane.add(jLabelC_Name, null);\r
-            jContentPane.add(jLabelFeatureFlag, null);\r
-            jContentPane.add(getJTextFieldFeatureFlag(), null);\r
-            jContentPane.add(jLabelUsage, null);\r
-            jContentPane.add(getJComboBoxProtocolUsage(), null);\r
-            jContentPane.add(jLabelProtocolType, null);\r
-\r
-            jStarLabel1 = new StarLabel();\r
-            jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));\r
-            jStarLabel2 = new StarLabel();\r
-            jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));\r
-\r
-            jContentPane.add(jStarLabel1, null);\r
-            jContentPane.add(jStarLabel2, null);\r
-            jContentPane.add(jLabelArch, null);\r
-            jContentPane.add(getJComboBoxList(), null);\r
+            jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));\r
+\r
             jContentPane.add(getJButtonAdd(), null);\r
             jContentPane.add(getJButtonRemove(), null);\r
             jContentPane.add(getJButtonUpdate(), null);\r
-            jContentPane.add(getJScrollPaneList(), null);\r
-\r
-            jContentPane.add(getJComboBoxProtocolType(), null);\r
-            jContentPane.add(getJComboBoxCName(), null);\r
-            jContentPane.add(getJScrollPaneArch(), null);\r
-            jContentPane.add(jLabelHelpText, null);\r
-            jContentPane.add(getJTextFieldHelpText(), null);\r
+            jContentPane.add(getJScrollPaneTable(), null);\r
         }\r
         return jContentPane;\r
     }\r
+    \r
+    private void showEdit(int index) {\r
+        ProtocolsDlg dlg = new ProtocolsDlg(vid.getProtocols(index), new IFrame());\r
+        int result = dlg.showDialog();\r
+        if (result == DataType.RETURN_TYPE_OK) {\r
+            if (index == -1) {\r
+                this.vid.addProtocols(dlg.getId());\r
+            } else {\r
+                this.vid.setProtocols(dlg.getId(), index);\r
+            }\r
+            this.showTable();\r
+            this.save();\r
+            dlg.dispose();\r
+        }\r
+        if (result == DataType.RETURN_TYPE_CANCEL) {\r
+            dlg.dispose();\r
+        }\r
+    }\r
+\r
+    /**\r
+     Clear all table rows\r
+     \r
+     **/\r
+    private void clearAll() {\r
+        if (model != null) {\r
+            for (int index = model.getRowCount() - 1; index >= 0; index--) {\r
+                model.removeRow(index);\r
+            }\r
+        }\r
+    }\r
 \r
     /**\r
-     This method initializes Usage type\r
+     Read content of vector and put then into table\r
      \r
      **/\r
-    private void initFrame() {\r
-        Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType());\r
-        Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllProtocolDeclarationsFromWorkspace());\r
-        Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage());\r
+    private void showTable() {\r
+        clearAll();\r
 \r
-        this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());\r
+        if (vid.size() > 0) {\r
+            for (int index = 0; index < vid.size(); index++) {\r
+                model.addRow(vid.toStringVector(index));\r
+            }\r
+        }\r
+        this.jTable.repaint();\r
+        this.jTable.updateUI();\r
     }\r
 \r
     /* (non-Javadoc)\r
@@ -534,55 +362,27 @@ public class ModuleProtocols extends IInternalFrame {
      */\r
     public void actionPerformed(ActionEvent arg0) {\r
         if (arg0.getSource() == jButtonAdd) {\r
-            if (!checkAdd()) {\r
-                return;\r
-            }\r
-            addToList();\r
-        }\r
-        if (arg0.getSource() == jButtonRemove) {\r
-            removeFromList();\r
+            showEdit(-1);\r
         }\r
         if (arg0.getSource() == jButtonUpdate) {\r
-            if (!checkAdd()) {\r
+            if (this.selectedRow < 0) {\r
+                Log.err("Please select one record first.");\r
                 return;\r
             }\r
-            updateForList();\r
+            showEdit(selectedRow);\r
         }\r
-    }\r
 \r
-    /**\r
-     Data validation for all fields\r
-     \r
-     @retval true - All datas are valid\r
-     @retval false - At least one data is invalid\r
-     \r
-     **/\r
-    public boolean checkAdd() {\r
-        //\r
-        // Check if all fields have correct data types \r
-        //\r
-\r
-        //\r
-        // Check Name \r
-        //\r
-        if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {\r
-            if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {\r
-                Log.err("Incorrect data type for Protocol/ProtocolNotify Name");\r
-                return false;\r
+        if (arg0.getSource() == jButtonRemove) {\r
+            if (jTable.isEditing()) {\r
+                jTable.getCellEditor().stopCellEditing();\r
             }\r
-        }\r
-        \r
-        //\r
-        // Check FeatureFlag\r
-        //\r
-        if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r
-            if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r
-                Log.err("Incorrect data type for Feature Flag");\r
-                return false;\r
+            if (selectedRow > -1) {\r
+                this.model.removeRow(selectedRow);\r
+                this.vid.removeProtocols(selectedRow);\r
+                selectedRow = -1;\r
+                this.save();\r
             }\r
         }\r
-\r
-        return true;\r
     }\r
 \r
     /**\r
@@ -650,204 +450,54 @@ public class ModuleProtocols extends IInternalFrame {
             Log.err("Update Protocols", e.getMessage());\r
         }\r
     }\r
-\r
+    \r
     /* (non-Javadoc)\r
-     * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r
-     * \r
-     * Override componentResized to resize all components when frame's size is changed\r
+     * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)\r
+     *\r
      */\r
-    public void componentResized(ComponentEvent arg0) {\r
-        int intCurrentWidth = this.getJContentPane().getWidth();\r
-        int intCurrentHeight = this.getJContentPane().getHeight();\r
-        int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r
-        int intPreferredHeight = this.getJContentPane().getPreferredSize().height;\r
-\r
-        resizeComponentWidth(this.jComboBoxProtocolType, intCurrentWidth, intPreferredWidth);\r
-        resizeComponentWidth(this.jComboBoxCName, intCurrentWidth, intPreferredWidth);\r
-        resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);\r
-        resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);\r
-        resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);\r
-        resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);\r
-\r
-        resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);\r
-        resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);\r
-\r
-        relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);\r
-        relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,\r
-                           DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);\r
-        relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,\r
-                           DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);\r
-    }\r
-\r
-    private ProtocolsIdentification getCurrentProtocols() {\r
-        String arg0 = this.jComboBoxCName.getSelectedItem().toString();\r
-        String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString();\r
-        String arg2 = this.jComboBoxUsage.getSelectedItem().toString();\r
-\r
-        String arg3 = this.jTextFieldFeatureFlag.getText();\r
-        Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();\r
-        String arg5 = this.jTextFieldHelpText.getText();\r
-        id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
-        return id;\r
-    }\r
-\r
-    /**\r
-     Add current item to Vector\r
-     \r
-     **/\r
-    private void addToList() {\r
-        intSelectedItemId = vid.size();\r
-\r
-        vid.addProtocols(getCurrentProtocols());\r
-\r
-        jComboBoxList.addItem(id.getName());\r
-        jComboBoxList.setSelectedItem(id.getName());\r
-\r
-        //\r
-        // Reset select item index\r
-        //\r
-        intSelectedItemId = vid.size();\r
-\r
-        //\r
-        // Reload all fields of selected item\r
-        //\r
-        reloadFromList();\r
-\r
-        // \r
-        // Save to memory\r
-        //\r
-        save();\r
-    }\r
-\r
-    /**\r
-     Remove current item from Vector\r
-     \r
-     **/\r
-    private void removeFromList() {\r
-        //\r
-        // Check if exist items\r
-        //\r
-        if (this.vid.size() < 1) {\r
+    public void valueChanged(ListSelectionEvent arg0) {\r
+        if (arg0.getValueIsAdjusting()) {\r
             return;\r
         }\r
-\r
-        int intTempIndex = intSelectedItemId;\r
-\r
-        jComboBoxList.removeItemAt(intSelectedItemId);\r
-\r
-        vid.removeProtocols(intTempIndex);\r
-\r
-        //\r
-        // Reload all fields of selected item\r
-        //\r
-        reloadFromList();\r
-\r
-        // \r
-        // Save to memory\r
-        //\r
-        save();\r
-    }\r
-\r
-    /**\r
-     Update current item of Vector\r
-     \r
-     **/\r
-    private void updateForList() {\r
-        //\r
-        // Check if exist items\r
-        //\r
-        if (this.vid.size() < 1) {\r
+        ListSelectionModel lsm = (ListSelectionModel) arg0.getSource();\r
+        if (lsm.isSelectionEmpty()) {\r
             return;\r
-        }\r
-\r
-        //\r
-        // Backup selected item index\r
-        //\r
-        int intTempIndex = intSelectedItemId;\r
-\r
-        vid.updateProtocols(getCurrentProtocols(), intTempIndex);\r
-\r
-        jComboBoxList.removeAllItems();\r
-        for (int index = 0; index < vid.size(); index++) {\r
-            jComboBoxList.addItem(vid.getProtocols(index).getName());\r
-        }\r
-\r
-        //\r
-        // Restore selected item index\r
-        //\r
-        intSelectedItemId = intTempIndex;\r
-\r
-        //\r
-        // Reset select item index\r
-        //\r
-        jComboBoxList.setSelectedIndex(intSelectedItemId);\r
-\r
-        //\r
-        // Reload all fields of selected item\r
-        //\r
-        reloadFromList();\r
-\r
-        // \r
-        // Save to memory\r
-        //\r
-        save();\r
-    }\r
-\r
-    /**\r
-     Refresh all fields' values of selected item of Vector\r
-     \r
-     **/\r
-    private void reloadFromList() {\r
-        if (vid.size() > 0) {\r
-            //\r
-            // Get selected item index\r
-            //\r
-            intSelectedItemId = jComboBoxList.getSelectedIndex();\r
-\r
-            this.jComboBoxCName.setSelectedItem(vid.getProtocols(intSelectedItemId).getName());\r
-            this.jComboBoxProtocolType.setSelectedItem(vid.getProtocols(intSelectedItemId).getType());\r
-            this.jComboBoxUsage.setSelectedItem(vid.getProtocols(intSelectedItemId).getUsage());\r
-            this.jTextFieldHelpText.setText(vid.getProtocols(intSelectedItemId).getHelp());\r
-            \r
-            jTextFieldFeatureFlag.setText(vid.getProtocols(intSelectedItemId).getFeatureFlag());\r
-            iCheckBoxListArch.setAllItemsUnchecked();\r
-            iCheckBoxListArch.initCheckedItem(true, vid.getProtocols(intSelectedItemId).getSupArchList());\r
-            \r
-\r
         } else {\r
+            selectedRow = lsm.getMinSelectionIndex();\r
         }\r
-\r
-        reloadListArea();\r
-    }\r
-\r
-    /**\r
-     Update list area pane via the elements of Vector\r
-     \r
-     **/\r
-    private void reloadListArea() {\r
-        String strListItem = "";\r
-        for (int index = 0; index < vid.size(); index++) {\r
-            strListItem = strListItem + vid.getProtocols(index).getName() + DataType.UNIX_LINE_SEPARATOR;\r
-        }\r
-        this.jTextAreaList.setText(strListItem);\r
     }\r
 \r
     /* (non-Javadoc)\r
-     * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)\r
+     * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)\r
      *\r
-     * Reflesh the frame when selected item changed\r
-     * \r
      */\r
-    public void itemStateChanged(ItemEvent arg0) {\r
-        if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {\r
-            reloadFromList();\r
-        }\r
-        if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) {\r
-            if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) {\r
-                Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage());\r
+    public void mouseClicked(MouseEvent arg0) {\r
+        if (arg0.getClickCount() == 2) {\r
+            if (this.selectedRow < 0) {\r
+                return;\r
             } else {\r
-                Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage());\r
+                showEdit(selectedRow);\r
             }\r
         }\r
     }\r
+\r
+    /* (non-Javadoc)\r
+     * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r
+     * \r
+     * Override componentResized to resize all components when frame's size is changed\r
+     */\r
+    public void componentResized(ComponentEvent arg0) {\r
+        int intCurrentWidth = this.getJContentPane().getWidth();\r
+        int intCurrentHeight = this.getJContentPane().getHeight();\r
+        int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r
+        int intPreferredHeight = this.getJContentPane().getPreferredSize().height;\r
+\r
+        resizeComponent(this.jScrollPaneTable, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);\r
+        relocateComponent(this.jButtonAdd, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,\r
+                          DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_ADD_BUTTON);\r
+        relocateComponent(this.jButtonRemove, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,\r
+                          DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_REMOVE_BUTTON);\r
+        relocateComponent(this.jButtonUpdate, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight,\r
+                          DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON, DataType.SPACE_TO_BOTTOM_FOR_UPDATE_BUTTON);\r
+    }\r
 }\r