2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.handler
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
21 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
22 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
23 import eu
.etaxonomy
.taxeditor
.editor
.AppModelId
;
24 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
25 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
26 import eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
.DerivateViewEditorInput
;
27 import eu
.etaxonomy
.taxeditor
.handler
.defaultHandler
.e4
.DefaultOpenHandlerBaseE4
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 public class OpenDerivativeEditorForGatheringEvent
extends DefaultOpenHandlerBaseE4
<GatheringEvent
, UuidAndTitleCache
<GatheringEvent
>> {
32 protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN
= Messages
.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN
;
35 protected void open(UuidAndTitleCache
<GatheringEvent
> entity
, Shell shell
, EPartService partService
) {
36 Collection
<UUID
> specimenUuids
= new ArrayList
<>();
37 List
<FieldUnit
> fieldUnits
= CdmStore
.getService(IOccurrenceService
.class).findFieldUnitsForGatheringEvent(entity
.getUuid());
38 fieldUnits
.forEach(fieldUnit
->specimenUuids
.add(fieldUnit
.getUuid()));
39 DerivateViewEditorInput input
= new DerivateViewEditorInput(specimenUuids
);
40 EditorUtil
.openSpecimenEditor(input
, modelService
, partService
, application
);
44 protected boolean canExecute(UuidAndTitleCache
<GatheringEvent
> entity
) {
45 return GatheringEvent
.class.isAssignableFrom(entity
.getType());
49 protected String
getPartId() {
50 return AppModelId
.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW
;