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 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<ConfigGroup> 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;
}

View file

@ -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<String> 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();
}
}

View file

@ -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);