From 0336dce69be17e379debaea5db17c1a5aabb8e09 Mon Sep 17 00:00:00 2001 From: David Dykstal Date: Thu, 19 Apr 2007 18:33:35 +0000 Subject: [PATCH] [181064] persist environment variables in the order they were entered --- .../eclipse/rse/core/model/IPropertySet.java | 6 + .../rse/core/model/IPropertySetContainer.java | 50 ++++ .../eclipse/rse/core/model/PropertyList.java | 52 ++++ .../eclipse/rse/core/model/PropertySet.java | 5 + .../rse/core/model/PropertySetContainer.java | 4 + .../core/subsystems/IRemoteSystemEnvVar.java | 2 + .../persistence/dom/RSEDOMExporter.java | 11 +- .../persistence/dom/RSEDOMImporter.java | 13 +- .../shells/subsystems/RemoteSystemEnvVar.java | 2 + .../core/subsystems/IRemoteCmdSubSystem.java | 7 - .../core/subsystems/RemoteCmdSubSystem.java | 236 +++++++----------- .../ui/widgets/EnvironmentVariablesForm.java | 22 +- 12 files changed, 241 insertions(+), 169 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyList.java diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java index 640c5ec6569..d05a1716cc2 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySet.java @@ -88,6 +88,8 @@ public interface IPropertySet { * * Provided that the Set has a description, the * @link{DESCRIPTION_KEY} key will also be in the list. + * The interface defines no particular ordering for the + * keys. * * @return String array of Property keys. */ @@ -161,4 +163,8 @@ public interface IPropertySet { */ public void setContainer(IPropertySetContainer container); + /** + * @return the container of this property set or null if there is no container. + */ + public IPropertySetContainer getContainer(); } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySetContainer.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySetContainer.java index f98d7a753e5..a2dc251f215 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySetContainer.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertySetContainer.java @@ -16,19 +16,69 @@ package org.eclipse.rse.core.model; +/** + * A property set container is capable of containing property sets. This interface allows for the + * addition, retrieval, and deletion of property sets from the container. A property set may have only + * one container. + */ public interface IPropertySetContainer { + + /** + * Retrieves an array all property sets known to this container. It will return an empty array if this + * container has property sets. The order of these property sets is not dictated by the interface. + * @return an array of property sets. + */ public IPropertySet[] getPropertySets(); + /** + * Retrieves a particular property set by its name. + * @param name the name of the property set. + * @return the named property set or null if one by that name does not exist. + */ public IPropertySet getPropertySet(String name); + /** + * Creates a new property set of a particular name in this container. + * If one already exists + * by this name it is replaced with a new empty property set. + * @param name the name of the property set. + * @return The property set. + */ public IPropertySet createPropertySet(String name); + /** + * Creates a new property set of a particular name and description in this container. + * If one already exists + * by this name it is replaced with a new empty property set. + * @param name the name of the property set. + * @param description the description (usually already localized) for this property set. + * @return the newly created property set. + */ public IPropertySet createPropertySet(String name, String description); + /** + * Adds an existing property set to this container. If the property set already has a container + * it is removed from that container and added to this one. If this container already + * has a property set by this name, this one replaces it. + * @param set the property set to be added. + * @return true if the property set was added. + */ public boolean addPropertySet(IPropertySet set); + /** + * Adds a number of existing property sets to this container. + * @param sets the sets to be added + * @return true if all property sets were added. + * @see #addPropertySet(IPropertySet) + */ public boolean addPropertySets(IPropertySet[] sets); + /** + * Removes a particular property set from this container. + * @param name the name of the property set to be removed + * @return true if the property set was removed; + * false if a property set was not removed, usually if it does not exist in the container. + */ public boolean removePropertySet(String name); } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyList.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyList.java new file mode 100644 index 00000000000..2c7b374bdc8 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyList.java @@ -0,0 +1,52 @@ +package org.eclipse.rse.core.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * A property list is an ordered property set. As items are added and removed their arrival order is + * maintained. + */ +public class PropertyList extends PropertySet { + + private List _keys = new ArrayList(10); + + public PropertyList(String name) { + super(name); + } + + public IProperty addProperty(String key, IProperty property) { + _keys.remove(key); + _keys.add(key); + return super.addProperty(key, property); + } + + public IProperty addProperty(String key, String value) { + _keys.remove(key); + _keys.add(key); + return super.addProperty(key, value); + } + + public IProperty addProperty(String key, String value, IPropertyType type) { + _keys.remove(key); + _keys.add(key); + return super.addProperty(key, value, type); + } + + public String[] getPropertyKeys() { + return (String[]) _keys.toArray(new String[_keys.size()]); + } + + public boolean removeProperty(String key) { + _keys.remove(key); + return super.removeProperty(key); + } + + public void setProperties(Map map) { + _keys.clear(); + _keys.addAll(map.keySet()); + super.setProperties(map); + } + +} diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java index 3c9824f16e3..005e8971a2e 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySet.java @@ -30,6 +30,7 @@ import java.util.Set; * not thread-safe. */ public class PropertySet extends RSEPersistableObject implements IPropertySet, Observer { + private String _name; private Map _properties; private IPropertySetContainer _container = null; @@ -178,6 +179,10 @@ public class PropertySet extends RSEPersistableObject implements IPropertySet, O _container = container; } + public IPropertySetContainer getContainer() { + return _container; + } + public void update(Observable o, Object arg) { setDirty(true); } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySetContainer.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySetContainer.java index 2904bd74152..b63bd716d37 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySetContainer.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertySetContainer.java @@ -58,6 +58,10 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen } public boolean addPropertySet(IPropertySet set) { + IPropertySetContainer old = set.getContainer(); + if (old != null) { + old.removePropertySet(set.getName()); + } set.setContainer(this); _propertySets.put(set.getName(), set); return true; diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IRemoteSystemEnvVar.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IRemoteSystemEnvVar.java index 878553f4630..aed0e930601 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IRemoteSystemEnvVar.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IRemoteSystemEnvVar.java @@ -61,12 +61,14 @@ public interface IRemoteSystemEnvVar { * @generated This field/method will be replaced during code generation * @return The value of the AdditionalAttributes attribute * Additional attributes that may need to be persisted per environment variable. + * @deprecated */ String getAdditionalAttributes(); /** * @generated This field/method will be replaced during code generation * @param value The new value of the AdditionalAttributes attribute + * @deprecated */ void setAdditionalAttributes(String value); diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java index ca6c54a2ad4..e98f0d2c9dd 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMExporter.java @@ -161,18 +161,23 @@ public class RSEDOMExporter implements IRSEDOMExporter { */ public RSEDOMNode[] createPropertySetNodes(RSEDOMNode parent, IRSEModelObject modelObject, boolean clean) { IPropertySet[] propertySets = modelObject.getPropertySets(); + RSEDOMNode[] result = new RSEDOMNode[propertySets.length]; for (int i = 0; i < propertySets.length; i++) { IPropertySet set = propertySets[i]; - RSEDOMNode node = new RSEDOMNode(parent, IRSEDOMConstants.TYPE_PROPERTY_SET, set.getName()); + RSEDOMNode propertySetNode = new RSEDOMNode(parent, IRSEDOMConstants.TYPE_PROPERTY_SET, set.getName()); String[] keys = set.getPropertyKeys(); for (int k = 0; k < keys.length; k++) { String key = keys[k]; String value = set.getPropertyValue(key); IPropertyType type = set.getPropertyType(key); - node.addAttribute(key, value, type.toString()); + RSEDOMNode propertyNode = new RSEDOMNode(propertySetNode, IRSEDOMConstants.TYPE_PROPERTY, key); + propertyNode.addAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE, type.toString()); + propertyNode.addAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE, value); + } + result[i] = propertySetNode; } - return parent.getChildren(); + return result; } /** diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java index 52afcaf9aaf..11134c331f9 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/dom/RSEDOMImporter.java @@ -423,14 +423,23 @@ public class RSEDOMImporter { public IPropertySet restorePropertySet(IRSEModelObject modelObject, RSEDOMNode propertySetNode) { String name = propertySetNode.getName(); IPropertySet set = modelObject.createPropertySet(name); + // properties used to be stored as attributes, get those first for compatability RSEDOMNodeAttribute[] attributes = propertySetNode.getAttributes(); for (int i = 0; i < attributes.length; i++) { RSEDOMNodeAttribute attribute = attributes[i]; String typeStr = attribute.getType(); IPropertyType type = PropertyType.fromString(typeStr); - set.addProperty(attribute.getKey(), attribute.getValue(), type); - + } + // properties are now stored as children, get those next + RSEDOMNode[] children = propertySetNode.getChildren(); + for (int i = 0; i < children.length; i++) { + RSEDOMNode child = children[i]; + String propertyName = child.getName(); + String propertyValue = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_VALUE).getValue(); + String propertyTypeName = child.getAttribute(IRSEDOMConstants.ATTRIBUTE_TYPE).getValue(); + IPropertyType propertyType = PropertyType.fromString(propertyTypeName); + set.addProperty(propertyName, propertyValue, propertyType); } return set; } diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteSystemEnvVar.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteSystemEnvVar.java index 52487f70ac3..f92885f2478 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteSystemEnvVar.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/internal/subsystems/shells/subsystems/RemoteSystemEnvVar.java @@ -128,6 +128,7 @@ public class RemoteSystemEnvVar implements IRemoteSystemEnvVar /** * @generated This field/method will be replaced during code generation * Additional attributes that may need to be persisted per environment variable. + * @deprecated */ public String getAdditionalAttributes() { @@ -136,6 +137,7 @@ public class RemoteSystemEnvVar implements IRemoteSystemEnvVar /** * @generated This field/method will be replaced during code generation. + * @deprecated */ public void setAdditionalAttributes(String newAdditionalAttributes) { diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCmdSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCmdSubSystem.java index bb06f587beb..55a42252475 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCmdSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCmdSubSystem.java @@ -216,13 +216,6 @@ public interface IRemoteCmdSubSystem extends ISubSystem{ */ public String getInvalidEnvironmentVariableNameCharacters(); - /** - * Private. Do not override or call. - * @generated This field/method will be replaced during code generation - * @return The list of EnvVars references - */ - java.util.List getEnvVars(); - public List getHostEnvironmentVariables(); diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java index e179c0ce3d4..1a4f493e9e8 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java @@ -18,17 +18,18 @@ package org.eclipse.rse.subsystems.shells.core.subsystems; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IProperty; import org.eclipse.rse.core.model.IPropertySet; +import org.eclipse.rse.core.model.PropertyList; import org.eclipse.rse.core.subsystems.CommunicationsEvent; import org.eclipse.rse.core.subsystems.ICommunicationsListener; import org.eclipse.rse.core.subsystems.IConnectorService; @@ -57,12 +58,9 @@ import org.eclipse.swt.widgets.Shell; public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmdSubSystem, ICommunicationsListener { - public static String COMMAND_SHELLS_MEMENTO = "commandshells"; //$NON-NLS-1$ - - protected java.util.List envVars = null; - - protected List _envVars; - + private static String COMMAND_SHELLS_MEMENTO = "commandshells"; //$NON-NLS-1$ + private static String ENVIRONMENT_VARS = "EnvironmentVariables"; //$NON-NLS-1$ + protected ArrayList _cmdShells; protected IRemoteCommandShell _defaultShell; @@ -128,164 +126,115 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd * RemoteSystemEnvVar objects. Array returned may be size zero but will not * be null. */ - public IRemoteSystemEnvVar[] getEnvironmentVariableList() - { - java.util.List initEVL = getEnvVars(); - IRemoteSystemEnvVar[] envl = new IRemoteSystemEnvVar[initEVL.size()]; - Iterator i = initEVL.iterator(); - int idx = 0; - while (i.hasNext()) - envl[idx++] = (IRemoteSystemEnvVar) i.next(); - return envl; + public IRemoteSystemEnvVar[] getEnvironmentVariableList() { + IPropertySet environmentVariables = getEnvironmentVariables(); + String[] names = environmentVariables.getPropertyKeys(); + IRemoteSystemEnvVar[] result = new IRemoteSystemEnvVar[names.length]; + for (int i = 0; i < names.length; i++) { + String name = names[i]; + String value = environmentVariables.getPropertyValue(name); + IRemoteSystemEnvVar v = new RemoteSystemEnvVar(); + v.setName(name); + v.setValue(value); + result[i] = v; + } + return result; } /** * Set the initial environment variable list entries, all in one shot, using * a pair of String arrays: the first is the environment variable names, the * second is the corresponding environment variable values. - *

- * Note, this calls getParentSubSystemConfiguration().saveSubSystem(this) for you. + * @param names the array of names + * @param values the array of string values */ - public void setEnvironmentVariableList(String[] envVarNames, String[] envVarValues) - { - java.util.List initEVL = getEnvVars(); - initEVL.clear(); - if (envVarNames != null) - { - IRemoteSystemEnvVar rsev = null; - for (int idx = 0; idx < envVarNames.length; idx++) - { - rsev = new RemoteSystemEnvVar(); - rsev.setName(envVarNames[idx]); - rsev.setValue(envVarValues[idx]); - initEVL.add(rsev); + public void setEnvironmentVariableList(String[] names, String[] values) { + removePropertySet(ENVIRONMENT_VARS); + IPropertySet environmentVariables = getEnvironmentVariables(); + if (names != null) { + for (int i = 0; i < names.length; i++) { + environmentVariables.addProperty(names[i], values[i]); } } - try - { - if (getSubSystemConfiguration() != null) - getSubSystemConfiguration().saveSubSystem(this); - } - catch (Exception exc) - { - SystemBasePlugin.logError("Error saving command subsystem after setting env var entries", exc); //$NON-NLS-1$ + try { + if (getSubSystemConfiguration() != null) getSubSystemConfiguration().saveSubSystem(this); + } catch (Exception exc) { + RSECorePlugin.getDefault().getLogger().logError("Error saving command subsystem after setting env var entries", exc); //$NON-NLS-1$ } } /** * Add environment variable entry, given a name and value */ - public void addEnvironmentVariable(String name, String value) - { - /* - * FIXME RemoteSystemEnvVar rsev = - * SubSystemConfigurationImpl.getSSMOFfactory().createRemoteSystemEnvVar(); - * rsev.setName(name); rsev.setValue(value); - * addEnvironmentVariable(rsev); - */ - RemoteSystemEnvVar rsev = new RemoteSystemEnvVar(); - rsev.setName(name); - rsev.setValue(value); - addEnvironmentVariable(rsev); - return; + public void addEnvironmentVariable(String name, String value) { + IPropertySet environmentVariables = getEnvironmentVariables(); + environmentVariables.addProperty(name, value); + commit(); } /** * Add environment variable entry, given a RemoteSystemEnvVar object */ - public void addEnvironmentVariable(IRemoteSystemEnvVar rsev) - { - getEnvVars().add(rsev); - try - { - getSubSystemConfiguration().saveSubSystem(this); - } - catch (Exception exc) - { - SystemBasePlugin.logError("Error saving command subsystem after adding env var entry", exc); //$NON-NLS-1$ - } + public void addEnvironmentVariable(IRemoteSystemEnvVar rsev) { + addEnvironmentVariable(rsev.getName(), rsev.getValue()); } /** * Remove environment variable entry given its RemoteSystemEnvVar object + * @param rsev the remote system environment variable to remove */ - public void removeEnvironmentVariable(IRemoteSystemEnvVar rsev) - { - getEnvVars().remove(rsev); - try - { - getSubSystemConfiguration().saveSubSystem(this); - } - catch (Exception exc) - { - SystemBasePlugin.logError("Error saving command subsystem after removing env var entry", exc); //$NON-NLS-1$ - } + public void removeEnvironmentVariable(IRemoteSystemEnvVar rsev) { + removeEnvironmentVariable(rsev.getName()); } /** * Remove environment variable entry given only its environment variable * name */ - public void removeEnvironmentVariable(String name) - { - IRemoteSystemEnvVar rsev = getEnvironmentVariable(name); - if (rsev != null) - removeEnvironmentVariable(rsev); + public void removeEnvironmentVariable(String name) { + IPropertySet environmentVariables = getEnvironmentVariables(); + environmentVariables.removeProperty(name); + commit(); } /** * Given an environment variable name, find its RemoteSystemEnvVar object. - * Returns null if not found! + * Returns null if not found. */ - public IRemoteSystemEnvVar getEnvironmentVariable(String name) - { - java.util.List envVarList = getEnvVars(); - IRemoteSystemEnvVar match = null; - Iterator i = envVarList.iterator(); - while ((match == null) && i.hasNext()) - { - IRemoteSystemEnvVar rsev = (IRemoteSystemEnvVar) i.next(); - if (rsev.getName().equals(name)) - match = rsev; + public IRemoteSystemEnvVar getEnvironmentVariable(String name) { + IRemoteSystemEnvVar result = null; + String value = getEnvironmentVariableValue(name); + if (value != null) { + result = new RemoteSystemEnvVar(); + result.setName(name); + result.setValue(value); } - return match; + return result; } /** * Given an environment variable name, find its value. Returns null if not * found. */ - public String getEnvironmentVariableValue(String name) - { - IRemoteSystemEnvVar match = getEnvironmentVariable(name); - if (match != null) - return match.getValue(); - else - return null; + public String getEnvironmentVariableValue(String name) { + IPropertySet environmentVariables = getEnvironmentVariables(); + String value = environmentVariables.getPropertyValue(name); + return value; } /** * */ - protected String[] getEnvVarsAsStringArray() - { - String[] envVars = null; - IRemoteSystemEnvVar[] list = getEnvironmentVariableList(); - if (list != null && list.length > 0) - { - envVars = new String[list.length]; - for (int i = 0; i < list.length; i++) - { - String name = list[i].getName(); - if (isWindows()) - { - name = name.toUpperCase(); - } - envVars[i] = name + "=" + list[i].getValue(); //$NON-NLS-1$ - } + protected String[] getEnvVarsAsStringArray() { + IPropertySet environmentVariables = getEnvironmentVariables(); + String[] names = environmentVariables.getPropertyKeys(); + String[] result = new String[names.length]; + for (int i = 0; i < names.length; i++) { + String name = names[i]; + String value = environmentVariables.getPropertyValue(name); + result[i] = name + "=" + value; //$NON-NLS-1$ } - - return envVars; + return result; } protected boolean isUniqueVariable(List variables, String varName) @@ -460,7 +409,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd * @see org.eclipse.rse.core.subsystems.SubSystem#internalResolveFilterString(IProgressMonitor,String) */ protected Object[] internalResolveFilterString(IProgressMonitor monitor, String filterString) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException + throws InvocationTargetException, InterruptedException { return null; } @@ -611,8 +560,8 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd } } - protected void internalRemoveShell(Object command) throws java.lang.reflect.InvocationTargetException, - java.lang.InterruptedException + protected void internalRemoveShell(Object command) throws InvocationTargetException, + InterruptedException { if (command instanceof IRemoteCommandShell) { @@ -800,19 +749,23 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd } } - /** - * @generated This field/method will be replaced during code generation - */ - public java.util.List getEnvVars() - { - if (envVars == null) - { - envVars = new ArrayList();// FIXME new - // EObjectContainmenteList(RemoteSystemEnvVar.class, - // this, - // SubsystemsPackage.REMOTE_CMD_SUB_SYSTEM__ENV_VARS); + private IPropertySet getEnvironmentVariables() { + IPropertySet environmentVariables = getPropertySet(ENVIRONMENT_VARS); + if (environmentVariables == null) { + environmentVariables = createPropertySet(ENVIRONMENT_VARS); } - return envVars; + return environmentVariables; + } + + public IPropertySet createPropertySet(String name) { + IPropertySet result = null; + if (name.equals(ENVIRONMENT_VARS)) { + result = new PropertyList(ENVIRONMENT_VARS); + addPropertySet(result); + } else { + result = super.createPropertySet(name); + } + return result; } /** @@ -821,8 +774,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd */ public Object[] runCommand(String command, Object context, boolean interpretOutput) throws Exception { -//dwd if (shell != null) -//dwd this.shell = shell; return internalRunCommand(null, command, context, interpretOutput); } @@ -831,8 +782,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd */ public Object[] runCommand(IProgressMonitor monitor, String command, Object context, boolean interpretOutput) throws Exception { -//dwd if (shell != null) -//dwd this.shell = shell; return internalRunCommand(monitor, command, context, interpretOutput); } @@ -843,8 +792,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd */ public IRemoteCommandShell runShell(Object context) throws Exception { -//dwd if (shell != null) -//dwd this.shell = shell; IRemoteCommandShell cmdShell = null; if (isConnected()) { @@ -929,7 +876,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { try { -//dwd this.shell = shell; // FIXME remove this SendCommandToShellJob job = new SendCommandToShellJob(input, commandObject); scheduleJob(job, null); @@ -990,7 +936,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { try { -//dwd this.shell = shell; // FIXME remove this CancelShellJob job = new CancelShellJob(commandObject); scheduleJob(job, null); } @@ -1052,7 +997,6 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { try { -//dwd this.shell = shell; // FIXME remove this RemoveShellJob job = new RemoveShellJob(commandObject); scheduleJob(job, null); } @@ -1264,7 +1208,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd *

  • if the user cancels (monitor.isCanceled()), throw new * InterruptedException() *
  • if something else bad happens, throw new - * java.lang.reflect.InvocationTargetException(exc); + * InvocationTargetException(exc); *
  • do not worry about calling monitor.done() ... caller will do that! * * YOU MUST OVERRIDE THIS IF YOU SUPPORT COMMANDS! @@ -1284,30 +1228,30 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd *
  • if the user cancels (monitor.isCanceled()), throw new * InterruptedException() *
  • if something else bad happens, throw new - * java.lang.reflect.InvocationTargetException(exc); + * InvocationTargetException(exc); *
  • do not worry about calling monitor.done() ... caller will do that! * * YOU MUST OVERRIDE THIS IF YOU SUPPORT COMMANDS! */ protected Object[] internalRunCommand(IProgressMonitor monitor, String cmd, Object context, boolean interpretOutput) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException, SystemMessageException + throws InvocationTargetException, InterruptedException, SystemMessageException { return null; } protected IRemoteCommandShell internalRunShell(IProgressMonitor monitor, Object context) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException, SystemMessageException + throws InvocationTargetException, InterruptedException, SystemMessageException { return null; } protected void internalCancelShell(IProgressMonitor monitor, Object command) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException + throws InvocationTargetException, InterruptedException { } protected void internalSendCommandToShell(IProgressMonitor monitor, String cmd, Object command) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException + throws InvocationTargetException, InterruptedException { } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/EnvironmentVariablesForm.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/EnvironmentVariablesForm.java index 6ff95645833..2aa816a6f49 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/EnvironmentVariablesForm.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/EnvironmentVariablesForm.java @@ -590,17 +590,17 @@ public class EnvironmentVariablesForm extends SystemBaseForm implements Selectio } // next check for duplicate env var names - String existingName; - int currentSelection = envVarTable.getSelectionIndex(); - for (int i = 0; i < envVars.size() && msg == null; i++) - { - existingName = ((EnvironmentVariable) envVars.get(i)).getName(); - if (currentSelection != i && existingName.equals(name)) - { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_ENVVAR_DUPLICATE); - msg.makeSubstitution(existingName); - } - } + int numberFound = 0; + int itemCount = envVarTable.getItemCount(); + for (int i = 0; i < itemCount; i++) { + TableItem item = envVarTable.getItem(i); + String itemName = item.getText(0); + if (itemName.equals(name)) numberFound++; + } + if (numberFound > 1) { + msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_ENVVAR_DUPLICATE); + msg.makeSubstitution(name); + } } }