From c86b807ab098388415c00301b2168dbd3b88406a Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 29 Jan 2008 15:25:21 +0000 Subject: [PATCH] [216596] dstore preferences (timeout, and others) --- .../META-INF/MANIFEST.MF | 2 +- .../build.properties | 3 +- .../plugin.properties | 2 + .../plugin.xml | 25 +++ .../dstore/DStoreConnectorService.java | 11 +- .../dstore/IUniversalDStoreConstants.java | 4 + .../dstore/DStoreResources.java | 40 ++++ .../dstore/DStoreResources.properties | 29 +++ .../propertypages/DStorePreferencePage.java | 200 ++++++++++++++++++ 9 files changed, 310 insertions(+), 6 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.xml create mode 100644 rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.java create mode 100644 rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.properties create mode 100644 rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ui/propertypages/DStorePreferencePage.java diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.connectorservice.dstore/META-INF/MANIFEST.MF index 24e214f27fa..3e78f09474d 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName -Bundle-SymbolicName: org.eclipse.rse.connectorservice.dstore +Bundle-SymbolicName: org.eclipse.rse.connectorservice.dstore;singleton:=true Bundle-Version: 3.0.0.qualifier Bundle-Activator: org.eclipse.rse.internal.connectorservice.dstore.Activator Bundle-Localization: plugin diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/build.properties b/rse/plugins/org.eclipse.rse.connectorservice.dstore/build.properties index b4ace03535b..5d2ccab877c 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/build.properties +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/build.properties @@ -11,7 +11,8 @@ bin.includes = .,\ META-INF/,\ about.html,\ - plugin.properties + plugin.properties,\ + plugin.xml source.. = src/ output.. = bin/ src.includes = about.html diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.properties b/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.properties index 8e87cf83c5c..660bcccdfb7 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.properties +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.properties @@ -14,3 +14,5 @@ pluginName = RSE DStore Connector Service providerName = Eclipse.org + +PreferencePage.Datastore = Datastore diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.xml b/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.xml new file mode 100644 index 00000000000..219eb8b2848 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/plugin.xml @@ -0,0 +1,25 @@ + + + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java index 69182ee8cee..b62a7cd5942 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java @@ -20,6 +20,7 @@ * David McKnight (IBM) - [205986] attempt SSL before non-SSL for daemon connect * David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect() * David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup + * David McKnight (IBM) - [216596] dstore preferences (timeout, and others) ********************************************************************************/ package org.eclipse.rse.connectorservice.dstore; @@ -908,8 +909,11 @@ public class DStoreConnectorService extends StandardConnectorService implements msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_SERVER_OLDER_WARNING); msg.makeSubstitution(getHostName()); } - ShowConnectMessage msgAction = new ShowConnectMessage(msg); - Display.getDefault().asyncExec(msgAction); + + if (store.getBoolean(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER)){ + DisplayHidableSystemMessageAction msgAction = new DisplayHidableSystemMessageAction(msg, store, IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, false); + Display.getDefault().syncExec(msgAction); + } } // register the classloader for this plugin with the datastore @@ -919,7 +923,6 @@ public class DStoreConnectorService extends StandardConnectorService implements if (serverVersion >= 8 || (serverVersion == 7 && getServerMinor() >= 1)) { // register the preference for remote class caching with the datastore - store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, IUniversalDStoreConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES); boolean cacheRemoteClasses = store.getBoolean(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES); dataStore.setPreference(RemoteClassLoader.CACHING_PREFERENCE, cacheRemoteClasses ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -938,7 +941,7 @@ public class DStoreConnectorService extends StandardConnectorService implements monitor.subTask(imsg.getLevelOneText()); } DataElement initStatus = dataStore.initMiners(); - statusMonitor.waitForUpdate(schemaStatus); + //statusMonitor.waitForUpdate(schemaStatus); statusMonitor.waitForUpdate(initStatus); } //long t2 = System.currentTimeMillis(); diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java index 864656dd6fa..db50fba823e 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java @@ -13,6 +13,7 @@ * * Contributors: * {Name} (company) - description of contribution. + * David McKnight (IBM) - [216596] dstore preferences (timeout, and others) *******************************************************************************/ package org.eclipse.rse.connectorservice.dstore; @@ -64,4 +65,7 @@ public interface IUniversalDStoreConstants public static final String RESID_PREF_DO_KEEPALIVE = RESID_PREF_PREFIX + "dokeepalive"; //$NON-NLS-1$ public static final boolean DEFAULT_PREF_DO_KEEPALIVE = true; + + public static final String ALERT_MISMATCHED_SERVER = RESID_PREFIX + "alert.mismatched.server"; //$NON-NLS-1$ + public static final boolean DEFAULT_ALERT_MISMATCHED_SERVER = true; } diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.java new file mode 100644 index 00000000000..52c26a064e5 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.java @@ -0,0 +1,40 @@ +/******************************************************************************** + * Copyright (c) 2008 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [216596] dstore preferences (timeout, and others) + ********************************************************************************/ +package org.eclipse.rse.internal.connectorservice.dstore; + +import org.eclipse.osgi.util.NLS; + +public class DStoreResources extends NLS { + + private static String BUNDLE_NAME = "org.eclipse.rse.internal.connectorservice.dstore.DStoreResources"; //$NON-NLS-1$ + + public static String RESID_PREFERENCE_CONNECTION_TIMEOUT_LABEL; + public static String RESID_PREFERENCE_CONNECTION_TIMEOUT_TOOLTIP; + + public static String RESID_PREFERENCE_DO_KEEPALIVE_LABEL; + public static String RESID_PREFERENCE_DO_KEEPALIVE_TOOLTIP; + + public static String RESID_PREFERENCE_CACHE_REMOTE_CLASSES_LABEL; + public static String RESID_PREFERENCE_CACHE_REMOTE_CLASSES_TOOLTIP; + + public static String RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_LABEL; + public static String RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_TOOLTIP; + + static + { + // load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, DStoreResources.class); + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.properties b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.properties new file mode 100644 index 00000000000..dfe9b225bc6 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/DStoreResources.properties @@ -0,0 +1,29 @@ +################################################################################ +# Copyright (c) 2008 IBM Corporation. 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 +# +# Initial Contributors: +# The following IBM employees contributed to the Remote System Explorer +# component that contains this file: David McKnight + +# Contributors: +# David McKnight (IBM) - [216596] dstore preferences (timeout, and others) +################################################################################# + +# NLS_MESSAGEFORMAT_VAR +# NLS_ENCODING=UTF-8 + +RESID_PREFERENCE_CONNECTION_TIMEOUT_LABEL=Connection Timeout (ms) +RESID_PREFERENCE_CONNECTION_TIMEOUT_TOOLTIP=Time to wait for establishing a Datastore connection. + +RESID_PREFERENCE_DO_KEEPALIVE_LABEL=Enable Keepalive +RESID_PREFERENCE_DO_KEEPALIVE_TOOLTIP=Keep Datastore connections alive when idle. + +RESID_PREFERENCE_CACHE_REMOTE_CLASSES_LABEL=Cache Remote Classes +RESID_PREFERENCE_CACHE_REMOTE_CLASSES_TOOLTIP=Cache remote server classes. This is only useful when all required classes are unavailable on the server side. + +RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_LABEL=Show Mismatched Server Warning +RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_TOOLTIP=Show a warning when the DataStore server is compatible but older or newer then the current client. + \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ui/propertypages/DStorePreferencePage.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ui/propertypages/DStorePreferencePage.java new file mode 100644 index 00000000000..2d7cdc6029f --- /dev/null +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ui/propertypages/DStorePreferencePage.java @@ -0,0 +1,200 @@ +/******************************************************************************** + * Copyright (c) 2008 IBM Corporation. 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 + * + * Initial Contributors: + * The following IBM employees contributed to the Remote System Explorer + * component that contains this file: David McKnight. + * + * Contributors: + * David McKnight (IBM) - [216596] dstore preferences (timeout, and others) + ********************************************************************************/ +package org.eclipse.rse.internal.connectorservice.dstore.ui.propertypages; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.rse.connectorservice.dstore.IUniversalDStoreConstants; +import org.eclipse.rse.internal.connectorservice.dstore.DStoreResources; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemWidgetHelpers; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class DStorePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener +{ + + private Text _connectionTimeout; + private Button _doKeepaliveButton; + private Button _cacheRemoteClassesButton; + private Button _showMismatchedServerWarningButton; + + protected Control createContents(Composite gparent) { + Composite parent = SystemWidgetHelpers.createComposite(gparent, 2); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + parent.setLayout(layout); + parent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + + SystemWidgetHelpers.createLabel(parent, DStoreResources.RESID_PREFERENCE_CONNECTION_TIMEOUT_LABEL); + + _connectionTimeout = new Text(parent, SWT.BORDER); + GridData gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); + gd.widthHint = 75; + _connectionTimeout.setLayoutData(gd); + _connectionTimeout.setTextLimit(5); + _connectionTimeout.setToolTipText(DStoreResources.RESID_PREFERENCE_CONNECTION_TIMEOUT_TOOLTIP); + _connectionTimeout.addVerifyListener(new VerifyListener() + { + public void verifyText(VerifyEvent e) + { + e.doit = true; + for (int loop = 0; loop < e.text.length(); loop++) + { + if (!Character.isDigit(e.text.charAt(loop))) + e.doit = false; + } + } + }); + + _doKeepaliveButton = SystemWidgetHelpers.createCheckBox(parent, DStoreResources.RESID_PREFERENCE_DO_KEEPALIVE_LABEL, this); + _doKeepaliveButton.setToolTipText(DStoreResources.RESID_PREFERENCE_DO_KEEPALIVE_TOOLTIP); + _doKeepaliveButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); + ((GridData)_doKeepaliveButton.getLayoutData()).horizontalSpan = 2; + + _cacheRemoteClassesButton = SystemWidgetHelpers.createCheckBox(parent, DStoreResources.RESID_PREFERENCE_CACHE_REMOTE_CLASSES_LABEL, this); + _cacheRemoteClassesButton.setToolTipText(DStoreResources.RESID_PREFERENCE_CACHE_REMOTE_CLASSES_TOOLTIP); + _cacheRemoteClassesButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); + ((GridData)_cacheRemoteClassesButton.getLayoutData()).horizontalSpan = 2; + + _showMismatchedServerWarningButton = SystemWidgetHelpers.createCheckBox(parent, DStoreResources.RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_LABEL, this); + _showMismatchedServerWarningButton.setToolTipText(DStoreResources.RESID_PREFERENCE_SHOW_MISMATCHED_SERVER_TOOLTIP); + _showMismatchedServerWarningButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false)); + ((GridData)_showMismatchedServerWarningButton.getLayoutData()).horizontalSpan = 2; + + + initControls(); + return parent; + } + + private void initControls() + { + IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); + + + // timeout + int timeout = 0; + if (store.contains(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT)){ + timeout = store.getInt(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT); + } + else { + timeout = IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, timeout); + } + _connectionTimeout.setText(""+timeout); //$NON-NLS-1$ + + + // cache remote classes + boolean cacheRemoteClasses = false; + if (store.contains(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES)) { + cacheRemoteClasses = store.getBoolean(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES); + } + else { + cacheRemoteClasses = IUniversalDStoreConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, cacheRemoteClasses); + } + _cacheRemoteClassesButton.setSelection(cacheRemoteClasses); + + + // do keepalive + boolean doKeepalive = false; + if (store.contains(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE)){ + doKeepalive = store.getBoolean(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE); + } + else { + doKeepalive = IUniversalDStoreConstants.DEFAULT_PREF_DO_KEEPALIVE; + store.setDefault(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE, doKeepalive); + + } + _doKeepaliveButton.setSelection(doKeepalive); + + // show mismatched server warning + boolean showMismatchedWarning = false; + if (store.contains(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER)){ + showMismatchedWarning = store.getBoolean(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER); + } + else { + showMismatchedWarning = IUniversalDStoreConstants.DEFAULT_ALERT_MISMATCHED_SERVER; + store.setDefault(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, showMismatchedWarning); + + } + _showMismatchedServerWarningButton.setSelection(showMismatchedWarning); + } + + protected void performApply() { + super.performApply(); + IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); + + // timeout + String timeoutStr = _connectionTimeout.getText(); + int timeout = Integer.parseInt(timeoutStr); + store.setValue(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, timeout); + + // do keepalive + boolean doKeepalive = _doKeepaliveButton.getSelection(); + store.setValue(IUniversalDStoreConstants.RESID_PREF_DO_KEEPALIVE, doKeepalive); + + // cache remote classes + boolean cacheRemoteClasses = _cacheRemoteClassesButton.getSelection(); + store.setValue(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, cacheRemoteClasses); + + // show mismatched server warning + boolean showMismatchedWarning = _showMismatchedServerWarningButton.getSelection(); + store.setValue(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER, showMismatchedWarning); + } + + protected void performDefaults() { + super.performDefaults(); + + int timeout = IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT; + _connectionTimeout.setText(""+timeout); //$NON-NLS-1$ + + // do keepalive + boolean doKeepalive = IUniversalDStoreConstants.DEFAULT_PREF_DO_KEEPALIVE; + _doKeepaliveButton.setSelection(doKeepalive); + + // show mismatched server warning + boolean showMismatchedWarning = IUniversalDStoreConstants.DEFAULT_ALERT_MISMATCHED_SERVER; + _showMismatchedServerWarningButton.setSelection(showMismatchedWarning); + + // cache remote classes + boolean cacheRemoteClasses = IUniversalDStoreConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES; + _cacheRemoteClassesButton.setSelection(cacheRemoteClasses); + + } + + public void init(IWorkbench workbench) { + + } + + public void handleEvent(Event event) { + // TODO Auto-generated method stub + + } + + + +}