1 |
fd4fff8b
|
Patrick Plitzner
|
package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
|
2 |
|
|
|
3 |
|
|
import java.util.Collections;
|
4 |
|
|
import java.util.UUID;
|
5 |
|
|
|
6 |
c050c60b
|
Patrick Plitzner
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
7 |
0db2412a
|
Patrick Plitzner
|
import org.eclipse.swt.widgets.Shell;
|
8 |
c050c60b
|
Patrick Plitzner
|
|
9 |
fd4fff8b
|
Patrick Plitzner
|
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 |
aa29d392
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
14 |
150b624d
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
15 |
fd4fff8b
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
|
16 |
0db2412a
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
|
17 |
fd4fff8b
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
18 |
|
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
19 |
|
|
|
20 |
0db2412a
|
Patrick Plitzner
|
public class OpenDerivativeEditorForDescriptionElement extends DefaultOpenHandlerBaseE4<IndividualsAssociation> {
|
21 |
fd4fff8b
|
Patrick Plitzner
|
|
22 |
|
|
@Override
|
23 |
|
|
protected IndividualsAssociation getEntity(UUID uuid) {
|
24 |
|
|
DescriptionElementBase descriptionElement = CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null);
|
25 |
7f6da0d3
|
Patrick Plitzner
|
if(descriptionElement!=null && descriptionElement.isInstanceOf(IndividualsAssociation.class)){
|
26 |
fd4fff8b
|
Patrick Plitzner
|
return (IndividualsAssociation) descriptionElement;
|
27 |
|
|
}
|
28 |
|
|
return null;
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
@Override
|
32 |
37bbbd30
|
Patrick Plitzner
|
protected void open(IndividualsAssociation entity, Shell shell, EPartService partService) {
|
33 |
c050c60b
|
Patrick Plitzner
|
if(entity==null || entity.getAssociatedSpecimenOrObservation()==null){
|
34 |
|
|
MessagingUtils.messageDialog(Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS, this, Messages.OpenDerivativeEditorForDescriptionElement_NO_SPECIMENS_MESSAGE);
|
35 |
|
|
return;
|
36 |
|
|
}
|
37 |
fd4fff8b
|
Patrick Plitzner
|
SpecimenOrObservationBase associatedSpecimenOrObservation = entity.getAssociatedSpecimenOrObservation();
|
38 |
|
|
if(associatedSpecimenOrObservation!=null){
|
39 |
|
|
UUID specimenUuid = associatedSpecimenOrObservation.getUuid();
|
40 |
aa29d392
|
Patrick Plitzner
|
EditorUtil.openSpecimenEditor(new DerivateViewEditorInput(Collections.singletonList(specimenUuid)), modelService, partService, application);
|
41 |
fd4fff8b
|
Patrick Plitzner
|
}
|
42 |
|
|
}
|
43 |
|
|
|
44 |
0db2412a
|
Patrick Plitzner
|
/**
|
45 |
|
|
* {@inheritDoc}
|
46 |
|
|
*/
|
47 |
|
|
@Override
|
48 |
|
|
protected boolean canExecute(IndividualsAssociation entity) {
|
49 |
|
|
return true;
|
50 |
|
|
}
|
51 |
fd4fff8b
|
Patrick Plitzner
|
}
|