]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 /*******************************************************************************\r
2  * Copyright (c) 2016 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     THTH ry - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.debug.browser.ui;\r
13 \r
14 import org.eclipse.core.expressions.PropertyTester;\r
15 import org.eclipse.core.runtime.Platform;\r
16 \r
17 /**\r
18  * @author Tuukka Lehtonen / Semantum Oy\r
19  */\r
20 public class PlatformPropertyTester extends PropertyTester {\r
21 \r
22     private static final String PROPERTY_IN_DEVELOPMENT_MODE = "inDevelopmentMode"; //$NON-NLS-1$\r
23 \r
24     @Override\r
25     public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {\r
26         if (PROPERTY_IN_DEVELOPMENT_MODE.equals(property)) {\r
27             return parseBoolean(expectedValue, true) == Platform.inDevelopmentMode();\r
28         }\r
29         return false;\r
30     }\r
31 \r
32     private boolean parseBoolean(Object value, boolean defaultValue) {\r
33         if (value instanceof Boolean) return (Boolean) value;\r
34         if (value instanceof String) return Boolean.parseBoolean((String) value);\r
35         return defaultValue;\r
36     }\r
37 \r
38 }\r