Search in sources :

Example 11 with TableWith3Cols

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

the class JsonTableTest method testRequestFocusInCellRowRequired.

/**
 * Tests if a RequestFocusInCell-Event get discarded when now row is set/available in the Event
 */
@Test
public void testRequestFocusInCellRowRequired() {
    TableWith3Cols table = new TableWith3Cols();
    table.fill(2);
    table.initTable();
    table.resetColumns();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    // Response should contain no events
    assertEquals(0, m_uiSession.currentJsonResponse().getEventList().size());
    // Request Focus without a row
    table.requestFocusInCell(table.getColumns().get(0), null);
    // Events should not be in the response
    assertEquals(0, m_uiSession.currentJsonResponse().getEventList().size());
    // And also not in the event buffer
    assertEquals(0, jsonTable.eventBuffer().size());
    // So there should be no events at all in the response
    JSONObject response = m_uiSession.currentJsonResponse().toJson();
    assertNull(response.optJSONArray("events"));
}
Also used : JSONObject(org.json.JSONObject) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) Test(org.junit.Test)

Example 12 with TableWith3Cols

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

the class JsonTableTest method testIgnorableColumnOrderChangedEvent.

/**
 * Response must not contain the column order changed event if the event was triggered by the request and the order
 * hasn't changed
 */
@Test
public void testIgnorableColumnOrderChangedEvent() throws JSONException {
    TableWith3Cols table = new TableWith3Cols();
    table.fill(2);
    table.initTable();
    table.resetColumns();
    IColumn<?> column = table.getColumns().get(0);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    JsonEvent event = createJsonColumnMovedEvent(jsonTable.getColumnId(column), 2);
    jsonTable.handleUiEvent(event);
    List<JsonEvent> responseEvents = JsonTestUtility.extractEventsFromResponse(m_uiSession.currentJsonResponse(), "columnOrderChanged");
    assertTrue(responseEvents.size() == 0);
}
Also used : JsonEvent(org.eclipse.scout.rt.ui.html.json.JsonEvent) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) Test(org.junit.Test)

Example 13 with TableWith3Cols

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

the class JsonTableTest method testColumnStructureChangedEvent_dispose.

/**
 * If column structure changes, old columns are disposed and the new ones attached
 */
@Test
public void testColumnStructureChangedEvent_dispose() throws JSONException {
    TableWith3Cols table = new TableWith3Cols();
    table.fill(2);
    table.initTable();
    table.resetColumns();
    IColumn column0 = table.getColumnSet().getColumn(0);
    IColumn column1 = table.getColumnSet().getColumn(1);
    IColumn column2 = table.getColumnSet().getColumn(2);
    column0.setVisible(false);
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    String column0Id = jsonTable.getColumnId(column0);
    String column1Id = jsonTable.getColumnId(column1);
    String column2Id = jsonTable.getColumnId(column2);
    assertNull(column0Id);
    assertNotNull(column1Id);
    assertNotNull(column2Id);
    column0.setVisible(true);
    column2.setVisible(false);
    JsonResponse response = m_uiSession.currentJsonResponse();
    response.fireProcessBufferedEvents();
    String newColumn0Id = jsonTable.getColumnId(column0);
    String newColumn1Id = jsonTable.getColumnId(column1);
    String newColumn2Id = jsonTable.getColumnId(column2);
    assertNotNull(newColumn0Id);
    assertNotNull(newColumn1Id);
    Assert.assertNotEquals(column1Id, newColumn1Id);
    assertNull(newColumn2Id);
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) JsonResponse(org.eclipse.scout.rt.ui.html.json.JsonResponse) Test(org.junit.Test)

Example 14 with TableWith3Cols

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

the class JsonTableTest method testTableEventCoalesceInUi_DeleteEventOnFilteredRow.

@Test
public void testTableEventCoalesceInUi_DeleteEventOnFilteredRow() throws Exception {
    TableWith3Cols table = new TableWith3Cols();
    table.initTable();
    table.fill(1, false);
    table.resetColumns();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    m_uiSession.currentJsonResponse().addAdapter(jsonTable);
    JSONObject response = m_uiSession.currentJsonResponse().toJson();
    JsonTestUtility.endRequest(m_uiSession);
    // -------------
    table.fill(2, false);
    table.addRowFilter(new ITableRowFilter() {

        @Override
        public boolean accept(ITableRow r) {
            // filter all rows
            return false;
        }
    });
    response = m_uiSession.currentJsonResponse().toJson();
    JsonTestUtility.endRequest(m_uiSession);
    JSONArray events = response.optJSONArray("events");
    assertEquals(1, events.length());
    assertEquals("allRowsDeleted", events.getJSONObject(0).getString("type"));
    // -------------
    // should not trigger any events
    table.deleteRow(0);
    response = m_uiSession.currentJsonResponse().toJson();
    JsonTestUtility.endRequest(m_uiSession);
    events = response.optJSONArray("events");
    // No events should be emitted
    assertNull(events);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ITableRowFilter(org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) 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 15 with TableWith3Cols

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

the class JsonTableTest method testGetTableRow.

@Test(expected = UiException.class)
public void testGetTableRow() throws Exception {
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, new TableWith3Cols(), null);
    jsonTable.getTableRow("foo");
}
Also used : ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) TableWith3Cols(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols) Test(org.junit.Test)

Aggregations

TableWith3Cols (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols)30 Test (org.junit.Test)30 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)28 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)16 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)11 JSONObject (org.json.JSONObject)11 ITableRowFilter (org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter)10 JSONArray (org.json.JSONArray)9 JsonResponse (org.eclipse.scout.rt.ui.html.json.JsonResponse)2 ArrayList (java.util.ArrayList)1 HeaderCell (org.eclipse.scout.rt.client.ui.basic.table.HeaderCell)1 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)1 UiException (org.eclipse.scout.rt.ui.html.UiException)1