Project

General

Profile

Download (4.4 KB) Statistics
| Branch: | Tag: | Revision:
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

    
21
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
22
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
23
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
26
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
27
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
28
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
29

    
30
/**
31
 * @author pplitzner
32
 * @date Dec 1, 2014
33
 *
34
 */
35
public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> implements IDoubleClickListener{
36

    
37

    
38
    public TaxonAssociationDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) {
39
        super(formFactory, formElement);
40
    }
41

    
42
    /** {@inheritDoc} */
43
    @Override
44
    protected void createControls(ICdmFormElement formElement, DerivedUnitFacade entity, int style) {
45

    
46
        Label associationsLabel = formFactory.createLabel(getLayoutComposite(), "Individuals Associations");
47
        associationsLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
48

    
49
        TableViewer associationsViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
50
        associationsViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
51
        associationsViewer.setContentProvider(new ArrayContentProvider());
52
        Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(entity.innerDerivedUnit(), null, null, null, null);
53
        associationsViewer.setInput(associatedTaxa);
54
        associationsViewer.addDoubleClickListener(this);
55

    
56
        Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations");
57
        typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
58

    
59
        TableViewer typeDesignationViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION);
60
        typeDesignationViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
61
        typeDesignationViewer.setContentProvider(new ArrayContentProvider());
62
        Collection<TaxonBase<?>> typedTaxa = CdmStore.getService(IOccurrenceService.class).listTypedTaxa(entity.innerDerivedUnit(), null, null, null, null);
63
        typeDesignationViewer.setInput(typedTaxa);
64
        typeDesignationViewer.addDoubleClickListener(this);
65
    }
66

    
67
    /** {@inheritDoc} */
68
    @Override
69
    public void handleEvent(Object eventSource) {
70

    
71
    }
72

    
73
    /* (non-Javadoc)
74
     * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
75
     */
76
    @Override
77
    public void doubleClick(DoubleClickEvent event) {
78
//        String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
79
//
80
//        IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
81
//        try {
82
//            handlerService.executeCommand(commandId, null);
83
//        } catch (ExecutionException e) {
84
//            // TODO Auto-generated catch block
85
//            e.printStackTrace();
86
//        } catch (NotDefinedException e) {
87
//            // TODO Auto-generated catch block
88
//            e.printStackTrace();
89
//        } catch (NotEnabledException e) {
90
//            // TODO Auto-generated catch block
91
//            e.printStackTrace();
92
//        } catch (NotHandledException e) {
93
//            // TODO Auto-generated catch block
94
//            e.printStackTrace();
95
//        }
96

    
97

    
98
//        if(event.getSelection() instanceof StructuredSelection){
99
//            StructuredSelection selection = (StructuredSelection)event.getSelection();
100
//            if(selection.getFirstElement() instanceof TaxonBase<?>){
101
//                UUID taxonBaseUUID = ((TaxonBase<?>) selection.getFirstElement()).getUuid();
102
//            }
103
//        }
104
    }
105

    
106
}
(1-1/2)