Search in sources :

Example 1 with VisualRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent in project nebula.widgets.nattable by eclipse.

the class DataChangeLayer method discardDataChanges.

/**
 * Discards the tracked data changes. In case temporary data storage is
 * disabled, the applied changes are undone by restoring the previous values
 * via dedicated {@link UpdateDataCommand}s.
 */
public void discardDataChanges() {
    if (!this.temporaryDataStorage) {
        // avoid handling of DataUpdateEvents that are caused by restoring
        // the previous data states
        this.handleDataUpdateEvents = false;
        // old values
        for (Map.Entry<Object, UpdateDataCommand> entry : this.dataChanges.entrySet()) {
            getUnderlyingLayer().doCommand(getUpdateDataCommand(entry.getKey(), entry.getValue()));
        }
        this.handleDataUpdateEvents = true;
    }
    clearDataChanges();
    fireLayerEvent(new VisualRefreshEvent(this));
}
Also used : VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 2 with VisualRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent in project nebula.widgets.nattable by eclipse.

the class DataChangeLayer method saveDataChanges.

/**
 * Saves the tracked data changes. In case temporary data storage is enabled
 * this means the underlying data model is updated. Otherwise the stored
 * data changes are simply cleared.
 * <p>
 * <b>Note:</b> In case temporary data storage is disabled and a custom save
 * operation should be performed on save, a custom
 * {@link SaveDataChangesCommandHandler} should be registered that first
 * performs a custom action and afterwards calls this method to ensure a
 * clear state in this layer.
 * </p>
 */
public void saveDataChanges() {
    if (this.temporaryDataStorage) {
        for (Map.Entry<Object, UpdateDataCommand> entry : this.dataChanges.entrySet()) {
            getUnderlyingLayer().doCommand(getUpdateDataCommand(entry.getKey(), entry.getValue()));
        }
    }
    clearDataChanges();
    fireLayerEvent(new VisualRefreshEvent(this));
}
Also used : VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 3 with VisualRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent in project nebula.widgets.nattable by eclipse.

the class ClearClipboardAction method run.

@Override
public void run(NatTable natTable, KeyEvent event) {
    this.clipboard.clear();
    natTable.fireLayerEvent(new VisualRefreshEvent(natTable));
}
Also used : VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent)

Example 4 with VisualRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent in project nebula.widgets.nattable by eclipse.

the class DisableFormulaEvaluationCommandHandler method doCommand.

@Override
public boolean doCommand(ILayer targetLayer, DisableFormulaEvaluationCommand command) {
    this.formulaDataProvider.setFormulaEvaluationEnabled(false);
    targetLayer.fireLayerEvent(new VisualRefreshEvent(targetLayer));
    return true;
}
Also used : VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent)

Example 5 with VisualRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent 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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent) ColumnStyleEditorDialog(org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog) VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent) Style(org.eclipse.nebula.widgets.nattable.style.Style)

Aggregations

VisualRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent)7 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)2 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)1 ColumnVisualUpdateEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent)1 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)1 RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1 ColumnStyleEditorDialog (org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog)1