use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableFieldTest method testTableDisposalOnPropertyChange.
@Test
public void testTableDisposalOnPropertyChange() {
ITable table = new Table();
ITable table2 = new Table();
ITableField<ITable> tableField = new TableField<ITable>(table);
JsonTableField<ITableField<?>> jsonTableField = UiSessionTestUtility.newJsonAdapter(m_uiSession, tableField, null);
// Switch table -> old one needs to be disposed
assertNotNull(jsonTableField.getAdapter(table));
tableField.setTable(table2, false);
assertNull(jsonTableField.getAdapter(table));
assertNotNull(jsonTableField.getAdapter(table2));
assertTrue(jsonTableField.getAdapter(table2).isInitialized());
jsonTableField.dispose();
assertNull(jsonTableField.getAdapter(table2));
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonTableTest method testSelectionEvent.
/**
* Tests whether the model row gets correctly selected
*/
@Test
public void testSelectionEvent() throws JSONException {
Table table = createTableFixture(5);
assertNull(table.getSelectedRow());
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);
assertTrue(row.isSelected());
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonFormTableControlTest method testLazyLoadingForm_onModelFormChanged.
@Test
public void testLazyLoadingForm_onModelFormChanged() 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));
FormWithOneField anotherForm = new FormWithOneField();
anotherForm.setShowOnStart(false);
control.setForm(anotherForm);
control.decorateForm();
// Both forms have to be null because the control has not been selected yet
assertNull(jsonControl.getAdapter(form));
assertNull(jsonControl.getAdapter(anotherForm));
control.setSelected(true);
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(anotherForm);
// Form is still null because it was exchanged with anotherForm
assertNull(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 JsonFormTableControlTest method testNonLazyLoadingFormWhenSelected.
@Test
public void testNonLazyLoadingFormWhenSelected() throws JSONException {
FormWithOneField form = new FormWithOneField();
FormTableControl control = new FormTableControl();
control.setTable(new Table());
control.setForm(form);
control.decorateForm();
control.setSelected(true);
JsonTableControl<ITableControl> jsonControl = UiSessionTestUtility.newJsonAdapter(m_uiSession, control, null);
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(form);
assertNotNull(formAdapter);
// Expects formId is sent along with the control and not with a separate property change event
String formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
}
use of org.eclipse.scout.rt.ui.html.json.table.fixtures.Table in project scout.rt by eclipse.
the class JsonFormTableControlTest method testLazyLoadingForm_onUiSelectionChanged.
@Test
public void testLazyLoadingForm_onUiSelectionChanged() throws Exception {
FormWithOneField form = new FormWithOneField();
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));
JsonEvent event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
// Form needs to be created and sent if selection changes to true
IJsonAdapter<?> formAdapter = jsonControl.getAdapter(form);
assertNotNull(formAdapter);
String formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertEquals(formAdapter.getId(), formId);
JsonTestUtility.endRequest(m_uiSession);
// Don't send form again on subsequent selection changes
event = createJsonSelectedEvent(jsonControl.getId(), false);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
JsonTestUtility.endRequest(m_uiSession);
event = createJsonSelectedEvent(jsonControl.getId(), true);
jsonControl.handleUiEvent(event);
formId = JsonTestUtility.extractProperty(m_uiSession.currentJsonResponse(), jsonControl.getId(), "form");
assertNull(formId);
}
Aggregations