diff --git a/src/main/java/ui/syscams/SysCAMSBlockDE.java b/src/main/java/ui/syscams/SysCAMSBlockDE.java index 9d8b94cf33832f06d3fc28a50922a94aae56a2c1..2fdb078318af62805c180c2edb6b67801c1b9663 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockDE.java +++ b/src/main/java/ui/syscams/SysCAMSBlockDE.java @@ -335,7 +335,8 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements sb.append(isAttacker() ? "Yes": "No"); sb.append("\" />\n"); sb.append("<Attribute period=\""); - sb.append(this.getPeriod()); + sb.append(getPeriod()); + sb.append("\" time=\"" + getTime()); sb.append("\" />\n"); sb.append("</extraparam>\n"); return new String(sb); @@ -346,7 +347,9 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements NodeList nli; Node n1, n2; Element elt; + int period; + String time; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -361,7 +364,9 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements } if (elt.getTagName().equals("Attribute")) { period = Integer.decode(elt.getAttribute("period")).intValue(); + time = elt.getAttribute("time"); setPeriod(period); + setTime(time); } } } @@ -413,8 +418,8 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements return period; } - public void setPeriod(int period) { - this.period = period; + public void setPeriod(int _period) { + period = _period; } public String getAttributes() { @@ -425,8 +430,7 @@ public class SysCAMSBlockDE extends TGCScalableWithInternalComponent implements return time; } - public void setTime(String time) { - this.time = time; + public void setTime(String _time) { + time = _time; } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/syscams/SysCAMSBlockTDF.java b/src/main/java/ui/syscams/SysCAMSBlockTDF.java index 90d2c3628958627e1302839bb7e6c678f4c1e100..48d591a75dc7ae09f9641a57ff6457cb63efca38 100644 --- a/src/main/java/ui/syscams/SysCAMSBlockTDF.java +++ b/src/main/java/ui/syscams/SysCAMSBlockTDF.java @@ -64,6 +64,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements private int period; private String time; private String processCode; + private DefaultListModel<String> listParameters; private int maxFontSize = 14; private int minFontSize = 4; @@ -113,6 +114,7 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements setPeriod(-1); setProcessCode("void processing() {\n\n}"); setTime(""); + setListParameters(new DefaultListModel<String>()); myImageIcon = IconManager.imgic1202; @@ -356,16 +358,28 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements sb.append("<Data isAttacker=\""); sb.append(isAttacker() ? "Yes": "No"); sb.append("\" />\n"); - sb.append("<Attribute period=\""); - sb.append(this.getPeriod()); - sb.append("\" processCode=\""); - proc = encode(this.getProcessCode()); - sb.append(proc); + sb.append("<Attribute period=\"" + getPeriod()); + sb.append("\" time=\"" + time); + sb.append("\" processCode=\"" + encode(getProcessCode())); + sb.append("\" listParameters=\"" + splitParameters(listParameters)); sb.append("\" />\n"); sb.append("</extraparam>\n"); return new String(sb); } + public String splitParameters(DefaultListModel listParameters) { + String s = ""; + + for (int i = 0; i < listParameters.getSize(); i++) { + if (i < listParameters.getSize()-1) { + s = s + listParameters.get(i) + "|"; + } else { + s = s + listParameters.get(i); + } + } + return s; + } + public StringBuffer encode(String data) { StringBuffer databuf = new StringBuffer(data); StringBuffer buffer = new StringBuffer(""); @@ -471,8 +485,9 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements NodeList nli; Node n1, n2; Element elt; + int period; - String processCode; + String time, processCode, listParameters; for(int i=0; i<nl.getLength(); i++) { n1 = nl.item(i); @@ -487,10 +502,19 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements } if (elt.getTagName().equals("Attribute")) { period = Integer.decode(elt.getAttribute("period")).intValue(); + time = elt.getAttribute("time"); processCode = elt.getAttribute("processCode"); + listParameters = elt.getAttribute("listParameters"); setPeriod(period); + setTime(time); processCode = decode(processCode).toString(); setProcessCode(processCode); + String[] split = listParameters.split("\\|"); + DefaultListModel<String> list = new DefaultListModel<String>(); + for (String s : split) { + list.addElement(s); + } + setListParameters(list); } } } @@ -575,16 +599,16 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements return processCode; } - public void setProcessCode(String processCode) { - this.processCode = processCode; + public void setProcessCode(String _processCode) { + processCode = _processCode; } public int getPeriod() { return period; } - public void setPeriod(int period) { - this.period = period; + public void setPeriod(int _period) { + period = _period; } public String getAttributes() { @@ -595,8 +619,15 @@ public class SysCAMSBlockTDF extends TGCScalableWithInternalComponent implements return time; } - public void setTime(String time) { - this.time = time; + public void setTime(String _time) { + time = _time; + } + + public DefaultListModel<String> getListParameters() { + return listParameters; } -} + public void setListParameters(DefaultListModel<String> _listParameters) { + listParameters = _listParameters; + } +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java index a1a857f0d2b16e69cc7553850baa2b97d2fff149..41b98451ad50e6eca932b4eb3035c8710cbaf827 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockDE.java @@ -114,16 +114,14 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { /** JTabbedPane **/ JPanel attributesMainPanel = new JPanel(); - mainPanel.add(attributesMainPanel, BorderLayout.NORTH); // add tab to main panel + mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - // --- Attributes GridLayout ---// + // --- Attributes ---// attributesMainPanel.setLayout(new BorderLayout()); - // Box for Attributes Box attributesBox = Box.createVerticalBox(); attributesBox.setBorder(BorderFactory.createTitledBorder("Setting DE block attributes")); - // BorderLayout for Adding Attributes GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); JPanel attributesBoxPanel = new JPanel(); @@ -132,33 +130,33 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { JLabel labelName = new JLabel("Name : "); constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(labelName, constraints); attributesBoxPanel.add(labelName); - if (block.getValue().toString().equals("")) { // name empty + if (block.getValue().toString().equals("")) { nameTextField = new JTextField(10); } else { - nameTextField = new JTextField(block.getValue().toString(), 10); // name not empty + nameTextField = new JTextField(block.getValue().toString(), 10); } constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(nameTextField, constraints); attributesBoxPanel.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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodLabel, constraints); attributesBoxPanel.add(periodLabel); - if (block.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (block.getPeriod() == -1) { periodTextField = new JTextField(10); } else { - periodTextField = new JTextField("" + block.getPeriod(), 10); // name not empty + periodTextField = new JTextField("" + block.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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodTextField, constraints); attributesBoxPanel.add(periodTextField); @@ -171,21 +169,20 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { periodComboBoxString.setSelectedIndex(0); } else if (block.getTime().equals("ms")) { periodComboBoxString.setSelectedIndex(1); - } else { + } else if (block.getTime().equals("s")) { 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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodComboBoxString, constraints); attributesBoxPanel.add(periodComboBoxString); attributesBox.add(attributesBoxPanel); - attributesMainPanel.add(attributesBox, BorderLayout.NORTH); // add box to grid + attributesMainPanel.add(attributesBox, BorderLayout.NORTH); - // Down Side JPanel downPanel = new JPanel(new FlowLayout()); JButton saveCloseButton = new JButton("Save and close"); @@ -230,7 +227,7 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { } } else { block.setPeriod(-1); - block.setTime((String) periodComboBoxString.getSelectedItem()); + block.setTime(""); } this.dispose(); @@ -240,5 +237,4 @@ public class JDialogSysCAMSBlockDE extends JDialog implements ActionListener { this.dispose(); } } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java index 59aebe4076e0b8a450faca5a156c0d8af0aad089..73d466438edef8d1f6303156db776233af89e1c3 100644 --- a/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSBlockTDF.java @@ -39,11 +39,10 @@ package ui.window; import ui.syscams.*; -import ui.util.IconManager; - +import ui.util.*; +import java.util.*; import java.awt.*; import java.awt.event.*; - import javax.swing.*; import javax.swing.event.*; @@ -67,13 +66,11 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L private String listPeriodString[]; private JComboBox<String> periodComboBoxString; - // private JTextField nameParameterTextField; private JTextField valueParameterTextField; private JRadioButton constantParameterRadioButton; private String listTypeParameterString[]; private JComboBox<String> typeParameterComboBoxString; - // private JList<String> listParameters; private DefaultListModel<String> listModel; private JButton upButton, downButton, removeButton; @@ -207,7 +204,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JLabel labelName = new JLabel("Name : "); constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(labelName, constraints); attributesBoxPanel.add(labelName); @@ -217,13 +214,13 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L nameTextField = new JTextField(block.getValue().toString(), 10); } constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(nameTextField, constraints); attributesBoxPanel.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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodLabel, constraints); attributesBoxPanel.add(periodLabel); @@ -233,7 +230,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L periodTextField = new JTextField("" + block.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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodTextField, constraints); attributesBoxPanel.add(periodTextField); @@ -246,13 +243,13 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L periodComboBoxString.setSelectedIndex(0); } else if (block.getTime().equals("ms")) { periodComboBoxString.setSelectedIndex(1); - } else { + } else if (block.getTime().equals("s")) { 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); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(periodComboBoxString, constraints); attributesBoxPanel.add(periodComboBoxString); @@ -265,6 +262,8 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L Box parametersBox = Box.createVerticalBox(); parametersBox.setBorder(BorderFactory.createTitledBorder("Setting TDF block parameters")); + JPanel blockPanel = new JPanel(new BorderLayout()); + GridBagLayout gridBagParameter = new GridBagLayout(); GridBagConstraints constraintParameter = new GridBagConstraints(); JPanel parameterBoxPanel = new JPanel(); @@ -273,7 +272,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JLabel nameParameterLabel = new JLabel("identifier"); constraintParameter = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBagParameter.setConstraints(nameParameterLabel, constraintParameter); parameterBoxPanel.add(nameParameterLabel); @@ -291,7 +290,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JLabel valueParameterLabel = new JLabel("value"); constraintParameter = new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBagParameter.setConstraints(valueParameterLabel, constraintParameter); parameterBoxPanel.add(valueParameterLabel); @@ -309,7 +308,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JLabel constantLabel = new JLabel("const"); constraintParameter = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBagParameter.setConstraints(constantLabel, constraintParameter); parameterBoxPanel.add(constantLabel); @@ -324,7 +323,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JLabel typeParameterLabel = new JLabel("type"); constraintParameter = new GridBagConstraints(5, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBagParameter.setConstraints(typeParameterLabel, constraintParameter); parameterBoxPanel.add(typeParameterLabel); @@ -346,11 +345,12 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L addModifyButton.setActionCommand("Add_Modify"); addModifyButton.addActionListener(this); constraintParameter = new GridBagConstraints(0, 2, 6, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBagParameter.setConstraints(addModifyButton, constraintParameter); parameterBoxPanel.add(addModifyButton); - parametersBox.add(parameterBoxPanel); + blockPanel.add(parameterBoxPanel, BorderLayout.NORTH); + parametersBox.add(blockPanel); parametersMainPanel.add(parametersBox, BorderLayout.WEST); Box managingParametersBox = Box.createVerticalBox(); @@ -360,40 +360,47 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JPanel managingParameterBoxPanel = new JPanel(borderLayout); managingParameterBoxPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); - listModel = new DefaultListModel<String>(); + listModel = block.getListParameters(); listParameters = new JList<String>(listModel); listParameters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listParameters.setLayoutOrientation(JList.VERTICAL); - listParameters.setVisibleRowCount(10); listParameters.addListSelectionListener(this); JScrollPane scrollPane = new JScrollPane(listParameters); - scrollPane.setBorder(BorderFactory.createCompoundBorder(scrollPane.getBorder(), BorderFactory.createEmptyBorder(5, 10, 5, 10))); - managingParameterBoxPanel.add(scrollPane, BorderLayout.NORTH); + managingParameterBoxPanel.add(scrollPane, BorderLayout.CENTER); + + GridBagLayout buttonGridBag = new GridBagLayout(); + GridBagConstraints buttonconstraints = new GridBagConstraints(); + JPanel buttonPanel = new JPanel(); + buttonPanel.setFont(new Font("Helvetica", Font.PLAIN, 14)); + buttonPanel.setLayout(buttonGridBag); - GridLayout gridLayout = new GridLayout(3, 1, 5, 10); - JPanel buttonPanel = new JPanel(gridLayout); - upButton = new JButton("Up"); upButton.setActionCommand("Up"); upButton.setEnabled(false); upButton.addActionListener(this); - upButton.setBorder(BorderFactory.createCompoundBorder(upButton.getBorder(), BorderFactory.createEmptyBorder(5, 10, 5, 10))); + buttonconstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + buttonGridBag.setConstraints(upButton, buttonconstraints); buttonPanel.add(upButton); downButton = new JButton("Down"); downButton.setActionCommand("Down"); downButton.setEnabled(false); downButton.addActionListener(this); - downButton.setBorder(BorderFactory.createCompoundBorder(downButton.getBorder(), BorderFactory.createEmptyBorder(5, 10, 5, 10))); + buttonconstraints = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + buttonGridBag.setConstraints(downButton, buttonconstraints); buttonPanel.add(downButton); removeButton = new JButton("Remove parameter"); removeButton.setActionCommand("Remove"); removeButton.setEnabled(false); removeButton.addActionListener(this); - removeButton.setBorder(BorderFactory.createCompoundBorder(removeButton.getBorder(), BorderFactory.createEmptyBorder(5, 10, 5, 10))); + buttonconstraints = new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, + new Insets(5, 10, 5, 10), 0, 0); + buttonGridBag.setConstraints(removeButton, buttonconstraints); buttonPanel.add(removeButton); - + managingParameterBoxPanel.add(buttonPanel, BorderLayout.SOUTH); managingParametersBox.add(managingParameterBoxPanel); @@ -403,12 +410,10 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L processMainPanel.setLayout(new BorderLayout()); Box codeBox = Box.createVerticalBox(); - codeBox.setBorder(BorderFactory.createTitledBorder("Generating code")); + codeBox.setBorder(BorderFactory.createTitledBorder("Behavior function of TDF block")); JPanel codeBoxPanel = new JPanel(new BorderLayout()); - codeBoxPanel.add(new JLabel("Behavior function of TDF block : "), BorderLayout.NORTH); - StringBuffer stringbuf = encode(block.getProcessCode()); String beginString = stringbuf.toString(); finalString = beginString.replaceAll("\t}", "}"); @@ -424,7 +429,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JScrollPane processScrollPane = new JScrollPane(processCodeTextArea); processScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); processScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - processScrollPane.setPreferredSize(new Dimension(200, 150)); + processScrollPane.setPreferredSize(new Dimension(200, 300)); codeBoxPanel.add(processScrollPane, BorderLayout.SOUTH); @@ -538,7 +543,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L } } else { listModel.remove(alreadyExistId); - + try { if (type.equals("bool")) { Boolean.parseBoolean(valueParameterTextField.getText()); @@ -599,7 +604,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L } } } - + if ("Remove".equals(e.getActionCommand())) { if (listModel.getSize() >= 1) { listModel.remove(listParameters.getSelectedIndex()); @@ -618,7 +623,7 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JOptionPane.WARNING_MESSAGE); } } - + if ("Down".equals(e.getActionCommand())) { if (listParameters.getSelectedIndex() < listModel.getSize()-1) { String snext = listModel.get(listParameters.getSelectedIndex()+1); @@ -631,12 +636,10 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L JOptionPane.WARNING_MESSAGE); } } - + if ("Save_Close".equals(e.getActionCommand())) { - /** Save the name of the block into listNameTDF **/ block.setValue(new String(nameTextField.getText())); - /** Save the period of the block into listPeriodTmTDF **/ if (!(periodTextField.getText().isEmpty())) { Boolean periodValueInteger = false; try { @@ -654,11 +657,11 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L } } else { block.setPeriod(-1); - block.setTime((String) periodComboBoxString.getSelectedItem()); + block.setTime(""); } - /** Save the process code into listProcessCodeTDF **/ block.setProcessCode(processCodeTextArea.getText()); + block.setListParameters(listModel); this.dispose(); } @@ -675,6 +678,37 @@ public class JDialogSysCAMSBlockTDF extends JDialog implements ActionListener, L downButton.setEnabled(false); removeButton.setEnabled(false); } else { + String select = listModel.get(listParameters.getSelectedIndex()); + String[] splita = select.split(" = "); + nameParameterTextField.setText(splita[0]); + String[] splitb = splita[1].split(" : "); + valueParameterTextField.setText(splitb[0]); + String[] splitc = splitb[1].split(" "); + + if (splitc[0].equals("const")) { + constantParameterRadioButton.setSelected(true); + if (splitc[1].equals("bool")) { + typeParameterComboBoxString.setSelectedIndex(0); + } else if (splitc[1].equals("int")) { + typeParameterComboBoxString.setSelectedIndex(1); + } else if (splitc[1].equals("double")) { + typeParameterComboBoxString.setSelectedIndex(2); + } else if (splitc[1].equals("long")) { + typeParameterComboBoxString.setSelectedIndex(3); + } + } else { + constantParameterRadioButton.setSelected(false); + if (splitc[0].equals("bool")) { + typeParameterComboBoxString.setSelectedIndex(0); + } else if (splitc[0].equals("int")) { + typeParameterComboBoxString.setSelectedIndex(1); + } else if (splitc[0].equals("double")) { + typeParameterComboBoxString.setSelectedIndex(2); + } else if (splitc[0].equals("long")) { + typeParameterComboBoxString.setSelectedIndex(3); + } + } + if (listModel.getSize() >= 2) { upButton.setEnabled(true); downButton.setEnabled(true); diff --git a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java index 0609e2e5f0c92766a0b9c366b133a7305f4099ee..5ca7bcb902acf5c3ef3cb0ed435ed2109b2adca2 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortConverter.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortConverter.java @@ -122,7 +122,6 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen JPanel attributesMainPanel = new JPanel(new GridLayout()); mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - // Left Side Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting converter input port attributes")); @@ -136,19 +135,19 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(labelName, constraints); boxPanel.add(labelName); - if (port.getPortName().toString().equals("")) { // name empty + if (port.getPortName().toString().equals("")) { nameTextField = new JTextField(10); } else { - nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + nameTextField = new JTextField(port.getPortName().toString(), 10); } constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(15, 10, 5, 10), 0, 0); gridBag.setConstraints(nameTextField, constraints); boxPanel.add(nameTextField); @@ -160,10 +159,10 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen gridBag.setConstraints(periodLabel, constraints); boxPanel.add(periodLabel); - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { periodTextField = new JTextField(10); } else { - periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + periodTextField = new JTextField("" + port.getPeriod(), 10); } constraints = new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, @@ -199,19 +198,19 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(rateLabel, constraints); - boxPanel.add(rateLabel); // add label to box + boxPanel.add(rateLabel); - if (port.getRate() == -1) { // name empty + if (port.getRate() == -1) { rateTextField = new JTextField(10); } else { - rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + 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); // add text to box + boxPanel.add(rateTextField); JLabel delayLabel = new JLabel("Delay : "); constraints = new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, @@ -219,19 +218,19 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(delayLabel, constraints); - boxPanel.add(delayLabel); // add label to box + boxPanel.add(delayLabel); - if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getDelay() == -1) { delayTextField = new JTextField(10); } else { - delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + 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); // add text to box + boxPanel.add(delayTextField); JLabel typeLabel = new JLabel("Type : "); constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, @@ -239,7 +238,7 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeLabel, constraints); - boxPanel.add(typeLabel); // add label to box + boxPanel.add(typeLabel); listTypeString = new String[4]; listTypeString[0] = "int"; @@ -266,15 +265,15 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); - boxPanel.add(typeComboBoxString); // add combo to box + boxPanel.add(typeComboBoxString); JLabel orginLabel = new JLabel("Origin : "); constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(orginLabel, constraints); - boxPanel.add(orginLabel); // add label to box + boxPanel.add(orginLabel); listOriginString = new String[2]; listOriginString[0] = "Input"; @@ -290,14 +289,13 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen constraints = new GridBagConstraints(1, 5, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(originComboBoxString, constraints); - boxPanel.add(originComboBoxString); // add combo to box + boxPanel.add(originComboBoxString); - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid + box.add(boxPanel); + attributesMainPanel.add(box); - // Down Side JPanel downPanel = new JPanel(new FlowLayout()); JButton saveCloseButton = new JButton("Save and close"); @@ -391,5 +389,4 @@ public class JDialogSysCAMSPortConverter extends JDialog implements ActionListen this.dispose(); } } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortDE.java b/src/main/java/ui/window/JDialogSysCAMSPortDE.java index cabfacf1c24f39d6b3ff29586ae0f87055415ab4..35c099f66f5b18445cfa65d5a2d0ffa82e93be80 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortDE.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortDE.java @@ -71,7 +71,7 @@ import javax.swing.KeyStroke; * Creation: 07/05/2018 * @version 1.0 07/05/2018 * @author Irina Kit Yan LEE -*/ + */ @SuppressWarnings("serial") @@ -103,14 +103,14 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { /** Parameters **/ this.port = port; - + getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); getRootPane().getActionMap().put("close", new AbstractAction() { public void actionPerformed(ActionEvent e) { - dispose(); + dispose(); } }); - + dialog(); } @@ -118,11 +118,10 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { /** JPanel **/ JPanel mainPanel = new JPanel(new BorderLayout()); this.add(mainPanel); - + JPanel attributesMainPanel = new JPanel(new GridLayout()); mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side + Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting DE port attributes")); @@ -134,41 +133,41 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { JLabel labelName = new JLabel("Name : "); constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 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("")) { // name empty + if (port.getPortName().toString().equals("")) { nameTextField = new JTextField(10); } else { - nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + nameTextField = new JTextField(port.getPortName().toString(), 10); } - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + constraints = new GridBagConstraints(1, 0, 2, 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(periodLabel, constraints); - boxPanel.add(periodLabel); + boxPanel.add(periodLabel); - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { periodTextField = new JTextField(10); } else { - periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + 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); + 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); @@ -187,60 +186,60 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(periodComboBoxString, constraints); - boxPanel.add(periodComboBoxString); - + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(rateLabel, constraints); - boxPanel.add(rateLabel); // add label to box + boxPanel.add(rateLabel); - if (port.getRate() == -1) { // name empty + if (port.getRate() == -1) { rateTextField = new JTextField(10); } else { - rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(rateTextField, constraints); - boxPanel.add(rateTextField); // add text to box + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(delayLabel, constraints); - boxPanel.add(delayLabel); // add label to box - - if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + boxPanel.add(delayLabel); + + if (port.getDelay() == -1) { delayTextField = new JTextField(10); } else { - delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(delayTextField, constraints); - boxPanel.add(delayTextField); // add text to box + boxPanel.add(delayTextField); JLabel typeLabel = new JLabel("Type : "); constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeLabel, constraints); - boxPanel.add(typeLabel); // add label to box - + boxPanel.add(typeLabel); + listTypeString = new String[3]; listTypeString[0] = "int"; listTypeString[1] = "bool"; @@ -258,20 +257,20 @@ 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, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); - boxPanel.add(typeComboBoxString); // add combo to box - + boxPanel.add(typeComboBoxString); + JLabel orginLabel = new JLabel("Origin : "); constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(orginLabel, constraints); - boxPanel.add(orginLabel); // add label to box - + boxPanel.add(orginLabel); + listOriginString = new String[2]; listOriginString[0] = "Input"; listOriginString[1] = "Output"; @@ -284,16 +283,15 @@ 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, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(originComboBoxString, constraints); - boxPanel.add(originComboBoxString); // add combo to box + boxPanel.add(originComboBoxString); - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid + box.add(boxPanel); + attributesMainPanel.add(box); - // Down Side JPanel downPanel = new JPanel(new FlowLayout()); JButton saveCloseButton = new JButton("Save and close"); @@ -379,7 +377,7 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { } else { port.setOrigin(0); } - + this.dispose(); } @@ -387,5 +385,4 @@ public class JDialogSysCAMSPortDE extends JDialog implements ActionListener { this.dispose(); } } -} - +} \ No newline at end of file diff --git a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java index ee34842628a150a29d868e936542be807a1acfc4..a24235bf8cf789fc940818829f4c4202e820f91a 100644 --- a/src/main/java/ui/window/JDialogSysCAMSPortTDF.java +++ b/src/main/java/ui/window/JDialogSysCAMSPortTDF.java @@ -71,7 +71,7 @@ import javax.swing.KeyStroke; * Creation: 26/04/2018 * @version 1.0 26/04/2018 * @author Irina Kit Yan LEE -*/ + */ @SuppressWarnings("serial") @@ -103,14 +103,14 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { /** Parameters **/ this.port = port; - + getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close"); getRootPane().getActionMap().put("close", new AbstractAction() { public void actionPerformed(ActionEvent e) { - dispose(); + dispose(); } }); - + dialog(); } @@ -118,11 +118,10 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { /** JPanel **/ JPanel mainPanel = new JPanel(new BorderLayout()); this.add(mainPanel); - + JPanel attributesMainPanel = new JPanel(new GridLayout()); mainPanel.add(attributesMainPanel, BorderLayout.NORTH); - - // Left Side + Box box = Box.createVerticalBox(); box.setBorder(BorderFactory.createTitledBorder("Setting TDF port attributes")); @@ -134,41 +133,41 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { JLabel labelName = new JLabel("Name : "); constraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); - gridBag.setConstraints(labelName, constraints); - boxPanel.add(labelName); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(15, 10, 5, 10), 0, 0); + gridBag.setConstraints(labelName, constraints); + boxPanel.add(labelName); - if (port.getPortName().toString().equals("")) { // name empty + if (port.getPortName().toString().equals("")) { nameTextField = new JTextField(10); } else { - nameTextField = new JTextField(port.getPortName().toString(), 10); // name not empty + nameTextField = new JTextField(port.getPortName().toString(), 10); } - constraints = new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + constraints = new GridBagConstraints(1, 0, 2, 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(periodLabel, constraints); - boxPanel.add(periodLabel); + boxPanel.add(periodLabel); - if (port.getPeriod() == -1) { // name empty // port.getName().toString().equals("") || + if (port.getPeriod() == -1) { periodTextField = new JTextField(10); } else { - periodTextField = new JTextField("" + port.getPeriod(), 10); // name not empty + 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); + 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); @@ -181,66 +180,66 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { periodComboBoxString.setSelectedIndex(0); } else if (port.getTime().equals("ms")){ periodComboBoxString.setSelectedIndex(1); - } else { + } else if (port.getTime().equals("s")){ 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(periodComboBoxString, constraints); - boxPanel.add(periodComboBoxString); - + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(rateLabel, constraints); - boxPanel.add(rateLabel); // add label to box + boxPanel.add(rateLabel); - if (port.getRate() == -1) { // name empty + if (port.getRate() == -1) { rateTextField = new JTextField(10); } else { - rateTextField = new JTextField("" + port.getRate(), 10); // name not empty + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(rateTextField, constraints); - boxPanel.add(rateTextField); // add text to box + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(delayLabel, constraints); - boxPanel.add(delayLabel); // add label to box - - if (port.getDelay() == -1) { // name empty // port.getName().toString().equals("") || + boxPanel.add(delayLabel); + + if (port.getDelay() == -1) { delayTextField = new JTextField(10); } else { - delayTextField = new JTextField("" + port.getDelay(), 10); // name not empty + 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); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(delayTextField, constraints); - boxPanel.add(delayTextField); // add text to box + boxPanel.add(delayTextField); JLabel typeLabel = new JLabel("Type : "); constraints = new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeLabel, constraints); - boxPanel.add(typeLabel); // add label to box - + boxPanel.add(typeLabel); + listTypeString = new String[3]; listTypeString[0] = "int"; listTypeString[1] = "bool"; @@ -258,20 +257,20 @@ public class JDialogSysCAMSPortTDF 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, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 5, 10), 0, 0); gridBag.setConstraints(typeComboBoxString, constraints); - boxPanel.add(typeComboBoxString); // add combo to box - + boxPanel.add(typeComboBoxString); + JLabel orginLabel = new JLabel("Origin : "); constraints = new GridBagConstraints(0, 5, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, - GridBagConstraints.BOTH, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(orginLabel, constraints); - boxPanel.add(orginLabel); // add label to box - + boxPanel.add(orginLabel); + listOriginString = new String[2]; listOriginString[0] = "Input"; listOriginString[1] = "Output"; @@ -284,16 +283,15 @@ public class JDialogSysCAMSPortTDF 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, - new Insets(5, 10, 5, 10), 0, 0); + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(5, 10, 15, 10), 0, 0); gridBag.setConstraints(originComboBoxString, constraints); - boxPanel.add(originComboBoxString); // add combo to box - - box.add(boxPanel); // add border to box - attributesMainPanel.add(box); // add grid to grid + boxPanel.add(originComboBoxString); + + box.add(boxPanel); + attributesMainPanel.add(box); - // Down Side JPanel downPanel = new JPanel(new FlowLayout()); JButton saveCloseButton = new JButton("Save and close"); @@ -379,7 +377,7 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { } else { port.setOrigin(0); } - + this.dispose(); } @@ -387,5 +385,4 @@ public class JDialogSysCAMSPortTDF extends JDialog implements ActionListener { this.dispose(); } } -} - +} \ No newline at end of file