diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSEPreferenceNames.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSEPreferenceNames.java index 098a73cf5f1..e0f49793560 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSEPreferenceNames.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSEPreferenceNames.java @@ -13,6 +13,22 @@ package org.eclipse.rse.core; * These constants define the set of preference names that the RSE core uses. */ public interface IRSEPreferenceNames { - public static final String ST_DEFAULT_USERID = "systemType.defaultUserId"; //$NON-NLS-1$ + /* + * core preference keys + */ public static final String ST_ENABLED = "systemType.enabled"; //$NON-NLS-1$ + public static final String ST_DEFAULT_USERID = "systemType.defaultUserId"; //$NON-NLS-1$ + public static final String SYSTEMTYPE = "systemtype"; //$NON-NLS-1$ + public static final String USERIDPERKEY = "useridperkey"; //$NON-NLS-1$ + public static final String USERIDKEYS = "userid.keys"; //$NON-NLS-1$ + public static final String ACTIVEUSERPROFILES = "activeuserprofiles"; //$NON-NLS-1$ + public static final String USE_DEFERRED_QUERIES = "useDeferredQueries"; //$NON-NLS-1$ + /* + * core preference default values + */ + public static final String DEFAULT_SYSTEMTYPE = ""; //$NON-NLS-1$ + public static final String DEFAULT_USERID = ""; //$NON-NLS-1$ + public static final boolean DEFAULT_USE_DEFERRED_QUERIES = true; + public static final String DEFAULT_TEAMPROFILE = "Team"; //$NON-NLS-1$ + public static final String DEFAULT_ACTIVEUSERPROFILES = "Team"; //$NON-NLS-1$ } diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/PasswordPersistenceManager.java similarity index 94% rename from rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java rename to rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/PasswordPersistenceManager.java index 2ff89987683..4ac86791845 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/PasswordPersistenceManager.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/PasswordPersistenceManager.java @@ -24,12 +24,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.core.runtime.Preferences; import org.eclipse.rse.core.model.SystemSignonInformation; -import org.eclipse.rse.ui.ISystemPreferencesConstants; -import org.eclipse.rse.ui.RSEUIPlugin; /** @@ -323,7 +322,7 @@ public class PasswordPersistenceManager { // if no passwords found with new URL, check old URL if (passwords == null) { - URL oldServerURL1 = new URL(SERVER_URL + SystemBasePlugin.getWorkspace().getRoot().getLocation().toOSString()); + URL oldServerURL1 = new URL(SERVER_URL + ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString()); passwords = Platform.getAuthorizationInfo(oldServerURL1, systemType, AUTH_SCHEME); // passwords found, so migrate to using new URL @@ -343,7 +342,7 @@ public class PasswordPersistenceManager { } } catch (MalformedURLException e) { - SystemBasePlugin.logError("PasswordPersistenceManager.getPasswordMap", e); //$NON-NLS-1$ + RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.getPasswordMap", e); //$NON-NLS-1$ } return passwords; @@ -361,10 +360,10 @@ public class PasswordPersistenceManager { Platform.addAuthorizationInfo(serverURL, systemType, AUTH_SCHEME, passwords); } catch (MalformedURLException e) { - SystemBasePlugin.logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$ + RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$ } catch (CoreException e) { - SystemBasePlugin.logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$ + RSECorePlugin.getDefault().getLogger().logError("PasswordPersistenceManager.savePasswordMap", e); //$NON-NLS-1$ } } @@ -411,8 +410,8 @@ public class PasswordPersistenceManager { // uid matches, check if hosts are the same if (khostname.startsWith(phostname) || phostname.startsWith(khostname)) { - String qkhost = RSEUIPlugin.getQualifiedHostName(khostname); - String qphost = RSEUIPlugin.getQualifiedHostName(phostname); + String qkhost = RSEHostUtil.getQualifiedHostName(khostname); + String qphost = RSEHostUtil.getQualifiedHostName(phostname); if (qkhost.equals(qphost)) { password = (String)passwords.get(key); @@ -461,8 +460,8 @@ public class PasswordPersistenceManager { // uid matches, check if hosts are the same if (khostname.startsWith(phostname) || phostname.startsWith(khostname)) { - String qkhost = RSEUIPlugin.getQualifiedHostName(khostname); - String qphost = RSEUIPlugin.getQualifiedHostName(phostname); + String qkhost = RSEHostUtil.getQualifiedHostName(khostname); + String qphost = RSEHostUtil.getQualifiedHostName(phostname); if (qkhost.equals(qphost)) { password = (String)passwords.get(key); @@ -546,8 +545,8 @@ public class PasswordPersistenceManager { { if (DEFAULT_SYSTEM_TYPE.equals(systemType)) { - IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); - systemType = store.getString(ISystemPreferencesConstants.SYSTEMTYPE); + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + systemType = store.getString(IRSEPreferenceNames.SYSTEMTYPE); } // First find the correct provider diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSEHostUtil.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSEHostUtil.java new file mode 100644 index 00000000000..ec0dbd6bb62 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSEHostUtil.java @@ -0,0 +1,24 @@ +package org.eclipse.rse.core; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + * This class is a collection of utility methods that can be used to + * deal with IP addresses and hosts. + * + * This class should not be subclassed. + */ +public class RSEHostUtil { + /** + * Returns a qualified hostname given a potentially unqualified hostname + */ + public static String getQualifiedHostName(String hostName) { + try { + InetAddress address = InetAddress.getByName(hostName); + return address.getCanonicalHostName(); + } catch (UnknownHostException exc) { + return hostName; + } + } +} diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemResourceConstants.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemResourceConstants.java similarity index 91% rename from rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemResourceConstants.java rename to rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemResourceConstants.java index e7b18682e9f..4f6000ddddb 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemResourceConstants.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/SystemResourceConstants.java @@ -16,7 +16,6 @@ package org.eclipse.rse.core; -import org.eclipse.rse.ui.ISystemPreferencesConstants; /** * Constants related to project and folder names. @@ -32,5 +31,5 @@ public interface SystemResourceConstants public static final String RESOURCE_USERACTIONS_FOLDER_NAME = "UserActions"; //$NON-NLS-1$ public static final String RESOURCE_COMPILECOMMANDS_FOLDER_NAME = "CompileCommands"; //$NON-NLS-1$ - public static final String RESOURCE_TEAMPROFILE_NAME = ISystemPreferencesConstants.DEFAULT_TEAMPROFILE; + public static final String RESOURCE_TEAMPROFILE_NAME = IRSEPreferenceNames.DEFAULT_TEAMPROFILE; } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java index 0c6853c66eb..8338783ef0b 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java @@ -527,7 +527,7 @@ public class SystemQualifiedRemoteFolderCombo extends Composite */ public static String[] getHistory() { - return SystemPreferencesManager.getPreferencesManager().getFolderHistory(); + return SystemPreferencesManager.getFolderHistory(); } /** diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemRemoteFolderCombo.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemRemoteFolderCombo.java index 18915341769..8f041a14a6f 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemRemoteFolderCombo.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemRemoteFolderCombo.java @@ -444,7 +444,7 @@ public class SystemRemoteFolderCombo extends Composite implements ISystemCombo */ public static String[] getHistory() { - return SystemPreferencesManager.getPreferencesManager().getFolderHistory(); + return SystemPreferencesManager.getFolderHistory(); } /** diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index 7e05fb0d765..bd5e492b7fe 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -1496,7 +1496,7 @@ public class SystemView extends SafeTreeViewer implements ISystemTree, ISystemRe setExpandedState(parentSubSystem, true); // expand the subsystem Object filterParentInTree = parentSubSystem; // will be case unless in show filter pool mode // if showing filter pools, expand parent filter pool reference... - if (SystemPreferencesManager.getPreferencesManager().getShowFilterPools()) { + if (SystemPreferencesManager.getShowFilterPools()) { ISystemFilterPoolReference poolRef = parentSubSystem.getFilterPoolReferenceManager().getReferenceToSystemFilterPool(filter.getParentFilterPool()); setExpandedState(poolRef, true); filterParentInTree = poolRef; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java index a64d16b666e..68840d1757b 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java @@ -23,25 +23,6 @@ public interface ISystemPreferencesConstants { * root */ public static final String ROOT = "org.eclipse.rse.preferences."; //$NON-NLS-1$ - /* - * core preference keys - */ - public static final String SYSTEMTYPE = ROOT + "systemtype"; //$NON-NLS-1$ - public static final String SYSTEMTYPE_VALUES = ROOT + "systemtype.info"; //$NON-NLS-1$ - public static final String USERIDPERKEY = ROOT + "useridperkey"; //$NON-NLS-1$ - public static final String USERIDKEYS = ROOT + "userid.keys"; //$NON-NLS-1$ - public static final String ACTIVEUSERPROFILES = ROOT + "activeuserprofiles"; //$NON-NLS-1$ - public static final String USE_DEFERRED_QUERIES = ROOT + "useDeferredQueries"; //$NON-NLS-1$ - public static final String RESTORE_STATE_FROM_CACHE = ROOT + "restoreStateFromCache"; //$NON-NLS-1$ - /* - * core preference default values - */ - public static final String DEFAULT_SYSTEMTYPE = ""; //$NON-NLS-1$ - public static final String DEFAULT_USERID = ""; //$NON-NLS-1$ - public static final boolean DEFAULT_RESTORE_STATE_FROM_CACHE = true; // yantzi: artemis 6.0 - public static final boolean DEFAULT_USE_DEFERRED_QUERIES = true; - public static final String DEFAULT_TEAMPROFILE = "Team"; //$NON-NLS-1$ - public static final String DEFAULT_ACTIVEUSERPROFILES = "Team"; //$NON-NLS-1$ /* * dstore preference keys */ @@ -63,6 +44,8 @@ public interface ISystemPreferencesConstants { /* * ui preference keys */ + public static final String RESTORE_STATE_FROM_CACHE = ROOT + "restoreStateFromCache"; //$NON-NLS-1$ + public static final String SYSTEMTYPE_VALUES = ROOT + "systemtype.info"; //$NON-NLS-1$ public static final String SHOWFILTERPOOLS = ROOT + "filterpools.show"; //$NON-NLS-1$ public static final String QUALIFY_CONNECTION_NAMES = ROOT + "qualifyconnectionnames"; //$NON-NLS-1$ public static final String ORDER_CONNECTIONS = ROOT + "order.connections"; //$NON-NLS-1$ @@ -76,6 +59,7 @@ public interface ISystemPreferencesConstants { /* * ui preference default values */ + public static final boolean DEFAULT_RESTORE_STATE_FROM_CACHE = true; // yantzi: artemis 6.0 public static final boolean DEFAULT_SHOWFILTERPOOLS = false; public static final boolean DEFAULT_QUALIFY_CONNECTION_NAMES = false; public static final String DEFAULT_ORDER_CONNECTIONS = ""; //$NON-NLS-1$ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java index d6f126bba9c..4669360fe93 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java @@ -21,13 +21,10 @@ import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.core.IRSEPreferenceNames; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemTypeConstants; -import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.SystemPreferencesManager; import org.osgi.framework.Bundle; /** @@ -183,12 +180,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo boolean result = false; IRSESystemType systemType = getSystemType(object); if ( systemType != null) { - Preferences prefs = RSECorePlugin.getDefault().getPluginPreferences(); - String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED); - if (!prefs.contains(key)) { - prefs.setDefault(key, true); - } - result = prefs.getBoolean(key); + result = SystemPreferencesManager.getIsSystemTypeEnabled(systemType); } return result; } @@ -201,11 +193,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo public void setIsEnabled(Object object, boolean isEnabled) { IRSESystemType systemType = getSystemType(object); if ( systemType != null) { - Plugin core = RSECorePlugin.getDefault(); - Preferences prefs = core.getPluginPreferences(); - String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED); - prefs.setValue(key, isEnabled); - core.savePluginPreferences(); + SystemPreferencesManager.setIsSystemTypeEnabled(systemType, isEnabled); } } @@ -219,12 +207,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo String result = null; IRSESystemType systemType = getSystemType(object); if ( systemType != null) { - Preferences prefs = RSECorePlugin.getDefault().getPluginPreferences(); - String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID); - if (!prefs.contains(key)) { - prefs.setDefault(key, System.getProperty("user.name")); //$NON-NLS-1$ - } - result = prefs.getString(key); + result = SystemPreferencesManager.getDefaultUserId(systemType); } return result; } @@ -237,20 +220,11 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo public void setDefaultUserId(Object object, String defaultUserId) { IRSESystemType systemType = getSystemType(object); if ( systemType != null) { - Plugin core = RSECorePlugin.getDefault(); - Preferences prefs = core.getPluginPreferences(); - String key = getPreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID); - prefs.setValue(key, defaultUserId); - core.savePluginPreferences(); + SystemPreferencesManager.setDefaultUserId(systemType, defaultUserId); } } - - private String getPreferencesKey(IRSESystemType systemType, String preference) { - String key = systemType.getName() + "." + preference; //$NON-NLS-1$ - return key; - } - - private IRSESystemType getSystemType(Object systemTypeCandidate) { + + private static IRSESystemType getSystemType(Object systemTypeCandidate) { IRSESystemType result = null; if (systemTypeCandidate instanceof IRSESystemType) { result = (IRSESystemType) systemTypeCandidate; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java index b570a7afcdf..a93c4b2f4c0 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java @@ -16,7 +16,6 @@ package org.eclipse.rse.ui; -import java.net.InetAddress; import java.net.URL; import java.util.Arrays; import java.util.Vector; @@ -30,6 +29,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemBasePlugin; +import org.eclipse.rse.core.SystemPreferencesManager; import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.comm.ISystemKeystoreProvider; import org.eclipse.rse.core.comm.SystemCommunicationsDaemon; @@ -56,8 +56,6 @@ import org.eclipse.rse.ui.actions.SystemDynamicPopupMenuExtensionManager; import org.eclipse.rse.ui.actions.SystemShowPreferencesPageAction; import org.eclipse.rse.ui.internal.RSESystemTypeAdapterFactory; import org.eclipse.rse.ui.internal.RSEUIRegistry; -import org.eclipse.rse.ui.propertypages.RemoteSystemsPreferencePage; -import org.eclipse.rse.ui.propertypages.SystemCommunicationsPreferencePage; import org.eclipse.rse.ui.view.SubSystemConfigurationAdapterFactory; import org.eclipse.rse.ui.view.SystemViewAdapterFactory; import org.eclipse.rse.ui.view.team.SystemTeamViewResourceAdapterFactory; @@ -81,7 +79,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi private static SystemMessageFile defaultMessageFile = null; // private SystemType[] allSystemTypes = null; - private String enabledSystemTypes; private SystemRegistry _systemRegistry = null; @@ -93,7 +90,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi private SystemViewAdapterFactory svaf; // for fastpath access private SystemTeamViewResourceAdapterFactory svraf; // for fastpath private SystemShowPreferencesPageAction[] showPrefPageActions = null; - private boolean dontShowLocalConnection, dontShowProfilePageInitially; private boolean loggingSystemMessageLine = false; /** @@ -119,50 +115,12 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi } /** - * Initializes default preferences. + * Initializes preferences. */ public void initializeDefaultPreferences() { - - boolean showNewConnPromptPref = ISystemPreferencesConstants.DEFAULT_SHOWNEWCONNECTIONPROMPT; - dontShowLocalConnection = false; - dontShowProfilePageInitially = false; - - String showNewConn = System.getProperty("rse.showNewConnectionPrompt"); //$NON-NLS-1$ - - if (showNewConn != null) { - showNewConnPromptPref = showNewConn.equals("true"); //$NON-NLS-1$ - } - - String showLocalConn = System.getProperty("rse.showLocalConnection"); //$NON-NLS-1$ - - if (showLocalConn != null) { - dontShowLocalConnection = showLocalConn.equals("false"); //$NON-NLS-1$ - } - - enabledSystemTypes = System.getProperty("rse.enableSystemTypes"); //$NON-NLS-1$ - - if ((enabledSystemTypes != null) && (enabledSystemTypes.length() == 0)) { - enabledSystemTypes = null; - } - - String showProfileInitially = System.getProperty("rse.showProfilePage"); //$NON-NLS-1$ - - if (showProfileInitially != null) { - dontShowProfilePageInitially = showProfileInitially.equals("false"); //$NON-NLS-1$ - } - - RemoteSystemsPreferencePage.initDefaults(getPreferenceStore(), showNewConnPromptPref); - SystemCommunicationsPreferencePage.initDefaults(getPreferenceStore()); + SystemPreferencesManager.initDefaults(); } - - /** - * Returns whether to show profile page initially, i.e. during the first new connection creation. - * @return true to show profile page initially, false otherwise. - */ - public boolean getShowProfilePageInitially() { - return !dontShowProfilePageInitially; - } - + /** * Set whether or not to log the messages shown on the system message line for dialogs * and wizards. These message are typically validation messages for fields. @@ -546,7 +504,7 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi //} // } // new support to allow products to not pre-create a local connection - if (SystemResourceManager.isFirstTime() && !dontShowLocalConnection) { + if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) { ISystemProfileManager profileManager = SystemProfileManager.getSystemProfileManager(); ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile(); String userName = System.getProperty("user.name"); //$NON-NLS-1$ @@ -706,22 +664,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi - /** - * Returns a qualified hostname given a potentially unqualified hostname - */ - public static String getQualifiedHostName(String hostName) - { - try - { - InetAddress address = InetAddress.getByName(hostName); - return address.getCanonicalHostName(); - } - catch (java.net.UnknownHostException exc) - { - return hostName; - } - } - /** * Return an array of SubSystemConfigurationProxy objects. * These represent all extensions to our subsystemConfigurations extension point. diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java index 97d5e23a568..f73eb7751c6 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemConnectionForm.java @@ -37,7 +37,6 @@ import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.propertypages.RemoteSystemsPreferencePage; import org.eclipse.rse.ui.validators.ISystemValidator; import org.eclipse.rse.ui.validators.ValidatorConnectionName; import org.eclipse.rse.ui.validators.ValidatorUserId; @@ -469,7 +468,7 @@ public class SystemConnectionForm } else userIdLocation = IRSEUserIdConstants.USERID_LOCATION_NOTSET; - SystemPreferencesManager.getPreferencesManager().setVerifyConnection(verifyHostNameCB.getSelection()); + SystemPreferencesManager.setVerifyConnection(verifyHostNameCB.getSelection()); } return ok; @@ -699,7 +698,7 @@ public class SystemConnectionForm if (!updateMode && (defaultSystemType==null)) { - defaultSystemType = RemoteSystemsPreferencePage.getSystemTypePreference(); + defaultSystemType = SystemPreferencesManager.getSystemType(); if ((defaultSystemType == null) || (defaultSystemType.length() == 0)) defaultSystemType = lastSystemType; if ((defaultSystemType == null) || (defaultSystemType.length() == 0)) @@ -738,7 +737,7 @@ public class SystemConnectionForm if (updateMode) verifyHostNameCB.setSelection(false); else - verifyHostNameCB.setSelection(SystemPreferencesManager.getPreferencesManager().getVerifyConnection()); + verifyHostNameCB.setSelection(SystemPreferencesManager.getVerifyConnection()); // yantzi: artemis 6.0, work offline if (enableOfflineCB()) @@ -991,7 +990,7 @@ public class SystemConnectionForm { if (defaultSystemType == null) { - defaultSystemType = RemoteSystemsPreferencePage.getSystemTypePreference(); + defaultSystemType = SystemPreferencesManager.getSystemType(); if ((defaultSystemType == null) || (defaultSystemType.length()==0)) defaultSystemType = lastSystemType; } @@ -1060,7 +1059,7 @@ public class SystemConnectionForm // --------------- // default user id // --------------- - String parentUserId = SystemPreferencesManager.getPreferencesManager().getDefaultUserId(systemType); + String parentUserId = SystemPreferencesManager.getUserId(systemType); if (textUserId!=null) { textUserId.setInheritedText(parentUserId); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceRestoreStateAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceRestoreStateAction.java index 273b65d4937..7f2a7fb35cf 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceRestoreStateAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceRestoreStateAction.java @@ -40,7 +40,7 @@ public class SystemPreferenceRestoreStateAction extends SystemBaseAction setSelectionSensitive(false); allowOnMultipleSelection(true); //sr = RSEUIPlugin.getTheSystemRegistry(); - setChecked(SystemPreferencesManager.getPreferencesManager().getRememberState()); + setChecked(SystemPreferencesManager.getRememberState()); setHelp(RSEUIPlugin.HELPPREFIX+"aprefres"); //$NON-NLS-1$ } @@ -52,7 +52,7 @@ public class SystemPreferenceRestoreStateAction extends SystemBaseAction public void run() { boolean newState = isChecked(); - SystemPreferencesManager.getPreferencesManager().setRememberState(newState); + SystemPreferencesManager.setRememberState(newState); firePreferenceChangeEvent(ISystemPreferenceChangeEvents.EVENT_RESTORESTATE, !newState,newState); } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceShowFilterPoolsAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceShowFilterPoolsAction.java index 8b05c418ecc..641bb195ff9 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceShowFilterPoolsAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemPreferenceShowFilterPoolsAction.java @@ -40,7 +40,7 @@ public class SystemPreferenceShowFilterPoolsAction extends SystemBaseAction super(SystemResources.ACTION_PREFERENCE_SHOW_FILTERPOOLS_LABEL,SystemResources.ACTION_PREFERENCE_SHOW_FILTERPOOLS_TOOLTIP, parent); allowOnMultipleSelection(true); - setChecked(SystemPreferencesManager.getPreferencesManager().getShowFilterPools()); + setChecked(SystemPreferencesManager.getShowFilterPools()); setSelectionSensitive(false); setHelp(RSEUIPlugin.HELPPREFIX+"actn0011"); //$NON-NLS-1$ @@ -53,7 +53,7 @@ public class SystemPreferenceShowFilterPoolsAction extends SystemBaseAction public void run() { boolean newState = isChecked(); - SystemPreferencesManager.getPreferencesManager().setShowFilterPools(newState); + SystemPreferencesManager.setShowFilterPools(newState); firePreferenceChangeEvent(ISystemPreferenceChangeEvents.EVENT_SHOWFILTERPOOLS, !newState,newState); // defect 41794 } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java index 80b842549d4..c428b0bead2 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/dialogs/SystemPasswordPromptDialog.java @@ -253,7 +253,7 @@ public final class SystemPasswordPromptDialog extends SystemPromptDialog impleme originalUserId = connectorService.getUserId(); userId = originalUserId; if (connectorService.supportsUserId() && (userId == null || userId.length() == 0)) { - userId = SystemPreferencesManager.getPreferencesManager().getDefaultUserId(connectorService.getHostType()); + userId = SystemPreferencesManager.getUserId(connectorService.getHostType()); } if (textUserId != null && userId != null) { textUserId.setText(userId); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java index 4470e83688d..c99009a073b 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/propertypages/RemoteSystemsPreferencePage.java @@ -16,22 +16,17 @@ package org.eclipse.rse.ui.propertypages; -import java.util.Hashtable; -import java.util.StringTokenizer; import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.IRSEPreferenceNames; import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.SystemPreferencesManager; import org.eclipse.rse.core.model.ISystemPreferenceChangeEvents; import org.eclipse.rse.internal.model.SystemPreferenceChangeEvent; -import org.eclipse.rse.internal.model.SystemProfileManager; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.Mnemonics; -import org.eclipse.rse.ui.RSESystemTypeAdapter; import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemConnectionForm; import org.eclipse.rse.ui.SystemResources; import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.swt.SWT; @@ -93,7 +88,7 @@ public class RemoteSystemsPreferencePage { // DEFAULT SYSTEM TYPE SystemComboBoxFieldEditor systemTypeEditor = new SystemComboBoxFieldEditor( - ISystemPreferencesConstants.SYSTEMTYPE, + IRSEPreferenceNames.SYSTEMTYPE, SystemResources.RESID_PREF_SYSTEMTYPE_PREFIX_LABEL, RSECorePlugin.getDefault().getRegistry().getSystemTypeNames(), true, // readonly @@ -169,7 +164,7 @@ public class RemoteSystemsPreferencePage // USE DEFERRED QUERY useDeferredQueryEditor = new SystemBooleanFieldEditor( - ISystemPreferencesConstants.USE_DEFERRED_QUERIES, + IRSEPreferenceNames.USE_DEFERRED_QUERIES, SystemResources.RESID_PREF_USEDEFERREDQUERIES_PREFIX_LABEL, getFieldEditorParent()) ; @@ -197,419 +192,11 @@ public class RemoteSystemsPreferencePage } - // --------------------------------------------------------- - // GETTERS/SETTERS FOR EACH OF THE USER PREFERENCE VALUES... - // --------------------------------------------------------- - // DWD these preferences methods should be moved to SystemPreferencesManager since they are not a proper function of a preference page. - /** - * Return the names of the profiles the user has elected to make "active". - */ - public static String[] getActiveProfiles() - { - IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); - return parseStrings(store.getString(ISystemPreferencesConstants.ACTIVEUSERPROFILES)); - } - - /** - * Set the names of the profiles the user has elected to make "active". - */ - public static void setActiveProfiles(String[] newProfileNames) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.ACTIVEUSERPROFILES, makeString(newProfileNames)); - savePreferenceStore(); - } - - /** - * Return the ordered list of connection names. This is how user arranged his connections in the system view. - */ - public static String[] getConnectionNamesOrder() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return parseStrings(store.getString(ISystemPreferencesConstants.ORDER_CONNECTIONS)); - } - /** - * Set the ordered list of connection names. This is how user arranged his connections in the system view. - */ - public static void setConnectionNamesOrder(String[] newConnectionNamesOrder) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.ORDER_CONNECTIONS, makeString(newConnectionNamesOrder)); - savePreferenceStore(); - } - /** - * Return true if the user has elected to show filter pools in the Remote System Explorer view - */ - public static boolean getShowFilterPoolsPreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(ISystemPreferencesConstants.SHOWFILTERPOOLS); - } - /** - * Toggle whether to show filter pools in the Remote System Explorer view - */ - public static void setShowFilterPoolsPreference(boolean show) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.SHOWFILTERPOOLS,show); - savePreferenceStore(); - } - - /** - * Return true if the user has elected to show the "New Connection..." prompt in the Remote Systems view - */ - public static boolean getShowNewConnectionPromptPreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - boolean value = store.getBoolean(ISystemPreferencesConstants.SHOWNEWCONNECTIONPROMPT); - return value; - } - /** - * Toggle whether to show filter pools in the Remote System Explorer view - */ - public static void setShowNewConnectionPromptPreference(boolean show) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.SHOWNEWCONNECTIONPROMPT,show); - savePreferenceStore(); - } - - /** - * Return true if the user has elected to show connection names qualified by profile - */ - public static boolean getQualifyConnectionNamesPreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(ISystemPreferencesConstants.QUALIFY_CONNECTION_NAMES); - } - /** - * Set if the user has elected to show connection names qualified by profile - */ - public static void setQualifyConnectionNamesPreference(boolean set) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.QUALIFY_CONNECTION_NAMES,set); - savePreferenceStore(); - } - - /** - * Return true if the user has elected to remember the state of the Remote Systems view - */ - public static boolean getRememberStatePreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(ISystemPreferencesConstants.REMEMBER_STATE); - } - /** - * Set if the user has elected to show connection names qualified by profile - */ - public static void setRememberStatePreference(boolean set) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.REMEMBER_STATE,set); - savePreferenceStore(); - } - - /** - * Return true if the user has elected to restore the state of the Remote Systems view from cached information - */ - public static boolean getRestoreStateFromCachePreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE); - } - - /** - * Set if the user has elected to restore the state of the Remote Systems view from cached information - */ - public static void setRestoreStateFromCachePreference(boolean set) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE, set); - savePreferenceStore(); - } - - /** - * Return true if the user has elected to show user defined actions cascaded by profile - */ - public static boolean getCascadeUserActionsPreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(ISystemPreferencesConstants.CASCADE_UDAS_BYPROFILE); - } - /** - * Set if the user has elected to show user defined actions cascaded by profile - */ - public static void setCascadeUserActionsPreference(boolean set) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(ISystemPreferencesConstants.CASCADE_UDAS_BYPROFILE,set); - savePreferenceStore(); - } - /** - * Return the userId to default to on the Create Connection wizard, per the given system type. - * - * @see SystemConnectionForm - */ - public static String getUserIdPreference(String systemType) - { - if (systemType == null) - return null; - - IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemType); - Object adapter = sysType.getAdapter(IRSESystemType.class); - if (adapter instanceof RSESystemTypeAdapter) - { - RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)adapter; - return sysTypeAdapter.getDefaultUserId(sysType); - } - else - return null; - } - - /** - * Set the default userId per the given system type. - */ - public static void setUserIdPreference(String systemType, String userId) - { - IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemType); - RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class)); - if (sysTypeAdapter != null) - sysTypeAdapter.setDefaultUserId(sysType, userId); - else - return; - // following needs to stay in synch with modify() method in SystemTypeFieldEditor... - String value = RSEUIPlugin.getDefault().getPreferenceStore().getString(ISystemPreferencesConstants.SYSTEMTYPE_VALUES); - Hashtable keyValues = null; - if ((value == null) || (value.length()==0)) // not initialized yet? - { - keyValues = new Hashtable(); - // nothing to do, as we have read from systemTypes extension points already - } - else - { - keyValues = parseString(value); - } - - String defaultUserId = sysTypeAdapter.getDefaultUserId(sysType); - - if (defaultUserId == null) { - defaultUserId = "null"; //$NON-NLS-1$ - } - - keyValues.put(sysType.getName(), "" + sysTypeAdapter.isEnabled(sysType) + SystemTypeFieldEditor.EACHVALUE_DELIMITER + defaultUserId); //$NON-NLS-1$ - String s = SystemTypeFieldEditor.createString(keyValues); - - if (s != null) - RSEUIPlugin.getDefault().getPreferenceStore().setValue(ISystemPreferencesConstants.SYSTEMTYPE_VALUES, s); - - savePreferenceStore(); - } - - -// /** -// * Return the hashtable where the key is a string identifying a particular object, and -// * the value is the user Id for that object. -// */ -// public static Hashtable getUserIdsPerKey() // DWD remove this later -// { -// IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); -// Hashtable keyValues = null; -// String value = store.getString(ISystemPreferencesConstants.USERIDPERKEY); -// if (value != null) -// keyValues = parseString(value); -// else -// { -// keyValues = new Hashtable(); -// } -// return keyValues; -// } -// /** -// * Set/store the user ids that are saved keyed by some key. -// */ -// public static void setUserIdsPerKey(Hashtable uidsPerKey) // DWD remove this later -// { -// IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); -// store.setValue(ISystemPreferencesConstants.USERIDPERKEY, makeString(uidsPerKey)); -// savePreferenceStore(); -// } - - /** - * Return the System type to default to on the Create Connection wizard. - * - * @see SystemConnectionForm - */ - public static String getSystemTypePreference() - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return store.getString(ISystemPreferencesConstants.SYSTEMTYPE); - } - - /** - * Return the history for the folder combo box widget - */ - public static String[] getFolderHistory() - { - return getWidgetHistory(ISystemPreferencesConstants.HISTORY_FOLDER); - } - /** - * Set the history for the folder combo box widget. - */ - public static void setFolderHistory(String[] newHistory) - { - setWidgetHistory(ISystemPreferencesConstants.HISTORY_FOLDER, newHistory); - } - /** - * Return the history for a widget given an arbitrary key uniquely identifying it - */ - public static String[] getWidgetHistory(String key) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - return parseStrings(store.getString(key)); - } - /** - * Set the history for a widget given an arbitrary key uniquely identifying it. - */ - public static void setWidgetHistory(String key, String[] newHistory) - { - IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore(); - store.setValue(key, makeString(newHistory)); - savePreferenceStore(); - } - - - // ------------------------------------------------- - // MISCELLANEOUS METHODS... - // ------------------------------------------------- - - /** - * Parse out list of key-value pairs into a hashtable - */ - protected static Hashtable parseString(String allvalues) - { - StringTokenizer tokens = new StringTokenizer(allvalues, "=;"); //$NON-NLS-1$ - Hashtable keyValues = new Hashtable(10); - int count = 0; - String token1=null; - String token2=null; - while (tokens.hasMoreTokens()) - { - count++; - if ((count % 2) == 0) // even number - { - token2 = tokens.nextToken(); - keyValues.put(token1, token2); - } - else - token1 = tokens.nextToken(); - } - return keyValues; - } - /** - * Convert hashtable of key-value pairs into a single string - */ -// protected static String makeString(Hashtable keyValues) DWD remove this later -// { -// Enumeration keys = keyValues.keys(); -// StringBuffer sb = new StringBuffer(); -// while (keys.hasMoreElements()) -// { -// String key = (String)keys.nextElement(); -// String value = (String)keyValues.get(key); -// if ((value != null) && (value.length()>0)) -// { -// sb.append(key); -// sb.append('='); -// sb.append(value); -// sb.append(';'); -// } -// } -// return sb.toString(); -// } - - /** - * Parse out list of multiple values into a string array per value - */ - protected static String[] parseStrings(String allvalues) - { - if (allvalues == null) - return new String[0]; - //StringTokenizer tokens = new StringTokenizer(allvalues, ";"); - String[] tokens = allvalues.split(";"); //$NON-NLS-1$ - return tokens; - /* - Vector v = new Vector(); - int idx=0; - while (tokens.hasMoreTokens()) - v.addElement(tokens.nextToken()); - String keyValues[] = new String[v.size()]; - for (idx=0;idx0)) - { - StringTokenizer tokens = new StringTokenizer(attributes, Character.toString(EACHVALUE_DELIMITER)); - if (tokens.hasMoreTokens()) - { - attr1 = tokens.nextToken(); - if (tokens.hasMoreTokens()) - { - attr2 = tokens.nextToken(); - } - else - { - attr2 = "null"; //$NON-NLS-1$ - } - } - } - // find this system type in the array... - IRSESystemType matchingType = RSECorePlugin.getDefault().getRegistry().getSystemType(key); - RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(matchingType.getAdapter(IRSESystemType.class)); - - // update this system type's attributes as per preferences... - { - adapter.setIsEnabled(matchingType, attr1.equals("true")); //$NON-NLS-1$ - if (!attr2.equals("null")) //$NON-NLS-1$ - adapter.setDefaultUserId(matchingType, attr2); - } - } - } - return keyValues; - } +// public static Hashtable initSystemTypePreferences(IPreferenceStore store, IRSESystemType[] systemTypes) +// { +// /* this must stay in synch with the SystemPreferencesManager */ +// String value = store.getString(ISystemPreferencesConstants.SYSTEMTYPE_VALUES); +// Hashtable keyValues = null; +// if ((value == null) || (value.length()==0)) // not initialized yet? +// { +// return null; +// // nothing to do, as we have read from systemTypes extension points already +// } +// else +// { +// keyValues = parseString(value); +// // we have now a hashtable, where the keys are the system type names, +// // and the values are the column-value attributes for that type, separated +// // by a '+' character: enabled+userid. eg: "true+bob" +// Enumeration keys = keyValues.keys(); +// while (keys.hasMoreElements()) +// { +// String key = (String)keys.nextElement(); +// String attributes = (String)keyValues.get(key); +// String attr1="true", attr2=""; //$NON-NLS-1$ //$NON-NLS-2$ +// if ((attributes != null) && (attributes.length()>0)) +// { +// StringTokenizer tokens = new StringTokenizer(attributes, Character.toString(EACHVALUE_DELIMITER)); +// if (tokens.hasMoreTokens()) +// { +// attr1 = tokens.nextToken(); +// if (tokens.hasMoreTokens()) +// { +// attr2 = tokens.nextToken(); +// } +// else +// { +// attr2 = "null"; //$NON-NLS-1$ +// } +// } +// } +// // find this system type in the array... +// IRSESystemType matchingType = RSECorePlugin.getDefault().getRegistry().getSystemType(key); +// RSESystemTypeAdapter adapter = (RSESystemTypeAdapter)(matchingType.getAdapter(IRSESystemType.class)); +// +// // update this system type's attributes as per preferences... +// { +// adapter.setIsEnabled(matchingType, attr1.equals("true")); //$NON-NLS-1$ +// if (!attr2.equals("null")) //$NON-NLS-1$ +// adapter.setDefaultUserId(matchingType, attr2); +// } +// } +// } +// return keyValues; +// } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewColumnManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewColumnManager.java index 35c9714b0a2..31648265898 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewColumnManager.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewColumnManager.java @@ -53,7 +53,6 @@ public class SystemTableViewColumnManager public void setCustomDescriptors(ISystemViewElementAdapter adapter, IPropertyDescriptor[] descriptors) { putCachedDescriptors(adapter, descriptors); - SystemPreferencesManager mgr = SystemPreferencesManager.getPreferencesManager(); String historyKey = getHistoryKey(adapter); String[] history = new String[descriptors.length]; for (int i = 0; i < descriptors.length; i++) @@ -61,7 +60,7 @@ public class SystemTableViewColumnManager history[i] = descriptors[i].getId().toString(); } - mgr.setWidgetHistory(historyKey, history); + SystemPreferencesManager.setWidgetHistory(historyKey, history); } /** @@ -99,9 +98,8 @@ public class SystemTableViewColumnManager { IPropertyDescriptor[] uniqueDescriptors = adapter.getUniquePropertyDescriptors(); - SystemPreferencesManager mgr = SystemPreferencesManager.getPreferencesManager(); String historyKey = getHistoryKey(adapter); - String[] history = mgr.getWidgetHistory(historyKey); + String[] history = SystemPreferencesManager.getWidgetHistory(historyKey); // determine the order and which of the uniqueDescriptors to use based on the history if (history != null && history.length > 0) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewPart.java index 0cb9de2f4e1..ed1e339915d 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewPart.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemTableViewPart.java @@ -1665,7 +1665,7 @@ public class SystemTableViewPart extends ViewPart implements ISelectionListener, { super.init(site, memento); - if (memento != null && SystemPreferencesManager.getPreferencesManager().getRememberState()) + if (memento != null && SystemPreferencesManager.getRememberState()) { _memento = memento; @@ -1679,7 +1679,7 @@ public class SystemTableViewPart extends ViewPart implements ISelectionListener, { super.saveState(memento); - if (!SystemPreferencesManager.getPreferencesManager().getRememberState()) + if (!SystemPreferencesManager.getRememberState()) return; if (_viewer != null) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java index 7e05fb0d765..bd5e492b7fe 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java @@ -1496,7 +1496,7 @@ public class SystemView extends SafeTreeViewer implements ISystemTree, ISystemRe setExpandedState(parentSubSystem, true); // expand the subsystem Object filterParentInTree = parentSubSystem; // will be case unless in show filter pool mode // if showing filter pools, expand parent filter pool reference... - if (SystemPreferencesManager.getPreferencesManager().getShowFilterPools()) { + if (SystemPreferencesManager.getShowFilterPools()) { ISystemFilterPoolReference poolRef = parentSubSystem.getFilterPoolReferenceManager().getReferenceToSystemFilterPool(filter.getParentFilterPool()); setExpandedState(poolRef, true); filterParentInTree = poolRef; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewConnectionAdapter.java index 33f3d4ae10c..3cbaf2ba1fa 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewConnectionAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewConnectionAdapter.java @@ -403,7 +403,7 @@ public class SystemViewConnectionAdapter { String localUserId = conn.getLocalDefaultUserId(); data.setLocalValue(localUserId); - String parentUserId = SystemPreferencesManager.getPreferencesManager().getDefaultUserId(conn.getSystemType()); + String parentUserId = SystemPreferencesManager.getUserId(conn.getSystemType()); data.setInheritedValue(parentUserId); data.setIsLocal((localUserId!=null)&&(localUserId.length()>0)); //data.printDetails(); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewFilterReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewFilterReferenceAdapter.java index e459eb0b23f..2df912b6f61 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewFilterReferenceAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewFilterReferenceAdapter.java @@ -206,7 +206,7 @@ public class SystemViewFilterReferenceAdapter return parentContainer; // else parent is a filter pool. The parent will be the pool only if // we are in "Show Filter Pools" mode, else it is the subsystem. - boolean showFPs = SystemPreferencesManager.getPreferencesManager().getShowFilterPools(); + boolean showFPs = SystemPreferencesManager.getShowFilterPools(); if (showFPs) return parentContainer; else @@ -748,7 +748,7 @@ public class SystemViewFilterReferenceAdapter { Object parent = ((ISystemFilterReference) element).getParent(); //getParent(element); // will be filter (nested) or filter pool ISystemViewElementAdapter parentAdapter = getAdapter(parent); - boolean showFPs = SystemPreferencesManager.getPreferencesManager().getShowFilterPools(); + boolean showFPs = SystemPreferencesManager.getShowFilterPools(); if (parent instanceof ISystemFilterPoolReference) // not a nested filter { if (!showFPs) // not showing the real parent in GUI? diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java index 3d38be1ba22..11d16babc1e 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewPart.java @@ -777,11 +777,11 @@ public class SystemViewPart public void systemPreferenceChanged(ISystemPreferenceChangeEvent event) { if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_QUALIFYCONNECTIONNAMES) && (qualifyConnectionNamesAction != null)) - qualifyConnectionNamesAction.setChecked(SystemPreferencesManager.getPreferencesManager().getQualifyConnectionNames()); + qualifyConnectionNamesAction.setChecked(SystemPreferencesManager.getQualifyConnectionNames()); else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_SHOWFILTERPOOLS) && (showFilterPoolsAction != null)) - showFilterPoolsAction.setChecked(SystemPreferencesManager.getPreferencesManager().getShowFilterPools()); + showFilterPoolsAction.setChecked(SystemPreferencesManager.getShowFilterPools()); else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_RESTORESTATE) && (restoreStateAction != null)) - restoreStateAction.setChecked(SystemPreferencesManager.getPreferencesManager().getRememberState()); + restoreStateAction.setChecked(SystemPreferencesManager.getRememberState()); //else if ((event.getType() == ISystemPreferenceChangeEvents.EVENT_SHOWFILTERSTRINGS) && // (showFilterStringsAction != null)) @@ -934,7 +934,7 @@ public class SystemViewPart public void saveState(IMemento memento) { //System.out.println("INSIDE SAVESTATE"); - if (!SystemPreferencesManager.getPreferencesManager().getRememberState()) + if (!SystemPreferencesManager.getRememberState()) return; if (systemView == null) { @@ -960,7 +960,7 @@ public class SystemViewPart // We do this to ensure the states match on restore. If they don't we will be in trouble // restoring expansion state and hence will abandon it. - memento.putString(TAG_SHOWFILTERPOOLS, SystemPreferencesManager.getPreferencesManager().getShowFilterPools() ? "t" : "f"); //$NON-NLS-1$ //$NON-NLS-2$ + memento.putString(TAG_SHOWFILTERPOOLS, SystemPreferencesManager.getShowFilterPools() ? "t" : "f"); //$NON-NLS-1$ //$NON-NLS-2$ //memento.putString(TAG_SHOWFILTERSTRINGS, SystemPreferencesManager.getPreferencesManager().getShowFilterStrings() ? "t" : "f"); String inputMemento = memento.getString("factoryID"); // see IWorkbenchWindow ... this is only clue I can figure out! //$NON-NLS-1$ @@ -1522,7 +1522,7 @@ public class SystemViewPart { IMemento memento = _memento; //System.out.println("SYSTEMVIEWPART: restoreState"); - if (!SystemPreferencesManager.getPreferencesManager().getRememberState()) + if (!SystemPreferencesManager.getRememberState()) return Status.CANCEL_STATUS; // restore the show filter pools and show filter strings settings as they were when this was saved @@ -1548,7 +1548,7 @@ public class SystemViewPart if (savedValue != null) showFilterPools = savedValue.equals("t"); //$NON-NLS-1$ else - showFilterPools = SystemPreferencesManager.getPreferencesManager().getShowFilterPools(); + showFilterPools = SystemPreferencesManager.getShowFilterPools(); savedValue = memento.getString(TAG_SHOWFILTERSTRINGS); // historical if (savedValue != null) showFilterStrings = savedValue.equals("t"); //$NON-NLS-1$ @@ -1754,7 +1754,7 @@ public class SystemViewPart if (savedValue != null) showFilterPools = savedValue.equals("t"); //$NON-NLS-1$ else - showFilterPools = SystemPreferencesManager.getPreferencesManager().getShowFilterPools(); + showFilterPools = SystemPreferencesManager.getShowFilterPools(); savedValue = memento.getString(TAG_SHOWFILTERSTRINGS); if (savedValue != null) @@ -1861,7 +1861,7 @@ public class SystemViewPart { //System.out.println("INSIDE GETADAPTER IN SYSTEMVIEWPART. adaptableObject = "+adaptableObject+", adapterType = "+adapterType.getName()); // we don't try to restore these secondary perspectives unless user has elected to do so... - if (!SystemPreferencesManager.getPreferencesManager().getRememberState()) + if (!SystemPreferencesManager.getRememberState()) return null; else return this; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewRootInputAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewRootInputAdapter.java index db718426e30..f145d9a2694 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewRootInputAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemViewRootInputAdapter.java @@ -33,7 +33,6 @@ import org.eclipse.swt.widgets.Shell; */ public class SystemViewRootInputAdapter extends AbstractSystemViewAdapter implements ISystemViewElementAdapter { - private SystemPreferencesManager spg; private SystemNewConnectionPromptObject newConnPrompt; private Object[] newConnPromptArray; @@ -168,9 +167,7 @@ public class SystemViewRootInputAdapter extends AbstractSystemViewAdapter implem private boolean showNewConnectionPrompt() { - if (spg == null) - spg = SystemPreferencesManager.getPreferencesManager(); - return spg.getShowNewConnectionPrompt(); + return SystemPreferencesManager.getShowNewConnectionPrompt(); } private SystemNewConnectionPromptObject getNewConnectionPromptObject() diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHistoryCombo.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHistoryCombo.java index 928fadafc30..62f34118626 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHistoryCombo.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHistoryCombo.java @@ -183,7 +183,7 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave { setItems(newItems); selIdx = currentItems.length; - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, newItems); + SystemPreferencesManager.setWidgetHistory(historyKey, newItems); } if (selIdx >= 0) { @@ -273,7 +273,7 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave if (historyCombo.getItemCount() == 0) { setItems(items); - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, items); //d41439 + SystemPreferencesManager.setWidgetHistory(historyKey, items); //d41439 //updateHistory(); d41439 } } @@ -416,7 +416,7 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave */ public String[] getHistory() { - return SystemPreferencesManager.getPreferencesManager().getWidgetHistory(historyKey); + return SystemPreferencesManager.getWidgetHistory(historyKey); } /** * Update the history with current entry field setting, but don't refresh contents. @@ -477,14 +477,14 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave ++idx2; } } - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, newHistory); + SystemPreferencesManager.setWidgetHistory(historyKey, newHistory); } } else { newHistory =new String[1]; newHistory[0] = textValue; - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, newHistory); + SystemPreferencesManager.setWidgetHistory(historyKey, newHistory); } if (refresh && (newHistory != null)) { @@ -513,7 +513,7 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave */ public void setHistory(String[] newHistory) { - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, newHistory); + SystemPreferencesManager.setWidgetHistory(historyKey, newHistory); } // ----------------------- @@ -600,7 +600,7 @@ public class SystemHistoryCombo extends Composite implements ISystemCombo, Trave { String value = historyCombo.getText(); // d41471 String[] newHistory = dlg.getHistory(); - SystemPreferencesManager.getPreferencesManager().setWidgetHistory(historyKey, newHistory); + SystemPreferencesManager.setWidgetHistory(historyKey, newHistory); setItems(newHistory); historyCombo.setText(value); // Restore the value d41471 } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHostCombo.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHostCombo.java index d1c4d73c678..81b4da240a3 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHostCombo.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/SystemHostCombo.java @@ -254,7 +254,7 @@ public class SystemHostCombo extends Composite implements ISelectionProvider, IS { this.showNewButton = showNewButton; this.showLabel = showLabel; - showQualifiedNames = SystemPreferencesManager.getPreferencesManager().getQualifyConnectionNames(); + showQualifiedNames = SystemPreferencesManager.getQualifyConnectionNames(); //prepareComposite(showNewButton ? 3 : 2); prepareComposite(3); @@ -925,7 +925,7 @@ public class SystemHostCombo extends Composite implements ISelectionProvider, IS { // if RENAME, update showQualifiedNames in case it changed if ( type == EVENT_RENAME ) - showQualifiedNames = SystemPreferencesManager.getPreferencesManager().getQualifyConnectionNames(); + showQualifiedNames = SystemPreferencesManager.getQualifyConnectionNames(); refreshConnections(); } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java index 37b2466dca1..1c427727258 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/wizards/RSEDefaultNewConnectionWizardDelegate.java @@ -20,6 +20,7 @@ import java.util.Hashtable; import java.util.Vector; import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.rse.core.IRSEPreferenceNames; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.model.IHost; @@ -33,7 +34,6 @@ import org.eclipse.rse.model.DummyHost; import org.eclipse.rse.model.SystemStartHere; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemConnectionForm; import org.eclipse.rse.ui.SystemResources; @@ -129,7 +129,7 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar SystemStartHere.getSystemProfileManager().getDefaultPrivateSystemProfile(); - RSEUIPlugin.getDefault().getShowProfilePageInitially(); + // RSEUIPlugin.getShowProfilePage(); /* DKM - I don't think we should force profiles into the faces of users * we no longer default to "private" so hopefully this would never be * desirable @@ -177,7 +177,7 @@ public class RSEDefaultNewConnectionWizardDelegate extends RSENewConnectionWizar { if ((lastProfile == null) && (activeProfileNames!=null)) { - String defaultTeamName = ISystemPreferencesConstants.DEFAULT_TEAMPROFILE; + String defaultTeamName = IRSEPreferenceNames.DEFAULT_TEAMPROFILE; for (int idx=0; (lastProfile==null)&&(idx0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.clearUserId(previousUserIdKey); - prefMgr.setUserId(newKey, userIdValue); // store old value with new preference key + SystemPreferencesManager.clearUserId(previousUserIdKey); + SystemPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key } previousUserIdKey = newKey; } @@ -278,9 +276,8 @@ public class Host extends RSEModelObject implements IHost String newKey = getPreferencesKey(getSystemProfileName(), newName); if ((userIdValue != null) && (userIdValue.length()>0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.clearUserId(previousUserIdKey); - prefMgr.setUserId(newKey, userIdValue); // store old value with new preference key + SystemPreferencesManager.clearUserId(previousUserIdKey); + SystemPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key } previousUserIdKey = newKey; } @@ -338,8 +335,7 @@ public class Host extends RSEModelObject implements IHost String key = getPreferencesKey(); if (key != null) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.setUserId(key, newId); + SystemPreferencesManager.setUserId(key, newId); } } } @@ -363,8 +359,7 @@ public class Host extends RSEModelObject implements IHost String uid = getLocalDefaultUserId(); if ((uid == null) || (uid.length()==0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - uid = prefMgr.getDefaultUserId(getSystemType()); // resolve from preferences + uid = SystemPreferencesManager.getUserId(getSystemType()); // resolve from preferences if ((uid != null) && ucId) uid = uid.toUpperCase(); } @@ -379,8 +374,7 @@ public class Host extends RSEModelObject implements IHost String uid = null; if ((key!=null) && (key.length()>0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - uid = prefMgr.getUserId(key); // resolve from preferences + uid = SystemPreferencesManager.getUserId(key); // resolve from preferences } return uid; } @@ -403,17 +397,9 @@ public class Host extends RSEModelObject implements IHost public void clearLocalDefaultUserId() { if (previousUserIdKey!=null) - getPreferencesManager().clearUserId(previousUserIdKey); + SystemPreferencesManager.clearUserId(previousUserIdKey); } - /** - * Helper method to return preference manager - */ - protected static SystemPreferencesManager getPreferencesManager() - { - return SystemPreferencesManager.getPreferencesManager(); - } - /** * Helper method to compute a unique name for a given subsystem instance */ diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java index 3a2cb81ffbd..46ce6b94146 100644 --- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java +++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemHostPool.java @@ -211,6 +211,7 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool addHost(conn); // only record internally if saved successfully conn.setHostPool(this); conn.setAliasName(aliasName); + conn.setSystemType(systemType); // if default userID is null, and location is in the connection we should retrieve it and use it as the initial value. if (defaultUserId == null && defaultUserIdLocation == IRSEUserIdConstants.USERID_LOCATION_HOST) { defaultUserId = conn.getDefaultUserId(); @@ -256,13 +257,12 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool if (defaultUserIdLocation != IRSEUserIdConstants.USERID_LOCATION_HOST) { conn.setDefaultUserId(null); // clear what was there, to ensure inheritance - SystemPreferencesManager prefMgr = SystemPreferencesManager.getPreferencesManager(); boolean forceToUpperCase = conn.getForceUserIdToUpperCase(); if (forceToUpperCase && (defaultUserId != null)) defaultUserId = defaultUserId.toUpperCase(); if (defaultUserIdLocation == IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE) { - prefMgr.setDefaultUserId(systemType, defaultUserId); + SystemPreferencesManager.setDefaultUserId(systemType, defaultUserId); } //else if (defaultUserIdLocation == IRSEUserIdConstants.USERID_LOCATION_DEFAULT_OVERALL) //{ diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemProfileManager.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemProfileManager.java index 1f8ceadf675..3b9a0d59012 100644 --- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemProfileManager.java +++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/SystemProfileManager.java @@ -20,13 +20,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Vector; +import org.eclipse.rse.core.IRSEPreferenceNames; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.SystemPreferencesManager; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.model.SystemStartHere; -import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.validators.ISystemValidator; import org.eclipse.rse.ui.validators.ValidatorProfileName; @@ -104,7 +104,7 @@ public class SystemProfileManager implements ISystemProfileManager { ISystemProfile newProfile = internalCreateSystemProfileAndFolder(name); if (makeActive) { - SystemPreferencesManager.getPreferencesManager().addActiveProfile(name); + SystemPreferencesManager.addActiveProfile(name); ((SystemProfile) newProfile).setActive(makeActive); } RSEUIPlugin.getThePersistenceManager().commit(this); @@ -117,8 +117,8 @@ public class SystemProfileManager implements ISystemProfileManager { public void makeSystemProfileActive(ISystemProfile profile, boolean makeActive) { boolean wasActive = isSystemProfileActive(profile.getName()); if (wasActive && !makeActive) - SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(profile.getName()); - else if (makeActive && !wasActive) SystemPreferencesManager.getPreferencesManager().addActiveProfile(profile.getName()); + SystemPreferencesManager.deleteActiveProfile(profile.getName()); + else if (makeActive && !wasActive) SystemPreferencesManager.addActiveProfile(profile.getName()); ((SystemProfile) profile).setActive(makeActive); } @@ -183,7 +183,7 @@ public class SystemProfileManager implements ISystemProfileManager { if (!defaultProfileExist) { for (int idx = 0; (!defaultProfileExist) && (idx < profiles.size()); idx++) { ISystemProfile profile = (ISystemProfile) profiles.get(idx); - if (!profile.getName().equalsIgnoreCase(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE)) { + if (!profile.getName().equalsIgnoreCase(IRSEPreferenceNames.DEFAULT_TEAMPROFILE)) { profile.setDefaultPrivate(true); RSEUIPlugin.getThePersistenceManager().commit(SystemStartHere.getSystemProfileManager()); @@ -259,7 +259,7 @@ public class SystemProfileManager implements ISystemProfileManager { boolean isActive = isSystemProfileActive(profile.getName()); String oldName = profile.getName(); profile.setName(newName); - if (isActive) SystemPreferencesManager.getPreferencesManager().renameActiveProfile(oldName, newName); + if (isActive) SystemPreferencesManager.renameActiveProfile(oldName, newName); invalidateCache(); // FIXME RSEUIPlugin.getThePersistenceManager().save(this); } @@ -278,7 +278,7 @@ public class SystemProfileManager implements ISystemProfileManager { * if (res != null) * res.getContents().remove(profile); */ - if (isActive) SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(oldName); + if (isActive) SystemPreferencesManager.deleteActiveProfile(oldName); invalidateCache(); if (persist) { RSEUIPlugin.getThePersistenceManager().deleteProfile(oldName); @@ -322,7 +322,7 @@ public class SystemProfileManager implements ISystemProfileManager { * @see org.eclipse.rse.core.model.ISystemProfileManager#getActiveSystemProfileNames() */ public String[] getActiveSystemProfileNames() { - String[] activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames(); + String[] activeProfileNames = SystemPreferencesManager.getActiveProfiles(); // dy: defect 48355, need to sync this with the actual profile list. If the user // imports old preference settings or does a team sync and a profile is deleted then // it is possible an active profile no longer exists. @@ -339,7 +339,7 @@ public class SystemProfileManager implements ISystemProfileManager { String activeProfileName = activeProfileNames[activeIdx]; if (activeProfileName.equals(defaultProfileName)) { found_private = true; - } else if (activeProfileName.equals(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE)) { + } else if (activeProfileName.equals(IRSEPreferenceNames.DEFAULT_TEAMPROFILE)) { found_team = true; } else { found = false; @@ -351,7 +351,7 @@ public class SystemProfileManager implements ISystemProfileManager { if (!found) { // The active profile no longer exists so remove it from the active list - SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(activeProfileNames[activeIdx]); + SystemPreferencesManager.deleteActiveProfile(activeProfileNames[activeIdx]); changed = true; } } @@ -370,9 +370,9 @@ public class SystemProfileManager implements ISystemProfileManager { } if (!matchesBoth && found_private) { if (systemProfiles[systemIdx].isActive() || systemProfiles[systemIdx].isDefaultPrivate()) { - SystemPreferencesManager.getPreferencesManager().addActiveProfile(name); - SystemPreferencesManager.getPreferencesManager().deleteActiveProfile(RSECorePlugin.getLocalMachineName()); - activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames(); + SystemPreferencesManager.addActiveProfile(name); + SystemPreferencesManager.deleteActiveProfile(RSECorePlugin.getLocalMachineName()); + activeProfileNames = SystemPreferencesManager.getActiveProfiles(); } } } @@ -384,24 +384,24 @@ public class SystemProfileManager implements ISystemProfileManager { // First time user, make sure default is in the active list, the only time it wouldn't // be is if the pref_store.ini was modified (because the user imported old preferences) if (!found_team) { - SystemPreferencesManager.getPreferencesManager().addActiveProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE); + SystemPreferencesManager.addActiveProfile(IRSEPreferenceNames.DEFAULT_TEAMPROFILE); changed = true; } if (!found_private) { - SystemPreferencesManager.getPreferencesManager().addActiveProfile(RSECorePlugin.getLocalMachineName()); + SystemPreferencesManager.addActiveProfile(RSECorePlugin.getLocalMachineName()); changed = true; } } else { ISystemProfile defaultProfile = getDefaultPrivateSystemProfile(); if (defaultProfile != null && !found_private) { - SystemPreferencesManager.getPreferencesManager().addActiveProfile(defaultProfile.getName()); + SystemPreferencesManager.addActiveProfile(defaultProfile.getName()); changed = true; } } if (changed) { - activeProfileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames(); + activeProfileNames = SystemPreferencesManager.getActiveProfiles(); } } @@ -412,7 +412,7 @@ public class SystemProfileManager implements ISystemProfileManager { * @return the profile names currently selected by the user as "active" profiles */ public Vector getActiveSystemProfileNamesVector() { - String[] profileNames = SystemPreferencesManager.getPreferencesManager().getActiveProfileNames(); + String[] profileNames = SystemPreferencesManager.getActiveProfiles(); Vector v = new Vector(profileNames.length); for (int idx = 0; idx < profileNames.length; idx++) v.addElement(profileNames[idx]); @@ -442,7 +442,7 @@ public class SystemProfileManager implements ISystemProfileManager { * @see org.eclipse.rse.core.model.ISystemProfileManager#getDefaultTeamSystemProfile() */ public ISystemProfile getDefaultTeamSystemProfile() { - return getSystemProfile(ISystemPreferencesConstants.DEFAULT_TEAMPROFILE); + return getSystemProfile(IRSEPreferenceNames.DEFAULT_TEAMPROFILE); } /** diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemRegistry.java index f7825637ba4..2c473d7dbf2 100644 --- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/SystemRegistry.java @@ -681,14 +681,14 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven */ public boolean getQualifiedHostNames() { - return SystemPreferencesManager.getPreferencesManager().getQualifyConnectionNames(); + return SystemPreferencesManager.getQualifyConnectionNames(); } /** * Set if connection names are to be qualified by profile name */ public void setQualifiedHostNames(boolean set) { - SystemPreferencesManager.getPreferencesManager().setQualifyConnectionNames(set); + SystemPreferencesManager.setQualifyConnectionNames(set); IHost[] conns = getHosts(); if (conns != null) { @@ -697,7 +697,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven fireEvent(new SystemResourceChangeEvent(conns[idx], ISystemResourceChangeEvents.EVENT_RENAME, this)); } } - if (SystemPreferencesManager.getPreferencesManager().getShowFilterPools()) + if (SystemPreferencesManager.getShowFilterPools()) { fireEvent(new SystemResourceChangeEvent(this, ISystemResourceChangeEvents.EVENT_REFRESH, this)); } @@ -892,7 +892,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven ssf.renameSubSystemProfile(ss, oldName, newName); } } - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list boolean namesQualifed = getQualifiedHostNames(); if (namesQualifed) setQualifiedHostNames(namesQualifed); // causes refresh events to be fired @@ -1072,7 +1072,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven } // last step... physically blow away the profile... getSystemProfileManager().deleteSystemProfile(profile, true); - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list if (connections.length > 0) // defect 42112 fireEvent(new org.eclipse.rse.model.SystemResourceChangeEvent(connections, ISystemResourceChangeEvents.EVENT_DELETE_MANY, this)); @@ -1166,7 +1166,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven SystemResourceChangeEvent event = new org.eclipse.rse.model.SystemResourceChangeEvent(affectedConnections, ISystemResourceChangeEvents.EVENT_ADD_MANY, this); fireEvent(event); } - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list fireModelChangeEvent(SYSTEM_RESOURCE_CHANGED, SYSTEM_RESOURCETYPE_PROFILE, profile, null); } @@ -2250,7 +2250,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven } RSEUIPlugin.getThePersistenceManager().commit(conn); - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list return conn; @@ -2555,7 +2555,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).deleteSubSystemsByConnection(conn); } conn.getHostPool().deleteHost(conn); // delete from memory and from disk. - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list fireModelChangeEvent(SYSTEM_RESOURCE_REMOVED, SYSTEM_RESOURCETYPE_CONNECTION, conn, null); } @@ -2580,7 +2580,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven for (int idx = 0; idx < affectedSubSystemFactories.size(); idx++) ((ISubSystemConfiguration) affectedSubSystemFactories.elementAt(idx)).renameSubSystemsByConnection(conn, newName); conn.getHostPool().renameHost(conn, newName); // rename in memory and disk - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); // update preferences order list + SystemPreferencesManager.setConnectionNamesOrder(); // update preferences order list fireModelChangeEvent(SYSTEM_RESOURCE_RENAMED, SYSTEM_RESOURCETYPE_CONNECTION, conn, oldName); } @@ -2601,7 +2601,7 @@ public class SystemRegistry implements ISystemRegistryUI, ISystemModelChangeEven { ISystemHostPool pool = getHostPool(profileName); pool.moveHosts(conns, delta); - SystemPreferencesManager.getPreferencesManager().setConnectionNamesOrder(); + SystemPreferencesManager.setConnectionNamesOrder(); //fireEvent(new SystemResourceChangeEvent(pool.getSystemConnections(),ISystemResourceChangeEvent.EVENT_MOVE_MANY,this)); SystemResourceChangeEvent event = new SystemResourceChangeEvent(conns, ISystemResourceChangeEvents.EVENT_MOVE_MANY, this); event.setPosition(delta); diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index 29f84bda024..4f552fc2221 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -255,9 +255,8 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS String newKey = getPreferencesKey(newName, getHostAliasName()); if ((userIdValue != null) && (userIdValue.length()>0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.clearUserId(previousUserIdKey); - prefMgr.setUserId(newKey, userIdValue); // store old value with new preference key + SystemPreferencesManager.clearUserId(previousUserIdKey); + SystemPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key } previousUserIdKey = newKey; @@ -304,9 +303,8 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS String newKey = getPreferencesKey(getSystemProfileName(), newName); if ((userIdValue != null) && (userIdValue.length()>0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.clearUserId(previousUserIdKey); - prefMgr.setUserId(newKey, userIdValue); // store old value with new preference key + SystemPreferencesManager.clearUserId(previousUserIdKey); + SystemPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key } previousUserIdKey = newKey; @@ -341,8 +339,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS // value (the actual user id) the old keyed entry held. if (oldUserId != null) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - prefMgr.clearUserId(previousUserIdKey); + SystemPreferencesManager.clearUserId(previousUserIdKey); } // delete the connection-private filter pool, if it exists: ISystemFilterPool privatePool = getConnectionPrivateFilterPool(false); // false => don't create if not found @@ -384,14 +381,6 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS return uid; } - /** - * Helper method to return preference manager - */ - protected SystemPreferencesManager getPreferencesManager() - { - return SystemPreferencesManager.getPreferencesManager(); - } - /** * Helper method to compute a unique name for a given subsystem instance */ @@ -419,8 +408,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS String uid = null; if ((key!=null) && (key.length()>0)) { - SystemPreferencesManager prefMgr = getPreferencesManager(); - uid = prefMgr.getUserId(key); // resolve from preferences + uid = SystemPreferencesManager.getUserId(key); // resolve from preferences } return uid; } @@ -456,7 +444,7 @@ public abstract class SubSystem extends RSEModelObject implements IAdaptable, IS public void clearLocalUserId() { if (previousUserIdKey != null) - getPreferencesManager().clearUserId(previousUserIdKey); + SystemPreferencesManager.clearUserId(previousUserIdKey); IConnectorService system = getConnectorService(); if (system != null) system.clearUserIdCache(); diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java index 1db0f93fde5..4dd5ef51f5e 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java @@ -585,7 +585,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration */ public boolean showFilterPools() { - return SystemPreferencesManager.getPreferencesManager().getShowFilterPools(); + return SystemPreferencesManager.getShowFilterPools(); } /* * If we support filters, should we show filter strings in the remote system explorer? diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java index efec3af9e1a..8a3808496ef 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java +++ b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemPreferencesManager.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2000, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2000, 2007 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 @@ -13,8 +13,8 @@ * Contributors: * {Name} (company) - description of contribution. ********************************************************************************/ - package org.eclipse.rse.core; + import java.util.Arrays; import java.util.Enumeration; import java.util.Hashtable; @@ -24,16 +24,15 @@ import java.util.TreeSet; import java.util.Vector; import org.eclipse.core.runtime.Preferences; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.internal.model.SystemProfileManager; import org.eclipse.rse.ui.ISystemPreferencesConstants; import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.propertypages.RemoteSystemsPreferencePage; - /** - * A class that encapsulates all global preferences for the remote system framework + * A utility class that encapsulates all global preferences for the remote system framework + * for both core and UI preferences. *

* These include: *

+ * This class should not be subclassed. */ -public class SystemPreferencesManager - implements ISystemPreferencesConstants -{ +public class SystemPreferencesManager { - private static SystemPreferencesManager inst; -// private Hashtable userIdsPerKey = null; - /** - * - */ - protected SystemPreferencesManager() - { - } - - /** - * Get singleton of this class - */ - public static SystemPreferencesManager getPreferencesManager() - { - if (inst == null) - inst = new SystemPreferencesManager(); - return inst; - } - - // ------------------------- - // ACTIVE PROFILE METHODS... - // ------------------------- - - /** - * Return active profile names - */ - public String[] getActiveProfileNames() - { - return RemoteSystemsPreferencePage.getActiveProfiles(); - } - - /** - * Rename one of the active profile names in the list of names stored in the registry. - */ - public void renameActiveProfile(String oldName, String newName) - { - // update active profile name list - String[] names = getActiveProfileNames(); - int matchPos = -1; - for (int idx=0; (matchPos==-1) && (idx= 0) - RemoteSystemsPreferencePage.setActiveProfiles(names); - } - /** - * Delete one of the active profile names in the list of names stored in the registry. - */ - public void deleteActiveProfile(String oldName) - { - String[] names = getActiveProfileNames(); - int matchPos = -1; - for (int idx=0; (matchPos==-1) && (idx= 0) - RemoteSystemsPreferencePage.setActiveProfiles(names); - } - /** - * Add a name to the active profile list. A name already in the list is not added again. - * The list remains sorted in the natural order. - */ - public void addActiveProfile(String newName) - { - SortedSet names = new TreeSet(Arrays.asList(getActiveProfileNames())); - names.add(newName); - String[] newNames = new String[names.size()]; - names.toArray(newNames); - RemoteSystemsPreferencePage.setActiveProfiles(newNames); - } + /* + * The following are preferences that may be set from the + * system properties. + */ + private static boolean showLocalConnection; + private static boolean showProfilePage; + private static boolean showNewConnectionPrompt; - /** - * Return the position of a give profile name in the active list - */ - public int getActiveProfilePosition(String profileName) - { - String[] names = getActiveProfileNames(); - int matchPos = -1; - for (int idx=0; (matchPos==-1) && (idx., or ., or - * ... - */ - public void setUserId(String key, String userId) { - if ((key != null) && (userId != null)) { - Hashtable userIds = getUserIds(); - String storedUserId = (String) userIds.get(key); - if (storedUserId == null || !storedUserId.equals(userId)) { // don't bother updating if its already there - userIds.put(key, userId); - setUserIds(userIds); - } + private static void migrateCorePreference(String preferenceName) { + String name = ISystemPreferencesConstants.ROOT + preferenceName; + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + if (store.contains(name)) { + String value = store.getString(name); + String defaultValue = store.getDefaultString(name); + store.setToDefault(name); + store.setDefault(name, "*migrated*"); //$NON-NLS-1$ + store = RSECorePlugin.getDefault().getPluginPreferences(); + store.setDefault(preferenceName, defaultValue); + store.setValue(preferenceName, value); } } - - /** - * Clear the user Id for the given key - */ - public void clearUserId(String key) - { - Hashtable userIds = getUserIds(); - if (userIds.containsKey(key)) - { - userIds.remove(key); - setUserIds(userIds); - } - } - - /** - * Return the hashtable where the key is a string identifying a particular object, and - * the value is the user Id for that object. - */ - public static Hashtable getUserIds() { - Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); - Hashtable userIds = null; - String value = store.getString(ISystemPreferencesConstants.USERIDPERKEY); - if (value != null) { - userIds = parseString(value); - } else { - userIds = new Hashtable(); - } - return userIds; - } /** - * Set/store the user ids that are saved keyed by some key. + * Determines if a string (the needle) is present in an array of strings (the haystack) + * @param haystack an array of strings to search + * @param needle the string for which to search + * @return true if the needle was found */ - public static void setUserIds(Hashtable userIds) { - Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); - String userIdsString = makeString(userIds); - store.setValue(ISystemPreferencesConstants.USERIDPERKEY, userIdsString); - RSECorePlugin.getDefault().savePluginPreferences(); + private static boolean find(String[] haystack, String needle) { + for (int idx = 0; idx < haystack.length; idx++) { + if (haystack[idx].equals(needle)) return true; + } + return false; } /** - * Convert hashtable of key-value pairs into a single string + * Convert table of key-value pairs into a single string. Each (name, value) pair is + * encoded as "name=value;" thus no keys or values in the string may + * contain semi-colons or equal signs. + * @param table a Hashtable to convert + * @return the string containing the converted table */ - protected static String makeString(Hashtable table) { + private static String makeString(Hashtable table) { Enumeration keys = table.keys(); StringBuffer sb = new StringBuffer(20 * table.size()); while (keys.hasMoreElements()) { @@ -357,160 +116,717 @@ public class SystemPreferencesManager } return sb.toString(); } - + /** - * Parse out list of key-value pairs into a hashtable + * Parse out list of key-value pairs into a hashtable. This is the inverse of the + * {@link #makeString(Hashtable)} operation. + * @param allValues the string containing the key-value pairs. If empty or null returns + * and empty Hashtable. + * @return the reconstituted Hashtable */ - protected static Hashtable parseString(String allvalues) { - StringTokenizer tokens = new StringTokenizer(allvalues, "=;"); //$NON-NLS-1$ + private static Hashtable parseString(String allValues) { Hashtable keyValues = new Hashtable(10); - int count = 0; - String token1 = null; - String token2 = null; - while (tokens.hasMoreTokens()) { - count++; - if ((count % 2) == 0) // even number - { - token2 = tokens.nextToken(); - keyValues.put(token1, token2); - } else - token1 = tokens.nextToken(); + if (allValues != null) { + StringTokenizer tokens = new StringTokenizer(allValues, "=;"); //$NON-NLS-1$ + int count = 0; + String token1 = null; + String token2 = null; + while (tokens.hasMoreTokens()) { + count++; + if ((count % 2) == 0) // even number + { + token2 = tokens.nextToken(); + keyValues.put(token1, token2); + } else + token1 = tokens.nextToken(); + } } return keyValues; } - - // ---------------------- - // GETTER METHODS... - // ---------------------- - /** - * Return whether to show connection names qualified by profile name - */ - public boolean getQualifyConnectionNames() - { - return RemoteSystemsPreferencePage.getQualifyConnectionNamesPreference(); - } - - /** - * Return whether to show filter pools or not - */ - public boolean getShowFilterPools() - { - return RemoteSystemsPreferencePage.getShowFilterPoolsPreference(); - } - /** - * Return whether to remember state or not in Remote Systems view - */ - public boolean getRememberState() - { - return RemoteSystemsPreferencePage.getRememberStatePreference(); - } - /** - * Return whether to show "New Connection..." prompt - */ - public boolean getShowNewConnectionPrompt() - { - return RemoteSystemsPreferencePage.getShowNewConnectionPromptPreference(); - } - /** - * Return whether to cascade user actions menu by profile - */ - public static boolean getCascadeUserActionsPreference() - { - return RemoteSystemsPreferencePage.getCascadeUserActionsPreference(); - } - /** - * Return whether to turn on "Verify connection" checkbox on the New Connection wizard - */ - public boolean getVerifyConnection() - { - IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); + /** + * Make a single string out of an array of strings. A semi-colon is + * used as a delimiter between the separate values. No value in the + * array can contain a semi-colon. + * @param values the array of strings to condense into a single one + * @return the condensed string + */ + private static String makeString(String[] values) { + StringBuffer allValues = new StringBuffer(20 * values.length); + for (int idx = 0; idx < values.length; idx++) { + if (values[idx] != null) { + if (idx > 0) { + allValues = allValues.append(';'); + } + allValues.append(values[idx]); + } + } + return allValues.toString(); + } + + /** + * Parse out list of multiple values into a string array per value. + * This is the inverse of the {@link #makeString(String[])} operation. + * @param allvalues the string holding the condensed value + * @return the reconstituted array of strings. + */ + private static String[] parseStrings(String allvalues) { + if (allvalues == null) return new String[0]; + String[] tokens = allvalues.split(";"); //$NON-NLS-1$ + return tokens; + } + + /** + * Initialize our preference store with our defaults. + * This is called once at plugin startup. + */ + public static void initDefaults() { + migrateCorePreferences(); + initDefaultsCore(); + initDefaultsUI(); + initDefaultsComm(); + savePreferences(); + } + + private static void initDefaultsUI() { + RSEUIPlugin ui = RSEUIPlugin.getDefault(); + Preferences store = ui.getPluginPreferences(); + showNewConnectionPrompt= getBooleanProperty("rse.showNewConnectionPrompt", ISystemPreferencesConstants.DEFAULT_SHOWNEWCONNECTIONPROMPT); //$NON-NLS-1$ + showLocalConnection = getBooleanProperty("rse.showLocalConnection", true); //$NON-NLS-1$ + showProfilePage = getBooleanProperty("rse.showProfilePage", false); //$NON-NLS-1$ + store.setDefault(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE, ISystemPreferencesConstants.DEFAULT_RESTORE_STATE_FROM_CACHE); + store.setDefault(ISystemPreferencesConstants.QUALIFY_CONNECTION_NAMES, ISystemPreferencesConstants.DEFAULT_QUALIFY_CONNECTION_NAMES); + store.setDefault(ISystemPreferencesConstants.SHOWFILTERPOOLS, ISystemPreferencesConstants.DEFAULT_SHOWFILTERPOOLS); + store.setDefault(ISystemPreferencesConstants.ORDER_CONNECTIONS, ISystemPreferencesConstants.DEFAULT_ORDER_CONNECTIONS); + store.setDefault(ISystemPreferencesConstants.HISTORY_FOLDER, ISystemPreferencesConstants.DEFAULT_HISTORY_FOLDER); + store.setDefault(ISystemPreferencesConstants.REMEMBER_STATE, ISystemPreferencesConstants.DEFAULT_REMEMBER_STATE); + store.setDefault(ISystemPreferencesConstants.CASCADE_UDAS_BYPROFILE, ISystemPreferencesConstants.DEFAULT_CASCADE_UDAS_BYPROFILE); + store.setDefault(ISystemPreferencesConstants.SHOWNEWCONNECTIONPROMPT, showNewConnectionPrompt); + savePreferences(); + } + + private static boolean getBooleanProperty(String propertyName, boolean defaultValue) { + String property = System.getProperty(propertyName); + boolean value = (property == null) ? defaultValue : property.equals(Boolean.toString(true)); + return value; + } + + private static void initDefaultsCore() { + String defaultProfileNames = IRSEPreferenceNames.DEFAULT_ACTIVEUSERPROFILES; + String userProfileName = SystemProfileManager.getDefaultPrivateSystemProfileName(); + defaultProfileNames += ";" + userProfileName; //$NON-NLS-1$ + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + store.setDefault(IRSEPreferenceNames.SYSTEMTYPE, IRSEPreferenceNames.DEFAULT_SYSTEMTYPE); + store.setDefault(IRSEPreferenceNames.ACTIVEUSERPROFILES, defaultProfileNames); + store.setDefault(IRSEPreferenceNames.USE_DEFERRED_QUERIES, IRSEPreferenceNames.DEFAULT_USE_DEFERRED_QUERIES); + savePreferences(); + } + + /** + * Set default communications preferences + */ + private static void initDefaultsComm() { + RSEUIPlugin ui = RSEUIPlugin.getDefault(); + Preferences store = ui.getPluginPreferences(); + store.setDefault(ISystemPreferencesConstants.DAEMON_AUTOSTART, ISystemPreferencesConstants.DEFAULT_DAEMON_AUTOSTART); + store.setDefault(ISystemPreferencesConstants.DAEMON_PORT, ISystemPreferencesConstants.DEFAULT_DAEMON_PORT); + ui.savePluginPreferences(); + } + + public static boolean getShowLocalConnection() { + return showLocalConnection; + } + + public static boolean getShowProfilePage() { + return showProfilePage; + } + + /** + * @return the Hashtable where the key is a string identifying a particular object, and + * the value is the user ID for that object. + * @see #setUserId(String, String) + */ + private static Hashtable getUserIds() { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + Hashtable userIds = null; + String value = store.getString(IRSEPreferenceNames.USERIDPERKEY); + if (value != null) { + userIds = parseString(value); + } else { + userIds = new Hashtable(); + } + return userIds; + } + + /** + * Store the user ids that are saved keyed by some key. + * @param userIds A Hashtable of userids. + * @see #setUserId(String, String) + */ + private static void setUserIds(Hashtable userIds) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String userIdsString = makeString(userIds); + store.setValue(IRSEPreferenceNames.USERIDPERKEY, userIdsString); + savePreferences(); + } + + /** + * Retrieves a user id given a key. + * @param key the key from which to get the particular user id. + * @return user ID for the given key or null if the key was not found. + * @see #setUserId(String, String) + */ + public static String getUserId(String key) { + String uid = null; + Hashtable userIds = getUserIds(); + uid = (String) userIds.get(key); + return uid; + } + + /** + * Clears the user ID for the given key. + * @param key the key for the user id. + * @see #setUserId(String, String) + */ + public static void clearUserId(String key) { + Hashtable userIds = getUserIds(); + if (userIds.containsKey(key)) { + userIds.remove(key); + setUserIds(userIds); + } + } + + /** + * Sets the user Id for this key. + * The key typically designates a scope for this userid so that a hierarchy + * of user ids can be maintained for inheritance. + * For example, hosts have greater scope than subsystems. + * A key would typically be ., + * or ., + * or ... + * @param key the key used to find the userId + * @param userId the userId to retrieve by this key. + */ + public static void setUserId(String key, String userId) { + if ((key != null) && (userId != null)) { + Hashtable userIds = getUserIds(); + String storedUserId = (String) userIds.get(key); + if (storedUserId == null || !storedUserId.equals(userId)) { // don't bother updating if its already there + userIds.put(key, userId); + setUserIds(userIds); + } + } + } + + /** + * Gets the default user id for a given system type. + * @param systemType the systemtype for which to retrieve the default user id + * @return The default user id + */ + public static String getDefaultUserId(IRSESystemType systemType) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String key = getSystemTypePreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID); + if (!store.contains(key)) { + store.setDefault(key, System.getProperty("user.name")); //$NON-NLS-1$ + } + String result = store.getString(key); + return result; + } + + /** + * Sets the default userId for the given system type. + * @param systemTypeName the name of the system type + * @param userId the default user id for this system type. + * This may be null to "unset" the default. + */ + public static void setDefaultUserId(String systemTypeName, String userId) { + IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(systemTypeName); + if (systemType != null) { + setDefaultUserId(systemType, userId); + } + } + + /** + * Sets the default userId for the given system type. + * @param systemType the system type for which to set the default + * @param userId the default user id for this system type. + * This may be null to "unset" the default. + */ + public static void setDefaultUserId(IRSESystemType systemType, String userId) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String key = getSystemTypePreferencesKey(systemType, IRSEPreferenceNames.ST_DEFAULT_USERID); + store.setValue(key, userId); + savePreferences(); + } + + /** + * Gets the system type values table for editing. This is a synthesized preference + * that is handled as a single value. Rows are separated by semi-colons. + * Each row is of the format =+; + * @return the table of system types formatted as a single string + */ + public static String getSystemTypeValues() { + IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes(); + StringBuffer buffer = new StringBuffer(100); + for (int i = 0; i < systemTypes.length; i++) { + IRSESystemType systemType = systemTypes[i]; + buffer.append(systemType.getName()); + buffer.append('='); + buffer.append(getIsSystemTypeEnabled(systemType)); + buffer.append('+'); + buffer.append(getDefaultUserId(systemType)); + buffer.append(';'); + } + String result = buffer.toString(); + return result; + } + + /** + * @return the system type to default when no explicit system type is available. + */ + public static String getSystemType() { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String result = store.getString(IRSEPreferenceNames.SYSTEMTYPE); + return result; + } + + /** + * Sets the system type to default when no explicit system type is available. + * @param systemType the string giving the system type name. + */ + public static void setSystemType(String systemType) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + store.setValue(IRSEPreferenceNames.SYSTEMTYPE, systemType); + savePreferences(); + } + + /** + * Sets the default user id and enabled state for all system types. + * @param systemTypeValues a tabled encoded as a string that contains + * entries for each system type. See {@link #getSystemTypeValues()} for the + * table format. + */ + public static void setSystemTypeValues(String systemTypeValues) { + IRSECoreRegistry registry = RSECorePlugin.getDefault().getRegistry(); + Hashtable table = parseString(systemTypeValues); + Enumeration e = table.keys(); + while (e.hasMoreElements()) { + String key = (String) e.nextElement(); + String compoundValue = (String) table.get(key); + String[] values = compoundValue.split("\\+"); //$NON-NLS-1$ + String isEnabled = values[0]; + String defaultUserId = values[1]; + IRSESystemType systemType = registry.getSystemType(key); + setIsSystemTypeEnabled(systemType, isEnabled.equals("true")); //$NON-NLS-1$ + setDefaultUserId(systemType, defaultUserId); + } + } + + /** + * Sets if a system type is enabled. + * @param systemType the system type to be enabled on this machine. + * @param isEnabled the enabled state + */ + public static void setIsSystemTypeEnabled(IRSESystemType systemType, boolean isEnabled) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String key = getSystemTypePreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED); + if (!store.contains(key)) { + store.setDefault(key, true); + } + store.setValue(key, isEnabled); + savePreferences(); + } + + /** + * Gets the enabled state for a particular system type. + * @param systemType the system type + * @return the enabled state of that type + */ + public static boolean getIsSystemTypeEnabled(IRSESystemType systemType) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String key = getSystemTypePreferencesKey(systemType, IRSEPreferenceNames.ST_ENABLED); + if (!store.contains(key)) { + store.setDefault(key, true); + } + boolean result = store.getBoolean(key); + return result; + } + + private static String getSystemTypePreferencesKey(IRSESystemType systemType, String preference) { + String key = systemType.getName() + "." + preference; //$NON-NLS-1$ + return key; + } + + /** + * @return the names of the profiles the user has elected to make active. + */ + public static String[] getActiveProfiles() { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + String value = store.getString(IRSEPreferenceNames.ACTIVEUSERPROFILES); + String[] result = parseStrings(value); + return result; + } + + /** + * Sets the names of the profiles the user has elected to make "active". + * The caller must also save the preferences when completing. + * @see #savePreferences() + * @param newProfileNames an array of profile names considered to be active. + */ + private static void setActiveProfiles(String[] newProfileNames) { + Preferences store = RSECorePlugin.getDefault().getPluginPreferences(); + store.setValue(IRSEPreferenceNames.ACTIVEUSERPROFILES, makeString(newProfileNames)); + savePreferences(); + } + + /** + * Add a name to the active profile list. + * A name already in the list is not added again. + * The list remains sorted in the natural order. + * @param newName a new active profile name + */ + public static void addActiveProfile(String newName) { + SortedSet names = new TreeSet(Arrays.asList(getActiveProfiles())); + names.add(newName); + String[] newNames = new String[names.size()]; + names.toArray(newNames); + SystemPreferencesManager.setActiveProfiles(newNames); + savePreferences(); + } + + /** + * Delete one of the active profile names in the list of names stored in the registry. + * @param oldName the name of the profile to remove from the active profiles list. + */ + public static void deleteActiveProfile(String oldName) { + String[] names = getActiveProfiles(); + int matchPos = -1; + for (int idx = 0; (matchPos == -1) && (idx < names.length); idx++) { + if (names[idx].equalsIgnoreCase(oldName)) { + matchPos = idx; + names[idx] = null; + } + } + if (matchPos >= 0) { + SystemPreferencesManager.setActiveProfiles(names); + savePreferences(); + } + } + + /** + * @param profileName the name of the profile to search for in the list of active profiles. + * @return the zero-based position of a give profile name in the active list + */ + public static int getActiveProfilePosition(String profileName) { + String[] names = getActiveProfiles(); + int matchPos = -1; + for (int idx = 0; (matchPos == -1) && (idx < names.length); idx++) { + if (names[idx].equalsIgnoreCase(profileName)) matchPos = idx; + } + return matchPos; + } + + /** + * Renames one of the active profile names in the list of names stored in the registry. + * This is usually employed after renaming a profile to ensure that the active names + * list stays in synch with the actual profile names. The active state of the profiles + * cannot be kept in the profiles themselves since that can vary from workspace to workspace + * for profiles that are shared in a team. + * @param oldName the old name of the profile + * @param newName the new name of the profile + */ + public static void renameActiveProfile(String oldName, String newName) { + // update active profile name list + String[] names = getActiveProfiles(); + int matchPos = -1; + for (int idx = 0; (matchPos == -1) && (idx < names.length); idx++) { + if (names[idx].equalsIgnoreCase(oldName)) { + matchPos = idx; + names[idx] = newName; + } + } + if (matchPos >= 0) { + SystemPreferencesManager.setActiveProfiles(names); + savePreferences(); + } + } + + /** + * @return true if the user has elected to show user defined actions cascaded by profile + */ + public static boolean getCascadeUserActions() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return store.getBoolean(ISystemPreferencesConstants.CASCADE_UDAS_BYPROFILE); + } + + /** + * Sets if the user has elected to show user defined actions cascaded by profile. + * Does not save the preferences. This must be done by the caller. + * @see #savePreferences() + * @param cascade whether or not to cascade user action menus + */ + public static void setCascadeUserActions(boolean cascade) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.CASCADE_UDAS_BYPROFILE, cascade); + } + + /** + * @return the ordered list of connection names. + * This is how user arranged his connections in the system view. + */ + public static String[] getConnectionNamesOrder() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return parseStrings(store.getString(ISystemPreferencesConstants.ORDER_CONNECTIONS)); + } + + /** + * Gets the user's preference for the order of the connection names within a given profile + * @param profileName the name of the profile to return the connection names for. + * @return an array of connection names for this profile in the order preferred by the user. + */ + public static String[] getConnectionNamesOrder(String profileName) { + String[] allConnectionNamesOrder = SystemPreferencesManager.getConnectionNamesOrder(); + profileName = profileName + "."; //$NON-NLS-1$ + int profileNameLength = profileName.length(); + Vector v = new Vector(); + for (int idx = 0; idx < allConnectionNamesOrder.length; idx++) + if (allConnectionNamesOrder[idx].startsWith(profileName)) { + v.addElement(allConnectionNamesOrder[idx].substring(profileNameLength)); + } + String[] names = new String[v.size()]; + for (int idx = 0; idx < names.length; idx++) { + names[idx] = (String) v.elementAt(idx); + } + return names; + } + + /** + * Gets the user's preference for the order of a given list of connections, + * after resolving it against the actual list of connection names contained within + * a specified profile. + * Connections not in the given profile will be ignored. + * @param realityConnectionList The list of connections that will be reordered according to + * the user's preferred ordering. + * @param profileName the name of the profile that we will search for these connections. + * @return the list of connection names from the given list and profile in the order + * preferred by the user. + */ + public static String[] getConnectionNamesOrder(IHost[] realityConnectionList, String profileName) { + if (realityConnectionList == null) return new String[0]; + String[] realityNames = new String[realityConnectionList.length]; + for (int idx = 0; idx < realityConnectionList.length; idx++) { + realityNames[idx] = realityConnectionList[idx].getAliasName(); + } + String[] names = resolveOrderPreferenceVersusReality(realityNames, getConnectionNamesOrder(profileName)); + return names; + } + + /** + * Sets user's preference for the order of the connection names according to the + * list kept in the system registry. + */ + public static void setConnectionNamesOrder() { + ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); + IHost[] conns = sr.getHosts(); + String[] names = new String[conns.length]; + for (int idx = 0; idx < names.length; idx++) + names[idx] = conns[idx].getSystemProfileName() + "." + conns[idx].getAliasName(); //$NON-NLS-1$ + setConnectionNamesOrder(names); + } + + /** + * Sets the ordered list of connection names. + * This is how user arranged connections in the system view. + * @param connectionNames an array of connection names in the order they are to be presented. + */ + public static void setConnectionNamesOrder(String[] connectionNames) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.ORDER_CONNECTIONS, makeString(connectionNames)); + savePreferences(); + } + + /** + * Resolves differences between two ordered name lists. + * Used when there are differences between the actual list of names and + * a restored ordered list of names. + */ + private static String[] resolveOrderPreferenceVersusReality(String[] reality, String[] ordered) { + Vector finalList = new Vector(); + // step 1: include all names from preferences list which do exist in reality... + for (int idx = 0; idx < ordered.length; idx++) { + if (find(reality, ordered[idx])) finalList.addElement(ordered[idx]); + } + // step 2: add all names in reality which do not exist in preferences list... + for (int idx = 0; idx < reality.length; idx++) { + if (!find(ordered, reality[idx])) finalList.addElement(reality[idx]); + } + String[] resolved = new String[finalList.size()]; + finalList.toArray(resolved); + return resolved; + } + + /** + * @return the history for the folder combo box widget + */ + public static String[] getFolderHistory() { + return getWidgetHistory(ISystemPreferencesConstants.HISTORY_FOLDER); + } + + /** + * Sets the history for the folder combo box widget. + * Does not save the preferences. This must be done by the caller. + * @see #savePreferences() + * @param newHistory the names of the folders to be saved in the folder history + */ + public static void setFolderHistory(String[] newHistory) { + setWidgetHistory(ISystemPreferencesConstants.HISTORY_FOLDER, newHistory); + } + + /** + * @return true if the user has elected to show connection names qualified by profile + */ + public static boolean getQualifyConnectionNames() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return store.getBoolean(ISystemPreferencesConstants.QUALIFY_CONNECTION_NAMES); + } + + /** + * Sets if the user has elected to show connection names qualified by profile. + * @param qualify whether or not to qualify the connection names in the UI. + */ + public static void setQualifyConnectionNames(boolean qualify) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.QUALIFY_CONNECTION_NAMES, qualify); + savePreferences(); + } + + /** + * @return true if the user has elected to remember the state of the Remote Systems View + */ + public static boolean getRememberState() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return store.getBoolean(ISystemPreferencesConstants.REMEMBER_STATE); + } + + /** + * Sets if the user has elected to remember the state of RSE. + * @param remember true if the state should be remembered. + */ + public static void setRememberState(boolean remember) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.REMEMBER_STATE, remember); + savePreferences(); + } + + /** + * Return true if the user has elected to restore the state of the Remote Systems view from cached information + */ + public static boolean getRestoreStateFromCache() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return store.getBoolean(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE); + } + + /** + * Set if the user has elected to restore the state of the + * Remote Systems View from cached information + * @param restore whether or not to restore the state of RSE from cached information. + */ + public static void setRestoreStateFromCache(boolean restore) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.RESTORE_STATE_FROM_CACHE, restore); + savePreferences(); + } + + /** + * Return true if the user has elected to show filter pools in the Remote System Explorer view + */ + public static boolean getShowFilterPools() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return store.getBoolean(ISystemPreferencesConstants.SHOWFILTERPOOLS); + } + + /** + * Sets whether or not to show filter pools. + * @param show true if we want to show the filter pools + */ + public static void setShowFilterPools(boolean show) { + boolean prevValue = getShowFilterPools(); + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.SHOWFILTERPOOLS, show); + savePreferences(); + if (show != prevValue) { + RSEUIPlugin.getTheSystemRegistry().setShowFilterPools(show); + } + } + + /** + * @return true if the user has elected to show the "New Connection..." prompt + * in the Remote Systems View + */ + public static boolean getShowNewConnectionPrompt() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + boolean value = store.getBoolean(ISystemPreferencesConstants.SHOWNEWCONNECTIONPROMPT); + return value; + } + + /** + * Sets whether to show the new connection... prompt in the Remote System Explorer view. + * @param show true if we want to show the filter pools + */ + public static void setShowNewConnectionPrompt(boolean show) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(ISystemPreferencesConstants.SHOWNEWCONNECTIONPROMPT, show); + savePreferences(); + } + + /** + * @return whether to turn on "Verify connection" checkbox on the New Connection wizard + */ + public static boolean getVerifyConnection() { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); store.setDefault(ISystemPreferencesConstants.VERIFY_CONNECTION, ISystemPreferencesConstants.DEFAULT_VERIFY_CONNECTION); - return store.getBoolean(ISystemPreferencesConstants.VERIFY_CONNECTION); - } - - // ---------------------- - // SETTER METHODS... - // ---------------------- - /** - * Set whether to show connection names qualified by profile name - */ - public void setQualifyConnectionNames(boolean set) - { - RemoteSystemsPreferencePage.setQualifyConnectionNamesPreference(set); - } + return store.getBoolean(ISystemPreferencesConstants.VERIFY_CONNECTION); + } - /** - * Set whether to show filter pools or not - */ - public void setShowFilterPools(boolean show) - { - boolean prevValue = getShowFilterPools(); - RemoteSystemsPreferencePage.setShowFilterPoolsPreference(show); - if (show != prevValue) - RSEUIPlugin.getTheSystemRegistry().setShowFilterPools(show); - } - - /** - * Set whether to remember state or not in Remote Systems view - */ - public void setRememberState(boolean remember) - { - RemoteSystemsPreferencePage.setRememberStatePreference(remember); - } - /** - * Set whether to show "New Connection..." prompt - */ - public void setShowNewConnectionPrompt(boolean show) - { - RemoteSystemsPreferencePage.setShowNewConnectionPromptPreference(show); - } - /** - * Set whether to cascade user actions menu by profile - */ - public void setCascadeUserActions(boolean cascade) - { - RemoteSystemsPreferencePage.setCascadeUserActionsPreference(cascade); - } - /** - * Set whether to turn on "Verify connection" checkbox on the New Connection wizard - */ - public void setVerifyConnection(boolean verify) - { - IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore(); + /** + * Sets whether connections should be verified by the New Connection wizard. + * @param verify true if the connection should be verified + */ + public static void setVerifyConnection(boolean verify) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); store.setValue(ISystemPreferencesConstants.VERIFY_CONNECTION, verify); - RSEUIPlugin.getDefault().savePluginPreferences(); // also saves the preference store - } - - // ------------------ - // HISTORY METHODS... - // ------------------ - /** - * Return history for the folder combobox - */ - public String[] getFolderHistory() - { - return RemoteSystemsPreferencePage.getFolderHistory(); - } - /** - * Set history for the folder combobox - */ - public void setFolderHistory(String[] history) - { - RemoteSystemsPreferencePage.setFolderHistory(history); - } - /** - * Return history for a widget given a key that uniquely identifies it - */ - public String[] getWidgetHistory(String key) - { - return RemoteSystemsPreferencePage.getWidgetHistory(key); - } - /** - * Set history for a widget given a key that uniquely identifies it - */ - public void setWidgetHistory(String key, String[] history) - { - RemoteSystemsPreferencePage.setWidgetHistory(key, history); - } + savePreferences(); + } + + /** + * Return the history for a widget given an arbitrary key uniquely identifying it + */ + public static String[] getWidgetHistory(String key) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + return parseStrings(store.getString(key)); + } + + /** + * Sets the history for a widget given an arbitrary key uniquely identifying it. + * Does not save the preferences. This must be done by the caller. + * @see #savePreferences() + */ + public static void setWidgetHistory(String key, String[] newHistory) { + Preferences store = RSEUIPlugin.getDefault().getPluginPreferences(); + store.setValue(key, makeString(newHistory)); + } + + /** + * Save the preference stores. + */ + public static void savePreferences() { + RSEUIPlugin.getDefault().savePluginPreferences(); + RSECorePlugin.getDefault().savePluginPreferences(); + } + + /* + * Private to discourage instance creation. + */ + private SystemPreferencesManager() { + } } \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java index c0232cc6a83..82eed43a2c5 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/RSECombinedTestSuite.java @@ -17,6 +17,7 @@ import org.eclipse.rse.tests.core.connection.RSEConnectionTestSuite; import org.eclipse.rse.tests.core.registries.RSERegistriesTestSuite; import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder; import org.eclipse.rse.tests.internal.RSEInternalFrameworkTestSuite; +import org.eclipse.rse.tests.preferences.RSEPreferencesTestSuite; import org.eclipse.rse.tests.subsystems.files.RSEFileSubsystemTestSuite; import org.eclipse.rse.tests.subsystems.testsubsystem.RSETestSubsystemTestSuite; @@ -56,7 +57,8 @@ public class RSECombinedTestSuite extends DelegatingTestSuiteHolder { suite.addTest(RSEConnectionTestSuite.suite()); suite.addTest(RSEFileSubsystemTestSuite.suite()); suite.addTest(RSETestSubsystemTestSuite.suite()); - + suite.addTest(RSEPreferencesTestSuite.suite()); + return suite; } diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java new file mode 100644 index 00000000000..e091fcc96e8 --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/PreferencesTest.java @@ -0,0 +1,80 @@ +/* ****************************************************************************** + * Copyright (c) 2006 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 + * + * Contributors: + * David Dykstal (IBM) - initial API and implementation. + * David McKnight (IBM) - initial API and implementation. + * Kushal Munir (IBM) - initial API and implementation. + * ******************************************************************************/ + +package org.eclipse.rse.tests.preferences; + +import org.eclipse.rse.core.IRSECoreRegistry; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.SystemPreferencesManager; +import org.eclipse.rse.tests.core.RSECoreTestCase; + +/** + * Tests for {@link SystemPreferencesManager}. + */ +public class PreferencesTest extends RSECoreTestCase { + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testActiveProfiles() { + SystemPreferencesManager.addActiveProfile("bogus01"); //$NON-NLS-1$ + SystemPreferencesManager.addActiveProfile("bogus02"); //$NON-NLS-1$ + String[] profiles = SystemPreferencesManager.getActiveProfiles(); + assertTrue(profiles.length >= 2); + assertEquals("bogus02", profiles[SystemPreferencesManager.getActiveProfilePosition("bogus02")]); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("bogus01", profiles[SystemPreferencesManager.getActiveProfilePosition("bogus01")]); //$NON-NLS-1$ //$NON-NLS-2$ + SystemPreferencesManager.renameActiveProfile("bogus02", "bogus99"); //$NON-NLS-1$ //$NON-NLS-2$ + profiles = SystemPreferencesManager.getActiveProfiles(); + assertEquals("bogus99", profiles[SystemPreferencesManager.getActiveProfilePosition("bogus99")]); //$NON-NLS-1$ //$NON-NLS-2$ + SystemPreferencesManager.deleteActiveProfile("bogus01"); //$NON-NLS-1$ + SystemPreferencesManager.deleteActiveProfile("bogus99"); //$NON-NLS-1$ + assertEquals(-1, SystemPreferencesManager.getActiveProfilePosition("bogus02")); //$NON-NLS-1$ + assertEquals(-1, SystemPreferencesManager.getActiveProfilePosition("bogus01")); //$NON-NLS-1$ + assertEquals(-1, SystemPreferencesManager.getActiveProfilePosition("bogus99")); //$NON-NLS-1$ + } + + public void testUserIds() { + SystemPreferencesManager.setUserId("a.b.c", "bogusUser"); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("bogusUser", SystemPreferencesManager.getUserId("a.b.c")); //$NON-NLS-1$ //$NON-NLS-2$ + SystemPreferencesManager.clearUserId("a.b.c"); //$NON-NLS-1$ + assertNull(SystemPreferencesManager.getUserId("a.b.c")); //$NON-NLS-1$ + } + + public void testDefaultUserIds() { + IRSECoreRegistry registry = RSECorePlugin.getDefault().getRegistry(); + IRSESystemType systemType = registry.getSystemType("Local"); //$NON-NLS-1$ + String oldValue = SystemPreferencesManager.getDefaultUserId(systemType); + SystemPreferencesManager.setDefaultUserId(systemType, "bogus1"); //$NON-NLS-1$ + assertEquals("bogus1", SystemPreferencesManager.getDefaultUserId(systemType)); //$NON-NLS-1$ + SystemPreferencesManager.setDefaultUserId("Local", "bogus2"); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("bogus2", SystemPreferencesManager.getDefaultUserId(systemType)); //$NON-NLS-1$ + SystemPreferencesManager.setDefaultUserId(systemType, oldValue); + assertEquals(oldValue, SystemPreferencesManager.getDefaultUserId(systemType)); + } + + public void testShowLocalConnection() { + assertTrue(SystemPreferencesManager.getShowLocalConnection()); + } + +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/RSEPreferencesTestSuite.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/RSEPreferencesTestSuite.java new file mode 100644 index 00000000000..77b105b421a --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/preferences/RSEPreferencesTestSuite.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2006 Wind River Systems, Inc. and others. + * 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: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.rse.tests.preferences; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.rse.tests.framework.DelegatingTestSuiteHolder; + +public class RSEPreferencesTestSuite extends DelegatingTestSuiteHolder { + /** + * Standard Java application main method. Allows to launch the test + * suite from outside as part of nightly runs, headless runs or other. + *

Note: Use only junit.textui.TestRunner here as + * it is explicitly supposed to output the test output to the shell the + * test suite has been launched from. + *

+ * @param args The standard Java application command line parameters passed in. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + /** + * Combine all test into a suite and returns the test suite instance. + *

+ * Note: This method must be always called suite ! Otherwise + * the JUnit plug-in test launcher will fail to detect this class! + *

+ * @return The test suite instance. + */ + public static Test suite() { + TestSuite suite = new TestSuite("RSE Preferences Test Suite"); //$NON-NLS-1$ + // add the single test suites to the overall one here. + suite.addTestSuite(PreferencesTest.class); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite() + */ + public TestSuite getTestSuite() { + return (TestSuite)RSEPreferencesTestSuite.suite(); + } + +}