当前位置: 首页>>代码示例>>Java>>正文


Java EventSource.push方法代码示例

本文整理汇总了Java中org.reactfx.EventSource.push方法的典型用法代码示例。如果您正苦于以下问题:Java EventSource.push方法的具体用法?Java EventSource.push怎么用?Java EventSource.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.reactfx.EventSource的用法示例。


在下文中一共展示了EventSource.push方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.reactfx.EventSource.push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。