1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

[245918] Allow customization of DStore Preferences

This commit is contained in:
Martin Oberhuber 2008-09-18 17:15:26 +00:00
parent 135bdf1c79
commit 8d8b8b2a36

View file

@ -7,10 +7,10 @@
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
*
* Contributors:
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
@ -18,15 +18,19 @@
* David McKnight (IBM) - [227406] [dstore] DStoreFileService must listen to buffer size preference changes
* David McKnight (IBM) - [228334][api][breaking][dstore] Default DataStore connection timeout is too short
* David McKnight (IBM) - [233160] [dstore] SSL/non-SSL alert are not appropriate
* Martin Oberhuber (Wind River) - [245918] Allow customization of DStore Preferences
*******************************************************************************/
package org.eclipse.rse.internal.connectorservice.dstore;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.rse.connectorservice.dstore.IUniversalDStoreConstants;
import org.eclipse.rse.ui.ISystemPreferencesConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
/**
@ -36,9 +40,9 @@ public class Activator extends SystemBasePlugin {
//The shared instance.
private static Activator plugin;
public final static String PLUGIN_ID = "org.eclipse.rse.connectorservice.dstore"; //$NON-NLS-1$
/**
* The constructor.
*/
@ -49,38 +53,70 @@ public class Activator extends SystemBasePlugin {
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception
public void start(BundleContext context) throws Exception
{
super.start(context);
initializeDefaultPreferences();
}
/**
* A Preference Store that gives direct access to Default Preferences.
*/
private static class DefaultPreferenceStore extends ScopedPreferenceStore {
private IEclipsePreferences[] defaultNodes;
public DefaultPreferenceStore(String qualifier) {
super(new DefaultScope(), qualifier);
defaultNodes = new IEclipsePreferences[] {
new DefaultScope().getNode(qualifier) };
}
public boolean hasDefault(String key) {
return Platform.getPreferencesService().get(key, null, defaultNodes) != null;
}
}
public void initializeDefaultPreferences() {
IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
// [245918] Since our Preferences are stored in RSEUIPlugin, we cannot
// use the core.runtime.preferences extension in order to do
// initialization in the correct order (allow overriding by
// plugin_customization.ini). We therefore explicitly check each
// Preference slot, and only set a there isn't one set already. Note
// that requires explicit access to the DefaultScope().
// TODO move Preferences to our own PreferenceStore to simplify this
DefaultPreferenceStore store = new DefaultPreferenceStore(RSEUIPlugin.getDefault().getBundle().getSymbolicName());
//IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
//Preferences store = RSECorePlugin.getDefault().getPluginPreferences();
store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_SOCKET_TIMEOUT);
if (!store.hasDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT))
store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_SOCKET_TIMEOUT);
// do keepalive
store.setDefault(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_DO_KEEPALIVE);
// socket read timeout
store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_READ_TIMEOUT, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_SOCKET_READ_TIMEOUT);
if (!store.hasDefault(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE))
store.setDefault(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_DO_KEEPALIVE);
// socket read timeout
if (!store.hasDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_READ_TIMEOUT))
store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_READ_TIMEOUT, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_SOCKET_READ_TIMEOUT);
// keepalive response timeout
store.setDefault(IUniversalDStoreConstants.RESID_PREF_KEEPALIVE_RESPONSE_TIMEOUT, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_KEEPALIVE_RESPONSE_TIMEOUT);
if (!store.hasDefault(IUniversalDStoreConstants.RESID_PREF_KEEPALIVE_RESPONSE_TIMEOUT))
store.setDefault(IUniversalDStoreConstants.RESID_PREF_KEEPALIVE_RESPONSE_TIMEOUT,
IDStoreDefaultPreferenceConstants.DEFAULT_PREF_KEEPALIVE_RESPONSE_TIMEOUT);
// show mismatched server warning
store.setDefault(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, IDStoreDefaultPreferenceConstants.DEFAULT_ALERT_MISMATCHED_SERVER);
if (!store.hasDefault(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER))
store.setDefault(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, IDStoreDefaultPreferenceConstants.DEFAULT_ALERT_MISMATCHED_SERVER);
// cache remote classes
store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES);
if (!store.hasDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES))
store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, IDStoreDefaultPreferenceConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES);
// alert defaults
store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
if (!store.hasDefault(ISystemPreferencesConstants.ALERT_SSL))
store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
if (!store.hasDefault(ISystemPreferencesConstants.ALERT_NONSSL))
store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
}
/**
@ -103,6 +139,6 @@ public class Activator extends SystemBasePlugin {
protected void initializeImageRegistry()
{
// TODO Auto-generated method stub
}
}