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