use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table 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.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableFieldTest method testPreventTableDisposal2.
@Test
public void testPreventTableDisposal2() {
// Create tablePage
IPageWithTable<?> tablePage = createTablePageAndSelectNode();
ITable tablePageTable = tablePage.getTable();
JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, tablePage.getOutline(), null);
Assert.assertNotNull(jsonOutline.getAdapter(tablePageTable));
// Create table field which uses the table from the table page
ITableField<ITable> tableField = new TableField<ITable>();
JsonTableField<ITableField<?>> jsonTableField = UiSessionTestUtility.newJsonAdapter(m_uiSession, tableField, null);
tableField.setTable(tablePageTable, true);
// Switch table -> table must not be disposed because table page still needs it
ITable table2 = new Table();
tableField.setTable(table2, true);
assertNotNull(jsonTableField.getAdapter(table2));
assertTrue(jsonTableField.getAdapter(table2).isInitialized());
assertNotNull(jsonOutline.getAdapter(tablePageTable));
assertTrue(jsonOutline.getAdapter(tablePageTable).isInitialized());
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableFieldTest method testTableDisposal.
@Test
public void testTableDisposal() {
ITable table = new Table();
ITableField<ITable> tableField = new TableField<ITable>(table);
JsonTableField<ITableField<?>> jsonTableField = UiSessionTestUtility.newJsonAdapter(m_uiSession, tableField, null);
assertNotNull(jsonTableField.getAdapter(table));
jsonTableField.dispose();
assertNull(jsonTableField.getAdapter(table));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonFormTableControlTest method testLazyLoadingForm_onModelSelectionChanged.
@Test
public void testLazyLoadingForm_onModelSelectionChanged() throws JSONException {
FormWithOneField form = new FormWithOneField();
form.setShowOnStart(false);
FormTableControl control = new FormTableControl();
control.setTable(new Table());
control.setForm(form);
control.decorateForm();
JsonTableControl<ITableControl> jsonControl = UiSessionTestUtility.newJsonAdapter(m_uiSession, control, null);
assertNull(jsonControl.getAdapter(form));
control.setSelected(true);
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(form);
assertNotNull(formAdapter);
String formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertEquals(formAdapter.getId(), formId);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testIgnorableSelectionEvent.
/**
* Response must not contain the selection event if the selection was triggered by the request
*/
@Test
public void testIgnorableSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
ITableRow row = table.getRow(2);
JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
jsonTable.toJson();
// ----------
JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row));
jsonTable.handleUiEvent(event);
List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
assertTrue(responseEvents.size() == 0);
}
Aggregations