Search in sources :

Example 1 with RenameMomentCommand

use of controller.command.RenameMomentCommand in project uPMT by coco35700.

the class MomentExpVBox method editNameMode.

private void editNameMode() {
    TextField t = new TextField();
    t.setMaxWidth(180);
    t.setText(moment.getName());
    t.requestFocus();
    ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
            if (!newPropertyValue) {
                RenameMomentCommand cmd = new RenameMomentCommand(nameController, moment.getName(), t.getText(), main);
                cmd.execute();
                UndoCollector.INSTANCE.add(cmd);
                borderPaneLabel.setCenter(label);
                // borderPaneLabel.setCenter(label);
                t.focusedProperty().removeListener(this);
            }
        }
    };
    t.setOnKeyPressed(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
                t.setText(t.getText());
                borderPaneLabel.setCenter(label);
            // borderPaneLabel.setCenter(label);
            }
            if (event.getCode() == KeyCode.ESCAPE) {
                borderPaneLabel.setCenter(label);
            // borderPaneLabel.setCenter(label);
            }
        }
    });
    t.focusedProperty().addListener(listener);
    Platform.runLater(() -> t.requestFocus());
    Platform.runLater(() -> t.selectAll());
    borderPaneLabel.setCenter(t);
// borderPaneLabel.setCenter(t);
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) RenameMomentCommand(controller.command.RenameMomentCommand) ObservableValue(javafx.beans.value.ObservableValue) TextField(javafx.scene.control.TextField) ChangeListener(javafx.beans.value.ChangeListener)

Example 2 with RenameMomentCommand

use of controller.command.RenameMomentCommand in project uPMT by coco35700.

the class SelectDescriptemePartController method validateSelection.

@FXML
public void validateSelection() {
    String newExtract = "";
    if (this.descriptemeArea.getSelectedText().trim().length() != 0)
        newExtract = this.descriptemeArea.getSelectedText().trim();
    else
        newExtract = null;
    if (propertyExtractController != null) {
        // System.out.println("Description: "+main.getCurrentMoment().getCurrentProperty().getDescripteme().getTexte());
        // System.out.println("Valeur: "+main.getCurrentMoment().getCurrentProperty().getValeur());
        ChangeExtractProperty cmd = new ChangeExtractProperty(propertyExtractController, propertyExtractController.getProperty().getExtract().getTexte(), newExtract, main);
        main.getCurrentMoment().getCurrentProperty().setExtract(newExtract);
        cmd.execute();
        UndoCollector.INSTANCE.add(cmd);
    } else {
        // System.out.println("Moment: "+main.getCurrentMoment().getMoment().getNom());
        RenameMomentCommand cmd = new RenameMomentCommand(main.getCurrentMoment().getMomentExtractController(), main.getCurrentMoment().getMoment().getDescripteme(), newExtract, main);
        cmd.execute();
        UndoCollector.INSTANCE.add(cmd);
    }
    main.needToSave();
    stage.close();
}
Also used : RenameMomentCommand(controller.command.RenameMomentCommand) ChangeExtractProperty(controller.command.ChangeExtractProperty) FXML(javafx.fxml.FXML)

Aggregations

RenameMomentCommand (controller.command.RenameMomentCommand)2 ChangeExtractProperty (controller.command.ChangeExtractProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableValue (javafx.beans.value.ObservableValue)1 FXML (javafx.fxml.FXML)1 TextField (javafx.scene.control.TextField)1 KeyEvent (javafx.scene.input.KeyEvent)1