Project

General

Profile

« Previous | Next » 

Revision 598e33b7

Added by Patrick Plitzner over 3 years ago

ref #7580 Add copy&paste configuration (not yet actually working)

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
41 41
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
42 42
import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
43 43
import org.eclipse.nebula.widgets.nattable.coordinate.Range;
44
import org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler;
45
import org.eclipse.nebula.widgets.nattable.copy.command.InternalPasteDataCommandHandler;
44 46
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
45 47
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
48
import org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommandHandler;
46 49
import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
47 50
import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
48 51
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
......
185 188

  
186 189
    private boolean isShowTooltips = true;
187 190

  
191
    private DataLayer bodyDataLayer;
192

  
188 193
    public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
189 194
        super(parent, SWT.NONE);
190 195
        this.part = part;
......
352 357
         *
353 358

  
354 359
         */
355
        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
360
        bodyDataLayer = new DataLayer(bodyDataProvider);
356 361

  
357 362
        //register labels
358 363
        CharacterMatrixConfigLabelAccumulator labelAccumulator = new CharacterMatrixConfigLabelAccumulator(this);
......
461 466

  
462 467
        //register handler for view configuration menu
463 468
        natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
469

  
470
        //register handlers for copy&paste
471
        natTable.registerCommandHandler(
472
                new InternalPasteDataCommandHandler(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
473
        natTable.registerCommandHandler(
474
                new InternalCopyDataCommandHandler(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
475
        natTable.registerCommandHandler(new UpdateDataCommandHandler(bodyDataLayer));
464 476
    }
465 477

  
466 478
    private void configureNatTable(boolean treeView,
......
477 489
        //add default configuration because autoconfigure is set to false in constructor
478 490
        natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
479 491

  
480
        //FIXME: this is for DEBUG ONLY
492
        // this is for DEBUG ONLY
481 493
        //        natTable.addConfiguration(new DebugMenuConfiguration(natTable));
482 494

  
483 495
        // override the default sort configuration and change the mouse bindings
......
498 510
        //register aggregation configuration
499 511
        summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
500 512

  
513
        //copy&paste configuration
514
        natTable.addConfiguration(new CopyPasteEditBindings(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
515

  
501 516
      //+++CONTEXT MENU+++
502 517
        menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
503 518
        // get the menu registered by EMenuService
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CopyPasteEditBindings.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10

  
11
import org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard;
12
import org.eclipse.nebula.widgets.nattable.copy.action.ClearClipboardAction;
13
import org.eclipse.nebula.widgets.nattable.copy.action.PasteDataAction;
14
import org.eclipse.nebula.widgets.nattable.copy.action.PasteOrMoveSelectionAction;
15
import org.eclipse.nebula.widgets.nattable.edit.action.DeleteSelectionAction;
16
import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings;
17
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
18
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
19
import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
20
import org.eclipse.swt.SWT;
21

  
22
/**
23
 * @author pplitzner
24
 * @since Dec 20, 2018
25
 *
26
 */
27
public class CopyPasteEditBindings extends DefaultEditBindings {
28

  
29
    private SelectionLayer selectionLayer;
30

  
31
    private InternalCellClipboard clipboard;
32

  
33
    public CopyPasteEditBindings(SelectionLayer selectionLayer, InternalCellClipboard clipboard) {
34
        this.selectionLayer = selectionLayer;
35
        this.clipboard = clipboard;
36
    }
37

  
38
    @Override
39
    public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
40
        super.configureUiBindings(uiBindingRegistry);
41
        // ui binding for deleting a cell value on pressing DEL
42
        uiBindingRegistry.registerFirstKeyBinding(
43
                new KeyEventMatcher(SWT.DEL),
44
                new DeleteSelectionAction());
45

  
46
        // ui binding to perform a paste action on pressing CTRL+V
47
        uiBindingRegistry.registerFirstKeyBinding(
48
                new KeyEventMatcher(SWT.MOD1, 'v'),
49
                new PasteDataAction());
50

  
51
        // ui binding to perform paste or selection movement on ENTER
52
        uiBindingRegistry.registerFirstKeyBinding(
53
                new KeyEventMatcher(SWT.NONE, SWT.CR),
54
                new PasteOrMoveSelectionAction(this.clipboard));
55

  
56
        // ui binding to clear the InternalCellClipboard
57
        uiBindingRegistry.registerFirstKeyBinding(
58
                new KeyEventMatcher(SWT.NONE, SWT.ESC),
59
                new ClearClipboardAction(this.clipboard));
60

  
61
        // Mouse drag
62
        // trigger the handle drag operations
63
        // Note: we ensure a FillHandleLayerPainter is set in configureLayer
64
//        uiBindingRegistry.registerFirstMouseDragMode(
65
//                new FillHandleEventMatcher((FillHandleLayerPainter) this.selectionLayer.getLayerPainter()),
66
//                new FormulaFillHandleDragMode(this.selectionLayer, this.clipboard, this.dataProvider));
67
    }
68
}

Also available in: Unified diff