Project

General

Profile

Download (1.61 KB) Statistics
| Branch: | Tag: | Revision:
1 0f0c1e8c Patric Plitzner
// $Id$
2
/**
3 6c610cc5 Cherian Mathew
 * Copyright (C) 2007 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 0f0c1e8c Patric Plitzner
11
package eu.etaxonomy.taxeditor.preference;
12
13
import org.eclipse.core.expressions.PropertyTester;
14
15
import eu.etaxonomy.taxeditor.store.CdmStore;
16
17
/**
18
 * @author n.hoffmann
19
 * @created Jan 26, 2011
20
 * @version 1.0
21
 */
22
public class CdmStorePropertyTester extends PropertyTester {
23
24 6c610cc5 Cherian Mathew
    private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
25
    private static final String IS_REMOTING = "isRemoting";
26 323a4942 Cherian Mathew
    private static final String IS_STANDALONE = "isStandAlone";
27 6c610cc5 Cherian Mathew
28
    @Override
29
    public boolean test(Object receiver, String property, Object[] args,
30
            Object expectedValue) {
31
32
        if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
33
            return isCdmStoreConnected();
34
        }
35
36
        if(IS_REMOTING.equals(property)){
37 323a4942 Cherian Mathew
            if(!isCdmStoreConnected()) {
38
                return false;
39
            } else {
40
                return isRemoting();
41
            }
42
        }
43
44
        if(IS_STANDALONE.equals(property)){
45
            if(!isCdmStoreConnected()) {
46
                return false;
47
            } else {
48
                return !isRemoting();
49
            }
50 6c610cc5 Cherian Mathew
        }
51
        return false;
52
    }
53
54
    private boolean isCdmStoreConnected(){
55
        boolean active = CdmStore.isActive();
56
        return active;
57
    }
58 0f0c1e8c Patric Plitzner
59 6c610cc5 Cherian Mathew
    private boolean isRemoting() {
60
        return CdmStore.getCurrentSessionManager().isRemoting();
61 323a4942 Cherian Mathew
62 6c610cc5 Cherian Mathew
    }
63 0f0c1e8c Patric Plitzner
64
65
}