Project

General

Profile

Download (1.99 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2009 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
package eu.etaxonomy.taxeditor.editor.definedterm.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
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.ui.handlers.HandlerUtil;
19

    
20
import eu.etaxonomy.cdm.model.common.TermBase;
21
import eu.etaxonomy.taxeditor.editor.definedterm.DefinedTermEditor;
22
import eu.etaxonomy.taxeditor.editor.definedterm.operation.CreateDefinedTermOperation;
23
import eu.etaxonomy.taxeditor.editor.definedterm.operation.CreateTermVocabularyOperation;
24
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
25
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26
import eu.etaxonomy.taxeditor.store.StoreUtil;
27

    
28
/**
29
 * @author l.morris
30
 * @date 21 Dec 2011
31
 *
32
 */
33
public class CreateTermVocabularyHandler extends AbstractHandler implements
34
		IHandler {
35

    
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38
	 */
39
	@Override
40
	public Object execute(ExecutionEvent event) throws ExecutionException {
41
		IPostOperationEnabled editor = (IPostOperationEnabled) HandlerUtil
42
				.getActiveEditor(event);
43

    
44
		if (! (editor instanceof DefinedTermEditor)){
45
			return null;
46
		}
47
		
48
		try {
49
			AbstractPostOperation operation = new CreateTermVocabularyOperation(
50
					event.getCommand().getName(), StoreUtil.getUndoContext(), (DefinedTermEditor) editor);
51
			StoreUtil.executeOperation(operation);
52

    
53
		} catch (NotDefinedException e) {
54
			StoreUtil.error(getClass(), e);
55
		}
56

    
57
		return null;
58
	}
59

    
60
}
(2-2/5)