Project

General

Profile

« Previous | Next » 

Revision 68d759c3

Added by Katja Luther over 3 years ago

ref #8124: remaining issues for name facts (protologue filter)

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/NameDescriptionFilter.java
1
/**
2
* Copyright (C) 2019 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.descriptive;
10

  
11
import org.eclipse.jface.viewers.Viewer;
12
import org.eclipse.jface.viewers.ViewerFilter;
13

  
14
import eu.etaxonomy.cdm.model.description.DescriptionBase;
15
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
18

  
19
/**
20
 * @author k.luther
21
 * @since 09.04.2019
22
 *
23
 */
24
public class NameDescriptionFilter extends ViewerFilter {
25

  
26
    /**
27
     * {@inheritDoc}
28
     */
29
    @Override
30
    public boolean select(Viewer viewer, Object parentElement, Object element) {
31
        if (element instanceof FeatureNodeContainer ){
32
            FeatureNodeContainer desc = (FeatureNodeContainer)element;
33
            if(!desc.getFeature().equals(Feature.PROTOLOGUE())){
34
                return true;
35
            }
36
        }
37
        if (element instanceof DescriptionBase){
38
            for (Object desc:((DescriptionBase) element).getElements()){
39
                if (desc instanceof DescriptionElementBase){
40
                    if (!((DescriptionElementBase)desc).getFeature().equals(Feature.PROTOLOGUE())){
41
                        return true;
42
                    }
43
                }
44
            }
45
            if (((DescriptionBase) element).getElements().isEmpty()){
46
                return true;
47
            }
48
        }
49
        if (element instanceof DescriptionElementBase){
50
            if (!((DescriptionElementBase)element).getFeature().equals(Feature.PROTOLOGUE())){
51
                return true;
52
            }
53
        }
54
        return false;
55
    }
56

  
57
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
51 51
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
52 52
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveLabelProvider;
53 53
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;
54
import eu.etaxonomy.taxeditor.editor.view.descriptive.NameDescriptionFilter;
54 55
import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
55 56
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
56 57
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
......
96 97
        treeViewer.setContentProvider(provider);
97 98
        treeViewer.setLabelProvider(new DescriptiveLabelProvider());
98 99
        treeViewer.setSorter(new DescriptiveViewerSorter());
100
        treeViewer.setFilters(new NameDescriptionFilter());
99 101
        treeViewer.setAutoExpandLevel(2);
100 102
        Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
101 103
        treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
......
109 111
        viewer.addSelectionChangedListener(selectionChangedListener);
110 112
        DescriptionElementDropAdapter dropListener = new DescriptionElementDropAdapter(viewer);
111 113
        ContextInjectionFactory.inject(dropListener, context);
114

  
112 115
        treeViewer.addDropSupport(dndOperations, transfers,
113 116
                dropListener);
114 117
        //create context menu
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenuE4.java
140 140
			featureTree = TermEditorInput.getDefaultFeatureTree();
141 141
		}
142 142
		if (description instanceof TaxonNameDescription){
143
		    featureTree = FeatureTree.NewInstance(CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid())));
143
		    List<Feature> terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()));
144
		    terms.remove(Feature.PROTOLOGUE());
145
		    featureTree = FeatureTree.NewInstance(terms);
144 146
		}
145 147

  
146 148
		return featureTree;

Also available in: Unified diff