use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonCellToJsonTest method testBooleanColumn.
@Test
public void testBooleanColumn() throws JSONException {
TableWithBooleanColumn table = new TableWithBooleanColumn();
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, true);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
Assert.assertEquals(true, jsonObj.get("value"));
table.getColumn().setValue(row, false);
jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
Assert.assertEquals(false, jsonObj.get("value"));
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonCellToJsonTest method testLongColumn_leftAlignment.
/**
* Don't generate a cell object if text is the only property.
*/
@Test
public void testLongColumn_leftAlignment() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.getColumn().setHorizontalAlignment(-1);
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, 15L);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
Object jsonObj = jsonTable.cellToJson(row, table.getColumn());
assertTrue(jsonObj instanceof String);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonCellToJsonTest method testDateColumn.
@Test
public void testDateColumn() throws JSONException {
TableWithDateColumn table = new TableWithDateColumn();
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setFormat("dd.MM.yyyy");
table.getColumn().setValue(row, DateUtility.parse("01.01.2015", "dd.MM.yyyy"));
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
JSONObject jsonObj = (JSONObject) jsonTable.cellToJson(row, table.getColumn());
Assert.assertEquals("01.01.2015", jsonObj.get("text"));
// Pattern used by JsonDate
Assert.assertEquals("2015-01-01", jsonObj.get("value"));
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonCellToJsonTest method testNullValueAndEmptyText_leftAlignment.
/**
* Send only empty text if both are empty
*/
@Test
public void testNullValueAndEmptyText_leftAlignment() throws JSONException {
TableWithLongColumn table = new TableWithLongColumn();
table.getColumn().setHorizontalAlignment(-1);
table.initTable();
ITableRow row = table.addRow(table.createRow());
table.getColumn().setValue(row, null);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
Object jsonObj = jsonTable.cellToJson(row, table.getColumn());
assertEquals("", jsonObj);
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTableTest method testTableEventCoalesceInUi_UpdateEventOnFilteredRow.
@Test
public void testTableEventCoalesceInUi_UpdateEventOnFilteredRow() 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);
// would normally trigger an event, but we filter the row in the next step
table.getRow(2).setChecked(true);
table.addRowFilter(new ITableRowFilter() {
@Override
public boolean accept(ITableRow r) {
// hide everything expect the first (already existing row)
return r.getRowIndex() == 0;
}
});
response = m_uiSession.currentJsonResponse().toJson();
assertEquals(0, jsonTable.eventBuffer().size());
JSONArray events = response.optJSONArray("events");
// No events should be emitted
assertNull(events);
}
Aggregations