Search in sources :

Example 1 with IndexCoordinate

use of net.sourceforge.nattable.coordinate.IndexCoordinate in project translationstudio8 by heartsome.

the class BlinkLayer method getConfigLabelsByPosition.

@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
    if (!blinkingEnabled) {
        return getUnderlyingLayer().getConfigLabelsByPosition(columnPosition, rowPosition);
    }
    int rowIndex = getUnderlyingLayer().getRowIndexByPosition(rowPosition);
    int columnIndex = getUnderlyingLayer().getColumnIndexByPosition(columnPosition);
    String rowId = rowIdAccessor.getRowId(rowDataProvider.getRowObject(rowIndex)).toString();
    String key = updateEventsCache.getKey(columnIndex, rowId);
    LabelStack underlyingLabelStack = getUnderlyingLayer().getConfigLabelsByPosition(columnPosition, rowPosition);
    IndexCoordinate coordinate = new IndexCoordinate(columnIndex, rowIndex);
    // Cell has been updated
    if (updateEventsCache.isUpdated(key)) {
        PropertyUpdateEvent<T> event = updateEventsCache.getEvent(key);
        // Old update in middle of a blink - cancel it
        if (blinkingUpdates.containsKey(key)) {
            blinkingTasks.get(key).cancel();
            getStopBlinkTimer().purge();
            blinkingTasks.remove(key);
            blinkingUpdates.remove(key);
        }
        LabelStack blinkingConfigTypes = resolveConfigTypes(event.getOldValue(), event.getNewValue(), coordinate, getUnderlyingLayer());
        // start blinking cell
        if (blinkingConfigTypes != null) {
            TimerTask stopBlinkTask = getStopBlinkTask(key, this);
            blinkingUpdates.put(key, event);
            blinkingTasks.put(key, stopBlinkTask);
            updateEventsCache.remove(key);
            getStopBlinkTimer().schedule(stopBlinkTask, blinkDurationInMilis);
            return blinkingConfigTypes;
        } else {
            return new LabelStack();
        }
    }
    // Previous blink timer is still running
    if (blinkingUpdates.containsKey(key)) {
        PropertyUpdateEvent<T> event = blinkingUpdates.get(key);
        return resolveConfigTypes(event.getOldValue(), event.getNewValue(), coordinate, getUnderlyingLayer());
    }
    return underlyingLabelStack;
}
Also used : LabelStack(net.sourceforge.nattable.layer.LabelStack) TimerTask(java.util.TimerTask) IndexCoordinate(net.sourceforge.nattable.coordinate.IndexCoordinate)

Aggregations

TimerTask (java.util.TimerTask)1 IndexCoordinate (net.sourceforge.nattable.coordinate.IndexCoordinate)1 LabelStack (net.sourceforge.nattable.layer.LabelStack)1