Search in sources :

Example 1 with FormulaFillHandlePasteCommandHandler

use of org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler in project nebula.widgets.nattable by eclipse.

the class FormulaFillHandlePasteTest method setup.

@Before
public void setup() {
    InternalCellClipboard clipboard = new InternalCellClipboard();
    this.selectionLayer.registerCommandHandler(new InternalCopyDataCommandHandler(this.selectionLayer, clipboard));
    this.selectionLayer.registerCommandHandler(new FormulaFillHandlePasteCommandHandler(this.selectionLayer, clipboard, this.formulaDataProvider));
    this.natTable.addConfiguration(new DefaultFormulaConfiguration(this.formulaDataProvider, this.selectionLayer, clipboard));
    this.natTable.addConfiguration(new AbstractRegistryConfiguration() {

        @Override
        public void configureRegistry(IConfigRegistry configRegistry) {
            configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE);
        }
    });
    this.natTable.configure();
}
Also used : InternalCellClipboard(org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard) DefaultFormulaConfiguration(org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration) AbstractRegistryConfiguration(org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration) FormulaFillHandlePasteCommandHandler(org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler) IConfigRegistry(org.eclipse.nebula.widgets.nattable.config.IConfigRegistry) InternalCopyDataCommandHandler(org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler) Before(org.junit.Before)

Example 2 with FormulaFillHandlePasteCommandHandler

use of org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler 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

FormulaFillHandlePasteCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.FormulaFillHandlePasteCommandHandler)2 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)1 InternalCellClipboard (org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard)1 InternalClipboardStructuralChangeListener (org.eclipse.nebula.widgets.nattable.copy.InternalClipboardStructuralChangeListener)1 InternalCopyDataCommandHandler (org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler)1 DeleteSelectionCommandHandler (org.eclipse.nebula.widgets.nattable.edit.command.DeleteSelectionCommandHandler)1 ExportCommandHandler (org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler)1 FillHandleLayerPainter (org.eclipse.nebula.widgets.nattable.fillhandle.FillHandleLayerPainter)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 FormulaPasteDataCommandHandler (org.eclipse.nebula.widgets.nattable.formula.command.FormulaPasteDataCommandHandler)1 DefaultFormulaConfiguration (org.eclipse.nebula.widgets.nattable.formula.config.DefaultFormulaConfiguration)1 Before (org.junit.Before)1