import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.Feature;
import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.model.description.TaxonDescription;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.cdm.model.description.IDescribable;
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
public class DescriptiveContentProvider implements ITreeContentProvider {
protected static final Object[] NO_CHILDREN = new Object[0];
- protected Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache;
+ protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache;
/**
* <p>Constructor for DescriptiveContentProvider.</p>
*
* @param featureNodeContainerCache a {@link java.util.Map} object.
*/
- public DescriptiveContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {
+ public DescriptiveContentProvider(Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache) {
this.featureNodeContainerCache = featureNodeContainerCache;
}
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TaxonEditorInput) {
- return getDescriptions((TaxonEditorInput) parentElement).toArray();
+ if (parentElement instanceof IDescribable<?>) {
+ return getDescriptions((IDescribable<?>) parentElement).toArray();
}
- else if (parentElement instanceof TaxonDescription) {
- if ( ! ((TaxonDescription) parentElement).isImageGallery()) {
- TaxonDescription description = (TaxonDescription) parentElement;
+ else if (parentElement instanceof DescriptionBase<?>) {
+ if ( ! ((DescriptionBase<?>) parentElement).isImageGallery()) {
+ DescriptionBase<?> description = (DescriptionBase<?>) parentElement;
FeatureNodeContainerTree containerTree = getContainerTreeForDesription(description);
return NO_CHILDREN;
}
- private FeatureNodeContainerTree getContainerTreeForDesription(TaxonDescription description){
+ private FeatureNodeContainerTree getContainerTreeForDesription(DescriptionBase<?> description){
if(! featureNodeContainerCache.containsKey(description)){
FeatureNodeContainerTree containerTree = new FeatureNodeContainerTree(description, getFeatureTree(description));
featureNodeContainerCache.put(description, containerTree);
/** {@inheritDoc} */
@Override
public boolean hasChildren(Object element) {
- if (element instanceof TaxonDescription){
- TaxonDescription description = (TaxonDescription) element;
+ if (element instanceof DescriptionBase<?>){
+ DescriptionBase<?> description = (DescriptionBase<?>) element;
FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);
if(containerTree != null && containerTree.getRoot() != null){
return containerTree.getRoot().getChildren().size() != 0;
* @param parentElement
* @return
*/
- protected List<DescriptionBase> getDescriptions(TaxonEditorInput parentElement) {
- Taxon taxon = parentElement.getTaxon();
- List<DescriptionBase> descriptions = new ArrayList<DescriptionBase>();
- for(DescriptionBase description : taxon.getDescriptions()){
+ protected List<DescriptionBase> getDescriptions(IDescribable<?> parentElement) {
+ Set<? extends DescriptionBase<?>> elementDescriptions = parentElement.getDescriptions();
+ List<DescriptionBase> resultDescriptions = new ArrayList<DescriptionBase>();
+ for(DescriptionBase description : elementDescriptions){
if(! description.isImageGallery()){
MarkerType useMarkertype = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
Set<Marker> descriptionMarkers = description.getMarkers();
if(descriptionMarkers != null && !descriptionMarkers.isEmpty()) {
for (Marker marker: descriptionMarkers) {
if(!(marker.getMarkerType().equals(useMarkertype))) {
- descriptions.add(description);
+ resultDescriptions.add(description);
}
}
}
else {
- descriptions.add(description);
+ resultDescriptions.add(description);
}
}
}
- return descriptions;
+ return resultDescriptions;
}
/* (non-Javadoc)