1
|
/**
|
2
|
* Copyright (C) 2007 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.e4.handler;
|
10
|
|
11
|
import javax.inject.Named;
|
12
|
|
13
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
14
|
import org.eclipse.e4.core.di.annotations.Execute;
|
15
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
16
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
17
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
18
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
19
|
|
20
|
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditor;
|
21
|
|
22
|
/**
|
23
|
*
|
24
|
* @author pplitzner
|
25
|
* @date 12.09.2017
|
26
|
*
|
27
|
*/
|
28
|
public class CopyHandler {
|
29
|
|
30
|
@Execute
|
31
|
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
|
32
|
BulkEditor editor = (BulkEditor) activePart.getObject();
|
33
|
editor.copyDataToClipboard();
|
34
|
}
|
35
|
|
36
|
@CanExecute
|
37
|
public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
|
38
|
MHandledMenuItem menuItem) {
|
39
|
boolean canExecute = false;
|
40
|
BulkEditor editor = (BulkEditor) activePart.getObject();
|
41
|
IStructuredSelection selection = editor.getCellSelection();
|
42
|
canExecute = selection.size()==1;
|
43
|
menuItem.setVisible(canExecute);
|
44
|
return canExecute;
|
45
|
}
|
46
|
}
|