Search in sources :

Example 11 with Table

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));
}
Also used : ITableField(org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField) Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) IPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableField(org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField) TableField(org.eclipse.scout.rt.ui.html.json.form.fields.tablefield.fixtures.TableField) Test(org.junit.Test)

Example 12 with Table

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());
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ListBoxTable(org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) Test(org.junit.Test)

Example 13 with Table

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);
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) FormWithOneField(org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField) Test(org.junit.Test)

Example 14 with Table

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);
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) FormWithOneField(org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField) Test(org.junit.Test)

Example 15 with Table

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);
}
Also used : Table(org.eclipse.scout.rt.ui.html.json.table.fixtures.Table) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) FormWithOneField(org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField) Test(org.junit.Test)

Aggregations

Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)15 Test (org.junit.Test)14 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)11 ListBoxTable (org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable)8 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)7 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)5 ITableControl (org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl)4 FormWithOneField (org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField)4 FormTableControl (org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl)4 IPageWithTable (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable)3 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)3 TableField (org.eclipse.scout.rt.ui.html.json.form.fields.tablefield.fixtures.TableField)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 WeakReference (java.lang.ref.WeakReference)1 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1