diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java
index 35c77784a8f..3557c7f294c 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/IRSECoreRegistry.java
@@ -15,6 +15,7 @@
********************************************************************************/
package org.eclipse.rse.core;
+
/**
* Interface for RSE core registry. Clients should use this interface as the starting point for querying and
* manipulating model objects in the RSE framework.
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java
index 35bc7ecb076..7def1c8222f 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java
@@ -161,7 +161,7 @@ public class RSECorePlugin extends Plugin {
* @return the RSE core registry.
*/
public IRSECoreRegistry getRegistry() {
- return RSECoreRegistry.getDefault();
+ return RSECoreRegistry.getInstance();
}
/**
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java
index 0e0dcff32c4..0eadee754f1 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSECoreRegistry.java
@@ -17,8 +17,10 @@ package org.eclipse.rse.core.internal;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -37,15 +39,16 @@ public class RSECoreRegistry implements IRSECoreRegistry {
// the singleton instance
private static RSECoreRegistry instance = null;
- // extension registry
- private IExtensionRegistry registry;
-
// state variables
private boolean hasReadSystemTypes;
// model objects
private IRSESystemType[] systemTypes;
+ // Cache for accessed system type either by id or by name. Avoids to
+ // re-iterate over all registered ones each call again.
+ private final Map accessedSystemTypeCache = new HashMap();
+
// constants
private static final String ELEMENT_SYTEM_TYPE = "systemType"; //$NON-NLS-1$
@@ -54,21 +57,13 @@ public class RSECoreRegistry implements IRSECoreRegistry {
*/
private RSECoreRegistry() {
super();
- init();
- }
-
- /**
- * Initializes the registry. This should only be called from the constructor.
- */
- private void init() {
- registry = Platform.getExtensionRegistry();
}
/**
* Returns the singleton instance of the registry.
* @return the singleton instance
*/
- public static final RSECoreRegistry getDefault() {
+ public static final RSECoreRegistry getInstance() {
if (instance == null) {
instance = new RSECoreRegistry();
@@ -95,12 +90,18 @@ public class RSECoreRegistry implements IRSECoreRegistry {
*/
public IRSESystemType getSystemTypeById(String systemTypeId) {
if (systemTypeId != null) {
- IRSESystemType[] types = getSystemTypes();
- for (int i = 0; i < types.length; i++) {
- if (types[i].getId().equals(systemTypeId)) {
- return types[i];
+ IRSESystemType systemType = (IRSESystemType)accessedSystemTypeCache.get(systemTypeId);
+ if (systemType == null) {
+ // We have to re-lookup the system type
+ IRSESystemType[] types = getSystemTypes();
+ for (int i = 0; i < types.length && systemType == null; i++) {
+ if (types[i].getId().equals(systemTypeId)) {
+ systemType = types[i];
+ }
}
+ if (systemType != null) accessedSystemTypeCache.put(systemTypeId, systemType);
}
+ return systemType;
}
return null;
}
@@ -109,28 +110,35 @@ public class RSECoreRegistry implements IRSECoreRegistry {
* @see org.eclipse.rse.core.IRSECoreRegistry#getSystemType(java.lang.String)
*/
public IRSESystemType getSystemType(String name) {
- IRSESystemType[] types = getSystemTypes();
-
- for (int i = 0; i < types.length; i++) {
- IRSESystemType type = types[i];
-
- if (type.getName().equals(name)) {
- return type;
+ if (name != null) {
+ IRSESystemType systemType = (IRSESystemType)accessedSystemTypeCache.get(name);
+ if (systemType == null) {
+ // We have to re-lookup the system type
+ IRSESystemType[] types = getSystemTypes();
+ for (int i = 0; i < types.length && systemType == null; i++) {
+ if (types[i].getName().equals(name)) {
+ systemType = types[i];
+ }
+ }
+ if (systemType != null) accessedSystemTypeCache.put(name, systemType);
}
+ return systemType;
}
-
+
return null;
}
/**
* Reads system types from the extension point registry and returns the defined system types.
- * @return an array of system types that have been defined
+ *
+ * @return An array of system types that have been defined.
*/
private IRSESystemType[] readSystemTypes() {
List types = new LinkedList();
List typeIds = new ArrayList();
+ accessedSystemTypeCache.clear();
- IExtensionRegistry registry = getExtensionRegistry();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
// First we take the direct system type contributions via extension point
IConfigurationElement[] elements = registry.getConfigurationElementsFor(PI_RSE_CORE, PI_SYSTEM_TYPES);
@@ -143,6 +151,10 @@ public class RSECoreRegistry implements IRSECoreRegistry {
types.add(type);
typeIds.add(type.getId());
+ // Build up the cache directly for improving access performance.
+ accessedSystemTypeCache.put(type.getId(), type);
+ accessedSystemTypeCache.put(type.getName(), type);
+
String message = "Successfully registered RSE system type ''{0}'' (id = ''{1}'')."; //$NON-NLS-1$
message = MessageFormat.format(message, new Object[] { type.getLabel(), type.getId() });
RSECorePlugin.getDefault().getLogger().logInfo(message);
@@ -170,6 +182,10 @@ public class RSECoreRegistry implements IRSECoreRegistry {
types.add(type);
typeIds.add(type.getId());
+ // Build up the cache directly for improving access performance.
+ accessedSystemTypeCache.put(type.getId(), type);
+ accessedSystemTypeCache.put(type.getName(), type);
+
String message = "Successfully registered RSE system type ''{0}'' (id = ''{1}'')."; //$NON-NLS-1$
message = MessageFormat.format(message, new Object[] { type.getLabel(), type.getId() });
RSECorePlugin.getDefault().getLogger().logInfo(message);
@@ -189,12 +205,4 @@ public class RSECoreRegistry implements IRSECoreRegistry {
return (IRSESystemType[])types.toArray(new IRSESystemType[types.size()]);
}
-
- /**
- * Returns the platform extension registry.
- * @return the platform extension registry
- */
- private IExtensionRegistry getExtensionRegistry() {
- return registry;
- }
}
diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSESystemType.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSESystemType.java
index 154399cb2a1..3cbee525570 100644
--- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSESystemType.java
+++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/internal/RSESystemType.java
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2006 IBM Corporation. All rights reserved.
+ * Copyright (c) 2006, 2007 IBM Corporation 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
@@ -11,7 +11,7 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
- * {Name} (company) - description of contribution.
+ * Uwe Stieber (Wind River) - Dynamic system type provider extension.
********************************************************************************/
package org.eclipse.rse.core.internal;
@@ -22,6 +22,7 @@ import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSESystemTypeConstants;
import org.osgi.framework.Bundle;
@@ -29,7 +30,7 @@ import org.osgi.framework.Bundle;
/**
* Class representing a system type.
*/
-public class RSESystemType implements IRSESystemType {
+public class RSESystemType extends PlatformObject implements IRSESystemType {
private static final String ATTR_ID = "id"; //$NON-NLS-1$
private static final String ATTR_NAME = "name"; //$NON-NLS-1$
@@ -151,11 +152,4 @@ public class RSESystemType implements IRSESystemType {
public String[] getSubsystemConfigurationIds() {
return subsystemConfigurationIds;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteSearchResultAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteSearchResultAdapter.java
index e520548b032..3d1c3437249 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteSearchResultAdapter.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/view/SystemViewRemoteSearchResultAdapter.java
@@ -474,10 +474,10 @@ public class SystemViewRemoteSearchResultAdapter extends AbstractSystemViewAdapt
int idx = -1;
// path
- _propertyDescriptors[++idx] = createSimplePropertyDescriptor(P_FILE_PATH, SystemViewResources.RESID_PROPERTY_FILE_PATH_LABEL, SystemViewResources.RESID_PROPERTY_FILE_PATH_TOOLTIP);
+ _propertyDescriptors[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILE_PATH, SystemViewResources.RESID_PROPERTY_FILE_PATH_LABEL, SystemViewResources.RESID_PROPERTY_FILE_PATH_TOOLTIP);
// char start
- _propertyDescriptors[++idx] = createSimplePropertyDescriptor(P_SEARCH_LINE, SystemViewResources.RESID_PROPERTY_SEARCH_LINE_LABEL, SystemViewResources.RESID_PROPERTY_SEARCH_LINE_TOOLTIP);
+ _propertyDescriptors[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_SEARCH_LINE, SystemViewResources.RESID_PROPERTY_SEARCH_LINE_LABEL, SystemViewResources.RESID_PROPERTY_SEARCH_LINE_TOOLTIP);
//_propertyDescriptors[++idx] = createSimplePropertyDescriptor(P_SEARCH_CHAR_END, SystemViewResources.RESID_PROPERTY_SEARCH_CHAR_END_ROOT);
}
return _propertyDescriptors;
@@ -496,11 +496,11 @@ public class SystemViewRemoteSearchResultAdapter extends AbstractSystemViewAdapt
{
IHostSearchResult output = (IHostSearchResult) propertySourceInput;
- if (name.equals(P_FILE_PATH))
+ if (name.equals(ISystemPropertyConstants.P_FILE_PATH))
{
return output.getAbsolutePath();
}
- else if (name.equals(P_SEARCH_LINE))
+ else if (name.equals(ISystemPropertyConstants.P_SEARCH_LINE))
{
return new Integer(output.getLine());
}
diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java
index 77a4984fa1c..b46cbe0a811 100644
--- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java
+++ b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.internal.ui.view.SystemViewResources;
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError;
import org.eclipse.rse.ui.SystemMenuManager;
+import org.eclipse.rse.ui.view.ISystemPropertyConstants;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;
@@ -56,10 +57,10 @@ public class SystemViewRemoteErrorAdapter extends SystemViewRemoteOutputAdapter
//RSEUIPlugin plugin = RSEUIPlugin.getDefault();
// path
- _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(P_ERROR_FILENAME, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_TOOLTIP);
+ _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_ERROR_FILENAME, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_TOOLTIP);
// line
- _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(P_ERROR_LINENO, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_TOOLTIP);
+ _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_ERROR_LINENO, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_TOOLTIP);
}
return _uniquePropertyDescriptorArray;
@@ -80,7 +81,7 @@ public class SystemViewRemoteErrorAdapter extends SystemViewRemoteOutputAdapter
int idx = -1;
// path
- _propertyDescriptors[++idx] = createSimplePropertyDescriptor(P_FILE_PATH, SystemViewResources.RESID_PROPERTY_FILE_PATH_LABEL, SystemViewResources.RESID_PROPERTY_FILE_PATH_TOOLTIP);
+ _propertyDescriptors[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILE_PATH, SystemViewResources.RESID_PROPERTY_FILE_PATH_LABEL, SystemViewResources.RESID_PROPERTY_FILE_PATH_TOOLTIP);
// append...
for (int i = 0; i < unique.length; i++)
{
@@ -101,15 +102,15 @@ public class SystemViewRemoteErrorAdapter extends SystemViewRemoteOutputAdapter
{
IRemoteError output = (IRemoteError) propertySourceInput;
- if (name.equals(P_FILE_PATH))
+ if (name.equals(ISystemPropertyConstants.P_FILE_PATH))
{
return output.getAbsolutePath();
}
- else if (name.equals(P_ERROR_FILENAME))
+ else if (name.equals(ISystemPropertyConstants.P_ERROR_FILENAME))
{
return output.getAbsolutePath();
}
- else if (name.equals(P_ERROR_LINENO))
+ else if (name.equals(ISystemPropertyConstants.P_ERROR_LINENO))
{
return new Integer(output.getLine());
}
diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java
index 96b98d31b94..372a85c4ef8 100644
--- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java
+++ b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java
@@ -1150,8 +1150,8 @@ implements ISystemViewElementAdapter, ISystemRemoteElementAdapter, ISystemOutpu
{
_shellPropertyDescriptors = new IPropertyDescriptor[2];
- _shellPropertyDescriptors[0] = createSimplePropertyDescriptor(P_SHELL_STATUS, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_TOOLTIP);
- _shellPropertyDescriptors[1] = createSimplePropertyDescriptor(P_SHELL_CONTEXT, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_TOOLTIP);
+ _shellPropertyDescriptors[0] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_SHELL_STATUS, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_TOOLTIP);
+ _shellPropertyDescriptors[1] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_SHELL_CONTEXT, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_TOOLTIP);
}
return _shellPropertyDescriptors;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
index a2d234eeaf8..8966fba78ce 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java
@@ -530,21 +530,21 @@ public class SystemViewConnectionAdapter
String name = (String)key;
IHost conn = (IHost)propertySourceInput;
- if (name.equals(P_SYSTEMTYPE))
+ if (name.equals(ISystemPropertyConstants.P_SYSTEMTYPE))
return conn.getSystemType();
- else if (name.equals(P_HOSTNAME))
+ else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
return conn.getHostName();
- else if (name.equals(P_DEFAULTUSERID))
+ else if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
{
setDefaultUserIdPropertyData(userIdData, conn);
//System.out.println("Testing getPropertyValue: " + userIdData);
return userIdData;
}
- else if (name.equals(P_DESCRIPTION))
+ else if (name.equals(ISystemPropertyConstants.P_DESCRIPTION))
return conn.getDescription();
- else if (name.equals(P_PROFILE))
+ else if (name.equals(ISystemPropertyConstants.P_PROFILE))
return conn.getSystemProfile().getName();
- else if (name.equals(P_IS_CONNECTED))
+ else if (name.equals(ISystemPropertyConstants.P_IS_CONNECTED))
{
if (conn.isOffline())
{
@@ -606,11 +606,11 @@ public class SystemViewConnectionAdapter
{
String property = (String)propertyObject;
boolean changed = false;
- if (property.equals(P_DEFAULTUSERID))
+ if (property.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
changed = changed_userId;
- else if (property.equals(P_HOSTNAME))
+ else if (property.equals(ISystemPropertyConstants.P_HOSTNAME))
changed = changed_hostName;
- else if (property.equals(P_DESCRIPTION))
+ else if (property.equals(ISystemPropertyConstants.P_DESCRIPTION))
changed = changed_description;
return changed;
}
@@ -625,18 +625,18 @@ public class SystemViewConnectionAdapter
IHost conn = (IHost)propertySourceInput;
ISystemRegistryUI sr = RSEUIPlugin.getDefault().getSystemRegistry();
- if (property.equals(P_DEFAULTUSERID))
+ if (property.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
{
//sr.updateConnection(null, conn, conn.getSystemType(), conn.getAliasName(),
// conn.getHostName(), conn.getDescription(), original_userId, USERID_LOCATION_CONNECTION);
updateDefaultUserId(conn, original_userIdData);
}
- else if (property.equals(P_HOSTNAME))
+ else if (property.equals(ISystemPropertyConstants.P_HOSTNAME))
{
sr.updateHost(null, conn, conn.getSystemType(), conn.getAliasName(),
original_hostName, conn.getDescription(), conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
}
- else if (property.equals(P_DESCRIPTION))
+ else if (property.equals(ISystemPropertyConstants.P_DESCRIPTION))
{
sr.updateHost(null, conn, conn.getSystemType(), conn.getAliasName(),
conn.getHostName(), original_description, conn.getDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_NOTSET);
@@ -665,7 +665,7 @@ public class SystemViewConnectionAdapter
IHost conn = (IHost)propertySourceInput;
ISystemRegistryUI sr = RSEUIPlugin.getDefault().getSystemRegistry();
- if (name.equals(P_DEFAULTUSERID))
+ if (name.equals(ISystemPropertyConstants.P_DEFAULTUSERID))
{
//System.out.println("Testing setPropertyValue: " + value);
//sr.updateConnection(null, conn, conn.getSystemType(), conn.getAliasName(),
@@ -673,7 +673,7 @@ public class SystemViewConnectionAdapter
updateDefaultUserId(conn, (SystemInheritablePropertyData)value);
changed_userId = true;
}
- else if (name.equals(P_HOSTNAME))
+ else if (name.equals(ISystemPropertyConstants.P_HOSTNAME))
{
// DKM - don't update unless it really changed
// defect 57739
@@ -684,7 +684,7 @@ public class SystemViewConnectionAdapter
changed_hostName = true;
}
}
- else if (name.equals(P_DESCRIPTION))
+ else if (name.equals(ISystemPropertyConstants.P_DESCRIPTION))
{
// DKM - don't update unless it really changed
// defect 57739
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java
index 6a038b3b4de..080ea4fbcdc 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterAdapter.java
@@ -355,11 +355,11 @@ public class SystemViewFilterAdapter extends AbstractSystemViewAdapter
int idx = 0;
// parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
+ propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
// parent filter
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
// number filter strings
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_FILTERSTRINGS_COUNT,SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT,SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
}
return propertyDescriptorArray;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java
index 52860134c5b..1124ec7b773 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolAdapter.java
@@ -181,13 +181,13 @@ public class SystemViewFilterPoolAdapter extends AbstractSystemViewAdapter
int idx = 0;
// parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
+ propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
// parent filter pool's profile
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
// Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
}
return propertyDescriptorArray;
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
index 27f435ff757..1d21732d8d8 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterPoolReferenceAdapter.java
@@ -235,13 +235,13 @@ public class SystemViewFilterPoolReferenceAdapter
int idx = 0;
// parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
+ propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPOOL_TOOLTIP);
// parent filter pool's profile
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PROFILE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_PARENTPROFILE_TOOLTIP);
// Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_RELATED_CONNECTION, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_RELATEDCONNECTION_TOOLTIP);
}
return propertyDescriptorArray;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
index af4fb6b0d97..2415ed97a90 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterReferenceAdapter.java
@@ -517,13 +517,13 @@ public class SystemViewFilterReferenceAdapter
propertyDescriptorArray = new PropertyDescriptor[nbrOfProperties];
int idx = 0;
// parent filter pool
- propertyDescriptorArray[idx] = createSimplePropertyDescriptor(P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
+ propertyDescriptorArray[idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
// parent filter
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PARENT_FILTER, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
// number filter strings
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_FILTERSTRINGS_COUNT, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRINGS_COUNT, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRINGS_COUNT_TOOLTIP);
// Related connection
- propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_IS_CONNECTION_PRIVATE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP);
+ propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_IS_CONNECTION_PRIVATE, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPOOLREFERENCE_IS_CONNECTIONPRIVATE_TOOLTIP);
}
return propertyDescriptorArray;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java
index 439dfaa2345..e6a9f1d13aa 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewFilterStringAdapter.java
@@ -162,11 +162,11 @@ public class SystemViewFilterStringAdapter extends AbstractSystemViewAdapter
{
propertyDescriptorArray = new PropertyDescriptor[3];
// parent filter pool
- propertyDescriptorArray[0] = createSimplePropertyDescriptor(P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
+ propertyDescriptorArray[0] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTERPOOL,SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTPOOL_TOOLTIP);
// parent filter
- propertyDescriptorArray[1] = createSimplePropertyDescriptor(P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
+ propertyDescriptorArray[1] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_PARENT_FILTER,SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_LABEL, SystemViewResources.RESID_PROPERTY_FILTERPARENTFILTER_TOOLTIP);
// filter string
- propertyDescriptorArray[2] = createSimplePropertyDescriptor(P_FILTERSTRING,SystemViewResources.RESID_PROPERTY_FILTERSTRING_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRING_TOOLTIP);
+ propertyDescriptorArray[2] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_FILTERSTRING,SystemViewResources.RESID_PROPERTY_FILTERSTRING_LABEL, SystemViewResources.RESID_PROPERTY_FILTERSTRING_TOOLTIP);
}
return propertyDescriptorArray;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java
index de4560dbc8d..0a90c9962f9 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/team/SystemTeamViewProfileAdapter.java
@@ -309,7 +309,7 @@ public class SystemTeamViewProfileAdapter
String name = (String)key;
ISystemProfile profile = (ISystemProfile)propertySourceInput;
- if (name.equals(P_IS_ACTIVE))
+ if (name.equals(ISystemPropertyConstants.P_IS_ACTIVE))
{
boolean active = RSEUIPlugin.getTheSystemRegistry().getSystemProfileManager().isSystemProfileActive(profile.getName());
if (active)
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 fcf3c0185f0..4c8332dc53f 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
@@ -30,9 +30,10 @@ import org.eclipse.rse.core.IRSESystemTypeConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.internal.ui.view.SystemView;
+import org.eclipse.rse.model.Host;
import org.eclipse.rse.ui.actions.SystemClearAllPasswordsAction;
import org.eclipse.rse.ui.actions.SystemWorkOfflineAction;
import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor;
@@ -249,7 +250,7 @@ public class RSESystemTypeAdapter extends RSEAdapter {
}
/**
- * Called from {@link SystemView#createStandardGroups(IMenuManager)} to allow dynamic system
+ * Called from {@link org.eclipse.rse.internal.ui.view.SystemView#createStandardGroups(IMenuManager)} to allow dynamic system
* type providers to customize the RSE standard menu structure regarding their needs.
*
* @param menu The menu manager. Must be not null
.
@@ -313,4 +314,17 @@ public class RSESystemTypeAdapter extends RSEAdapter {
return false;
}
+
+
+ /**
+ * Creates a new IHost
object instance. This method is
+ * called from {@link org.eclipse.rse.internal.model.SystemHostPool#createHost(String, String, String, String, String, int)}.
+ *
+ * @param profile The system profile to associate with the host.
+ * @return A new IHost
object instance.
+ */
+ public IHost createNewHostInstance(ISystemProfile profile) {
+ return new Host(profile);
+ }
+
}
\ No newline at end of file
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 93323bb73c3..3426ec3fccf 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
@@ -474,33 +474,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi
registerDynamicPopupMenuExtensions();
registerKeystoreProviders();
- // if first time creating the remote systems project, add some default connections...
-// if (SystemResourceManager.isFirstTime()
-// && !dontShowLocalConnection) // new support to allow products to not pre-create a local connection
-// {
- //try
- //{
-
-// registry.createLocalHost(null, SystemResources.TERM_LOCAL, SystemProfileManager.getSystemProfileManager().getDefaultPrivateSystemProfileName()); // profile, name, userId
- /* replaced with re-usable method by Phil, in v5.1.2
- SystemConnection localConn = registry.createConnection(
- //SystemResourceConstants.RESOURCE_TEAMPROFILE_NAME, IRSESystemType.SYSTEMTYPE_LOCAL,
- SystemResourceConstants.RESOURCE_PRIVATEPROFILE_NAME, IRSESystemType.SYSTEMTYPE_LOCAL,
- getString(ISystemConstants.TERM_LOCAL, "Local"), // connection name
- "localhost", // hostname
- "", // description
- // DY: defect 42101, description cannot be null
- // null, // description
- getLocalMachineName(), // userId
- IRSEUserIdConstants.USERID_LOCATION_DEFAULT_SYSTEMTYPE, null);
- */
- //}
- //catch (Exception exc)
- //{
- //logError("Error creating default Local connection", exc);
- //}
-// }
-
// new support to allow products to not pre-create a local connection
if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) {
// create the connection only if the local system type is enabled!
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/AbstractSystemViewAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/AbstractSystemViewAdapter.java
index 0e965cb0b1f..08a4172699e 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/AbstractSystemViewAdapter.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/AbstractSystemViewAdapter.java
@@ -1,5 +1,5 @@
/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
+ * Copyright (c) 2002, 2007 IBM Corporation 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
@@ -11,13 +11,15 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
- * {Name} (company) - description of contribution.
+ * Uwe Stieber (Wind River) - Allow to extend action filter by dynamic system type providers.
********************************************************************************/
package org.eclipse.rse.ui.view;
import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
@@ -26,11 +28,17 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemAdapterHelpers;
import org.eclipse.rse.core.SystemBasePlugin;
+import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
+import org.eclipse.rse.core.filters.ISystemFilterReference;
+import org.eclipse.rse.core.filters.ISystemFilterStringReference;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ISystemMessageObject;
import org.eclipse.rse.core.model.ISystemResourceSet;
@@ -60,12 +68,12 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
import org.eclipse.ui.progress.IElementCollector;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
@@ -74,10 +82,20 @@ import org.eclipse.ui.views.properties.PropertyDescriptor;
* It implements the ISystemViewElementAdapter interface.
* @see AbstractSystemRemoteAdapterFactory
*/
-public abstract class AbstractSystemViewAdapter
- implements ISystemViewElementAdapter, IPropertySource, ISystemPropertyConstants, IWorkbenchAdapter,
- ISystemViewActionFilter, IDeferredWorkbenchAdapter
+public abstract class AbstractSystemViewAdapter implements ISystemViewElementAdapter, IWorkbenchAdapter,
+ IDeferredWorkbenchAdapter
{
+ // Static action filter per system type cache. Filled from testAttribute.
+ private final static Map ACTION_FILTER_CACHE = new HashMap();
+
+ // Internal helper class to cache system type -> no action filter relation ships.
+ // Used from testAttribute.
+ private final static class NULL_ACTION_FILTER implements IActionFilter {
+ public boolean testAttribute(Object target, String name, String value) {
+ return false;
+ }
+ }
+
//protected boolean isEditable = false;
protected String filterString = null;
@@ -90,6 +108,7 @@ public abstract class AbstractSystemViewAdapter
* Current input provider. Set by content provider
*/
protected Object propertySourceInput = null;
+
/**
* Current shell, set by the content provider
*/
@@ -161,6 +180,13 @@ public abstract class AbstractSystemViewAdapter
* A variable that can be used to cache last selection, if desired
*/
protected Object _lastSelected = null;
+
+ /**
+ * Static constructor.
+ */
+ static {
+ ACTION_FILTER_CACHE.clear();
+ }
// ------------------------------------------------------------------
// Configuration methods, called by the label and content provider...
@@ -524,11 +550,11 @@ public abstract class AbstractSystemViewAdapter
// The following determine what properties will be displayed in the PropertySheet
// resource type
int idx = 0;
- propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(P_TYPE, SystemPropertyResources.RESID_PROPERTY_TYPE_LABEL, SystemPropertyResources.RESID_PROPERTY_TYPE_TOOLTIP);
+ propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_TYPE, SystemPropertyResources.RESID_PROPERTY_TYPE_LABEL, SystemPropertyResources.RESID_PROPERTY_TYPE_TOOLTIP);
// resource name
- propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(P_TEXT, SystemPropertyResources.RESID_PROPERTY_NAME_LABEL, SystemPropertyResources.RESID_PROPERTY_NAME_TOOLTIP);
+ propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(IBasicPropertyConstants.P_TEXT, SystemPropertyResources.RESID_PROPERTY_NAME_LABEL, SystemPropertyResources.RESID_PROPERTY_NAME_TOOLTIP);
// number of children in tree currently
- propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(P_NBRCHILDREN, SystemViewResources.RESID_PROPERTY_NBRCHILDREN_LABEL, SystemViewResources.RESID_PROPERTY_NBRCHILDREN_TOOLTIP);
+ propertyDescriptorArray[idx++] = createSimplePropertyDescriptor(ISystemPropertyConstants.P_NBRCHILDREN, SystemViewResources.RESID_PROPERTY_NBRCHILDREN_LABEL, SystemViewResources.RESID_PROPERTY_NBRCHILDREN_TOOLTIP);
}
//System.out.println("In getDefaultDescriptors() in AbstractSystemViewAdapter");
@@ -698,12 +724,12 @@ public abstract class AbstractSystemViewAdapter
public Object getPropertyValue(Object key)
{
String name = (String)key;
- if (name.equals(P_TEXT))
+ if (name.equals(IBasicPropertyConstants.P_TEXT))
//return getText(propertySourceInput);
return getName(propertySourceInput);
- else if (name.equals(P_TYPE))
+ else if (name.equals(ISystemPropertyConstants.P_TYPE))
return getType(propertySourceInput);
- else if (name.equals(P_NBRCHILDREN))
+ else if (name.equals(ISystemPropertyConstants.P_NBRCHILDREN))
{
ISystemTree tree = getSystemTree();
if (tree != null)
@@ -1458,6 +1484,50 @@ public abstract class AbstractSystemViewAdapter
}
return false;
}
+
+ // Give the ISV's as the element owners/contibutors the chance to extend the standard RSE action
+ // filters for their specific needs. We do this by trying to determine the system type from the
+ // target object and try to adapt the system type to an IActionFilter.
+ //
+ // Note: Everything we do here is performance critical to the menu to show up. Therefor
+ // we cache as much as possible here. The cache is static to all AbstractSystemViewAdapter
+ // instances throughout the whole hierarchy.
+ IHost conn = null;
+ if (target instanceof IHost) {
+ conn = (IHost)target;
+ } else if (target instanceof ISubSystem) {
+ conn = ((ISubSystem)target).getHost();
+ } else if (target instanceof ISystemFilterPoolReference) {
+ ISystemFilterPoolReference modelObject = (ISystemFilterPoolReference)target;
+ if (modelObject.getProvider() != null) conn = ((ISubSystem)modelObject.getProvider()).getHost();
+ } else if (target instanceof ISystemFilterReference) {
+ ISystemFilterReference modelObject = (ISystemFilterReference)target;
+ if (modelObject.getProvider() != null) conn = ((ISubSystem)modelObject.getProvider()).getHost();
+ } else if (target instanceof ISystemFilterStringReference) {
+ ISystemFilterStringReference modelObject = (ISystemFilterStringReference)target;
+ if (modelObject.getProvider() != null) conn = ((ISubSystem)modelObject.getProvider()).getHost();
+ }
+
+ if (conn != null) {
+ IRSESystemType systemType = RSECorePlugin.getDefault().getRegistry().getSystemType(conn.getSystemType());
+ if (systemType != null) {
+ IActionFilter actionFilter = (IActionFilter)ACTION_FILTER_CACHE.get(systemType);
+ if (actionFilter == null) {
+ Object adapter = systemType.getAdapter(IActionFilter.class);
+ if (adapter instanceof IActionFilter && !adapter.equals(this)) {
+ // put the association in the cache
+ ACTION_FILTER_CACHE.put(systemType, adapter);
+ actionFilter = (IActionFilter)adapter;
+ } else if (!(adapter instanceof IActionFilter)) {
+ // put the association in the cache
+ ACTION_FILTER_CACHE.put(systemType, new NULL_ACTION_FILTER());
+ }
+ }
+ if (actionFilter instanceof NULL_ACTION_FILTER) actionFilter = null;
+ if (actionFilter != null) return actionFilter.testAttribute(target, name, value);
+ }
+ }
+
return false;
}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewActionFilter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewActionFilter.java
deleted file mode 100644
index aa5570fff25..00000000000
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewActionFilter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/********************************************************************************
- * 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
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.ui.view;
-
-import org.eclipse.ui.IActionFilter;
-
-/**
- * This interface is implemented by the adapters for every object shown in the
- * Remote System Explorer. It enables complex filtering of action and popup menu
- * extensions via the <filter> element, and action extensions
- * via the <visibility> and <enablement>
- * elements.
- *
- * The base adapter class used for all RSE objects supports the following properties - * by default: - *
- * What we need to do is delete our entry in the preference store for our default userId. - */ - public void deletingHost() - { - String oldUserId = null; - if (previousUserIdKey != null) - oldUserId = getLocalDefaultUserId(previousUserIdKey); - // if the userId attribute held a preference store key of the form profileName.connectionName, - // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same - // value (the actual user id) the old keyed entry held. - if (oldUserId != null) - { - RSEPreferencesManager.clearUserId(previousUserIdKey); - } - } - /** - * Private method called when this connection's profile is being rename, so - * we can do any pre-death cleanup we need. - *
- * What we need to do is rename our entry in the preference store for our default userId. - */ - public void renamingSystemProfile(String oldName, String newName) - { - String userIdValue = null; - if (previousUserIdKey!=null) - userIdValue = getLocalDefaultUserId(previousUserIdKey); - // if the userId attribute held a preference store key of the form profileName.connectionName, - // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same - // value (the actual user id) the old keyed entry held. - String newKey = getPreferencesKey(newName, getAliasName()); - if ((userIdValue != null) && (userIdValue.length()>0)) - { - RSEPreferencesManager.clearUserId(previousUserIdKey); - RSEPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key - } - previousUserIdKey = newKey; - } - - /** - * Return the system profile that owns this connection - */ - public ISystemProfile getSystemProfile() - { - return _profile; - } - /** - * Return the name of system profile that owns this connection - */ - public String getSystemProfileName() - { - if (pool == null) - return null; - else - { - ISystemProfile profile = pool.getSystemProfile(); - if (profile!=null) - return profile.getName(); - else - return null; - } - } - - /** - * Intercept of setAliasName so we can potentially rename the default-user-id key - * for the preferences store. That key is profileName.connectionAliasName so is - * affected when the alias name changes. - */ - public void setAliasName(String newName) - { - String userIdValue = null; - if (previousUserIdKey != null) - userIdValue = getLocalDefaultUserId(previousUserIdKey); - this.setAliasNameGen(newName); // update mof-modelled attribute - // if the userId attribute held a preference store key of the form profileName.connectionAliasName, - // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same - // value (the actual user id) the old keyed entry held. - String newKey = getPreferencesKey(getSystemProfileName(), newName); - if ((userIdValue != null) && (userIdValue.length()>0)) - { - RSEPreferencesManager.clearUserId(previousUserIdKey); - RSEPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key - } - previousUserIdKey = newKey; - } - /** - * Intercept of setSystemType so we can decide if the user ID is case sensitive - */ - public void setSystemType(String systemType) - { - // defect 43219 - if (systemType != null) - { - boolean forceUC = systemType.equals(IRSESystemType.SYSTEMTYPE_ISERIES); - boolean caseSensitiveUID = systemType.equals(IRSESystemType.SYSTEMTYPE_UNIX) - || systemType.equals(IRSESystemType.SYSTEMTYPE_LINUX) - || (systemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL) && - !System.getProperty("os.name").toLowerCase().startsWith("windows")); //$NON-NLS-1$ //$NON-NLS-2$ - setForceUserIdToUpperCase(forceUC); - setUserIdCaseSensitive(caseSensitiveUID); - } - this.setSystemTypeGen(systemType); - } - - /** - * Intercept of setHostName so we can force it to uppercase. - * IPv4 host names are case insensitive. Much data is stored using the host - * name as part of the key. Therefore, the host name is capitalized here so that - * these comparisons work naturally. - * However, this must be done using the US locale since IPv4 host names - * use can be compared using this locale. See RFC1035. - */ - public void setHostName(String name) { - if (name != null) { - name = name.toUpperCase(Locale.US); - } - this.setHostNameGen(name); - } - /** - * Intercept of setDefaultUserId so we can force it to uppercase. - * Also, we do not store the user Id per se in the attribute, but rather - * we store it in the preference with a key name unique to this connection. - * We store that key name in this attribute. However, this is all transparent to - * the caller. - */ - public void setDefaultUserId(String newId) - { - if ((newId != null) && ucId) - newId = newId.toUpperCase(); - - if ((newId == null) || (newId.length()==0)) // a "clear" request? - { - clearLocalDefaultUserId(); - } - else - { - String key = getPreferencesKey(); - if (key != null) - { - RSEPreferencesManager.setUserId(key, newId); - } - } - } - /** - * Returns the default UserId for this Host. - * Note that we don't store it directly in - * the model, since we don't want the team to share it. Rather, - * we store the actual it in the preference store keyed by - * (profileName.connectionName). - *
- * Further, it is possible that there is no default UserId. If so, this - * method will go to the preference store and will try to get the default - * UserId for this connection's system type. - *
- * This is all transparent to the caller though. - *
- * @return The value of the DefaultUserId attribute - */ - public String getDefaultUserId() - { - String uid = getLocalDefaultUserId(); - if ((uid == null) || (uid.length()==0)) - { - uid = RSEPreferencesManager.getUserId(getSystemType()); // resolve from preferences - if ((uid != null) && ucId) - uid = uid.toUpperCase(); - } - return uid; - } - /** - * Return the local default user Id without resolving up the food chain. - * @see #getDefaultUserId() - */ - protected static String getLocalDefaultUserId(String key) - { - String uid = null; - if ((key!=null) && (key.length()>0)) - { - uid = RSEPreferencesManager.getUserId(key); // resolve from preferences - } - return uid; - } - /** - * Return the local default user Id without resolving up the food chain. - * @see #getDefaultUserId() - */ - public String getLocalDefaultUserId() - { - return getLocalDefaultUserId(getPreferencesKey()); - } - - /** - * Clear the local default user Id so next query will return the value from - * the preference store. - *
- * Same as calling setDefaultUserId(null)
- * @see #setDefaultUserId(String)
- */
- public void clearLocalDefaultUserId()
- {
- if (previousUserIdKey!=null)
- RSEPreferencesManager.clearUserId(previousUserIdKey);
- }
-
- /**
- * Helper method to compute a unique name for a given subsystem instance
- */
- protected String getPreferencesKey()
- {
- if ((getSystemProfileName()==null) || (getAliasName()==null))
- return null;
- return getPreferencesKey(getSystemProfileName());
- }
- /**
- * Helper method to compute a unique name for a given subsystem instance, given a profile name
- */
- protected String getPreferencesKey(String profileName)
- {
- String connectionName = getAliasName();
- if (connectionName == null)
- return null;
- return getPreferencesKey(profileName, connectionName);
- }
- /**
- * Helper method to compute a unique name for a given subsystem instance, given a profile name and connection name
- */
- protected String getPreferencesKey(String profileName, String connectionName)
- {
- return profileName + "." + connectionName; //$NON-NLS-1$
- }
-
-
- /**
- * Call this with false to turn off the default behaviour of forcing the default userId to uppercase.
- */
- public void setForceUserIdToUpperCase(boolean force)
- {
- this.ucId = force;
- }
- /**
- * Call this to turn off the default behaviour of considering case when comparing userIds
- */
- public void setUserIdCaseSensitive(boolean caseSensitive)
- {
- this.userIdCaseSensitive = caseSensitive;
- }
-
- /**
- * Call this to query whether the default userId is to be uppercased.
- */
- public boolean getForceUserIdToUpperCase()
- {
- return ucId;
- }
- /**
- * Call this to query whether the default userId is case sensitive
- */
- public boolean getUserIdCaseSensitive()
- {
- return userIdCaseSensitive;
- }
- /**
- * Call this to compare two userIds taking case sensitivity
- */
- public boolean compareUserIds(String userId1, String userId2)
- {
- if (userId1 == null)
- userId1 = ""; //$NON-NLS-1$
- if (userId2 == null)
- userId2 = ""; //$NON-NLS-1$
- if (userIdCaseSensitive)
- return userId1.equals(userId2);
- else
- return userId1.equalsIgnoreCase(userId2);
- }
-
- public String toString()
- {
- if (getAliasName() == null)
- return this.toStringGen();
- else
- return getAliasName();
- }
- /**
- * This is the method required by the IAdaptable interface.
- * Given an adapter class type, return an object castable to the type, or
- * null if this is not possible.
- */
- public Object getAdapter(Class adapterType)
- {
- return Platform.getAdapterManager().getAdapter(this, adapterType);
- }
-
-
- /**
- * @generated This field/method will be replaced during code generation
- */
- public String getSystemType()
- {
- return systemType;
- }
-
- /**
- * Returns the alias name for this host
- */
- public String getName()
- {
- return getAliasName();
- }
-
- /**
- * @generated This field/method will be replaced during code generation
- * The unique key for this object. Unique per connection pool
- */
- public String getAliasName()
- {
- return aliasName;
- }
-
- /**
- * @generated This field/method will be replaced during code generation
- */
- public String getHostName()
- {
- return hostName;
- }
-
- /**
- * @generated This field/method will be replaced during code generation
- */
- public String getDescription()
- {
- return description;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setDescription(String newDescription)
- {
- setDirty(!compareStrings(description, newDescription));
- description = newDescription;
- }
-
- /**
- * @generated This field/method will be replaced during code generation
- */
- public boolean isPromptable()
- {
- return promptable;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setPromptable(boolean newPromptable)
- {
- setDirty(promptable != newPromptable);
- promptable = newPromptable;
- }
-
- /**
- *
- * Query if this connection is offline or not. It is up to each subsystem to honor this
- * flag.
- *
- * @generated
- */
- public boolean isOffline()
- {
- return offline;
- }
-
- /**
- *
- * Specify if this connection is offline or not. It is up to each subsystem to honor this
- * flag.
- *
- * @generated
- */
- public void setOffline(boolean newOffline)
- {
- setDirty(offline != newOffline);
- offline = newOffline;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setSystemTypeGen(String newSystemType)
- {
- setDirty(!compareStrings(systemType, newSystemType));
- systemType = newSystemType;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setAliasNameGen(String newAliasName)
- {
- setDirty(!compareStrings(aliasName, newAliasName));
- aliasName = newAliasName;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setHostNameGen(String newHostName)
- {
- setDirty(!compareStrings(hostName, newHostName));
- hostName = newHostName;
- }
-
- /**
- * @generated This field/method will be replaced during code generation
- */
- public String getDefaultUserIdGen()
- {
- return defaultUserId;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public void setDefaultUserIdGen(String newDefaultUserId)
- {
- setDirty(!compareStrings(defaultUserId, newDefaultUserId));
- defaultUserId = newDefaultUserId;
- }
-
- /**
- * @deprecated This field/method will be replaced during code generation.
- */
- public String toStringGen()
- {
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (systemType: "); //$NON-NLS-1$
- result.append(systemType);
- result.append(", aliasName: "); //$NON-NLS-1$
- result.append(aliasName);
- result.append(", hostName: "); //$NON-NLS-1$
- result.append(hostName);
- result.append(", description: "); //$NON-NLS-1$
- result.append(description);
- result.append(", defaultUserId: "); //$NON-NLS-1$
- result.append(defaultUserId);
- result.append(", promptable: "); //$NON-NLS-1$
- result.append(promptable);
- result.append(", offline: "); //$NON-NLS-1$
- result.append(offline);
- result.append(')');
- return result.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.model.RSEModelObject#setDirty(boolean)
- */
- public void setDirty(boolean flag) {
- super.setDirty(flag);
- ISystemHostPool myPool = getHostPool();
- if (myPool != null && flag) {
- myPool.setDirty(true);
- }
- }
-
- public boolean commit()
- {
- return RSEUIPlugin.getThePersistenceManager().commit(this);
- }
-
-}
\ No newline at end of file
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 6a92f8e287a..3c3209c03a5 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
@@ -21,6 +21,7 @@ import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSEUserIdConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
@@ -29,6 +30,8 @@ import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.model.RSEModelObject;
import org.eclipse.rse.core.model.RSEModelResources;
+import org.eclipse.rse.model.Host;
+import org.eclipse.rse.ui.RSESystemTypeAdapter;
/**
@@ -205,7 +208,19 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool
try
{
ISystemProfile profile = getSystemProfile();
- conn = new Host(profile);
+
+ // delegate the creation of the host object instance to the system type provider!!!
+ IRSESystemType systemTypeObject = RSECorePlugin.getDefault().getRegistry().getSystemType(systemType);
+ if (systemTypeObject != null) {
+ Object adapter = systemTypeObject.getAdapter(IRSESystemType.class);
+ if (adapter instanceof RSESystemTypeAdapter) {
+ conn = ((RSESystemTypeAdapter)adapter).createNewHostInstance(profile);
+ }
+ }
+ // Fallback to create host object instance here if failed by system type provider.
+ if (conn == null) conn = new Host(profile);
+ assert conn != null;
+
addHost(conn); // only record internally if saved successfully
conn.setHostPool(this);
conn.setAliasName(aliasName);
diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/Host.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/Host.java
new file mode 100644
index 00000000000..8d98da3d4f9
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/Host.java
@@ -0,0 +1,549 @@
+/********************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation 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
+ *
+ * Initial Contributors:
+ * The following IBM employees contributed to the Remote System Explorer
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
+ *
+ * Contributors:
+ * David Dykstal (IBM) - using new API from RSECorePlugin, RSEPreferencesManager
+ * - moved SystemsPreferencesManager to a new plugin
+ * Uwe Stieber (Wind River) - Dynamic system type provider extensions.
+ * - Moved to package org.eclipse.rse.model for being extendable.
+ ********************************************************************************/
+
+package org.eclipse.rse.model;
+
+import java.util.Locale;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.rse.core.IRSESystemType;
+import org.eclipse.rse.core.RSEPreferencesManager;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.ISystemHostPool;
+import org.eclipse.rse.core.model.ISystemProfile;
+import org.eclipse.rse.core.model.RSEModelObject;
+import org.eclipse.rse.core.subsystems.IConnectorService;
+import org.eclipse.rse.core.subsystems.ISubSystem;
+import org.eclipse.rse.ui.RSEUIPlugin;
+
+/**
+ * Default implementation of the IHost
interface.
+ *
+ * Dynamic system type providers may extend this implementation
+ * if needed.
+ */
+public class Host extends RSEModelObject implements IHost {
+
+
+ private boolean ucId = true;
+ private boolean userIdCaseSensitive = true;
+ private ISystemHostPool pool;
+ protected String previousUserIdKey;
+
+ /**
+ * The system type which is associated to this IHost
object.
+ */
+ private String systemType = null;
+
+ /**
+ * The alias name of this IHost
object.
+ */
+ private String aliasName = null;
+
+ /**
+ * The host name of the target which is associated to this IHost
object.
+ */
+ private String hostName = null;
+
+ /**
+ * The description of this IHost
object.
+ */
+ private String description = null;
+
+ /**
+ * The default user id to use to login to the target host.
+ */
+ private String defaultUserId = null;
+
+ /**
+ * Prompt for user id and password.
+ */
+ private boolean promptable = false;
+
+ /**
+ * Offline mode.
+ */
+ private boolean offline = false;
+
+ /**
+ * The system profile associated with this IHost
object.
+ */
+ private ISystemProfile _profile;
+
+ /**
+ * Constructor
+ */
+ public Host(ISystemProfile profile) {
+ super();
+ _profile = profile;
+ }
+
+ /**
+ * Set the parent connection pool this is owned by.
+ * Connection pools are internal management objects, one per profile.
+ */
+ public void setHostPool(ISystemHostPool pool) {
+ this.pool = pool;
+ previousUserIdKey = getPreferencesKey();
+ }
+
+ /**
+ * Set the parent connection pool this is owned by.
+ * Connection pools are internal management objects, one per profile.
+ */
+ public ISystemHostPool getHostPool() {
+ return pool;
+ }
+
+ /**
+ * Return all the connector services provided for this host
+ */
+ public IConnectorService[] getConnectorServices() {
+ return RSEUIPlugin.getTheSystemRegistry().getConnectorServices(this);
+ }
+
+ /**
+ * Return the subsystem instances under this connection.
+ * Just a shortcut to {@link org.eclipse.rse.core.model.ISystemRegistry#getSubSystems(IHost)}
+ */
+ public ISubSystem[] getSubSystems() {
+ return RSEUIPlugin.getTheSystemRegistry().getSubSystems(this);
+ }
+
+ /**
+ * Private method called when this connection is being deleted, so
+ * we can do any pre-death cleanup we need.
+ *
+ * What we need to do is delete our entry in the preference store for our default userId. + */ + public void deletingHost() { + String oldUserId = null; + if (previousUserIdKey != null) oldUserId = getLocalDefaultUserId(previousUserIdKey); + // if the userId attribute held a preference store key of the form profileName.connectionName, + // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same + // value (the actual user id) the old keyed entry held. + if (oldUserId != null) { + RSEPreferencesManager.clearUserId(previousUserIdKey); + } + } + + /** + * Private method called when this connection's profile is being rename, so + * we can do any pre-death cleanup we need. + *
+ * What we need to do is rename our entry in the preference store for our default userId. + */ + public void renamingSystemProfile(String oldName, String newName) { + String userIdValue = null; + if (previousUserIdKey != null) userIdValue = getLocalDefaultUserId(previousUserIdKey); + // if the userId attribute held a preference store key of the form profileName.connectionName, + // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same + // value (the actual user id) the old keyed entry held. + String newKey = getPreferencesKey(newName, getAliasName()); + if ((userIdValue != null) && (userIdValue.length() > 0)) { + RSEPreferencesManager.clearUserId(previousUserIdKey); + RSEPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key + } + previousUserIdKey = newKey; + } + + /** + * Return the system profile that owns this connection + */ + public ISystemProfile getSystemProfile() { + return _profile; + } + + /** + * Return the name of system profile that owns this connection + */ + public String getSystemProfileName() { + if (pool == null) + return null; + else { + ISystemProfile profile = pool.getSystemProfile(); + if (profile != null) + return profile.getName(); + else return null; + } + } + + /** + * Intercept of setAliasName so we can potentially rename the default-user-id key + * for the preferences store. That key is profileName.connectionAliasName so is + * affected when the alias name changes. + */ + public void setAliasName(String newName) { + String userIdValue = null; + if (previousUserIdKey != null) userIdValue = getLocalDefaultUserId(previousUserIdKey); + this.setAliasNameGen(newName); // update mof-modelled attribute + // if the userId attribute held a preference store key of the form profileName.connectionAliasName, + // we have to delete that key entry from the preference store and re-gen a new keyed entry with the same + // value (the actual user id) the old keyed entry held. + String newKey = getPreferencesKey(getSystemProfileName(), newName); + if ((userIdValue != null) && (userIdValue.length() > 0)) { + RSEPreferencesManager.clearUserId(previousUserIdKey); + RSEPreferencesManager.setUserId(newKey, userIdValue); // store old value with new preference key + } + previousUserIdKey = newKey; + } + + /** + * Intercept of setSystemType so we can decide if the user ID is case sensitive + */ + public void setSystemType(String systemType) { + // defect 43219 + if (systemType != null) { + boolean forceUC = systemType.equals(IRSESystemType.SYSTEMTYPE_ISERIES); + boolean caseSensitiveUID = systemType.equals(IRSESystemType.SYSTEMTYPE_UNIX) || systemType.equals(IRSESystemType.SYSTEMTYPE_LINUX) + || (systemType.equals(IRSESystemType.SYSTEMTYPE_LOCAL) && !System.getProperty("os.name").toLowerCase().startsWith("windows")); //$NON-NLS-1$ //$NON-NLS-2$ + setForceUserIdToUpperCase(forceUC); + setUserIdCaseSensitive(caseSensitiveUID); + } + this.setSystemTypeGen(systemType); + } + + /** + * Intercept of setHostName so we can force it to uppercase. + * IPv4 host names are case insensitive. Much data is stored using the host + * name as part of the key. Therefore, the host name is capitalized here so that + * these comparisons work naturally. + * However, this must be done using the US locale since IPv4 host names + * use can be compared using this locale. See RFC1035. + */ + public void setHostName(String name) { + if (name != null) { + name = name.toUpperCase(Locale.US); + } + this.setHostNameGen(name); + } + + /** + * Intercept of setDefaultUserId so we can force it to uppercase. + * Also, we do not store the user Id per se in the attribute, but rather + * we store it in the preference with a key name unique to this connection. + * We store that key name in this attribute. However, this is all transparent to + * the caller. + */ + public void setDefaultUserId(String newId) { + if ((newId != null) && ucId) newId = newId.toUpperCase(); + + if ((newId == null) || (newId.length() == 0)) // a "clear" request? + { + clearLocalDefaultUserId(); + } + else { + String key = getPreferencesKey(); + if (key != null) { + RSEPreferencesManager.setUserId(key, newId); + } + } + } + + /** + * Returns the default UserId for this Host. + * Note that we don't store it directly in + * the model, since we don't want the team to share it. Rather, + * we store the actual it in the preference store keyed by + * (profileName.connectionName). + *
+ * Further, it is possible that there is no default UserId. If so, this + * method will go to the preference store and will try to get the default + * UserId for this connection's system type. + *
+ * This is all transparent to the caller though. + *
+ * @return The value of the DefaultUserId attribute + */ + public String getDefaultUserId() { + String uid = getLocalDefaultUserId(); + if ((uid == null) || (uid.length() == 0)) { + uid = RSEPreferencesManager.getUserId(getSystemType()); // resolve from preferences + if ((uid != null) && ucId) uid = uid.toUpperCase(); + } + return uid; + } + + /** + * Return the local default user Id without resolving up the food chain. + * @see #getDefaultUserId() + */ + protected static String getLocalDefaultUserId(String key) { + String uid = null; + if ((key != null) && (key.length() > 0)) { + uid = RSEPreferencesManager.getUserId(key); // resolve from preferences + } + return uid; + } + + /** + * Return the local default user Id without resolving up the food chain. + * @see #getDefaultUserId() + */ + public String getLocalDefaultUserId() { + return getLocalDefaultUserId(getPreferencesKey()); + } + + /** + * Clear the local default user Id so next query will return the value from + * the preference store. + *
+ * Same as calling setDefaultUserId(null) + * @see #setDefaultUserId(String) + */ + public void clearLocalDefaultUserId() { + if (previousUserIdKey != null) RSEPreferencesManager.clearUserId(previousUserIdKey); + } + + /** + * Helper method to compute a unique name for a given subsystem instance + */ + protected String getPreferencesKey() { + if ((getSystemProfileName() == null) || (getAliasName() == null)) return null; + return getPreferencesKey(getSystemProfileName()); + } + + /** + * Helper method to compute a unique name for a given subsystem instance, given a profile name + */ + protected String getPreferencesKey(String profileName) { + String connectionName = getAliasName(); + if (connectionName == null) return null; + return getPreferencesKey(profileName, connectionName); + } + + /** + * Helper method to compute a unique name for a given subsystem instance, given a profile name and connection name + */ + protected String getPreferencesKey(String profileName, String connectionName) { + return profileName + "." + connectionName; //$NON-NLS-1$ + } + + /** + * Call this with false to turn off the default behaviour of forcing the default userId to uppercase. + */ + public void setForceUserIdToUpperCase(boolean force) { + this.ucId = force; + } + + /** + * Call this to turn off the default behaviour of considering case when comparing userIds + */ + public void setUserIdCaseSensitive(boolean caseSensitive) { + this.userIdCaseSensitive = caseSensitive; + } + + /** + * Call this to query whether the default userId is to be uppercased. + */ + public boolean getForceUserIdToUpperCase() { + return ucId; + } + + /** + * Call this to query whether the default userId is case sensitive + */ + public boolean getUserIdCaseSensitive() { + return userIdCaseSensitive; + } + + /** + * Call this to compare two userIds taking case sensitivity + */ + public boolean compareUserIds(String userId1, String userId2) { + if (userId1 == null) userId1 = ""; //$NON-NLS-1$ + if (userId2 == null) userId2 = ""; //$NON-NLS-1$ + if (userIdCaseSensitive) + return userId1.equals(userId2); + else return userId1.equalsIgnoreCase(userId2); + } + + public String toString() { + if (getAliasName() == null) { + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (systemType: "); //$NON-NLS-1$ + result.append(systemType); + result.append(", aliasName: "); //$NON-NLS-1$ + result.append(aliasName); + result.append(", hostName: "); //$NON-NLS-1$ + result.append(hostName); + result.append(", description: "); //$NON-NLS-1$ + result.append(description); + result.append(", defaultUserId: "); //$NON-NLS-1$ + result.append(defaultUserId); + result.append(", promptable: "); //$NON-NLS-1$ + result.append(promptable); + result.append(", offline: "); //$NON-NLS-1$ + result.append(offline); + result.append(')'); + return result.toString(); + } + + return getAliasName(); + } + + /** + * This is the method required by the IAdaptable interface. + * Given an adapter class type, return an object castable to the type, or + * null if this is not possible. + */ + public Object getAdapter(Class adapterType) { + return Platform.getAdapterManager().getAdapter(this, adapterType); + } + + /** + * @generated This field/method will be replaced during code generation + */ + public String getSystemType() { + return systemType; + } + + /** + * Returns the alias name for this host + */ + public String getName() { + return getAliasName(); + } + + /** + * @generated This field/method will be replaced during code generation + * The unique key for this object. Unique per connection pool + */ + public String getAliasName() { + return aliasName; + } + + /** + * @generated This field/method will be replaced during code generation + */ + public String getHostName() { + return hostName; + } + + /** + * @generated This field/method will be replaced during code generation + */ + public String getDescription() { + return description; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setDescription(String newDescription) { + setDirty(!compareStrings(description, newDescription)); + description = newDescription; + } + + /** + * @generated This field/method will be replaced during code generation + */ + public boolean isPromptable() { + return promptable; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setPromptable(boolean newPromptable) { + setDirty(promptable != newPromptable); + promptable = newPromptable; + } + + /** + * + * Query if this connection is offline or not. It is up to each subsystem to honor this + * flag. + * + * @generated + */ + public boolean isOffline() { + return offline; + } + + /** + * + * Specify if this connection is offline or not. It is up to each subsystem to honor this + * flag. + * + * @generated + */ + public void setOffline(boolean newOffline) { + setDirty(offline != newOffline); + offline = newOffline; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setSystemTypeGen(String newSystemType) { + setDirty(!compareStrings(systemType, newSystemType)); + systemType = newSystemType; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setAliasNameGen(String newAliasName) { + setDirty(!compareStrings(aliasName, newAliasName)); + aliasName = newAliasName; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setHostNameGen(String newHostName) { + setDirty(!compareStrings(hostName, newHostName)); + hostName = newHostName; + } + + /** + * @generated This field/method will be replaced during code generation + */ + public String getDefaultUserIdGen() { + return defaultUserId; + } + + /** + * @generated This field/method will be replaced during code generation. + */ + public void setDefaultUserIdGen(String newDefaultUserId) { + setDirty(!compareStrings(defaultUserId, newDefaultUserId)); + defaultUserId = newDefaultUserId; + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.RSEModelObject#setDirty(boolean) + */ + public void setDirty(boolean flag) { + super.setDirty(flag); + ISystemHostPool myPool = getHostPool(); + if (myPool != null && flag) { + myPool.setDirty(true); + } + } + + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IRSEPersistableContainer#commit() + */ + public boolean commit() { + return RSEUIPlugin.getThePersistenceManager().commit(this); + } + +} \ No newline at end of file