handler implementations
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / handlers / CreateMisappliedNameHandler.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.handlers;
5
6 import org.apache.log4j.Logger;
7 import org.eclipse.core.commands.AbstractHandler;
8 import org.eclipse.core.commands.ExecutionEvent;
9 import org.eclipse.core.commands.ExecutionException;
10 import org.eclipse.core.commands.IHandler;
11 import org.eclipse.core.commands.common.NotDefinedException;
12 import org.eclipse.core.commands.operations.IUndoableOperation;
13
14 import eu.etaxonomy.cdm.model.taxon.Taxon;
15 import eu.etaxonomy.taxeditor.controller.EditorController;
16 import eu.etaxonomy.taxeditor.controller.GlobalController;
17 import eu.etaxonomy.taxeditor.operations.name.CreateMisappliedNameOperation;
18
19 /**
20 * @author nho
21 *
22 */
23 public class CreateMisappliedNameHandler extends AbstractHandler implements IHandler {
24 private static final Logger logger = Logger
25 .getLogger(CreateMisappliedNameHandler.class);
26
27 /* (non-Javadoc)
28 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
29 */
30 public Object execute(ExecutionEvent event) throws ExecutionException {
31 Taxon taxon = EditorController.getActiveEditor().getTaxon();
32
33 IUndoableOperation operation;
34 try {
35 operation = new CreateMisappliedNameOperation(event.getCommand().getName(),
36 EditorController.getUndoContext(taxon), taxon);
37 GlobalController.executeOperation(operation);
38 } catch (NotDefinedException e) {
39 logger.warn("Command name not set");
40 }
41
42 return null;
43 }
44
45 }