1 |
3be6ef3e
|
n.hoffmann
|
/**
|
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.handler;
|
11 |
|
|
|
12 |
|
|
import org.apache.log4j.Logger;
|
13 |
|
|
import org.eclipse.core.commands.AbstractHandler;
|
14 |
|
|
import org.eclipse.core.commands.ExecutionEvent;
|
15 |
|
|
import org.eclipse.core.commands.ExecutionException;
|
16 |
|
|
import org.eclipse.core.commands.IHandler;
|
17 |
|
|
import org.eclipse.core.commands.common.NotDefinedException;
|
18 |
|
|
|
19 |
|
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
20 |
|
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
21 |
|
|
import eu.etaxonomy.taxeditor.editor.Page;
|
22 |
|
|
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
|
23 |
35861667
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation;
|
24 |
|
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
25 |
3be6ef3e
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.parser.ParseHandler;
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* <p>CreateHeterotypicSynonymHandler class.</p>
|
29 |
|
|
*
|
30 |
|
|
* @author n.hoffmann
|
31 |
|
|
* @created 06.02.2009
|
32 |
|
|
* @version 1.0
|
33 |
|
|
*/
|
34 |
|
|
public class CreateHeterotypicSynonymHandler extends AbstractHandler implements
|
35 |
|
|
IHandler {
|
36 |
|
|
private static final Logger logger = Logger
|
37 |
|
|
.getLogger(CreateHeterotypicSynonymHandler.class);
|
38 |
|
|
|
39 |
|
|
/* (non-Javadoc)
|
40 |
|
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
41 |
|
|
*/
|
42 |
|
|
/** {@inheritDoc} */
|
43 |
|
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
44 |
|
|
TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
|
45 |
|
|
Page.NAME);
|
46 |
|
|
|
47 |
|
|
TaxonNameBase newSynonymName = ParseHandler.createEmptyName();
|
48 |
|
|
|
49 |
|
|
AbstractPostOperation operation;
|
50 |
|
|
try {
|
51 |
|
|
operation = new CreateSynonymInNewGroupOperation(event.getCommand().getName(),
|
52 |
|
|
editor.getUndoContext(), editor.getTaxon(), newSynonymName, editor);
|
53 |
|
|
EditorUtil.executeOperation(operation);
|
54 |
|
|
} catch (NotDefinedException e) {
|
55 |
|
|
logger.warn("Command name not set");
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
return null;
|
59 |
|
|
}
|
60 |
|
|
}
|