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
.jface
.viewers
.ArrayContentProvider
;
15 import org
.eclipse
.jface
.viewers
.DoubleClickEvent
;
16 import org
.eclipse
.jface
.viewers
.IDoubleClickListener
;
17 import org
.eclipse
.jface
.viewers
.TableViewer
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.eclipse
.ui
.handlers
.IHandlerService
;
22 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
25 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
28 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
29 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
30 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractCdmDetailElement
;
37 public class TaxonAssociationDetailElement
extends AbstractCdmDetailElement
<DerivedUnitFacade
> implements IDoubleClickListener
{
40 public TaxonAssociationDetailElement(CdmFormFactory formFactory
, ICdmFormElement formElement
) {
41 super(formFactory
, formElement
);
46 protected void createControls(ICdmFormElement formElement
, DerivedUnitFacade entity
, int style
) {
48 Label associationsLabel
= formFactory
.createLabel(getLayoutComposite(), "Individuals Associations");
49 associationsLabel
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
51 TableViewer associationsViewer
= new TableViewer(getLayoutComposite(), SWT
.FULL_SELECTION
);
52 associationsViewer
.getTable().setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
53 associationsViewer
.setContentProvider(new ArrayContentProvider());
54 Collection
<TaxonBase
<?
>> associatedTaxa
= CdmStore
.getService(IOccurrenceService
.class).listAssociatedTaxa(entity
.innerDerivedUnit(), null, null, null, null);
55 associationsViewer
.setInput(associatedTaxa
);
56 associationsViewer
.addDoubleClickListener(this);
58 Label typeLabel
= formFactory
.createLabel(getLayoutComposite(), "Type Designations");
59 typeLabel
.setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
61 TableViewer typeDesignationViewer
= new TableViewer(getLayoutComposite(), SWT
.FULL_SELECTION
);
62 typeDesignationViewer
.getTable().setLayoutData(LayoutConstants
.FILL_HORIZONTALLY(2, 1));
63 typeDesignationViewer
.setContentProvider(new ArrayContentProvider());
64 Collection
<TaxonBase
<?
>> typedTaxa
= CdmStore
.getService(IOccurrenceService
.class).listTypedTaxa(entity
.innerDerivedUnit(), null, null, null, null);
65 typeDesignationViewer
.setInput(typedTaxa
);
66 typeDesignationViewer
.addDoubleClickListener(this);
71 public void handleEvent(Object eventSource
) {
76 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
79 public void doubleClick(DoubleClickEvent event
) {
80 // String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
82 // IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
84 // handlerService.executeCommand(commandId, null);
85 // } catch (ExecutionException e) {
86 // // TODO Auto-generated catch block
87 // e.printStackTrace();
88 // } catch (NotDefinedException e) {
89 // // TODO Auto-generated catch block
90 // e.printStackTrace();
91 // } catch (NotEnabledException e) {
92 // // TODO Auto-generated catch block
93 // e.printStackTrace();
94 // } catch (NotHandledException e) {
95 // // TODO Auto-generated catch block
96 // e.printStackTrace();
100 // if(event.getSelection() instanceof StructuredSelection){
101 // StructuredSelection selection = (StructuredSelection)event.getSelection();
102 // if(selection.getFirstElement() instanceof TaxonBase<?>){
103 // UUID taxonBaseUUID = ((TaxonBase<?>) selection.getFirstElement()).getUuid();