### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.files.ui Index: src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java,v retrieving revision 1.78 diff -u -r1.78 SystemViewRemoteFileAdapter.java --- src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java 29 Apr 2008 20:25:43 -0000 1.78 +++ src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java 30 Apr 2008 20:40:58 -0000 @@ -51,11 +51,13 @@ * Rupen Mardirossian (IBM) - [210682] Copy collisions will use SystemCopyDialog now instead of renameDialog when there is a copy collision within the same connection * David McKnight (IBM) - [224377] "open with" menu does not have "other" option * 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 + * 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; import java.io.File; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -156,6 +158,7 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemIconConstants; +import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.SystemMenuManager; @@ -2117,9 +2120,9 @@ } else if (first instanceof IRemoteFile) { - //List toCopy = new ArrayList(); - //List toCopyNames = new ArrayList(); - List toCopyBatch = new ArrayList(); + List toCopy = new ArrayList(); + List toCopyNames = new ArrayList(); + //List toCopyBatch = new ArrayList(); List existing = new ArrayList(); boolean overwrite=false; @@ -2150,36 +2153,63 @@ String name = srcFileOrFolder.getName(); - + String originalName = srcFileOrFolder.getName(); + int count = 1; + boolean go = true; + // same systemfor - if (sameSystem) + if (sameSystem) { try { - if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath()) && !targetFolder.getAbsolutePath().equals(srcFileOrFolder.getParentRemoteFile().getAbsolutePath())) + if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath())) { - - // should be better doing a query for all in the set - IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor); - if (existingFileOrFolder.exists()) + //Handle resources being copied to their parent folder. Name = "Copy of " + name + if(targetFolder.getAbsolutePath().equals(srcFileOrFolder.getParentRemoteFile().getAbsolutePath())) { - /*RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames); - Display.getDefault().syncExec(rr); - name = rr.getNewName(); - */ - existing.add(existingFileOrFolder); + name = MessageFormat.format(FileResources.RESID_CONFLICT_COPY_PATTERN, new Object[] { + new Integer(count), originalName }); + while(go) + { + 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; + } + } } - - if (name != null) + else { - //toCopy.add(srcFileOrFolder); - //toCopyNames.add(name); - toCopyBatch.add(srcFileOrFolder); + // 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) + { + toCopy.add(srcFileOrFolder); + toCopyNames.add(name); + //toCopyBatch.add(srcFileOrFolder); + } + /*else if (name != null) + { + toCopyBatch.add(srcFileOrFolder); + }*/ } - /*else if (name != null) - { - toCopyBatch.add(srcFileOrFolder); - }*/ } } catch (Exception e) @@ -2200,9 +2230,13 @@ Display.getDefault().syncExec(rr); 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++) { @@ -2283,9 +2317,9 @@ e.printStackTrace(); } } - }*/ + } // deal with batch copies now - if(existing.size()==0 || overwrite) + /*if(existing.size()==0 || overwrite) { IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()]; for (int x = 0; x < toCopyBatch.size(); x++) @@ -2362,7 +2396,7 @@ e.printStackTrace(); } } - } + }*/ } } } Index: src/org/eclipse/rse/internal/files/ui/FileResources.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/FileResources.java,v retrieving revision 1.20 diff -u -r1.20 FileResources.java --- src/org/eclipse/rse/internal/files/ui/FileResources.java 28 Mar 2008 17:26:22 -0000 1.20 +++ src/org/eclipse/rse/internal/files/ui/FileResources.java 30 Apr 2008 20:40:58 -0000 @@ -20,6 +20,7 @@ * David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others * David McKnight (IBM) - [224377] "open with" menu does not have "other" option + * Rupen Mardirossian (IBM) - [227213] Added RESID_CONFLICT_COPY_PATTERN to be used for copying resources to parent folder. *******************************************************************************/ package org.eclipse.rse.internal.files.ui; @@ -171,6 +172,9 @@ public static String RESID_CONFLICT_DOWNLOAD_MESSAGE_REMOTECHANGED; public static String RESID_CONFLICT_DOWNLOAD_REPLACELOCAL; public static String RESID_CONFLICT_DOWNLOAD_OPENWITHLOCAL; + + // Resource conflict constants + public static String RESID_CONFLICT_COPY_PATTERN; // RSE Cache Preferences public static String RESID_PREF_CACHE_CLEAR; Index: src/org/eclipse/rse/internal/files/ui/FileResources.properties =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/FileResources.properties,v retrieving revision 1.26 diff -u -r1.26 FileResources.properties --- src/org/eclipse/rse/internal/files/ui/FileResources.properties 17 Apr 2008 09:55:50 -0000 1.26 +++ src/org/eclipse/rse/internal/files/ui/FileResources.properties 30 Apr 2008 20:40:58 -0000 @@ -21,6 +21,7 @@ # David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others # David McKnight (IBM) - [224377] "open with" menu does not have "other" option # Martin Oberhuber (Wind River) - [226784] [nls] Standardize on Cancelled in PII +# Rupen Mardirossian (IBM) - [227213] Added RESID_CONFLICT_COPY_PATTERN to be used for copying resources to parent folder. ############################################################################### # NLS_MESSAGEFORMAT_VAR @@ -153,6 +154,13 @@ RESID_CONFLICT_DOWNLOAD_REPLACELOCAL= Replace pending changes with remote file RESID_CONFLICT_DOWNLOAD_OPENWITHLOCAL= Open editor with pending changes +################################################################################## +############################Resource Conflict Constants ######################### +################################################################################## + +RESID_CONFLICT_COPY_PATTERN =Copy{0,choice,1#|1< ({0,number,integer})} of {1} + + #============================================================== # REMOTE FILE SYSTEM CACHE PREFERENCE PAGE #=============================================================