Search in sources :

Example 1 with SortColumnEvent

use of org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent in project nebula.widgets.nattable by eclipse.

the class RowSelectionPreserver method handleLayerEvent.

/**
 * On a change in the underlying data:
 * <ol>
 * <li>Clears the selection
 * <li>Re-select the row objects selected earlier.
 * </ol>
 */
@Override
public void handleLayerEvent(IVisualChangeEvent event) {
    if (ObjectUtils.isEmpty(this.selectedRowObjects)) {
        return;
    }
    if (event instanceof RowStructuralRefreshEvent || event instanceof RowStructuralChangeEvent || event instanceof SortColumnEvent) {
        this.selectionLayer.clear();
        this.selectionProvider.setSelection(new StructuredSelection(getValidSelections()));
    }
}
Also used : SortColumnEvent(org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) RowStructuralChangeEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralChangeEvent)

Example 2 with SortColumnEvent

use of org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent in project nebula.widgets.nattable by eclipse.

the class SortCommandHandler method doCommand.

@Override
public boolean doCommand(final SortColumnCommand command) {
    final int columnIndex = command.getLayer().getColumnIndexByPosition(command.getColumnPosition());
    final SortDirectionEnum newSortDirection = (command.getSortDirection()) != null ? command.getSortDirection() : this.sortModel.getSortDirection(columnIndex).getNextSortDirection();
    // Fire command - with busy indicator
    Runnable sortRunner = new Runnable() {

        @Override
        public void run() {
            SortCommandHandler.this.sortModel.sort(columnIndex, newSortDirection, command.isAccumulate());
        }
    };
    BusyIndicator.showWhile(null, sortRunner);
    // Fire event
    SortColumnEvent sortEvent = new SortColumnEvent(this.sortHeaderLayer, command.getColumnPosition());
    this.sortHeaderLayer.fireLayerEvent(sortEvent);
    return true;
}
Also used : SortColumnEvent(org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent) SortDirectionEnum(org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum)

Aggregations

SortColumnEvent (org.eclipse.nebula.widgets.nattable.sort.event.SortColumnEvent)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 RowStructuralChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralChangeEvent)1 RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)1 SortDirectionEnum (org.eclipse.nebula.widgets.nattable.sort.SortDirectionEnum)1