1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.workbench.internal.preferences;
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;
22 * @author Tuukka Lehtonen
24 public class SimanticsPreferenceInitializer extends AbstractPreferenceInitializer {
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);
32 IScopeContext instance = InstanceScope.INSTANCE;
33 node = instance.getNode(Activator.PLUGIN_ID);
34 boolean show = node.getBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false);
36 System.setProperty(bind(Activator.PLUGIN_ID, SimanticsPreferences.SHOW_DATABASE_CONTROLS), "true");
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.
43 private static String bind(String namespace, String pref) {
44 return namespace + "." + pref;