f011cdb179cab0970c11554e1ee79b968d1f70f8
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / association / TaxonAssociationDetailElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.ui.section.occurrence.association;
11
12 import java.util.Collection;
13
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;
21
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;
31
32 /**
33 * @author pplitzner
34 * @date Dec 1, 2014
35 *
36 */
37 public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> implements IDoubleClickListener{
38
39
40 public TaxonAssociationDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
41 super(formFactory, formElement);
42 }
43
44 /** {@inheritDoc} */
45 @Override
46 protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
47
48 Label associationsLabel = formFactory.createLabel(getLayoutComposite(), "Individuals Associations");
49 associationsLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
50
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);
57
58 Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations");
59 typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
60
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);
67 }
68
69 /** {@inheritDoc} */
70 @Override
71 public void handleEvent(Object eventSource) {
72
73 }
74
75 /* (non-Javadoc)
76 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
77 */
78 @Override
79 public void doubleClick(DoubleClickEvent event) {
80 // String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
81 //
82 // IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
83 // try {
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();
97 // }
98
99
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();
104 // }
105 // }
106 }
107
108 }