From 7ab6baa9de2937578a96719eeaba0b4706bd8579 Mon Sep 17 00:00:00 2001 From: lhauch Date: Fri, 28 Jul 2006 00:17:23 +0000 Subject: [PATCH] Fixed Absolute position of fields, Added ToolTipText and made HelpText a Scrolling Text Area git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1129 6f19259b-4bc3-4df7-8a09-765794883524 --- .../module/ui/dialog/EventsDlg.java | 808 +++++++++--------- .../module/ui/dialog/ProtocolsDlg.java | 771 +++++++++-------- 2 files changed, 834 insertions(+), 745 deletions(-) diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java index 3c008504d1..d16057b4b1 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/EventsDlg.java @@ -23,6 +23,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; +import javax.swing.JTextArea; import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataValidation; @@ -37,434 +38,475 @@ import org.tianocore.frameworkwizard.module.Identifications.Events.EventsIdentif import org.tianocore.frameworkwizard.workspace.WorkspaceTools; /** - The class is used to create, update Event of MSA/MBD file - It extends IInternalFrame - - @since ModuleEditor 1.0 - - **/ + * The class is used to create, update Event of MSA/MBD file It extends + * IInternalFrame + * + * @since ModuleEditor 1.0 + * + */ public class EventsDlg extends IDialog { - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = -4396143706422842331L; + // / + // / Define class Serial Version UID + // / + private static final long serialVersionUID = -4396143706422842331L; - // - //Define class members - // - private JPanel jContentPane = null; + // + // Define class members + // + private JPanel jContentPane = null; - private JLabel jLabelEventType = null; + private JLabel jLabelEventType = null; - private JLabel jLabelC_Name = null; + private JLabel jLabelC_Name = null; - private JComboBox jComboBoxGuidC_Name = null; + private JComboBox jComboBoxGuidC_Name = null; - private JLabel jLabelUsage = null; - - private JLabel jLabelGroup = null; + private JLabel jLabelUsage = null; - private JComboBox jComboBoxUsage = null; - - private JComboBox jComboBoxEventGroup = null; + private JLabel jLabelGroup = null; - private StarLabel jStarLabel1 = null; + private JComboBox jComboBoxUsage = null; - private StarLabel jStarLabel2 = null; - - private StarLabel jStarLabel3 = null; + private JComboBox jComboBoxEventGroup = null; - private JComboBox jComboBoxEventsType = null; + private StarLabel jStarLabel1 = null; - private JScrollPane jScrollPane = null; + private StarLabel jStarLabel2 = null; - private JLabel jLabelArch = null; + private StarLabel jStarLabel3 = null; - private JLabel jLabelHelpText = null; + private StarLabel jStarLabel4 = null; - private JTextField jTextFieldHelpText = null; + private JComboBox jComboBoxEventsType = null; - private JLabel jLabelFeatureFlag = null; + private JScrollPane jScrollPane = null; - private JTextField jTextFieldFeatureFlag = null; + private JLabel jLabelArch = null; - private ArchCheckBox jArchCheckBox = null; + private JLabel jLabelHelpText = null; - private JButton jButtonOk = null; + private JTextArea jTextAreaHelpText = null; - private JButton jButtonCancel = null; + private JScrollPane jScrollPaneHelpText = null; - // - // Not used by UI - // - private EventsIdentification id = null; - - private EnumerationData ed = new EnumerationData(); - - private WorkspaceTools wt = new WorkspaceTools(); - - /** - This method initializes jTextFieldC_Name - - @return javax.swing.JTextField jTextFieldC_Name - - **/ - private JComboBox getJComboBoxGuidC_Name() { - if (jComboBoxGuidC_Name == null) { - jComboBoxGuidC_Name = new JComboBox(); - jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); - jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event"); - } - return jComboBoxGuidC_Name; - } + private JLabel jLabelFeatureFlag = null; - /** - This method initializes jComboBoxUsage - - @return javax.swing.JComboBox jComboBoxUsage - - **/ - private JComboBox getJComboBoxUsage() { - if (jComboBoxUsage == null) { - jComboBoxUsage = new JComboBox(); - jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20)); - jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20)); - } - return jComboBoxUsage; - } - - /** - This method initializes jComboBoxType - - @return javax.swing.JComboBox jComboBoxType - - **/ - private JComboBox getJComboBoxEventsType() { - if (jComboBoxEventsType == null) { - jComboBoxEventsType = new JComboBox(); - jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); - jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxEventsType - .setToolTipText("Select CreateEvents if the Module has an event that is waiting to be signaled.
Select SignalEvents if the Module will signal all events in an event group.
NOTE: Signal events are named by GUID."); - } - return jComboBoxEventsType; - } - - /** - * This method initializes jComboBoxEventsType - * - * @return javax.swing.JComboBox - */ - private JComboBox getJComboBoxEventGroup() { - if (jComboBoxEventGroup == null) { - jComboBoxEventGroup = new JComboBox(); - jComboBoxEventGroup.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); - jComboBoxEventGroup.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxEventGroup.setToolTipText("Select Type of Event, Guid or Timer."); - - } - return jComboBoxEventGroup; - } + private JTextField jTextFieldFeatureFlag = null; - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - */ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(getJContentPane()); - } - return jScrollPane; - } + private ArchCheckBox jArchCheckBox = null; - /** - * This method initializes jTextFieldFeatureFlag - * - * @return javax.swing.JTextField - */ - private JTextField getJTextFieldFeatureFlag() { - if (jTextFieldFeatureFlag == null) { - jTextFieldFeatureFlag = new JTextField(); - jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20)); - jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20)); - } - return jTextFieldFeatureFlag; - } + private JButton jButtonOk = null; - /** - This method initializes jTextFieldHelpText - - @return javax.swing.JTextField - - **/ - private JTextField getJTextFieldHelpText() { - if (jTextFieldHelpText == null) { - jTextFieldHelpText = new JTextField(); - jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 110, 320, 20)); - jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20)); - } - return jTextFieldHelpText; - } + private JButton jButtonCancel = null; - /** - This method initializes jButtonOk - - @return javax.swing.JButton - - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20)); - jButtonOk.setText("Ok"); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } + // + // Not used by UI + // + private EventsIdentification id = null; - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20)); - jButtonCancel.setText("Cancel"); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } + private EnumerationData ed = new EnumerationData(); - public static void main(String[] args) { + private WorkspaceTools wt = new WorkspaceTools(); + /** + * This method initializes jComboBoxType + * + * @return javax.swing.JComboBox jComboBoxType + * + */ + private JComboBox getJComboBoxEventsType() { + if (jComboBoxEventsType == null) { + jComboBoxEventsType = new JComboBox(); + jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); + jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxEventsType + .setToolTipText("Select CreateEvents if the Module has an event that is waiting to be signaled.
Select SignalEvents if the Module will signal all events in an event group.
NOTE: Signal events are named by GUID."); } - - /** - This method initializes this - - **/ - private void init() { - this.setSize(508, 265); - this.setContentPane(getJScrollPane()); - this.setTitle("Events"); - initFrame(); - this.setViewMode(false); - this.centerWindow(); + return jComboBoxEventsType; + } + + /** + * This method initializes jTextFieldC_Name + * + * @return javax.swing.JTextField jTextFieldC_Name + * + */ + private JComboBox getJComboBoxGuidC_Name() { + if (jComboBoxGuidC_Name == null) { + jComboBoxGuidC_Name = new JComboBox(); + jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); + jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the Event"); } + return jComboBoxGuidC_Name; + } + + /** + * This method initializes jComboBoxEventsType + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBoxEventGroup() { + if (jComboBoxEventGroup == null) { + jComboBoxEventGroup = new JComboBox(); + jComboBoxEventGroup.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); + jComboBoxEventGroup.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxEventGroup + .setToolTipText("Select Type of Event: Guid or Timer."); - /** - This method initializes this - Fill values to all fields if these values are not empty - - @param inEventsId - - **/ - private void init(EventsIdentification inEventsId) { - init(); - this.id = inEventsId; - - if (this.id != null) { - this.jComboBoxGuidC_Name.setSelectedItem(id.getName()); - this.jComboBoxEventsType.setSelectedItem(id.getType()); - this.jComboBoxUsage.setSelectedItem(id.getUsage()); - this.jTextFieldHelpText.setText(id.getHelp()); - - jTextFieldFeatureFlag.setText(id.getFeatureFlag()); - this.jArchCheckBox.setSelectedItems(id.getSupArchList()); - this.jComboBoxEventGroup.setSelectedItem(id.getGroup()); - } } - - /** - This is the override edit constructor - - @param inEventsIdentification - @param iFrame - - **/ - public EventsDlg(EventsIdentification inEventsIdentification, IFrame iFrame) { - super(iFrame, true); - init(inEventsIdentification); + return jComboBoxEventGroup; + } + + /** + * This method initializes jComboBoxUsage + * + * @return javax.swing.JComboBox jComboBoxUsage + * + */ + private JComboBox getJComboBoxUsage() { + if (jComboBoxUsage == null) { + jComboBoxUsage = new JComboBox(); + jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20)); + jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxUsage + .setToolTipText("
Create Events
ALWAYS_CONSUMEDModule registers a notification function and REQUIRES that it be
executed for the module to fully function.
SOMETIMES_CONSUMEDModule registers a notification function and calls the function
when it is signaled
Signal Events
ALWAYS_PRODUCEDModule will Always signal the event
SOMETIMES_PRODUCEDModule will sometimes signal the event
"); } - - /** - Disable all components when the mode is view - - @param isView true - The view mode; false - The non-view mode - - **/ - public void setViewMode(boolean isView) { - if (isView) { - this.jComboBoxGuidC_Name.setEnabled(!isView); - this.jComboBoxUsage.setEnabled(!isView); - } + return jComboBoxUsage; + } + + /** + * This method initializes jScrollPane + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane() { + if (jScrollPane == null) { + jScrollPane = new JScrollPane(); + jScrollPane.setViewportView(getJContentPane()); } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel jContentPane - - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jArchCheckBox = new ArchCheckBox(); - jArchCheckBox.setBounds(new java.awt.Rectangle(160, 160, 320, 20)); - jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20)); - jLabelFeatureFlag = new JLabel(); - jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20)); - jLabelFeatureFlag.setText("Feature Flag"); - jLabelArch = new JLabel(); - jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20)); - jLabelArch.setText("Arch"); - jLabelUsage = new JLabel(); - jLabelUsage.setText("Usage"); - jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20)); - jLabelC_Name = new JLabel(); - jLabelC_Name.setText("Guid C Name"); - jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); - jLabelGroup = new JLabel(); - jLabelGroup.setText("Event Type"); - jLabelGroup.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); - jLabelEventType = new JLabel(); - jLabelEventType.setText("Type"); - jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); - jLabelHelpText = new JLabel(); - jLabelHelpText.setBounds(new java.awt.Rectangle(14, 110, 140, 20)); - jLabelHelpText.setText("Help Text"); - - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.setPreferredSize(new java.awt.Dimension(490, 220)); - - jContentPane.add(jLabelEventType, null); - jContentPane.add(jLabelGroup, null); - jContentPane.add(jLabelC_Name, null); - jContentPane.add(getJComboBoxGuidC_Name(), null); - jContentPane.add(jLabelUsage, null); - jContentPane.add(getJComboBoxUsage(), null); - jStarLabel1 = new StarLabel(); - jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20)); - jStarLabel2 = new StarLabel(); - jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20)); - jStarLabel3 = new StarLabel(); - jStarLabel3.setBounds(new java.awt.Rectangle(0, 60, 10, 20)); - - jContentPane.add(jStarLabel1, null); - jContentPane.add(jStarLabel2, null); - jContentPane.add(jStarLabel3, null); - jContentPane.add(getJComboBoxEventsType(), null); - - jContentPane.add(jLabelArch, null); - jContentPane.add(jLabelFeatureFlag, null); - jContentPane.add(getJTextFieldFeatureFlag(), null); - jContentPane.add(jLabelHelpText, null); - jContentPane.add(getJTextFieldHelpText(), null); - jContentPane.add(jArchCheckBox, null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJComboBoxEventGroup(), null); - } - return jContentPane; + return jScrollPane; + } + + /** + * This method initializes jTextFieldFeatureFlag + * + * @return javax.swing.JTextField + */ + private JTextField getJTextFieldFeatureFlag() { + if (jTextFieldFeatureFlag == null) { + jTextFieldFeatureFlag = new JTextField(); + jTextFieldFeatureFlag + .setBounds(new java.awt.Rectangle(160, 155, 320, 20)); + jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldFeatureFlag + .setToolTipText("Postfix expression that must evaluate to TRUE or FALSE"); } - - /** - This method initializes events groups and usage type - - **/ - private void initFrame() { - Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType()); - Tools.generateComboBoxByVector(jComboBoxEventGroup, ed.getVEventGroup()); - Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage()); - Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt.getAllGuidDeclarationsFromWorkspace()); + return jTextFieldFeatureFlag; + } + + /** + * This method initializes jTextAreaHelpText + * + * @return javax.swing.JTextArea + * + */ + private JTextArea getJTextAreaHelpText() { + if (jTextAreaHelpText == null) { + jTextAreaHelpText = new JTextArea(); + jTextAreaHelpText.setLineWrap(true); + jTextAreaHelpText.setWrapStyleWord(true); + } + return jTextAreaHelpText; + } + + /** + * This method initializes jScrollPaneHelpText + * + * @return javax.swing.JScrollPane + * + */ + private JScrollPane getJScrollPaneHelpText() { + if (jScrollPaneHelpText == null) { + jScrollPaneHelpText = new JScrollPane(); + jScrollPaneHelpText.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPaneHelpText.setSize(new java.awt.Dimension(320,40)); + jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320,40)); + jScrollPaneHelpText.setLocation(new java.awt.Point(160,110)); + jScrollPaneHelpText.setViewportView(getJTextAreaHelpText()); + } + return jScrollPaneHelpText; + } + + /** + * This method initializes jButtonOk + * + * @return javax.swing.JButton + * + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setBounds(new java.awt.Rectangle(290, 202, 90, 20)); + jButtonOk.setText("Ok"); + jButtonOk.addActionListener(this); + } + return jButtonOk; + } + + /** + * This method initializes jButtonCancel + * + * @return javax.swing.JButton + * + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setBounds(new java.awt.Rectangle(390, 202, 90, 20)); + jButtonCancel.setText("Cancel"); + jButtonCancel.addActionListener(this); + } + return jButtonCancel; + } + + public static void main(String[] args) { + + } + + /** + * This method initializes this + * + */ + private void init() { + this.setSize(500, 275); + this.setContentPane(getJScrollPane()); + this.setTitle("Events"); + initFrame(); + this.setViewMode(false); + this.centerWindow(); + } + + /** + * This method initializes this Fill values to all fields if these values are + * not empty + * + * @param inEventsId + * + */ + private void init(EventsIdentification inEventsId) { + init(); + this.id = inEventsId; + + if (this.id != null) { + this.jComboBoxGuidC_Name.setSelectedItem(id.getName()); + this.jComboBoxEventsType.setSelectedItem(id.getType()); + this.jComboBoxUsage.setSelectedItem(id.getUsage()); + this.jTextAreaHelpText.setText(id.getHelp()); + + jTextFieldFeatureFlag.setText(id.getFeatureFlag()); + this.jArchCheckBox.setSelectedItems(id.getSupArchList()); + this.jComboBoxEventGroup.setSelectedItem(id.getGroup()); + } + } + + /** + * This is the override edit constructor + * + * @param inEventsIdentification + * @param iFrame + * + */ + public EventsDlg(EventsIdentification inEventsIdentification, IFrame iFrame) { + super(iFrame, true); + init(inEventsIdentification); + } + + /** + * Disable all components when the mode is view + * + * @param isView + * true - The view mode; false - The non-view mode + * + */ + public void setViewMode(boolean isView) { + if (isView) { + this.jComboBoxGuidC_Name.setEnabled(!isView); + this.jComboBoxUsage.setEnabled(!isView); } + } + + /** + * This method initializes jContentPane + * + * @return javax.swing.JPanel jContentPane + * + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jStarLabel1 = new StarLabel(); + jStarLabel1.setLocation(new java.awt.Point(2, 10)); + jLabelEventType = new JLabel(); + jLabelEventType.setText("Type"); + jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 145, 20)); + + jStarLabel2 = new StarLabel(); + jStarLabel2.setLocation(new java.awt.Point(2, 35)); + jLabelC_Name = new JLabel(); + jLabelC_Name.setText("Guid C Name"); + jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 145, 20)); + + jStarLabel3 = new StarLabel(); + jStarLabel3.setLocation(new java.awt.Point(2, 60)); + jLabelGroup = new JLabel(); + jLabelGroup.setText("Event Type"); + jLabelGroup.setBounds(new java.awt.Rectangle(15, 60, 145, 20)); + + jStarLabel4 = new StarLabel(); + jStarLabel4.setLocation(new java.awt.Point(2, 85)); + jLabelUsage = new JLabel(); + jLabelUsage.setText("Usage"); + jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20)); + + jLabelHelpText = new JLabel(); + jLabelHelpText.setBounds(new java.awt.Rectangle(15, 110, 145, 20)); + jLabelHelpText.setText("Help Text"); + + jLabelFeatureFlag = new JLabel(); + jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 155, 145, 20)); + jLabelFeatureFlag.setText("Feature Flag"); + + jLabelArch = new JLabel(); + jLabelArch.setBounds(new java.awt.Rectangle(15, 180, 145, 20)); + jLabelArch.setText("Arch"); + jArchCheckBox = new ArchCheckBox(); + jArchCheckBox.setBounds(new java.awt.Rectangle(160, 180, 320, 20)); + jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20)); + + jContentPane = new JPanel(); + jContentPane.setLayout(null); + jContentPane.setPreferredSize(new java.awt.Dimension(485, 230)); + + jContentPane.add(jStarLabel1, null); + jContentPane.add(jLabelEventType, null); + jContentPane.add(getJComboBoxEventsType(), null); + jContentPane.add(jStarLabel2, null); + jContentPane.add(jLabelC_Name, null); + jContentPane.add(getJComboBoxGuidC_Name(), null); + jContentPane.add(jStarLabel3, null); + jContentPane.add(jLabelGroup, null); + jContentPane.add(getJComboBoxEventGroup(), null); + jContentPane.add(jStarLabel4, null); + jContentPane.add(jLabelUsage, null); + jContentPane.add(getJComboBoxUsage(), null); + jContentPane.add(jLabelHelpText, null); + jContentPane.add(getJScrollPaneHelpText(), null); + jContentPane.add(jLabelFeatureFlag, null); + jContentPane.add(getJTextFieldFeatureFlag(), null); + jContentPane.add(jLabelArch, null); + jContentPane.add(jArchCheckBox, null); + jContentPane.add(getJButtonOk(), null); + jContentPane.add(getJButtonCancel(), null); - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - * - * Override actionPerformed to listen all actions - * - */ - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - if (checkAdd()) { - getCurrentEvents(); - this.returnType = DataType.RETURN_TYPE_OK; - this.setVisible(false); - } - } - - if (arg0.getSource() == jButtonCancel) { - this.returnType = DataType.RETURN_TYPE_CANCEL; - this.setVisible(false); - } + } + return jContentPane; + } + + /** + * This method initializes events groups and usage type + * + */ + private void initFrame() { + Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType()); + Tools.generateComboBoxByVector(jComboBoxEventGroup, ed.getVEventGroup()); + Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage()); + Tools.generateComboBoxByVector(jComboBoxGuidC_Name, wt + .getAllGuidDeclarationsFromWorkspace()); + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + * + * Override actionPerformed to listen all actions + * + */ + public void actionPerformed(ActionEvent arg0) { + if (arg0.getSource() == jButtonOk) { + if (checkAdd()) { + getCurrentEvents(); + this.returnType = DataType.RETURN_TYPE_OK; + this.setVisible(false); + } } - /** - Data validation for all fields - - @retval true - All datas are valid - @retval false - At least one data is invalid - - **/ - public boolean checkAdd() { - // - // Check if all fields have correct data types - // - - // - // Check Name - // - if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) { - Log.wrn("Update Events", "Event Name couldn't be empty"); - return false; - } - - if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) { - if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name.getSelectedItem().toString())) { - Log.wrn("Update Events", "Incorrect data type for Event Name"); - return false; - } - } - - // - // Check FeatureFlag - // - if (!isEmpty(this.jTextFieldFeatureFlag.getText())) { - if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) { - Log.wrn("Update Events", "Incorrect data type for Feature Flag"); - return false; - } - } - - return true; + if (arg0.getSource() == jButtonCancel) { + this.returnType = DataType.RETURN_TYPE_CANCEL; + this.setVisible(false); } + } + + /** + * Data validation for all fields + * + * @retval true - All datas are valid + * @retval false - At least one data is invalid + * + */ + public boolean checkAdd() { + // + // Check if all fields have correct data types + // - private EventsIdentification getCurrentEvents() { - String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString(); - String arg1 = this.jComboBoxEventsType.getSelectedItem().toString(); - String arg2 = this.jComboBoxUsage.getSelectedItem().toString(); - - String arg3 = this.jTextFieldFeatureFlag.getText(); - Vector arg4 = this.jArchCheckBox.getSelectedItemsVector(); - String arg5 = this.jTextFieldHelpText.getText(); - String arg6 = this.jComboBoxEventGroup.getSelectedItem().toString(); - id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6); - return id; + // + // Check Name + // + if (isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) { + Log.wrn("Update Events", "Event Name couldn't be empty"); + return false; } - public EventsIdentification getId() { - return id; + if (!isEmpty(this.jComboBoxGuidC_Name.getSelectedItem().toString())) { + if (!DataValidation.isC_NameType(this.jComboBoxGuidC_Name + .getSelectedItem().toString())) { + Log.wrn("Update Events", "Incorrect data type for Event Name"); + return false; + } } - public void setId(EventsIdentification id) { - this.id = id; + // + // Check FeatureFlag + // + if (!isEmpty(this.jTextFieldFeatureFlag.getText())) { + if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) { + Log.wrn("Update Events", "Incorrect data type for Feature Flag"); + return false; + } } + + return true; + } + + private EventsIdentification getCurrentEvents() { + String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString(); + String arg1 = this.jComboBoxEventsType.getSelectedItem().toString(); + String arg2 = this.jComboBoxUsage.getSelectedItem().toString(); + + String arg3 = this.jTextFieldFeatureFlag.getText(); + Vector arg4 = this.jArchCheckBox.getSelectedItemsVector(); + String arg5 = this.jTextAreaHelpText.getText(); + String arg6 = this.jComboBoxEventGroup.getSelectedItem().toString(); + id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + return id; + } + + public EventsIdentification getId() { + return id; + } + + public void setId(EventsIdentification id) { + this.id = id; + } } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java index 6a794f41fe..5e171edc8f 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ProtocolsDlg.java @@ -26,6 +26,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; +import javax.swing.JTextArea; import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataValidation; @@ -40,413 +41,459 @@ import org.tianocore.frameworkwizard.module.Identifications.Protocols.ProtocolsI import org.tianocore.frameworkwizard.workspace.WorkspaceTools; /** - The class is used to create, update Protocol of MSA/MBD file - It extends IInternalFrame - + * The class is used to create, update Protocol of MSA/MBD file + * It extends JDialog + * + */ +public class ProtocolsDlg extends IDialog implements ItemListener { + // / + // / Define class Serial Version UID + // / + private static final long serialVersionUID = -9084913640747858848L; - **/ -public class ProtocolsDlg extends IDialog implements ItemListener { + // + // Define class members + // + private JPanel jContentPane = null; - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = -9084913640747858848L; + private JLabel jLabelC_Name = null; - // - //Define class members - // - private JPanel jContentPane = null; + private JLabel jLabelFeatureFlag = null; - private JLabel jLabelC_Name = null; + private JTextField jTextFieldFeatureFlag = null; - private JLabel jLabelFeatureFlag = null; + private JLabel jLabelUsage = null; - private JTextField jTextFieldFeatureFlag = null; + private JComboBox jComboBoxUsage = null; - private JLabel jLabelUsage = null; + private StarLabel jStarLabel1 = null; - private JComboBox jComboBoxUsage = null; + private StarLabel jStarLabel2 = null; - private StarLabel jStarLabel1 = null; + private StarLabel jStarLabel3 = null; - private StarLabel jStarLabel2 = null; + private JLabel jLabelProtocolType = null; - private JLabel jLabelProtocolType = null; + private JLabel jLabelArch = null; - private JLabel jLabelArch = null; + private JScrollPane jScrollPane = null; - private JScrollPane jScrollPane = null; + private JComboBox jComboBoxProtocolType = null; - private JComboBox jComboBoxProtocolType = null; + private JComboBox jComboBoxCName = null; - private JComboBox jComboBoxCName = null; + private JLabel jLabelHelpText = null; - private JLabel jLabelHelpText = null; + private JTextArea jTextAreaHelpText = null; - private JTextField jTextFieldHelpText = null; + private JScrollPane jScrollPaneHelpText = null; - private ArchCheckBox jArchCheckBox = null; - - private JButton jButtonOk = null; + private ArchCheckBox jArchCheckBox = null; - private JButton jButtonCancel = null; + private JButton jButtonOk = null; - // - // Not used by UI - // - private ProtocolsIdentification id = null; - - private WorkspaceTools wt = new WorkspaceTools(); - - private EnumerationData ed = new EnumerationData(); - - /** - This method initializes jTextFieldFeatureFlag - - @return javax.swing.JTextField jTextFieldFeatureFlag - - **/ - private JTextField getJTextFieldFeatureFlag() { - if (jTextFieldFeatureFlag == null) { - jTextFieldFeatureFlag = new JTextField(); - jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20)); - jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20)); - } - return jTextFieldFeatureFlag; - } + private JButton jButtonCancel = null; - /** - This method initializes jComboBoxUsage - - @return javax.swing.JComboBox jComboBoxUsage - - **/ - private JComboBox getJComboBoxProtocolUsage() { - if (jComboBoxUsage == null) { - jComboBoxUsage = new JComboBox(); - jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); - jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxUsage.setToolTipText("ALWAYS_CONSUMED is the only valid usage for type ProtocolNotify."); - } - return jComboBoxUsage; - } + // + // Not used by UI + // + private ProtocolsIdentification id = null; - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - */ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(getJContentPane()); - } - return jScrollPane; - } + private WorkspaceTools wt = new WorkspaceTools(); - /** - * This method initializes jComboBoxProtocolType - * - * @return javax.swing.JComboBox - */ - private JComboBox getJComboBoxProtocolType() { - if (jComboBoxProtocolType == null) { - jComboBoxProtocolType = new JComboBox(); - jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); - jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxProtocolType.addItemListener(this); - jComboBoxProtocolType.setToolTipText("Select Protocol Type
Protocol Notify is a register protocol notify mechanism."); - } - return jComboBoxProtocolType; - } + private EnumerationData ed = new EnumerationData(); - /** - * This method initializes jComboBoxCName - * - * @return javax.swing.JComboBox - */ - private JComboBox getJComboBoxCName() { - if (jComboBoxCName == null) { - jComboBoxCName = new JComboBox(); - jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); - jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20)); - jComboBoxCName.setToolTipText("Select Guid C Name of the Protocol"); - - } - return jComboBoxCName; + /** + * This method initializes jTextFieldFeatureFlag + * + * @return javax.swing.JTextField jTextFieldFeatureFlag + * + */ + private JTextField getJTextFieldFeatureFlag() { + if (jTextFieldFeatureFlag == null) { + jTextFieldFeatureFlag = new JTextField(); + jTextFieldFeatureFlag + .setBounds(new java.awt.Rectangle(160, 130, 320, 20)); + jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldFeatureFlag + .setToolTipText("Postfix expression that must evaluate to TRUE or FALSE"); } - - /** - This method initializes jTextFieldHelpText - - @return javax.swing.JTextField - - **/ - private JTextField getJTextFieldHelpText() { - if (jTextFieldHelpText == null) { - jTextFieldHelpText = new JTextField(); - jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20)); - jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20)); - } - return jTextFieldHelpText; + return jTextFieldFeatureFlag; + } + + /** + * This method initializes jComboBoxUsage + * + * @return javax.swing.JComboBox jComboBoxUsage + * + */ + private JComboBox getJComboBoxProtocolUsage() { + if (jComboBoxUsage == null) { + jComboBoxUsage = new JComboBox(); + jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); + jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxUsage + .setToolTipText("
Protocol
ALWAYS_CONSUMEDModule always consumes the protocol
SOMETIMES_CONSUMESModule sometimes consumes the protocol
ALWAYS_PRODUCEDModule always produces the protocol
SOMETIMES_PRODUCEDModule sometimes produces the protocol
TO_STARTThe protocol is consumed by a Driver Binding protocol Start
function. The protocol is used in EFI 1.10 driver model
BY_STARTProtocol is produced by a Driver Binding protocol Start
function. The protocol is used in EFI 1.10 driver model
Protocol Notify
SOMETIMES_CONSUMEDModule will consume the protocol if it is produced.
Consumption is defined by executing the protocol notify
function.
"); } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20)); - jButtonOk.setText("Ok"); - jButtonOk.addActionListener(this); - } - return jButtonOk; + return jComboBoxUsage; + } + + /** + * This method initializes jScrollPane + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane() { + if (jScrollPane == null) { + jScrollPane = new JScrollPane(); + jScrollPane.setViewportView(getJContentPane()); } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20)); - jButtonCancel.setText("Cancel"); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; + return jScrollPane; + } + + /** + * This method initializes jComboBoxProtocolType + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBoxProtocolType() { + if (jComboBoxProtocolType == null) { + jComboBoxProtocolType = new JComboBox(); + jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); + jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxProtocolType.addItemListener(this); + jComboBoxProtocolType + .setToolTipText("Select Protocol Type
Protocol Notify is a register protocol notify mechanism."); } - - public static void main(String[] args) { + return jComboBoxProtocolType; + } + + /** + * This method initializes jComboBoxCName + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBoxCName() { + if (jComboBoxCName == null) { + jComboBoxCName = new JComboBox(); + jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); + jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxCName.setToolTipText("Select Guid C Name of the Protocol"); } - - /** - This method initializes this - - **/ - private void init() { - this.setSize(510, 240); - this.setContentPane(getJScrollPane()); - this.setTitle("Protocols"); - initFrame(); - this.setViewMode(false); - this.centerWindow(); + return jComboBoxCName; + } + + /** + * This method initializes jTextAreaHelpText + * + * @return javax.swing.JTextArea + * + */ + private JTextArea getJTextAreaHelpText() { + if (jTextAreaHelpText == null) { + jTextAreaHelpText = new JTextArea(); + jTextAreaHelpText.setLineWrap(true); + jTextAreaHelpText.setWrapStyleWord(true); } - - /** - This method initializes this - Fill values to all fields if these values are not empty - - @param inProtocolsId - - **/ - private void init(ProtocolsIdentification inProtocolsId) { - init(); - this.id = inProtocolsId; - - if (this.id != null) { - this.jComboBoxCName.setSelectedItem(id.getName()); - this.jComboBoxProtocolType.setSelectedItem(id.getType()); - this.jComboBoxUsage.setSelectedItem(id.getUsage()); - this.jTextFieldHelpText.setText(id.getHelp()); - - jTextFieldFeatureFlag.setText(id.getFeatureFlag()); - this.jArchCheckBox.setSelectedItems(id.getSupArchList()); - } + return jTextAreaHelpText; + } + + /** + * This method initializes jScrollPaneHelpText + * + * @return javax.swing.JScrollPane + * + */ + private JScrollPane getJScrollPaneHelpText() { + if (jScrollPaneHelpText == null) { + jScrollPaneHelpText = new JScrollPane(); + jScrollPaneHelpText + .setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPaneHelpText.setSize(new java.awt.Dimension(320, 40)); + jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320, 40)); + jScrollPaneHelpText.setLocation(new java.awt.Point(160, 85)); + jScrollPaneHelpText.setViewportView(getJTextAreaHelpText()); } - - /** - This is the override edit constructor - - @param inProtocolsIdentification - @param iFrame - - **/ - public ProtocolsDlg(ProtocolsIdentification inProtocolsIdentification, IFrame iFrame) { - super(iFrame, true); - init(inProtocolsIdentification); + return jScrollPaneHelpText; + } + + /** + * This method initializes jButtonOk + * + * @return javax.swing.JButton + * + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setBounds(new java.awt.Rectangle(290, 182, 90, 20)); + jButtonOk.setText("Ok"); + jButtonOk.addActionListener(this); } - - /** - Disable all components when the mode is view - - @param isView true - The view mode; false - The non-view mode - - **/ - public void setViewMode(boolean isView) { - if (isView) { - this.jComboBoxUsage.setEnabled(!isView); - this.jTextFieldFeatureFlag.setEnabled(!isView); - } + return jButtonOk; + } + + /** + * This method initializes jButtonCancel + * + * @return javax.swing.JButton + * + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setBounds(new java.awt.Rectangle(390, 182, 90, 20)); + jButtonCancel.setText("Cancel"); + jButtonCancel.addActionListener(this); } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel jContentPane - - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jArchCheckBox = new ArchCheckBox(); - jArchCheckBox.setBounds(new java.awt.Rectangle(160, 135, 320, 20)); - jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20)); - jLabelHelpText = new JLabel(); - jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20)); - jLabelHelpText.setText("Help Text"); - jLabelArch = new JLabel(); - jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20)); - jLabelArch.setText("Arch Type"); - jLabelProtocolType = new JLabel(); - jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); - jLabelProtocolType.setText("Protocol Type"); - jLabelUsage = new JLabel(); - jLabelUsage.setText("Usage"); - jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); - jLabelFeatureFlag = new JLabel(); - jLabelFeatureFlag.setText("Feature Flag"); - jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20)); - jLabelC_Name = new JLabel(); - jLabelC_Name.setText("C Name Type"); - jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); - - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.setPreferredSize(new java.awt.Dimension(490, 190)); - - jContentPane.add(jLabelC_Name, null); - jContentPane.add(jLabelFeatureFlag, null); - jContentPane.add(getJTextFieldFeatureFlag(), null); - jContentPane.add(jLabelUsage, null); - jContentPane.add(getJComboBoxProtocolUsage(), null); - jContentPane.add(jLabelProtocolType, null); - - jStarLabel1 = new StarLabel(); - jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20)); - jStarLabel2 = new StarLabel(); - jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20)); - - jContentPane.add(jStarLabel1, null); - jContentPane.add(jStarLabel2, null); - jContentPane.add(jLabelArch, null); - jContentPane.add(getJComboBoxProtocolType(), null); - jContentPane.add(getJComboBoxCName(), null); - jContentPane.add(jLabelHelpText, null); - jContentPane.add(getJTextFieldHelpText(), null); - jContentPane.add(jArchCheckBox, null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - } - return jContentPane; + return jButtonCancel; + } + + public static void main(String[] args) { + + } + + /** + * This method initializes this + * + */ + private void init() { + this.setSize(500, 255); + this.setContentPane(getJScrollPane()); + this.setTitle("Protocols"); + initFrame(); + this.setViewMode(false); + this.centerWindow(); + } + + /** + * This method initializes this Fill values to all fields if these values are + * not empty + * + * @param inProtocolsId + * + */ + private void init(ProtocolsIdentification inProtocolsId) { + init(); + this.id = inProtocolsId; + + if (this.id != null) { + this.jComboBoxCName.setSelectedItem(id.getName()); + this.jComboBoxProtocolType.setSelectedItem(id.getType()); + this.jComboBoxUsage.setSelectedItem(id.getUsage()); + this.jTextAreaHelpText.setText(id.getHelp()); + this.jTextFieldFeatureFlag.setText(id.getFeatureFlag()); + this.jArchCheckBox.setSelectedItems(id.getSupArchList()); } - - /** - This method initializes Usage type - - **/ - private void initFrame() { - Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType()); - Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllProtocolDeclarationsFromWorkspace()); - Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage()); + } + + /** + * This is the override edit constructor + * + * @param inProtocolsIdentification + * @param iFrame + * + */ + public ProtocolsDlg(ProtocolsIdentification inProtocolsIdentification, + IFrame iFrame) { + super(iFrame, true); + init(inProtocolsIdentification); + } + + /** + * Disable all components when the mode is view + * + * @param isView + * true - The view mode; false - The non-view mode + * + */ + public void setViewMode(boolean isView) { + if (isView) { + this.jComboBoxUsage.setEnabled(!isView); + this.jTextFieldFeatureFlag.setEnabled(!isView); } - - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - * - * Override actionPerformed to listen all actions - * - */ - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - if (checkAdd()) { - getCurrentProtocols(); - this.returnType = DataType.RETURN_TYPE_OK; - this.setVisible(false); - } - } - - if (arg0.getSource() == jButtonCancel) { - this.returnType = DataType.RETURN_TYPE_CANCEL; - this.setVisible(false); - } + } + + /** + * This method initializes jContentPane + * + * @return javax.swing.JPanel jContentPane + * + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jStarLabel1 = new StarLabel(); + jStarLabel1.setLocation(new java.awt.Point(2, 10)); + jLabelProtocolType = new JLabel(); + jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 145, 20)); + jLabelProtocolType.setText("Select Protocol Type"); + + jStarLabel2 = new StarLabel(); + jStarLabel2.setLocation(new java.awt.Point(2, 35)); + jLabelC_Name = new JLabel(); + jLabelC_Name.setText("Protocol Guid C Name"); + jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 145, 20)); + + jStarLabel3 = new StarLabel(); + jStarLabel3.setLocation(new java.awt.Point(2, 60)); + jLabelUsage = new JLabel(); + jLabelUsage.setText("Usage"); + jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 145, 20)); + + jLabelHelpText = new JLabel(); + jLabelHelpText.setBounds(new java.awt.Rectangle(15, 85, 145, 20)); + jLabelHelpText.setText("Help Text"); + + jLabelFeatureFlag = new JLabel(); + jLabelFeatureFlag.setText("Feature Flag Expression"); + jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 130, 145, 20)); + + jLabelArch = new JLabel(); + jLabelArch.setBounds(new java.awt.Rectangle(15, 155, 145, 20)); + jLabelArch.setText("Supported Architectures"); + jArchCheckBox = new ArchCheckBox(); + jArchCheckBox.setBounds(new java.awt.Rectangle(160, 155, 320, 20)); + jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20)); + + jContentPane = new JPanel(); + jContentPane.setLayout(null); + jContentPane.setPreferredSize(new java.awt.Dimension(485, 210)); + + jContentPane.add(jStarLabel1, null); + jContentPane.add(jLabelProtocolType, null); + jContentPane.add(getJComboBoxProtocolType(), null); + jContentPane.add(jStarLabel2, null); + jContentPane.add(jLabelC_Name, null); + jContentPane.add(getJComboBoxCName(), null); + jContentPane.add(jStarLabel3, null); + jContentPane.add(jLabelUsage, null); + jContentPane.add(getJComboBoxProtocolUsage(), null); + jContentPane.add(jLabelHelpText, null); + jContentPane.add(getJScrollPaneHelpText(), null); + jContentPane.add(jLabelFeatureFlag, null); + jContentPane.add(getJTextFieldFeatureFlag(), null); + jContentPane.add(jLabelArch, null); + jContentPane.add(jArchCheckBox, null); + jContentPane.add(getJButtonOk(), null); + jContentPane.add(getJButtonCancel(), null); } - - /** - Data validation for all fields - - @retval true - All datas are valid - @retval false - At least one data is invalid - - **/ - public boolean checkAdd() { - // - // Check if all fields have correct data types - // - - // - // Check Name - // - if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) { - if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) { - Log.wrn("Update Protocols", "Incorrect data type for Protocol/ProtocolNotify Name"); - return false; - } - } - - // - // Check FeatureFlag - // - if (!isEmpty(this.jTextFieldFeatureFlag.getText())) { - if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) { - Log.wrn("Update Protocols", "Incorrect data type for Feature Flag"); - return false; - } - } - - return true; + return jContentPane; + } + + /** + * This method initializes Usage type + * + */ + private void initFrame() { + Tools + .generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType()); + Tools.generateComboBoxByVector(jComboBoxCName, wt + .getAllProtocolDeclarationsFromWorkspace()); + Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage()); + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + * + * Override actionPerformed to listen all actions + * + */ + public void actionPerformed(ActionEvent arg0) { + if (arg0.getSource() == jButtonOk) { + if (checkAdd()) { + getCurrentProtocols(); + this.returnType = DataType.RETURN_TYPE_OK; + this.setVisible(false); + } } - private ProtocolsIdentification getCurrentProtocols() { - String arg0 = this.jComboBoxCName.getSelectedItem().toString(); - String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString(); - String arg2 = this.jComboBoxUsage.getSelectedItem().toString(); - - String arg3 = this.jTextFieldFeatureFlag.getText(); - Vector arg4 = this.jArchCheckBox.getSelectedItemsVector(); - String arg5 = this.jTextFieldHelpText.getText(); - id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5); - return id; + if (arg0.getSource() == jButtonCancel) { + this.returnType = DataType.RETURN_TYPE_CANCEL; + this.setVisible(false); } + } + + /** + * Data validation for all fields + * + * @retval true - All datas are valid + * @retval false - At least one data is invalid + * + */ + public boolean checkAdd() { + // + // Check if all fields have correct data types + // - /* (non-Javadoc) - * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) - * - * Reflesh the frame when selected item changed - * - */ - public void itemStateChanged(ItemEvent arg0) { - if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) { - if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) { - Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage()); - } else { - Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage()); - } - } + // + // Check Name + // + if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) { + if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem() + .toString())) { + Log.wrn("Update Protocols", + "Incorrect data type for Protocol/ProtocolNotify Name"); + return false; + } } - public ProtocolsIdentification getId() { - return id; + // + // Check FeatureFlag + // + if (!isEmpty(this.jTextFieldFeatureFlag.getText())) { + if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) { + Log.wrn("Update Protocols", "Incorrect data type for Feature Flag"); + return false; + } } - public void setId(ProtocolsIdentification id) { - this.id = id; + return true; + } + + private ProtocolsIdentification getCurrentProtocols() { + String arg0 = this.jComboBoxCName.getSelectedItem().toString(); + String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString(); + String arg2 = this.jComboBoxUsage.getSelectedItem().toString(); + + String arg3 = this.jTextFieldFeatureFlag.getText(); + Vector arg4 = this.jArchCheckBox.getSelectedItemsVector(); + String arg5 = this.jTextAreaHelpText.getText(); + id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5); + return id; + } + + /* + * (non-Javadoc) + * + * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) + * + * Reflesh the frame when selected item changed + * + */ + + public void itemStateChanged(ItemEvent arg0) { + if (arg0.getSource() == this.jComboBoxProtocolType + && arg0.getStateChange() == ItemEvent.SELECTED) { + if (this.jComboBoxProtocolType.getSelectedItem().toString().equals( + ed.getVProtocolType().get(0))) { + Tools.generateComboBoxByVector(this.jComboBoxUsage, ed + .getVProtocolUsage()); + } else { + Tools.generateComboBoxByVector(this.jComboBoxUsage, ed + .getVProtocolNotifyUsage()); + } } + } + + public ProtocolsIdentification getId() { + return id; + } + + public void setId(ProtocolsIdentification id) { + this.id = id; + } } -- 2.39.2