74 lines
1.4 KiB
Java
74 lines
1.4 KiB
Java
package dev.kske.undoredo.core;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* A change manager keeps track of subsequent changes and allows un- and redoing them. A specific
|
|
* change can be marked using {@link #mark()} to keep track of a saved state in the application that
|
|
* uses the manager.
|
|
*
|
|
* @param <C> the change type to store in this change manager
|
|
* @author Maximilian Käfer
|
|
* @author Kai S. K. Engelbart
|
|
* @since 0.0.1
|
|
*/
|
|
public interface ChangeManager<C extends Change> {
|
|
|
|
/**
|
|
* Applies the given change and appends it to the change list.
|
|
*
|
|
* @param change the change to add
|
|
* @since 0.0.1
|
|
*/
|
|
void addChange(C change);
|
|
|
|
/**
|
|
* Undoes the current change.
|
|
*
|
|
* @return whether an action was performed
|
|
* @since 0.1.0
|
|
*/
|
|
boolean undo();
|
|
|
|
/**
|
|
* Applies the change that was undone before.
|
|
*
|
|
* @return whether an action was performed
|
|
* @since 0.0.1
|
|
*/
|
|
boolean redo();
|
|
|
|
/**
|
|
* Marks the current change.
|
|
*
|
|
* @since 0.0.1
|
|
*/
|
|
void mark();
|
|
|
|
/**
|
|
* @return whether the current change is marked
|
|
* @since 0.0.1
|
|
*/
|
|
boolean isAtMarkedIndex();
|
|
|
|
/**
|
|
* @return whether a change is present that can be undone
|
|
* @since 0.0.1
|
|
*/
|
|
boolean isUndoAvailable();
|
|
|
|
/**
|
|
* @return whether a change is present that can be redone
|
|
* @since 0.0.1
|
|
*/
|
|
boolean isRedoAvailable();
|
|
|
|
/**
|
|
* Provides an unmodifiable view of the changes stored in this change manager.
|
|
*
|
|
* @return all stored changes
|
|
* @since 0.0.1
|
|
*/
|
|
List<C> getChanges();
|
|
}
|