Search in sources :

Example 1 with FormTableControl

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl in project scout.rt by eclipse.

the class JsonTableTest method testMultipleTableControlDisposallOnPropertyChange.

@Test
public void testMultipleTableControlDisposallOnPropertyChange() throws JSONException {
    ITable table = new TableWithoutMenus();
    table.initTable();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    FormTableControl tableControl1 = new FormTableControl();
    FormTableControl tableControl2 = new FormTableControl();
    table.addTableControl(tableControl1);
    table.addTableControl(tableControl2);
    assertNotNull(jsonTable.getAdapter(tableControl1));
    assertTrue(jsonTable.getAdapter(tableControl1).isInitialized());
    assertNotNull(jsonTable.getAdapter(tableControl2));
    assertTrue(jsonTable.getAdapter(tableControl2).isInitialized());
    table.removeTableControl(tableControl1);
    assertNull(jsonTable.getAdapter(tableControl1));
    assertNotNull(jsonTable.getAdapter(tableControl2));
    assertTrue(jsonTable.getAdapter(tableControl2).isInitialized());
}
Also used : TableWithoutMenus(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithoutMenus) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) Test(org.junit.Test)

Example 2 with FormTableControl

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl 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);
}
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 3 with FormTableControl

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl in project scout.rt by eclipse.

the class JsonTableTest method testTableControlDisposalOnPropertyChange.

@Test
public void testTableControlDisposalOnPropertyChange() throws JSONException {
    ITable table = new TableWithoutMenus();
    table.initTable();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    FormTableControl control = new FormTableControl();
    table.addTableControl(control);
    assertNotNull(jsonTable.getAdapter(control));
    assertTrue(jsonTable.getAdapter(control).isInitialized());
    table.removeTableControl(control);
    assertNull(jsonTable.getAdapter(control));
}
Also used : TableWithoutMenus(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithoutMenus) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) FormTableControl(org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl) Test(org.junit.Test)

Example 4 with FormTableControl

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl 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 5 with FormTableControl

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl 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)

Aggregations

FormTableControl (org.eclipse.scout.rt.ui.html.json.table.fixtures.FormTableControl)6 Test (org.junit.Test)6 ITableControl (org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl)4 FormWithOneField (org.eclipse.scout.rt.ui.html.json.form.fixtures.FormWithOneField)4 Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)4 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 TableWithoutMenus (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithoutMenus)2 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)1