13 |
13 |
import org.eclipse.e4.core.di.annotations.CanExecute;
|
14 |
14 |
import org.eclipse.e4.core.di.annotations.Execute;
|
15 |
15 |
import org.eclipse.e4.ui.model.application.MApplication;
|
|
16 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
16 |
17 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
|
17 |
18 |
import org.eclipse.e4.ui.services.IServiceConstants;
|
18 |
19 |
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
19 |
20 |
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
|
21 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
20 |
22 |
|
21 |
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
22 |
23 |
import eu.etaxonomy.cdm.model.common.Group;
|
|
24 |
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
|
23 |
25 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
24 |
26 |
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
|
25 |
27 |
import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
|
26 |
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
27 |
28 |
|
28 |
29 |
/**
|
29 |
30 |
* Handler which opens an instance of the {@link CdmAuthorityEditorE4} for a2
|
... | ... | |
36 |
37 |
|
37 |
38 |
public class EditCdmAuthoritiesHandlerE4 {
|
38 |
39 |
|
39 |
|
private static final String OPENING_CDM_AUTHORITIES = Messages.EditCdmAuthoritiesHandler_OPEN_AUTHORITIES;
|
40 |
|
|
41 |
40 |
@Execute
|
42 |
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
|
43 |
|
EPartService partService, EModelService modelService, MApplication application) {
|
|
41 |
public void execute(EPartService partService, EModelService modelService, MApplication application,
|
|
42 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
|
|
43 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
|
|
44 |
Group group = (Group) editor.getSelection().getFirstElement();
|
44 |
45 |
try {
|
45 |
|
EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(((Group) selection).getUuid()), modelService, partService, application);
|
|
46 |
EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(group.getUuid()), modelService, partService, application);
|
46 |
47 |
} catch (Exception e) {
|
47 |
48 |
e.printStackTrace();
|
48 |
49 |
}
|
49 |
50 |
}
|
50 |
51 |
|
51 |
52 |
@CanExecute
|
52 |
|
public boolean execute(@Named(IServiceConstants.ACTIVE_SELECTION) CdmBase selection,
|
53 |
|
MHandledMenuItem menuItem){
|
|
53 |
public boolean execute(MHandledMenuItem menuItem,
|
|
54 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart){
|
54 |
55 |
boolean canExecute = false;
|
55 |
|
canExecute = selection instanceof Group;
|
|
56 |
BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
|
|
57 |
IStructuredSelection selection = editor.getSelection();
|
|
58 |
canExecute =
|
|
59 |
selection.size()==1
|
|
60 |
&& selection.getFirstElement() instanceof Group;
|
56 |
61 |
menuItem.setVisible(canExecute);
|
57 |
62 |
return canExecute;
|
58 |
63 |
|
ref #6321 Fix open authority handler + no multiple editor for same input