Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.fxmisc.undo.UndoManagerFactory Maven / Gradle / Ivy
package org.fxmisc.undo;
import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import org.fxmisc.undo.impl.ChangeQueue;
import org.fxmisc.undo.impl.FixedSizeChangeQueue;
import org.fxmisc.undo.impl.UndoManagerImpl;
import org.fxmisc.undo.impl.UnlimitedChangeQueue;
import org.fxmisc.undo.impl.ZeroSizeChangeQueue;
import org.reactfx.EventStream;
public interface UndoManagerFactory {
UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo);
UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge);
public static UndoManager unlimitedHistoryUndoManager(
EventStream changeStream,
Consumer apply,
Consumer undo) {
ChangeQueue queue = new UnlimitedChangeQueue();
BiFunction> merge = (c1, c2) -> Optional.empty();
return new UndoManagerImpl<>(queue, apply, undo, merge, changeStream);
}
public static UndoManager unlimitedHistoryUndoManager(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge) {
ChangeQueue queue = new UnlimitedChangeQueue();
return new UndoManagerImpl<>(queue, apply, undo, merge, changeStream);
}
public static UndoManagerFactory unlimitedHistoryFactory() {
return new UndoManagerFactory() {
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo) {
return unlimitedHistoryUndoManager(changeStream, apply, undo);
}
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge) {
return unlimitedHistoryUndoManager(changeStream, apply, undo, merge);
}
};
}
public static UndoManager fixedSizeHistoryUndoManager(
EventStream changeStream,
Consumer apply,
Consumer undo,
int capacity) {
ChangeQueue queue = new FixedSizeChangeQueue(capacity);
BiFunction> merge = (c1, c2) -> Optional.empty();
return new UndoManagerImpl<>(queue, apply, undo, merge, changeStream);
}
public static UndoManager fixedSizeHistoryUndoManager(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge,
int capacity) {
ChangeQueue queue = new FixedSizeChangeQueue(capacity);
return new UndoManagerImpl<>(queue, apply, undo, merge, changeStream);
}
public static UndoManagerFactory fixedSizeHistoryFactory(int capacity) {
return new UndoManagerFactory() {
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo) {
return fixedSizeHistoryUndoManager(changeStream, apply, undo, capacity);
}
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge) {
return fixedSizeHistoryUndoManager(changeStream, apply, undo, merge, capacity);
}
};
}
public static UndoManager zeroHistoryUndoManager(EventStream changeStream) {
ChangeQueue queue = new ZeroSizeChangeQueue<>();
return new UndoManagerImpl<>(queue, c -> {}, c -> {}, (c1, c2) -> Optional.empty(), changeStream);
}
public static UndoManagerFactory zeroHistoryFactory() {
return new UndoManagerFactory() {
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo) {
return zeroHistoryUndoManager(changeStream);
}
@Override
public UndoManager create(
EventStream changeStream,
Consumer apply,
Consumer undo,
BiFunction> merge) {
return zeroHistoryUndoManager(changeStream);
}
};
}
}