merge-update from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / command / BulkEditorMenuPropertyTester.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.bulkeditor.command;
11
12 import org.eclipse.core.expressions.PropertyTester;
13 import org.eclipse.jface.viewers.IStructuredSelection;
14
15 import eu.etaxonomy.cdm.model.agent.Person;
16 import eu.etaxonomy.cdm.model.agent.Team;
17
18 /**
19 * @author k.luther
20 * @date 13.05.2015
21 *
22 */
23 public class BulkEditorMenuPropertyTester extends PropertyTester {
24
25
26 private static final String IS_TEAM = "isTeam";
27 private static final String IS_PERSON = "isPerson";
28
29 public BulkEditorMenuPropertyTester(){
30 }
31 /**
32 * {@inheritDoc}
33 */
34 @Override
35 public boolean test(Object receiver, String property, Object[] args,
36 Object expectedValue) {
37 if(receiver instanceof IStructuredSelection){
38 IStructuredSelection selection = (IStructuredSelection) receiver;
39 Object selectedElement = selection.getFirstElement();
40 if (property.equals(IS_PERSON) && selectedElement instanceof Person){
41 return true;
42 }
43 if (property.equals(IS_TEAM) && selectedElement instanceof Team){
44 return true;
45 }
46 return false;
47
48 }
49 return false;
50 }
51
52 }