ref #7699: wait for the thread to stop
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / command / BulkEditorMenuPropertyTester.java
1 /**
2 * Copyright (C) 2015 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.bulkeditor.command;
10
11 import org.eclipse.core.expressions.PropertyTester;
12 import org.eclipse.jface.viewers.IStructuredSelection;
13
14 import eu.etaxonomy.cdm.model.agent.Person;
15 import eu.etaxonomy.cdm.model.agent.Team;
16
17 /**
18 * @author k.luther
19 * @date 13.05.2015
20 *
21 */
22 public class BulkEditorMenuPropertyTester extends PropertyTester {
23
24
25 private static final String IS_TEAM = "isTeam";
26 private static final String IS_PERSON = "isPerson";
27 private static final String IS_TEAM_OR_PERSON = "isTeamOrPerson";
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_TEAM_OR_PERSON) && (selectedElement instanceof Team || selectedElement instanceof Person)){
41 return true;
42 }
43 if (property.equals(IS_PERSON) && selectedElement instanceof Person){
44 return true;
45 }
46 if (property.equals(IS_TEAM) && selectedElement instanceof Team){
47 return true;
48 }
49 return false;
50
51 }
52 return false;
53 }
54
55 }