Project

General

Profile

Download (1.92 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.editor.name.handler;
12

    
13
import org.apache.log4j.Logger;
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.core.commands.IHandler;
18
import org.eclipse.core.commands.common.NotDefinedException;
19

    
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.operations.AbstractPostOperation;
25
import eu.etaxonomy.taxeditor.operations.ChangeConceptToSynonymOperation;
26

    
27
/**
28
 * <p>ChangeToSynonymHandler class.</p>
29
 *
30
 * @author n.hoffmann
31
 * @created 21.04.2009
32
 * @version 1.0
33
 */
34
public class ChangeToSynonymHandler extends AbstractHandler implements
35
		IHandler {
36
	private static final Logger logger = Logger
37
			.getLogger(ChangeToSynonymHandler.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
		Taxon concept  = (Taxon) EditorUtil.getSelection(event).getFirstElement();
48
		
49
		AbstractPostOperation operation;
50
		try {
51
			operation = new ChangeConceptToSynonymOperation(event.getCommand().getName(), 
52
					editor.getUndoContext(), editor.getTaxon(), concept, null, editor);
53
			
54
			EditorUtil.executeOperation(operation);
55
		} catch (NotDefinedException e) {
56
			logger.warn("Command name not set");
57
		}
58
		
59
		return null;
60
	}
61
}
(9-9/21)