From c0c44198a89ca312ada60da41eebc99638fb9937 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 2 Mar 2011 13:50:51 +0000 Subject: [PATCH] [338510] "Copy Connection" operation deletes the registered property set in the original connection --- .../org.eclipse.rse.core/META-INF/MANIFEST.MF | 2 +- .../org/eclipse/rse/core/model/DummyHost.java | 10 +++++- .../rse/core/model/IPropertySetContainer.java | 12 ++++++- .../rse/core/model/PropertySetContainer.java | 27 +++++++++++++++ .../AbstractDelegatingConnectorService.java | 13 +++++++ .../internal/core/model/SystemHostPool.java | 34 +++---------------- .../subsystems/SubSystemConfiguration.java | 11 ++++-- 7 files changed, 75 insertions(+), 34 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.core/META-INF/MANIFEST.MF index 04ee1e26e2c..3f000c6622f 100644 --- a/rse/plugins/org.eclipse.rse.core/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.rse.core;singleton:=true -Bundle-Version: 3.1.200.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Activator: org.eclipse.rse.core.RSECorePlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/DummyHost.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/DummyHost.java index a8a0a7e16d3..1ef3a1f4b3d 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/DummyHost.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/DummyHost.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2011 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 @@ -14,6 +14,7 @@ * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType * David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection ********************************************************************************/ package org.eclipse.rse.core.model; @@ -264,4 +265,11 @@ public class DummyHost extends PlatformObject implements IHost public void setDefaultEncoding(String encoding, boolean fromRemote) { } + + /** + * @since 3.2 + */ + public void clonePropertySets(IPropertySetContainer targetContainer) { + } + } \ 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 6b1e2e0c46c..d52e7e4ac5a 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2011 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 @@ -15,6 +15,7 @@ * Johann Draschwandtner (Wind River) - [227509][apidoc] Add note how to persist property sets * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement * David Dykstal (IBM) - [261486][api] add noextend to interfaces that require it + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection *******************************************************************************/ package org.eclipse.rse.core.model; @@ -100,5 +101,14 @@ public interface IPropertySetContainer { * false if a property set was not removed, usually if it does not exist in the container. */ public boolean removePropertySet(String name); + + /** + * Make copies of a list of property sets and add them to the specified container. + * Each property set may contain its own list of property sets, so the + * method is recursive. + * @param targetContainer new container to copy property sets into + * @since 3.2 + */ + public void clonePropertySets(IPropertySetContainer targetContainer); } 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 476cd224c46..8fc62c7d639 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 @@ -14,10 +14,12 @@ * David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement * David McKnight (IBM) - [334837] Ordering of Library list entries incorrect after migration + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection ********************************************************************************/ package org.eclipse.rse.core.model; +import java.io.ObjectInputStream.GetField; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; @@ -84,5 +86,30 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen public boolean removePropertySet(String name) { return _propertySets.remove(name) != null; } + + /** + * @since 3.2 + */ + public void clonePropertySets(IPropertySetContainer container) { + IPropertySet[] propertySets = getPropertySets(); + if (propertySets != null && propertySets.length > 0) + clonePropertySets(container, propertySets); + } + + private void clonePropertySets(IPropertySetContainer container, IPropertySet[] propertySets){ + if (propertySets == null) { + return; + } + for (int i = 0, n = propertySets.length; i < n; ++i) { + IPropertySet fromSet = propertySets[i]; + IPropertySet copySet = container.createPropertySet(fromSet.getName(), fromSet.getDescription()); + String[] fromKeys = fromSet.getPropertyKeys(); + for (int i2 = 0, n2 = fromKeys.length; i2 < n2; ++i2) { + IProperty fromProperty = fromSet.getProperty(fromKeys[i2]); + copySet.addProperty(fromProperty.getKey(), fromProperty.getValue(), fromProperty.getType()); + } + clonePropertySets(copySet, fromSet.getPropertySets()); + } + } } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java index 576b824cd2d..f05f915c260 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java @@ -14,6 +14,7 @@ * Martin Oberhuber (Wind River) - [185750] Remove IConnectorService.getHostType() * David Dykstal (IBM) - [210474] Deny save password function missing * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection ********************************************************************************/ package org.eclipse.rse.core.subsystems; @@ -21,6 +22,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IPropertySet; +import org.eclipse.rse.core.model.IPropertySetContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer; public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService @@ -811,4 +813,15 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC return result; } + /** + * @since 3.2 + */ + public void clonePropertySets(IPropertySetContainer targetContainer) { + IConnectorService connectorService = getRealConnectorService(); + if (connectorService != null) { + connectorService.clonePropertySets(targetContainer); + } + } + + } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemHostPool.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemHostPool.java index 415eafb24c3..43507d6d73d 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemHostPool.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemHostPool.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2011 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 @@ -22,6 +22,7 @@ * Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe * David Dykstal (IBM) - [210537] removed exception signaling from this class to match the interface * Tom Hochstein (Freescale) - [301075] Host copy doesn't copy contained property sets + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection ********************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -38,9 +39,6 @@ import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.model.Host; 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.IPropertySetContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.ISystemHostPool; import org.eclipse.rse.core.model.ISystemProfile; @@ -410,33 +408,11 @@ public class SystemHostPool extends RSEModelObject implements ISystemHostPool conn.getHostName(), conn.getDescription(), conn.getLocalDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_HOST); // Copy all properties as well. - clonePropertySets(copy, conn.getPropertySets()); + conn.clonePropertySets(copy); return copy; } - - /** - * Make copies of a list of property sets and add them to the specified container. - * Each property set may contain its own list of property sets, so the - * method is recursive. - * @param container - * @param propertySets - */ - private static void clonePropertySets(IPropertySetContainer container, IPropertySet[] propertySets) { - if (propertySets == null) { - return; - } - for (int i = 0, n = propertySets.length; i < n; ++i) { - IPropertySet fromSet = propertySets[i]; - IPropertySet copySet = container.createPropertySet(fromSet.getName(), fromSet.getDescription()); - String[] fromKeys = fromSet.getPropertyKeys(); - for (int i2 = 0, n2 = fromKeys.length; i2 < n2; ++i2) { - IProperty fromProperty = fromSet.getProperty(fromKeys[i2]); - copySet.addProperty(fromProperty.getKey(), fromProperty.getValue(), fromProperty.getType()); - } - clonePropertySets(copySet, fromSet.getPropertySets()); - } - } - + + /* * (non-Javadoc) * @see org.eclipse.rse.core.model.ISystemHostPool#moveHosts(org.eclipse.rse.core.model.IHost[], int) diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java index 68a521d72e1..d814cc4ca34 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystemConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved. + * Copyright (c) 2002, 2011 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 @@ -37,6 +37,7 @@ * Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding() * David Dykstal (IBM) - [236516] Bug in user code causes failure in RSE initialization * Martin Oberhuber (Wind River) - [218309] ConcurrentModificationException during workbench startup + * David McKnight (IBM) - [338510] "Copy Connection" operation deletes the registered property set in the original connection ********************************************************************************/ package org.eclipse.rse.core.subsystems; @@ -66,6 +67,9 @@ import org.eclipse.rse.core.filters.ISystemFilterPoolWrapperInformation; import org.eclipse.rse.core.filters.ISystemFilterString; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ILabeledObject; +import org.eclipse.rse.core.model.IProperty; +import org.eclipse.rse.core.model.IPropertySet; +import org.eclipse.rse.core.model.IPropertySetContainer; import org.eclipse.rse.core.model.IRSEPersistableContainer; import org.eclipse.rse.core.model.ISubSystemConfigurator; import org.eclipse.rse.core.model.ISystemProfile; @@ -1057,6 +1061,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration } return subsys; } + /** * Clone a given subsystem into the given connection. * Called when user does a copy-connection action. @@ -1076,7 +1081,9 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration internalInitializeNewSubSystem(subsys, newConnection); // copy common data subsys.setName(oldSubsystem.getName()); // just in case it was changed - subsys.addPropertySets(oldSubsystem.getPropertySets()); + + oldSubsystem.clonePropertySets(subsys); + subsys.setHidden(oldSubsystem.isHidden());