Search in sources :

Example 1 with RemoveTypeCommand

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

the class MainViewTransformations method addTypeListener.

public static void addTypeListener(TypeClassRepresentationController boutType, MomentExpVBox m, Type type, Main main) {
    boutType.focusedProperty().addListener(new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
            if (newPropertyValue) {
                boutType.colorFocus();
            } else {
                boutType.resetFocusColor();
            }
        }
    });
    boutType.setOnMouseClicked(new EventHandler<Event>() {

        @Override
        public void handle(Event event) {
            boutType.requestFocus();
        }
    });
    boutType.setOnKeyPressed(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent event) {
            if ((event.getCode().equals(KeyCode.DELETE) || event.getCode().equals(KeyCode.BACK_SPACE)) & boutType.isFocused()) {
                RemoveTypeCommand cmd = new RemoveTypeCommand(boutType, m, main);
                cmd.execute();
                UndoCollector.INSTANCE.add(cmd);
            }
        }
    });
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) RemoveTypeCommand(controller.command.RemoveTypeCommand) MouseEvent(javafx.scene.input.MouseEvent) DragEvent(javafx.scene.input.DragEvent) Event(javafx.event.Event) KeyEvent(javafx.scene.input.KeyEvent)

Aggregations

RemoveTypeCommand (controller.command.RemoveTypeCommand)1 Event (javafx.event.Event)1 DragEvent (javafx.scene.input.DragEvent)1 KeyEvent (javafx.scene.input.KeyEvent)1 MouseEvent (javafx.scene.input.MouseEvent)1