]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/preferences/SimanticsPreferenceInitializer.java b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/preferences/SimanticsPreferenceInitializer.java
new file mode 100644 (file)
index 0000000..a2bacee
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * 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
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.workbench.internal.preferences;\r
+\r
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;\r
+import org.eclipse.core.runtime.preferences.DefaultScope;\r
+import org.eclipse.core.runtime.preferences.IScopeContext;\r
+import org.eclipse.core.runtime.preferences.InstanceScope;\r
+import org.osgi.service.prefs.Preferences;\r
+import org.simantics.workbench.internal.Activator;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class SimanticsPreferenceInitializer extends AbstractPreferenceInitializer {\r
+\r
+    @Override\r
+    public void initializeDefaultPreferences() {\r
+        IScopeContext defaults = DefaultScope.INSTANCE;\r
+        Preferences node = defaults.getNode(Activator.PLUGIN_ID);\r
+        node.putBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false);\r
+\r
+        IScopeContext instance = InstanceScope.INSTANCE;\r
+        node = instance.getNode(Activator.PLUGIN_ID);\r
+        boolean show = node.getBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false);\r
+        if (show)\r
+            System.setProperty(bind(Activator.PLUGIN_ID, SimanticsPreferences.SHOW_DATABASE_CONTROLS), "true");\r
+\r
+        // NOTE: the above system property are used in plugin.xml with\r
+        // systemTest in menu contribution visibility checking.\r
+        // This implementation requires a restart every time the preference is changed.\r
+    }\r
+\r
+    private static String bind(String namespace, String pref) {\r
+        return namespace + "." + pref;\r
+    }\r
+\r
+}\r