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