1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

[224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields

This commit is contained in:
David McKnight 2008-03-28 17:22:08 +00:00
parent c6a5434726
commit 669b79655c
6 changed files with 229 additions and 27 deletions

View file

@ -12,6 +12,7 @@
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * 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; package org.eclipse.rse.core.events;
@ -49,12 +50,12 @@ public interface ISystemRemoteChangeEvent
public Object getResourceParent(); 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. * 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 <code>null</code> if not applicable. * or <code>null</code> if not applicable.
*/ */
public String getOldName(); public String[] getOldNames();
/** /**
* Get the subsystem in which this resource resides. * Get the subsystem in which this resource resides.
@ -65,4 +66,9 @@ public interface ISystemRemoteChangeEvent
*/ */
public ISubSystem getSubSystem(); 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();
} }

View file

@ -137,4 +137,30 @@ public interface ISystemRemoteChangeEvents
*/ */
public static final int SYSTEM_REMOTE_RESOURCE_DOWNLOADED = 24; 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$
} }

View file

@ -12,6 +12,7 @@
* *
* Contributors: * Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * 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; package org.eclipse.rse.core.events;
@ -27,9 +28,10 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent
{ {
private int eventType; private int eventType;
private Object resource, parent; private Object resource, parent;
private String oldName; private String[] oldNames;
private ISubSystem subsystem; private ISubSystem subsystem;
private Object originatingViewer; private Object originatingViewer;
private String operation;
/** /**
* Constructor for non-rename event * 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 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. * 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(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 * 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. * 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;
} }
/** /**
@ -179,4 +217,21 @@ public class SystemRemoteChangeEvent implements ISystemRemoteChangeEvent
return originatingViewer; 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;
}
} }

View file

@ -780,9 +780,9 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
* @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 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. * 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. * Notify all listeners of a change to a remote resource such as a file.
@ -792,11 +792,39 @@ public interface ISystemRegistry extends ISchedulingRule, IAdaptable, ISystemVie
* @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 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. * 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. * @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. * 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. * Notify a specific listener of a change to a remote resource such as a file.

View file

@ -45,6 +45,7 @@
* David Dykstal (IBM) - [217556] remove service subsystem types * David Dykstal (IBM) - [217556] remove service subsystem types
* Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core
* David Dykstal (IBM) - [202630] getDefaultPrivateProfile() and ensureDefaultPrivateProfile() are inconsistent * 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; 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 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. * 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) if (resourceParent instanceof ISystemContainer)
{ {
@ -2577,7 +2578,7 @@ public class SystemRegistry implements ISystemRegistry
remoteEvent.setEventType(eventType); remoteEvent.setEventType(eventType);
remoteEvent.setResource(resource); remoteEvent.setResource(resource);
remoteEvent.setResourceParent(resourceParent); remoteEvent.setResourceParent(resourceParent);
remoteEvent.setOldName(oldName); remoteEvent.setOldNames(oldNames);
remoteEvent.setSubSystem(subsystem); remoteEvent.setSubSystem(subsystem);
if (onMainThread()) 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 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. * 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. * @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. * 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) if (resourceParent instanceof ISystemContainer)
{ {
@ -2616,7 +2617,88 @@ public class SystemRegistry implements ISystemRegistry
remoteEvent.setEventType(eventType); remoteEvent.setEventType(eventType);
remoteEvent.setResource(resource); remoteEvent.setResource(resource);
remoteEvent.setResourceParent(resourceParent); remoteEvent.setResourceParent(resourceParent);
remoteEvent.setOldName(oldName); remoteEvent.setOldNames(oldNames);
remoteEvent.setSubSystem(subsystem);
remoteEvent.setOriginatingViewer(originatingViewer);
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
*/
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.setSubSystem(subsystem);
remoteEvent.setOriginatingViewer(originatingViewer); remoteEvent.setOriginatingViewer(originatingViewer);

View file

@ -55,6 +55,7 @@ import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.internal.model.SystemScratchpad; import org.eclipse.rse.ui.internal.model.SystemScratchpad;
import org.eclipse.rse.ui.messages.SystemMessageDialog; 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.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.UIJob; import org.eclipse.ui.progress.UIJob;
@ -641,6 +642,7 @@ public class SystemDNDTransferRunnable extends WorkspaceJob
public IStatus runInUIThread(IProgressMonitor monitor) public IStatus runInUIThread(IProgressMonitor monitor)
{ {
String[] oldNames = new String[_resultSrcObjects.size()];
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
if (_resultTgtObjects.size() > 0) if (_resultTgtObjects.size() > 0)
{ {
@ -658,6 +660,8 @@ public class SystemDNDTransferRunnable extends WorkspaceJob
{ {
doRefresh = true; doRefresh = true;
} }
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)src).getAdapter(ISystemViewElementAdapter.class);
oldNames[t] = adapter.getAbsoluteName(src);
} }
if (_originatingViewer instanceof TreeViewer) if (_originatingViewer instanceof TreeViewer)
@ -675,7 +679,8 @@ public class SystemDNDTransferRunnable extends WorkspaceJob
if (doRefresh) 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) else if (_target instanceof SystemScratchpad)
{ {