diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvent.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvent.java index 81900777d65..bad279f1cd6 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvent.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvent.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core + * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields ********************************************************************************/ package org.eclipse.rse.core.events; @@ -49,12 +50,12 @@ public interface ISystemRemoteChangeEvent public Object getResourceParent(); /** - * Get the old name of the resource, in the event of a resource rename. + * Get the old name(s) of the resource(s), in the event of a resource rename, move or copy. * Null for other event types. - * @return the old name of the resource in case of a rename event, + * @return the old names of the resources in case of a rename event, * or null if not applicable. */ - public String getOldName(); + public String[] getOldNames(); /** * Get the subsystem in which this resource resides. @@ -65,4 +66,9 @@ public interface ISystemRemoteChangeEvent */ public ISubSystem getSubSystem(); + /** + * Returns the operation of this event if it's not implied by the event itself + * @return the operation that triggered this event + */ + public String getOperation(); } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvents.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvents.java index 5a03a3577c0..ecd686ff891 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvents.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/ISystemRemoteChangeEvents.java @@ -136,5 +136,31 @@ public interface ISystemRemoteChangeEvents * @since org.eclipse.rse.core 3.0 */ public static final int SYSTEM_REMOTE_RESOURCE_DOWNLOADED = 24; + + + /** + * Indicates that the event is for a delete operation + */ + public static final String SYSTEM_REMOTE_OPERATION_DELETE = "DELETE"; //$NON-NLS-1$ + + /** + * Indicates that the event is for a rename operation + */ + public static final String SYSTEM_REMOTE_OPERATION_RENAME = "RENAME"; //$NON-NLS-1$ + + /** + * Indicates that the event is for a create operation + */ + public static final String SYSTEM_REMOTE_OPERATION_CREATE = "CREATE"; //$NON-NLS-1$ + + /** + * Indicates that the event is for a move operation + */ + public static final String SYSTEM_REMOTE_OPERATION_MOVE = "MOVE"; //$NON-NLS-1$ + + /** + * Indicates that the event is for a copy operation + */ + public static final String SYSTEM_REMOTE_OPERATION_COPY = "COPY"; //$NON-NLS-1$ } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/SystemRemoteChangeEvent.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/SystemRemoteChangeEvent.java index e563caef063..d820319e077 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/SystemRemoteChangeEvent.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/events/SystemRemoteChangeEvent.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core + * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields ********************************************************************************/ package org.eclipse.rse.core.events; @@ -27,9 +28,10 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent { private int eventType; private Object resource, parent; - private String oldName; + private String[] oldNames; private ISubSystem subsystem; private Object originatingViewer; + private String operation; /** * Constructor for non-rename event @@ -57,14 +59,50 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. - * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation */ - public SystemRemoteChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName) + public SystemRemoteChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames) { this(eventType, resource, resourceParent, subsystem); - this.oldName = oldName; + this.oldNames = oldNames; } + /** + * Constructor for non-rename event + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter, + * or List of absoluteNames + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + */ + public SystemRemoteChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem) + { + super(); + this.eventType = eventType; + this.resource = resource; + this.parent = resourceParent; + this.subsystem = subsystem; + this.operation = operation; + } + + /** + * Constructor for a rename event. + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter, + * or List of absoluteNames + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + */ + public SystemRemoteChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames) + { + this(operation, eventType, resource, resourceParent, subsystem); + this.oldNames = oldNames; + } /** * Constructor you shouldn't use unless you intend to call the setters */ @@ -105,11 +143,11 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent } /** - * Reset the old name on a rename event + * Reset the old names on a rename, move or copy event */ - public void setOldName(String oldName) + public void setOldNames(String[] oldNames) { - this.oldName = oldName; + this.oldNames = oldNames; } /** @@ -153,9 +191,9 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent /** * Get the old name of the resource, in the event of a resource rename. Null for other event types. */ - public String getOldName() + public String[] getOldNames() { - return oldName; + return oldNames; } /** @@ -178,5 +216,22 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent public Object getOriginatingViewer() { return originatingViewer; } + + + public void setOperation(String operation){ + this.operation = operation; + } + + /** + * Returns the operation of this event if it's not implied by the event itself. + * The operation can be optionally specified when the event is constructed. + * By default this will return null. + * + * @return the operation that triggered this event + */ + public String getOperation() { + return operation; + } + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java index ba639a700dc..3edb4141030 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/ISystemRegistry.java @@ -778,11 +778,11 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. - * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. - * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation */ - public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName); + public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames); /** * Notify all listeners of a change to a remote resource such as a file. @@ -790,13 +790,41 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. - * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. - * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename - * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent. * This saves sending a separate event to reveal and select the new created resource on a create event, for example. */ - public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName, Object originatingViewer); + public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames, Object originatingViewer); + + /** + * Notify all listeners of a change to a remote resource such as a file. + * This one takes the information needed and creates the event for you. + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + */ + public void fireRemoteResourceChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames); + + /** + * Notify all listeners of a change to a remote resource such as a file. + * This one takes the information needed and creates the event for you. + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent. + * This saves sending a separate event to reveal and select the new created resource on a create event, for example. + */ + public void fireRemoteResourceChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames, Object originatingViewer); /** * Notify a specific listener of a change to a remote resource such as a file. diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java index 3d484224066..bbbb77d8d86 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/core/model/SystemRegistry.java @@ -45,6 +45,7 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core * David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent + * David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields ********************************************************************************/ package org.eclipse.rse.internal.core.model; @@ -2561,9 +2562,9 @@ public class SystemRegistry implements ISystemRegistry * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. - * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation */ - public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName) + public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames) { if (resourceParent instanceof ISystemContainer) { @@ -2577,7 +2578,7 @@ public class SystemRegistry implements ISystemRegistry remoteEvent.setEventType(eventType); remoteEvent.setResource(resource); remoteEvent.setResourceParent(resourceParent); - remoteEvent.setOldName(oldName); + remoteEvent.setOldNames(oldNames); remoteEvent.setSubSystem(subsystem); if (onMainThread()) @@ -2598,11 +2599,11 @@ public class SystemRegistry implements ISystemRegistry * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. - * @param oldName - on a rename operation, this is the absolute name of the resource prior to the rename + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent. * This saves sending a separate event to reveal and select the new created resource on a create event, for example. */ - public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String oldName, Object originatingViewer) + public void fireRemoteResourceChangeEvent(int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames, Object originatingViewer) { if (resourceParent instanceof ISystemContainer) { @@ -2616,7 +2617,7 @@ public class SystemRegistry implements ISystemRegistry remoteEvent.setEventType(eventType); remoteEvent.setResource(resource); remoteEvent.setResourceParent(resourceParent); - remoteEvent.setOldName(oldName); + remoteEvent.setOldNames(oldNames); remoteEvent.setSubSystem(subsystem); remoteEvent.setOriginatingViewer(originatingViewer); @@ -2630,6 +2631,87 @@ public class SystemRegistry implements ISystemRegistry } } + /** + * Notify all listeners of a change to a remote resource such as a file. + * This one takes the information needed and creates the event for you. + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + */ + public void fireRemoteResourceChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames) + { + if (resourceParent instanceof ISystemContainer) + { + ((ISystemContainer)resourceParent).markStale(true); + } + // mark stale any filters that reference this object + invalidateFiltersFor(resourceParent, subsystem); + + if (remoteEvent == null) + remoteEvent = new SystemRemoteChangeEvent(); + remoteEvent.setOperation(operation); + remoteEvent.setEventType(eventType); + remoteEvent.setResource(resource); + remoteEvent.setResourceParent(resourceParent); + remoteEvent.setOldNames(oldNames); + remoteEvent.setSubSystem(subsystem); + + if (onMainThread()) + { + remoteListManager.notify(remoteEvent); + } + else + { + runOnMainThread(new RemoteChangedRunnable(remoteEvent)); + } + } + + /** + * Notify all listeners of a change to a remote resource such as a file. + * This one takes the information needed and creates the event for you. + * @param operation - the operation for which this event was fired + * @param eventType - one of the constants from {@link org.eclipse.rse.core.events.ISystemRemoteChangeEvents} + * @param resource - the remote resource object, or absolute name of the resource as would be given by calling getAbsoluteName on its remote adapter + * @param resourceParent - the remote resource's parent object, or absolute name, if that is known. If it is non-null, this will aid in refreshing occurences of that parent. + * @param subsystem - the subsystem which contains this remote resource. This allows the search for impacts to be + * limited to subsystems of the same parent factory, and to connections with the same hostname as the subsystem's connection. + * @param oldNames - on a rename, copy or move operation, these are the absolute names of the resources prior to the operation + * @param originatingViewer - optional. If set, this gives the viewer a clue that it should select the affected resource after refreshing its parent. + * This saves sending a separate event to reveal and select the new created resource on a create event, for example. + */ + public void fireRemoteResourceChangeEvent(String operation, int eventType, Object resource, Object resourceParent, ISubSystem subsystem, String[] oldNames, Object originatingViewer) + { + if (resourceParent instanceof ISystemContainer) + { + ((ISystemContainer)resourceParent).markStale(true); + } + // mark stale any filters that reference this object + invalidateFiltersFor(resourceParent, subsystem); + + if (remoteEvent == null) + remoteEvent = new SystemRemoteChangeEvent(); + remoteEvent.setOperation(operation); + remoteEvent.setEventType(eventType); + remoteEvent.setResource(resource); + remoteEvent.setResourceParent(resourceParent); + remoteEvent.setOldNames(oldNames); + remoteEvent.setSubSystem(subsystem); + remoteEvent.setOriginatingViewer(originatingViewer); + + if (onMainThread()) + { + remoteListManager.notify(remoteEvent); + } + else + { + runOnMainThread(new RemoteChangedRunnable(remoteEvent)); + } + } + /** * Returns the implementation of ISystemRemoteElement for the given * object. Returns null if this object does not adaptable to this. diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java index c888f86ca16..2aa85952843 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java @@ -55,6 +55,7 @@ import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.internal.model.SystemScratchpad; import org.eclipse.rse.ui.messages.SystemMessageDialog; +import org.eclipse.rse.ui.view.ISystemViewElementAdapter; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.progress.UIJob; @@ -641,6 +642,7 @@ public class SystemDNDTransferRunnable extends WorkspaceJob public IStatus runInUIThread(IProgressMonitor monitor) { + String[] oldNames = new String[_resultSrcObjects.size()]; ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); if (_resultTgtObjects.size() > 0) { @@ -658,6 +660,8 @@ public class SystemDNDTransferRunnable extends WorkspaceJob { doRefresh = true; } + ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)src).getAdapter(ISystemViewElementAdapter.class); + oldNames[t] = adapter.getAbsoluteName(src); } if (_originatingViewer instanceof TreeViewer) @@ -672,10 +676,11 @@ public class SystemDNDTransferRunnable extends WorkspaceJob } } - + if (doRefresh) { - registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, _resultTgtObjects, _target, _targetSubSystem, null, _originatingViewer); + String operation = ISystemRemoteChangeEvents.SYSTEM_REMOTE_OPERATION_COPY; + registry.fireRemoteResourceChangeEvent(operation, ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, _resultTgtObjects, _target, _targetSubSystem, oldNames, _originatingViewer); } else if (_target instanceof SystemScratchpad) {