diff --git a/src/main/java/ui/syscams/SysCAMSPortDE.java b/src/main/java/ui/syscams/SysCAMSPortDE.java index 70bd37e45882ed61878d7c7d08034d7d085f801a..738fc1fb354ea96ba27674dd1c46a36444144055 100644 --- a/src/main/java/ui/syscams/SysCAMSPortDE.java +++ b/src/main/java/ui/syscams/SysCAMSPortDE.java @@ -52,56 +52,74 @@ import ui.TGComponent; */ public class SysCAMSPortDE extends SysCAMSPrimitivePort { - private int period; - private String time; - private int rate; - private int delay; +// private int period; +// private String time; +// private int rate; +// private int delay; private String DEType; + private boolean sensitive; + private String sensitiveMethod; public SysCAMSPortDE(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) { super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp); } - public String getTime() { - return time; - } +// public int getPeriod() { +// return period; +// } +// +// public void setPeriod(int period) { +// this.period = period; +// } +// +// public String getTime() { +// return time; +// } +// +// public void setTime(String time) { +// this.time = time; +// } +// +// public int getRate() { +// return rate; +// } +// +// public void setRate(int rate) { +// this.rate = rate; +// } +// +// public int getDelay() { +// return delay; +// } +// +// public void setDelay(int delay) { +// this.delay = delay; +// } - public void setTime(String time) { - this.time = time; + public void drawParticularity(Graphics g) { } public String getDEType() { return DEType; } - public void setDEType(String DEType) { - this.DEType = DEType; - } - - public int getPeriod() { - return period; - } - - public void setPeriod(int period) { - this.period = period; + public void setDEType(String _DEType) { + DEType = _DEType; } - - public int getRate() { - return rate; - } - - public void setRate(int rate) { - this.rate = rate; + + public boolean getSensitive() { + return sensitive; } - public int getDelay() { - return delay; + public void setSensitive(boolean _sensitive) { + sensitive = _sensitive; } - public void setDelay(int delay) { - this.delay = delay; + public String getSensitiveMethod() { + return sensitiveMethod; } - public void drawParticularity(Graphics g) { + public void setSensitiveMethod(String _sensitiveMethod) { + sensitiveMethod = _sensitiveMethod; } } \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java index 8ebfb616bd6e40a51e337d3830c4e40026099774..5e0274655221a4df9c49991290b7fb5d4fd5ba91 100644 --- a/src/main/java/ui/syscams/SysCAMSPrimitivePort.java +++ b/src/main/java/ui/syscams/SysCAMSPrimitivePort.java @@ -123,11 +123,13 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple ((SysCAMSPortTDF) this).setDelay(-1); ((SysCAMSPortTDF) this).setTDFType("int"); } else if (this instanceof SysCAMSPortDE) { - ((SysCAMSPortDE) this).setPeriod(-1); - ((SysCAMSPortDE) this).setTime(""); - ((SysCAMSPortDE) this).setRate(-1); - ((SysCAMSPortDE) this).setDelay(-1); +// ((SysCAMSPortDE) this).setPeriod(-1); +// ((SysCAMSPortDE) this).setTime(""); +// ((SysCAMSPortDE) this).setRate(-1); +// ((SysCAMSPortDE) this).setDelay(-1); ((SysCAMSPortDE) this).setDEType("int"); + ((SysCAMSPortDE) this).setSensitive(false); + ((SysCAMSPortDE) this).setSensitiveMethod(""); } else if (this instanceof SysCAMSPortConverter) { ((SysCAMSPortConverter) this).setPeriod(-1); ((SysCAMSPortConverter) this).setTime(""); @@ -391,11 +393,13 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple sb.append("\" type=\"" + ((SysCAMSPortTDF) this).getTDFType()); } if (this instanceof SysCAMSPortDE) { - sb.append("\" period=\"" + ((SysCAMSPortDE) this).getPeriod()); - sb.append("\" time=\"" + ((SysCAMSPortDE) this).getTime()); - sb.append("\" rate=\"" + ((SysCAMSPortDE) this).getRate()); - sb.append("\" delay=\"" + ((SysCAMSPortDE) this).getDelay()); +// sb.append("\" period=\"" + ((SysCAMSPortDE) this).getPeriod()); +// sb.append("\" time=\"" + ((SysCAMSPortDE) this).getTime()); +// sb.append("\" rate=\"" + ((SysCAMSPortDE) this).getRate()); +// sb.append("\" delay=\"" + ((SysCAMSPortDE) this).getDelay()); sb.append("\" type=\"" + ((SysCAMSPortDE) this).getDEType()); + sb.append("\" sensitive=\"" + ((SysCAMSPortDE) this).getSensitive()); + sb.append("\" sensitive_method=\"" + ((SysCAMSPortDE) this).getSensitiveMethod()); } if (this instanceof SysCAMSPortConverter) { sb.append("\" period=\"" + ((SysCAMSPortConverter) this).getPeriod()); @@ -416,7 +420,8 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple Element elt; int period, rate, delay; - String type, time; + String type, time, sensitiveMethod; + Boolean sensitive; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -430,28 +435,38 @@ public class SysCAMSPrimitivePort extends TGCScalableWithInternalComponent imple commName = elt.getAttribute("commName"); typep = Integer.decode(elt.getAttribute("commType")).intValue(); isOrigin = Integer.decode(elt.getAttribute("origin")).intValue(); - period = Integer.decode(elt.getAttribute("period")).intValue(); - time = elt.getAttribute("time"); - rate = Integer.decode(elt.getAttribute("rate")).intValue(); - delay = Integer.decode(elt.getAttribute("delay")).intValue(); - type = elt.getAttribute("type"); - setPortName(commName); - if (this instanceof SysCAMSPortTDF) { - ((SysCAMSPortTDF)this).setPeriod(period); - ((SysCAMSPortTDF)this).setTime(time); - ((SysCAMSPortTDF)this).setRate(rate); - ((SysCAMSPortTDF)this).setDelay(delay); - ((SysCAMSPortTDF)this).setTDFType(type); - } else if (this instanceof SysCAMSPortDE) { - ((SysCAMSPortDE)this).setPeriod(period); - ((SysCAMSPortDE)this).setTime(time); - ((SysCAMSPortDE)this).setRate(rate); - ((SysCAMSPortDE)this).setDelay(delay); - ((SysCAMSPortDE)this).setDEType(type); - } else if (this instanceof SysCAMSPortConverter) { - ((SysCAMSPortConverter)this).setPeriod(period); - ((SysCAMSPortConverter)this).setTime(time); - ((SysCAMSPortConverter)this).setRate(rate); + setPortName(commName); + if (this instanceof SysCAMSPortTDF) { + period = Integer.decode(elt.getAttribute("period")).intValue(); + time = elt.getAttribute("time"); + rate = Integer.decode(elt.getAttribute("rate")).intValue(); + delay = Integer.decode(elt.getAttribute("delay")).intValue(); + type = elt.getAttribute("type"); + ((SysCAMSPortTDF) this).setPeriod(period); + ((SysCAMSPortTDF) this).setTime(time); + ((SysCAMSPortTDF) this).setRate(rate); + ((SysCAMSPortTDF) this).setDelay(delay); + ((SysCAMSPortTDF) this).setTDFType(type); + } else if (this instanceof SysCAMSPortDE) { + // ((SysCAMSPortDE)this).setPeriod(period); + // ((SysCAMSPortDE)this).setTime(time); + // ((SysCAMSPortDE)this).setRate(rate); + // ((SysCAMSPortDE)this).setDelay(delay); + type = elt.getAttribute("type"); + sensitive = Boolean.parseBoolean(elt.getAttribute("sensitive")); + sensitiveMethod = elt.getAttribute("sensitive_method"); + ((SysCAMSPortDE) this).setDEType(type); + ((SysCAMSPortDE) this).setSensitive(sensitive); + ((SysCAMSPortDE) this).setSensitiveMethod(sensitiveMethod); + } else if (this instanceof SysCAMSPortConverter) { + period = Integer.decode(elt.getAttribute("period")).intValue(); + time = elt.getAttribute("time"); + rate = Integer.decode(elt.getAttribute("rate")).intValue(); + delay = Integer.decode(elt.getAttribute("delay")).intValue(); + type = elt.getAttribute("type"); + ((SysCAMSPortConverter) this).setPeriod(period); + ((SysCAMSPortConverter) this).setTime(time); + ((SysCAMSPortConverter) this).setRate(rate); ((SysCAMSPortConverter)this).setDelay(delay); ((SysCAMSPortConverter)this).setConvType(type); } diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index 35c099f66f5b18445cfa65d5a2d0ffa82e93be80..e4613a260b4f932858d70c313b802f10125d0995 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -39,36 +39,15 @@ package ui.window; import ui.syscams.*; -import ui.util.IconManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractAction; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.KeyStroke; +import ui.util.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; /** - * Class JDialogSystemCAMSPortDE - * Dialog for managing of SystemC-AMS DE Port + * Class JDialogSystemCAMSPortDE Dialog for managing of SystemC-AMS DE Port * Creation: 07/05/2018 + * * @version 1.0 07/05/2018 * @author Irina Kit Yan LEE */ @@ -76,32 +55,29 @@ import javax.swing.KeyStroke; @SuppressWarnings("serial") public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { - - /** Access to ActionPerformed **/ private JTextField nameTextField; - private JTextField periodTextField; - private String listPeriodString[]; - private JComboBox<String> periodComboBoxString; - private JTextField rateTextField; - private JTextField delayTextField; + // private JTextField periodTextField; + // private String listPeriodString[]; + // private JComboBox<String> periodComboBoxString; + // private JTextField rateTextField; + // private JTextField delayTextField; private String listTypeString[]; private JComboBox<String> typeComboBoxString; private String listOriginString[]; private JComboBox<String> originComboBoxString; + private JRadioButton sensitiveRadioButton; + private String listSensitiveString[]; + private JComboBox<String> sensitiveComboBoxString; - /** Parameters **/ private SysCAMSPortDE port; - /** Constructor **/ public JDialogSysCAMSPortDE(SysCAMSPortDE port) { - /** Set JDialog **/ this.setTitle("Setting DE Ports"); this.setLocationRelativeTo(null); this.setVisible(true); this.setAlwaysOnTop(true); this.setResizable(false); - /** Parameters **/ this.port = port; getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); @@ -115,7 +91,6 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } public void dialog() { - /** JPanel **/ JPanel mainPanel = new JPanel(new BorderLayout()); this.add(mainPanel); @@ -129,113 +104,107 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { GridBagConstraints constraints = new GridBagConstraints(); JPanel boxPanel = new JPanel(); boxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - boxPanel.setLayout(gridBag); + boxPanel.setLayout(gridBag); JLabel labelName = new JLabel("Name : "); - constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(labelName, constraints); boxPanel.add(labelName); - if (port.getPortName().toString().equals("")) { + if (port.getPortName().toString().equals("")) { nameTextField = new JTextField(10); } else { nameTextField = new JTextField(port.getPortName().toString(), 10); } - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(nameTextField, constraints); boxPanel.add(nameTextField); - JLabel periodLabel = new JLabel("Period Tp : "); - constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(periodLabel, constraints); - boxPanel.add(periodLabel); - - if (port.getPeriod() == -1) { - periodTextField = new JTextField(10); - } else { - periodTextField = new JTextField("" + port.getPeriod(), 10); - } - constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(periodTextField, constraints); - boxPanel.add(periodTextField); - - listPeriodString = new String[3]; - listPeriodString[0] = "us"; - listPeriodString[1] = "ms"; - listPeriodString[2] = "s"; - periodComboBoxString = new JComboBox<String>(listPeriodString); - if (port.getTime().equals("") || port.getTime().equals("us")) { - periodComboBoxString.setSelectedIndex(0); - } else if (port.getTime().equals("ms")){ - periodComboBoxString.setSelectedIndex(1); - } else { - periodComboBoxString.setSelectedIndex(2); - } - periodComboBoxString.setActionCommand("time"); - periodComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(periodComboBoxString, constraints); - boxPanel.add(periodComboBoxString); - - JLabel rateLabel = new JLabel("Rate : "); - constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(rateLabel, constraints); - boxPanel.add(rateLabel); - - if (port.getRate() == -1) { - rateTextField = new JTextField(10); - } else { - rateTextField = new JTextField("" + port.getRate(), 10); - } - constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(rateTextField, constraints); - boxPanel.add(rateTextField); - - JLabel delayLabel = new JLabel("Delay : "); - constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(delayLabel, constraints); - boxPanel.add(delayLabel); - - if (port.getDelay() == -1) { - delayTextField = new JTextField(10); - } else { - delayTextField = new JTextField("" + port.getDelay(), 10); - } - constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(delayTextField, constraints); - boxPanel.add(delayTextField); + // JLabel periodLabel = new JLabel("Period Tp : "); + // constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(periodLabel, constraints); + // boxPanel.add(periodLabel); + // + // if (port.getPeriod() == -1) { + // periodTextField = new JTextField(10); + // } else { + // periodTextField = new JTextField("" + port.getPeriod(), 10); + // } + // constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(periodTextField, constraints); + // boxPanel.add(periodTextField); + // + // listPeriodString = new String[3]; + // listPeriodString[0] = "us"; + // listPeriodString[1] = "ms"; + // listPeriodString[2] = "s"; + // periodComboBoxString = new JComboBox<String>(listPeriodString); + // if (port.getTime().equals("") || port.getTime().equals("us")) { + // periodComboBoxString.setSelectedIndex(0); + // } else if (port.getTime().equals("ms")){ + // periodComboBoxString.setSelectedIndex(1); + // } else { + // periodComboBoxString.setSelectedIndex(2); + // } + // periodComboBoxString.setActionCommand("time"); + // periodComboBoxString.addActionListener(this); + // constraints = new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(periodComboBoxString, constraints); + // boxPanel.add(periodComboBoxString); + // + // JLabel rateLabel = new JLabel("Rate : "); + // constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(rateLabel, constraints); + // boxPanel.add(rateLabel); + // + // if (port.getRate() == -1) { + // rateTextField = new JTextField(10); + // } else { + // rateTextField = new JTextField("" + port.getRate(), 10); + // } + // constraints = new GridBagConstraints(1, 2, 2, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(rateTextField, constraints); + // boxPanel.add(rateTextField); + // + // JLabel delayLabel = new JLabel("Delay : "); + // constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(delayLabel, constraints); + // boxPanel.add(delayLabel); + // + // if (port.getDelay() == -1) { + // delayTextField = new JTextField(10); + // } else { + // delayTextField = new JTextField("" + port.getDelay(), 10); + // } + // constraints = new GridBagConstraints(1, 3, 2, 1, 1.0, 1.0, + // GridBagConstraints.CENTER, + // GridBagConstraints.BOTH, + // new Insets(5, 10, 5, 10), 0, 0); + // gridBag.setConstraints(delayTextField, constraints); + // boxPanel.add(delayTextField); JLabel typeLabel = new JLabel("Type : "); - constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeLabel, constraints); boxPanel.add(typeLabel); @@ -256,20 +225,16 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } typeComboBoxString.setActionCommand("type"); typeComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(1, 4, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); - boxPanel.add(typeComboBoxString); + boxPanel.add(typeComboBoxString); JLabel orginLabel = new JLabel("Origin : "); - constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(orginLabel, constraints); - boxPanel.add(orginLabel); + boxPanel.add(orginLabel); listOriginString = new String[2]; listOriginString[0] = "Input"; @@ -282,16 +247,47 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } originComboBoxString.setActionCommand("origin"); originComboBoxString.addActionListener(this); - constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, + constraints = new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(originComboBoxString, constraints); - boxPanel.add(originComboBoxString); + boxPanel.add(originComboBoxString); - box.add(boxPanel); + box.add(boxPanel); attributesMainPanel.add(box); + JPanel sensitivePanel = new JPanel(new FlowLayout()); + + sensitiveRadioButton = new JRadioButton(); + sensitiveRadioButton.setActionCommand("Sensitive"); + sensitiveRadioButton.setSelected(port.getSensitive()); + sensitiveRadioButton.addActionListener(this); + sensitivePanel.add(sensitiveRadioButton); + + JLabel sensitiveLabel = new JLabel("Sensitive"); + sensitivePanel.add(sensitiveLabel); + + constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(sensitivePanel, constraints); + boxPanel.add(sensitivePanel); + + listSensitiveString = new String[2]; + listSensitiveString[0] = "positive"; + listSensitiveString[1] = "negative"; + sensitiveComboBoxString = new JComboBox<String>(listSensitiveString); + if (port.getSensitiveMethod().equals("") || port.getSensitiveMethod().equals("positive")) { + sensitiveComboBoxString.setSelectedIndex(0); + } else if (port.getSensitiveMethod().equals("negative")) { + sensitiveComboBoxString.setSelectedIndex(1); + } + sensitiveComboBoxString.setActionCommand("Sensitive_method"); + sensitiveComboBoxString.addActionListener(this); + constraints = new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(sensitiveComboBoxString, constraints); + boxPanel.add(sensitiveComboBoxString); + + // -- Button -- // JPanel downPanel = new JPanel(new FlowLayout()); JButton saveCloseButton = new JButton("Save and close"); @@ -317,60 +313,61 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { if ("Save_Close".equals(e.getActionCommand())) { port.setPortName(new String(nameTextField.getText())); - if (!(periodTextField.getText().isEmpty())) { - Boolean periodValueInteger = false; - try { - Integer.parseInt(periodTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !", - JOptionPane.WARNING_MESSAGE); - periodValueInteger = true; - } - if (periodValueInteger == false) { - port.setPeriod(Integer.parseInt(periodTextField.getText())); - } - } else { - port.setPeriod(-1); - } - if (!(rateTextField.getText().isEmpty())) { - Boolean rateValueInteger = false; - try { - Integer.parseInt(rateTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !", - JOptionPane.WARNING_MESSAGE); - rateValueInteger = true; - } - if (rateValueInteger == false) { - port.setRate(Integer.parseInt(rateTextField.getText())); - } - } else { - port.setRate(-1); - } - - if (!(delayTextField.getText().isEmpty())) { - Boolean delayValueInteger = false; - try { - Integer.parseInt(delayTextField.getText()); - } catch (NumberFormatException e1) { - JDialog msg = new JDialog(this); - msg.setLocationRelativeTo(null); - JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !", - JOptionPane.WARNING_MESSAGE); - delayValueInteger = true; - } - if (delayValueInteger == false) { - port.setDelay(Integer.parseInt(delayTextField.getText())); - } - } else { - port.setDelay(-1); - } + // if (!(periodTextField.getText().isEmpty())) { + // Boolean periodValueInteger = false; + // try { + // Integer.parseInt(periodTextField.getText()); + // } catch (NumberFormatException e1) { + // JDialog msg = new JDialog(this); + // msg.setLocationRelativeTo(null); + // JOptionPane.showMessageDialog(msg, "Period is not a Integer", "Warning !", + // JOptionPane.WARNING_MESSAGE); + // periodValueInteger = true; + // } + // if (periodValueInteger == false) { + // port.setPeriod(Integer.parseInt(periodTextField.getText())); + // } + // } else { + // port.setPeriod(-1); + // } + // + // if (!(rateTextField.getText().isEmpty())) { + // Boolean rateValueInteger = false; + // try { + // Integer.parseInt(rateTextField.getText()); + // } catch (NumberFormatException e1) { + // JDialog msg = new JDialog(this); + // msg.setLocationRelativeTo(null); + // JOptionPane.showMessageDialog(msg, "Rate is not a Integer", "Warning !", + // JOptionPane.WARNING_MESSAGE); + // rateValueInteger = true; + // } + // if (rateValueInteger == false) { + // port.setRate(Integer.parseInt(rateTextField.getText())); + // } + // } else { + // port.setRate(-1); + // } + // + // if (!(delayTextField.getText().isEmpty())) { + // Boolean delayValueInteger = false; + // try { + // Integer.parseInt(delayTextField.getText()); + // } catch (NumberFormatException e1) { + // JDialog msg = new JDialog(this); + // msg.setLocationRelativeTo(null); + // JOptionPane.showMessageDialog(msg, "Delay is not a Integer", "Warning !", + // JOptionPane.WARNING_MESSAGE); + // delayValueInteger = true; + // } + // if (delayValueInteger == false) { + // port.setDelay(Integer.parseInt(delayTextField.getText())); + // } + // } else { + // port.setDelay(-1); + // } port.setDEType((String) typeComboBoxString.getSelectedItem()); - port.setTime((String) periodComboBoxString.getSelectedItem()); + // port.setTime((String) periodComboBoxString.getSelectedItem()); if ((String) originComboBoxString.getSelectedItem() == "Output") { port.setOrigin(1); @@ -378,6 +375,9 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { port.setOrigin(0); } + port.setSensitive(sensitiveRadioButton.isSelected()); + port.setSensitiveMethod((String) sensitiveComboBoxString.getSelectedItem()); + this.dispose(); }