b416726cd1377a98e7220f3d4aecf67fc3a0e922
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / handler / OpenTaxonEditorHandler.java
1 package eu.etaxonomy.taxeditor.editor.handler;
2 import org.eclipse.core.commands.AbstractHandler;
3 import org.eclipse.core.commands.ExecutionEvent;
4 import org.eclipse.core.commands.ExecutionException;
5 import org.eclipse.core.commands.ParameterType;
6 import org.eclipse.core.commands.common.NotDefinedException;
7 import org.eclipse.ui.PartInitException;
8
9 import eu.etaxonomy.taxeditor.editor.EditorUtil;
10 import eu.etaxonomy.taxeditor.model.MessagingUtils;
11
12
13 public class OpenTaxonEditorHandler extends AbstractHandler {
14
15 @Override
16 public Object execute(ExecutionEvent event) throws ExecutionException {
17 Object object = event.getObjectParameterForExecution("eu.etaxonomy.taxeditor.editor.taxonParameter");
18
19 try {
20 ParameterType parameterType = event.getCommand().getParameterType("eu.etaxonomy.taxeditor.editor.taxonParameter");
21 if(parameterType.isCompatible(object)){
22 EditorUtil.openTaxonEditor(object);
23 }
24 } catch (NotDefinedException e) {
25 MessagingUtils.error(this.getClass(), "Parameter type not defined", e);
26 } catch (PartInitException e) {
27 MessagingUtils.error(OpenTaxonEditorHandler.class, "Error opening the editor", e);
28 }
29 return null;
30 }
31
32 }