Search in sources :

Example 1 with ITableRow

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

the class OrganizeColumnsForm method execRemoveColumnAction.

/**
 * Calls removeColumn() method of table-customizer, if table has a customizer and selected row is a custom column.
 * Override this method if a different behavior is required.
 */
protected void execRemoveColumnAction() {
    if (isCustomizable()) {
        Table columnsTable = getColumnsTableField().getTable();
        for (ITableRow selectedRow : columnsTable.getSelectedRows()) {
            IColumn<?> selectedColumn = columnsTable.getKeyColumn().getValue(selectedRow);
            if (selectedColumn instanceof ICustomColumn) {
                m_organizedTable.getTableCustomizer().removeColumn((ICustomColumn) selectedColumn);
            }
        }
        getColumnsTableField().reloadTableData();
    }
}
Also used : AbstractTable(org.eclipse.scout.rt.client.ui.basic.table.AbstractTable) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) Table(org.eclipse.scout.rt.client.ui.basic.table.organizer.OrganizeColumnsForm.MainBox.GroupBox.ColumnsGroupBox.ColumnsTableField.Table) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow) ICustomColumn(org.eclipse.scout.rt.client.ui.basic.table.customizer.ICustomColumn)

Example 2 with ITableRow

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

the class JsonTable method handleModelRowsChecked.

protected void handleModelRowsChecked(Collection<ITableRow> modelRows) {
    JSONArray jsonRows = new JSONArray();
    for (ITableRow row : modelRows) {
        if (!isRowAccepted(row)) {
            continue;
        }
        JSONObject jsonRow = new JSONObject();
        putProperty(jsonRow, "id", getTableRowId(row));
        putProperty(jsonRow, "checked", row.isChecked());
        jsonRows.put(jsonRow);
    }
    if (jsonRows.length() == 0) {
        return;
    }
    JSONObject jsonEvent = new JSONObject();
    putProperty(jsonEvent, PROP_ROWS, jsonRows);
    addActionEvent(EVENT_ROWS_CHECKED, jsonEvent);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 3 with ITableRow

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

the class JsonTable method handleUiRowAction.

protected void handleUiRowAction(JsonEvent event) {
    ITableRow tableRow = extractTableRow(event.getData());
    IColumn column = extractColumn(event.getData());
    getModel().getUIFacade().setContextColumnFromUI(column);
    getModel().getUIFacade().fireRowActionFromUI(tableRow);
}
Also used : IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 4 with ITableRow

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

the class JsonTable method jsonToCheckedInfo.

protected CheckedInfo jsonToCheckedInfo(JSONObject data) {
    JSONArray jsonRows = data.optJSONArray("rows");
    CheckedInfo checkInfo = new CheckedInfo();
    for (int i = 0; i < jsonRows.length(); i++) {
        JSONObject jsonObject = jsonRows.optJSONObject(i);
        ITableRow row = optTableRow(jsonObject.getString("rowId"));
        if (row != null) {
            checkInfo.getAllRows().add(row);
            if (jsonObject.optBoolean("checked")) {
                checkInfo.getCheckedRows().add(row);
            } else {
                checkInfo.getUncheckedRows().add(row);
            }
        }
    }
    return checkInfo;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Example 5 with ITableRow

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

the class JsonTable method handleUiPrepareCellEdit.

protected void handleUiPrepareCellEdit(JsonEvent event) {
    ITableRow row = extractTableRow(event.getData());
    if (row == null) {
        LOG.info("Requested table-row doesn't exist anymore. Skip prepareCellEdit event");
        return;
    }
    IColumn column = extractColumn(event.getData());
    IFormField field = getModel().getUIFacade().prepareCellEditFromUI(row, column);
    if (field == null) {
        // caused the initially editable cell to be become non-editable.
        return;
    }
    IJsonAdapter<?> jsonField = attachAdapter(field);
    LOG.debug("Created new field adapter for cell editing. Adapter: {}", jsonField);
    JSONObject json = new JSONObject();
    json.put("columnId", event.getData().getString(PROP_COLUMN_ID));
    json.put("rowId", event.getData().getString(PROP_ROW_ID));
    json.put("fieldId", jsonField.getId());
    addActionEvent(EVENT_START_CELL_EDIT, json).protect();
}
Also used : IFormField(org.eclipse.scout.rt.client.ui.form.fields.IFormField) JSONObject(org.json.JSONObject) IColumn(org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn) 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