Project

General

Profile

Download (1.6 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

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

    
31
        if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
32
            return isCdmStoreConnected();
33
        }
34

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

    
43
        if(IS_STANDALONE.equals(property)){
44
            if(!isCdmStoreConnected()) {
45
                return false;
46
            } else {
47
                return !isRemoting();
48
            }
49
        }
50
        return false;
51
    }
52

    
53
    private boolean isCdmStoreConnected(){
54
        boolean active = CdmStore.isActive();
55
        return active;
56
    }
57

    
58
    private boolean isRemoting() {
59
        return CdmStore.getCurrentSessionManager().isRemoting();
60

    
61
    }
62

    
63

    
64
}
(4-4/27)