mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
[208435] Rupen's Patch to disable the user to rename to the same name when multiple collisions occur
This commit is contained in:
parent
00690859a4
commit
3fa42877ce
3 changed files with 84 additions and 16 deletions
|
@ -22,16 +22,17 @@
|
|||
* Martin Oberhuber (Wind River) - [189130] Move SystemIFileProperties from UI to Core
|
||||
* Xuan Chen (IBM) - [187548] Editor shows incorrect file name after renaming file on Linux dstore
|
||||
* David McKnight (IBM) - [191472] should not use super transfer with SSH/FTP Folder Copy and Paste
|
||||
* Xuan Chen (IBM) - [191367] with supertransfer on, Drag & Drop Folder from DStore to DStore doesn't work
|
||||
* Xuan Chen (IBM) - [201790] [dnd] Copy and Paste across connections to a Drive doesn't work
|
||||
* Xuan Chen (IBM) - [202668] [Supertransfer] Subfolders not copied when doing first copy from dstore to Local
|
||||
* Xuan Chen (IBM) - [202670] [Supertransfer] After doing a copy to a directory that contains folders some folders name's display "deleted"
|
||||
* Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work
|
||||
* Xuan Chen (IBM) - [191367] with supertransfer on, Drag & Drop Folder from DStore to DStore doesn't work
|
||||
* Xuan Chen (IBM) - [201790] [dnd] Copy and Paste across connections to a Drive doesn't work
|
||||
* Xuan Chen (IBM) - [202668] [Supertransfer] Subfolders not copied when doing first copy from dstore to Local
|
||||
* Xuan Chen (IBM) - [202670] [Supertransfer] After doing a copy to a directory that contains folders some folders name's display "deleted"
|
||||
* Xuan Chen (IBM) - [202949] [archives] copy a folder from one connection to an archive file in a different connection does not work
|
||||
* David McKnight (IBM) - [205819] Need to use input stream copy when EFS files are the src
|
||||
* David McKnight (IBM) - [195285] mount path mapper changes
|
||||
* Kevin Doyle (IBM) - [203014] Copy/Paste Across Connections doesn't display Overwrite dialog when folder already exists
|
||||
* Kevin Doyle (IBM) - [203014] Copy/Paste Across Connections doesn't display Overwrite dialog when folder already exists
|
||||
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
||||
* David McKnight (IBM) - [209375] new API copyRemoteResourcesToWorkspaceMultiple to optimize downloads
|
||||
* Rupen Mardirossian (IBM) - [208435] added constructor to nested RenameRunnable class to take in names that are previously used as a parameter for multiple renaming instances, passed through check collision as well through overloading.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
|
@ -1229,7 +1230,7 @@ public class UniversalFileTransferUtility
|
|||
|
||||
// clear the list so that next time we use renamed names
|
||||
newFilePathList.clear();
|
||||
|
||||
List toCopyNames = new ArrayList();
|
||||
|
||||
for (int i = 0; i < resources.size() && !resultSet.hasMessage(); i++)
|
||||
{
|
||||
|
@ -1247,11 +1248,12 @@ public class UniversalFileTransferUtility
|
|||
String oldPath = newPathBuf.toString() + name;
|
||||
if (checkForCollisions)
|
||||
{
|
||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath);
|
||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
||||
int severity = status.getSeverity();
|
||||
|
||||
if (severity == IStatus.OK) {
|
||||
name = status.getMessage();
|
||||
toCopyNames.add(name);
|
||||
}
|
||||
else if (severity == IStatus.CANCEL) {
|
||||
|
||||
|
@ -1320,11 +1322,12 @@ public class UniversalFileTransferUtility
|
|||
String oldPath = newPathBuf.toString() + name;
|
||||
if (checkForCollisions)
|
||||
{
|
||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath);
|
||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
||||
int severity = status.getSeverity();
|
||||
|
||||
if (severity == IStatus.OK) {
|
||||
name = status.getMessage();
|
||||
toCopyNames.add(name);
|
||||
}
|
||||
else if (severity == IStatus.CANCEL) {
|
||||
|
||||
|
@ -2305,6 +2308,10 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
|
||||
protected static RenameStatus checkForCollision(SystemRemoteResourceSet existingFiles, IRemoteFile targetFolder, String oldName, String oldPath)
|
||||
{
|
||||
return checkForCollision(existingFiles, targetFolder, oldName, oldPath, null);
|
||||
}
|
||||
protected static RenameStatus checkForCollision(SystemRemoteResourceSet existingFiles, IRemoteFile targetFolder, String oldName, String oldPath, List NamesInUse)
|
||||
{
|
||||
String newName = oldName;
|
||||
|
||||
|
@ -2313,7 +2320,7 @@ public class UniversalFileTransferUtility
|
|||
RenameStatus status = new RenameStatus(IStatus.OK, Activator.getDefault().getBundle().getSymbolicName(), IStatus.OK, newName, null);
|
||||
|
||||
if (targetFileOrFolder != null && targetFileOrFolder.exists()) {
|
||||
RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
|
||||
RenameRunnable rr = new RenameRunnable(targetFileOrFolder, NamesInUse);
|
||||
Display.getDefault().syncExec(rr);
|
||||
newName = rr.getNewName();
|
||||
|
||||
|
@ -2341,6 +2348,7 @@ public class UniversalFileTransferUtility
|
|||
{
|
||||
private IRemoteFile _targetFileOrFolder;
|
||||
private String _newName;
|
||||
private List _namesInUse = new ArrayList();
|
||||
private int cancelStatus;
|
||||
|
||||
public static int RENAME_DIALOG_NOT_CANCELLED = -1;
|
||||
|
@ -2352,10 +2360,24 @@ public class UniversalFileTransferUtility
|
|||
_targetFileOrFolder = targetFileOrFolder;
|
||||
cancelStatus = RENAME_DIALOG_NOT_CANCELLED;
|
||||
}
|
||||
public RenameRunnable(IRemoteFile targetFileOrFolder, List namesInUse)
|
||||
{
|
||||
_targetFileOrFolder = targetFileOrFolder;
|
||||
cancelStatus = RENAME_DIALOG_NOT_CANCELLED;
|
||||
_namesInUse=namesInUse;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ValidatorFileUniqueName validator = null;
|
||||
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
|
||||
SystemRenameSingleDialog dlg;
|
||||
if(_namesInUse!=null && _namesInUse.size()>0)
|
||||
{
|
||||
dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator, _namesInUse); // true => copy-collision-mode
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
|
||||
}
|
||||
dlg.setShowCancelAllButton(true);
|
||||
|
||||
dlg.open();
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
* Kevin Doyle (IBM) - [186125] Changing encoding of a file is not reflected when it was opened before
|
||||
* David McKnight (IBM) - [208803] add exists() method
|
||||
* David McKnight (IBM) - [209375] download using copyRemoteResourcesToWorkspaceMultiple
|
||||
* Rupen Mardirossian (IBM) - [208435] added constructor to nested RenameRunnable class to take in names that are previously used as a parameter for multiple renaming instances
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.view;
|
||||
|
@ -1739,15 +1740,28 @@ public class SystemViewRemoteFileAdapter
|
|||
{
|
||||
private IRemoteFile _targetFileOrFolder;
|
||||
private String _newName;
|
||||
private List _namesInUse = new ArrayList();
|
||||
public RenameRunnable(IRemoteFile targetFileOrFolder)
|
||||
{
|
||||
_targetFileOrFolder = targetFileOrFolder;
|
||||
}
|
||||
public RenameRunnable(IRemoteFile targetFileOrFolder, List namesInUse)
|
||||
{
|
||||
_targetFileOrFolder = targetFileOrFolder;
|
||||
_namesInUse=namesInUse;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ValidatorFileUniqueName validator = null;
|
||||
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
|
||||
|
||||
ValidatorFileUniqueName validator = null;
|
||||
SystemRenameSingleDialog dlg;
|
||||
if(_namesInUse!=null && _namesInUse.size()>0)
|
||||
{
|
||||
dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator, _namesInUse); // true => copy-collision-mode
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
|
||||
}
|
||||
dlg.open();
|
||||
if (!dlg.wasCancelled())
|
||||
_newName = dlg.getNewName();
|
||||
|
@ -1933,7 +1947,7 @@ public class SystemViewRemoteFileAdapter
|
|||
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
||||
if (existingFileOrFolder.exists())
|
||||
{
|
||||
RenameRunnable rr = new RenameRunnable(existingFileOrFolder);
|
||||
RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
|
||||
Display.getDefault().syncExec(rr);
|
||||
name = rr.getNewName();
|
||||
|
||||
|
|
|
@ -12,9 +12,13 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
|
||||
* Rupen Mardirossian (IBM) - [208435] When validating name, check for previously used names for multiple renaming instances
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.ui.dialogs;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -98,6 +102,7 @@ public class SystemRenameSingleDialog extends SystemPromptDialog
|
|||
private ISystemViewElementAdapter adapter = null;
|
||||
private Object inputElement = null;
|
||||
private String description = null;
|
||||
private List _namesInUse = new ArrayList();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -137,7 +142,24 @@ public class SystemRenameSingleDialog extends SystemPromptDialog
|
|||
setNameValidator(nameValidator);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an input object and validator
|
||||
* This constructor is in copy/move dialogs when there is a collision
|
||||
* @param shell The parent dialog
|
||||
* @param copyCollisionMode true if this is being called because of a name collision on a copy or move operation
|
||||
* @param inputObject The object that is being renamed, or on a copy/move the object in the target container which already exists. Used to get the old name and the name validator
|
||||
* @param nameValidator The name validator to use. Can be null, in which case it is queried from the adapter of the input object
|
||||
* @param nameInUse the List of names that have been previously selected for other files that are to be renamed for multiple file renaming.
|
||||
*/
|
||||
public SystemRenameSingleDialog(Shell shell, boolean copyCollisionMode, Object inputObject, ISystemValidator nameValidator, List nameInUse)
|
||||
{
|
||||
this(shell);
|
||||
setInputObject(inputObject);
|
||||
setCopyCollisionMode(copyCollisionMode);
|
||||
setNameValidator(nameValidator);
|
||||
_namesInUse = nameInUse;
|
||||
|
||||
}
|
||||
/**
|
||||
* Set the label and tooltip of the prompt. The default is "New name:"
|
||||
*/
|
||||
|
@ -612,6 +634,16 @@ public class SystemRenameSingleDialog extends SystemPromptDialog
|
|||
|
||||
if ((errorMessage == null) && (uniqueNameValidator != null))
|
||||
errorMessage = uniqueNameValidator.validate(theNewName);
|
||||
if(_namesInUse != null && _namesInUse.size()>0)
|
||||
{
|
||||
for(int i=0;i<_namesInUse.size();i++)
|
||||
{
|
||||
if(theNewName.equals(_namesInUse.get(i)))
|
||||
{
|
||||
errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_ENTRY_NOTUNIQUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errorMessage != null)
|
||||
setErrorMessage(errorMessage);
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue