use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent2.
/**
* If the selection event triggers the selection of another row, the selection event must not be ignored.
*/
@Test
public void testIgnorableSelectionEvent2() throws JSONException {
Table table = new Table() {
@Override
protected void execRowsSelected(List<? extends ITableRow> rows) {
selectRow(4);
}
};
table.fill(5);
table.initTable();
ITableRow row2 = table.getRow(2);
ITableRow row4 = table.getRow(4);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row2));
assertFalse(row2.isSelected());
assertFalse(row4.isSelected());
jsonTable.handleUiEvent(event);
assertFalse(row2.isSelected());
assertTrue(row4.isSelected());
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 1);
List<ITableRow> tableRows = jsonTable.extractTableRows(responseEvents.get(0).getData());
assertEquals(row4, tableRows.get(0));
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method createJsonRowsSelectedEvent.
public static JsonEvent createJsonRowsSelectedEvent(String rowId) throws JSONException {
// never used
String tableId = "x";
JSONObject data = new JSONObject();
JSONArray rowIds = new JSONArray();
if (rowId != null) {
rowIds.put(rowId);
}
data.put(JsonTable.PROP_ROW_IDS, rowIds);
return new JsonEvent(tableId, JsonTable.EVENT_ROWS_SELECTED, data);
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableRowOrderChangedEvent.
/**
* Response must not contain the row_order_changed event if the sort was triggered by the request
*/
@Test
public void testIgnorableRowOrderChangedEvent() throws JSONException {
Table table = createTableFixture(5);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
IColumn column = table.getColumnSet().getFirstVisibleColumn();
// ----------
JsonEvent event = createJsonRowsSortedEvent(jsonTable.getColumnId(column), !column.isSortAscending());
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "rowOrderChanged");
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTableTest method testClearSelectionEvent.
/**
* Tests whether the model rows get correctly unselected
*/
@Test
public void testClearSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
ITableRow row1 = table.getRow(1);
table.selectRow(row1);
assertTrue(row1.isSelected());
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(null);
jsonTable.handleUiEvent(event);
assertTrue(table.getSelectedRows().size() == 0);
}
use of org.eclipse.scout.rt.ui.html.json.JsonEvent in project scout.rt by eclipse.
the class JsonTreeTest method createJsonSelectedEvent.
public static JsonEvent createJsonSelectedEvent(String nodeId) throws JSONException {
// never used
String desktopId = "x";
JSONObject data = new JSONObject();
JSONArray nodeIds = new JSONArray();
nodeIds.put(nodeId);
data.put(JsonTree.PROP_NODE_IDS, nodeIds);
return new JsonEvent(desktopId, JsonTree.EVENT_NODES_SELECTED, data);
}
Aggregations