Search in sources :

Example 1 with TableEvent

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

the class TableUserFilterManager method fireFilterRemoved.

private void fireFilterRemoved(IUserFilterState filter) {
    TableEvent event = new TableEvent(m_table, TableEvent.TYPE_USER_FILTER_REMOVED);
    event.setUserFilter(filter);
    m_table.fireTableEventInternal(event);
}
Also used : TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent)

Example 2 with TableEvent

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

the class TableUserFilterManager method fireFilterAdded.

private void fireFilterAdded(IUserFilterState filter) {
    TableEvent event = new TableEvent(m_table, TableEvent.TYPE_USER_FILTER_ADDED);
    event.setUserFilter(filter);
    m_table.fireTableEventInternal(event);
}
Also used : TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent)

Example 3 with TableEvent

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

the class JsonTable method processBufferedEvents.

@Override
public void processBufferedEvents() {
    if (m_eventBuffer.isEmpty()) {
        return;
    }
    preprocessBufferedEvents();
    List<TableEvent> coalescedEvents = m_eventBuffer.consumeAndCoalesceEvents();
    for (TableEvent event : coalescedEvents) {
        processEvent(event);
    }
}
Also used : TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent)

Example 4 with TableEvent

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

the class JsonTable method bufferColumnStructureChanged.

protected void bufferColumnStructureChanged(TableEvent event) {
    m_eventBuffer.add(event);
    // Also necessary because column ids have changed.
    if (getModel().getUserFilterManager() != null && getModel().getUserFilterManager().getFilters().size() > 0) {
        m_eventBuffer.add(new TableEvent(getModel(), TableEvent.TYPE_USER_FILTER_ADDED));
    }
    // If a column got visible it is necessary to resend all rows to inform the gui about the new cells of the new column
    m_eventBuffer.add(new TableEvent(getModel(), TableEvent.TYPE_ALL_ROWS_DELETED));
    m_eventBuffer.add(new TableEvent(getModel(), TableEvent.TYPE_ROWS_INSERTED, getModel().getRows()));
}
Also used : TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent)

Example 5 with TableEvent

use of org.eclipse.scout.rt.client.ui.basic.table.TableEvent 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;
}
Also used : TableEvent(org.eclipse.scout.rt.client.ui.basic.table.TableEvent) ArrayList(java.util.ArrayList) ITableRow(org.eclipse.scout.rt.client.ui.basic.table.ITableRow)

Aggregations

TableEvent (org.eclipse.scout.rt.client.ui.basic.table.TableEvent)10 ArrayList (java.util.ArrayList)3 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)3 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 TableAdapter (org.eclipse.scout.rt.client.ui.basic.table.TableAdapter)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 AbstractTable (org.eclipse.scout.rt.client.ui.basic.table.AbstractTable)1 TableListener (org.eclipse.scout.rt.client.ui.basic.table.TableListener)1 IColumn (org.eclipse.scout.rt.client.ui.basic.table.columns.IColumn)1 IFormField (org.eclipse.scout.rt.client.ui.form.fields.IFormField)1 OrderedComparator (org.eclipse.scout.rt.platform.OrderedComparator)1