Commit 66c0f507 authored by Ivan Dages's avatar Ivan Dages
Browse files

unlink controller

parent 22e0a649
......@@ -739,7 +739,40 @@ public class EditorMenuBar extends MenuBar {
linkStage.show();
});
axisMenu.getItems().addAll(addAxisItem, calibrateAxisItem, linkAxisItem, displayAxisItem);
MenuItem unlinkAxisItem = new MenuItem("Unlink axis");
unlinkAxisItem.setOnAction(event -> {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getRoot() == null) {
return;
}
final Component selectedComponent = selectComponent(calibrateAxisItem.getText());
final Axis selectedAxis = (selectedComponent == null) ? null : selectedComponent.getAxis();
if (selectedAxis == null) {
// Error alert already display in selectComponent(String)
return;
}
if (selectedComponent.getController() != null) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(linkAxisItem.getText());
alert.setContentText("Do you want to unlink the controller " + selectedComponent.getController().getName()
+ " from " + selectedComponent.getName() + " ?");
Optional<ButtonType> res = alert.showAndWait();
if (res.isPresent()) {
if (res.get() != ButtonType.OK) {
return;
}
}
selectedComponent.setController(null);
} else {
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle(linkAxisItem.getText());
alert.setContentText("No controller linked to " + selectedComponent.getName());
alert.showAndWait();
}
});
axisMenu.getItems().addAll(addAxisItem, calibrateAxisItem, linkAxisItem, unlinkAxisItem, displayAxisItem);
MenuItem modifyMaterialItem = new MenuItem("Modify material");
modifyMaterialItem.setOnAction(new EventHandler<ActionEvent>() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment