### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.ui Index: model/org/eclipse/rse/internal/model/PropertySet.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/internal/model/PropertySet.java,v retrieving revision 1.1 diff -u -r1.1 PropertySet.java --- model/org/eclipse/rse/internal/model/PropertySet.java 10 Apr 2006 21:10:53 -0000 1.1 +++ model/org/eclipse/rse/internal/model/PropertySet.java 18 Jul 2006 12:50:26 -0000 @@ -30,7 +30,7 @@ private String _name; private Map _properties; - protected static PropertyType _defaultType = new PropertyType(IPropertyType.TYPE_STRING); + protected static IPropertyType _defaultType = PropertyType.getStringPropertyType(); public PropertySet(IPropertySet propertySet) { Index: subsystems/org/eclipse/rse/core/subsystems/IBMServerLauncher.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/IBMServerLauncher.java,v retrieving revision 1.4 diff -u -r1.4 IBMServerLauncher.java --- subsystems/org/eclipse/rse/core/subsystems/IBMServerLauncher.java 23 May 2006 17:07:53 -0000 1.4 +++ subsystems/org/eclipse/rse/core/subsystems/IBMServerLauncher.java 18 Jul 2006 12:50:26 -0000 @@ -98,39 +98,18 @@ protected boolean _autoDetectSSL = AUTODETECT_SSL_EDEFAULT; - protected PropertyType _serverLauncherEnumType; - protected PropertyType _intPropertyType; - protected PropertyType _booleanPropertyType; + protected IPropertyType _serverLauncherEnumType; protected IBMServerLauncher(String name, IConnectorService connectorService) { super(name, connectorService); } - public IPropertyType getIntegerPropertyType() - { - if (_intPropertyType == null) - { - _intPropertyType = new PropertyType(IPropertyType.TYPE_INTEGER); - } - return _intPropertyType; - } - - public IPropertyType getBooleanPropertyType() - { - if (_booleanPropertyType == null) - { - _booleanPropertyType = new PropertyType(IPropertyType.TYPE_BOOLEAN); - } - return _booleanPropertyType; - } - public IPropertyType getServerLauncherPropertyType() { if (_serverLauncherEnumType == null) { // for persistence - _serverLauncherEnumType = new PropertyType(IPropertyType.TYPE_ENUM); List values = Arrays.asList(getSupportedLauncherEnumTypes()); // DKM - only need supported types /// ServerLaunchType.VALUES; @@ -141,7 +120,7 @@ ServerLaunchType type = (ServerLaunchType)values.get(i); enumValues[i] = type.getName(); } - _serverLauncherEnumType.setEnumValues(enumValues); + _serverLauncherEnumType = PropertyType.getEnumPropertyType(enumValues); } return _serverLauncherEnumType; } @@ -221,16 +200,16 @@ IProperty launchTypeProperty = set.addProperty(KEY_SERVER_LAUNCH_TYPE_NAME, _serverLaunchType.getName(), getServerLauncherPropertyType()); launchTypeProperty.setLabel(SystemResources.RESID_PROP_SERVERLAUNCHER_MEANS_LABEL); - IProperty daemonPortProperty = set.addProperty(KEY_DAEMON_PORT, ""+_daemonPort, getIntegerPropertyType()); + IProperty daemonPortProperty = set.addProperty(KEY_DAEMON_PORT, ""+_daemonPort, PropertyType.getIntegerPropertyType()); daemonPortProperty.setEnabled(_serverLaunchType.getType() == ServerLaunchType.DAEMON); daemonPortProperty.setLabel(SystemResources.RESID_CONNECTION_DAEMON_PORT_LABEL); - IProperty rexecPortProperty = set.addProperty(KEY_REXEC_PORT, ""+_rexecPort, getIntegerPropertyType()); + IProperty rexecPortProperty = set.addProperty(KEY_REXEC_PORT, ""+_rexecPort, PropertyType.getIntegerPropertyType()); boolean usingRexec = _serverLaunchType.getType() == ServerLaunchType.REXEC; rexecPortProperty.setEnabled(usingRexec); rexecPortProperty.setLabel(SystemResources.RESID_CONNECTION_PORT_LABEL); - IProperty autoDetectSSLProperty = set.addProperty(KEY_AUTODETECT_SSL, ""+_autoDetectSSL, getBooleanPropertyType()); + IProperty autoDetectSSLProperty = set.addProperty(KEY_AUTODETECT_SSL, ""+_autoDetectSSL, PropertyType.getBooleanPropertyType()); autoDetectSSLProperty.setEnabled(usingRexec); autoDetectSSLProperty.setLabel(SystemResources.RESID_SUBSYSTEM_AUTODETECT_LABEL); Index: persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java,v retrieving revision 1.6 diff -u -r1.6 RSEDOMImporter.java --- persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java 28 Jun 2006 03:16:05 -0000 1.6 +++ persistence/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java 18 Jul 2006 12:50:26 -0000 @@ -513,7 +513,7 @@ { RSEDOMNodeAttribute attribute = attributes[i]; String typeStr = attribute.getType(); - IPropertyType type = new PropertyType(typeStr); + IPropertyType type = PropertyType.fromString(typeStr); set.addProperty(attribute.getKey(), attribute.getValue(), type); Index: model/org/eclipse/rse/model/PropertyType.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/model/PropertyType.java,v retrieving revision 1.2 diff -u -r1.2 PropertyType.java --- model/org/eclipse/rse/model/PropertyType.java 26 Apr 2006 22:19:55 -0000 1.2 +++ model/org/eclipse/rse/model/PropertyType.java 18 Jul 2006 12:50:26 -0000 @@ -21,55 +21,95 @@ public class PropertyType implements IPropertyType { - private final String ENUMERATION_STR = "enumeration:"; - private int _type = 0; - - private String[] _enumValues; + + private static final String ENUMERATION_STR = "enumeration:"; //$NON-NLS-1$ - public PropertyType(int type) + private static IPropertyType _booleanPropertyType = new PropertyType(TYPE_BOOLEAN); + private static IPropertyType _integerPropertyType = new PropertyType(TYPE_INTEGER); + private static IPropertyType _stringPropertyType = new PropertyType(TYPE_STRING); + + private PropertyType(int type) { _type = type; } - - public PropertyType(String typeStr) + + /** + * Return an instance of boolean property type. + * @return IPropertyType + */ + public static IPropertyType getBooleanPropertyType() + { + return _booleanPropertyType; + } + + /** + * Return an instance of integer property type. + * @return IPropertyType + */ + public static IPropertyType getIntegerPropertyType() + { + return _integerPropertyType; + } + + /** + * Return an instance of string property type. + * @return IPropertyType + */ + public static IPropertyType getStringPropertyType() + { + return _stringPropertyType; + } + + /** + * Return an instance of enum property type. + * @param values String[] array of allowed enumerator values. + * @return IPropertyType + */ + public static IPropertyType getEnumPropertyType(String[] values) + { + PropertyType type = new PropertyType(TYPE_ENUM); + type.setEnumValues(values); + return type; + } + + /** + * Return an instance of property type based on the String specification. + * This is the reverse of PropertyType.toString(). + * @return IPropertyType instance based on String specification. + */ + public static IPropertyType fromString(String typeStr) { if (typeStr.equals(String.class.toString())) { - setType(TYPE_STRING); + return getStringPropertyType(); } else if (typeStr.equals(Integer.class.toString())) { - setType(TYPE_INTEGER); + return getIntegerPropertyType(); } else if (typeStr.startsWith(ENUMERATION_STR)) { - setType(TYPE_ENUM); String subString = typeStr.substring(ENUMERATION_STR.length()); - String[] enumValues = subString.split(","); - setEnumValues(enumValues); + String[] enumValues = subString.split(","); //$NON-NLS-1$ + return getEnumPropertyType(enumValues); } else if (typeStr.equals(Boolean.class.toString())) { - setType(TYPE_BOOLEAN); + return getBooleanPropertyType(); } else { - setType(TYPE_STRING); + return getStringPropertyType(); } } - + public int getType() { return _type; } - public void setType(int type) - { - _type = type; - } - public boolean isString() { return _type == TYPE_STRING; @@ -90,11 +130,10 @@ return _type == TYPE_BOOLEAN; } - public void setEnumValues(String[] enumValues) + private void setEnumValues(String[] enumValues) { _enumValues = enumValues; } - public String[] getEnumValues() { @@ -121,7 +160,7 @@ buf.append(enumValues[i]); if (i + 1 < enumValues.length) { - buf.append(","); + buf.append(","); //$NON-NLS-1$ } } return buf.toString();