Top Description Fields Constructors Methods
com.dlsc.preferencesfx.history

public Class History

extends Object
Class Inheritance
Imports
com.dlsc.preferencesfx.model.Setting, javafx.beans.binding.Bindings, javafx.beans.property.BooleanProperty, .IntegerProperty, .ReadOnlyBooleanProperty, .ReadOnlyObjectProperty, .SimpleBooleanProperty, .SimpleIntegerProperty, .SimpleListProperty, .SimpleObjectProperty, javafx.beans.value.ChangeListener, javafx.collections.FXCollections, .ObservableList, org.slf4j.Logger, .LoggerFactory

Manages a list of changes, so undo / redo functionality can be used with Setting.
Authors
François Martin, Marco Sanfratello

Field Summary

Modifier and TypeField and Description
private ObservableList<Change<P>>
private SimpleObjectProperty<Change<P>>
private BooleanProperty
private static final Logger
private IntegerProperty
private BooleanProperty
private BooleanProperty
private IntegerProperty

Constructor Summary

AccessConstructor and Description
public
History()

Initializes a new history object.

Method Summary

Modifier and TypeMethod and Description
private void
addChange(Change<P> change)

public void
attachChangeListener(Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
the setting to observe for changes
setting
)

Adds a listener to the setting, so every time the value of the setting changes, a new Change will be created and added to the list of changes.

public void
clear(boolean
if true, will undo all changes before clearing
undoAll
)

Clears the change history.

public ReadOnlyObjectProperty<Change<P>>
private int

Returns:

the position value before the decrementation
decrementPosition
()

Equals to the same as: "return position--" if position was an Integer.

public void
doWithoutListeners(Setting<E extends Element<E extends Element<E>>, P extends Property<T>>
the setting, whose ChangeListener should be ignored
setting
,
Runnable
the action to be performed
action
)

Enables to perform an action, without firing the attached ChangeListener of a Setting.

public ObservableList<Change<P>>
private boolean
private boolean
private int

Returns:

the position value before the incrementation
incrementPosition
()

Equals to the same as: "return ++position" if position was an Integer.

public boolean
public boolean
public boolean
public ReadOnlyBooleanProperty
private Change<P>
next()

private Change<P>
prev()

public boolean

Returns:

true if successful, false if there are no changes to redo
redo
()

Redos a change in the history.

public void
redoAll()

Redos all changes in the history.

public BooleanProperty
public void
setListenerActive(boolean listenerActive)

private void
public boolean

Returns:

true if successful, false if there are no changes to undo
undo
()

Undos a change in the history.

public void
undoAll()

Undos all changes in the history.

public BooleanProperty
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changesback to summary
private ObservableList<Change<P>> changes
currentChangeback to summary
private SimpleObjectProperty<Change<P>> currentChange
listenerActiveback to summary
private BooleanProperty listenerActive
LOGGERback to summary
private static final Logger LOGGER
positionback to summary
private IntegerProperty position
redoAvailableback to summary
private BooleanProperty redoAvailable
undoAvailableback to summary
private BooleanProperty undoAvailable
validPositionback to summary
private IntegerProperty validPosition

Constructor Detail

Historyback to summary
public History()

Initializes a new history object.

Method Detail

addChangeback to summary
private void addChange(Change<P> change)
attachChangeListenerback to summary
public void attachChangeListener(Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting)

Adds a listener to the setting, so every time the value of the setting changes, a new Change will be created and added to the list of changes.

Parameters
setting:Setting<E extends Element<E extends Element<E>>, P extends Property<T>>

the setting to observe for changes

clearback to summary
public void clear(boolean undoAll)

Clears the change history.

Parameters
undoAll:boolean

if true, will undo all changes before clearing

currentChangePropertyback to summary
public ReadOnlyObjectProperty<Change<P>> currentChangeProperty()
decrementPositionback to summary
private int decrementPosition()

Equals to the same as: "return position--" if position was an Integer.

Returns:int

the position value before the decrementation

doWithoutListenersback to summary
public void doWithoutListeners(Setting<E extends Element<E extends Element<E>>, P extends Property<T>> setting, Runnable action)

Enables to perform an action, without firing the attached ChangeListener of a Setting. This is used by undo and redo, since those shouldn't cause a new change to be added.

Parameters
setting:Setting<E extends Element<E extends Element<E>>, P extends Property<T>>

the setting, whose ChangeListener should be ignored

action:Runnable

the action to be performed

getChangesback to summary
public ObservableList<Change<P>> getChanges()
hasNextback to summary
private boolean hasNext()
hasPrevback to summary
private boolean hasPrev()
incrementPositionback to summary
private int incrementPosition()

Equals to the same as: "return ++position" if position was an Integer.

Returns:int

the position value before the incrementation

isListenerActiveback to summary
public boolean isListenerActive()
isRedoAvailableback to summary
public boolean isRedoAvailable()
isUndoAvailableback to summary
public boolean isUndoAvailable()
listenerActivePropertyback to summary
public ReadOnlyBooleanProperty listenerActiveProperty()
nextback to summary
private Change<P> next()
prevback to summary
private Change<P> prev()
redoback to summary
public boolean redo()

Redos a change in the history.

Returns:boolean

true if successful, false if there are no changes to redo

redoAllback to summary
public void redoAll()

Redos all changes in the history.

redoAvailablePropertyback to summary
public BooleanProperty redoAvailableProperty()
setListenerActiveback to summary
public void setListenerActive(boolean listenerActive)
setupBindingsback to summary
private void setupBindings()
undoback to summary
public boolean undo()

Undos a change in the history.

Returns:boolean

true if successful, false if there are no changes to undo

undoAllback to summary
public void undoAll()

Undos all changes in the history.

undoAvailablePropertyback to summary
public BooleanProperty undoAvailableProperty()