mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
[198728] Copy/paste across connections did not preserve empty folder.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=198728
This commit is contained in:
parent
c885280664
commit
6c6bed23d5
2 changed files with 115 additions and 18 deletions
|
@ -44,6 +44,7 @@
|
|||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||
* Rupen Mardirossian (IBM) - [210682] Collisions when doing a copy operation across systems will us the SystemCopyDialog
|
||||
* Xuan Chen (IBM) - [229093] set charset of the temp file of the text remote file to its remote encoding
|
||||
* Rupen Mardirossian (IBM) - [198728] downloadResourcesToWorkspace now creates empty folders for copying across connections via createEmptyFolders method
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
|
@ -65,6 +66,7 @@ import java.util.List;
|
|||
import org.eclipse.core.internal.resources.Resource;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -410,6 +412,7 @@ public class UniversalFileTransferUtility
|
|||
List remoteFilesForDownload = new ArrayList();
|
||||
List tempFilesForDownload = new ArrayList();
|
||||
List remoteEncodingsForDownload = new ArrayList();
|
||||
List emptyFolders = new ArrayList();
|
||||
|
||||
// step 1: pre-download processing
|
||||
for (int i = 0; i < set.size() && !resultSet.hasMessage(); i++){
|
||||
|
@ -432,7 +435,7 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
else
|
||||
{
|
||||
if (srcFileOrFolder.isFile()) // file transfer
|
||||
if (srcFileOrFolder.isFile()) // file transfer only
|
||||
{
|
||||
IResource tempResource = getTempFileFor(srcFileOrFolder);
|
||||
|
||||
|
@ -460,21 +463,31 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (srcFileOrFolder.isDirectory()) // recurse for folders and add to our consolidated resource set
|
||||
else if (srcFileOrFolder.isDirectory()) // recurse for empty folders and add to our consolidated resource set
|
||||
{
|
||||
IResource tempFolder = getTempFileFor(srcFileOrFolder);
|
||||
try
|
||||
{
|
||||
IRemoteFile[] children = srcFS.list(srcFileOrFolder,monitor);
|
||||
|
||||
|
||||
SystemRemoteResourceSet childSet = new SystemRemoteResourceSet(srcFS, children);
|
||||
SystemWorkspaceResourceSet childResults = downloadResourcesToWorkspaceMultiple(childSet, monitor);
|
||||
if (childResults.hasMessage())
|
||||
{
|
||||
//get contents of folder
|
||||
IRemoteFile[] children = srcFS.list(srcFileOrFolder,IFileService.FILE_TYPE_FILES_AND_FOLDERS,monitor);
|
||||
//check for empty folder and add to set
|
||||
if(children==null || children.length==0)
|
||||
{
|
||||
resultSet.setMessage(childResults.getMessage());
|
||||
emptyFolders.add(tempFolder);
|
||||
}
|
||||
//get all subfolders
|
||||
children=srcFS.list(srcFileOrFolder, IFileService.FILE_TYPE_FOLDERS, monitor);
|
||||
if(!(children==null) && !(children.length==0))
|
||||
{
|
||||
SystemRemoteResourceSet childSet = new SystemRemoteResourceSet(srcFS, children);
|
||||
//recurse with subfolders to check for empty folders
|
||||
SystemWorkspaceResourceSet childResults = downloadResourcesToWorkspaceMultiple(childSet, monitor);
|
||||
if (childResults.hasMessage())
|
||||
{
|
||||
resultSet.setMessage(childResults.getMessage());
|
||||
}
|
||||
resultSet.addResource(tempFolder);
|
||||
}
|
||||
resultSet.addResource(tempFolder);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
|
@ -515,7 +528,19 @@ public class UniversalFileTransferUtility
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
//Create empty folders
|
||||
try
|
||||
{
|
||||
createEmptyFolders(monitor, emptyFolders);
|
||||
}
|
||||
catch(CoreException e)
|
||||
{
|
||||
SystemMessage errorMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
ISystemFileConstants.FILEMSG_CREATE_FILE_FAILED,
|
||||
IStatus.ERROR, FileResources.FILEMSG_CREATE_FILE_FAILED, e);
|
||||
resultSet.setMessage(errorMessage);
|
||||
}
|
||||
|
||||
// step 3: post download processing
|
||||
if (!resultSet.hasMessage())
|
||||
{
|
||||
|
@ -593,10 +618,51 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private static void createEmptyFolders(IProgressMonitor monitor, List emptyFolders) throws CoreException
|
||||
{
|
||||
IContainer empty;
|
||||
IFolder emptyFolder;
|
||||
List emptyParent;
|
||||
boolean go=false;
|
||||
for(int i=0; i<emptyFolders.size();i++)
|
||||
{
|
||||
emptyParent = new ArrayList();
|
||||
empty = (IContainer) emptyFolders.get(i);
|
||||
go=true;
|
||||
//check to see which parent folders need to be created
|
||||
while(go)
|
||||
{
|
||||
empty = empty.getParent();
|
||||
if(!empty.exists() && empty instanceof IFolder)
|
||||
{
|
||||
emptyParent.add(empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
go=false;
|
||||
}
|
||||
}
|
||||
//create empty parent folders
|
||||
for(int j=emptyParent.size()-1;j>=0;j--)
|
||||
{
|
||||
emptyFolder = (IFolder) emptyParent.get(j);
|
||||
if(!emptyFolder.exists())
|
||||
{
|
||||
emptyFolder.create(true, true, monitor);
|
||||
}
|
||||
}
|
||||
//create empty folders
|
||||
emptyFolder = (IFolder) emptyFolders.get(i);
|
||||
if(!emptyFolder.exists())
|
||||
{
|
||||
emptyFolder.create(true, true, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replicates a set of remote files or folders to the workspace
|
||||
|
@ -610,7 +676,7 @@ public class UniversalFileTransferUtility
|
|||
boolean ok = true;
|
||||
SystemWorkspaceResourceSet resultSet = new SystemWorkspaceResourceSet();
|
||||
IRemoteFileSubSystem srcFS = (IRemoteFileSubSystem)remoteSet.getSubSystem();
|
||||
|
||||
|
||||
if (!srcFS.isConnected())
|
||||
{
|
||||
return null;
|
||||
|
@ -619,6 +685,8 @@ public class UniversalFileTransferUtility
|
|||
boolean doSuperTransferProperty = doSuperTransfer(srcFS);
|
||||
|
||||
List set = remoteSet.getResourceSet();
|
||||
List emptyFolders = new ArrayList();
|
||||
|
||||
for (int i = 0; i < set.size() && !resultSet.hasMessage(); i++)
|
||||
{
|
||||
if (monitor != null && monitor.isCanceled())
|
||||
|
@ -674,8 +742,12 @@ public class UniversalFileTransferUtility
|
|||
try
|
||||
{
|
||||
IRemoteFile[] children = srcFS.list(srcFileOrFolder,monitor);
|
||||
|
||||
|
||||
//check for empty folder and add to set
|
||||
if(children==null || children.length==0)
|
||||
{
|
||||
emptyFolders.add(tempFolder);
|
||||
}
|
||||
|
||||
SystemRemoteResourceSet childSet = new SystemRemoteResourceSet(srcFS, children);
|
||||
SystemWorkspaceResourceSet childResults = downloadResourcesToWorkspace(childSet, monitor);
|
||||
if (childResults.hasMessage())
|
||||
|
@ -693,7 +765,19 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//Create empty folders
|
||||
try
|
||||
{
|
||||
createEmptyFolders(monitor, emptyFolders);
|
||||
}
|
||||
catch(CoreException e)
|
||||
{
|
||||
SystemMessage errorMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
ISystemFileConstants.FILEMSG_CREATE_FILE_FAILED,
|
||||
IStatus.ERROR, FileResources.FILEMSG_CREATE_FILE_FAILED, e);
|
||||
resultSet.setMessage(errorMessage);
|
||||
}
|
||||
|
||||
// refresh and set IFile properties
|
||||
for (int r = 0; r < resultSet.size(); r++)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
* 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.files.ui.view;
|
||||
|
@ -1652,6 +1653,7 @@ public class SystemViewRemoteFileAdapter
|
|||
boolean doSuperTransferProperty = RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemFilePreferencesConstants.DOSUPERTRANSFER);
|
||||
if (!doSuperTransferProperty && supportsSearch)
|
||||
{
|
||||
//flatset will contain all FILES that will be copied to workspace in UniversalFileTransferUtility and create corresponding folders. Empty folders will be ignored
|
||||
SystemRemoteResourceSet flatSet = new SystemRemoteResourceSet(set.getSubSystem(), set.getAdapter());
|
||||
long totalByteSize = getFlatRemoteResourceSet(set.getResourceSet(), flatSet, monitor);
|
||||
flatSet.setByteSize(totalByteSize);
|
||||
|
@ -1661,7 +1663,18 @@ public class SystemViewRemoteFileAdapter
|
|||
monitor.beginTask(_downloadMessage, (int)totalByteSize);
|
||||
//monitor.done();
|
||||
}
|
||||
|
||||
|
||||
//add folders to set that are being copied to the workspace in order to strip out empty folders in UniversalFileTransferUtility
|
||||
for (int i=0;i<set.size();i++)
|
||||
{
|
||||
IRemoteFile remoteFile = (IRemoteFile)set.get(i);
|
||||
//make sure it is a folder as files are being accounted for already
|
||||
if(remoteFile.isDirectory())
|
||||
{
|
||||
flatSet.addResource(remoteFile);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//SystemWorkspaceResourceSet flatResult = UniversalFileTransferUtility.copyRemoteResourcesToWorkspace(flatSet, monitor);
|
||||
|
|
Loading…
Add table
Reference in a new issue