1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-18 14:35:23 +02:00

[338510] "Copy Connection" operation deletes the registered property set in the original connection

This commit is contained in:
David McKnight 2011-03-02 13:50:51 +00:00
parent 1335f9a633
commit c0c44198a8
7 changed files with 75 additions and 34 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.core;singleton:=true 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-Activator: org.eclipse.rse.core.RSECorePlugin
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime, Require-Bundle: org.eclipse.core.runtime,

View file

@ -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 * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType
* David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - 142806: refactoring persistence framework
* David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement * 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; package org.eclipse.rse.core.model;
@ -264,4 +265,11 @@ public class DummyHost extends PlatformObject implements IHost
public void setDefaultEncoding(String encoding, boolean fromRemote) { public void setDefaultEncoding(String encoding, boolean fromRemote) {
} }
/**
* @since 3.2
*/
public void clonePropertySets(IPropertySetContainer targetContainer) {
}
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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 * 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) - [226561] Add API markup to RSE javadocs for extend / implement
* David Dykstal (IBM) - [261486][api] add noextend to interfaces that require it * 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; 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. * false if a property set was not removed, usually if it does not exist in the container.
*/ */
public boolean removePropertySet(String name); 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);
} }

View file

@ -14,10 +14,12 @@
* David Dykstal (IBM) - 142806: refactoring persistence framework * David Dykstal (IBM) - 142806: refactoring persistence framework
* David Dykstal (IBM) - [226561] Add API markup to RSE javadocs for extend / implement * 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) - [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; package org.eclipse.rse.core.model;
import java.io.ObjectInputStream.GetField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -84,5 +86,30 @@ public abstract class PropertySetContainer extends RSEPersistableObject implemen
public boolean removePropertySet(String name) { public boolean removePropertySet(String name) {
return _propertySets.remove(name) != null; 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());
}
}
} }

View file

@ -14,6 +14,7 @@
* Martin Oberhuber (Wind River) - [185750] Remove IConnectorService.getHostType() * Martin Oberhuber (Wind River) - [185750] Remove IConnectorService.getHostType()
* David Dykstal (IBM) - [210474] Deny save password function missing * David Dykstal (IBM) - [210474] Deny save password function missing
* David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception * 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; 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.core.runtime.OperationCanceledException;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IPropertySet; 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.IRSEPersistableContainer;
public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService
@ -811,4 +813,15 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC
return result; return result;
} }
/**
* @since 3.2
*/
public void clonePropertySets(IPropertySetContainer targetContainer) {
IConnectorService connectorService = getRealConnectorService();
if (connectorService != null) {
connectorService.clonePropertySets(targetContainer);
}
}
} }

View file

@ -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 * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -22,6 +22,7 @@
* Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe * Martin Oberhuber (Wind River) - [206742] Make SystemHostPool thread-safe
* David Dykstal (IBM) - [210537] removed exception signaling from this class to match the interface * 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 * 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; 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.RSEPreferencesManager;
import org.eclipse.rse.core.model.Host; import org.eclipse.rse.core.model.Host;
import org.eclipse.rse.core.model.IHost; 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.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISystemHostPool; import org.eclipse.rse.core.model.ISystemHostPool;
import org.eclipse.rse.core.model.ISystemProfile; 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); conn.getHostName(), conn.getDescription(), conn.getLocalDefaultUserId(), IRSEUserIdConstants.USERID_LOCATION_HOST);
// Copy all properties as well. // Copy all properties as well.
clonePropertySets(copy, conn.getPropertySets()); conn.clonePropertySets(copy);
return 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) * (non-Javadoc)
* @see org.eclipse.rse.core.model.ISystemHostPool#moveHosts(org.eclipse.rse.core.model.IHost[], int) * @see org.eclipse.rse.core.model.ISystemHostPool#moveHosts(org.eclipse.rse.core.model.IHost[], int)

View file

@ -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 * 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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
@ -37,6 +37,7 @@
* Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding() * Martin Oberhuber (Wind River) - [226574][api] Add ISubSystemConfiguration#supportsEncoding()
* David Dykstal (IBM) - [236516] Bug in user code causes failure in RSE initialization * David Dykstal (IBM) - [236516] Bug in user code causes failure in RSE initialization
* Martin Oberhuber (Wind River) - [218309] ConcurrentModificationException during workbench startup * 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; 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.filters.ISystemFilterString;
import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.ILabeledObject; 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.IRSEPersistableContainer;
import org.eclipse.rse.core.model.ISubSystemConfigurator; import org.eclipse.rse.core.model.ISubSystemConfigurator;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
@ -1057,6 +1061,7 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
} }
return subsys; return subsys;
} }
/** /**
* Clone a given subsystem into the given connection. * Clone a given subsystem into the given connection.
* Called when user does a copy-connection action. * Called when user does a copy-connection action.
@ -1076,7 +1081,9 @@ public abstract class SubSystemConfiguration implements ISubSystemConfiguration
internalInitializeNewSubSystem(subsys, newConnection); internalInitializeNewSubSystem(subsys, newConnection);
// copy common data // copy common data
subsys.setName(oldSubsystem.getName()); // just in case it was changed subsys.setName(oldSubsystem.getName()); // just in case it was changed
subsys.addPropertySets(oldSubsystem.getPropertySets());
oldSubsystem.clonePropertySets(subsys);
subsys.setHidden(oldSubsystem.isHidden()); subsys.setHidden(oldSubsystem.isHidden());