Revision 7a0547ca
Added by Patrick Plitzner over 10 years ago
- enabled DescriptiveView (Factual Data) to show descriptions of SpecimenOrObservationBase
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesContentProvider.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2011 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
14 | 14 |
import java.util.Map; |
15 | 15 |
import java.util.Set; |
16 | 16 |
|
17 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
|
18 |
import org.eclipse.jface.viewers.Viewer; |
|
19 |
|
|
20 | 17 |
import eu.etaxonomy.cdm.api.service.ITermService; |
21 | 18 |
import eu.etaxonomy.cdm.model.common.Marker; |
22 | 19 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
23 | 20 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
24 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
25 |
import eu.etaxonomy.cdm.model.description.FeatureTree; |
|
26 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
21 |
import eu.etaxonomy.cdm.model.description.IDescribable; |
|
27 | 22 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
28 |
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput; |
|
29 | 23 |
import eu.etaxonomy.taxeditor.editor.UsageTermCollection; |
30 | 24 |
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider; |
31 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer; |
|
32 | 25 |
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree; |
33 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
34 | 26 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
35 |
import eu.etaxonomy.taxeditor.store.TermStore; |
|
36 | 27 |
|
37 | 28 |
/** |
38 | 29 |
* The class provides the required content to the Uses View |
39 |
* @author a.theys
|
|
30 |
* @author a.theys |
|
40 | 31 |
* @created mar 13, 2012 |
41 | 32 |
* @version 1.0 |
42 | 33 |
*/ |
43 |
public class UsesContentProvider extends DescriptiveContentProvider implements ITreeContentProvider {
|
|
34 |
public class UsesContentProvider extends DescriptiveContentProvider { |
|
44 | 35 |
|
45 | 36 |
Set<MarkerType> markerTypes = new HashSet<MarkerType>(); |
46 |
|
|
37 |
|
|
47 | 38 |
/** |
48 | 39 |
* <p>Constructor for DescriptiveContentProvider.</p> |
49 | 40 |
* |
50 | 41 |
* @param featureNodeContainerCache a {@link java.util.Map} object. |
51 | 42 |
*/ |
52 |
public UsesContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {
|
|
43 |
public UsesContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {
|
|
53 | 44 |
super(featureNodeContainerCache); |
54 | 45 |
this.featureNodeContainerCache = featureNodeContainerCache; |
55 | 46 |
} |
56 | 47 |
|
57 | 48 |
/** |
58 | 49 |
* Get all descriptions associated with the given TaxonEditorInput |
59 |
*
|
|
50 |
* |
|
60 | 51 |
* @param parentElement |
61 | 52 |
* @return |
62 | 53 |
*/ |
63 | 54 |
@Override |
64 |
protected List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) { |
|
65 |
this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class)); |
|
66 |
Taxon taxon = parentElement.getTaxon(); |
|
67 |
List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>(); |
|
68 |
|
|
69 |
for(DescriptionBase description : taxon.getDescriptions()){ |
|
70 |
if(! description.isImageGallery()){ |
|
71 |
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); |
|
72 |
Set<Marker> descriptionMarkers = description.getMarkers(); |
|
73 |
if(descriptionMarkers != null) { |
|
74 |
for (Marker marker: descriptionMarkers) { |
|
75 |
if(marker.getMarkerType().equals(useMarkertype)) { |
|
76 |
descriptions.add(description); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
55 |
protected List<DescriptionBase> getDescriptions(IDescribable<?> parentElement) { |
|
56 |
List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>(); |
|
57 |
if(parentElement instanceof Taxon){ |
|
58 |
Taxon taxon = (Taxon) parentElement; |
|
59 |
this.markerTypes.addAll(CdmStore.getTermManager().getPreferredTerms(MarkerType.class)); |
|
60 |
for(DescriptionBase description : taxon.getDescriptions()){ |
|
61 |
if(! description.isImageGallery()){ |
|
62 |
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType); |
|
63 |
Set<Marker> descriptionMarkers = description.getMarkers(); |
|
64 |
if(descriptionMarkers != null) { |
|
65 |
for (Marker marker: descriptionMarkers) { |
|
66 |
if(marker.getMarkerType().equals(useMarkertype)) { |
|
67 |
descriptions.add(description); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
82 | 74 |
return descriptions; |
83 | 75 |
} |
84 | 76 |
|
Also available in: Unified diff