1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.editor.view.uses;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.List;
|
14
|
import java.util.Map;
|
15
|
import java.util.Set;
|
16
|
|
17
|
import org.eclipse.jface.viewers.ITreeContentProvider;
|
18
|
import org.eclipse.jface.viewers.Viewer;
|
19
|
|
20
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
21
|
import eu.etaxonomy.cdm.model.common.Marker;
|
22
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
23
|
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;
|
27
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
28
|
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
|
29
|
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
|
30
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
|
31
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
|
32
|
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
|
33
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
34
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
35
|
import eu.etaxonomy.taxeditor.store.TermStore;
|
36
|
|
37
|
/**
|
38
|
* The class provides the required content to the Uses View
|
39
|
* @author a.theys
|
40
|
* @created mar 13, 2012
|
41
|
* @version 1.0
|
42
|
*/
|
43
|
public class UsesContentProvider extends DescriptiveContentProvider implements ITreeContentProvider {
|
44
|
|
45
|
Set<MarkerType> markerTypes = new HashSet<MarkerType>();
|
46
|
|
47
|
/**
|
48
|
* <p>Constructor for DescriptiveContentProvider.</p>
|
49
|
*
|
50
|
* @param featureNodeContainerCache a {@link java.util.Map} object.
|
51
|
*/
|
52
|
public UsesContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {
|
53
|
super(featureNodeContainerCache);
|
54
|
this.featureNodeContainerCache = featureNodeContainerCache;
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Get all descriptions associated with the given TaxonEditorInput
|
59
|
*
|
60
|
* @param parentElement
|
61
|
* @return
|
62
|
*/
|
63
|
@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
|
}
|
82
|
return descriptions;
|
83
|
}
|
84
|
|
85
|
}
|