3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.association
;
12 import java
.util
.Collection
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.NotEnabledException
;
16 import org
.eclipse
.core
.commands
.NotHandledException
;
17 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
18 import org
.eclipse
.jface
.viewers
.ArrayContentProvider
;
19 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
20 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
21 import org
.eclipse
.jface
.viewers
.TableViewer
;
22 import org
.eclipse
.swt
.SWT
;
23 import org
.eclipse
.swt
.widgets
.Label
;
24 import org
.eclipse
.ui
.handlers
.IHandlerService
;
26 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
27 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
29 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
30 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
32 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
33 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
34 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
41 public class TaxonAssociationDetailElement
extends AbstractCdmDetailElement
<DerivedUnitFacade
> implements IDoubleClickListener
{
44 public TaxonAssociationDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
45 super(formFactory
, formElement
);
50 protected void createControls(ICdmFormElement formElement
, DerivedUnitFacade entity
, int style
) {
52 Label associationsLabel
= formFactory
.createLabel(getLayoutComposite(), "Individuals Associations");
53 associationsLabel
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
55 TableViewer associationsViewer
= new TableViewer(getLayoutComposite(), SWT
.FULL_SELECTION
);
56 associationsViewer
.getTable().setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
57 associationsViewer
.setContentProvider(new ArrayContentProvider());
58 Collection
<TaxonBase
<?
>> associatedTaxa
= CdmStore
.getService(IOccurrenceService
.class).listAssociatedTaxa(entity
.innerDerivedUnit(), null, null, null, null);
59 associationsViewer
.setInput(associatedTaxa
);
60 associationsViewer
.addDoubleClickListener(this);
62 Label typeLabel
= formFactory
.createLabel(getLayoutComposite(), "Type Designations");
63 typeLabel
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
65 TableViewer typeDesignationViewer
= new TableViewer(getLayoutComposite(), SWT
.FULL_SELECTION
);
66 typeDesignationViewer
.getTable().setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
67 typeDesignationViewer
.setContentProvider(new ArrayContentProvider());
68 Collection
<TaxonBase
<?
>> typedTaxa
= CdmStore
.getService(IOccurrenceService
.class).listTypedTaxa(entity
.innerDerivedUnit(), null, null, null, null);
69 typeDesignationViewer
.setInput(typedTaxa
);
70 typeDesignationViewer
.addDoubleClickListener(this);
75 public void handleEvent(Object eventSource
) {
80 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
83 public void doubleClick(DoubleClickEvent event
) {
84 String commandId
= "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
86 IHandlerService handlerService
= (IHandlerService
) AbstractUtility
.getService(IHandlerService
.class);
88 handlerService
.executeCommand(commandId
, null);
89 } catch (ExecutionException e
) {
90 // TODO Auto-generated catch block
92 } catch (NotDefinedException e
) {
93 // TODO Auto-generated catch block
95 } catch (NotEnabledException e
) {
96 // TODO Auto-generated catch block
98 } catch (NotHandledException e
) {
99 // TODO Auto-generated catch block
104 // if(event.getSelection() instanceof StructuredSelection){
105 // StructuredSelection selection = (StructuredSelection)event.getSelection();
106 // if(selection.getFirstElement() instanceof TaxonBase<?>){
107 // UUID taxonBaseUUID = ((TaxonBase<?>) selection.getFirstElement()).getUuid();