mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-13 11:15:38 +02:00
[198007] fix Moving multiple folders allows moving to themselves (contributed by Kevin Doyle)
This commit is contained in:
parent
68862c619e
commit
873ee7b9b6
1 changed files with 32 additions and 22 deletions
|
@ -14,6 +14,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
|
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
|
||||||
* Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
|
* Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
|
||||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||||
|
* Kevin Doyle (IBM) - [198007] Moving multiple folders allows moving to themselves
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.actions;
|
package org.eclipse.rse.internal.files.ui.actions;
|
||||||
|
@ -117,31 +118,40 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
||||||
*/
|
*/
|
||||||
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
|
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
|
||||||
{
|
{
|
||||||
//if (selectedConnection != sourceConnection) {} // someday, but can't happen today.
|
//if (selectedConnection != sourceConnection) {} // someday, but can't happen today.
|
||||||
|
IRemoteFile[] files = getSelectedFiles();
|
||||||
Object selectedObject = selectedObjects[0];
|
Object selectedObject = selectedObjects[0];
|
||||||
if (!(selectedObject instanceof IRemoteFile))
|
if (!(selectedObject instanceof IRemoteFile) || files == null)
|
||||||
return null;
|
return null;
|
||||||
IRemoteFile selectedFolder = (IRemoteFile)selectedObject;
|
IRemoteFile selectedFolder = (IRemoteFile)selectedObject;
|
||||||
if (selectedFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
String selectedFolderPath = selectedFolder.getAbsolutePath();
|
||||||
{
|
|
||||||
if (targetEqualsSrcMsg == null)
|
for (int i = 0; i < files.length; i++) {
|
||||||
targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE);
|
IRemoteFile selectedFile = files[i];
|
||||||
return targetEqualsSrcMsg;
|
if (selectedFile != null && selectedFile.getParentRemoteFile() != null) {
|
||||||
}
|
IRemoteFile selectedParentFile = selectedFile.getParentRemoteFile();
|
||||||
else if (selectedFolder.getAbsolutePath().equals(firstSelection.getAbsolutePath()))
|
|
||||||
{
|
if (selectedFolderPath.equals(selectedParentFile.getAbsolutePath()))
|
||||||
if (targetEqualsSrcMsg == null)
|
{
|
||||||
targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); // todo: different msg
|
if (targetEqualsSrcMsg == null)
|
||||||
return targetEqualsSrcMsg;
|
targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE);
|
||||||
}
|
return targetEqualsSrcMsg;
|
||||||
else if (selectedFolder.isDescendantOf(firstSelection))
|
}
|
||||||
{
|
else if (selectedFolderPath.equals(selectedFile.getAbsolutePath()))
|
||||||
if (targetDescendsFromSrcMsg == null)
|
{
|
||||||
targetDescendsFromSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOURCE);
|
if (targetEqualsSrcMsg == null)
|
||||||
return targetDescendsFromSrcMsg;
|
targetEqualsSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_EQUALS_SOURCE); // todo: different msg
|
||||||
}
|
return targetEqualsSrcMsg;
|
||||||
else
|
}
|
||||||
return null;
|
else if (selectedFolder.isDescendantOf(selectedFile))
|
||||||
|
{
|
||||||
|
if (targetDescendsFromSrcMsg == null)
|
||||||
|
targetDescendsFromSrcMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOURCE);
|
||||||
|
return targetDescendsFromSrcMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue