use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTable method handleModelRequestFocusInCell.
protected void handleModelRequestFocusInCell(TableEvent event) {
final ITableRow row = CollectionUtility.firstElement(event.getRows());
if (row == null || !isRowAccepted(row)) {
return;
}
JSONObject jsonEvent = new JSONObject();
putProperty(jsonEvent, PROP_ROW_ID, getOrCreateRowId(row));
putProperty(jsonEvent, PROP_COLUMN_ID, getColumnId(CollectionUtility.firstElement(event.getColumns())));
addActionEvent(EVENT_REQUEST_FOCUS_IN_CELL, jsonEvent).protect();
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTable method rowIdsToJson.
protected JSONArray rowIdsToJson(Collection<ITableRow> modelRows) {
JSONArray jsonRowIds = new JSONArray();
for (ITableRow row : modelRows) {
if (!isRowAccepted(row)) {
continue;
}
String rowId = getTableRowId(row);
if (rowId == null) {
// Ignore rows that are not yet sent to the UI
continue;
}
jsonRowIds.put(rowId);
}
return jsonRowIds;
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class TableEventFilter method filter.
@Override
public TableEvent filter(TableEvent event) {
for (TableEventFilterCondition condition : getConditions()) {
if (condition.getType() == event.getType()) {
if (condition.checkRows()) {
List<ITableRow> rows = new ArrayList<>(event.getRows());
rows.removeAll(condition.getRows());
if (rows.size() == 0) {
// Ignore event if no nodes remain (or if the event contained no nodes at all)
return null;
}
TableEvent newEvent = new TableEvent(m_jsonTable.getModel(), event.getType(), rows);
return newEvent;
}
if (condition.checkCheckedRows()) {
List<ITableRow> rows = new ArrayList<>(event.getRows());
List<ITableRow> checkedRows = new ArrayList<>();
List<ITableRow> uncheckedRows = new ArrayList<>();
for (ITableRow row : rows) {
if (row.isChecked()) {
checkedRows.add(row);
} else {
uncheckedRows.add(row);
}
}
if (CollectionUtility.equalsCollection(checkedRows, condition.getCheckedRows()) && CollectionUtility.equalsCollection(uncheckedRows, condition.getUncheckedRows())) {
// Ignore event if the checked and the unchecked rows have not changes
return null;
}
// Otherwise, send rows that a different checked state than before
checkedRows.removeAll(condition.getCheckedRows());
uncheckedRows.removeAll(condition.getUncheckedRows());
rows = CollectionUtility.combine(checkedRows, uncheckedRows);
TableEvent newEvent = new TableEvent(m_jsonTable.getModel(), event.getType(), rows);
return newEvent;
}
if (condition.checkColumns()) {
// Columns are not delivered by the event itself (at least not with COLUMN_ORDER_CHANGED) -> grab from table
if (CollectionUtility.equalsCollection(m_jsonTable.getColumnsInViewOrder(), condition.getColumns())) {
return null;
}
// Don't ignore if columns are different
return event;
}
if (condition.checkUserFilter()) {
if (condition.getUserFilter().equals(event.getUserFilter())) {
return null;
}
// Don't ignore if filters are different
return event;
}
// Ignore event if only type should be checked
return null;
}
}
return event;
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTable method extractTableRows.
protected List<ITableRow> extractTableRows(JSONObject json) {
JSONArray rowIds = json.getJSONArray(PROP_ROW_IDS);
List<ITableRow> rows = new ArrayList<>(rowIds.length());
for (int i = 0; i < rowIds.length(); i++) {
ITableRow tableRow = optTableRow((String) rowIds.get(i));
if (tableRow != null) {
rows.add(tableRow);
}
}
return rows;
}
use of org.eclipse.scout.rt.client.ui.basic.table.ITableRow in project scout.rt by eclipse.
the class JsonTable method handleUiRowClick.
protected void handleUiRowClick(JsonEvent event) {
ITableRow tableRow = extractTableRow(event.getData());
if (tableRow == null) {
LOG.info("Requested table-row doesn't exist anymore -> skip rowClicked event");
return;
}
ArrayList<ITableRow> rows = new ArrayList<ITableRow>();
rows.add(tableRow);
MouseButton mouseButton = extractMouseButton(event.getData());
getModel().getUIFacade().fireRowClickFromUI(tableRow, mouseButton);
}
Aggregations