corefx - updated configuration dialogs for nodes to be disabled when running

This commit is contained in:
Blake J. Harnden 2018-11-29 09:26:42 -08:00
parent f9402f53d5
commit 113bd3cb6c
3 changed files with 30 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import com.jfoenix.controls.JFXScrollPane;
import com.jfoenix.controls.JFXTabPane; import com.jfoenix.controls.JFXTabPane;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.scene.control.Tab; import javafx.scene.control.Tab;
import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.ColumnConstraints;
@ -37,8 +38,14 @@ public class ConfigDialog extends StageDialog {
return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList()); return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList());
} }
private void setDisabled(boolean isDisabled) {
saveButton.setDisable(isDisabled);
}
public void showDialog(String title, List<ConfigGroup> configGroups, Runnable runnable) { public void showDialog(String title, List<ConfigGroup> configGroups, Runnable runnable) {
setTitle(title); setTitle(title);
boolean sessionRunning = getCoreClient().isRunning();
setDisabled(sessionRunning);
configItems.clear(); configItems.clear();
tabPane.getTabs().clear(); tabPane.getTabs().clear();
@ -64,7 +71,9 @@ public class ConfigDialog extends StageDialog {
for (ConfigOption option : group.getOptions()) { for (ConfigOption option : group.getOptions()) {
IConfigItem configItem = ConfigItemUtils.get(getStage(), option); 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); configItems.add(configItem);
index += 1; index += 1;
} }

View file

@ -17,6 +17,7 @@ import java.util.List;
public class NodeEmaneDialog extends StageDialog { public class NodeEmaneDialog extends StageDialog {
private static final Logger logger = LogManager.getLogger(); private static final Logger logger = LogManager.getLogger();
private final JFXButton saveButton;
private CoreNode coreNode; private CoreNode coreNode;
@FXML private JFXComboBox<String> modelCombo; @FXML private JFXComboBox<String> modelCombo;
@FXML private JFXButton modelButton; @FXML private JFXButton modelButton;
@ -25,7 +26,7 @@ public class NodeEmaneDialog extends StageDialog {
public NodeEmaneDialog(Controller controller) { public NodeEmaneDialog(Controller controller) {
super(controller, "/fxml/node_emane_dialog.fxml"); super(controller, "/fxml/node_emane_dialog.fxml");
JFXButton saveButton = createButton("Save"); saveButton = createButton("Save");
saveButton.setOnAction(event -> { saveButton.setOnAction(event -> {
String model = modelCombo.getSelectionModel().getSelectedItem(); String model = modelCombo.getSelectionModel().getSelectedItem();
coreNode.setEmane(model); 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) { public void showDialog(CoreNode node) {
coreNode = node; coreNode = node;
setTitle(String.format("%s - EMANE", node.getName())); setTitle(String.format("%s - EMANE", node.getName()));
setDisabled(getCoreClient().isRunning());
show(); show();
} }
} }

View file

@ -14,6 +14,7 @@ import java.io.IOException;
public class NodeWlanDialog extends StageDialog { public class NodeWlanDialog extends StageDialog {
private static final Logger logger = LogManager.getLogger(); private static final Logger logger = LogManager.getLogger();
private final JFXButton saveButton;
private CoreNode coreNode; private CoreNode coreNode;
@FXML private JFXTextField rangeTextField; @FXML private JFXTextField rangeTextField;
@FXML private JFXTextField bandwidthTextField; @FXML private JFXTextField bandwidthTextField;
@ -24,7 +25,7 @@ public class NodeWlanDialog extends StageDialog {
public NodeWlanDialog(Controller controller) { public NodeWlanDialog(Controller controller) {
super(controller, "/fxml/wlan_dialog.fxml"); super(controller, "/fxml/wlan_dialog.fxml");
JFXButton saveButton = createButton("Save"); saveButton = createButton("Save");
saveButton.setOnAction(event -> { saveButton.setOnAction(event -> {
try { try {
WlanConfig config = new WlanConfig(); WlanConfig config = new WlanConfig();
@ -44,9 +45,19 @@ public class NodeWlanDialog extends StageDialog {
addCancelButton(); 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) { public void showDialog(CoreNode node) {
coreNode = node; coreNode = node;
setTitle(String.format("%s - WLAN", node.getName())); setTitle(String.format("%s - WLAN", node.getName()));
setDisabled(getCoreClient().isRunning());
try { try {
WlanConfig wlanConfig = getCoreClient().getWlanConfig(coreNode); WlanConfig wlanConfig = getCoreClient().getWlanConfig(coreNode);