Project

General

Profile

Download (2.13 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.view.concept.e4;
11

    
12
import java.util.List;
13

    
14
import org.eclipse.e4.ui.di.AboutToShow;
15
import org.eclipse.e4.ui.model.application.commands.MCommand;
16
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
19
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
20
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
21

    
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

    
25
/**
26
 * @author pplitzner
27
 * @date 21.08.2017
28
 */
29
public class CreateConceptRelationMenuE4 {
30

    
31
    public String commandName = "eu.etaxonomy.taxeditor.editor.name.createConceptRelation"; //$NON-NLS-1$
32

    
33
    @AboutToShow
34
    public void aboutToShow(List<MMenuElement> items) {
35

    
36
        MMenu menu = MMenuFactory.INSTANCE.createMenu();
37
        menu.setLabel("New");
38
        items.add(menu);
39

    
40
        for (final TaxonRelationshipType taxonRelationshipType : CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipType.class)) {
41
            if (!taxonRelationshipType.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
42
                MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem();
43
                menuItem.setLabel(taxonRelationshipType.getTitleCache());
44
                MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
45
                mCommand.setElementId(commandName);
46
                mCommand.setCommandName("Create concept relation");
47
                // set params
48
                menuItem.getTransientData().put(commandName + ".taxonRelationshipType.uuid",
49
                        taxonRelationshipType.getUuid());
50

    
51
                menuItem.setCommand(mCommand);
52
                menu.getChildren().add(menuItem);
53
            }
54
        }
55
    }
56

    
57
}
(2-2/2)