Revision 07929589
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/association/TaxonAssociationDetailElement.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.util.ArrayList; |
13 | 13 |
import java.util.Collection; |
14 |
import java.util.HashSet; |
|
15 |
import java.util.Set; |
|
16 | 14 |
|
17 | 15 |
import org.eclipse.core.commands.Command; |
18 | 16 |
import org.eclipse.core.commands.ExecutionException; |
... | ... | |
36 | 34 |
|
37 | 35 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
38 | 36 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
39 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
40 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
41 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
42 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
43 | 37 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
44 | 38 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
45 | 39 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
55 | 49 |
*/ |
56 | 50 |
public class TaxonAssociationDetailElement extends AbstractCdmDetailElement<DerivedUnitFacade> implements IDoubleClickListener{ |
57 | 51 |
|
58 |
|
|
59 | 52 |
private TableViewer associationsViewer; |
60 |
private TableViewer typeDesignationViewer; |
|
61 | 53 |
|
62 | 54 |
public TaxonAssociationDetailElement(CdmFormFactory formFactory, ICdmFormElement formElement) { |
63 | 55 |
super(formFactory, formElement); |
... | ... | |
70 | 62 |
//TODO add context menu for deleting associations |
71 | 63 |
|
72 | 64 |
Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(entity.innerDerivedUnit(), null, null, null, null); |
73 |
Collection<SpecimenTypeDesignation> typeDesignations = CdmStore.getService(IOccurrenceService.class).listTypeDesignations(entity.innerDerivedUnit(), null, null, null, null); |
|
74 | 65 |
|
75 | 66 |
if(!associatedTaxa.isEmpty()){ |
76 | 67 |
associationsViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION); |
... | ... | |
84 | 75 |
label.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
85 | 76 |
} |
86 | 77 |
|
87 |
//TODO implement service method for this which is just used in the label provider |
|
88 |
Collection<TaxonBase<?>> typedTaxa = new HashSet<TaxonBase<?>>(); |
|
89 |
for (SpecimenTypeDesignation specimenTypeDesignation : typeDesignations) { |
|
90 |
for (TaxonNameBase taxonNameBase : specimenTypeDesignation.getTypifiedNames()) { |
|
91 |
Set taxa = taxonNameBase.getTaxa(); |
|
92 |
for (Object taxon : taxa) { |
|
93 |
if(taxon instanceof CdmBase && ((CdmBase)taxon).isInstanceOf(TaxonBase.class)){ |
|
94 |
typedTaxa.add(HibernateProxyHelper.deproxy(taxon, TaxonBase.class)); |
|
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
if(!typedTaxa.isEmpty()){ |
|
100 |
Label typeLabel = formFactory.createLabel(getLayoutComposite(), "Type Designations"); |
|
101 |
typeLabel.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
102 |
|
|
103 |
typeDesignationViewer = new TableViewer(getLayoutComposite(), SWT.FULL_SELECTION); |
|
104 |
typeDesignationViewer.getTable().setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
|
105 |
typeDesignationViewer.setContentProvider(new ArrayContentProvider()); |
|
106 |
typeDesignationViewer.setInput(typedTaxa); |
|
107 |
typeDesignationViewer.addDoubleClickListener(this); |
|
108 |
} |
|
109 | 78 |
} |
110 | 79 |
|
111 | 80 |
/** {@inheritDoc} */ |
Also available in: Unified diff
Remove types from taxon associations detail element