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
|
*
|
27
|
* @author pplitzner
|
28
|
* @date 21.08.2017
|
29
|
*
|
30
|
*/
|
31
|
public class CreateConceptRelationMenuE4 {
|
32
|
|
33
|
public String commandName = "eu.etaxonomy.taxeditor.editor.name.createConceptRelation"; //$NON-NLS-1$
|
34
|
|
35
|
/** {@inheritDoc} */
|
36
|
@AboutToShow
|
37
|
public void aboutToShow(List<MMenuElement> items) {
|
38
|
|
39
|
MMenu menu = MMenuFactory.INSTANCE.createMenu();
|
40
|
menu.setLabel("New");
|
41
|
items.add(menu);
|
42
|
|
43
|
for (final TaxonRelationshipType taxonRelationshipType : CdmStore.getTermManager().getPreferredTerms(TaxonRelationshipType.class)) {
|
44
|
if (!taxonRelationshipType.equals(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN())) {
|
45
|
MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem();
|
46
|
menuItem.setLabel(taxonRelationshipType.getTitleCache());
|
47
|
MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
|
48
|
mCommand.setElementId(commandName);
|
49
|
mCommand.setCommandName("Create concept relation");
|
50
|
// set params
|
51
|
menuItem.getTransientData().put(commandName + ".taxonRelationshipType.uuid",
|
52
|
taxonRelationshipType.getUuid());
|
53
|
|
54
|
menuItem.setCommand(mCommand);
|
55
|
menu.getChildren().add(menuItem);
|
56
|
}
|
57
|
}
|
58
|
}
|
59
|
|
60
|
}
|