Merge branch 'release/3.12.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / CdmStorePropertyTester.java
index b28e46d6117141fb66e3c2da57b476b5cdf031d8..26877a9e3d6638a75959b0378fdd8dc2d8f5ba01 100644 (file)
@@ -1,12 +1,12 @@
 // $Id$
 /**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+ * Copyright (C) 2007 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
 
 package eu.etaxonomy.taxeditor.preference;
 
@@ -21,20 +21,45 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  */
 public class CdmStorePropertyTester extends PropertyTester {
 
-       private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
+    private static final String EDITOR_IS_CONNECTED_TO_DB = "isCdmStoreConnected";
+    private static final String IS_REMOTING = "isRemoting";
+    private static final String IS_STANDALONE = "isStandAlone";
+
+    @Override
+    public boolean test(Object receiver, String property, Object[] args,
+            Object expectedValue) {
+
+        if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
+            return isCdmStoreConnected();
+        }
+
+        if(IS_REMOTING.equals(property)){
+            if(!isCdmStoreConnected()) {
+                return false;
+            } else {
+                return isRemoting();
+            }
+        }
+
+        if(IS_STANDALONE.equals(property)){
+            if(!isCdmStoreConnected()) {
+                return false;
+            } else {
+                return !isRemoting();
+            }
+        }
+        return false;
+    }
+
+    private boolean isCdmStoreConnected(){
+        boolean active = CdmStore.isActive();
+        return active;
+    }
+
+    private boolean isRemoting() {
+        return CdmStore.getCurrentSessionManager().isRemoting();
 
-       @Override
-       public boolean test(Object receiver, String property, Object[] args,
-                       Object expectedValue) {
+    }
 
-           if(EDITOR_IS_CONNECTED_TO_DB.equals(property)){
-               return isCdmStoreConnected();
-           }
-               return false;
-       }
 
-       private boolean isCdmStoreConnected(){
-           boolean active = CdmStore.isActive();
-           return active;
-       }
 }