]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.browser.ui/src/org/simantics/debug/browser/ui/PlatformPropertyTester.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.debug.browser.ui / src / org / simantics / debug / browser / ui / PlatformPropertyTester.java
diff --git a/bundles/org.simantics.debug.browser.ui/src/org/simantics/debug/browser/ui/PlatformPropertyTester.java b/bundles/org.simantics.debug.browser.ui/src/org/simantics/debug/browser/ui/PlatformPropertyTester.java
new file mode 100644 (file)
index 0000000..c5e49f2
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************\r
+ * Copyright (c) 2016 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     THTH ry - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.debug.browser.ui;\r
+\r
+import org.eclipse.core.expressions.PropertyTester;\r
+import org.eclipse.core.runtime.Platform;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen / Semantum Oy\r
+ */\r
+public class PlatformPropertyTester extends PropertyTester {\r
+\r
+    private static final String PROPERTY_IN_DEVELOPMENT_MODE = "inDevelopmentMode"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {\r
+        if (PROPERTY_IN_DEVELOPMENT_MODE.equals(property)) {\r
+            return parseBoolean(expectedValue, true) == Platform.inDevelopmentMode();\r
+        }\r
+        return false;\r
+    }\r
+\r
+    private boolean parseBoolean(Object value, boolean defaultValue) {\r
+        if (value instanceof Boolean) return (Boolean) value;\r
+        if (value instanceof String) return Boolean.parseBoolean((String) value);\r
+        return defaultValue;\r
+    }\r
+\r
+}\r