Project

General

Profile

Revision a4784593

IDa47845938daf3f2f813a362dcf69776882eb6db2
Parent 9d6458e9
Child c508431a

Added by Patrick Plitzner over 1 year ago

ref #7439 Add context menu to cell editor, disable editing

View differences:

eu.etaxonomy.taxeditor.bulkeditor/META-INF/MANIFEST.MF
21 21
 eu.etaxonomy.taxeditor.cdmlib,
22 22
 org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0.v20160229-1459",
23 23
 org.eclipse.e4.ui.workbench,
24
 org.eclipse.e4.core.di.annotations;bundle-version="1.5.0",
24
 org.eclipse.e4.core.di.annotations,
25 25
 org.eclipse.e4.ui.services,
26 26
 org.eclipse.e4.ui.di,
27 27
 org.eclipse.e4.core.contexts,
28 28
 org.eclipse.e4.core.services,
29 29
 org.eclipse.nebula.widgets.nattable.core,
30 30
 ca.odell.glazedlists,
31
 org.eclipse.nebula.widgets.nattable.extension.glazedlists
31
 org.eclipse.nebula.widgets.nattable.extension.glazedlists,
32
 org.eclipse.e4.core.di
32 33
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
33 34
Import-Package: eu.etaxonomy.taxeditor.editor,
34 35
 org.eclipse.core.runtime,
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/NullTextEditor.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.bulkeditor;
10

  
11
import javax.inject.Inject;
12

  
13
import org.eclipse.e4.ui.services.EMenuService;
14
import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.swt.widgets.Text;
19

  
20
/**
21
 * @author pplitzner
22
 * @since Jun 26, 2018
23
 *
24
 */
25
public class NullTextEditor extends AbstractCellEditor{
26

  
27
    private Control editorControl;
28
    private Text text;
29
    @Inject
30
    private EMenuService menuService;
31

  
32
    @Override
33
    public Object getEditorValue() {
34
        return null;
35
    }
36

  
37
    @Override
38
    public void setEditorValue(Object value) {
39
    }
40

  
41
    @Override
42
    public Control getEditorControl() {
43
        return editorControl;
44
    }
45

  
46
    @Override
47
    public Control createEditorControl(Composite parent) {
48
        text = new Text(parent, SWT.NONE);
49
        text.setEditable(false);
50
        menuService.registerContextMenu(text, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor");
51
        return text;
52
    }
53

  
54
    @Override
55
    protected Control activateCell(Composite parent, Object originalCanonicalValue) {
56
        editorControl = createEditorControl(parent);
57
        text.setText(originalCanonicalValue.toString());
58
        text.selectAll();
59
        return editorControl;
60
    }
61

  
62
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
21 21

  
22 22
import org.eclipse.core.runtime.IProgressMonitor;
23 23
import org.eclipse.core.runtime.NullProgressMonitor;
24
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
25
import org.eclipse.e4.core.contexts.IEclipseContext;
24 26
import org.eclipse.e4.core.di.annotations.Optional;
25 27
import org.eclipse.e4.core.services.events.IEventBroker;
26 28
import org.eclipse.e4.ui.di.Focus;
......
90 92
import eu.etaxonomy.cdm.model.taxon.Taxon;
91 93
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
92 94
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
95
import eu.etaxonomy.taxeditor.bulkeditor.NullTextEditor;
93 96
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
94 97
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator;
95 98
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
......
134 137
    private ISelectionChangedListener selectionChangedListener;
135 138

  
136 139
    @Inject
140
    IEclipseContext context;
141

  
142
    @Inject
137 143
    private MPart thisPart;
138 144

  
139 145
    private BulkEditorQuery lastQuery = null;
......
298 304
                        EditConfigAttributes.CELL_EDITABLE_RULE,
299 305
                        IEditableRule.ALWAYS_EDITABLE,
300 306
                        DisplayMode.EDIT);
307
                //register editor
308
                NullTextEditor nullTextEditor = new NullTextEditor();
309
                ContextInjectionFactory.inject(nullTextEditor, context);
310
                configRegistry.registerConfigAttribute(
311
                        EditConfigAttributes.CELL_EDITOR,
312
                        nullTextEditor,
313
                        DisplayMode.EDIT);
301 314
            }
302 315
        });
303 316

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)