Search in sources :

Example 1 with FillHandleLayerPainter

use of org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter in project nebula.widgets.nattable by eclipse.

the class FillHandleConfiguration method configureTypedLayer.

@Override
public void configureTypedLayer(NatTable natTable) {
    // initialization works here because configureLayer() is executed before
    // configureUiBindings()
    this.clipboard = natTable.getInternalCellClipboard();
    this.painter = new FillHandleLayerPainter();
    this.selectionLayer.setLayerPainter(this.painter);
    this.selectionLayer.addLayerListener(new FillHandleMarkupListener(this.selectionLayer));
    this.selectionLayer.registerCommandHandler(new InternalCopyDataCommandHandler(this.selectionLayer, this.clipboard));
    this.selectionLayer.registerCommandHandler(new FillHandlePasteCommandHandler(this.selectionLayer, this.clipboard));
}
Also used : FillHandleLayerPainter(org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter) FillHandleMarkupListener(org.eclipse.nebula.widgets.nattable.fillhandle.event.FillHandleMarkupListener) FillHandlePasteCommandHandler(org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommandHandler) InternalCopyDataCommandHandler(org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler)

Example 2 with FillHandleLayerPainter

use of org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter in project nebula.widgets.nattable by eclipse.

the class DefaultFormulaConfiguration method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    // ui binding for deleting a cell value on pressing DEL
    uiBindingRegistry.registerFirstKeyBinding(new KeyEventMatcher(SWT.DEL), new DeleteSelectionAction());
    // ui binding to perform a paste action on pressing CTRL+V
    uiBindingRegistry.registerFirstKeyBinding(new KeyEventMatcher(SWT.MOD1, 'v'), new PasteDataAction());
    // ui binding to perform paste or selection movement on ENTER
    uiBindingRegistry.registerFirstKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.CR), new PasteOrMoveSelectionAction(this.clipboard));
    // ui binding to clear the InternalCellClipboard
    uiBindingRegistry.registerFirstKeyBinding(new KeyEventMatcher(SWT.NONE, SWT.ESC), new ClearClipboardAction(this.clipboard));
    // Mouse drag
    // trigger the handle drag operations
    // Note: we ensure a FillHandleLayerPainter is set in configureLayer
    uiBindingRegistry.registerFirstMouseDragMode(new FillHandleEventMatcher((FillHandleLayerPainter) this.selectionLayer.getLayerPainter()), new FormulaFillHandleDragMode(this.selectionLayer, this.clipboard, this.dataProvider));
}
Also used : FillHandleLayerPainter(org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter) FormulaFillHandleDragMode(org.eclipse.nebula.widgets.nattable.formula.action.FormulaFillHandleDragMode) ClearClipboardAction(org.eclipse.nebula.widgets.nattable.copy.action.ClearClipboardAction) KeyEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher) DeleteSelectionAction(org.eclipse.nebula.widgets.nattable.edit.action.DeleteSelectionAction) PasteDataAction(org.eclipse.nebula.widgets.nattable.copy.action.PasteDataAction) PasteOrMoveSelectionAction(org.eclipse.nebula.widgets.nattable.copy.action.PasteOrMoveSelectionAction) FillHandleEventMatcher(org.eclipse.nebula.widgets.nattable.fillhandle.event.FillHandleEventMatcher)

Example 3 with FillHandleLayerPainter

use of org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter in project nebula.widgets.nattable by eclipse.

the class DefaultFormulaConfiguration method configureLayer.

@Override
public void configureLayer(ILayer layer) {
    // register the command handler for deleting values
    layer.registerCommandHandler(new DeleteSelectionCommandHandler(this.selectionLayer));
    // register the ExportCommandHandler to the current layer (should be a
    // layer on top of the GridLayer to override default GridLayer behavior)
    // that exports from the SelectionLayer downwards. This way the column
    // and row headers won't be exported.
    layer.registerCommandHandler(new ExportCommandHandler(this.selectionLayer));
    // register the command handler for enabling/disabling formula
    // evaluation
    // register on the SelectionLayer so it works on export
    this.selectionLayer.registerCommandHandler(new DisableFormulaEvaluationCommandHandler(this.dataProvider));
    this.selectionLayer.registerCommandHandler(new EnableFormulaEvaluationCommandHandler(this.dataProvider));
    // add a layer listener that clears the internal clipboard on structural
    // changes
    this.selectionLayer.addLayerListener(new InternalClipboardStructuralChangeListener(this.clipboard));
    // add the layer painter that renders a border around copied cells
    if (!(this.selectionLayer.getLayerPainter() instanceof FillHandleLayerPainter)) {
        this.selectionLayer.setLayerPainter(new FillHandleLayerPainter(this.clipboard));
    } else {
        // ensure the clipboard is set
        ((FillHandleLayerPainter) this.selectionLayer.getLayerPainter()).setClipboard(this.clipboard);
    }
    // register special copy+paste command handlers
    layer.registerCommandHandler(new FormulaCopyDataCommandHandler(this.selectionLayer, this.clipboard));
    layer.registerCommandHandler(new FormulaPasteDataCommandHandler(this.selectionLayer, this.clipboard, this.dataProvider));
    layer.registerCommandHandler(new FormulaFillHandlePasteCommandHandler(this.selectionLayer, this.clipboard, this.dataProvider));
}
Also used : DisableFormulaEvaluationCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.DisableFormulaEvaluationCommandHandler) FillHandleLayerPainter(org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter) InternalClipboardStructuralChangeListener(org.eclipse.nebula.widgets.nattable.copy.InternalClipboardStructuralChangeListener) FormulaFillHandlePasteCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler) ExportCommandHandler(org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler) FormulaCopyDataCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.FormulaCopyDataCommandHandler) FormulaPasteDataCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.FormulaPasteDataCommandHandler) DeleteSelectionCommandHandler(org.eclipse.nebula.widgets.nattable.edit.command.DeleteSelectionCommandHandler) EnableFormulaEvaluationCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.EnableFormulaEvaluationCommandHandler)

Aggregations

FillHandleLayerPainter (org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter)3 InternalClipboardStructuralChangeListener (org.eclipse.nebula.widgets.nattable.copy.InternalClipboardStructuralChangeListener)1 ClearClipboardAction (org.eclipse.nebula.widgets.nattable.copy.action.ClearClipboardAction)1 PasteDataAction (org.eclipse.nebula.widgets.nattable.copy.action.PasteDataAction)1 PasteOrMoveSelectionAction (org.eclipse.nebula.widgets.nattable.copy.action.PasteOrMoveSelectionAction)1 InternalCopyDataCommandHandler (org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler)1 DeleteSelectionAction (org.eclipse.nebula.widgets.nattable.edit.action.DeleteSelectionAction)1 DeleteSelectionCommandHandler (org.eclipse.nebula.widgets.nattable.edit.command.DeleteSelectionCommandHandler)1 ExportCommandHandler (org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler)1 FillHandlePasteCommandHandler (org.eclipse.nebula.widgets.nattable.fillhandle.command.FillHandlePasteCommandHandler)1 FillHandleEventMatcher (org.eclipse.nebula.widgets.nattable.fillhandle.event.FillHandleEventMatcher)1 FillHandleMarkupListener (org.eclipse.nebula.widgets.nattable.fillhandle.event.FillHandleMarkupListener)1 FormulaFillHandleDragMode (org.eclipse.nebula.widgets.nattable.formula.action.FormulaFillHandleDragMode)1 DisableFormulaEvaluationCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.DisableFormulaEvaluationCommandHandler)1 EnableFormulaEvaluationCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.EnableFormulaEvaluationCommandHandler)1 FormulaCopyDataCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.FormulaCopyDataCommandHandler)1 FormulaFillHandlePasteCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler)1 FormulaPasteDataCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.FormulaPasteDataCommandHandler)1 KeyEventMatcher (org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher)1