--- /dev/null
+/**
+* Copyright (C) 2019 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.view.descriptive;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+
+/**
+ * @author k.luther
+ * @since 09.04.2019
+ *
+ */
+public class NameDescriptionFilter extends ViewerFilter {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof FeatureNodeContainer ){
+ FeatureNodeContainer desc = (FeatureNodeContainer)element;
+ if(!desc.getFeature().equals(Feature.PROTOLOGUE())){
+ return true;
+ }
+ }
+ if (element instanceof DescriptionBase){
+ for (Object desc:((DescriptionBase) element).getElements()){
+ if (desc instanceof DescriptionElementBase){
+ if (!((DescriptionElementBase)desc).getFeature().equals(Feature.PROTOLOGUE())){
+ return true;
+ }
+ }
+ }
+ if (((DescriptionBase) element).getElements().isEmpty()){
+ return true;
+ }
+ }
+ if (element instanceof DescriptionElementBase){
+ if (!((DescriptionElementBase)element).getFeature().equals(Feature.PROTOLOGUE())){
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveLabelProvider;
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.NameDescriptionFilter;
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
treeViewer.setContentProvider(provider);
treeViewer.setLabelProvider(new DescriptiveLabelProvider());
treeViewer.setSorter(new DescriptiveViewerSorter());
+ treeViewer.setFilters(new NameDescriptionFilter());
treeViewer.setAutoExpandLevel(2);
Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
viewer.addSelectionChangedListener(selectionChangedListener);
DescriptionElementDropAdapter dropListener = new DescriptionElementDropAdapter(viewer);
ContextInjectionFactory.inject(dropListener, context);
+
treeViewer.addDropSupport(dndOperations, transfers,
dropListener);
//create context menu
featureTree = TermEditorInput.getDefaultFeatureTree();
}
if (description instanceof TaxonNameDescription){
- featureTree = FeatureTree.NewInstance(CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid())));
+ List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()));
+ terms.remove(Feature.PROTOLOGUE());
+ featureTree = FeatureTree.NewInstance(terms);
}
return featureTree;