1
|
/**
|
2
|
* Copyright (C) 2007 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.preference;
|
10
|
|
11
|
import org.eclipse.core.expressions.PropertyTester;
|
12
|
|
13
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
14
|
|
15
|
/**
|
16
|
* @author n.hoffmann
|
17
|
* @created Jan 26, 2011
|
18
|
*/
|
19
|
public class CdmStorePropertyTester extends PropertyTester {
|
20
|
|
21
|
private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
|
22
|
private static final String IS_REMOTING = "isRemoting";
|
23
|
private static final String IS_CONNECTED_AND_NOT_LOCAL_ACTIVATED = "isCdmStoreConnectedAndNotLocalActivated";
|
24
|
private static final String IS_CONNECTED_AND_LOCAL_ACTIVATED = "isCdmStoreConnectedAndLocalActive";
|
25
|
|
26
|
@Override
|
27
|
public boolean test(Object receiver, String property, Object[] args,
|
28
|
Object expectedValue) {
|
29
|
|
30
|
if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
|
31
|
return isCdmStoreConnected();
|
32
|
}
|
33
|
|
34
|
if(IS_REMOTING.equals(property)){
|
35
|
if(!isCdmStoreConnected()) {
|
36
|
return false;
|
37
|
} else {
|
38
|
return true;
|
39
|
}
|
40
|
}
|
41
|
|
42
|
if(IS_CONNECTED_AND_NOT_LOCAL_ACTIVATED.equals(property)){
|
43
|
return isCdmStoreConnectedAndNotLocalActive();
|
44
|
}
|
45
|
if(IS_CONNECTED_AND_LOCAL_ACTIVATED.equals(property)){
|
46
|
return isCdmStoreConnectedAndLocalActive();
|
47
|
}
|
48
|
return false;
|
49
|
}
|
50
|
|
51
|
private boolean isCdmStoreConnected(){
|
52
|
boolean active = CdmStore.isActive();
|
53
|
return active;
|
54
|
}
|
55
|
|
56
|
private boolean isCdmStoreConnectedAndNotLocalActive(){
|
57
|
boolean active = CdmStore.isActive();
|
58
|
active = active & !PreferencesUtil.getLocalActive();
|
59
|
return active;
|
60
|
}
|
61
|
private boolean isCdmStoreConnectedAndLocalActive(){
|
62
|
boolean active = CdmStore.isActive();
|
63
|
active = active & PreferencesUtil.getLocalActive();
|
64
|
return active;
|
65
|
}
|
66
|
}
|