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 descEl:((DescriptionBase) element).getElements()){
|
39
|
if (descEl instanceof DescriptionElementBase){
|
40
|
if (! Feature.PROTOLOGUE().equals(((DescriptionElementBase)descEl).getFeature())){
|
41
|
return true;
|
42
|
}
|
43
|
}
|
44
|
}
|
45
|
if (((DescriptionBase) element).getElements().isEmpty()){
|
46
|
return true;
|
47
|
}
|
48
|
}
|
49
|
if (element instanceof DescriptionElementBase){
|
50
|
if (! Feature.PROTOLOGUE().equals(((DescriptionElementBase)element).getFeature())){
|
51
|
return true;
|
52
|
}
|
53
|
}
|
54
|
return false;
|
55
|
}
|
56
|
|
57
|
}
|