Project

General

Profile

Download (2.13 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
2

    
3
import java.util.ArrayList;
4
import java.util.Collection;
5
import java.util.List;
6
import java.util.UUID;
7

    
8
import org.eclipse.e4.ui.workbench.modeling.EPartService;
9
import org.eclipse.jface.viewers.IStructuredSelection;
10
import org.eclipse.swt.widgets.Shell;
11

    
12
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
13
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
14
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
15
import eu.etaxonomy.taxeditor.editor.AppModelId;
16
import eu.etaxonomy.taxeditor.editor.EditorUtil;
17
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
18
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateViewEditorInput;
19
import eu.etaxonomy.taxeditor.handler.defaultHandler.e4.DefaultOpenHandlerBaseE4;
20
import eu.etaxonomy.taxeditor.store.CdmStore;
21

    
22
public class OpenDerivativeEditorForGatheringEvent extends DefaultOpenHandlerBaseE4<GatheringEvent> {
23

    
24
    protected static final String OPEN_DERIVATIVE_EDITOR_FOR_TAXON_NODE_COULD_NOT_OPEN = Messages.OpenDerivativeEditorForTaxonNode_COULD_NOT_OPEN;
25

    
26
//    @Override
27
//    protected GatheringEvent getEntity(UUID uuid) {
28
//        ICdmBase load = CdmStore.getService(IEventBaseService.class).load(uuid);
29
//        return HibernateProxyHelper.deproxy(load, GatheringEvent.class );
30
//    }
31

    
32
    @Override
33
    protected void open(GatheringEvent entity, Shell shell, EPartService partService) {
34
        Collection<UUID> specimenUuids = new ArrayList<UUID>();
35
        List<FieldUnit> fieldUnits = CdmStore.getService(IOccurrenceService.class).findFieldUnitsForGatheringEvent(entity.getUuid());
36
        fieldUnits.forEach(fieldUnit->specimenUuids.add(fieldUnit.getUuid()));
37
        DerivateViewEditorInput input = new DerivateViewEditorInput(specimenUuids);
38
        EditorUtil.openSpecimenEditor(input, modelService, partService, application);
39
    }
40

    
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    protected boolean canExecute(IStructuredSelection entity) {
46
        return true;
47
    }
48

    
49
    @Override
50
    protected String getPartId() {
51
        return AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DERIVATE_DERIVATEVIEW;
52
    }
53

    
54
}
(12-12/18)