|
@@ -158,6 +158,7 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
* Should not update if mutex is true
|
|
|
*/
|
|
|
private boolean mutex = true;
|
|
|
+ private JTextField tfLabel;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -165,6 +166,7 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
* @param connection connection which should be edited
|
|
|
* @param controller controller for manipulation
|
|
|
* @param frame parent frame
|
|
|
+ * @wbp.parser.constructor
|
|
|
*/// @wbp.parser.constructor for Eclipse:WindowBuilder
|
|
|
public ConnectionCreationPanel(Connection connection, Controller controller, Window frame) {
|
|
|
this.controller = controller;
|
|
@@ -216,9 +218,9 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
|
|
|
// Sets up window
|
|
|
setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
|
|
- this.setPreferredSize(new Dimension(600, 220 + ports.length * 20));
|
|
|
+ this.setPreferredSize(new Dimension(600, 250 + ports.length * 20));
|
|
|
content = new JPanel();
|
|
|
- content.setPreferredSize(new Dimension(600, 200 + ports.length * 20));
|
|
|
+ content.setPreferredSize(new Dimension(600, 240 + ports.length * 20));
|
|
|
this.setViewportView(content);
|
|
|
content.setLayout(null);
|
|
|
|
|
@@ -484,6 +486,8 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
}
|
|
|
|
|
|
private void updateConnectionAndField() {
|
|
|
+ if(mutex)
|
|
|
+ return;
|
|
|
try {
|
|
|
double newRate = Double.parseDouble(tfPacketLossRate.getText());
|
|
|
if (newRate >= 0.0 && newRate <= 1.0) {
|
|
@@ -498,6 +502,46 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+
|
|
|
+ JLabel lblLabel = new JLabel("Label:");
|
|
|
+ lblLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
+ lblLabel.setBounds(10, 160, 140, 20);
|
|
|
+ content.add(lblLabel);
|
|
|
+
|
|
|
+ tfLabel = new JTextField();
|
|
|
+ tfLabel.setColumns(10);
|
|
|
+ tfLabel.setBounds(155, 160, 90, 20);
|
|
|
+ content.add(tfLabel);
|
|
|
+ tfLabel.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void removeUpdate(DocumentEvent e) {
|
|
|
+ updateConnectionAndField();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void insertUpdate(DocumentEvent e) {
|
|
|
+ updateConnectionAndField();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void changedUpdate(DocumentEvent e) {
|
|
|
+ updateConnectionAndField();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateConnectionAndField() {
|
|
|
+ if(mutex)
|
|
|
+ return;
|
|
|
+ try {
|
|
|
+ short newLabel = Short.parseShort(tfLabel.getText());
|
|
|
+ connection.setLabel(newLabel);
|
|
|
+ tfLabel.setBackground(Color.WHITE);
|
|
|
+ } catch (Exception exception) {
|
|
|
+ tfLabel.setBackground(Color.RED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
JLabel lblStatus = new JLabel("Status:");
|
|
|
lblStatus.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblStatus.setBounds(250, 130, 60, 20);
|
|
@@ -524,7 +568,7 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
});
|
|
|
|
|
|
JButton btnCreate = new JButton("Verify and Create");
|
|
|
- btnCreate.setBounds(125, 160, 206, 25);
|
|
|
+ btnCreate.setBounds(127, 186, 206, 25);
|
|
|
content.add(btnCreate);
|
|
|
|
|
|
btnCreate.addActionListener(new ActionListener() {
|
|
@@ -626,15 +670,14 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
*/
|
|
|
JLabel lblRole = new JLabel("Roles:");
|
|
|
lblRole.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- lblRole.setBounds(350, 165, 50, 18);
|
|
|
+ lblRole.setBounds(345, 189, 50, 18);
|
|
|
lblRole.setToolTipText("The roles each device plays in the connection, can be defined below. It defines how the device acts.");
|
|
|
content.add(lblRole);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Height of the current Box which is being created
|
|
|
*/
|
|
|
- int currentHeight = 190;
|
|
|
+ int currentHeight = 220;
|
|
|
|
|
|
cmbPortRoles = new JComboBox[ports.length];
|
|
|
for (int i = 0; i < ports.length; i++) {
|
|
@@ -750,6 +793,9 @@ public class ConnectionCreationPanel extends JScrollPane {
|
|
|
// Update packet loss field
|
|
|
tfPacketLossRate.setText("" + connection.getPacketLossProbability());
|
|
|
|
|
|
+ // Update Label
|
|
|
+ tfLabel.setText("" + connection.getLabel());
|
|
|
+
|
|
|
// Update Status
|
|
|
cmbStatus.setSelectedIndex(connection.getStatus());
|
|
|
|