]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.workbench/src/org/simantics/workbench/internal/preferences/SimanticsPreferenceInitializer.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.workbench / src / org / simantics / workbench / internal / preferences / SimanticsPreferenceInitializer.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
3  * 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  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.workbench.internal.preferences;\r
13 \r
14 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\r
15 import org.eclipse.core.runtime.preferences.DefaultScope;\r
16 import org.eclipse.core.runtime.preferences.IScopeContext;\r
17 import org.eclipse.core.runtime.preferences.InstanceScope;\r
18 import org.osgi.service.prefs.Preferences;\r
19 import org.simantics.workbench.internal.Activator;\r
20 \r
21 /**\r
22  * @author Tuukka Lehtonen\r
23  */\r
24 public class SimanticsPreferenceInitializer extends AbstractPreferenceInitializer {\r
25 \r
26     @Override\r
27     public void initializeDefaultPreferences() {\r
28         IScopeContext defaults = DefaultScope.INSTANCE;\r
29         Preferences node = defaults.getNode(Activator.PLUGIN_ID);\r
30         node.putBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false);\r
31 \r
32         IScopeContext instance = InstanceScope.INSTANCE;\r
33         node = instance.getNode(Activator.PLUGIN_ID);\r
34         boolean show = node.getBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false);\r
35         if (show)\r
36             System.setProperty(bind(Activator.PLUGIN_ID, SimanticsPreferences.SHOW_DATABASE_CONTROLS), "true");\r
37 \r
38         // NOTE: the above system property are used in plugin.xml with\r
39         // systemTest in menu contribution visibility checking.\r
40         // This implementation requires a restart every time the preference is changed.\r
41     }\r
42 \r
43     private static String bind(String namespace, String pref) {\r
44         return namespace + "." + pref;\r
45     }\r
46 \r
47 }\r