Search in sources :

Example 1 with IStructuralChangeEvent

use of net.sourceforge.nattable.layer.event.IStructuralChangeEvent in project translationstudio8 by heartsome.

the class ColumnReorderLayer method handleLayerEvent.

@Override
public void handleLayerEvent(ILayerEvent event) {
    if (event instanceof IStructuralChangeEvent) {
        IStructuralChangeEvent structuralChangeEvent = (IStructuralChangeEvent) event;
        if (structuralChangeEvent.isHorizontalStructureChanged()) {
            Collection<StructuralDiff> structuralDiffs = structuralChangeEvent.getColumnDiffs();
            if (structuralDiffs == null) {
                // Assume everything changed
                columnIndexOrder.clear();
                populateIndexOrder();
            } else {
                for (StructuralDiff structuralDiff : structuralDiffs) {
                    switch(structuralDiff.getDiffType()) {
                        case ADD:
                            columnIndexOrder.clear();
                            populateIndexOrder();
                            break;
                        case DELETE:
                            columnIndexOrder.clear();
                            populateIndexOrder();
                            break;
                    }
                }
            }
            invalidateCache();
        }
    }
    super.handleLayerEvent(event);
}
Also used : IStructuralChangeEvent(net.sourceforge.nattable.layer.event.IStructuralChangeEvent) StructuralDiff(net.sourceforge.nattable.layer.event.StructuralDiff)

Aggregations

IStructuralChangeEvent (net.sourceforge.nattable.layer.event.IStructuralChangeEvent)1 StructuralDiff (net.sourceforge.nattable.layer.event.StructuralDiff)1