4 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
;
6 import java
.util
.Arrays
;
8 import org
.eclipse
.core
.expressions
.PropertyTester
;
9 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
11 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
12 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
15 * Property tester used by the DerivateView tree menu.
18 public class DerivateMenuPropertyTester
extends PropertyTester
{
20 private static final String IS_FIELD_UNIT
= "isFieldUnit";
21 private static final String IS_SPECIMEN
= "isSpecimen";
24 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
28 public boolean test(Object receiver
, String property
, Object
[] args
, Object expectedValue
) {
29 System
.out
.println(receiver
.toString() + receiver
.getClass().toString());
30 System
.out
.println(property
);
31 System
.out
.println(Arrays
.asList(args
));
32 System
.out
.println(expectedValue
);
34 Object
[] selectedElements
= ((IStructuredSelection
) receiver
).toArray();
36 if(selectedElements
.length
== 0){
37 // nothing selected so all tests should fail
41 if(IS_FIELD_UNIT
.equals(property
)){
42 return isFieldUnit(selectedElements
);
44 else if(IS_SPECIMEN
.equals(property
)){
45 return isSpecimen(selectedElements
);
52 private boolean isFieldUnit(Object
[] selectedElements
) {
53 for (Object object
: selectedElements
){
54 if(!(object
instanceof FieldUnit
)){
61 private boolean isSpecimen(Object
[] selectedElements
) {
62 for (Object object
: selectedElements
){
63 if(!(object
instanceof DerivedUnit
)){