From 113bd3cb6cfecd636130ce4dc9bbe37f88e967e0 Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Thu, 29 Nov 2018 09:26:42 -0800 Subject: [PATCH] corefx - updated configuration dialogs for nodes to be disabled when running --- .../main/java/com/core/ui/dialogs/ConfigDialog.java | 11 ++++++++++- .../java/com/core/ui/dialogs/NodeEmaneDialog.java | 9 ++++++++- .../java/com/core/ui/dialogs/NodeWlanDialog.java | 13 ++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java b/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java index aadef236..7d2c8db6 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java @@ -10,6 +10,7 @@ import com.jfoenix.controls.JFXScrollPane; import com.jfoenix.controls.JFXTabPane; import javafx.fxml.FXML; import javafx.geometry.Insets; +import javafx.scene.Node; import javafx.scene.control.ScrollPane; import javafx.scene.control.Tab; import javafx.scene.layout.ColumnConstraints; @@ -37,8 +38,14 @@ public class ConfigDialog extends StageDialog { return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList()); } + private void setDisabled(boolean isDisabled) { + saveButton.setDisable(isDisabled); + } + public void showDialog(String title, List configGroups, Runnable runnable) { setTitle(title); + boolean sessionRunning = getCoreClient().isRunning(); + setDisabled(sessionRunning); configItems.clear(); tabPane.getTabs().clear(); @@ -64,7 +71,9 @@ public class ConfigDialog extends StageDialog { for (ConfigOption option : group.getOptions()) { IConfigItem configItem = ConfigItemUtils.get(getStage(), option); - gridPane.addRow(index, configItem.getLabel(), configItem.getNode()); + Node node = configItem.getNode(); + node.setDisable(sessionRunning); + gridPane.addRow(index, configItem.getLabel(), node); configItems.add(configItem); index += 1; } diff --git a/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java b/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java index 8c34c399..7b91c578 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java @@ -17,6 +17,7 @@ import java.util.List; public class NodeEmaneDialog extends StageDialog { private static final Logger logger = LogManager.getLogger(); + private final JFXButton saveButton; private CoreNode coreNode; @FXML private JFXComboBox modelCombo; @FXML private JFXButton modelButton; @@ -25,7 +26,7 @@ public class NodeEmaneDialog extends StageDialog { public NodeEmaneDialog(Controller controller) { super(controller, "/fxml/node_emane_dialog.fxml"); - JFXButton saveButton = createButton("Save"); + saveButton = createButton("Save"); saveButton.setOnAction(event -> { String model = modelCombo.getSelectionModel().getSelectedItem(); coreNode.setEmane(model); @@ -88,9 +89,15 @@ public class NodeEmaneDialog extends StageDialog { } } + private void setDisabled(boolean isDisabled) { + saveButton.setDisable(isDisabled); + modelCombo.setDisable(isDisabled); + } + public void showDialog(CoreNode node) { coreNode = node; setTitle(String.format("%s - EMANE", node.getName())); + setDisabled(getCoreClient().isRunning()); show(); } } diff --git a/corefx/src/main/java/com/core/ui/dialogs/NodeWlanDialog.java b/corefx/src/main/java/com/core/ui/dialogs/NodeWlanDialog.java index 79fb202f..8cbc7868 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/NodeWlanDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/NodeWlanDialog.java @@ -14,6 +14,7 @@ import java.io.IOException; public class NodeWlanDialog extends StageDialog { private static final Logger logger = LogManager.getLogger(); + private final JFXButton saveButton; private CoreNode coreNode; @FXML private JFXTextField rangeTextField; @FXML private JFXTextField bandwidthTextField; @@ -24,7 +25,7 @@ public class NodeWlanDialog extends StageDialog { public NodeWlanDialog(Controller controller) { super(controller, "/fxml/wlan_dialog.fxml"); - JFXButton saveButton = createButton("Save"); + saveButton = createButton("Save"); saveButton.setOnAction(event -> { try { WlanConfig config = new WlanConfig(); @@ -44,9 +45,19 @@ public class NodeWlanDialog extends StageDialog { addCancelButton(); } + private void setDisabled(boolean isDisabled) { + rangeTextField.setDisable(isDisabled); + bandwidthTextField.setDisable(isDisabled); + jitterTextField.setDisable(isDisabled); + delayTextField.setDisable(isDisabled); + lossTextField.setDisable(isDisabled); + saveButton.setDisable(isDisabled); + } + public void showDialog(CoreNode node) { coreNode = node; setTitle(String.format("%s - WLAN", node.getName())); + setDisabled(getCoreClient().isRunning()); try { WlanConfig wlanConfig = getCoreClient().getWlanConfig(coreNode);