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.editor.group.authority.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.MApplication;
|
16
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
17
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
18
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
19
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
22
|
import eu.etaxonomy.cdm.model.common.Group;
|
23
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
24
|
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditor;
|
25
|
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
|
26
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
27
|
|
28
|
/**
|
29
|
* Handler which opens an instance of the {@link CdmAuthorityEditor} for a2
|
30
|
* particluar group.
|
31
|
*
|
32
|
* @author cmathew
|
33
|
* @created Mar 28, 2013
|
34
|
*
|
35
|
*/
|
36
|
|
37
|
public class EditCdmAuthoritiesHandlerE4 {
|
38
|
|
39
|
private static final String OPENING_CDM_AUTHORITIES = Messages.EditCdmAuthoritiesHandler_OPEN_AUTHORITIES;
|
40
|
|
41
|
@Execute
|
42
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
|
43
|
EPartService partService, EModelService modelService, MApplication application) {
|
44
|
try {
|
45
|
EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()), modelService, partService, application);
|
46
|
} catch (Exception e) {
|
47
|
e.printStackTrace();
|
48
|
}
|
49
|
}
|
50
|
|
51
|
@CanExecute
|
52
|
public boolean execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
|
53
|
MHandledMenuItem menuItem){
|
54
|
boolean canExecute = false;
|
55
|
canExecute = selection instanceof Group;
|
56
|
menuItem.setVisible(canExecute);
|
57
|
return canExecute;
|
58
|
|
59
|
}
|
60
|
}
|