Project

General

Profile

Download (2.07 KB) Statistics
| Branch: | Tag: | Revision:
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.eclipse.core.commands.AbstractHandler;
13
import org.eclipse.core.commands.ExecutionEvent;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.IHandler;
16
import org.eclipse.core.commands.common.NotDefinedException;
17

    
18
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
19
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
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.name.operation.CreateSynonymInExistingHomotypicalGroupOperation;
25
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
26
import eu.etaxonomy.taxeditor.parser.ParseHandler;
27

    
28
/**
29
 * <p>CreateHomotypicSynonymHandler class.</p>
30
 *
31
 * @author n.hoffmann
32
 * @created 06.02.2009
33
 * @version 1.0
34
 */
35
public class CreateHomotypicSynonymHandler extends AbstractHandler implements
36
		IHandler {
37

    
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
40
	 */
41
	/** {@inheritDoc} */
42
	public Object execute(ExecutionEvent event) throws ExecutionException {
43
		TaxonNameEditor editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
44
				Page.NAME);
45
		Taxon taxon = editor.getTaxon();
46
		HomotypicalGroup group = taxon.getHomotypicGroup();
47
		TaxonNameBase newSynonymName = ParseHandler.createEmptyName();
48
		
49
		AbstractPostOperation operation;
50
		try {
51
			operation = new CreateSynonymInExistingHomotypicalGroupOperation(event.getCommand().getName(), 
52
					editor.getUndoContext(), taxon, group, newSynonymName, editor);
53
			EditorUtil.executeOperation(operation);
54
		} catch (NotDefinedException e) {
55
			EditorUtil.error(getClass(), e);
56
		}
57
		
58

    
59
		return null;
60
	}
61
}
(7-7/16)