本文整理汇总了Java中org.reactfx.EventSource类的典型用法代码示例。如果您正苦于以下问题:Java EventSource类的具体用法?Java EventSource怎么用?Java EventSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventSource类属于org.reactfx包,在下文中一共展示了EventSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUndoInvertsTheChange
import org.reactfx.EventSource; //导入依赖的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());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:24,代码来源:UndoManagerTest.java
示例2: testMark
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testMark() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.fixedSizeHistoryUndoManager(
changes, c -> c, changes::push, 4);
assertTrue(um.atMarkedPositionProperty().get());
changes.push(1);
assertFalse(um.atMarkedPositionProperty().get());
changes.push(2);
um.mark();
assertTrue(um.atMarkedPositionProperty().get());
changes.push(3);
changes.push(4);
assertFalse(um.atMarkedPositionProperty().get());
um.undo();
um.undo();
assertTrue(um.atMarkedPositionProperty().get());
changes.push(3);
changes.push(4);
changes.push(5); // overflow
changes.push(6);
assertFalse(um.atMarkedPositionProperty().get());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:25,代码来源:UndoManagerTest.java
示例3: testAtMarkedPositionRevalidation
import org.reactfx.EventSource; //导入依赖的package包/类
/**
* Tests that isAtMarkedPosition() forces atMarkedPositionProperty()
* become valid.
*/
@Test
public void testAtMarkedPositionRevalidation() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.zeroHistoryUndoManager(changes);
um.atMarkedPositionProperty().get(); // atMarkedPositionProperty is now valid
// we are going to expect two invalidations
CountDownLatch latch = new CountDownLatch(2);
um.atMarkedPositionProperty().addListener(observable -> latch.countDown());
changes.push(1); // atMarkedPositionProperty has been invalidated
assertEquals(1, latch.getCount());
um.isAtMarkedPosition(); // we want to test whether this caused revalidation of atMarkedPositionProperty
changes.push(2); // should have caused invalidation of atMarkedPositionProperty
assertEquals(0, latch.getCount());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:24,代码来源:UndoManagerTest.java
示例4: testPushedNonIdentityChangeIsStored
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testPushedNonIdentityChangeIsStored() {
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(4);
assertTrue(um.isUndoAvailable());
um.undo();
assertEquals(-4, lastAppliedValue.get());
assertFalse(um.isUndoAvailable());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:18,代码来源:UndoManagerTest.java
示例5: testPushedIdentityChangeIsNotStored
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testPushedIdentityChangeIsNotStored() {
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
// force lastAppliedValue to store non-zero value
changes.push(4);
um.undo();
// test that pushed identity change is not stored
changes.push(0);
assertFalse(um.isUndoAvailable());
assertEquals(-4, lastAppliedValue.get());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:21,代码来源:UndoManagerTest.java
示例6: testMergeResultingInNonIdentityChangeStoresMergeAndPreventsNextMerge
import org.reactfx.EventSource; //导入依赖的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());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:25,代码来源:UndoManagerTest.java
示例7: testPositionValidAfterAddingAChange
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testPositionValidAfterAddingAChange() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(changes, c -> c, changes::push);
changes.push(1);
UndoPosition pos = um.getCurrentPosition();
changes.push(1);
assertTrue(pos.isValid());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:11,代码来源:UndoManagerTest.java
示例8: testPositionInvalidAfterMerge
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testPositionInvalidAfterMerge() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes, c -> -c, changes::push, (c1, c2) -> Optional.of(c1 + c2));
changes.push(1);
UndoPosition pos = um.getCurrentPosition();
changes.push(1);
assertFalse(pos.isValid());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:12,代码来源:UndoManagerTest.java
示例9: testRedoUnavailableAfterAnnihilation
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void testRedoUnavailableAfterAnnihilation() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes, c -> -c, changes::push, (c1, c2) -> Optional.of(c1 + c2), c -> c == 0);
changes.push(1);
changes.push(-1);
assertFalse(um.isRedoAvailable());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:11,代码来源:UndoManagerTest.java
示例10: zeroHistoryUndoManagerMark
import org.reactfx.EventSource; //导入依赖的package包/类
@Test
public void zeroHistoryUndoManagerMark() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.zeroHistoryUndoManager(changes);
assertTrue(um.atMarkedPositionProperty().get());
changes.push(1);
assertFalse(um.atMarkedPositionProperty().get());
changes.push(2);
um.mark();
assertTrue(um.atMarkedPositionProperty().get());
changes.push(3);
changes.push(4);
assertFalse(um.atMarkedPositionProperty().get());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:16,代码来源:UndoManagerTest.java
示例11: testFailFastWhenExpectedChangeNotReceived
import org.reactfx.EventSource; //导入依赖的package包/类
@Test(expected = IllegalStateException.class)
public void testFailFastWhenExpectedChangeNotReceived() {
EventSource<Integer> changes = new EventSource<>();
UndoManager<?> um = UndoManagerFactory.unlimitedHistoryUndoManager(
changes, i -> -i, i -> {});
changes.push(1);
um.undo(); // should throw because the undone change is not received back
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:11,代码来源:UndoManagerTest.java
示例12: testMergeResultingInIdentityChangeAnnihilatesBothAndPreventsNextMerge
import org.reactfx.EventSource; //导入依赖的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());
}
开发者ID:FXMisc,项目名称:UndoFX,代码行数:34,代码来源:UndoManagerTest.java
示例13: start
import org.reactfx.EventSource; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
EasyDI context = new EasyDI();
EventSource<Action> actionStream = new EventSource<>();
context.bindInstance(EventStream.class, actionStream);
context.bindInstance(EventSource.class, actionStream);
ViewLoader.setDependencyInjector(context::getInstance);
final Parent root = ViewLoader.load(CounterView.class);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
开发者ID:lestard,项目名称:FluxFX,代码行数:19,代码来源:CounterApp.java
示例14: CounterView
import org.reactfx.EventSource; //导入依赖的package包/类
public CounterView(CounterStore store, EventSource<Action> actionStream) {
this.store = store;
this.actionStream = actionStream;
}
开发者ID:lestard,项目名称:FluxFX,代码行数:5,代码来源:CounterView.java
示例15: setup
import org.reactfx.EventSource; //导入依赖的package包/类
@Before
public void setup() {
actionStream = new EventSource<>();
store = new CounterStore(actionStream);
}
开发者ID:lestard,项目名称:FluxFX,代码行数:6,代码来源:CounterStoreTest.java
注:本文中的org.reactfx.EventSource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论