Project

General

Profile

Download (2.32 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

    
10
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
11

    
12
import javax.inject.Named;
13

    
14
import org.eclipse.e4.core.di.annotations.CanExecute;
15
import org.eclipse.e4.core.di.annotations.Execute;
16
import org.eclipse.e4.ui.di.UISynchronize;
17
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
18
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
19
import org.eclipse.e4.ui.services.IServiceConstants;
20
import org.eclipse.jface.viewers.IStructuredSelection;
21

    
22
import eu.etaxonomy.cdm.model.name.TaxonName;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
25
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
26
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
27
import eu.etaxonomy.taxeditor.model.AbstractUtility;
28
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
29
import eu.etaxonomy.taxeditor.parser.ParseHandler;
30

    
31
/**
32
 *
33
 * @author pplitzner
34
 * @since Aug 28, 2017
35
 *
36
 */
37
public class CreateMisapplicationHandlerE4 {
38

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

    
44
        TaxonNameEditorE4 editor = (TaxonNameEditorE4) activePart.getObject();
45

    
46
		TaxonName conceptName = ParseHandler.createEmptyName();
47
		Taxon concept = Taxon.NewInstance(conceptName, null);
48

    
49
		TaxonRelationshipType type = TaxonRelationshipType.MISAPPLIED_NAME_FOR();
50

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

    
57

    
58
    @CanExecute
59
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
60
            MHandledMenuItem menuItem){
61
        boolean canExecute = false;
62
        Object selectedElement = selection.getFirstElement();
63
      //  canExecute = !NameEditorMenuPropertyTester.isMisapplication(selectedElement);
64
        return true;
65
    }
66
}
(9-9/16)