diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java index ab3c0eeb06b..da9d49b4d6d 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Kevin Doyle (IBM) - [198007] Moving multiple folders allows moving to themselves + * Kevin Doyle (IBM) - [160769] Move Resource dialog allows user to continue on invalid destination ********************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; @@ -23,6 +24,7 @@ import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; +import org.eclipse.rse.core.filters.ISystemFilterReference; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.services.clientserver.messages.SystemMessage; @@ -44,6 +46,7 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction { private SystemMessage targetEqualsSrcMsg = null; private SystemMessage targetDescendsFromSrcMsg = null; + private SystemMessage invalidFilterMsg = null; protected Vector movedFiles = new Vector(); /** @@ -121,34 +124,51 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction //if (selectedConnection != sourceConnection) {} // someday, but can't happen today. IRemoteFile[] files = getSelectedFiles(); Object selectedObject = selectedObjects[0]; - if (!(selectedObject instanceof IRemoteFile) || files == null) + if (!(selectedObject instanceof IRemoteFile || selectedObject instanceof ISystemFilterReference) || files == null) { return null; - IRemoteFile selectedFolder = (IRemoteFile)selectedObject; - String selectedFolderPath = selectedFolder.getAbsolutePath(); + } - for (int i = 0; i < files.length; i++) { - IRemoteFile selectedFile = files[i]; - if (selectedFile != null && selectedFile.getParentRemoteFile() != null) { - IRemoteFile selectedParentFile = selectedFile.getParentRemoteFile(); - - if (selectedFolderPath.equals(selectedParentFile.getAbsolutePath())) - { - if (targetEqualsSrcMsg == null) - targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); - return targetEqualsSrcMsg; - } - else if (selectedFolderPath.equals(selectedFile.getAbsolutePath())) - { - if (targetEqualsSrcMsg == null) - targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); // todo: different msg - return targetEqualsSrcMsg; - } - else if (selectedFolder.isDescendantOf(selectedFile)) - { - if (targetDescendsFromSrcMsg == null) - targetDescendsFromSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOURCE); - return targetDescendsFromSrcMsg; - } + if (selectedObject instanceof IRemoteFile) { + IRemoteFile selectedFolder = (IRemoteFile)selectedObject; + String selectedFolderPath = selectedFolder.getAbsolutePath(); + + for (int i = 0; i < files.length; i++) { + IRemoteFile selectedFile = files[i]; + if (selectedFile != null && selectedFile.getParentRemoteFile() != null) { + IRemoteFile selectedParentFile = selectedFile.getParentRemoteFile(); + + if (selectedFolderPath.equals(selectedParentFile.getAbsolutePath())) + { + if (targetEqualsSrcMsg == null) + targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); + return targetEqualsSrcMsg; + } + else if (selectedFolderPath.equals(selectedFile.getAbsolutePath())) + { + if (targetEqualsSrcMsg == null) + targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); // todo: different msg + return targetEqualsSrcMsg; + } + else if (selectedFolder.isDescendantOf(selectedFile)) + { + if (targetDescendsFromSrcMsg == null) + targetDescendsFromSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOURCE); + return targetDescendsFromSrcMsg; + } + } + } + } else if (selectedObject instanceof ISystemFilterReference) { + ISystemFilterReference filter = (ISystemFilterReference) selectedObject; + String[] filterStrings = filter.getReferencedFilter().getFilterStrings(); + String firstFilterString = filterStrings[0]; + // Check only first filter string as by convention we move files only + // to the first filter string. * and /* are invalid as they represent + // Drives and Root Filters which we can't Move files to. + if (firstFilterString.equals("*") || firstFilterString.equals("/*")) { //$NON-NLS-1$ //$NON-NLS-2$ + if (invalidFilterMsg == null) { + invalidFilterMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_FILTER_NOT_VALID); + } + return invalidFilterMsg; } } return null; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemMessages.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemMessages.java index 1cc63bf1c8a..c036469f447 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemMessages.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemMessages.java @@ -13,6 +13,7 @@ * Contributors: * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands * API to the user actions plugin + * Kevin Doyle (IBM) - [160769] Added FILEMSG_MOVE_FILTER_NOT_VALID ********************************************************************************/ package org.eclipse.rse.ui; @@ -261,6 +262,7 @@ public interface ISystemMessages public static final String FILEMSG_MOVE_FILE_FAILED = "RSEF1307"; //$NON-NLS-1$ public static final String FILEMSG_MOVE_TARGET_EQUALS_SOURCE = "RSEF1308"; //$NON-NLS-1$ public static final String FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOURCE = "RSEF1312"; //$NON-NLS-1$ + public static final String FILEMSG_MOVE_FILTER_NOT_VALID = "RSEF1313"; //$NON-NLS-1$ public static final String FILEMSG_DELETING = "RSEF1315"; //$NON-NLS-1$ // ------------------------- diff --git a/rse/plugins/org.eclipse.rse.ui/systemmessages.xml b/rse/plugins/org.eclipse.rse.ui/systemmessages.xml index 1edbb269c67..3826aa761c7 100644 --- a/rse/plugins/org.eclipse.rse.ui/systemmessages.xml +++ b/rse/plugins/org.eclipse.rse.ui/systemmessages.xml @@ -14,6 +14,7 @@ Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. Contributors: Martin Oberhuber (Wind River) - Rename Remote Systems Explorer to Remote System Explorer for consistency Uwe Stieber (Wind River) - [175153][175316] Fix messages for new connection dlg +Kevin Doyle (IBM) - [160769] Added message for invalid filter when moving files --> @@ -990,6 +991,10 @@ Uwe Stieber (Wind River) - [175153][175316] Fix messages for new connection dlg Target folder cannot descend from source folder It is impossible to move a folder to one of its subfolders. + + + Selected filter is not a valid destination. + Some filters, such as the Root or Drives filter, do not designate locations on the remote file system and cannot have files moved into them. Deleting %1...