use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualUpdateEvent 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.CellVisualUpdateEvent in project nebula.widgets.nattable by eclipse.
the class HoverLayer method setCurrentHoveredCellPosition.
/**
* Set the information about the cell position that is currently hovered and
* fire an event to update a possible previous hovered cell to remove the
* hover styling and an event to update the newly hovered cell to apply the
* hover styling.
*
* @param cellPosition
* The position of the cell that is currently hovered.
*/
public void setCurrentHoveredCellPosition(Point cellPosition) {
if (!isCellPositionHovered(cellPosition)) {
Point oldHover = this.currentHoveredCellPosition;
this.currentHoveredCellPosition = cellPosition;
if (oldHover != null) {
fireLayerEvent(new CellVisualUpdateEvent(this, oldHover.x, oldHover.y));
}
fireLayerEvent(new CellVisualUpdateEvent(this, this.currentHoveredCellPosition.x, this.currentHoveredCellPosition.y));
}
}
use of org.eclipse.nebula.widgets.nattable.layer.event.CellVisualUpdateEvent in project nebula.widgets.nattable by eclipse.
the class HoverLayer method clearCurrentHoveredCellPosition.
/**
* Removes the local stored information about the cell position that is
* currently hovered and fires an event to update the cell so the hover
* styling is removed.
*/
public void clearCurrentHoveredCellPosition() {
if (this.currentHoveredCellPosition != null) {
Point oldHover = this.currentHoveredCellPosition;
this.currentHoveredCellPosition = null;
fireLayerEvent(new CellVisualUpdateEvent(this, oldHover.x, oldHover.y));
}
}
Aggregations