Skip to content
Snippets Groups Projects

Resolve "fonctionnalité permettant de déplacer une étape dans une étape parent"

1 file
+ 78
1
Compare changes
  • Side-by-side
  • Inline
@@ -298,7 +298,7 @@ public class DataTreeCell extends TextFieldTreeCell<DataNode> {
parentStep.addSubStep(s);
}
itiFile.addLinkItinerary(s, null);
itiFile.addStep(s);
DataNode stepNode = new DataNode(DataNodeType.STEP);
stepNode.setItineraryFile(itiFile);
if(parentStep != null) {
@@ -1153,6 +1153,83 @@ public class DataTreeCell extends TextFieldTreeCell<DataNode> {
});
if (s.getSubStep().isEmpty()) menu.getItems().add(newMix);
MenuItem moveStep = new MenuItem("Move Step");
moveStep.setDisable(false);
moveStep.disableProperty().bind(Bindings.not(mainApp.getEditProperty()));
moveStep.setGraphic(new ImageView(UITools.getImage("resources/images/move_16.png")));
moveStep.setOnAction(event -> {
StepFile stepFile = (StepFile) item.getFile();
GeneralFile processFile = stepFile.getGeneralFile();
Dialog<ButtonType> moveStepDiag = new Dialog<>();
moveStepDiag.getDialogPane().setPrefSize(500, 400);
moveStepDiag.initModality(Modality.WINDOW_MODAL);
moveStepDiag.initOwner(MainApp.primaryStage);
AnchorPane pane = new AnchorPane();
VBox vb = new VBox(1.0);
vb.getChildren().add(new Label("Select the step / itinerary where you want to move this step"));
TreeItem<GenericFile> fakeRoot = new TreeItem<>(null);
TreeView<GenericFile> treeStep = new TreeView<>(fakeRoot);
treeStep.setCellFactory(factory -> new TextFieldTreeCell<>(){});
treeStep.setShowRoot(false);
processFile.getItinerary().forEach(itiFile -> {
TreeItem<GenericFile> ckIti = new TreeItem<>(itiFile);
fakeRoot.getChildren().add(ckIti);
itiFile.getListStep().forEach(step -> {
TreeItem<GenericFile> ckStep = new TreeItem<>(step);
ckIti.getChildren().add(ckStep);
});
});
vb.getChildren().add(treeStep);
pane.getChildren().add(vb);
AnchorPane.setTopAnchor(vb, 2.0);
AnchorPane.setLeftAnchor(vb, 2.0);
AnchorPane.setRightAnchor(vb, 2.0);
AnchorPane.setBottomAnchor(vb, 2.0);
moveStepDiag.getDialogPane().setContent(pane);
moveStepDiag.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
Button bok = (Button) moveStepDiag.getDialogPane().lookupButton(ButtonType.OK);
bok.disableProperty().bind(treeStep.getSelectionModel().selectedItemProperty().isNull());
Optional<ButtonType> result = moveStepDiag.showAndWait();
if (result.isPresent()) {
if (result.get().equals(ButtonType.OK)) {
GenericFile moveTo = treeStep.getSelectionModel().getSelectedItem().getValue();
if(moveTo != null) {
stepFile.removeFather();
// remove step from old itinerary
item.getItineraryFile().removeStepFromItinerary(stepFile);
if(moveTo instanceof ItineraryFile) {
ItineraryFile itiFile = (ItineraryFile) moveTo;
itiFile.addStep(stepFile);
MainApp.getDataControler().buildProcessTree(itiFile.getProcessFile());
}
if(moveTo instanceof StepFile) {
StepFile stepFileFather = (StepFile) moveTo;
stepFileFather.addSubStep(stepFile);
for(ItineraryFile iti : processFile.getItinerary()) {
if(iti.contains(stepFileFather)) {
iti.addStep(stepFile);
}
}
MainApp.getDataControler().buildProcessTree(processFile);
}
MainApp.getDataControler().selectNode(stepFile);
}
}
}
});
menu.getItems().add(moveStep);
MenuItem exportStep = new MenuItem("Export Step");
exportStep.setDisable(false);
Loading