1 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.handler
;
3 import java
.util
.Collections
;
6 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
7 import org
.eclipse
.swt
.widgets
.Shell
;
9 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
10 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
11 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
12 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
13 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
14 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
15 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
16 import eu
.etaxonomy
.taxeditor
.handler
.defaultHandler
.e4
.DefaultOpenHandlerBaseE4
;
17 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
18 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
20 public class OpenDerivativeEditorForDescriptionElement
extends DefaultOpenHandlerBaseE4
<IndividualsAssociation
> {
23 protected IndividualsAssociation
getEntity(UUID uuid
) {
24 DescriptionElementBase descriptionElement
= CdmStore
.getService(IDescriptionService
.class).loadDescriptionElement(uuid
, null);
25 if(descriptionElement
!=null && descriptionElement
.isInstanceOf(IndividualsAssociation
.class)){
26 return (IndividualsAssociation
) descriptionElement
;
32 protected void open(IndividualsAssociation entity
, Shell shell
, EPartService partService
) {
33 if(entity
==null || entity
.getAssociatedSpecimenOrObservation()==null){
34 MessagingUtils
.messageDialog(Messages
.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS
, this, Messages
.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE
);
37 SpecimenOrObservationBase associatedSpecimenOrObservation
= entity
.getAssociatedSpecimenOrObservation();
38 if(associatedSpecimenOrObservation
!=null){
39 UUID specimenUuid
= associatedSpecimenOrObservation
.getUuid();
40 EditorUtil
.openSpecimenEditor(new DerivateViewEditorInput(Collections
.singletonList(specimenUuid
)), modelService
, partService
, application
);
48 protected boolean canExecute(IndividualsAssociation entity
) {