Project

General

Profile

Download (2.24 KB) Statistics
| Branch: | Tag: | Revision:
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.view.checklist.e4;
10

    
11
import org.eclipse.jface.viewers.ColumnViewer;
12
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
13
import org.eclipse.jface.viewers.ViewerCell;
14
import org.eclipse.swt.events.KeyEvent;
15
import org.eclipse.swt.events.KeyListener;
16

    
17
/**
18
 * @author k.luther
19
 * @since 17.10.2018
20
 *
21
 */
22
public class DistributionEditorColumnViewerEditorActivationStrategy extends ColumnViewerEditorActivationStrategy {
23

    
24
    private KeyListener customkeyboardActivationListener;
25
    /**
26
     * @param viewer
27
     */
28
    public DistributionEditorColumnViewerEditorActivationStrategy(ColumnViewer viewer) {
29
        super(viewer);
30
        // TODO Auto-generated constructor stub
31
    }
32

    
33
    /**
34
     * Enable activation of cell editors by keyboard
35
     *
36
     * @param enable
37
     *            <code>true</code> to enable
38
     */
39
    @Override
40
    public void setEnableEditorActivationWithKeyboard(boolean enable) {
41
        super.setEnableEditorActivationWithKeyboard(enable);
42
        if (enable) {
43
            if (customkeyboardActivationListener == null) {
44
                customkeyboardActivationListener = new KeyListener() {
45

    
46
                    @Override
47
                    public void keyPressed(KeyEvent e) {
48

    
49
                    }
50

    
51
                    @Override
52
                    public void keyReleased(KeyEvent e) {
53
                        ViewerCell cell = getFocusCell();
54

    
55
//                        if (cell != null) {
56
//                        getViewer().getColumnViewerEditor().handleEditorActivationEvent(new ColumnViewerEditorActivationEvent(
57
//                                cell, e));
58
//                        }
59
                    }
60

    
61
                };
62
                getViewer().getControl().addKeyListener(customkeyboardActivationListener);
63
            }
64
        }
65
    }
66

    
67
    /**
68
     * @return the cell holding the current focus
69
     */
70
    private ViewerCell getFocusCell() {
71
        return getViewer().getColumnViewerEditor().getFocusCell();
72
    }
73

    
74
}
(6-6/17)