2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.handler
;
12 import javax
.inject
.Named
;
14 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
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
;
20 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
21 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
23 import eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.TaxonNameEditorE4
;
24 import eu
.etaxonomy
.taxeditor
.editor
.name
.operation
.CreateSynonymInExistingHomotypicalGroupOperation
;
25 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
26 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
27 import eu
.etaxonomy
.taxeditor
.parser
.ParseHandler
;
35 public class CreateSynonymInHomotypicalGroupHandlerE4
{
38 public void execute(@Named(IServiceConstants
.ACTIVE_PART
)MPart activePart
,
39 @Named(IServiceConstants
.ACTIVE_SELECTION
)IStructuredSelection selection
,
40 MHandledMenuItem menuItem
) {
42 TaxonNameEditorE4 editor
= (TaxonNameEditorE4
) activePart
.getObject();
44 Object selecteObject
= selection
.getFirstElement();
46 if(! (selecteObject
instanceof Synonym
)){
50 Synonym synonym
= (Synonym
) selecteObject
;
52 HomotypicalGroup group
= synonym
.getHomotypicGroup();
54 TaxonName newSynonymName
= ParseHandler
.createEmptyName();
56 AbstractPostOperation
<?
> operation
;
58 operation
= new CreateSynonymInExistingHomotypicalGroupOperation(menuItem
.getLocalizedLabel(), editor
.getUndoContext(),
59 editor
.getTaxon(), group
, newSynonymName
, editor
);
60 AbstractUtility
.executeOperation(operation
);