2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
;
11 import org
.eclipse
.core
.expressions
.PropertyTester
;
12 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
21 public class PolytomousKeyPropertyTester
extends PropertyTester
{
22 private static final String KEYNODE
= "isKeyNode";
28 public boolean test(Object receiver
, String property
, Object
[] args
, Object expectedValue
) {
29 if(receiver
instanceof IStructuredSelection
){
31 IStructuredSelection selection
= (IStructuredSelection
) receiver
;
33 Object selectedElement
= selection
.getFirstElement();
34 if(KEYNODE
.equals(property
)){
35 return isKeyNode(selectedElement
);
41 private boolean isKeyNode(Object selectedElement
) {
42 return (selectedElement
instanceof PolytomousKeyNode
) ?
true : false;