本文整理汇总了Java中org.fxmisc.undo.UndoManager.redo方法的典型用法代码示例。如果您正苦于以下问题:Java UndoManager.redo方法的具体用法?Java UndoManager.redo怎么用?Java UndoManager.redo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fxmisc.undo.UndoManager
的用法示例。
在下文中一共展示了UndoManager.redo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUndoInvertsTheChange
import org.fxmisc.undo.UndoManager; //导入方法依赖的package包/类
@Test
public void testUndoInvertsTheChange() {
EventSource<Integer> changes = new EventSource<>();
Var<Integer> lastAction = Var.newSimpleVar(null);
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes, i -> -i, i -> { lastAction.setValue(i); changes.push(i); });
changes.push(3);
changes.push(7);
assertNull(lastAction.getValue());
um.undo();
assertEquals(-7, lastAction.getValue().intValue());
um.undo();
assertEquals(-3, lastAction.getValue().intValue());
um.redo();
assertEquals(3, lastAction.getValue().intValue());
um.redo();
assertEquals(7, lastAction.getValue().intValue());
}
示例2: testMergeResultingInNonIdentityChangeStoresMergeAndPreventsNextMerge
import org.fxmisc.undo.UndoManager; //导入方法依赖的package包/类
@Test
public void testMergeResultingInNonIdentityChangeStoresMergeAndPreventsNextMerge() {
SimpleIntegerProperty lastAppliedValue = new SimpleIntegerProperty(0);
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes,
i -> -i, // invert
i -> { lastAppliedValue.set(i); changes.push(i); }, // apply change and re-emit value so expected change is received
(a, b) -> Optional.of(a + b), // merge adds two changes together
i -> i == 0); // identity change = 0
changes.push(1);
changes.push(2);
assertTrue(um.isUndoAvailable());
um.undo();
assertFalse(um.isUndoAvailable());
assertEquals(-3, lastAppliedValue.get());
um.redo(); // redo to test whether merge occurs on next push
changes.push(5);
assertTrue(um.isUndoAvailable());
um.undo();
assertEquals(-5, lastAppliedValue.get());
}
示例3: testMergeResultingInIdentityChangeAnnihilatesBothAndPreventsNextMerge
import org.fxmisc.undo.UndoManager; //导入方法依赖的package包/类
@Test
public void testMergeResultingInIdentityChangeAnnihilatesBothAndPreventsNextMerge() {
SimpleIntegerProperty lastAppliedValue = new SimpleIntegerProperty(0);
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes,
i -> -i, // invert
i -> { lastAppliedValue.set(i); changes.push(i); }, // apply change and re-emit value so expected change is received
(a, b) -> Optional.of(a + b), // merge adds two changes together
i -> i == 0); // identity change = 0
// have at least one change stored
changes.push(6);
// prevent next merge from occurring
um.preventMerge();
// now push the identity-resulting merge changes
changes.push(-3); // change A
changes.push(3); // change B
// changes should annihilate; neither are stored
assertTrue(um.isUndoAvailable());
um.undo();
assertFalse(um.isUndoAvailable());
assertEquals(-6, lastAppliedValue.get());
um.redo(); // redo to test whether merge occurs on next push
changes.push(3);
assertTrue(um.isUndoAvailable());
um.undo();
assertTrue(um.isUndoAvailable());
assertEquals(-3, lastAppliedValue.get());
}