Bug 491356 - Modify behavior of CONNECTION_RENAMED events
Change-Id: Ia42fc1b1f9784a33442f4275e99bb373c40c2e06
Signed-off-by: Jonathan Williams <jonwilliams@qnx.com>
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
index 333e152..f73ca73 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
@@ -34,7 +34,8 @@
public static final int CONNECTION_ABORTED = 1 << 2;
/**
- * Event indicating that the connection name was changed.
+ * Event indicating that the connection name will be changed. It is sent prior to the name change taking place.
+ * The event passes an IRemoteConnectionWorkingCopy so that the original and new name can be used by the listener.
*/
public static final int CONNECTION_RENAMED = 1 << 3;
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java
index 98f1588..59fb0c4 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java
@@ -189,7 +189,7 @@
*/
@Override
public void fireConnectionChangeEvent(int type) {
- if (original != null) {
+ if (original != null && type != RemoteConnectionChangeEvent.CONNECTION_RENAMED) {
original.fireConnectionChangeEvent(type);
} else {
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
@@ -273,7 +273,7 @@
public IRemoteConnection save() throws RemoteConnectionException {
if (newName != null && original != null) {
// rename, delete the old one
- original.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_RENAMED);
+ fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_RENAMED);
connectionType.removeConnection(original.getName());
original.rename(newName);
}