JavaFX reflective access + Javadoc + @delvh
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good
All checks were successful
zdm/undo-redo/pipeline/head This commit looks good
* Allow reflective access to the JavaFX module for javafx.base * Add space to the unit test orders * Improve Javadoc * Add @delvh as developer
This commit is contained in:
@ -9,6 +9,11 @@ import dev.kske.undoredo.core.*;
|
||||
/**
|
||||
* Wraps an ordinary change manager into an observable change manager, providing the required
|
||||
* properties for concrete implementations.
|
||||
* <p>
|
||||
* The properties have the same name as their corresponding {@code -property()} methods and can be
|
||||
* accessed reflectively from JavaFX, e.g. through
|
||||
* {@link javafx.beans.binding.Bindings#select(Object, String...)}. Alternatively, the property
|
||||
* names are available as constants.
|
||||
*
|
||||
* @param <C> the change type to store in this change manager
|
||||
* @param <M> the type of change manager to wrap
|
||||
@ -18,18 +23,29 @@ import dev.kske.undoredo.core.*;
|
||||
public class ChangeManagerWrapper<C extends Change, M extends ChangeManager<C>>
|
||||
implements ObservableChangeManager<C> {
|
||||
|
||||
public static final String LAST_CHANGE = "lastChange";
|
||||
public static final String AT_MARKED_INDEX = "atMarkedIndex";
|
||||
public static final String UNDO_AVAILABLE = "undoAvailable";
|
||||
public static final String REDO_AVAILABLE = "redoAvailable";
|
||||
|
||||
protected ReadOnlyObjectWrapper<C> lastChange =
|
||||
new ReadOnlyObjectWrapper<>(this, "lastChange");
|
||||
new ReadOnlyObjectWrapper<>(this, LAST_CHANGE);
|
||||
protected ReadOnlyBooleanWrapper atMarkedIndex =
|
||||
new ReadOnlyBooleanWrapper(this, "atMarkedIndex");
|
||||
new ReadOnlyBooleanWrapper(this, AT_MARKED_INDEX);
|
||||
protected ReadOnlyBooleanWrapper undoAvailable =
|
||||
new ReadOnlyBooleanWrapper(this, "undoAvailable");
|
||||
new ReadOnlyBooleanWrapper(this, UNDO_AVAILABLE);
|
||||
protected ReadOnlyBooleanWrapper redoAvailable =
|
||||
new ReadOnlyBooleanWrapper(this, "redoAvailable");
|
||||
new ReadOnlyBooleanWrapper(this, REDO_AVAILABLE);
|
||||
|
||||
protected final M manager;
|
||||
|
||||
protected ChangeManagerWrapper(M manager) {
|
||||
/**
|
||||
* Initializes a change manager wrapper.
|
||||
*
|
||||
* @param manager the change manager to wrap
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public ChangeManagerWrapper(M manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
|
@ -7,35 +7,39 @@ import javafx.beans.property.*;
|
||||
import dev.kske.undoredo.core.*;
|
||||
|
||||
/**
|
||||
* A change manager that exposes its state through JavaFX properties, thereby allowing a direct
|
||||
* integration of Undo-Redo with JavaFX listeners and property bindings.
|
||||
*
|
||||
* @param <C> the change type to store in this change manager
|
||||
* @author Kai S. K. Engelbart
|
||||
* @since 0.0.1
|
||||
* @see ChangeManagerWrapper
|
||||
*/
|
||||
public interface ObservableChangeManager<C extends Change> extends ChangeManager<C> {
|
||||
|
||||
ReadOnlyObjectProperty<C> lastChangeProperty();
|
||||
|
||||
|
||||
@Override
|
||||
default Optional<C> getLastChange() {
|
||||
return Optional.of(lastChangeProperty().get());
|
||||
}
|
||||
|
||||
|
||||
ReadOnlyBooleanProperty atMarkedIndexProperty();
|
||||
|
||||
|
||||
@Override
|
||||
default boolean isAtMarkedIndex() {
|
||||
return atMarkedIndexProperty().get();
|
||||
}
|
||||
|
||||
|
||||
ReadOnlyBooleanProperty undoAvailableProperty();
|
||||
|
||||
|
||||
@Override
|
||||
default boolean isUndoAvailable() {
|
||||
return undoAvailableProperty().get();
|
||||
}
|
||||
|
||||
|
||||
ReadOnlyBooleanProperty redoAvailableProperty();
|
||||
|
||||
|
||||
@Override
|
||||
default boolean isRedoAvailable() {
|
||||
return redoAvailableProperty().get();
|
||||
|
@ -8,6 +8,8 @@ module dev.kske.undoredo.javafx {
|
||||
|
||||
exports dev.kske.undoredo.javafx;
|
||||
|
||||
requires dev.kske.undoredo.core;
|
||||
opens dev.kske.undoredo.javafx to javafx.base;
|
||||
|
||||
requires transitive dev.kske.undoredo.core;
|
||||
requires transitive javafx.base;
|
||||
}
|
||||
|
Reference in New Issue
Block a user