Commit 22e0a649 authored by Ivan Dages's avatar Ivan Dages
Browse files

configurations : save median/min/max & remove

parent 6a0c2b38
......@@ -77,6 +77,8 @@ public class EditorMenuBar extends MenuBar {
/** Show configuration sub-menu. */
private Menu showConfig;
private Menu removeConfig;
/** Selection menu. */
private Menu selection;
......@@ -868,63 +870,71 @@ public class EditorMenuBar extends MenuBar {
}
});
MenuItem saveConfigItem = new MenuItem("Save current configuration");
saveConfigItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
saveConfigItem.setOnAction(event -> {
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
Scene modifyScene = new Scene(scenePane);
Stage modifyStage = new Stage(StageStyle.UTILITY);
modifyStage.setTitle(modifyMaterialItem.getText());
modifyStage.setScene(modifyScene);
modifyStage.initOwner(Nomad3DEditor.getInstance().getStage());
Scene modifyScene = new Scene(scenePane);
Stage modifyStage = new Stage(StageStyle.UTILITY);
modifyStage.setTitle(modifyMaterialItem.getText());
modifyStage.setScene(modifyScene);
modifyStage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane modifyPane = new GridPane();
modifyPane.setVgap(5);
modifyPane.setHgap(10);
modifyPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, modifyPane);
GridPane.setMargin(modifyPane, new Insets(10));
modifyPane.add(new Label("Configuration name : "), 0, 0);
TextField nameField = new TextField();
modifyPane.add(nameField, 1, 0);
GridPane modifyPane = new GridPane();
modifyPane.setVgap(5);
modifyPane.setHgap(10);
modifyPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, modifyPane);
GridPane.setMargin(modifyPane, new Insets(10));
GridPane buttonsPane = new GridPane();
buttonsPane.setVgap(5);
buttonsPane.setHgap(10);
buttonsPane.setAlignment(Pos.CENTER);
scenePane.addRow(1, buttonsPane);
GridPane.setMargin(buttonsPane, new Insets(10));
Button modifyButton = new Button("Save");
modifyButton.setDefaultButton(true);
buttonsPane.addColumn(0, modifyButton);
modifyButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Nomad3DEditor.getInstance().getModel().getRoot().saveCurrentConfiguration(nameField.getText());
updateShowConfigMenu();
modifyStage.close();
}
});
Button cancelButton = new Button("Cancel");
cancelButton.setCancelButton(true);
cancelButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
modifyStage.close();
}
});
buttonsPane.addColumn(1, cancelButton);
modifyPane.add(new Label("Configuration name : "), 0, 0);
TextField nameField = new TextField();
modifyPane.add(nameField, 1, 0);
modifyStage.showAndWait();
}
GridPane buttonsPane = new GridPane();
buttonsPane.setVgap(5);
buttonsPane.setHgap(10);
buttonsPane.setAlignment(Pos.CENTER);
scenePane.addRow(1, buttonsPane);
GridPane.setMargin(buttonsPane, new Insets(10));
Button modifyButton = new Button("Save");
modifyButton.setDefaultButton(true);
buttonsPane.addColumn(0, modifyButton);
modifyButton.setOnAction(modifyEvent -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveCurrentConfiguration(nameField.getText());
updateConfigMenus();
modifyStage.close();
});
Button cancelButton = new Button("Cancel");
cancelButton.setCancelButton(true);
cancelButton.setOnAction(cancelEvent -> {
modifyStage.close();
});
buttonsPane.addColumn(1, cancelButton);
modifyStage.showAndWait();
});
MenuItem saveMedianConfigItem = new MenuItem("Save median configuration");
saveMedianConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMedianConfiguration();
updateConfigMenus();
});
MenuItem saveMinConfigItem = new MenuItem("Save min configuration");
saveMinConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMinConfiguration();
updateConfigMenus();
});
MenuItem saveMaxConfigItem = new MenuItem("Save max configuration");
saveMaxConfigItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().saveMaxConfiguration();
updateConfigMenus();
});
this.removeConfig = new Menu("Remove configuration");
this.edit.getItems().addAll(axisMenu, modifyMaterialItem, removeComponentsItem,
new SeparatorMenuItem(),
analyzeConfigItem, saveConfigItem);
analyzeConfigItem, saveMedianConfigItem, saveMinConfigItem, saveMaxConfigItem, saveConfigItem,
this.removeConfig);
this.view = new Menu("View");
Menu cameraMenu = new Menu("Camera");
......@@ -994,7 +1004,7 @@ public class EditorMenuBar extends MenuBar {
}
});
this.showConfig = new Menu("Show configuration");
updateShowConfigMenu();
updateConfigMenus();
MenuItem resetMoveItem = new MenuItem("Reset movement");
resetMoveItem.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHIFT_DOWN));
resetMoveItem.setOnAction(new EventHandler<ActionEvent>() {
......@@ -1245,7 +1255,7 @@ public class EditorMenuBar extends MenuBar {
*/
private void update() {
updateLodMenu();
updateShowConfigMenu();
updateConfigMenus();
updateAxes();
updateWalls();
updateSystem();
......@@ -1295,12 +1305,15 @@ public class EditorMenuBar extends MenuBar {
/**
* Updates the "show configuration" sub-menu.
*/
private void updateShowConfigMenu() {
private void updateConfigMenus() {
if (Nomad3DEditor.getInstance().getModel() == null || Nomad3DEditor.getInstance().getModel().getRoot() == null) {
return;
}
this.showConfig.getItems().clear();
activeConfiguration = Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations().get(0).getConfiguration();
// Show configuration
this.showConfig.getItems().clear();
for (ConfigParams config : Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations()) {
CheckMenuItem configItem = new CheckMenuItem(config.getConfiguration());
configItem.setSelected(activeConfiguration.equals(config.getConfiguration()));
......@@ -1323,6 +1336,17 @@ public class EditorMenuBar extends MenuBar {
});
this.showConfig.getItems().add(configItem);
}
// Remove configuration
this.removeConfig.getItems().clear();
for (ConfigParams config : Nomad3DEditor.getInstance().getModel().getRoot().getConfigurations()) {
MenuItem configItem = new MenuItem(config.getConfiguration());
configItem.setOnAction(event -> {
Nomad3DEditor.getInstance().getModel().getRoot().removeConfiguration(configItem.getText(), true);
updateConfigMenus();
});
this.removeConfig.getItems().add(configItem);
}
}
/**
......
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