use of org.gwtproject.cell.client.ValueUpdater in project gwtproject by treblereel.
the class ColumnTest method testOnBrowserEventWithoutFieldUpdater.
public void testOnBrowserEventWithoutFieldUpdater() {
final Element theElem = Document.get().createDivElement();
final NativeEvent theEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
final MockEditableCell cell = new MockEditableCell() {
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) {
assertEquals(theElem, parent);
assertEquals("test", value);
assertEquals("oldViewData", getViewData("test"));
assertEquals(theEvent, event);
assertNull(valueUpdater);
setViewData("test", "newViewData");
}
};
Column<String, String> column = new IdentityColumn<String>(cell);
cell.setViewData("test", "oldViewData");
Context context = new Context(3, 0, null);
column.onBrowserEvent(context, theElem, "test", theEvent);
}
use of org.gwtproject.cell.client.ValueUpdater in project gwtproject by treblereel.
the class ColumnTest method testOnBrowserEventWithFieldUpdater.
public void testOnBrowserEventWithFieldUpdater() {
final Element theElem = Document.get().createDivElement();
final NativeEvent theEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
final MockEditableCell cell = new MockEditableCell() {
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, ValueUpdater<String> valueUpdater) {
assertEquals(theElem, parent);
assertEquals("test", value);
assertEquals("oldViewData", getViewData("test"));
assertEquals(theEvent, event);
assertNotNull(valueUpdater);
setViewData("test", "newViewData");
valueUpdater.update("newValue");
}
};
final Column<String, String> column = new IdentityColumn<String>(cell);
final MockFieldUpdater<String, String> fieldUpdater = new MockFieldUpdater<String, String>() {
@Override
public void update(int index, String object, String value) {
// The new view data should already be set.
assertEquals("newViewData", cell.getViewData("test"));
super.update(index, object, value);
}
};
column.setFieldUpdater(fieldUpdater);
cell.setViewData("test", "oldViewData");
Context context = new Context(3, 0, null);
column.onBrowserEvent(context, theElem, "test", theEvent);
fieldUpdater.assertUpdateCalled(true);
fieldUpdater.assertIndex(3);
fieldUpdater.assertObject("test");
fieldUpdater.assertValue("newValue");
}
use of org.gwtproject.cell.client.ValueUpdater in project gwtproject by treblereel.
the class ColumnTest method testDelayedValueUpdaer.
/**
* Test that a cell can hold onto the {@link ValueUpdater} and update it
* later.
*/
public void testDelayedValueUpdaer() {
final Element theElem = Document.get().createDivElement();
final NativeEvent theEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
final MockEditableCell cell = new MockEditableCell() {
@Override
public void onBrowserEvent(Context context, Element parent, String value, NativeEvent event, final ValueUpdater<String> valueUpdater) {
setViewData("test", "newViewData");
new Timer() {
@Override
public void run() {
valueUpdater.update("newValue");
}
}.schedule(200);
}
};
final Column<String, String> column = new IdentityColumn<>(cell);
final MockFieldUpdater<String, String> fieldUpdater = new MockFieldUpdater<String, String>() {
@Override
public void update(int index, String object, String value) {
assertEquals("newViewData", cell.getViewData("test"));
super.update(index, object, value);
finishTest();
}
};
column.setFieldUpdater(fieldUpdater);
// Fire the event to the cell.
delayTestFinish(5000);
cell.setViewData("test", "oldViewData");
Context context = new Context(3, 0, null);
column.onBrowserEvent(context, theElem, "test", theEvent);
}
use of org.gwtproject.cell.client.ValueUpdater in project gwtproject by treblereel.
the class DefaultNodeInfoTest method testAccessors.
public void testAccessors() {
org.gwtproject.view.client.ListDataProvider<String> provider = new ListDataProvider<String>();
TextCell cell = new TextCell();
org.gwtproject.view.client.SingleSelectionModel<String> selectionModel = new org.gwtproject.view.client.SingleSelectionModel<String>(null);
ValueUpdater<String> valueUpdater = new ValueUpdater<String>() {
@Override
public void update(String value) {
}
};
DefaultNodeInfo<String> nodeInfo = new DefaultNodeInfo<String>(provider, cell, selectionModel, valueUpdater);
assertEquals(provider, nodeInfo.getProvidesKey());
assertEquals(cell, nodeInfo.getCell());
assertEquals(selectionModel, nodeInfo.getSelectionModel());
assertEquals(valueUpdater, nodeInfo.getValueUpdater());
}
Aggregations