Search in sources :

Example 1 with Table

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

the class JsonTableTest method testIgnorableSelectionEvent3.

/**
 * Same as {@link #testIgnorableSelectionEvent2()} but with an empty selection
 */
@Test
public void testIgnorableSelectionEvent3() throws JSONException {
    Table table = new Table() {

        @Override
        protected void execRowsSelected(List<? extends ITableRow> rows) {
            if (rows.size() == 0) {
                selectRow(4);
            }
        }
    };
    table.fill(5);
    table.initTable();
    ITableRow row2 = table.getRow(2);
    ITableRow row4 = table.getRow(4);
    table.selectRow(row2);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    JsonEvent event = createJsonRowsSelectedEvent(null);
    assertTrue(row2.isSelected());
    assertFalse(row4.isSelected());
    jsonTable.handleUiEvent(event);
    assertFalse(row2.isSelected());
    assertTrue(row4.isSelected());
    List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
    assertTrue(responseEvents.size() == 1);
    List<ITableRow> tableRows = jsonTable.extractTableRows(responseEvents.get(0).getData());
    assertEquals(row4, tableRows.get(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) List(java.util.List) ArrayList(java.util.ArrayList) 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 2 with Table

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

the class JsonTableTest method testIgnorableSelectionEvent2.

/**
 * If the selection event triggers the selection of another row, the selection event must not be ignored.
 */
@Test
public void testIgnorableSelectionEvent2() throws JSONException {
    Table table = new Table() {

        @Override
        protected void execRowsSelected(List<? extends ITableRow> rows) {
            selectRow(4);
        }
    };
    table.fill(5);
    table.initTable();
    ITableRow row2 = table.getRow(2);
    ITableRow row4 = table.getRow(4);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    JsonEvent event = createJsonRowsSelectedEvent(jsonTable.getOrCreateRowId(row2));
    assertFalse(row2.isSelected());
    assertFalse(row4.isSelected());
    jsonTable.handleUiEvent(event);
    assertFalse(row2.isSelected());
    assertTrue(row4.isSelected());
    List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), JsonTable.EVENT_ROWS_SELECTED);
    assertTrue(responseEvents.size() == 1);
    List<ITableRow> tableRows = jsonTable.extractTableRows(responseEvents.get(0).getData());
    assertEquals(row4, tableRows.get(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) List(java.util.List) ArrayList(java.util.ArrayList) 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 3 with Table

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

the class JsonTableTest method testIgnorableRowOrderChangedEvent.

/**
 * Response must not contain the row_order_changed event if the sort was triggered by the request
 */
@Test
public void testIgnorableRowOrderChangedEvent() throws JSONException {
    Table table = createTableFixture(5);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    IColumn column = table.getColumnSet().getFirstVisibleColumn();
    // ----------
    JsonEvent event = createJsonRowsSortedEvent(jsonTable.getColumnId(column), !column.isSortAscending());
    jsonTable.handleUiEvent(event);
    List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "rowOrderChanged");
    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) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) Test(org.junit.Test)

Example 4 with Table

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

the class JsonTableTest method testDispose.

@Test
public void testDispose() {
    Table table = new Table();
    JsonTable<ITable> object = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    WeakReference<JsonTable> ref = new WeakReference<JsonTable>(object);
    object.dispose();
    m_uiSession = null;
    object = null;
    TestingUtility.assertGC(ref);
}
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) WeakReference(java.lang.ref.WeakReference) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) Test(org.junit.Test)

Example 5 with Table

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

the class JsonTableTest method createTableFixture.

public static Table createTableFixture(int numRows) {
    Table table = new Table();
    table.fill(numRows);
    table.initTable();
    return table;
}
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)

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