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
.molecular
.Amplification
;
10 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
11 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
14 * Property tester used by the DerivateView tree menu.
17 public class DerivateMenuPropertyTester
extends PropertyTester
{
19 private static final String IS_SPECIMEN_OR_OBSERVATION
= "isSpecimenOrObservation";
22 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
26 public boolean test(Object receiver
, String property
, Object
[] args
, Object expectedValue
) {
27 //TODO: these simple instanceof-checks can be unified in one class because there are several
28 // PropertyTesters that do the same, that is just checking which class the selection is of
30 Object
[] selectedElements
= ((IStructuredSelection
) receiver
).toArray();
32 if(selectedElements
.length
== 0){
33 // nothing selected so all tests should fail
37 if(IS_SPECIMEN_OR_OBSERVATION
.equals(property
)){
38 return isSpecimenOrObservation(selectedElements
);
45 private boolean isSpecimenOrObservation(Object
[] selectedElements
) {
46 for (Object object
: selectedElements
){
47 if(!(object
instanceof SpecimenOrObservationBase
|| object
instanceof Amplification
|| object
instanceof Sequence
)){