1 package eu
.etaxonomy
.taxeditor
.editor
.handler
;
3 import java
.util
.HashSet
;
4 import java
.util
.Iterator
;
8 import org
.eclipse
.core
.commands
.AbstractHandler
;
9 import org
.eclipse
.core
.commands
.ExecutionEvent
;
10 import org
.eclipse
.core
.commands
.ExecutionException
;
11 import org
.eclipse
.jface
.viewers
.ISelection
;
12 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
13 import org
.eclipse
.ui
.PartInitException
;
14 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
16 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
17 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
18 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
19 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 public class OpenDerivateViewHandler
extends AbstractHandler
{
24 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
27 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
28 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
29 if(currentSelection
instanceof IStructuredSelection
){
30 Iterator
<?
> selectionIterator
= ((IStructuredSelection
) currentSelection
).iterator();
31 Set
<UUID
> selectedElementUUIDs
= new HashSet
<UUID
>();
32 while(selectionIterator
.hasNext()){
33 Object object
= selectionIterator
.next();
34 if(object
instanceof SpecimenOrObservationBase
<?
>){
35 selectedElementUUIDs
.add(((SpecimenOrObservationBase
<?
>) object
).getUuid());
38 DerivateViewEditorInput input
= new DerivateViewEditorInput(selectedElementUUIDs
);
40 EditorUtil
.open(input
);
41 } catch (PartInitException e
) {
42 MessagingUtils
.error(OpenDerivateViewHandler
.class, "Could not open DerivateView", e
);
43 } catch (NullPointerException npe
){
44 MessagingUtils
.messageDialog("Failed to open Editor", OpenDerivateViewHandler
.class, "Could not open DerivateView. The derivate hierarchy is corrupted!", npe
);