ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / handler / CreateMisapplicationHandler.java
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.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.common.NotDefinedException;
17
18 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19 import eu.etaxonomy.cdm.model.taxon.Taxon;
20 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
21 import eu.etaxonomy.taxeditor.editor.EditorUtil;
22 import eu.etaxonomy.taxeditor.editor.Page;
23 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
24 import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
25 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
26 import eu.etaxonomy.taxeditor.parser.ParseHandler;
27
28 /**
29 * <p>CreateMisapplicationHandler class.</p>
30 *
31 * @author n.hoffmann
32 * @created 16.04.2009
33 * @version 1.0
34 */
35 public class CreateMisapplicationHandler extends AbstractHandler {
36 private static final Logger logger = Logger
37 .getLogger(CreateMisapplicationHandler.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
48 TaxonNameBase conceptName = ParseHandler.createEmptyName();
49 Taxon concept = Taxon.NewInstance(conceptName, null);
50
51 TaxonRelationshipType type = TaxonRelationshipType.MISAPPLIED_NAME_FOR();
52
53 AbstractPostOperation operation;
54 try {
55 operation = new CreateConceptRelationOperation(event.getCommand().getName(),
56 editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
57 EditorUtil.executeOperation(operation);
58 } catch (NotDefinedException e) {
59 logger.warn("Command name not set");
60 }
61
62 return null;
63 }
64 }