package de.synolo.lib.fw; import de.synolo.lib.fw.cmd.Command; import de.synolo.lib.fw.cmd.UndoManager; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class TestMain extends Application { static class TestCommand implements Command { @Override public void execute() { System.out.println("Execute command!"); } @Override public boolean isUndoable() { return true; } @Override public boolean isCollapsable(Command other) { // TODO Auto-generated method stub return false; } @Override public void collapse(Command other) { // TODO Auto-generated method stub } @Override public void undo() { System.out.println("Undo command"); } @Override public void redo() { System.out.println("Redo command"); } @Override public String getId() { return "command.test"; } } public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) throws Exception { UndoManager undoManager = new UndoManager(); BorderPane bp = new BorderPane(); Scene scene = new Scene(bp); Button btn = new Button("Execute command"); bp.setCenter(btn); Button btnUndo = new Button("Undo"); btnUndo.disableProperty().bind(undoManager.undoAvailableProperty().not()); btnUndo.setOnAction(e -> undoManager.undo()); Button btnRedo = new Button("Redo"); btnRedo.disableProperty().bind(undoManager.redoAvailableProperty().not()); btnRedo.setOnAction(e -> undoManager.redo()); btn.setOnAction(e -> undoManager.execute(new TestCommand())); VBox vbox = new VBox(); vbox.getChildren().addAll(btnUndo, btnRedo); bp.setBottom(vbox); primaryStage.setScene(scene); primaryStage.show(); } }