X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.workbench%2Fsrc%2Forg%2Fsimantics%2Fworkbench%2Finternal%2Fpreferences%2FSimanticsPreferenceInitializer.java;fp=bundles%2Forg.simantics.workbench%2Fsrc%2Forg%2Fsimantics%2Fworkbench%2Finternal%2Fpreferences%2FSimanticsPreferenceInitializer.java;h=a2bacee626635da9993890dc28bc525d459af9a1;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..a2bacee62 --- /dev/null +++ b/bundles/org.simantics.workbench/src/org/simantics/workbench/internal/preferences/SimanticsPreferenceInitializer.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.workbench.internal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IScopeContext; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.osgi.service.prefs.Preferences; +import org.simantics.workbench.internal.Activator; + +/** + * @author Tuukka Lehtonen + */ +public class SimanticsPreferenceInitializer extends AbstractPreferenceInitializer { + + @Override + public void initializeDefaultPreferences() { + IScopeContext defaults = DefaultScope.INSTANCE; + Preferences node = defaults.getNode(Activator.PLUGIN_ID); + node.putBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false); + + IScopeContext instance = InstanceScope.INSTANCE; + node = instance.getNode(Activator.PLUGIN_ID); + boolean show = node.getBoolean(SimanticsPreferences.SHOW_DATABASE_CONTROLS, false); + if (show) + System.setProperty(bind(Activator.PLUGIN_ID, SimanticsPreferences.SHOW_DATABASE_CONTROLS), "true"); + + // NOTE: the above system property are used in plugin.xml with + // systemTest in menu contribution visibility checking. + // This implementation requires a restart every time the preference is changed. + } + + private static String bind(String namespace, String pref) { + return namespace + "." + pref; + } + +}