Commit 6f385335 authored by legoc's avatar legoc
Browse files

Some cleaning

parent e2623097
......@@ -1363,116 +1363,10 @@ public class EditorMenuBar extends MenuBar {
stage.showAndWait();
});
MenuItem regroupComponentsItem = new MenuItem("Regroup Components");
regroupComponentsItem.setOnAction(event -> {
if (!modelLoaded()) {
return;
}
HashSet<Component> selectedComponents = Component.excludeComponentsWithParentIn(Nomad3DEditor.getInstance().getModel().getSelection());
if (selectedComponents.isEmpty()) {
Alert emptyAlert = new Alert(AlertType.WARNING);
emptyAlert.setTitle(regroupComponentsItem.getText());
emptyAlert.setContentText("Empty selection.");
emptyAlert.showAndWait();
return;
}
Component commonAncestor = Component.ancestorOf(selectedComponents);
if (commonAncestor == null) {
Alert ancestorAlert = new Alert(AlertType.WARNING);
ancestorAlert.setTitle(regroupComponentsItem.getText());
ancestorAlert.setContentText("Unable to find the common parent of the selection.");
ancestorAlert.showAndWait();
return;
}
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
Scene regroupScene = new Scene(scenePane);
Stage regroupStage = new Stage(StageStyle.UTILITY);
regroupStage.setTitle(editMaterialItem.getText());
regroupStage.setScene(regroupScene);
regroupStage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane parentPane = new GridPane();
parentPane.setVgap(5);
parentPane.setHgap(10);
parentPane.setAlignment(Pos.CENTER);
scenePane.addRow(0, parentPane);
GridPane.setMargin(parentPane, 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));
Label parentLabel = new Label("Parent Of The Group :");
ToggleGroup buttonsGroup = new ToggleGroup();
RadioButton commonButton = new RadioButton("Common parent : ");
commonButton.setSelected(true);
commonButton.setToggleGroup(buttonsGroup);
RadioButton selectButton = new RadioButton("Parent of : ");
selectButton.setToggleGroup(buttonsGroup);
Label commonLabel = new Label(commonAncestor.getName());
ObservableList<Component> selectList = FXCollections.observableArrayList(selectedComponents);
ComboBox<Component> selectBox = new ComboBox<>(selectList);
selectBox.setCellFactory(ComboCell.FACTORY);
CheckBox addLevelBox = new CheckBox("Insert A New Component Regrouping The Selection");
addLevelBox.setSelected(true);
parentPane.addRow(0, parentLabel);
parentPane.addRow(1, commonButton, commonLabel);
parentPane.addRow(2, selectButton, selectBox);
parentPane.addRow(3, addLevelBox);
GridPane.setColumnSpan(parentLabel, GridPane.REMAINING);
GridPane.setColumnSpan(addLevelBox, GridPane.REMAINING);
Button okButton = new Button("OK");
okButton.setDefaultButton(true);
okButton.setOnAction(okEvent -> {
try {
Component newParent = null;
if (commonButton.isSelected()) {
newParent = commonAncestor;
} else if (selectButton.isSelected()) {
newParent = selectBox.getSelectionModel().getSelectedItem().getParent();
}
if (addLevelBox.isSelected()) {
System.out.println("inserting " + selectedComponents.size() + " components");
newParent.insertBlock(selectedComponents, false, "REGROUPED");
} else {
for (Component comp : selectedComponents) {
newParent.addChild(comp);
}
}
updateScene();
} catch (Exception e) {
e.printStackTrace();
} finally {
regroupStage.close();
}
});
Button cancelButton = new Button("Cancel");
cancelButton.setCancelButton(true);
cancelButton.setOnAction(cancelEvent -> {
regroupStage.close();
});
buttonsPane.addRow(0, okButton, cancelButton);
regroupStage.show();
});
///////////////////////////////////////////////////////////////////////////////////////
// Not used anymore
// TODO remove?
MenuItem subdivideComponentItem = new MenuItem("Subdivide Component");
subdivideComponentItem.setOnAction(event -> {
if (!modelLoaded()) {
......@@ -1885,9 +1779,9 @@ public class EditorMenuBar extends MenuBar {
modifyStage.showAndWait();
});
Menu componentsMenu = new Menu("Components");
componentsMenu.getItems().addAll(regroupComponentsItem, subdivideComponentItem, insertComponentItem);
this.edit.getItems().addAll(undoItem, new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem, new SeparatorMenuItem(), componentsMenu, addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem);
// Menu componentsMenu = new Menu("Components");
// componentsMenu.getItems().addAll(subdivideComponentItem, insertComponentItem);
this.edit.getItems().addAll(undoItem, new SeparatorMenuItem(), editAxisItem, displayAxisItem, editMaterialItem, new SeparatorMenuItem(), addComponentItem, removeComponentsItem, renameComponentItem, moveComponentsItem);
this.view = new Menu("View");
Menu cameraMenu = new Menu("Camera");
......
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