4 package eu
.etaxonomy
.taxeditor
.editor
.view
.derivate
;
6 import org
.eclipse
.core
.expressions
.PropertyTester
;
7 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
9 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
12 * Property tester used by the DerivateView tree menu.
15 public class DerivateMenuPropertyTester
extends PropertyTester
{
17 private static final String IS_SPECIMEN_OR_OBSERVATION
= "isSpecimenOrObservation";
20 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
24 public boolean test(Object receiver
, String property
, Object
[] args
, Object expectedValue
) {
25 //TODO: these simple instanceof-checks can be unified in one class because there are several
26 // PropertyTesters that do the same, that is just checking which class the selection is of
28 Object
[] selectedElements
= ((IStructuredSelection
) receiver
).toArray();
30 if(selectedElements
.length
== 0){
31 // nothing selected so all tests should fail
35 if(IS_SPECIMEN_OR_OBSERVATION
.equals(property
)){
36 return isSpecimenOrObservation(selectedElements
);
43 private boolean isSpecimenOrObservation(Object
[] selectedElements
) {
44 for (Object object
: selectedElements
){
45 if(!(object
instanceof SpecimenOrObservationBase
)){