Project

General

Profile

Download (1.28 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.editor.key.polytomous;
10

    
11
import org.eclipse.core.expressions.PropertyTester;
12
import org.eclipse.jface.viewers.IStructuredSelection;
13

    
14
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
15

    
16
/**
17
 * @author k.luther
18
 * @date 23.11.2016
19
 *
20
 */
21
public class PolytomousKeyPropertyTester extends PropertyTester {
22
    private static final String KEYNODE = "isKeyNode"; //$NON-NLS-1$
23

    
24
    /**
25
     * {@inheritDoc}
26
     */
27
    @Override
28
    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
29
        if(receiver instanceof IStructuredSelection){
30

    
31
            IStructuredSelection selection = (IStructuredSelection) receiver;
32

    
33
            Object selectedElement = selection.getFirstElement();
34
            if(KEYNODE.equals(property)){
35
                return isKeyNode(selectedElement);
36
            }
37
        }
38
        return false;
39
    }
40

    
41
    private boolean isKeyNode(Object selectedElement) {
42
        return (selectedElement instanceof PolytomousKeyNode) ? true : false;
43
    }
44

    
45

    
46
}
(11-11/11)