Search in sources :

Example 96 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow 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)

Example 97 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow 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 98 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractTableField method doSave.

/**
 * Saves the table. The call order is as follows:
 * <ol>
 * <li>{@link #interceptSave(ITableRow[], ITableRow[], ITableRow[])}</li>
 * <li>{@link #interceptSaveDeletedRow(ITableRow)}</li>
 * <li>{@link #interceptSaveInsertedRow(ITableRow)}</li>
 * <li>{@link #interceptSaveUpdatedRow(ITableRow)}</li>
 * </ol>
 */
@Override
public void doSave() {
    if (m_table != null && !m_tableExternallyManaged) {
        try {
            m_table.setTableChanging(true);
            // 
            // 1. batch
            interceptSave(m_table.getInsertedRows(), m_table.getUpdatedRows(), m_table.getDeletedRows());
            // deleted rows
            for (ITableRow deletedRow : m_table.getDeletedRows()) {
                interceptSaveDeletedRow(deletedRow);
            }
            // inserted rows
            for (ITableRow insertedRow : m_table.getInsertedRows()) {
                interceptSaveInsertedRow(insertedRow);
                insertedRow.setStatusNonchanged();
                m_table.updateRow(insertedRow);
            }
            // updated rows
            for (ITableRow updatedRow : m_table.getUpdatedRows()) {
                interceptSaveUpdatedRow(updatedRow);
                updatedRow.setStatusNonchanged();
                m_table.updateRow(updatedRow);
            }
        } finally {
            m_table.setTableChanging(false);
        }
    }
    markSaved();
}
Also used : ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 99 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractTableField method storeToXml.

@Override
public void storeToXml(Element x) {
    super.storeToXml(x);
    if (m_table != null) {
        List<ITableRow> selectedRows = m_table.getSelectedRows();
        int[] selectedRowIndices = new int[selectedRows.size()];
        int i = 0;
        for (ITableRow selrow : selectedRows) {
            selectedRowIndices[i] = selrow.getRowIndex();
            i++;
        }
        try {
            XmlUtility.setObjectAttribute(x, "selectedRowIndices", selectedRowIndices);
        } catch (Exception e) {
            LOG.warn("writing attribute 'selectedRowIndices'", e);
        }
        Object[][] dataMatrix = m_table.getTableData();
        for (int r = 0; r < dataMatrix.length; r++) {
            for (int c = 0; c < dataMatrix[r].length; c++) {
                Object o = dataMatrix[r][c];
                if (o != null && !(o instanceof Serializable)) {
                    LOG.warn("ignoring not serializable value at row={}, col={}: {}[{}]", r, c, o, o.getClass());
                    dataMatrix[r][c] = null;
                }
            }
        }
        try {
            XmlUtility.setObjectAttribute(x, "rows", dataMatrix);
        } catch (Exception e) {
            LOG.warn("writing attribute 'rows'", e);
        }
    }
}
Also used : Serializable(java.io.Serializable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 100 with ITableRow

use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.

the class AbstractTableField method validateContent.

@Override
public IValidateContentDescriptor validateContent() {
    IValidateContentDescriptor desc = super.validateContent();
    // super check
    if (desc != null) {
        return desc;
    }
    ITable table = getTable();
    // check cells
    ValidateTableFieldDescriptor tableDesc = null;
    TreeSet<String> columnNames = new TreeSet<String>();
    if (table != null) {
        for (ITableRow row : table.getRows()) {
            for (IColumn col : table.getColumns()) {
                if (!col.isContentValid(row)) {
                    if (tableDesc == null) {
                        tableDesc = new ValidateTableFieldDescriptor(this, row, col);
                    }
                    columnNames.add(getColumnName(col));
                }
            }
        }
        table.ensureInvalidColumnsVisible();
    }
    if (tableDesc != null) {
        tableDesc.setDisplayText(TEXTS.get("TableName") + " " + getLabel() + ": " + CollectionUtility.format(columnNames));
    }
    return tableDesc;
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) TreeSet(java.util.TreeSet) IValidateContentDescriptor(org.eclipse.scout.rt.client.ui.form.fields.IValidateContentDescriptor) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Aggregations

ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)127 Test (org.junit.Test)77 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)47 ArrayList (java.util.ArrayList)23 JSONObject (org.json.JSONObject)22 TableWith3Cols (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWith3Cols)16 JSONArray (org.json.JSONArray)13 JsonEvent (org.eclipse.scout.rt.ui.html.json.JsonEvent)12 ITableRowFilter (org.eclipse.scout.rt.client.ui.basic.table.ITableRowFilter)11 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)7 IProposalField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IProposalField)7 ListBoxTable (org.eclipse.scout.rt.ui.html.json.table.fixtures.ListBoxTable)6 IMixedSmartField (org.eclipse.scout.rt.client.ui.form.fields.smartfield.IMixedSmartField)5 Table (org.eclipse.scout.rt.ui.html.json.table.fixtures.Table)5 TableWithLongColumn (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithLongColumn)5 DecimalFormat (java.text.DecimalFormat)4 List (java.util.List)4 Cell (org.eclipse.scout.rt.client.ui.basic.cell.Cell)4 ICell (org.eclipse.scout.rt.client.ui.basic.cell.ICell)4 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)4