use of org.eclipse.scout.rt.client.ui.basic.table.ITable in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableColumnOrderChangedEvent.
/**
* Response must not contain the column order changed event if the event was triggered by the request and the order
* hasn't changed
*/
@Test
public void testIgnorableColumnOrderChangedEvent() throws JSONException {
TableWith3Cols table = new TableWith3Cols();
table.fill(2);
table.initTable();
table.resetColumns();
IColumn<?> column = table.getColumns().get(0);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonColumnMovedEvent(jsonTable.getColumnId(column), 2);
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "columnOrderChanged");
assertTrue(responseEvents.size() == 0);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITable in project scout.rt by eclipse.
the class JsonTableTest method testColumnStructureChangedEvent_dispose.
/**
* If column structure changes, old columns are disposed and the new ones attached
*/
@Test
public void testColumnStructureChangedEvent_dispose() throws JSONException {
TableWith3Cols table = new TableWith3Cols();
table.fill(2);
table.initTable();
table.resetColumns();
IColumn column0 = table.getColumnSet().getColumn(0);
IColumn column1 = table.getColumnSet().getColumn(1);
IColumn column2 = table.getColumnSet().getColumn(2);
column0.setVisible(false);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
String column0Id = jsonTable.getColumnId(column0);
String column1Id = jsonTable.getColumnId(column1);
String column2Id = jsonTable.getColumnId(column2);
assertNull(column0Id);
assertNotNull(column1Id);
assertNotNull(column2Id);
column0.setVisible(true);
column2.setVisible(false);
JsonResponse response = m_uiSession.currentJsonResponse();
response.fireProcessBufferedEvents();
String newColumn0Id = jsonTable.getColumnId(column0);
String newColumn1Id = jsonTable.getColumnId(column1);
String newColumn2Id = jsonTable.getColumnId(column2);
assertNotNull(newColumn0Id);
assertNotNull(newColumn1Id);
Assert.assertNotEquals(column1Id, newColumn1Id);
assertNull(newColumn2Id);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITable in project scout.rt by eclipse.
the class JsonTableTest method testTableEventCoalesceInUi_DeleteEventOnFilteredRow.
@Test
public void testTableEventCoalesceInUi_DeleteEventOnFilteredRow() throws Exception {
TableWith3Cols table = new TableWith3Cols();
table.initTable();
table.fill(1, false);
table.resetColumns();
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
m_uiSession.currentJsonResponse().addAdapter(jsonTable);
JSONObject response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
// -------------
table.fill(2, false);
table.addRowFilter(new ITableRowFilter() {
@Override
public boolean accept(ITableRow r) {
// filter all rows
return false;
}
});
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
JSONArray events = response.optJSONArray("events");
assertEquals(1, events.length());
assertEquals("allRowsDeleted", events.getJSONObject(0).getString("type"));
// -------------
// should not trigger any events
table.deleteRow(0);
response = m_uiSession.currentJsonResponse().toJson();
JsonTestUtility.endRequest(m_uiSession);
events = response.optJSONArray("events");
// No events should be emitted
assertNull(events);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITable in project scout.rt by eclipse.
the class JsonTableTest method testGetTableRow.
@Test(expected = UiException.class)
public void testGetTableRow() throws Exception {
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, new TableWith3Cols(), null);
jsonTable.getTableRow("foo");
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITable 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));
}
Aggregations