/**
- *
+ *
*/
package eu.etaxonomy.taxeditor.editor.view.descriptive;
* @version $Id: $
*/
public class DescriptiveContentProvider implements ITreeContentProvider {
-
+
protected static final Object[] NO_CHILDREN = new Object[0];
protected Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache;
-
+
/**
* <p>Constructor for DescriptiveContentProvider.</p>
*
public DescriptiveContentProvider(Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache) {
this.featureNodeContainerCache = featureNodeContainerCache;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
/** {@inheritDoc} */
- public Object[] getChildren(Object parentElement) {
+ @Override
+ public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TaxonEditorInput) {
- return getDescriptions((TaxonEditorInput) parentElement).toArray();
+ return getDescriptions((TaxonEditorInput) parentElement).toArray();
}
else if (parentElement instanceof TaxonDescription) {
if ( ! ((TaxonDescription) parentElement).isImageGallery()) {
TaxonDescription description = (TaxonDescription) parentElement;
-
+
FeatureNodeContainerTree containerTree = getContainerTreeForDesription(description);
-
+
return containerTree.getRoot().getChildren().toArray();
}
}
return container.getChildren().toArray();
}
}
-
+
return NO_CHILDREN;
}
-
+
private FeatureNodeContainerTree getContainerTreeForDesription(TaxonDescription description){
if(! featureNodeContainerCache.containsKey(description)){
FeatureNodeContainerTree containerTree = new FeatureNodeContainerTree(description, getFeatureTree(description));
if(containerTree != null && containerTree.getRoot() != null){
return containerTree.getRoot().getChildren().size() != 0;
}
- }
+ }
return getChildren(element).length != 0;
}
-
+
/**
* Retrieves the feature tree associated with the given description
- *
- * TODO as of now this is always the same thing because feature trees may not be associated
+ *
+ * TODO as of now this is always the same thing because feature trees may not be associated
* to descriptions yet.
- *
+ *
* @param description
* @return
*/
private FeatureTree getFeatureTree(DescriptionBase description){
FeatureTree featureTree = null;
-
+
// TODO change this to the feature tree associated with this taxon description
- if (description.hasStructuredData()){
+ if (description.hasStructuredData()){
featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();
}else{
featureTree = PreferencesUtil.getDefaultFeatureTreeForTextualDescription();
}
-
+
// create a transient tree with all features if none was selected
if(featureTree == null){
featureTree = FeatureTree.NewInstance(TermStore.getTerms(Feature.class));
}
-
+
return featureTree;
}
/**
* Get all descriptions associated with the given TaxonEditorInput
- *
+ *
* @param parentElement
* @return
*/
descriptions.add(description);
}
}
-
- }
+
+ }
return descriptions;
}
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
/** {@inheritDoc} */
- public Object getParent(Object element) {
+ @Override
+ public Object getParent(Object element) {
return null;
}
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
/** {@inheritDoc} */
- public Object[] getElements(Object inputElement) {
+ @Override
+ public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
/**
* <p>dispose</p>
*/
- public void dispose() {
+ @Override
+ public void dispose() {
featureNodeContainerCache.clear();
}
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
/** {@inheritDoc} */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
-
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+
}