1 package eu
.etaxonomy
.taxeditor
.editor
.name
.handler
;
5 import org
.apache
.log4j
.Logger
;
6 import org
.eclipse
.core
.commands
.AbstractHandler
;
7 import org
.eclipse
.core
.commands
.ExecutionEvent
;
8 import org
.eclipse
.core
.commands
.ExecutionException
;
9 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
10 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
11 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
12 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
13 import org
.eclipse
.swt
.widgets
.Shell
;
14 import org
.eclipse
.ui
.IEditorInput
;
15 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
17 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
18 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
22 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
23 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
24 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
25 import eu
.etaxonomy
.taxeditor
.editor
.name
.operation
.MoveSynonymToAnotherAcceptedTaxonOperation
;
26 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
.TaxonNodeSelectionDialog
;
29 public class MoveSynonymToAnotherAcceptedTaxonHandler
extends AbstractHandler
implements IPostOperationEnabled
{
30 private static final Logger logger
= Logger
31 .getLogger(MoveSynonymToAnotherAcceptedTaxonHandler
.class);
32 private MultiPageTaxonEditor editor
;
35 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
36 editor
= (MultiPageTaxonEditor
) HandlerUtil
.getActiveEditor(event
);
37 Shell shell
= HandlerUtil
.getActiveShell(event
);
38 IEditorInput input
= editor
.getEditorInput();
39 if (!EditorUtil
.forceUserSave(editor
, shell
)) {
43 if (!(input
instanceof TaxonEditorInput
)) {
44 logger
.error("Editor input is not TaxonEditorInput");
48 // Get synonym from selection
49 StructuredSelection selection
= (StructuredSelection
) HandlerUtil
.getCurrentSelection(event
);
50 if (!(selection
.getFirstElement() instanceof Synonym
)) {
51 logger
.error("Selection does not contain a Synonym");
55 Synonym synonym
= (Synonym
) selection
.getFirstElement();
56 TaxonNode newParentNode
= TaxonNodeSelectionDialog
.select(HandlerUtil
.getActiveShell(event
), editor
.getConversationHolder(), "Select new accepted taxon", null, null, null);
57 Taxon oldParent
= ((TaxonEditorInput
)input
).getTaxon();
59 MoveSynonymToAnotherAcceptedTaxonOperation operation
= new MoveSynonymToAnotherAcceptedTaxonOperation("Change accepted Taxon of Synonym", EditorUtil
.getUndoContext(),
60 oldParent
.getUuid(), synonym
.getUuid(), newParentNode
.getTaxon(), editor
);
62 EditorUtil
.executeOperation(operation
);
69 public boolean postOperation(CdmBase objectAffectedByOperation
) {
70 // TODO Auto-generated method stub
75 public boolean onComplete() {
76 // TODO Auto-generated method stub