mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-29 19:23:38 +02:00
[210682] Copy collisions will use SystemCopyDialog now instead of renameDialog when there is a copy collision within the same connection
This commit is contained in:
parent
63f7168933
commit
900754f99d
10 changed files with 1183 additions and 490 deletions
|
@ -34,14 +34,15 @@
|
||||||
* David McKnight (IBM) - [209375] new API copyRemoteResourcesToWorkspaceMultiple to optimize downloads
|
* 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.
|
* 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.
|
||||||
* Xuan Chen (IBM) - [160775] [api] [breaking] [nl] rename (at least within a zip) blocks UI thread
|
* Xuan Chen (IBM) - [160775] [api] [breaking] [nl] rename (at least within a zip) blocks UI thread
|
||||||
* David Mcknight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text)
|
* David McKnight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text)
|
||||||
* David McKnight (IBM) - [209552] get rid of copy APIs to be clearer with download and upload
|
* David McKnight (IBM) - [209552] get rid of copy APIs to be clearer with download and upload
|
||||||
* David McKnight (IBM) - [143503] encoding and isBinary needs to be stored in the IFile properties
|
* David McKnight (IBM) - [143503] encoding and isBinary needs to be stored in the IFile properties
|
||||||
* Xuan Chen (IBM) - [191370] [dstore] supertransfer zip not deleted when cancelling copy
|
* Xuan Chen (IBM) - [191370] [dstore] supertransfer zip not deleted when canceling copy
|
||||||
* Xuan Chen (IBM) - [210816] Archive testcases throw ResourceException if they are run in batch
|
* Xuan Chen (IBM) - [210816] Archive testcases throw ResourceException if they are run in batch
|
||||||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||||
* Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal
|
* Martin Oberhuber (Wind River) - [220020][api][breaking] SystemFileTransferModeRegistry should be internal
|
||||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
* 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
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.files.ui.resources;
|
package org.eclipse.rse.files.ui.resources;
|
||||||
|
@ -107,6 +108,7 @@ import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem;
|
||||||
import org.eclipse.rse.subsystems.files.core.util.ValidatorFileUniqueName;
|
import org.eclipse.rse.subsystems.files.core.util.ValidatorFileUniqueName;
|
||||||
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.internal.ui.dialogs.CopyRunnable;
|
||||||
import org.eclipse.rse.ui.dialogs.SystemRenameSingleDialog;
|
import org.eclipse.rse.ui.dialogs.SystemRenameSingleDialog;
|
||||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
@ -116,6 +118,9 @@ import org.eclipse.ui.PlatformUI;
|
||||||
* Utility class for doing file transfers on universal systems.
|
* Utility class for doing file transfers on universal systems.
|
||||||
*
|
*
|
||||||
* Clients may use this class, but not instantiate or subclass it.
|
* Clients may use this class, but not instantiate or subclass it.
|
||||||
|
*
|
||||||
|
* @noextend
|
||||||
|
* @noinstantiate
|
||||||
*/
|
*/
|
||||||
public class UniversalFileTransferUtility
|
public class UniversalFileTransferUtility
|
||||||
{
|
{
|
||||||
|
@ -1316,7 +1321,9 @@ public class UniversalFileTransferUtility
|
||||||
|
|
||||||
// clear the list so that next time we use renamed names
|
// clear the list so that next time we use renamed names
|
||||||
newFilePathList.clear();
|
newFilePathList.clear();
|
||||||
List toCopyNames = new ArrayList();
|
//List toCopyNames = new ArrayList(); //was used for rename operation (no longer needed)
|
||||||
|
List copyFilesOrFolders = new ArrayList();
|
||||||
|
List existingFilesOrFolders = new ArrayList();
|
||||||
|
|
||||||
for (int i = 0; i < resources.size() && !resultSet.hasMessage(); i++)
|
for (int i = 0; i < resources.size() && !resultSet.hasMessage(); i++)
|
||||||
{
|
{
|
||||||
|
@ -1347,8 +1354,15 @@ public class UniversalFileTransferUtility
|
||||||
String oldPath = newPathBuf.toString() + name;
|
String oldPath = newPathBuf.toString() + name;
|
||||||
if (checkForCollisions)
|
if (checkForCollisions)
|
||||||
{
|
{
|
||||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
if(existingFiles!=null)
|
||||||
int severity = status.getSeverity();
|
{
|
||||||
|
if(checkForCollision(existingFiles, targetFolder, oldPath))
|
||||||
|
{
|
||||||
|
existingFilesOrFolders.add(existingFiles.get(oldPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//below code is used for renaming operation, which is no longer needed
|
||||||
|
/*int severity = status.getSeverity();
|
||||||
|
|
||||||
if (severity == IStatus.OK) {
|
if (severity == IStatus.OK) {
|
||||||
name = status.getMessage();
|
name = status.getMessage();
|
||||||
|
@ -1364,56 +1378,9 @@ public class UniversalFileTransferUtility
|
||||||
else if (code == RenameStatus.CANCEL_ALL) {
|
else if (code == RenameStatus.CANCEL_ALL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
String newPath = newPathBuf.toString() + name;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
String srcCharSet = null;
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
srcCharSet = ((IFile)srcFileOrFolder).getCharset(false);
|
|
||||||
if (srcCharSet == null || srcCharSet.length() == 0)
|
|
||||||
{
|
|
||||||
srcCharSet = SystemEncodingUtil.ENCODING_UTF_8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (CoreException e)
|
|
||||||
{
|
|
||||||
srcCharSet = SystemEncodingUtil.ENCODING_UTF_8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
String srcFileLocation = srcFileOrFolder.getLocation().toOSString();
|
|
||||||
targetFS.upload(srcFileLocation, srcCharSet, newPath, targetFS.getRemoteEncoding(),monitor);
|
|
||||||
newFilePathList.add(newPath);
|
|
||||||
|
|
||||||
// should check preference first
|
|
||||||
if (RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemFilePreferencesConstants.PRESERVETIMESTAMPS))
|
|
||||||
{
|
|
||||||
SystemIFileProperties properties = new SystemIFileProperties(srcFileOrFolder);
|
|
||||||
((FileServiceSubSystem)targetFS).getFileService().setLastModified(newPathBuf.toString(), name, properties.getRemoteFileTimeStamp(), monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (RemoteFileIOException e)
|
|
||||||
{
|
|
||||||
resultSet.setMessage(e.getSystemMessage());
|
|
||||||
}
|
|
||||||
catch (SystemMessageException e)
|
|
||||||
{
|
|
||||||
resultSet.setMessage(e.getSystemMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resultSet.hasMessage())
|
|
||||||
{
|
|
||||||
return resultSet;
|
|
||||||
}
|
}
|
||||||
|
copyFilesOrFolders.add(srcFileOrFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (srcFileOrFolder instanceof IContainer)
|
else if (srcFileOrFolder instanceof IContainer)
|
||||||
|
@ -1421,6 +1388,15 @@ public class UniversalFileTransferUtility
|
||||||
String oldPath = newPathBuf.toString() + name;
|
String oldPath = newPathBuf.toString() + name;
|
||||||
if (checkForCollisions)
|
if (checkForCollisions)
|
||||||
{
|
{
|
||||||
|
if(existingFiles!=null)
|
||||||
|
{
|
||||||
|
if(checkForCollision(existingFiles, targetFolder, oldPath))
|
||||||
|
{
|
||||||
|
existingFilesOrFolders.add(existingFiles.get(oldPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//below code is used for renaming operation, which is no longer needed
|
||||||
|
/*
|
||||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
||||||
int severity = status.getSeverity();
|
int severity = status.getSeverity();
|
||||||
|
|
||||||
|
@ -1439,83 +1415,146 @@ public class UniversalFileTransferUtility
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
|
|
||||||
IContainer directory = (IContainer) srcFileOrFolder;
|
|
||||||
if (!directory.exists())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
directory.refreshLocal(IResource.DEPTH_ONE, monitor);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
copyFilesOrFolders.add(srcFileOrFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean overwrite=false;
|
||||||
|
if(existingFilesOrFolders.size()>0)
|
||||||
|
{
|
||||||
|
CopyRunnable cr = new CopyRunnable(existingFilesOrFolders);
|
||||||
|
Display.getDefault().syncExec(cr);
|
||||||
|
overwrite = cr.getOk();
|
||||||
|
}
|
||||||
|
if(existingFilesOrFolders.size()==0 || overwrite)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < copyFilesOrFolders.size() && !resultSet.hasMessage(); i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
IResource srcFileOrFolder = (IResource)copyFilesOrFolders.get(i);
|
||||||
|
String name = srcFileOrFolder.getName();
|
||||||
|
|
||||||
String newPath = newPathBuf.toString() + name;
|
String newPath = newPathBuf.toString() + name;
|
||||||
|
|
||||||
// this is a directory
|
if (srcFileOrFolder instanceof IFile)
|
||||||
// recursively copy
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
if (existingFiles != null)
|
try
|
||||||
{
|
{
|
||||||
IRemoteFile newTargetFolder = (IRemoteFile)existingFiles.get(newPath);
|
String srcCharSet = null;
|
||||||
// newTargetFolder will be null if user chose to do a rename
|
try
|
||||||
if (newTargetFolder == null) {
|
|
||||||
newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
|
|
||||||
}
|
|
||||||
if (newTargetFolder != null && !newTargetFolder.exists())
|
|
||||||
{
|
|
||||||
newTargetFolder = targetFS.createFolder(newTargetFolder, monitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isTargetLocal = newTargetFolder.getParentRemoteFileSubSystem().getHost().getSystemType().isLocal();
|
|
||||||
boolean destInArchive = (newTargetFolder instanceof IVirtualRemoteFile) || newTargetFolder.isArchive();
|
|
||||||
|
|
||||||
if (doCompressedTransfer && doSuperTransferPreference && !destInArchive && !isTargetLocal)
|
|
||||||
{
|
|
||||||
compressedUploadFromWorkspace(directory, newTargetFolder, monitor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//sometimes, IContainer#members does not return the right members under
|
|
||||||
//this folder. We need to call refreshLocal() first to overcome this problem
|
|
||||||
directory.refreshLocal(IResource.DEPTH_ONE, monitor);
|
|
||||||
IResource[] children = directory.members();
|
|
||||||
SystemWorkspaceResourceSet childSet = new SystemWorkspaceResourceSet(children);
|
|
||||||
SystemRemoteResourceSet childResults = uploadResourcesFromWorkspace(childSet, newTargetFolder, monitor, false);
|
|
||||||
if (childResults == null)
|
|
||||||
{
|
{
|
||||||
return null;
|
srcCharSet = ((IFile)srcFileOrFolder).getCharset(false);
|
||||||
|
if (srcCharSet == null || srcCharSet.length() == 0)
|
||||||
|
{
|
||||||
|
srcCharSet = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (childResults.hasMessage())
|
catch (CoreException e)
|
||||||
{
|
{
|
||||||
resultSet.setMessage(childResults.getMessage());
|
srcCharSet = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String srcFileLocation = srcFileOrFolder.getLocation().toOSString();
|
||||||
|
targetFS.upload(srcFileLocation, srcCharSet, newPath, targetFS.getRemoteEncoding(),monitor);
|
||||||
|
newFilePathList.add(newPath);
|
||||||
|
|
||||||
|
// should check preference first
|
||||||
|
if (RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemFilePreferencesConstants.PRESERVETIMESTAMPS))
|
||||||
|
{
|
||||||
|
SystemIFileProperties properties = new SystemIFileProperties(srcFileOrFolder);
|
||||||
|
((FileServiceSubSystem)targetFS).getFileService().setLastModified(newPathBuf.toString(), name, properties.getRemoteFileTimeStamp(), monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newFilePathList.add(newPath);
|
catch (RemoteFileIOException e)
|
||||||
|
{
|
||||||
|
resultSet.setMessage(e.getSystemMessage());
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
resultSet.setMessage(e.getSystemMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultSet.hasMessage())
|
||||||
|
{
|
||||||
|
return resultSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SystemMessageException e)
|
if(srcFileOrFolder instanceof IContainer)
|
||||||
{
|
{
|
||||||
workspaceSet.setMessage(e.getSystemMessage());
|
IContainer directory = (IContainer) srcFileOrFolder;
|
||||||
}
|
if (!directory.exists())
|
||||||
catch (CoreException e)
|
{
|
||||||
{
|
try
|
||||||
e.printStackTrace();
|
{
|
||||||
}
|
directory.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||||
catch (Exception e)
|
}
|
||||||
{
|
catch (Exception e)
|
||||||
e.printStackTrace();
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (existingFiles != null)
|
||||||
|
{
|
||||||
|
IRemoteFile newTargetFolder = (IRemoteFile)existingFiles.get(newPath);
|
||||||
|
// newTargetFolder will be null if user chose to do a rename
|
||||||
|
if (newTargetFolder == null) {
|
||||||
|
newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
|
||||||
|
}
|
||||||
|
if (newTargetFolder != null && !newTargetFolder.exists())
|
||||||
|
{
|
||||||
|
newTargetFolder = targetFS.createFolder(newTargetFolder, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isTargetLocal = newTargetFolder.getParentRemoteFileSubSystem().getHost().getSystemType().isLocal();
|
||||||
|
boolean destInArchive = (newTargetFolder instanceof IVirtualRemoteFile) || newTargetFolder.isArchive();
|
||||||
|
|
||||||
|
if (doCompressedTransfer && doSuperTransferPreference && !destInArchive && !isTargetLocal)
|
||||||
|
{
|
||||||
|
compressedUploadFromWorkspace(directory, newTargetFolder, monitor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//sometimes, IContainer#members does not return the right members under
|
||||||
|
//this folder. We need to call refreshLocal() first to overcome this problem
|
||||||
|
directory.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||||
|
IResource[] children = directory.members();
|
||||||
|
SystemWorkspaceResourceSet childSet = new SystemWorkspaceResourceSet(children);
|
||||||
|
SystemRemoteResourceSet childResults = uploadResourcesFromWorkspace(childSet, newTargetFolder, monitor, false);
|
||||||
|
if (childResults == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (childResults.hasMessage())
|
||||||
|
{
|
||||||
|
resultSet.setMessage(childResults.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newFilePathList.add(newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
workspaceSet.setMessage(e.getSystemMessage());
|
||||||
|
}
|
||||||
|
catch (CoreException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
|
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
|
||||||
|
@ -2469,6 +2508,18 @@ public class UniversalFileTransferUtility
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static boolean checkForCollision(SystemRemoteResourceSet existingFiles, IRemoteFile targetFolder, String oldPath)
|
||||||
|
{
|
||||||
|
|
||||||
|
IRemoteFile targetFileOrFolder = (IRemoteFile) existingFiles.get(oldPath);
|
||||||
|
|
||||||
|
|
||||||
|
if (targetFileOrFolder != null && targetFileOrFolder.exists())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static class RenameRunnable implements Runnable
|
public static class RenameRunnable implements Runnable
|
||||||
{
|
{
|
||||||
private IRemoteFile _targetFileOrFolder;
|
private IRemoteFile _targetFileOrFolder;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
|
* Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* This program and the accompanying materials are made available under the terms
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
|
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
|
||||||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] created checkForCollision method that returns a boolean for SystemCopyDialog enhancement
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.actions;
|
package org.eclipse.rse.internal.files.ui.actions;
|
||||||
|
@ -73,15 +74,15 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
* Copy selected files and folders action.
|
* Copy selected files and folders action.
|
||||||
*/
|
*/
|
||||||
public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
implements IValidatorRemoteSelection
|
implements IValidatorRemoteSelection
|
||||||
{
|
{
|
||||||
protected IRemoteFile targetFolder, targetFileOrFolder = null;
|
protected IRemoteFile targetFolder, targetFileOrFolder = null;
|
||||||
protected IRemoteFile firstSelection = null;
|
protected IRemoteFile firstSelection = null;
|
||||||
protected IRemoteFile firstSelectionParent = null;
|
protected IRemoteFile firstSelectionParent = null;
|
||||||
protected IRemoteFile[] files;
|
protected IRemoteFile[] files;
|
||||||
protected Vector copiedFiles = new Vector();
|
protected Vector copiedFiles = new Vector();
|
||||||
protected IHost sourceConnection;
|
protected IHost sourceConnection;
|
||||||
protected IRemoteFileSubSystem ss;
|
protected IRemoteFileSubSystem ss;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -96,8 +97,8 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
SystemCopyRemoteFileAction(Shell shell, int mode)
|
SystemCopyRemoteFileAction(Shell shell, int mode)
|
||||||
{
|
{
|
||||||
super(shell, mode);
|
super(shell, mode);
|
||||||
setHelp(RSEUIPlugin.HELPPREFIX+"actn0110"); //$NON-NLS-1$
|
setHelp(RSEUIPlugin.HELPPREFIX+"actn0110"); //$NON-NLS-1$
|
||||||
setDialogHelp(RSEUIPlugin.HELPPREFIX+"dcrf0000"); //$NON-NLS-1$
|
setDialogHelp(RSEUIPlugin.HELPPREFIX+"dcrf0000"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,14 +133,14 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
{
|
{
|
||||||
Object selectedObject = e.next();
|
Object selectedObject = e.next();
|
||||||
if (!(selectedObject instanceof IRemoteFile))
|
if (!(selectedObject instanceof IRemoteFile))
|
||||||
enable = false;
|
enable = false;
|
||||||
}
|
}
|
||||||
return enable;
|
return enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// PARENT METHOD OVERRIDES...
|
// PARENT METHOD OVERRIDES...
|
||||||
// --------------------------
|
// --------------------------
|
||||||
public static class RenameRunnable implements Runnable
|
public static class RenameRunnable implements Runnable
|
||||||
{
|
{
|
||||||
private IRemoteFile _targetFileOrFolder;
|
private IRemoteFile _targetFileOrFolder;
|
||||||
|
@ -166,6 +167,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
|
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
|
||||||
* @param shell Window to host dialog
|
* @param shell Window to host dialog
|
||||||
|
@ -175,7 +177,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
* @param oldName will be the name of the IRemoteFile object currently being copied
|
* @param oldName will be the name of the IRemoteFile object currently being copied
|
||||||
*/
|
*/
|
||||||
protected String checkForCollision(Shell shell, IProgressMonitor monitor,
|
protected String checkForCollision(Shell shell, IProgressMonitor monitor,
|
||||||
Object targetContainer, Object oldObject, String oldName)
|
Object targetContainer, Object oldObject, String oldName)
|
||||||
{
|
{
|
||||||
String newName = oldName;
|
String newName = oldName;
|
||||||
|
|
||||||
|
@ -193,13 +195,15 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
//RSEUIPlugin.logInfo("...target.exists()? "+tgtFileOrFolder.exists());
|
//RSEUIPlugin.logInfo("...target.exists()? "+tgtFileOrFolder.exists());
|
||||||
if (targetFileOrFolder.exists())
|
if (targetFileOrFolder.exists())
|
||||||
{
|
{
|
||||||
//monitor.setVisible(false); wish we could!
|
//monitor.setVisible(false); wish we could!
|
||||||
|
|
||||||
// we no longer have to set the validator here... the common rename dialog we all now use queries the input
|
// we no longer have to set the validator here... the common rename dialog we all now use queries the input
|
||||||
// object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
|
// object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
|
||||||
ValidatorFileUniqueName validator = null; // new ValidatorFileUniqueName(shell, targetFolder, srcFileOrFolder.isDirectory());
|
// ValidatorFileUniqueName validator = null; // new
|
||||||
//SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
|
// ValidatorFileUniqueName(shell, targetFolder,
|
||||||
RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
|
// srcFileOrFolder.isDirectory());
|
||||||
|
//SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
|
||||||
|
RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
|
||||||
Display.getDefault().syncExec(rr);
|
Display.getDefault().syncExec(rr);
|
||||||
newName = rr.getNewName();
|
newName = rr.getNewName();
|
||||||
}
|
}
|
||||||
|
@ -209,7 +213,35 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
|
|
||||||
return newName;
|
return newName;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
|
||||||
|
* @param shell Window to host dialog
|
||||||
|
* @param monitor Usually not needed
|
||||||
|
* @param targetContainer will be the IRemoteFile folder selected to copy into
|
||||||
|
* @param oldName will be the name of the IRemoteFile object currently being copied
|
||||||
|
*/
|
||||||
|
protected boolean checkForCollision(Shell shell, IProgressMonitor monitor,
|
||||||
|
Object targetContainer, String oldName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
targetFolder = (IRemoteFile)targetContainer;
|
||||||
|
ss = targetFolder.getParentRemoteFileSubSystem();
|
||||||
|
targetFileOrFolder = ss.getRemoteFileObject(targetFolder, oldName, monitor);
|
||||||
|
|
||||||
|
if (targetFileOrFolder.exists())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
SystemBasePlugin.logError("SystemCopyRemoteFileAction.checkForCollision()", e); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param targetContainer will be the IRemoteFile folder selected to copy into
|
* @param targetContainer will be the IRemoteFile folder selected to copy into
|
||||||
|
@ -219,17 +251,17 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
* @see SystemBaseCopyAction#doCopy(Object, Object, String, IProgressMonitor)
|
* @see SystemBaseCopyAction#doCopy(Object, Object, String, IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
protected boolean doCopy(Object targetContainer, Object oldObject, String newName, IProgressMonitor monitor)
|
protected boolean doCopy(Object targetContainer, Object oldObject, String newName, IProgressMonitor monitor)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
targetFolder = (IRemoteFile)targetContainer;
|
targetFolder = (IRemoteFile)targetContainer;
|
||||||
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
|
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
|
||||||
|
|
||||||
IHost targetConnection = targetFolder.getSystemConnection();
|
IHost targetConnection = targetFolder.getSystemConnection();
|
||||||
IHost srcConnection = srcFileOrFolder.getSystemConnection();
|
IHost srcConnection = srcFileOrFolder.getSystemConnection();
|
||||||
|
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
if (targetConnection == srcConnection)
|
if (targetConnection == srcConnection)
|
||||||
{
|
{
|
||||||
ss = targetFolder.getParentRemoteFileSubSystem();
|
ss = targetFolder.getParentRemoteFileSubSystem();
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,35 +270,35 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
{
|
{
|
||||||
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getName());
|
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getName());
|
||||||
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
|
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
throw new SystemMessageException(msg);
|
throw new SystemMessageException(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String sep = targetFolder.getSeparator();
|
String sep = targetFolder.getSeparator();
|
||||||
String targetFolderName = targetFolder.getAbsolutePath();
|
String targetFolderName = targetFolder.getAbsolutePath();
|
||||||
if (!targetFolderName.endsWith(sep))
|
if (!targetFolderName.endsWith(sep))
|
||||||
copiedFiles.addElement(targetFolderName+sep+newName);
|
copiedFiles.addElement(targetFolderName+sep+newName);
|
||||||
else
|
else
|
||||||
copiedFiles.addElement(targetFolderName+newName);
|
copiedFiles.addElement(targetFolderName+newName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// DKM - for cross system copy
|
// DKM - for cross system copy
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IRemoteFileSubSystem targetFS = targetFolder.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem targetFS = targetFolder.getParentRemoteFileSubSystem();
|
||||||
IRemoteFileSubSystem srcFS = srcFileOrFolder.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem srcFS = srcFileOrFolder.getParentRemoteFileSubSystem();
|
||||||
String newPath = targetFolder.getAbsolutePath() + "/" + newName; //$NON-NLS-1$
|
String newPath = targetFolder.getAbsolutePath() + "/" + newName; //$NON-NLS-1$
|
||||||
if (srcFileOrFolder.isFile())
|
if (srcFileOrFolder.isFile())
|
||||||
{
|
{
|
||||||
SystemRemoteEditManager mgr = SystemRemoteEditManager.getInstance();
|
SystemRemoteEditManager mgr = SystemRemoteEditManager.getInstance();
|
||||||
// if remote edit project doesn't exist, create it
|
// if remote edit project doesn't exist, create it
|
||||||
if (!mgr.doesRemoteEditProjectExist())
|
if (!mgr.doesRemoteEditProjectExist())
|
||||||
mgr.getRemoteEditProject();
|
mgr.getRemoteEditProject();
|
||||||
|
|
||||||
StringBuffer path = new StringBuffer(mgr.getRemoteEditProjectLocation().makeAbsolute().toOSString());
|
StringBuffer path = new StringBuffer(mgr.getRemoteEditProjectLocation().makeAbsolute().toOSString());
|
||||||
path = path.append("/" + srcFS.getSystemProfileName() + "/" + srcFS.getHostAliasName() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
path = path.append("/" + srcFS.getSystemProfileName() + "/" + srcFS.getHostAliasName() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
||||||
String absolutePath = srcFileOrFolder.getAbsolutePath();
|
String absolutePath = srcFileOrFolder.getAbsolutePath();
|
||||||
|
@ -294,27 +326,27 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
|
|
||||||
String tempFile = path.toString();
|
String tempFile = path.toString();
|
||||||
|
|
||||||
srcFS.download(srcFileOrFolder, tempFile, SystemEncodingUtil.ENCODING_UTF_8, null);
|
srcFS.download(srcFileOrFolder, tempFile, SystemEncodingUtil.ENCODING_UTF_8, null);
|
||||||
targetFS.upload(tempFile, SystemEncodingUtil.ENCODING_UTF_8, newPath, System.getProperty("file.encoding"), null); //$NON-NLS-1$
|
targetFS.upload(tempFile, SystemEncodingUtil.ENCODING_UTF_8, newPath, System.getProperty("file.encoding"), null); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
IRemoteFile newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
|
IRemoteFile newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
|
||||||
targetFS.createFolder(newTargetFolder, monitor);
|
targetFS.createFolder(newTargetFolder, monitor);
|
||||||
IRemoteFile[] children = srcFS.list(srcFileOrFolder, monitor);
|
IRemoteFile[] children = srcFS.list(srcFileOrFolder, monitor);
|
||||||
if (children != null)
|
if (children != null)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < children.length; i++)
|
for (int i = 0; i < children.length; i++)
|
||||||
{
|
{
|
||||||
IRemoteFile child = children[i];
|
IRemoteFile child = children[i];
|
||||||
monitor.subTask("copying " + child.getName()); //$NON-NLS-1$
|
monitor.subTask("copying " + child.getName()); //$NON-NLS-1$
|
||||||
doCopy(newTargetFolder, child, child.getName(), monitor);
|
doCopy(newTargetFolder, child, child.getName(), monitor);
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
@ -354,7 +386,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
IRemoteFile[] files = getSelectedFiles();
|
IRemoteFile[] files = getSelectedFiles();
|
||||||
String[] names = new String[files.length];
|
String[] names = new String[files.length];
|
||||||
for (int idx=0; idx<files.length; idx++)
|
for (int idx=0; idx<files.length; idx++)
|
||||||
names[idx] = files[idx].getName();
|
names[idx] = files[idx].getName();
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +399,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
{
|
{
|
||||||
++runCount;
|
++runCount;
|
||||||
if (runCount > 1)
|
if (runCount > 1)
|
||||||
reset();
|
reset();
|
||||||
//return new SystemSimpleCopyDialog(parent, getPromptString(), mode, this, getTreeModel(), getTreeInitialSelection());
|
//return new SystemSimpleCopyDialog(parent, getPromptString(), mode, this, getTreeModel(), getTreeInitialSelection());
|
||||||
String dlgTitle = (mode==MODE_COPY ? SystemResources.RESID_COPY_TITLE : SystemResources.RESID_MOVE_TITLE);
|
String dlgTitle = (mode==MODE_COPY ? SystemResources.RESID_COPY_TITLE : SystemResources.RESID_MOVE_TITLE);
|
||||||
|
|
||||||
|
@ -381,7 +413,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
|
|
||||||
//dlg.setSystemConnection(sourceConnection);
|
//dlg.setSystemConnection(sourceConnection);
|
||||||
if (mode==MODE_MOVE)
|
if (mode==MODE_MOVE)
|
||||||
dlg.setSelectionValidator(this);
|
dlg.setSelectionValidator(this);
|
||||||
//RSEUIPlugin.logInfo("Calling getParentRemoteFile for '"+firstSelection.getAbsolutePath()+"'");
|
//RSEUIPlugin.logInfo("Calling getParentRemoteFile for '"+firstSelection.getAbsolutePath()+"'");
|
||||||
firstSelectionParent = firstSelection.getParentRemoteFile();
|
firstSelectionParent = firstSelection.getParentRemoteFile();
|
||||||
boolean supportsArchiveManagement = firstSelectionParent.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
|
boolean supportsArchiveManagement = firstSelectionParent.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
|
||||||
|
@ -399,7 +431,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
RSEUIPlugin.logInfo("Result of getParentRemoteFile: '"+firstSelectionParent.getAbsolutePath()+"'");
|
RSEUIPlugin.logInfo("Result of getParentRemoteFile: '"+firstSelectionParent.getAbsolutePath()+"'");
|
||||||
else
|
else
|
||||||
RSEUIPlugin.logInfo("Result of getParentRemoteFile: null");
|
RSEUIPlugin.logInfo("Result of getParentRemoteFile: null");
|
||||||
*/
|
*/
|
||||||
dlg.setPreSelection(firstSelectionParent);
|
dlg.setPreSelection(firstSelectionParent);
|
||||||
|
|
||||||
// our title now reflects multiple selection. If single change it.
|
// our title now reflects multiple selection. If single change it.
|
||||||
|
@ -429,18 +461,18 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
Object targetContainer = null;
|
Object targetContainer = null;
|
||||||
if (!cpyDlg.wasCancelled())
|
if (!cpyDlg.wasCancelled())
|
||||||
{
|
{
|
||||||
targetContainer = cpyDlg.getSelectedObject();
|
targetContainer = cpyDlg.getSelectedObject();
|
||||||
if (targetContainer instanceof ISystemFilterReference)
|
if (targetContainer instanceof ISystemFilterReference)
|
||||||
{
|
{
|
||||||
ISubSystem targetSubSystem = ((ISystemFilterReference)targetContainer).getSubSystem();
|
ISubSystem targetSubSystem = ((ISystemFilterReference)targetContainer).getSubSystem();
|
||||||
ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
|
ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
|
||||||
if (factory.supportsDropInFilters())
|
if (factory.supportsDropInFilters())
|
||||||
{
|
{
|
||||||
targetContainer = targetSubSystem.getTargetForFilter((ISystemFilterReference)targetContainer);
|
targetContainer = targetSubSystem.getTargetForFilter((ISystemFilterReference)targetContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return targetContainer;
|
return targetContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidateFilterReferences(IRemoteFile targetFolder)
|
private void invalidateFilterReferences(IRemoteFile targetFolder)
|
||||||
|
@ -495,25 +527,25 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
public void copyComplete()
|
public void copyComplete()
|
||||||
{
|
{
|
||||||
if (copiedFiles.size() == 0)
|
if (copiedFiles.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// refresh all instances of this parent, and all affected filters...
|
// refresh all instances of this parent, and all affected filters...
|
||||||
ISubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
|
ISubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
|
||||||
Viewer originatingViewer = getViewer();
|
Viewer originatingViewer = getViewer();
|
||||||
if (originatingViewer != null)
|
if (originatingViewer != null)
|
||||||
{
|
{
|
||||||
if (!targetFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
if (!targetFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
||||||
{
|
{
|
||||||
// we select the first instance of the target folder now so that the copied members will be selected in it
|
// we select the first instance of the target folder now so that the copied members will be selected in it
|
||||||
// after it is refreshed via the remote_resource_created event.
|
// after it is refreshed via the remote_resource_created event.
|
||||||
if (originatingViewer instanceof SystemView)
|
if (originatingViewer instanceof SystemView)
|
||||||
{
|
{
|
||||||
// boolean selectedOk = ((SystemView)originatingViewer).selectRemoteObjects(targetFolder.getAbsolutePath(), fileSS, null);
|
// boolean selectedOk = ((SystemView)originatingViewer).selectRemoteObjects(targetFolder.getAbsolutePath(), fileSS, null);
|
||||||
//System.out.println(targetFolder.getAbsolutePath()+" selectedOK? " + selectedOk);
|
//System.out.println(targetFolder.getAbsolutePath()+" selectedOK? " + selectedOk);
|
||||||
//if (selectedOk)
|
//if (selectedOk)
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -524,7 +556,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
|
|
||||||
|
|
||||||
RSECorePlugin.getTheSystemRegistry().fireRemoteResourceChangeEvent(
|
RSECorePlugin.getTheSystemRegistry().fireRemoteResourceChangeEvent(
|
||||||
ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, copiedFiles, targetFolder.getAbsolutePath(), fileSS, null, originatingViewer);
|
ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, copiedFiles, targetFolder.getAbsolutePath(), fileSS, null, originatingViewer);
|
||||||
|
|
||||||
/* Old release 1.0 way...
|
/* Old release 1.0 way...
|
||||||
// did they copy to the same parent? Just refresh that parent, whatever it is...
|
// did they copy to the same parent? Just refresh that parent, whatever it is...
|
||||||
|
@ -567,43 +599,43 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||||
event.setOriginatingViewer(getViewer());
|
event.setOriginatingViewer(getViewer());
|
||||||
sr.fireEvent(event);
|
sr.fireEvent(event);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
// PRIVATE METHODS...
|
// PRIVATE METHODS...
|
||||||
// ------------------
|
// ------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the currently selected IRemoteFile objects
|
* Get the currently selected IRemoteFile objects
|
||||||
*/
|
*/
|
||||||
protected IRemoteFile[] getSelectedFiles()
|
protected IRemoteFile[] getSelectedFiles()
|
||||||
{
|
{
|
||||||
if (files == null)
|
if (files == null)
|
||||||
{
|
{
|
||||||
IStructuredSelection selection = getSelection();
|
IStructuredSelection selection = getSelection();
|
||||||
files = new IRemoteFile[selection.size()];
|
files = new IRemoteFile[selection.size()];
|
||||||
Iterator i = selection.iterator();
|
Iterator i = selection.iterator();
|
||||||
int idx=0;
|
int idx=0;
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
files[idx++] = (IRemoteFile)i.next();
|
files[idx++] = (IRemoteFile)i.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the first selected file or folder
|
* Get the first selected file or folder
|
||||||
*/
|
*/
|
||||||
protected IRemoteFile getFirstSelectedFile()
|
protected IRemoteFile getFirstSelectedFile()
|
||||||
{
|
{
|
||||||
if (files == null)
|
if (files == null)
|
||||||
getSelectedFiles();
|
getSelectedFiles();
|
||||||
if (files.length > 0)
|
if (files.length > 0)
|
||||||
return files[0];
|
return files[0];
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage
|
* The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2002, 2007 IBM Corporation and others. All rights reserved.
|
* Copyright (c) 2002, 2008 IBM Corporation and others. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* This program and the accompanying materials are made available under the terms
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -21,9 +21,12 @@
|
||||||
* Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations
|
* Xuan Chen (IBM) - [209827] Update DStore command implementation to enable cancelation of archive operations
|
||||||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] Modified MoveRemoteFileJob.runInWorkspace to use SystemCopyDialog for collisions in move operations
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.actions;
|
package org.eclipse.rse.internal.files.ui.actions;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.core.resources.WorkspaceJob;
|
import org.eclipse.core.resources.WorkspaceJob;
|
||||||
|
@ -50,7 +53,9 @@ import org.eclipse.rse.ui.actions.SystemBaseCopyAction;
|
||||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.rse.internal.ui.dialogs.CopyRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move selected files and folders action.
|
* Move selected files and folders action.
|
||||||
|
@ -84,65 +89,103 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
||||||
|
|
||||||
IStatus status = Status.OK_STATUS;
|
IStatus status = Status.OK_STATUS;
|
||||||
|
|
||||||
try
|
//holds existing objects
|
||||||
{
|
List existing = new ArrayList();
|
||||||
int steps = oldObjects.length;
|
//holds objects to be copied
|
||||||
monitor.beginTask(msg.getLevelOneText(), steps);
|
List toCopy = new ArrayList();
|
||||||
copiedOk = true;
|
boolean overwrite = false;
|
||||||
String oldName = null;
|
|
||||||
String newName = null;
|
|
||||||
Object oldObject = null;
|
|
||||||
newNames = new String[oldNames.length];
|
|
||||||
for (int idx=0; copiedOk && (idx<steps); idx++)
|
|
||||||
{
|
|
||||||
oldName = oldNames[idx];
|
|
||||||
oldObject = oldObjects[idx];
|
|
||||||
monitor.subTask(getCopyingMessage(oldName).getLevelOneText());
|
|
||||||
newName = checkForCollision(getShell(), monitor, targetContainer, oldObject, oldName);
|
|
||||||
if (newName == null)
|
|
||||||
copiedOk = false;
|
|
||||||
else
|
|
||||||
copiedOk = doCopy(targetContainer, oldObject, newName, monitor);
|
|
||||||
newNames[idx] = newName;
|
|
||||||
monitor.worked(1);
|
|
||||||
movedFileNames.add(oldName); //remember the old name, in case we need it later.
|
|
||||||
}
|
|
||||||
monitor.done();
|
|
||||||
}
|
|
||||||
catch (SystemMessageException exc)
|
|
||||||
{
|
|
||||||
copiedOk = false;
|
|
||||||
//If this operation is canceled, need to display a proper message to the user.
|
|
||||||
if (monitor.isCanceled() && movedFileNames.size() > 0)
|
|
||||||
{
|
|
||||||
//Get the moved file names
|
|
||||||
String movedFileNamesList = (String)(movedFileNames.get(0));
|
|
||||||
for (int i=1; i<(movedFileNames.size()); i++)
|
|
||||||
{
|
|
||||||
movedFileNamesList = movedFileNamesList + "\n" + (String)(movedFileNames.get(i)); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
String msgTxt = FileResources.FILEMSG_MOVE_INTERRUPTED;
|
|
||||||
String msgDetails = NLS.bind(FileResources.FILEMSG_MOVE_INTERRUPTED_DETAILS, movedFileNamesList);
|
int steps = oldObjects.length;
|
||||||
|
monitor.beginTask(msg.getLevelOneText(), steps);
|
||||||
|
copiedOk = true;
|
||||||
|
String oldName = null;
|
||||||
|
String newName = null;
|
||||||
|
Object oldObject = null;
|
||||||
|
newNames = new String[oldNames.length];
|
||||||
|
//go through all files to see if they exist
|
||||||
|
for (int idx=0; copiedOk && (idx<steps); idx++)
|
||||||
|
{
|
||||||
|
oldName = oldNames[idx];
|
||||||
|
oldObject = oldObjects[idx];
|
||||||
|
//monitor.subTask(getCopyingMessage(oldName).getLevelOneText());
|
||||||
|
if(checkForCollision(getShell(), monitor, targetContainer, oldName))
|
||||||
|
{
|
||||||
|
existing.add(oldObject);
|
||||||
|
}
|
||||||
|
toCopy.add(oldObject);
|
||||||
|
/*newName = checkForCollision(getShell(), monitor, targetContainer, oldObject, oldName);
|
||||||
|
if (newName == null)
|
||||||
|
copiedOk = false;
|
||||||
|
else
|
||||||
|
copiedOk = doCopy(targetContainer, oldObject, newName, monitor);
|
||||||
|
newNames[idx] = newName;
|
||||||
|
monitor.worked(1);
|
||||||
|
movedFileNames.add(oldName);*/ //remember the old name, in case we need it later.
|
||||||
|
}
|
||||||
|
//monitor.done();
|
||||||
|
|
||||||
|
//SystemCopyDialog used here with all existing objects
|
||||||
|
if(existing.size()>0)
|
||||||
|
{
|
||||||
|
CopyRunnable cr = new CopyRunnable(existing);
|
||||||
|
Display.getDefault().syncExec(cr);
|
||||||
|
overwrite = cr.getOk();
|
||||||
|
if(!overwrite)
|
||||||
|
{
|
||||||
|
status = Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Proceed with copy if user chose to overwrite or there were no copy collisions
|
||||||
|
if(existing.size()==0 || overwrite)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int idx=0; copiedOk && (idx<steps); idx++)
|
||||||
|
{
|
||||||
|
newName = oldNames[idx];
|
||||||
|
oldObject = oldObjects[idx];
|
||||||
|
monitor.subTask(getCopyingMessage(newName).getLevelOneText());
|
||||||
|
copiedOk = doCopy(targetContainer, oldObject, newName, monitor);
|
||||||
|
monitor.worked(1);
|
||||||
|
newNames[idx] = newName;
|
||||||
|
movedFileNames.add(newName);
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SystemMessageException exc)
|
||||||
|
{
|
||||||
|
copiedOk = false;
|
||||||
|
//If this operation is canceled, need to display a proper message to the user.
|
||||||
|
if (monitor.isCanceled() && movedFileNames.size() > 0)
|
||||||
|
{
|
||||||
|
//Get the moved file names
|
||||||
|
String movedFileNamesList = (String)(movedFileNames.get(0));
|
||||||
|
for (int i=1; i<(movedFileNames.size()); i++)
|
||||||
|
{
|
||||||
|
movedFileNamesList = movedFileNamesList + "\n" + (String)(movedFileNames.get(i)); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
String msgTxt = FileResources.FILEMSG_MOVE_INTERRUPTED;
|
||||||
|
String msgDetails = NLS.bind(FileResources.FILEMSG_MOVE_INTERRUPTED_DETAILS, movedFileNamesList);
|
||||||
|
|
||||||
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ISystemFileConstants.FILEMSG_MOVE_INTERRUPTED,
|
ISystemFileConstants.FILEMSG_MOVE_INTERRUPTED,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||||
|
|
||||||
status = Status.CANCEL_STATUS;
|
status = Status.CANCEL_STATUS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SystemMessageDialog.displayErrorMessage(shell, exc.getSystemMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception exc)
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayErrorMessage(shell, exc.getSystemMessage());
|
copiedOk = false;
|
||||||
|
exc.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exc)
|
|
||||||
{
|
|
||||||
copiedOk = false;
|
|
||||||
exc.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (movedFiles.size() > 0)
|
if (movedFiles.size() > 0)
|
||||||
{
|
{
|
||||||
copyComplete(); //Need to reflect the views.
|
copyComplete(); //Need to reflect the views.
|
||||||
|
@ -151,7 +194,6 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
|
* David McKnight (IBM) - [216252] MessageFormat.format -> NLS.bind
|
||||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||||
* Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
|
* Xuan Chen (IBM) - [223126] [api][breaking] Remove API related to User Actions in RSE Core/UI
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] Copy collisions will use SystemCopyDialog now instead of renameDialog when there is a copy collision within the same connection
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.files.ui.view;
|
package org.eclipse.rse.internal.files.ui.view;
|
||||||
|
@ -113,6 +114,7 @@ import org.eclipse.rse.internal.files.ui.actions.SystemSearchAction;
|
||||||
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
|
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
|
||||||
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
|
import org.eclipse.rse.internal.subsystems.files.core.ISystemFilePreferencesConstants;
|
||||||
import org.eclipse.rse.internal.ui.SystemResources;
|
import org.eclipse.rse.internal.ui.SystemResources;
|
||||||
|
import org.eclipse.rse.internal.ui.dialogs.CopyRunnable;
|
||||||
import org.eclipse.rse.internal.ui.view.ISystemMementoConstants;
|
import org.eclipse.rse.internal.ui.view.ISystemMementoConstants;
|
||||||
import org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable;
|
import org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable;
|
||||||
import org.eclipse.rse.internal.ui.view.SystemViewResources;
|
import org.eclipse.rse.internal.ui.view.SystemViewResources;
|
||||||
|
@ -1970,7 +1972,6 @@ public class SystemViewRemoteFileAdapter
|
||||||
ISystemFileConstants.FILEMSG_SECURITY_ERROR,
|
ISystemFileConstants.FILEMSG_SECURITY_ERROR,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
resultSet.setMessage(errorMsg);
|
resultSet.setMessage(errorMsg);
|
||||||
|
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2021,7 +2022,7 @@ public class SystemViewRemoteFileAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//getMessage("RSEG1125").makeSubstitution(movedFileName));
|
||||||
if (copiedFileNames != null)
|
if (copiedFileNames != null)
|
||||||
{
|
{
|
||||||
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
||||||
|
@ -2031,6 +2032,7 @@ public class SystemViewRemoteFileAdapter
|
||||||
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
resultSet.setMessage(thisMessage);
|
resultSet.setMessage(thisMessage);
|
||||||
|
//SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2096,9 +2098,11 @@ 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();
|
||||||
|
boolean overwrite=false;
|
||||||
|
|
||||||
for (int i = 0; i < set.size(); i++)
|
for (int i = 0; i < set.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -2133,27 +2137,30 @@ public class SystemViewRemoteFileAdapter
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath()))
|
if (!targetFolder.getAbsolutePath().equals(srcFileOrFolder.getAbsolutePath()) && !targetFolder.getAbsolutePath().equals(srcFileOrFolder.getParentRemoteFile().getAbsolutePath()))
|
||||||
{
|
{
|
||||||
|
|
||||||
// should be better doing a query for all in the set
|
// should be better doing a query for all in the set
|
||||||
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
|
||||||
if (existingFileOrFolder.exists())
|
if (existingFileOrFolder.exists())
|
||||||
{
|
{
|
||||||
RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
|
/*RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
|
||||||
Display.getDefault().syncExec(rr);
|
Display.getDefault().syncExec(rr);
|
||||||
name = rr.getNewName();
|
name = rr.getNewName();
|
||||||
|
*/
|
||||||
if (name != null)
|
existing.add(existingFileOrFolder);
|
||||||
{
|
|
||||||
toCopy.add(srcFileOrFolder);
|
|
||||||
toCopyNames.add(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (name != null)
|
|
||||||
|
if (name != null)
|
||||||
{
|
{
|
||||||
|
//toCopy.add(srcFileOrFolder);
|
||||||
|
//toCopyNames.add(name);
|
||||||
toCopyBatch.add(srcFileOrFolder);
|
toCopyBatch.add(srcFileOrFolder);
|
||||||
}
|
}
|
||||||
|
/*else if (name != null)
|
||||||
|
{
|
||||||
|
toCopyBatch.add(srcFileOrFolder);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2167,160 +2174,174 @@ public class SystemViewRemoteFileAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < toCopy.size(); x++)
|
|
||||||
|
if(existing.size()>0)
|
||||||
{
|
{
|
||||||
|
CopyRunnable rr = new CopyRunnable(existing);
|
||||||
|
Display.getDefault().syncExec(rr);
|
||||||
|
overwrite = rr.getOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Following code for renaming dialog copying procedures is not required
|
||||||
|
/*if(existing.size()==0 || overwrite)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < toCopy.size(); x++)
|
||||||
|
{
|
||||||
|
|
||||||
|
IRemoteFile srcFileOrFolder = (IRemoteFile)toCopy.get(x);
|
||||||
|
String name = (String)toCopyNames.get(x);
|
||||||
|
|
||||||
IRemoteFile srcFileOrFolder = (IRemoteFile)toCopy.get(x);
|
|
||||||
String name = (String)toCopyNames.get(x);
|
|
||||||
|
|
||||||
/*
|
|
||||||
SystemMessage copyMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COPY_PROGRESS);
|
SystemMessage copyMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COPY_PROGRESS);
|
||||||
copyMessage.makeSubstitution(srcFileOrFolder.getName(), targetFolder.getName());
|
copyMessage.makeSubstitution(srcFileOrFolder.getName(), targetFolder.getName());
|
||||||
if (monitor != null)
|
if (monitor != null)
|
||||||
{
|
{
|
||||||
monitor.beginTask(copyMessage.getLevelOneText(), 100);
|
monitor.beginTask(copyMessage.getLevelOneText(), 100);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
try
|
try
|
||||||
{
|
|
||||||
if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor))
|
|
||||||
{
|
{
|
||||||
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
|
if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor))
|
||||||
resultSet.addResource(copiedFile);
|
{
|
||||||
}
|
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
|
||||||
else
|
resultSet.addResource(copiedFile);
|
||||||
{
|
}
|
||||||
// need a failed message here
|
else
|
||||||
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getAbsolutePath());
|
{
|
||||||
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
// need a failed message here
|
||||||
|
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getAbsolutePath());
|
||||||
|
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
|
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
resultSet.setMessage(msg);
|
resultSet.setMessage(msg);
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SystemMessageException e)
|
|
||||||
{
|
|
||||||
if (monitor.isCanceled() && resultSet.size() > 0)
|
|
||||||
{
|
|
||||||
//Get the moved file names
|
|
||||||
Object thisObject = resultSet.get(0);
|
|
||||||
String copiedFileNames = null;
|
|
||||||
if (thisObject instanceof IRemoteFile)
|
|
||||||
{
|
|
||||||
copiedFileNames = ((IRemoteFile)thisObject).getName();
|
|
||||||
for (int i=1; i<(resultSet.size()); i++)
|
|
||||||
{
|
|
||||||
if (thisObject instanceof IRemoteFile)
|
|
||||||
{
|
|
||||||
copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)thisObject).getName(); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//getMessage("RSEG1125").makeSubstitution(movedFileName));
|
|
||||||
if (copiedFileNames != null)
|
|
||||||
{
|
|
||||||
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
|
||||||
String msgDetails = NLS.bind(FileResources.FILEMSG_COPY_INTERRUPTED_DETAILS, copiedFileNames);
|
|
||||||
|
|
||||||
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
|
||||||
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
|
||||||
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SystemMessageDialog.displayMessage(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (SystemMessageException e)
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayMessage(e);
|
if (monitor.isCanceled() && resultSet.size() > 0)
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// deal with batch copies now
|
|
||||||
IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()];
|
|
||||||
for (int x = 0; x < toCopyBatch.size(); x++)
|
|
||||||
{
|
|
||||||
srcFileOrFolders[x] = (IRemoteFile)toCopyBatch.get(x);
|
|
||||||
}
|
|
||||||
if (toCopyBatch.size() > 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (targetFS.copyBatch(srcFileOrFolders, targetFolder, monitor))
|
|
||||||
{
|
|
||||||
for (int x = 0; x < toCopyBatch.size(); x++)
|
|
||||||
{
|
{
|
||||||
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[x].getName(), monitor);
|
//Get the moved file names
|
||||||
resultSet.addResource(copiedFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (SystemMessageException e)
|
|
||||||
{
|
|
||||||
if (monitor.isCanceled() && srcFileOrFolders.length > 1)
|
|
||||||
{
|
|
||||||
//ISystemViewElementAdapter adapter = fromSet.getViewAdapter();
|
|
||||||
for (int i = 0; i < srcFileOrFolders.length; i++)
|
|
||||||
{
|
|
||||||
IRemoteFile thisCopiedFile = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
thisCopiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[i].getName(), null);
|
|
||||||
}
|
|
||||||
catch (SystemMessageException thsiException)
|
|
||||||
{
|
|
||||||
thsiException.printStackTrace();
|
|
||||||
thisCopiedFile = null;
|
|
||||||
}
|
|
||||||
if (thisCopiedFile != null && thisCopiedFile.exists())
|
|
||||||
{
|
|
||||||
//This object has been deleted
|
|
||||||
resultSet.addResource(thisCopiedFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resultSet.size() > 0)
|
|
||||||
{
|
|
||||||
//Get the copied file names
|
|
||||||
Object thisObject = resultSet.get(0);
|
Object thisObject = resultSet.get(0);
|
||||||
String copiedFileNames = null;
|
String copiedFileNames = null;
|
||||||
copiedFileNames = ((IRemoteFile)thisObject).getName();
|
if (thisObject instanceof IRemoteFile)
|
||||||
for (int i=1; i<(resultSet.size()); i++)
|
|
||||||
{
|
{
|
||||||
thisObject = resultSet.get(i);
|
copiedFileNames = ((IRemoteFile)thisObject).getName();
|
||||||
copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)resultSet.get(i)).getName(); //$NON-NLS-1$
|
for (int i=1; i<(resultSet.size()); i++)
|
||||||
|
{
|
||||||
|
if (thisObject instanceof IRemoteFile)
|
||||||
|
{
|
||||||
|
copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)thisObject).getName(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//getMessage("RSEG1125").makeSubstitution(movedFileName));
|
||||||
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
if (copiedFileNames != null)
|
||||||
String msgDetails = NLS.bind(FileResources.FILEMSG_COPY_INTERRUPTED_DETAILS, copiedFileNames);
|
{
|
||||||
|
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
||||||
|
String msgDetails = NLS.bind(FileResources.FILEMSG_COPY_INTERRUPTED_DETAILS, copiedFileNames);
|
||||||
|
|
||||||
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
||||||
IStatus.ERROR, msgTxt, msgDetails);
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SystemMessageDialog.displayMessage(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayMessage(e);
|
SystemMessageDialog.displayMessage(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
SystemMessageDialog.displayMessage(e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
}*/
|
||||||
|
// deal with batch copies now
|
||||||
|
if(existing.size()==0 || overwrite)
|
||||||
|
{
|
||||||
|
IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()];
|
||||||
|
for (int x = 0; x < toCopyBatch.size(); x++)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
srcFileOrFolders[x] = (IRemoteFile)toCopyBatch.get(x);
|
||||||
|
}
|
||||||
|
if (toCopyBatch.size() > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (targetFS.copyBatch(srcFileOrFolders, targetFolder, monitor))
|
||||||
|
{
|
||||||
|
for (int x = 0; x < toCopyBatch.size(); x++)
|
||||||
|
{
|
||||||
|
IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[x].getName(), monitor);
|
||||||
|
resultSet.addResource(copiedFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
if (monitor.isCanceled() && srcFileOrFolders.length > 1)
|
||||||
|
{
|
||||||
|
//ISystemViewElementAdapter adapter = fromSet.getViewAdapter();
|
||||||
|
for (int i = 0; i < srcFileOrFolders.length; i++)
|
||||||
|
{
|
||||||
|
IRemoteFile thisCopiedFile = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
thisCopiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[i].getName(), null);
|
||||||
|
}
|
||||||
|
catch (SystemMessageException thsiException)
|
||||||
|
{
|
||||||
|
thsiException.printStackTrace();
|
||||||
|
thisCopiedFile = null;
|
||||||
|
}
|
||||||
|
if (thisCopiedFile != null && thisCopiedFile.exists())
|
||||||
|
{
|
||||||
|
//This object has been deleted
|
||||||
|
resultSet.addResource(thisCopiedFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resultSet.size() > 0)
|
||||||
|
{
|
||||||
|
//Get the copied file names
|
||||||
|
Object thisObject = resultSet.get(0);
|
||||||
|
String copiedFileNames = null;
|
||||||
|
copiedFileNames = ((IRemoteFile)thisObject).getName();
|
||||||
|
for (int i=1; i<(resultSet.size()); i++)
|
||||||
|
{
|
||||||
|
thisObject = resultSet.get(i);
|
||||||
|
copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)resultSet.get(i)).getName(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
|
||||||
|
String msgDetails = NLS.bind(FileResources.FILEMSG_COPY_INTERRUPTED_DETAILS, copiedFileNames);
|
||||||
|
|
||||||
|
SystemMessage thisMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
|
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
||||||
|
IStatus.ERROR, msgTxt, msgDetails);
|
||||||
|
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SystemMessageDialog.displayMessage(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SystemMessageDialog.displayMessage(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2329,7 +2350,6 @@ public class SystemViewRemoteFileAdapter
|
||||||
}
|
}
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a copy via drag and drop.
|
* Perform a copy via drag and drop.
|
||||||
* @param src the object to be copied. If the target and source are not on the same system, then this is a
|
* @param src the object to be copied. If the target and source are not on the same system, then this is a
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* David McKnight (IBM) - [210229] table refresh needs unique table-specific tooltip-text
|
* David McKnight (IBM) - [210229] table refresh needs unique table-specific tooltip-text
|
||||||
* David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
* David McKnight (IBM) - [216252] [nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||||
* David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
|
* David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] Added BUTTON_OVERWRITE_ALL & and tooltip, also added some verbiage for new SystemCopyDialog.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui;
|
package org.eclipse.rse.internal.ui;
|
||||||
|
@ -43,6 +44,9 @@ public class SystemResources extends NLS
|
||||||
public static String BUTTON_CREATE_TOOLTIP;
|
public static String BUTTON_CREATE_TOOLTIP;
|
||||||
|
|
||||||
public static String BUTTON_CANCEL_ALL;
|
public static String BUTTON_CANCEL_ALL;
|
||||||
|
public static String BUTTON_CANCEL_ALL_TOOLTIP;
|
||||||
|
public static String BUTTON_OVERWRITE_ALL;
|
||||||
|
public static String BUTTON_OVERWRITE_ALL_TOOLTIP;
|
||||||
|
|
||||||
// THESE TERMS ARE USED POTENTIALLY ANYWHERE
|
// THESE TERMS ARE USED POTENTIALLY ANYWHERE
|
||||||
public static String TERM_YES;
|
public static String TERM_YES;
|
||||||
|
@ -127,6 +131,9 @@ public class SystemResources extends NLS
|
||||||
public static String RESID_COLLISION_RENAME_TITLE;
|
public static String RESID_COLLISION_RENAME_TITLE;
|
||||||
public static String RESID_COLLISION_RENAME_VERBIAGE;
|
public static String RESID_COLLISION_RENAME_VERBIAGE;
|
||||||
public static String RESID_COLLISION_RENAME_LABEL;
|
public static String RESID_COLLISION_RENAME_LABEL;
|
||||||
|
public static String RESID_COLLISION_RENAME_TOOLTIP;
|
||||||
|
public static String RESID_COLLISION_COPY_VERBIAGE;
|
||||||
|
public static String RESID_COLLISION_COPY_COLHDG_OLDNAME;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
# David Dykstal (IBM) - [181331] new filter wizard title should be "New Filter"
|
# David Dykstal (IBM) - [181331] new filter wizard title should be "New Filter"
|
||||||
# David Dykstal (IBM) - [142452] copy operations for connections, filterpools, and filters should be named "Copy..."
|
# David Dykstal (IBM) - [142452] copy operations for connections, filterpools, and filters should be named "Copy..."
|
||||||
# David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
|
# David McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
|
||||||
|
# Rupen Mardirossian (IBM) - [210692] Define strings for SystemCopyDialog
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# NLS_MESSAGEFORMAT_VAR
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
@ -33,6 +34,9 @@ BUTTON_ADD=Add
|
||||||
BUTTON_CREATE_LABEL=Create
|
BUTTON_CREATE_LABEL=Create
|
||||||
BUTTON_CREATE_TOOLTIP=Press to create the new resource
|
BUTTON_CREATE_TOOLTIP=Press to create the new resource
|
||||||
BUTTON_CANCEL_ALL = Cancel All
|
BUTTON_CANCEL_ALL = Cancel All
|
||||||
|
BUTTON_CANCEL_ALL_TOOLTIP = Cancel for all
|
||||||
|
BUTTON_OVERWRITE_ALL = Overwrite All
|
||||||
|
BUTTON_OVERWRITE_ALL_TOOLTIP = Overwrite for all
|
||||||
|
|
||||||
TERM_YES=Yes
|
TERM_YES=Yes
|
||||||
TERM_NO=No
|
TERM_NO=No
|
||||||
|
@ -180,6 +184,9 @@ RESID_MOVE_TARGET_FILTERPOOL_PROMPT=Select the filter pool to move into
|
||||||
RESID_COLLISION_RENAME_TITLE=Duplicate Name Collision
|
RESID_COLLISION_RENAME_TITLE=Duplicate Name Collision
|
||||||
RESID_COLLISION_RENAME_VERBIAGE=A resource named "&1" already exists.
|
RESID_COLLISION_RENAME_VERBIAGE=A resource named "&1" already exists.
|
||||||
RESID_COLLISION_RENAME_LABEL=Rename to
|
RESID_COLLISION_RENAME_LABEL=Rename to
|
||||||
|
RESID_COLLISION_RENAME_TOOLTIP=Enter unique new resource name
|
||||||
|
RESID_COLLISION_COPY_VERBIAGE=The following resources already exist. Would you like to overwrite all of the existing resources or cancel the operation?
|
||||||
|
RESID_COLLISION_COPY_COLHDG_OLDNAME=Resource
|
||||||
|
|
||||||
|
|
||||||
#=============================================================
|
#=============================================================
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation and others. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Rupen Mardirossian (IBM) - [210693] Created class to run SystemCopyDialog for enhancement defect.
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.ui.dialogs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CopyRunnable implements Runnable
|
||||||
|
{
|
||||||
|
private boolean _ok;
|
||||||
|
private List _existingNames;
|
||||||
|
private SystemCopyDialog dlg;
|
||||||
|
|
||||||
|
public CopyRunnable(List existing)
|
||||||
|
{
|
||||||
|
_existingNames = existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
dlg = new SystemCopyDialog(null, _existingNames);
|
||||||
|
dlg.open();
|
||||||
|
if (!dlg.wasCancelled())
|
||||||
|
_ok = true;
|
||||||
|
else
|
||||||
|
_ok = false;
|
||||||
|
}
|
||||||
|
public boolean getOk()
|
||||||
|
{
|
||||||
|
return _ok;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,156 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation and others. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Rupen Mardirossian (IBM) - [210693] Created Dialog for enhancement defect
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.ui.dialogs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.rse.internal.ui.SystemResources;
|
||||||
|
import org.eclipse.rse.internal.ui.dialogs.SystemCopyTableProvider;
|
||||||
|
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for confirming overwriting of resources when copy collision occurs.
|
||||||
|
*
|
||||||
|
* This dialog is a mirror copy of the SystemDeleteDialog with a few changes
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SystemCopyDialog extends SystemPromptDialog
|
||||||
|
{
|
||||||
|
private String verbiage;
|
||||||
|
private SystemCopyTableProvider sctp;
|
||||||
|
private Table table;
|
||||||
|
private TableViewer tableViewer;
|
||||||
|
private GridData tableData;
|
||||||
|
private List collisions;
|
||||||
|
|
||||||
|
// column layout
|
||||||
|
private ColumnLayoutData columnLayouts[] =
|
||||||
|
{
|
||||||
|
new ColumnPixelData(19, false),
|
||||||
|
new ColumnWeightData(150,150,true)
|
||||||
|
};
|
||||||
|
|
||||||
|
// column headers
|
||||||
|
private String columnHeaders[] = {
|
||||||
|
"", //$NON-NLS-1$
|
||||||
|
SystemResources.RESID_COLLISION_COPY_COLHDG_OLDNAME
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Constructor when you have your list of files and would like to use default title.
|
||||||
|
*/
|
||||||
|
public SystemCopyDialog(Shell shell, List files)
|
||||||
|
{
|
||||||
|
this(shell, SystemResources.RESID_COPY_TITLE, files);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor when you have your own title and list of files.
|
||||||
|
*/
|
||||||
|
public SystemCopyDialog(Shell shell, String title, List files)
|
||||||
|
{
|
||||||
|
super(shell, title);
|
||||||
|
setOkButtonLabel(SystemResources.BUTTON_OVERWRITE_ALL);
|
||||||
|
setOkButtonToolTipText(SystemResources.BUTTON_OVERWRITE_ALL_TOOLTIP);
|
||||||
|
setCancelButtonLabel(SystemResources.BUTTON_CANCEL_ALL);
|
||||||
|
setCancelButtonToolTipText(SystemResources.BUTTON_CANCEL_ALL_TOOLTIP);
|
||||||
|
collisions=files;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see SystemPromptDialog#createInner(Composite)
|
||||||
|
*/
|
||||||
|
protected Control createInner(Composite parent)
|
||||||
|
{
|
||||||
|
// Inner composite
|
||||||
|
int nbrColumns = 1;
|
||||||
|
Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns);
|
||||||
|
|
||||||
|
if (verbiage != null)
|
||||||
|
SystemWidgetHelpers.createVerbiage(composite, verbiage, nbrColumns, false, 200);
|
||||||
|
else
|
||||||
|
SystemWidgetHelpers.createVerbiage(composite, SystemResources.RESID_COLLISION_COPY_VERBIAGE, nbrColumns, false, 200);
|
||||||
|
|
||||||
|
// TABLE
|
||||||
|
tableViewer = createTableViewer(composite, nbrColumns);
|
||||||
|
createColumns();
|
||||||
|
|
||||||
|
sctp = new SystemCopyTableProvider();
|
||||||
|
|
||||||
|
int width = tableData.widthHint;
|
||||||
|
int nbrRows = Math.min(collisions.size(),8);
|
||||||
|
int rowHeight = table.getItemHeight() + table.getGridLineWidth();
|
||||||
|
int sbHeight = table.getHorizontalBar().getSize().y;
|
||||||
|
int height = (nbrRows * rowHeight) + sbHeight;
|
||||||
|
|
||||||
|
tableData.heightHint = height;
|
||||||
|
table.setLayoutData(tableData);
|
||||||
|
table.setSize(width, height);
|
||||||
|
|
||||||
|
tableViewer.setLabelProvider(sctp);
|
||||||
|
tableViewer.setContentProvider(sctp);
|
||||||
|
|
||||||
|
tableViewer.setInput(collisions);
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Creates and returns TableViewer
|
||||||
|
*/
|
||||||
|
private TableViewer createTableViewer(Composite parent, int nbrColumns)
|
||||||
|
{
|
||||||
|
table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HIDE_SELECTION);
|
||||||
|
table.setLinesVisible(true);
|
||||||
|
tableViewer = new TableViewer(table);
|
||||||
|
tableData = new GridData();
|
||||||
|
tableData.horizontalAlignment = GridData.FILL;
|
||||||
|
tableData.grabExcessHorizontalSpace = true;
|
||||||
|
tableData.widthHint = 350;
|
||||||
|
tableData.heightHint = 30;
|
||||||
|
tableData.verticalAlignment = GridData.CENTER;
|
||||||
|
tableData.grabExcessVerticalSpace = true;
|
||||||
|
tableData.horizontalSpan = nbrColumns;
|
||||||
|
table.setLayoutData(tableData);
|
||||||
|
return tableViewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Control getInitialFocusControl()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void createColumns()
|
||||||
|
{
|
||||||
|
TableLayout layout = new TableLayout();
|
||||||
|
table.setLayout(layout);
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
for (int i = 0; i < columnHeaders.length; i++)
|
||||||
|
{
|
||||||
|
layout.addColumnData(columnLayouts[i]);
|
||||||
|
TableColumn tc = new TableColumn(table, SWT.NONE,i);
|
||||||
|
tc.setResizable(columnLayouts[i].resizable);
|
||||||
|
tc.setText(columnHeaders[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] Created for SystemCopyDialog
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.ui.dialogs;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
/**
|
||||||
|
* This class is the table provider class for the SystemCopyDialog
|
||||||
|
*/
|
||||||
|
public class SystemCopyTableProvider implements ITableLabelProvider, IStructuredContentProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
static final int COLUMN_IMAGE = 0;
|
||||||
|
static final int COLUMN_NAME = 1;
|
||||||
|
protected Map imageTable = new Hashtable(20);
|
||||||
|
protected Object[] children = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for SystemCopyTableProvider
|
||||||
|
*/
|
||||||
|
public SystemCopyTableProvider()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SystemCopyTableRow getTableRow(Object element)
|
||||||
|
{
|
||||||
|
return (SystemCopyTableRow)element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image getImageFromDescriptor(ImageDescriptor descriptor)
|
||||||
|
{
|
||||||
|
if (descriptor == null)
|
||||||
|
return null;
|
||||||
|
//obtain the cached image corresponding to the descriptor
|
||||||
|
Image image = (Image) imageTable.get(descriptor);
|
||||||
|
if (image == null)
|
||||||
|
{
|
||||||
|
image = descriptor.createImage();
|
||||||
|
imageTable.put(descriptor, image);
|
||||||
|
}
|
||||||
|
//System.out.println("...image = " + image);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public Image getColumnImage(Object element, int column)
|
||||||
|
{
|
||||||
|
if (column == COLUMN_IMAGE)
|
||||||
|
return getImageFromDescriptor(getTableRow(element).getImageDescriptor());
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public String getColumnText(Object element, int column)
|
||||||
|
{
|
||||||
|
String text = ""; //$NON-NLS-1$
|
||||||
|
if (column == COLUMN_NAME)
|
||||||
|
text = getTableRow(element).getName();
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IBaseLabelProvider#addListener(ILabelProviderListener)
|
||||||
|
*/
|
||||||
|
public void addListener(ILabelProviderListener listener)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IBaseLabelProvider#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
// The following we got from WorkbenchLabelProvider
|
||||||
|
if (imageTable != null)
|
||||||
|
{
|
||||||
|
Collection imageValues = imageTable.values();
|
||||||
|
if (imageValues!=null)
|
||||||
|
{
|
||||||
|
Iterator images = imageValues.iterator();
|
||||||
|
if (images!=null)
|
||||||
|
while (images.hasNext())
|
||||||
|
((Image)images.next()).dispose();
|
||||||
|
imageTable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||||
|
*/
|
||||||
|
public boolean isLabelProperty(Object element, String property)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||||
|
*/
|
||||||
|
public void removeListener(ILabelProviderListener listener)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return rows. Input must be an IStructuredSelection.
|
||||||
|
*/
|
||||||
|
public Object[] getElements(Object inputElement)
|
||||||
|
{
|
||||||
|
if (children == null)
|
||||||
|
{
|
||||||
|
List list = (List)inputElement;
|
||||||
|
children = new SystemCopyTableRow[list.size()];
|
||||||
|
for(int i=0;i<list.size();i++)
|
||||||
|
{
|
||||||
|
children[i] = new SystemCopyTableRow(list.get(i), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the 0-based row number of the given element.
|
||||||
|
*/
|
||||||
|
public int getRowNumber(SystemCopyTableRow row)
|
||||||
|
{
|
||||||
|
return row.getRowNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation and others. All rights reserved.
|
||||||
|
* This program and the accompanying materials are made available under the terms
|
||||||
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Rupen Mardirossian (IBM) - [210682] created for SystemCopyDialog
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.rse.internal.ui.dialogs;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.rse.core.filters.ISystemFilterPoolReference;
|
||||||
|
import org.eclipse.rse.internal.ui.view.SystemViewResources;
|
||||||
|
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||||
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
|
import org.eclipse.rse.ui.dialogs.ISystemTypedObject;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||||
|
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents one row in the table in the SystemCopyDialog dialog.
|
||||||
|
*/
|
||||||
|
public class SystemCopyTableRow
|
||||||
|
{
|
||||||
|
|
||||||
|
private Object element;
|
||||||
|
private String name;
|
||||||
|
private String type;
|
||||||
|
private ImageDescriptor imageDescriptor;
|
||||||
|
private ISystemViewElementAdapter adapter;
|
||||||
|
private ISystemRemoteElementAdapter remoteAdapter;
|
||||||
|
private int rowNbr = 0;
|
||||||
|
|
||||||
|
public SystemCopyTableRow(Object element, int rowNbr)
|
||||||
|
{
|
||||||
|
if (element instanceof SystemSimpleContentElement)
|
||||||
|
element = ((SystemSimpleContentElement)element).getData();
|
||||||
|
this.element = element;
|
||||||
|
this.adapter = getViewAdapter(element);
|
||||||
|
this.remoteAdapter = getRemoteAdapter(element);
|
||||||
|
this.rowNbr = rowNbr;
|
||||||
|
//this.oldName = getAdapter(element).getText(element);
|
||||||
|
if (adapter != null)
|
||||||
|
this.name = adapter.getName(element);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (element instanceof ISystemTypedObject)
|
||||||
|
this.name = ((ISystemTypedObject)element).getName();
|
||||||
|
else if (element instanceof IResource)
|
||||||
|
this.name = ((IResource)element).getName();
|
||||||
|
}
|
||||||
|
ISystemViewElementAdapter typeAdapter = adapter;
|
||||||
|
Object typeElement = element;
|
||||||
|
if (typeElement instanceof ISystemFilterPoolReference)
|
||||||
|
{
|
||||||
|
typeElement = ((ISystemFilterPoolReference)typeElement).getReferencedFilterPool();
|
||||||
|
typeAdapter = getViewAdapter(typeElement);
|
||||||
|
}
|
||||||
|
if (typeAdapter != null)
|
||||||
|
this.type = typeAdapter.getType(typeElement);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (element instanceof ISystemTypedObject)
|
||||||
|
this.type = ((ISystemTypedObject)element).getType();
|
||||||
|
else if (element instanceof IResource)
|
||||||
|
{
|
||||||
|
if ((element instanceof IFolder) || (element instanceof IProject))
|
||||||
|
this.type = SystemViewResources.RESID_PROPERTY_FILE_TYPE_FOLDER_VALUE;
|
||||||
|
else
|
||||||
|
this.type = SystemViewResources.RESID_PROPERTY_FILE_TYPE_FILE_VALUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.type = element.getClass().getName();
|
||||||
|
}
|
||||||
|
if (adapter != null)
|
||||||
|
this.imageDescriptor = adapter.getImageDescriptor(element);
|
||||||
|
else if (element instanceof ISystemTypedObject)
|
||||||
|
this.imageDescriptor = ((ISystemTypedObject)element).getImageDescriptor();
|
||||||
|
else if (element instanceof IFolder)
|
||||||
|
this.imageDescriptor = //PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
|
||||||
|
RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FOLDER_ID);
|
||||||
|
else if (element instanceof IFile)
|
||||||
|
this.imageDescriptor = RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry().getImageDescriptor(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the item to be copy
|
||||||
|
* @return display name of the item.
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return the resource type of the item to be copy
|
||||||
|
* @return resource type of the item
|
||||||
|
*/
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return the 0-based row number of this item
|
||||||
|
* @return 0-based row number
|
||||||
|
*/
|
||||||
|
public int getRowNumber()
|
||||||
|
{
|
||||||
|
return rowNbr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an image descriptor for the image. More efficient than getting the image.
|
||||||
|
*/
|
||||||
|
public ImageDescriptor getImageDescriptor()
|
||||||
|
{
|
||||||
|
return imageDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the input object this row represents
|
||||||
|
*/
|
||||||
|
public Object getElement()
|
||||||
|
{
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the input object adapter for the input object this row represents
|
||||||
|
*/
|
||||||
|
public ISystemViewElementAdapter getViewAdapter()
|
||||||
|
{
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the input object remote adapter for the input object this row represents
|
||||||
|
*/
|
||||||
|
public ISystemRemoteElementAdapter getRemoteAdapter()
|
||||||
|
{
|
||||||
|
return remoteAdapter;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return true if this is a remote object
|
||||||
|
*/
|
||||||
|
public boolean isRemote()
|
||||||
|
{
|
||||||
|
return (remoteAdapter != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of ISystemViewElement for the given
|
||||||
|
* object. Returns null if the adapter is not defined or the
|
||||||
|
* object is not adaptable.
|
||||||
|
*/
|
||||||
|
protected ISystemViewElementAdapter getViewAdapter(Object o)
|
||||||
|
{
|
||||||
|
return SystemAdapterHelpers.getViewAdapter(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of ISystemRemoteElement for the given
|
||||||
|
* object. Returns null if this object does not adaptable to this.
|
||||||
|
*/
|
||||||
|
protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
|
||||||
|
{
|
||||||
|
return SystemAdapterHelpers.getRemoteAdapter(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue