+++ /dev/null
-/** @file\r
- \r
- The file is used to create, update Protocol of MSA/MBD file\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-\r
-package org.tianocore.packaging.module.ui;\r
-\r
-import java.awt.Dimension;\r
-import java.awt.event.ActionEvent;\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.JRadioButton;\r
-import javax.swing.JTextField;\r
-\r
-import org.tianocore.ProtocolNotifyUsage;\r
-import org.tianocore.ProtocolUsage;\r
-import org.tianocore.ProtocolsDocument;\r
-import org.tianocore.common.DataValidation;\r
-import org.tianocore.common.Log;\r
-import org.tianocore.common.Tools;\r
-import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;\r
-import org.tianocore.packaging.common.ui.IInternalFrame;\r
-import org.tianocore.packaging.common.ui.StarLabel;\r
-\r
-/**\r
- The class is used to create, update Protocol of MSA/MBD file\r
- It extends IInternalFrame\r
- \r
- @since ModuleEditor 1.0\r
-\r
- **/\r
-public class ModuleProtocols extends IInternalFrame {\r
-\r
- ///\r
- /// Define class Serial Version UID\r
- ///\r
- private static final long serialVersionUID = -9084913640747858848L;\r
-\r
- //\r
- //Define class members\r
- //\r
- private ProtocolsDocument.Protocols protocols = null;\r
-\r
- private int location = -1;\r
-\r
- private JPanel jContentPane = null;\r
-\r
- private JLabel jLabelC_Name = null;\r
-\r
- private JTextField jTextFieldC_Name = null;\r
-\r
- private JLabel jLabelGuid = null;\r
-\r
- private JTextField jTextFieldGuid = null;\r
-\r
- private JLabel jLabelFeatureFlag = null;\r
-\r
- private JTextField jTextFieldFeatureFlag = null;\r
-\r
- private JButton jButtonOk = null;\r
-\r
- private JButton jButtonCancel = null;\r
-\r
- private JLabel jLabelUsage = null;\r
-\r
- private JComboBox jComboBoxUsage = null;\r
-\r
- private JLabel jLabelEnableFeature = null;\r
-\r
- private JRadioButton jRadioButtonEnableFeature = null;\r
-\r
- private JRadioButton jRadioButtonDisableFeature = null;\r
-\r
- private JRadioButton jRadioButtonProtocol = null;\r
-\r
- private JRadioButton jRadioButtonProtocolNotify = null;\r
-\r
- private JButton jButtonGenerateGuid = null;\r
-\r
- private JLabel jLabelOverrideID = null;\r
-\r
- private JTextField jTextFieldOverrideID = null;\r
-\r
- private StarLabel jStarLabel1 = null;\r
-\r
- private StarLabel jStarLabel2 = null;\r
-\r
- private JLabel jLabelProtocolType = null;\r
-\r
- /**\r
- This method initializes jTextFieldC_Name \r
- \r
- @return javax.swing.JTextField jTextFieldC_Name\r
- \r
- **/\r
- private JTextField getJTextFieldProtocolName() {\r
- if (jTextFieldC_Name == null) {\r
- jTextFieldC_Name = new JTextField();\r
- jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r
- }\r
- return jTextFieldC_Name;\r
- }\r
-\r
- /**\r
- This method initializes jTextFieldGuid \r
- \r
- @return javax.swing.JTextField jTextFieldGuid\r
- \r
- **/\r
- private JTextField getJTextFieldGuid() {\r
- if (jTextFieldGuid == null) {\r
- jTextFieldGuid = new JTextField();\r
- jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 250, 20));\r
- }\r
- return jTextFieldGuid;\r
- }\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, 135, 320, 20));\r
- }\r
- return jTextFieldFeatureFlag;\r
- }\r
-\r
- /**\r
- This method initializes jButtonOk \r
- \r
- @return javax.swing.JButton jButtonOk\r
- \r
- **/\r
- private JButton getJButtonOk() {\r
- if (jButtonOk == null) {\r
- jButtonOk = new JButton();\r
- jButtonOk.setText("OK");\r
- jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));\r
- jButtonOk.addActionListener(this);\r
- }\r
- return jButtonOk;\r
- }\r
-\r
- /**\r
- This method initializes jButtonCancel \r
- \r
- @return javax.swing.JButton jButtonCancel\r
- \r
- **/\r
- private JButton getJButtonCancel() {\r
- if (jButtonCancel == null) {\r
- jButtonCancel = new JButton();\r
- jButtonCancel.setText("Cancel");\r
- jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));\r
- jButtonCancel.setPreferredSize(new Dimension(90, 20));\r
- jButtonCancel.addActionListener(this);\r
- }\r
- return jButtonCancel;\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, 85, 320, 20));\r
- }\r
- return jComboBoxUsage;\r
- }\r
-\r
- /**\r
- This method initializes jRadioButtonEnableFeature \r
- \r
- @return javax.swing.JRadioButton jRadioButtonEnableFeature\r
- \r
- **/\r
- private JRadioButton getJRadioButtonEnableFeature() {\r
- if (jRadioButtonEnableFeature == null) {\r
- jRadioButtonEnableFeature = new JRadioButton();\r
- jRadioButtonEnableFeature.setText("Enable");\r
- jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 110, 90, 20));\r
- jRadioButtonEnableFeature.addActionListener(this);\r
- jRadioButtonEnableFeature.setSelected(true);\r
- }\r
- return jRadioButtonEnableFeature;\r
- }\r
-\r
- /**\r
- This method initializes jRadioButtonDisableFeature \r
- \r
- @return javax.swing.JRadioButton jRadioButtonDisableFeature\r
- \r
- **/\r
- private JRadioButton getJRadioButtonDisableFeature() {\r
- if (jRadioButtonDisableFeature == null) {\r
- jRadioButtonDisableFeature = new JRadioButton();\r
- jRadioButtonDisableFeature.setText("Disable");\r
- jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 110, 90, 20));\r
- jRadioButtonDisableFeature.addActionListener(this);\r
- }\r
- return jRadioButtonDisableFeature;\r
- }\r
-\r
- /**\r
- This method initializes jRadioButtonProtocol \r
- \r
- @return javax.swing.JRadioButton jRadioButtonProtocol\r
- \r
- **/\r
- private JRadioButton getJRadioButtonProtocol() {\r
- if (jRadioButtonProtocol == null) {\r
- jRadioButtonProtocol = new JRadioButton();\r
- jRadioButtonProtocol.setText("Protocol");\r
- jRadioButtonProtocol.setBounds(new java.awt.Rectangle(160, 10, 90, 20));\r
- jRadioButtonProtocol.setSelected(true);\r
- jRadioButtonProtocol.addActionListener(this);\r
- }\r
- return jRadioButtonProtocol;\r
- }\r
-\r
- /**\r
- This method initializes jRadioButtonProtocolNotify \r
- \r
- @return javax.swing.JRadioButton jRadioButtonProtocolNotify\r
- \r
- **/\r
- private JRadioButton getJRadioButtonProtocolNotify() {\r
- if (jRadioButtonProtocolNotify == null) {\r
- jRadioButtonProtocolNotify = new JRadioButton();\r
- jRadioButtonProtocolNotify.setText("Protocol Notify");\r
- jRadioButtonProtocolNotify.setBounds(new java.awt.Rectangle(320, 10, 120, 20));\r
- jRadioButtonProtocolNotify.addActionListener(this);\r
- }\r
- return jRadioButtonProtocolNotify;\r
- }\r
-\r
- /**\r
- This method initializes jButtonGenerateGuid \r
- \r
- @return javax.swing.JButton jButtonGenerateGuid\r
- \r
- **/\r
- private JButton getJButtonGenerateGuid() {\r
- if (jButtonGenerateGuid == null) {\r
- jButtonGenerateGuid = new JButton();\r
- jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 60, 65, 20));\r
- jButtonGenerateGuid.setText("GEN");\r
- jButtonGenerateGuid.addActionListener(this);\r
- }\r
- return jButtonGenerateGuid;\r
- }\r
-\r
- /**\r
- This method initializes jTextFieldOverrideID \r
- \r
- @return javax.swing.JTextField jTextFieldOverrideID\r
- \r
- **/\r
- private JTextField getJTextFieldOverrideID() {\r
- if (jTextFieldOverrideID == null) {\r
- jTextFieldOverrideID = new JTextField();\r
- jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 50, 20));\r
- }\r
- return jTextFieldOverrideID;\r
- }\r
-\r
- public static void main(String[] args) {\r
-\r
- }\r
-\r
- /**\r
- This is the default constructor\r
- \r
- **/\r
- public ModuleProtocols() {\r
- super();\r
- init();\r
- this.setVisible(true);\r
- }\r
-\r
- /**\r
- This is the override edit constructor\r
- \r
- @param inProtocol The input data of ProtocolsDocument.Protocols\r
- \r
- **/\r
- public ModuleProtocols(ProtocolsDocument.Protocols inProtocol) {\r
- super();\r
- init(inProtocol);\r
- this.setVisible(true);\r
- }\r
-\r
- /**\r
- This is the override edit constructor\r
- \r
- @param inProtocol The input data of ProtocolsDocument.Protocols\r
- @param type The input data of node type\r
- @param index The input data of node index\r
- \r
- **/\r
- public ModuleProtocols(ProtocolsDocument.Protocols inProtocol, int type, int index) {\r
- super();\r
- init(inProtocol, type, index);\r
- this.setVisible(true);\r
- }\r
-\r
- /**\r
- This method initializes this\r
- \r
- @param inProtocol The input data of ProtocolsDocument.Protocols\r
- \r
- **/\r
- private void init(ProtocolsDocument.Protocols inProtocol) {\r
- init();\r
- this.setProtocols(inProtocol);\r
- }\r
-\r
- /**\r
- This method initializes this\r
- Fill values to all fields if these values are not empty\r
- \r
- @param inProtocol The input data of ProtocolsDocument.Protocols\r
- @param type The input data of node type\r
- @param index The input data of node index\r
- \r
- **/\r
- private void init(ProtocolsDocument.Protocols inProtocol, int type, int index) {\r
- init(inProtocol);\r
- this.location = index;\r
- if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM) {\r
- this.jRadioButtonProtocol.setSelected(true);\r
- this.jRadioButtonProtocolNotify.setSelected(false);\r
- if (this.protocols.getProtocolArray(index).getStringValue() != null) {\r
- this.jTextFieldC_Name.setText(this.protocols.getProtocolArray(index).getStringValue());\r
- }\r
- if (this.protocols.getProtocolArray(index).getGuid() != null) {\r
- this.jTextFieldGuid.setText(this.protocols.getProtocolArray(index).getGuid());\r
- }\r
- if (this.protocols.getProtocolArray(index).getUsage() != null) {\r
- this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolArray(index).getUsage().toString());\r
- }\r
- this.jRadioButtonEnableFeature.setSelected(this.protocols.getProtocolArray(index).getEnableFeature());\r
- this.jRadioButtonDisableFeature.setSelected(!this.protocols.getProtocolArray(index).getEnableFeature());\r
- if (this.protocols.getProtocolArray(index).getFeatureFlag() != null) {\r
- this.jTextFieldFeatureFlag.setText(this.protocols.getProtocolArray(index).getFeatureFlag());\r
- }\r
- this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolArray(index).getOverrideID()));\r
- } else if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) {\r
- this.jRadioButtonProtocol.setSelected(false);\r
- this.jRadioButtonProtocolNotify.setSelected(true);\r
- this.jTextFieldFeatureFlag.setEditable(false);\r
- this.jRadioButtonDisableFeature.setEnabled(false);\r
- this.jRadioButtonEnableFeature.setEnabled(false);\r
- this.jComboBoxUsage.setEnabled(false);\r
- if (this.protocols.getProtocolNotifyArray(index).getStringValue() != null) {\r
- this.jTextFieldC_Name.setText(this.protocols.getProtocolNotifyArray(index).getStringValue());\r
- }\r
- if (this.protocols.getProtocolNotifyArray(index).getGuid() != null) {\r
- this.jTextFieldGuid.setText(this.protocols.getProtocolNotifyArray(index).getGuid());\r
- }\r
- if (this.protocols.getProtocolNotifyArray(index).getUsage() != null) {\r
- this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolNotifyArray(index).getUsage().toString());\r
- }\r
- this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolNotifyArray(index)\r
- .getOverrideID()));\r
- }\r
- this.jRadioButtonProtocol.setEnabled(false);\r
- this.jRadioButtonProtocolNotify.setEnabled(false);\r
- }\r
-\r
- /**\r
- This method initializes this\r
- \r
- **/\r
- private void init() {\r
- this.setSize(500, 515);\r
- this.setName("JFrame");\r
- this.setContentPane(getJContentPane());\r
- this.setTitle("Protocols");\r
- initFrame();\r
- this.setViewMode(false);\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
- this.jButtonOk.setVisible(false);\r
- this.jButtonCancel.setVisible(false);\r
- if (isView) {\r
- this.jRadioButtonProtocol.setEnabled(!isView);\r
- this.jRadioButtonProtocolNotify.setEnabled(!isView);\r
- this.jTextFieldC_Name.setEnabled(!isView);\r
- this.jTextFieldGuid.setEnabled(!isView);\r
- this.jComboBoxUsage.setEnabled(!isView);\r
- this.jRadioButtonEnableFeature.setEnabled(!isView);\r
- this.jRadioButtonDisableFeature.setEnabled(!isView);\r
- this.jTextFieldFeatureFlag.setEnabled(!isView);\r
- this.jTextFieldOverrideID.setEnabled(!isView);\r
- this.jButtonGenerateGuid.setEnabled(!isView);\r
- }\r
- }\r
-\r
- /**\r
- This method initializes jContentPane\r
- \r
- @return javax.swing.JPanel jContentPane\r
- \r
- **/\r
- private JPanel getJContentPane() {\r
- if (jContentPane == null) {\r
- jLabelProtocolType = new JLabel();\r
- jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r
- jLabelProtocolType.setText("Protocol Type");\r
- jLabelOverrideID = new JLabel();\r
- jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));\r
- jLabelOverrideID.setText("Override ID");\r
- jLabelEnableFeature = new JLabel();\r
- jLabelEnableFeature.setText("Enable Feature");\r
- jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 110, 140, 20));\r
- jLabelUsage = new JLabel();\r
- jLabelUsage.setText("Usage");\r
- jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));\r
- jLabelFeatureFlag = new JLabel();\r
- jLabelFeatureFlag.setText("Feature Flag");\r
- jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));\r
- jLabelGuid = new JLabel();\r
- jLabelGuid.setText("Guid");\r
- jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r
- jLabelC_Name = new JLabel();\r
- jLabelC_Name.setText("C_Name");\r
- jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r
- jContentPane = new JPanel();\r
- jContentPane.setLayout(null);\r
- jContentPane.add(jLabelC_Name, null);\r
- jContentPane.add(getJTextFieldProtocolName(), null);\r
- jContentPane.add(jLabelGuid, null);\r
- jContentPane.add(getJTextFieldGuid(), null);\r
- jContentPane.add(jLabelFeatureFlag, null);\r
- jContentPane.add(getJTextFieldFeatureFlag(), null);\r
- jContentPane.add(getJButtonOk(), null);\r
- jContentPane.add(getJButtonCancel(), null);\r
- jContentPane.add(jLabelUsage, null);\r
- jContentPane.add(getJComboBoxProtocolUsage(), null);\r
- jContentPane.add(jLabelEnableFeature, null);\r
- jContentPane.add(getJRadioButtonEnableFeature(), null);\r
- jContentPane.add(getJRadioButtonDisableFeature(), null);\r
- jContentPane.add(getJRadioButtonProtocol(), null);\r
- jContentPane.add(getJRadioButtonProtocolNotify(), null);\r
- jContentPane.add(getJButtonGenerateGuid(), null);\r
- jContentPane.add(jLabelOverrideID, null);\r
- jContentPane.add(getJTextFieldOverrideID(), 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
- }\r
- return jContentPane;\r
- }\r
-\r
- /**\r
- This method initializes Usage type\r
- \r
- **/\r
- private void initFrame() {\r
- jComboBoxUsage.addItem("ALWAYS_CONSUMED");\r
- jComboBoxUsage.addItem("SOMETIMES_CONSUMED");\r
- jComboBoxUsage.addItem("ALWAYS_PRODUCED");\r
- jComboBoxUsage.addItem("SOMETIMES_PRODUCED");\r
- jComboBoxUsage.addItem("TO_START");\r
- jComboBoxUsage.addItem("BY_START");\r
- jComboBoxUsage.addItem("PRIVATE");\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
- *\r
- * Override actionPerformed to listen all actions\r
- * \r
- */\r
- public void actionPerformed(ActionEvent arg0) {\r
- if (arg0.getSource() == jButtonOk) {\r
- this.setEdited(true);\r
- this.save();\r
- this.dispose();\r
- }\r
- if (arg0.getSource() == jButtonCancel) {\r
- this.dispose();\r
- }\r
-\r
- //\r
- // Contorl the selected status when click RadionButton\r
- // Do not use Radio Button Group\r
- //\r
- if (arg0.getSource() == jRadioButtonProtocol) {\r
- if (jRadioButtonProtocol.isSelected()) {\r
- jRadioButtonProtocolNotify.setSelected(false);\r
- jRadioButtonEnableFeature.setEnabled(true);\r
- jRadioButtonDisableFeature.setEnabled(true);\r
- jTextFieldFeatureFlag.setEnabled(true);\r
- jComboBoxUsage.setEnabled(true);\r
- }\r
- if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {\r
- jRadioButtonProtocol.setSelected(true);\r
- jRadioButtonEnableFeature.setEnabled(true);\r
- jRadioButtonDisableFeature.setEnabled(true);\r
- jTextFieldFeatureFlag.setEnabled(true);\r
- jComboBoxUsage.setEnabled(true);\r
- }\r
- }\r
-\r
- if (arg0.getSource() == jRadioButtonProtocolNotify) {\r
- if (jRadioButtonProtocolNotify.isSelected()) {\r
- jRadioButtonProtocol.setSelected(false);\r
- jRadioButtonEnableFeature.setEnabled(false);\r
- jRadioButtonDisableFeature.setEnabled(false);\r
- jTextFieldFeatureFlag.setEnabled(false);\r
- jComboBoxUsage.setSelectedIndex(1);\r
- jComboBoxUsage.setEnabled(false);\r
- }\r
- if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {\r
- jRadioButtonProtocolNotify.setSelected(true);\r
- jRadioButtonEnableFeature.setEnabled(false);\r
- jRadioButtonDisableFeature.setEnabled(false);\r
- jTextFieldFeatureFlag.setEnabled(false);\r
- jComboBoxUsage.setSelectedIndex(1);\r
- jComboBoxUsage.setEnabled(false);\r
- }\r
- }\r
-\r
- //\r
- // Contorl the selected status when click RadionButton\r
- // Do not use Radio Button Group\r
- //\r
- if (arg0.getSource() == jRadioButtonEnableFeature) {\r
- if (jRadioButtonEnableFeature.isSelected()) {\r
- jRadioButtonDisableFeature.setSelected(false);\r
- }\r
- if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r
- jRadioButtonEnableFeature.setSelected(true);\r
- }\r
- }\r
-\r
- if (arg0.getSource() == jRadioButtonDisableFeature) {\r
- if (jRadioButtonDisableFeature.isSelected()) {\r
- jRadioButtonEnableFeature.setSelected(false);\r
- }\r
- if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r
- jRadioButtonDisableFeature.setSelected(true);\r
- }\r
- }\r
-\r
- if (arg0.getSource() == jButtonGenerateGuid) {\r
- jTextFieldGuid.setText(Tools.generateUuidString());\r
- }\r
- }\r
-\r
- /**\r
- Get ProtocolsDocument.Protocols\r
- \r
- @return ProtocolsDocument.Protocols\r
- \r
- **/\r
- public ProtocolsDocument.Protocols getProtocols() {\r
- return protocols;\r
- }\r
-\r
- /**\r
- Set ProtocolsDocument.Protocols\r
- \r
- @param protocols The input data of ProtocolsDocument.Protocols\r
- \r
- **/\r
- public void setProtocols(ProtocolsDocument.Protocols protocols) {\r
- this.protocols = protocols;\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 check() {\r
- //\r
- // Check if all required fields are not empty\r
- //\r
- if (isEmpty(this.jTextFieldC_Name.getText())) {\r
- Log.err("C_Name couldn't be empty");\r
- return false;\r
- }\r
-\r
- //\r
- // Check if all fields have correct data types \r
- //\r
- if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {\r
- Log.err("Incorrect data type for C_Name");\r
- return false;\r
- }\r
- if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
- Log.err("Incorrect data type for Guid");\r
- return false;\r
- }\r
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())\r
- && !DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r
- Log.err("Incorrect data type for Feature Flag");\r
- return false;\r
- }\r
- if (!isEmpty(this.jTextFieldOverrideID.getText())\r
- && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {\r
- Log.err("Incorrect data type for Override ID");\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
- /**\r
- Save all components of Protocols\r
- if exists protocols, set the value directly\r
- if not exists protocols, new an instance first\r
- \r
- **/\r
- public void save() {\r
- try {\r
- if (this.protocols == null) {\r
- protocols = ProtocolsDocument.Protocols.Factory.newInstance();\r
- }\r
- if (this.jRadioButtonProtocol.isSelected()) {\r
- ProtocolsDocument.Protocols.Protocol protocol = ProtocolsDocument.Protocols.Protocol.Factory\r
- .newInstance();\r
- protocol.setStringValue(this.jTextFieldC_Name.getText());\r
- if (!isEmpty(this.jTextFieldGuid.getText())) {\r
- protocol.setGuid(this.jTextFieldGuid.getText());\r
- }\r
- protocol.setUsage(ProtocolUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));\r
- protocol.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());\r
- if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r
- protocol.setFeatureFlag(this.jTextFieldFeatureFlag.getText());\r
- }\r
- if (!isEmpty(this.jTextFieldOverrideID.getText())) {\r
- protocol.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));\r
- }\r
- if (location > -1) {\r
- protocols.setProtocolArray(location, protocol);\r
- } else {\r
- protocols.addNewProtocol();\r
- protocols.setProtocolArray(protocols.getProtocolList().size() - 1, protocol);\r
- }\r
- }\r
- if (this.jRadioButtonProtocolNotify.isSelected()) {\r
- ProtocolsDocument.Protocols.ProtocolNotify protocolNofity = ProtocolsDocument.Protocols.ProtocolNotify.Factory\r
- .newInstance();\r
- protocolNofity.setStringValue(this.jTextFieldC_Name.getText());\r
- if (!isEmpty(this.jTextFieldGuid.getText())) {\r
- protocolNofity.setGuid(this.jTextFieldGuid.getText());\r
- }\r
- protocolNofity\r
- .setUsage(ProtocolNotifyUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));\r
-\r
- if (!isEmpty(this.jTextFieldOverrideID.getText())) {\r
- protocolNofity.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));\r
- }\r
- if (location > -1) {\r
- protocols.setProtocolNotifyArray(location, protocolNofity);\r
- } else {\r
- protocols.addNewProtocolNotify();\r
- protocols.setProtocolNotifyArray(protocols.getProtocolNotifyList().size() - 1, protocolNofity);\r
- }\r
- }\r
- } catch (Exception e) {\r
- Log.err("Update Protocols", e.getMessage());\r
- }\r
- }\r
-}\r