1 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.handler
;
3 import java
.util
.Collections
;
6 import org
.eclipse
.core
.commands
.ExecutionEvent
;
7 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
8 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
9 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
.PartState
;
11 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
12 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
13 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
14 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
15 import eu
.etaxonomy
.taxeditor
.editor
.AppModelId
;
16 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
17 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateView
;
18 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
19 import eu
.etaxonomy
.taxeditor
.handler
.defaultHandler
.DefaultOpenHandlerBase
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
22 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
24 public class OpenDerivativeEditorForDescriptionElement
extends DefaultOpenHandlerBase
<IndividualsAssociation
> {
27 protected IndividualsAssociation
getEntity(UUID uuid
) {
28 DescriptionElementBase descriptionElement
= CdmStore
.getService(IDescriptionService
.class).loadDescriptionElement(uuid
, null);
29 if(descriptionElement
!=null && descriptionElement
.isInstanceOf(IndividualsAssociation
.class)){
30 return (IndividualsAssociation
) descriptionElement
;
36 protected void open(ExecutionEvent event
, IndividualsAssociation entity
) {
37 if(entity
==null || entity
.getAssociatedSpecimenOrObservation()==null){
38 MessagingUtils
.messageDialog(Messages
.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS
, this, Messages
.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE
);
41 SpecimenOrObservationBase associatedSpecimenOrObservation
= entity
.getAssociatedSpecimenOrObservation();
42 if(associatedSpecimenOrObservation
!=null){
43 UUID specimenUuid
= associatedSpecimenOrObservation
.getUuid();
44 DerivateViewEditorInput input
= new DerivateViewEditorInput(Collections
.singletonList(specimenUuid
));
45 MPart part
= TaxeditorStorePlugin
.getDefault().getWorkbench().getService(EPartService
.class).showPart(
46 AppModelId
.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW
, PartState
.ACTIVATE
);
47 DerivateView derivateView
= (DerivateView
) part
.getObject();
48 derivateView
.init(input
);