use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent in project nebula.widgets.nattable by eclipse.
the class NatTable method handleLayerEvent.
// Events /////////////////////////////////////////////////////////////////
@Override
public void handleLayerEvent(ILayerEvent event) {
List<ILayerListener> currentListeners;
this.eventListenerLock.readLock().lock();
try {
currentListeners = this.listeners;
} finally {
this.eventListenerLock.readLock().unlock();
}
for (ILayerListener layerListener : currentListeners) {
layerListener.handleLayerEvent(event);
}
if (event instanceof CellVisualUpdateEvent) {
CellVisualUpdateEvent update = (CellVisualUpdateEvent) event;
repaintCell(update.getColumnPosition(), update.getRowPosition());
return;
}
if (event instanceof ColumnVisualUpdateEvent) {
ColumnVisualUpdateEvent update = (ColumnVisualUpdateEvent) event;
// if more than one column has changed repaint the whole table
Collection<Range> ranges = update.getColumnPositionRanges();
if (ranges.size() == 1) {
Range range = ranges.iterator().next();
if (range.end - range.start == 1) {
repaintColumn(range.start);
return;
}
}
}
if (event instanceof RowVisualUpdateEvent) {
RowVisualUpdateEvent update = (RowVisualUpdateEvent) event;
// if more than one row has changed repaint the whole table
Collection<Range> ranges = update.getRowPositionRanges();
if (ranges.size() == 1) {
Range range = ranges.iterator().next();
if (range.end - range.start == 1) {
repaintRow(range.start);
return;
}
}
}
if (event instanceof ISelectionEvent) {
if (event instanceof CellSelectionEvent || event instanceof RowSelectionEvent) {
Event e = new Event();
e.widget = this;
try {
notifyListeners(SWT.Selection, e);
} catch (RuntimeException re) {
// $NON-NLS-1$
log.error("Error on SWT selection processing", re);
}
}
// in case of selections we redraw immediately
// this is because with Bug 440037 it was reported that
// NatTable is too lazy in handling selections which
// was caused by the EventConflaterChain that only performs
// updates every 100ms to avoid flickering when handling too
// many refresh operations in a short period
redraw();
} else if (event instanceof IVisualChangeEvent) {
this.conflaterChain.addEvent(event);
}
if (event instanceof CellEditorCreatedEvent) {
CellEditorCreatedEvent editorEvent = (CellEditorCreatedEvent) event;
this.activeCellEditor = editorEvent.getEditor();
Control editorControl = this.activeCellEditor.getEditorControl();
if (editorControl != null && !editorControl.isDisposed()) {
editorControl.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
NatTable.this.activeCellEditor = null;
ActiveCellEditorRegistry.unregisterActiveCellEditor();
}
});
} else {
this.activeCellEditor = null;
ActiveCellEditorRegistry.unregisterActiveCellEditor();
}
ActiveCellEditorRegistry.registerActiveCellEditor(this.activeCellEditor);
}
}
use of org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent in project nebula.widgets.nattable by eclipse.
the class DisplayColumnStyleEditorCommandHandler method doCommand.
@Override
public boolean doCommand(DisplayColumnStyleEditorCommand command) {
int columnIndexOfClick = command.getNattableLayer().getColumnIndexByPosition(command.columnPosition);
LabelStack configLabels = new LabelStack();
this.columnLabelAccumulator.accumulateConfigLabels(configLabels, columnIndexOfClick, 0);
configLabels.addLabel(getConfigLabel(columnIndexOfClick));
// Column style
Style clickedCellStyle = (Style) this.configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, configLabels.getLabels());
this.dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), clickedCellStyle);
this.dialog.open();
if (this.dialog.isCancelPressed()) {
return true;
}
int[] selectedColumns = getSelectedColumnIndeces();
if (selectedColumns.length > 0) {
applySelectedStyleToColumns(command, selectedColumns);
// fire refresh event
this.selectionLayer.fireLayerEvent(new ColumnVisualUpdateEvent(this.selectionLayer, this.selectionLayer.getSelectedColumnPositions()));
} else {
applySelectedStyle();
// fire refresh event
this.selectionLayer.fireLayerEvent(new VisualRefreshEvent(this.selectionLayer));
}
return true;
}
Aggregations