Revision 93aa41ab
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodePropertyTester.java | ||
---|---|---|
7 | 7 |
*/ |
8 | 8 |
package eu.etaxonomy.taxeditor.navigation.navigator; |
9 | 9 |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Collection; |
|
12 |
|
|
10 | 13 |
import org.eclipse.core.expressions.PropertyTester; |
11 | 14 |
|
12 | 15 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
... | ... | |
16 | 19 |
|
17 | 20 |
private static final Object HAS_SYNONYMS = "hasSynonyms"; //$NON-NLS-1$ |
18 | 21 |
private static final Object HAS_TAXA = "hasTaxa"; //$NON-NLS-1$ |
22 |
private static final Object IS_CLASSIFICATION = "isClassification"; //$NON-NLS-1$ |
|
19 | 23 |
|
20 | 24 |
/** {@inheritDoc} */ |
21 | 25 |
public boolean test(Object receiver, String property, Object[] args, |
22 | 26 |
Object expectedValue) { |
27 |
if (receiver instanceof Collection){ |
|
28 |
if (((Collection)receiver).iterator().hasNext()){ |
|
29 |
receiver = ((Collection)receiver).iterator().next(); |
|
30 |
} |
|
31 |
} |
|
23 | 32 |
if (receiver instanceof TaxonNode && HAS_SYNONYMS.equals(property)) { |
24 | 33 |
Taxon taxon = ((TaxonNode) receiver).getTaxon(); |
25 | 34 |
if(taxon != null){ |
... | ... | |
27 | 36 |
} |
28 | 37 |
} |
29 | 38 |
|
30 |
if (receiver instanceof Classification && HAS_TAXA.equals(property)) { |
|
31 |
Classification taxononomicTree = (Classification) receiver; |
|
32 |
return taxononomicTree.getChildNodes().size() > 0; |
|
39 |
if (receiver instanceof TaxonNode && HAS_TAXA.equals(property)) { |
|
40 |
TaxonNode node = (TaxonNode) receiver; |
|
41 |
if (!node.hasTaxon()){ |
|
42 |
return node.getChildNodes().size() > 0; |
|
43 |
}else{ |
|
44 |
return false; |
|
45 |
} |
|
46 |
} |
|
47 |
if (receiver instanceof TaxonNode && IS_CLASSIFICATION.equals(property)) { |
|
48 |
TaxonNode node = (TaxonNode) receiver; |
|
49 |
return !node.hasTaxon(); |
|
33 | 50 |
} |
34 | 51 |
|
35 | 52 |
return false; |
Also available in: Unified diff
adapt propertyTester to navigator changes