mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 18:25:40 +02:00
[227213] Copy and pasting to the parent folder will create a "Copy of" that resource
This commit is contained in:
parent
0f548e8386
commit
7322cfb231
1 changed files with 64 additions and 30 deletions
|
@ -53,10 +53,12 @@
|
||||||
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
* David McKnight (IBM) - [225747] [dstore] Trying to connect to an "Offline" system throws an NPE
|
||||||
* Rupen Mardirossian (IBM) - [198728] Folder being copied across systems is added to original set of files in order to extract empty (sub)folders in doDrop method
|
* Rupen Mardirossian (IBM) - [198728] Folder being copied across systems is added to original set of files in order to extract empty (sub)folders in doDrop method
|
||||||
* David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding
|
* David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding
|
||||||
|
* Rupen Mardirossian (IBM) - [227213] Copy and pasting to the parent folder will create a "Copy of" that resource
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.view;
|
package org.eclipse.rse.internal.files.ui.view;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -157,6 +159,7 @@ import org.eclipse.rse.subsystems.files.core.util.ValidatorFileUniqueName;
|
||||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
|
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
|
||||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||||
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
import org.eclipse.rse.ui.SystemBasePlugin;
|
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||||
import org.eclipse.rse.ui.SystemMenuManager;
|
import org.eclipse.rse.ui.SystemMenuManager;
|
||||||
|
@ -2118,9 +2121,9 @@ public class SystemViewRemoteFileAdapter
|
||||||
}
|
}
|
||||||
else if (first instanceof IRemoteFile)
|
else if (first instanceof IRemoteFile)
|
||||||
{
|
{
|
||||||
//List toCopy = new ArrayList();
|
List toCopy = new ArrayList();
|
||||||
//List toCopyNames = new ArrayList();
|
List toCopyNames = new ArrayList();
|
||||||
List toCopyBatch = new ArrayList();
|
//List toCopyBatch = new ArrayList();
|
||||||
List existing = new ArrayList();
|
List existing = new ArrayList();
|
||||||
boolean overwrite=false;
|
boolean overwrite=false;
|
||||||
|
|
||||||
|
@ -2151,36 +2154,63 @@ public class SystemViewRemoteFileAdapter
|
||||||
|
|
||||||
|
|
||||||
String name = srcFileOrFolder.getName();
|
String name = srcFileOrFolder.getName();
|
||||||
|
String originalName = srcFileOrFolder.getName();
|
||||||
|
int count = 1;
|
||||||
|
boolean go = true;
|
||||||
|
|
||||||
// same systemfor
|
// same systemfor
|
||||||
if (sameSystem)
|
if (sameSystem)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath()) && !targetFolder.getAbsolutePath().equals(srcFileOrFolder.getParentRemoteFile().getAbsolutePath()))
|
if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath()))
|
||||||
{
|
{
|
||||||
|
//Handle resources being copied to their parent folder. Name = "Copy of " + name
|
||||||
// should be better doing a query for all in the set
|
if(targetFolder.getAbsolutePath().equals(srcFileOrFolder.getParentRemoteFile().getAbsolutePath()))
|
||||||
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
|
||||||
if (existingFileOrFolder.exists())
|
|
||||||
{
|
{
|
||||||
/*RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
|
name = MessageFormat.format(FileResources.RESID_CONFLICT_COPY_PATTERN, new Object[] {
|
||||||
Display.getDefault().syncExec(rr);
|
new Integer(count), originalName });
|
||||||
name = rr.getNewName();
|
while(go)
|
||||||
*/
|
{
|
||||||
existing.add(existingFileOrFolder);
|
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
||||||
|
if (existingFileOrFolder.exists())
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
name = MessageFormat.format(FileResources.RESID_CONFLICT_COPY_PATTERN, new Object[] {
|
||||||
|
new Integer(count), originalName });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
toCopy.add(srcFileOrFolder);
|
||||||
|
toCopyNames.add(name);
|
||||||
|
go = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// should be better doing a query for all in the set
|
||||||
|
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
||||||
|
if (existingFileOrFolder.exists())
|
||||||
|
{
|
||||||
|
/*RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
|
||||||
|
Display.getDefault().syncExec(rr);
|
||||||
|
name = rr.getNewName();
|
||||||
|
*/
|
||||||
|
existing.add(existingFileOrFolder);
|
||||||
|
}
|
||||||
|
|
||||||
if (name != null)
|
if (name != null)
|
||||||
{
|
{
|
||||||
//toCopy.add(srcFileOrFolder);
|
toCopy.add(srcFileOrFolder);
|
||||||
//toCopyNames.add(name);
|
toCopyNames.add(name);
|
||||||
toCopyBatch.add(srcFileOrFolder);
|
//toCopyBatch.add(srcFileOrFolder);
|
||||||
|
}
|
||||||
|
/*else if (name != null)
|
||||||
|
{
|
||||||
|
toCopyBatch.add(srcFileOrFolder);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
/*else if (name != null)
|
|
||||||
{
|
|
||||||
toCopyBatch.add(srcFileOrFolder);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2202,8 +2232,12 @@ public class SystemViewRemoteFileAdapter
|
||||||
overwrite = rr.getOk();
|
overwrite = rr.getOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Following code for renaming dialog copying procedures is not required
|
|
||||||
/*if(existing.size()==0 || overwrite)
|
|
||||||
|
//Following code used originally with the rename dialog which no longer exists
|
||||||
|
//Resources will be copied with same names if an overwrite is desired from the user
|
||||||
|
//Resources that are copied to their parent will be renamed to "Copy of " + name of source
|
||||||
|
if(existing.size()==0 || overwrite)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < toCopy.size(); x++)
|
for (int x = 0; x < toCopy.size(); x++)
|
||||||
{
|
{
|
||||||
|
@ -2284,9 +2318,9 @@ public class SystemViewRemoteFileAdapter
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
// deal with batch copies now
|
// deal with batch copies now
|
||||||
if(existing.size()==0 || overwrite)
|
/*if(existing.size()==0 || overwrite)
|
||||||
{
|
{
|
||||||
IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()];
|
IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()];
|
||||||
for (int x = 0; x < toCopyBatch.size(); x++)
|
for (int x = 0; x < toCopyBatch.size(); x++)
|
||||||
|
@ -2363,7 +2397,7 @@ public class SystemViewRemoteFileAdapter
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue