@Test public void whenTrueDoesNotFireInitialValueWhenFalse() { final BooleanProperty b = booleanProperty("b", false); final StubWidget w = new StubWidget(); binder.when(b).is(true).set("c").on(w); assertThat(w, not(hasStyle("c"))); }
@Test public void whenTrueFiresInitialValueWhenTrue() { final BooleanProperty b = booleanProperty("b", true); final StubWidget w = new StubWidget(); binder.when(b).is(true).set("c").on(w); assertThat(w, hasStyle("c")); }
@Test public void whenIsNull() { final BooleanProperty b = booleanProperty("b", false); final StubWidget w = new StubWidget(); binder.when(b).is(notNull()).set("c").on(w); assertThat(w, hasStyle("c")); b.set(null); assertThat(w, not(hasStyle("c"))); }
@Test public void whenTrueFiresWhenFalseChangesToTrue() { final BooleanProperty b = booleanProperty("b", false); final StubWidget w = new StubWidget(); binder.when(b).is(true).set("c").on(w); b.set(true); assertThat(w, hasStyle("c")); }
private <T extends HasAllDragAndDropHandlers & IsWidget> void set(String type, IsFlowPanel root, Property<T> current, T a) { // just to see one of them not be draggable if (a != view.a4() && a != view.l4()) { a.getIsElement().setAttribute("draggable", "true"); } binder.when(draggingOver(a)).is(true).set(view.style().bold()).on(a); binder.when(dragging(a)).is(true).set(current).to(a); a.addDragStartHandler(e -> e.setData("text", type)); a.addDragOverHandler(e -> e.preventDefault()); a.addDropHandler(e -> { if (type.equals(e.getData("text")) && current.get() != a) { GWT.log("Dropped " + current + " onto " + a); root.remove(current.get()); root.insert(current.get(), root.getWidgetIndex(a)); } e.preventDefault(); }); }