Search in sources :

Example 6 with IStructuralChangeEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent in project nebula.widgets.nattable by eclipse.

the class RowReorderLayer method handleLayerEvent.

@Override
public void handleLayerEvent(ILayerEvent event) {
    if (event instanceof IStructuralChangeEvent) {
        IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event;
        if (structuralChangeEvent.isVerticalStructureChanged()) {
            Collection<StructuralDiff> structuralDiffs = structuralChangeEvent.getRowDiffs();
            if (structuralDiffs == null) {
                // Assume everything changed
                populateIndexOrder();
            } else {
                // only react on ADD or DELETE and not on CHANGE
                StructuralChangeEventHelper.handleRowDelete(structuralDiffs, this.underlyingLayer, this.rowIndexOrder, true);
                StructuralChangeEventHelper.handleRowInsert(structuralDiffs, this.underlyingLayer, this.rowIndexOrder, true);
                // update index-position mapping
                refreshIndexPositionMapping();
            }
            invalidateCache();
        }
    }
    super.handleLayerEvent(event);
}
Also used : IStructuralChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent) StructuralDiff(org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff)

Aggregations

IStructuralChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.IStructuralChangeEvent)6 StructuralDiff (org.eclipse.nebula.widgets.nattable.layer.event.StructuralDiff)5 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)1 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)1 DataUpdateEvent (org.eclipse.nebula.widgets.nattable.edit.event.DataUpdateEvent)1 ShowRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.ShowRowPositionsEvent)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 SearchEvent (org.eclipse.nebula.widgets.nattable.search.event.SearchEvent)1