Project

General

Profile

Download (1.68 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.navigation.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
import org.eclipse.core.commands.operations.IUndoableOperation;
20
import org.eclipse.ui.handlers.HandlerUtil;
21

    
22
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
25
import eu.etaxonomy.taxeditor.store.operations.DeleteTaxonOperation;
26

    
27
/**
28
 * @author n.hoffmann
29
 * @created 06.04.2009
30
 * @version 1.0
31
 */
32
public class DeleteTaxonHandler extends AbstractHandler implements IHandler{
33
	private static final Logger logger = Logger
34
			.getLogger(DeleteTaxonHandler.class);
35

    
36
	public Object execute(ExecutionEvent event) throws ExecutionException {
37
		IConversationEnabled part =  (IConversationEnabled) HandlerUtil.getActivePart(event);
38
				
39
		Taxon taxon = NavigationUtil.getCurrentSelection(event);
40
		
41
		IUndoableOperation operation;
42
		try {
43
			operation = new DeleteTaxonOperation(event.getCommand().getName(), 
44
					NavigationUtil.getUndoContext(), taxon);
45
			NavigationUtil.executeOperation(operation);
46
		} catch (NotDefinedException e) {
47
			logger.warn("Command name not set");
48
		}
49

    
50
		return null;
51
	}
52
}
(2-2/6)