Project

General

Profile

Download (2.39 KB) Statistics
| Branch: | Tag: | Revision:
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.basic.MPart;
17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18
import org.eclipse.e4.ui.services.IServiceConstants;
19
import org.eclipse.e4.ui.workbench.modeling.EModelService;
20
import org.eclipse.e4.ui.workbench.modeling.EPartService;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22

    
23
import eu.etaxonomy.cdm.model.common.Group;
24
import eu.etaxonomy.taxeditor.bulkeditor.e4.BulkEditorE4;
25
import eu.etaxonomy.taxeditor.editor.EditorUtil;
26
import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput;
27
import eu.etaxonomy.taxeditor.editor.group.authority.e4.CdmAuthorityEditorE4;
28

    
29
/**
30
 * Handler which opens an instance of the {@link CdmAuthorityEditorE4} for a2
31
 * particluar group.
32
 *
33
 * @author cmathew
34
 * @created Mar 28, 2013
35
 *
36
 */
37

    
38
public class EditCdmAuthoritiesHandlerE4 {
39

    
40
    @Execute
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();
45
        try {
46
            EditorUtil.openRightsEditor(CdmAuthorityEditorInput.NewInstance(group.getUuid()), modelService, partService, application);
47
        } catch (Exception e) {
48
            e.printStackTrace();
49
        }
50
    }
51

    
52
    @CanExecute
53
    public boolean execute(MHandledMenuItem menuItem,
54
            @Named(IServiceConstants.ACTIVE_PART)MPart activePart){
55
        boolean canExecute = false;
56
        BulkEditorE4 editor = (BulkEditorE4) activePart.getObject();
57
        IStructuredSelection selection = editor.getSelection();
58
        canExecute =
59
                selection.size()==1
60
                && selection.getFirstElement() instanceof Group;
61
        menuItem.setVisible(canExecute);
62
        return canExecute;
63

    
64
    }
65
}
    (1-1/1)