1 package eu
.etaxonomy
.taxeditor
.editor
.handler
;
3 import org
.eclipse
.core
.commands
.AbstractHandler
;
4 import org
.eclipse
.core
.commands
.ExecutionEvent
;
5 import org
.eclipse
.core
.commands
.ExecutionException
;
6 import org
.eclipse
.jface
.viewers
.ISelection
;
7 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
8 import org
.eclipse
.ui
.PartInitException
;
9 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
11 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
12 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
13 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
14 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
16 public class OpenDerivateViewHandler
extends AbstractHandler
{
19 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
22 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
23 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
24 if(currentSelection
instanceof IStructuredSelection
){
25 Object selectedElement
= ((IStructuredSelection
) currentSelection
).getFirstElement();
26 if(selectedElement
instanceof SpecimenOrObservationBase
<?
>){
28 DerivateViewEditorInput input
= new DerivateViewEditorInput(((SpecimenOrObservationBase
<?
>) selectedElement
).getUuid());
30 EditorUtil
.open(input
);
31 } catch (PartInitException e
) {
32 AbstractUtility
.error(OpenDerivateViewHandler
.class, "Could not open DerivateView", e
);
33 } catch (NullPointerException npe
){
34 AbstractUtility
.errorDialog("Failed to open Editor", OpenDerivateViewHandler
.class, "Could not open DerivateView. The derivate hierarchy is corrupted!", npe
);