Search in sources :

Example 6 with Table

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);
}
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 7 with Table

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());
}
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) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) 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 8 with Table

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));
}
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 9 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_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 10 with Table

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);
}
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)

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