Adjustments to recent changes in LibrAlign.
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / PreferencePropertyTester.java
1 // $Id$
2 /**
3 * 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
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 PreferencePropertyTester extends PropertyTester {
23
24
25 private static final String SHOW_EXPERIMENTAL_FEATURES = "isShowExperimentalFeatures";
26
27 private static final String SHOW_CHECKLIST_EDITOR = "isChecklistEditorEnabled";
28
29 private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
30
31 /* (non-Javadoc)
32 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
33 */
34 @Override
35 public boolean test(Object receiver, String property, Object[] args,
36 Object expectedValue) {
37
38 if(SHOW_EXPERIMENTAL_FEATURES.equals(property)){
39 return isShowExperimentalFeatures();
40 }
41 if(SHOW_CHECKLIST_EDITOR.equals(property)){
42 return isChecklistEditorEnabled();
43 }
44 if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
45 return isCdmStoreConnected();
46 }
47
48 return false;
49 }
50
51 /**
52 * @return
53 */
54 private boolean isShowExperimentalFeatures() {
55 return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES);
56 }
57
58 private boolean isChecklistEditorEnabled() {
59 return PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE);
60 }
61
62 private boolean isCdmStoreConnected(){
63 boolean active = CdmStore.isActive();
64 return active;
65 }
66 }