Search in sources :

Example 1 with ToggleMergingEvent

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.ToggleMergingEvent in project kie-wb-common by kiegroup.

the class AbstractMergableGridWidget method onSortData.

public void onSortData(SortDataEvent event) {
    // Remove grouping, if applicable
    if (data.isGrouped()) {
        ToggleMergingEvent tme = new ToggleMergingEvent(false);
        eventBus.fireEvent(tme);
    }
    // Sort data
    List<SortConfiguration> sortConfiguration = event.getSortConfiguration();
    data.sort(sortConfiguration);
    redraw();
    // Copy data and raise event for underlying model to update itself
    List<List<CellValue<? extends Comparable<?>>>> changedData = new ArrayList<List<CellValue<? extends Comparable<?>>>>();
    for (DynamicDataRow row : data) {
        List<CellValue<? extends Comparable<?>>> changedRow = new ArrayList<CellValue<? extends Comparable<?>>>();
        changedData.add(changedRow);
        for (int iCol = 0; iCol < row.size(); iCol++) {
            CellValue<? extends Comparable<?>> changedCell = row.get(iCol);
            changedRow.add(changedCell);
        }
    }
    UpdateModelEvent dce = new UpdateModelEvent(new Coordinate(0, 0), changedData);
    eventBus.fireEvent(dce);
}
Also used : ArrayList(java.util.ArrayList) ToggleMergingEvent(org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.ToggleMergingEvent) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) UpdateModelEvent(org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.UpdateModelEvent) Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Coordinate (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate)1 DynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow)1 GroupedDynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)1 ToggleMergingEvent (org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.ToggleMergingEvent)1 UpdateModelEvent (org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.UpdateModelEvent)1