Project

General

Profile

Download (2.45 KB) Statistics
| Branch: | Tag: | Revision:
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.editor.name.e4.handler;
10
import javax.inject.Named;
11

    
12
import org.eclipse.e4.core.di.annotations.CanExecute;
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.e4.ui.di.UISynchronize;
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.cdm.model.name.TaxonName;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
24
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
25
import eu.etaxonomy.taxeditor.model.AbstractUtility;
26
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
27
import eu.etaxonomy.taxeditor.parser.ParseHandler;
28

    
29
/**
30
 * @author k.luther
31
 * @since 15.05.2018
32
 *
33
 */
34
public class CreateProParteSynonymHandlerE4 {
35

    
36

    
37
        @Execute
38
        public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
39
                MHandledMenuItem menuItem,
40
                UISynchronize sync) {
41

    
42
            TaxonNameEditorE4 editor = (TaxonNameEditorE4) activePart.getObject();
43

    
44
            TaxonName conceptName = ParseHandler.createEmptyName();
45
            Taxon concept = Taxon.NewInstance(conceptName, null);
46

    
47
            TaxonRelationshipType type = TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR();
48

    
49
            AbstractPostOperation<?> operation;
50
            operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(),
51
                    editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
52
            AbstractUtility.executeOperation(operation, sync);
53
        }
54

    
55

    
56
        @CanExecute
57
        public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
58
                MHandledMenuItem menuItem){
59
            boolean canExecute = false;
60
            Object selectedElement = selection.getFirstElement();
61
           // canExecute = NameEditorMenuPropertyTester.isNotProparteSynonym(selectedElement);
62
            return true;
63
        }
64

    
65

    
66
}
(10-10/16)