Project

General

Profile

Download (2.45 KB) Statistics
| Branch: | Tag: | Revision:
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

    
10
package eu.etaxonomy.taxeditor.preference;
11

    
12
import org.eclipse.core.expressions.PropertyTester;
13

    
14
import eu.etaxonomy.taxeditor.store.CdmStore;
15

    
16
/**
17
 * @author n.hoffmann
18
 * @created Jan 26, 2011
19
 * @version 1.0
20
 */
21
public class CdmStorePropertyTester extends PropertyTester {
22

    
23
    private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
24
    private static final String IS_REMOTING = "isRemoting";
25
    private static final String IS_STANDALONE = "isStandAlone";
26
    private static final String IS_CONNECTED_AND_NOT_LOCAL_ACTIVATED = "isCdmStoreConnectedAndNotLocalActivated";
27
    private static final String IS_CONNECTED_AND_LOCAL_ACTIVATED = "isCdmStoreConnectedAndLocalActive";
28

    
29
    @Override
30
    public boolean test(Object receiver, String property, Object[] args,
31
            Object expectedValue) {
32

    
33
        if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
34
            return isCdmStoreConnected();
35
        }
36

    
37
        if(IS_REMOTING.equals(property)){
38
            if(!isCdmStoreConnected()) {
39
                return false;
40
            } else {
41
                return isRemoting();
42
            }
43
        }
44

    
45
        if(IS_STANDALONE.equals(property)){
46
            if(!isCdmStoreConnected()) {
47
                return false;
48
            } else {
49
                return !isRemoting();
50
            }
51
        }
52
        if(IS_CONNECTED_AND_NOT_LOCAL_ACTIVATED.equals(property)){
53
            return isCdmStoreConnectedAndNotLocalActive();
54
        }
55
        if(IS_CONNECTED_AND_LOCAL_ACTIVATED.equals(property)){
56
            return isCdmStoreConnectedAndLocalActive();
57
        }
58
        return false;
59
    }
60

    
61
    private boolean isCdmStoreConnected(){
62
        boolean active = CdmStore.isActive();
63
        return active;
64
    }
65

    
66
    private boolean isCdmStoreConnectedAndNotLocalActive(){
67
        boolean active = CdmStore.isActive();
68
        active = active & !PreferencesUtil.getLocalActive();
69
        return active;
70
    }
71
    private boolean isCdmStoreConnectedAndLocalActive(){
72
        boolean active = CdmStore.isActive();
73
        active = active & PreferencesUtil.getLocalActive();
74
        return active;
75
    }
76

    
77
    private boolean isRemoting() {
78
        return CdmStore.getCurrentSessionManager().isRemoting();
79
    }
80
}
(7-7/62)