diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
index fcb7a622703..1fa1bb1555d 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java
@@ -34,14 +34,15 @@
* 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.
* 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) - [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
* 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
* 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;
@@ -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.ui.RSEUIPlugin;
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.messages.SystemMessageDialog;
import org.eclipse.swt.widgets.Display;
@@ -116,6 +118,9 @@ import org.eclipse.ui.PlatformUI;
* Utility class for doing file transfers on universal systems.
*
* Clients may use this class, but not instantiate or subclass it.
+ *
+ * @noextend
+ * @noinstantiate
*/
public class UniversalFileTransferUtility
{
@@ -1316,8 +1321,10 @@ public class UniversalFileTransferUtility
// clear the list so that next time we use renamed names
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++)
{
if (monitor != null && monitor.isCanceled())
@@ -1347,8 +1354,15 @@ public class UniversalFileTransferUtility
String oldPath = newPathBuf.toString() + name;
if (checkForCollisions)
{
- RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
- int severity = status.getSeverity();
+ 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
+ /*int severity = status.getSeverity();
if (severity == IStatus.OK) {
name = status.getMessage();
@@ -1364,56 +1378,9 @@ public class UniversalFileTransferUtility
else if (code == RenameStatus.CANCEL_ALL) {
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)
@@ -1421,6 +1388,15 @@ public class UniversalFileTransferUtility
String oldPath = newPathBuf.toString() + name;
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);
int severity = status.getSeverity();
@@ -1439,83 +1415,146 @@ public class UniversalFileTransferUtility
break;
}
}
- }
+ */
- IContainer directory = (IContainer) srcFileOrFolder;
- if (!directory.exists())
+ }
+ 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;
+
+ if (srcFileOrFolder instanceof IFile)
{
try
{
- directory.refreshLocal(IResource.DEPTH_ONE, monitor);
+ 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;
+ }
+ }
+ if(srcFileOrFolder instanceof IContainer)
+ {
+ IContainer directory = (IContainer) srcFileOrFolder;
+ if (!directory.exists())
+ {
+ try
+ {
+ directory.refreshLocal(IResource.DEPTH_ONE, monitor);
+ }
+ catch (Exception e)
+ {
+
+ }
+ }
+ 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();
}
}
-
- String newPath = newPathBuf.toString() + name;
-
- // this is a directory
- // recursively copy
- 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
{
IRemoteFile[] results = targetFS.getRemoteFileObjects((String[])newFilePathList.toArray(new String[newFilePathList.size()]), monitor);
@@ -2468,7 +2507,19 @@ public class UniversalFileTransferUtility
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
{
private IRemoteFile _targetFileOrFolder;
diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCopyRemoteFileAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCopyRemoteFileAction.java
index 8746b1b6f78..7266b98460f 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCopyRemoteFileAction.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCopyRemoteFileAction.java
@@ -1,25 +1,26 @@
/********************************************************************************
- * 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
- * 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
+ * component that contains this file: David McKnight, Kushal Munir,
+ * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
- * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
+ * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Kevin Doyle (IBM) - [196588] Move Dialog doesn't show Archives
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* 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) - [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;
@@ -73,33 +74,33 @@ import org.eclipse.swt.widgets.Shell;
* Copy selected files and folders action.
*/
public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
- implements IValidatorRemoteSelection
+implements IValidatorRemoteSelection
{
- protected IRemoteFile targetFolder, targetFileOrFolder = null;
- protected IRemoteFile firstSelection = null;
- protected IRemoteFile firstSelectionParent = null;
- protected IRemoteFile[] files;
- protected Vector copiedFiles = new Vector();
- protected IHost sourceConnection;
- protected IRemoteFileSubSystem ss;
-
+ protected IRemoteFile targetFolder, targetFileOrFolder = null;
+ protected IRemoteFile firstSelection = null;
+ protected IRemoteFile firstSelectionParent = null;
+ protected IRemoteFile[] files;
+ protected Vector copiedFiles = new Vector();
+ protected IHost sourceConnection;
+ protected IRemoteFileSubSystem ss;
+
/**
* Constructor
*/
- public SystemCopyRemoteFileAction(Shell shell)
+ public SystemCopyRemoteFileAction(Shell shell)
{
this(shell, MODE_COPY);
}
/**
* Constructor for subclass
*/
- SystemCopyRemoteFileAction(Shell shell, int mode)
+ SystemCopyRemoteFileAction(Shell shell, int mode)
{
super(shell, mode);
- setHelp(RSEUIPlugin.HELPPREFIX+"actn0110"); //$NON-NLS-1$
- setDialogHelp(RSEUIPlugin.HELPPREFIX+"dcrf0000"); //$NON-NLS-1$
+ setHelp(RSEUIPlugin.HELPPREFIX+"actn0110"); //$NON-NLS-1$
+ setDialogHelp(RSEUIPlugin.HELPPREFIX+"dcrf0000"); //$NON-NLS-1$
}
-
+
/**
* Reset. This is a re-run of this action
*/
@@ -116,7 +117,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
sourceConnection = null;
ss = null;
}
-
+
/**
* We override from parent to do unique checking...
*
@@ -127,19 +128,19 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
public boolean updateSelection(IStructuredSelection selection)
{
boolean enable = true;
- Iterator e = selection.iterator();
+ Iterator e = selection.iterator();
while (enable && e.hasNext())
{
Object selectedObject = e.next();
if (!(selectedObject instanceof IRemoteFile))
- enable = false;
+ enable = false;
}
return enable;
}
-
- // --------------------------
- // PARENT METHOD OVERRIDES...
- // --------------------------
+
+ // --------------------------
+ // PARENT METHOD OVERRIDES...
+ // --------------------------
public static class RenameRunnable implements Runnable
{
private IRemoteFile _targetFileOrFolder;
@@ -148,24 +149,25 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
{
_targetFileOrFolder = targetFileOrFolder;
}
-
+
public void run() {
- ValidatorFileUniqueName validator = null;
+ ValidatorFileUniqueName validator = null;
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(null, true, _targetFileOrFolder, validator); // true => copy-collision-mode
-
+
dlg.open();
if (!dlg.wasCancelled())
_newName = dlg.getNewName();
else
_newName = null;
}
-
+
public String getNewName()
{
return _newName;
}
}
+
/**
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
* @param shell Window to host dialog
@@ -175,42 +177,72 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
* @param oldName will be the name of the IRemoteFile object currently being copied
*/
protected String checkForCollision(Shell shell, IProgressMonitor monitor,
- Object targetContainer, Object oldObject, String oldName)
+ Object targetContainer, Object oldObject, String oldName)
{
String newName = oldName;
-
+
try {
-
-
-
+
+
+
targetFolder = (IRemoteFile)targetContainer;
ss = targetFolder.getParentRemoteFileSubSystem();
targetFileOrFolder = ss.getRemoteFileObject(targetFolder, oldName, monitor);
-
-
+
+
//RSEUIPlugin.logInfo("CHECKING FOR COLLISION ON '"+srcFileOrFolder.getAbsolutePath() + "' IN '" +targetFolder.getAbsolutePath()+"'");
- //RSEUIPlugin.logInfo("...TARGET FILE: '"+tgtFileOrFolder.getAbsolutePath()+"'");
+ //RSEUIPlugin.logInfo("...TARGET FILE: '"+tgtFileOrFolder.getAbsolutePath()+"'");
//RSEUIPlugin.logInfo("...target.exists()? "+tgtFileOrFolder.exists());
if (targetFileOrFolder.exists())
{
- //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
- // object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
- ValidatorFileUniqueName validator = null; // new ValidatorFileUniqueName(shell, targetFolder, srcFileOrFolder.isDirectory());
- //SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
- RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
+ //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
+ // object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
+ // ValidatorFileUniqueName validator = null; // new
+ // ValidatorFileUniqueName(shell, targetFolder,
+ // srcFileOrFolder.isDirectory());
+ //SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
+ RenameRunnable rr = new RenameRunnable(targetFileOrFolder);
Display.getDefault().syncExec(rr);
newName = rr.getNewName();
}
} catch (SystemMessageException e) {
SystemBasePlugin.logError("SystemCopyRemoteFileAction.checkForCollision()", e); //$NON-NLS-1$
}
-
+
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 oldObject will be the IRemoteFile object currently being copied
@@ -219,102 +251,102 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
* @see SystemBaseCopyAction#doCopy(Object, Object, String, IProgressMonitor)
*/
protected boolean doCopy(Object targetContainer, Object oldObject, String newName, IProgressMonitor monitor)
- throws Exception
- {
- targetFolder = (IRemoteFile)targetContainer;
+ throws Exception
+ {
+ targetFolder = (IRemoteFile)targetContainer;
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
IHost targetConnection = targetFolder.getSystemConnection();
IHost srcConnection = srcFileOrFolder.getSystemConnection();
-
+
boolean ok = false;
- if (targetConnection == srcConnection)
- {
+ if (targetConnection == srcConnection)
+ {
ss = targetFolder.getParentRemoteFileSubSystem();
-
-
+
+
ok = ss.copy(srcFileOrFolder, targetFolder, newName, null);
if (!ok)
{
String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getName());
String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
- SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
- ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
- IStatus.ERROR, msgTxt, msgDetails);
- throw new SystemMessageException(msg);
+ SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
+ ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
+ IStatus.ERROR, msgTxt, msgDetails);
+ throw new SystemMessageException(msg);
}
else
{
- String sep = targetFolder.getSeparator();
- String targetFolderName = targetFolder.getAbsolutePath();
- if (!targetFolderName.endsWith(sep))
- copiedFiles.addElement(targetFolderName+sep+newName);
- else
- copiedFiles.addElement(targetFolderName+newName);
+ String sep = targetFolder.getSeparator();
+ String targetFolderName = targetFolder.getAbsolutePath();
+ if (!targetFolderName.endsWith(sep))
+ copiedFiles.addElement(targetFolderName+sep+newName);
+ else
+ copiedFiles.addElement(targetFolderName+newName);
}
- }
- // DKM - for cross system copy
- else
- {
- IRemoteFileSubSystem targetFS = targetFolder.getParentRemoteFileSubSystem();
- IRemoteFileSubSystem srcFS = srcFileOrFolder.getParentRemoteFileSubSystem();
- String newPath = targetFolder.getAbsolutePath() + "/" + newName; //$NON-NLS-1$
- if (srcFileOrFolder.isFile())
- {
- SystemRemoteEditManager mgr = SystemRemoteEditManager.getInstance();
- // if remote edit project doesn't exist, create it
- if (!mgr.doesRemoteEditProjectExist())
- mgr.getRemoteEditProject();
-
- StringBuffer path = new StringBuffer(mgr.getRemoteEditProjectLocation().makeAbsolute().toOSString());
+ }
+ // DKM - for cross system copy
+ else
+ {
+ IRemoteFileSubSystem targetFS = targetFolder.getParentRemoteFileSubSystem();
+ IRemoteFileSubSystem srcFS = srcFileOrFolder.getParentRemoteFileSubSystem();
+ String newPath = targetFolder.getAbsolutePath() + "/" + newName; //$NON-NLS-1$
+ if (srcFileOrFolder.isFile())
+ {
+ SystemRemoteEditManager mgr = SystemRemoteEditManager.getInstance();
+ // if remote edit project doesn't exist, create it
+ if (!mgr.doesRemoteEditProjectExist())
+ mgr.getRemoteEditProject();
+
+ StringBuffer path = new StringBuffer(mgr.getRemoteEditProjectLocation().makeAbsolute().toOSString());
path = path.append("/" + srcFS.getSystemProfileName() + "/" + srcFS.getHostAliasName() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String absolutePath = srcFileOrFolder.getAbsolutePath();
-
-
+
+
int colonIndex = absolutePath.indexOf(IPath.DEVICE_SEPARATOR);
-
- if (colonIndex != -1)
- {
- if (colonIndex == 0)
+
+ if (colonIndex != -1)
+ {
+ if (colonIndex == 0)
{
absolutePath = absolutePath.substring(1);
}
- else if (colonIndex == (absolutePath.length() - 1))
+ else if (colonIndex == (absolutePath.length() - 1))
{
absolutePath = absolutePath.substring(0, colonIndex);
}
- else
+ else
{
absolutePath = absolutePath.substring(0, colonIndex) + absolutePath.substring(colonIndex + 1);
}
}
-
+
path = path.append(absolutePath);
-
+
String tempFile = path.toString();
- 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$
- }
- else
- {
-
- IRemoteFile newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
- targetFS.createFolder(newTargetFolder, monitor);
- IRemoteFile[] children = srcFS.list(srcFileOrFolder, monitor);
- if (children != null)
- {
- for (int i = 0; i < children.length; i++)
- {
- IRemoteFile child = children[i];
- monitor.subTask("copying " + child.getName()); //$NON-NLS-1$
- doCopy(newTargetFolder, child, child.getName(), monitor);
- monitor.worked(1);
- }
- }
- }
- }
+ 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$
+ }
+ else
+ {
+
+ IRemoteFile newTargetFolder = targetFS.getRemoteFileObject(newPath, monitor);
+ targetFS.createFolder(newTargetFolder, monitor);
+ IRemoteFile[] children = srcFS.list(srcFileOrFolder, monitor);
+ if (children != null)
+ {
+ for (int i = 0; i < children.length; i++)
+ {
+ IRemoteFile child = children[i];
+ monitor.subTask("copying " + child.getName()); //$NON-NLS-1$
+ doCopy(newTargetFolder, child, child.getName(), monitor);
+ monitor.worked(1);
+ }
+ }
+ }
+ }
return ok;
}
@@ -324,7 +356,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
* Required parent class abstract method.
* Does not apply to us as we supply our own dialog for the copy-target
*/
- protected SystemSimpleContentElement getTreeModel()
+ protected SystemSimpleContentElement getTreeModel()
{
return null;
}
@@ -341,7 +373,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
* @see SystemBaseCopyAction#getOldObjects()
* Returns an array of IRemoteFile objects
*/
- protected Object[] getOldObjects()
+ protected Object[] getOldObjects()
{
return getSelectedFiles();
}
@@ -349,16 +381,16 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
/**
* @see SystemBaseCopyAction#getOldNames()
*/
- protected String[] getOldNames()
+ protected String[] getOldNames()
{
IRemoteFile[] files = getSelectedFiles();
String[] names = new String[files.length];
for (int idx=0; idx 1)
- reset();
- //return new SystemSimpleCopyDialog(parent, getPromptString(), mode, this, getTreeModel(), getTreeInitialSelection());
- String dlgTitle = (mode==MODE_COPY ? SystemResources.RESID_COPY_TITLE : SystemResources.RESID_MOVE_TITLE);
-
+ if (runCount > 1)
+ reset();
+ //return new SystemSimpleCopyDialog(parent, getPromptString(), mode, this, getTreeModel(), getTreeInitialSelection());
+ String dlgTitle = (mode==MODE_COPY ? SystemResources.RESID_COPY_TITLE : SystemResources.RESID_MOVE_TITLE);
+
firstSelection = getFirstSelectedFile();
sourceConnection = firstSelection.getSystemConnection();
SystemRemoteFolderDialog dlg = new SystemRemoteFolderDialog(shell, dlgTitle, sourceConnection);
@@ -378,10 +410,10 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
dlg.setMessage(getPromptString());
dlg.setShowPropertySheet(true, false);
dlg.setDefaultSystemConnection(sourceConnection, true);
-
+
//dlg.setSystemConnection(sourceConnection);
if (mode==MODE_MOVE)
- dlg.setSelectionValidator(this);
+ dlg.setSelectionValidator(this);
//RSEUIPlugin.logInfo("Calling getParentRemoteFile for '"+firstSelection.getAbsolutePath()+"'");
firstSelectionParent = firstSelection.getParentRemoteFile();
boolean supportsArchiveManagement = firstSelectionParent.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
@@ -399,14 +431,14 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
RSEUIPlugin.logInfo("Result of getParentRemoteFile: '"+firstSelectionParent.getAbsolutePath()+"'");
else
RSEUIPlugin.logInfo("Result of getParentRemoteFile: null");
- */
+ */
dlg.setPreSelection(firstSelectionParent);
-
+
// our title now reflects multiple selection. If single change it.
IStructuredSelection sel = getSelection();
//System.out.println("size = "+sel.size());
if (sel.size() == 1)
- {
+ {
String singleTitle = null;
if (mode == MODE_COPY)
singleTitle = SystemResources.RESID_COPY_SINGLE_TITLE;
@@ -415,36 +447,36 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
//System.out.println("..."+singleTitle);
if (!singleTitle.startsWith("Missing")) // TODO: remove test after next mri rev //$NON-NLS-1$
dlg.setTitle(singleTitle);
- }
+ }
return dlg;
}
-
+
/**
- * Override this method if you supply your own copy/move target dialog.
+ * Override this method if you supply your own copy/move target dialog.
* Return the user-selected target or null if cancelled
*/
protected Object getTargetContainer(Dialog dlg)
{
- SystemRemoteFolderDialog cpyDlg = (SystemRemoteFolderDialog)dlg;
+ SystemRemoteFolderDialog cpyDlg = (SystemRemoteFolderDialog)dlg;
Object targetContainer = null;
if (!cpyDlg.wasCancelled())
{
- targetContainer = cpyDlg.getSelectedObject();
- if (targetContainer instanceof ISystemFilterReference)
- {
- ISubSystem targetSubSystem = ((ISystemFilterReference)targetContainer).getSubSystem();
- ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
- if (factory.supportsDropInFilters())
- {
- targetContainer = targetSubSystem.getTargetForFilter((ISystemFilterReference)targetContainer);
- }
- }
+ targetContainer = cpyDlg.getSelectedObject();
+ if (targetContainer instanceof ISystemFilterReference)
+ {
+ ISubSystem targetSubSystem = ((ISystemFilterReference)targetContainer).getSubSystem();
+ ISubSystemConfiguration factory = targetSubSystem.getSubSystemConfiguration();
+ if (factory.supportsDropInFilters())
+ {
+ targetContainer = targetSubSystem.getTargetForFilter((ISystemFilterReference)targetContainer);
+ }
+ }
}
- return targetContainer;
+ return targetContainer;
}
-
+
private void invalidateFilterReferences(IRemoteFile targetFolder)
- {
+ {
String path = targetFolder.getAbsolutePath();
IRemoteFileSubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
ISystemFilterPoolReferenceManager mgr = fileSS.getSystemFilterPoolReferenceManager();
@@ -471,20 +503,20 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
par = fileSS.getRemoteFileObject(str, monitor);
}
catch (Exception e)
- {
+ {
}
-
+
if (par != null)
str = par.getAbsolutePath();
//if (StringCompare.compare(str, path, true))
- if (str.equals(path))
+ if (str.equals(path))
{
ISystemFilterReference ref = mgr.getSystemFilterReference(fileSS, filters[f]);
ref.markStale(true);
}
}
- }
+ }
}
}
@@ -492,40 +524,40 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
* Called after all the copy/move operations end, be it successfully or not.
* Your opportunity to display completion or do post-copy selections/refreshes
*/
- public void copyComplete()
+ public void copyComplete()
{
if (copiedFiles.size() == 0)
- return;
+ return;
// refresh all instances of this parent, and all affected filters...
ISubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
Viewer originatingViewer = getViewer();
if (originatingViewer != null)
- {
- 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
- // after it is refreshed via the remote_resource_created event.
- if (originatingViewer instanceof SystemView)
- {
- // boolean selectedOk = ((SystemView)originatingViewer).selectRemoteObjects(targetFolder.getAbsolutePath(), fileSS, null);
- //System.out.println(targetFolder.getAbsolutePath()+" selectedOK? " + selectedOk);
- //if (selectedOk)
- // return;
- }
- }
+ {
+ 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
+ // after it is refreshed via the remote_resource_created event.
+ if (originatingViewer instanceof SystemView)
+ {
+ // boolean selectedOk = ((SystemView)originatingViewer).selectRemoteObjects(targetFolder.getAbsolutePath(), fileSS, null);
+ //System.out.println(targetFolder.getAbsolutePath()+" selectedOK? " + selectedOk);
+ //if (selectedOk)
+ // return;
+ }
+ }
}
-
-
- targetFolder.markStale(true);
+
+
+ targetFolder.markStale(true);
// invalidate filters
invalidateFilterReferences(targetFolder);
-
-
+
+
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...
// did they copy to the same parent? Just refresh that parent, whatever it is...
if (targetFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
@@ -561,49 +593,49 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
else
{
// refresh target folder in all views, but only select new files in this view...
- org.eclipse.rse.ui.model.SystemResourceChangeEvent event =
+ org.eclipse.rse.ui.model.SystemResourceChangeEvent event =
new org.eclipse.rse.ui.model.SystemResourceChangeEvent(
targetFolder,ISystemResourceChangeEvent.EVENT_REFRESH_REMOTE, copiedFiles);
event.setOriginatingViewer(getViewer());
sr.fireEvent(event);
}
- */
+ */
+ }
+
+ // ------------------
+ // PRIVATE METHODS...
+ // ------------------
+
+ /**
+ * Get the currently selected IRemoteFile objects
+ */
+ protected IRemoteFile[] getSelectedFiles()
+ {
+ if (files == null)
+ {
+ IStructuredSelection selection = getSelection();
+ files = new IRemoteFile[selection.size()];
+ Iterator i = selection.iterator();
+ int idx=0;
+ while (i.hasNext())
+ {
+ files[idx++] = (IRemoteFile)i.next();
+ }
+ }
+ return files;
+ }
+ /**
+ * Get the first selected file or folder
+ */
+ protected IRemoteFile getFirstSelectedFile()
+ {
+ if (files == null)
+ getSelectedFiles();
+ if (files.length > 0)
+ return files[0];
+ else
+ return null;
}
-
- // ------------------
- // PRIVATE METHODS...
- // ------------------
-
- /**
- * Get the currently selected IRemoteFile objects
- */
- protected IRemoteFile[] getSelectedFiles()
- {
- if (files == null)
- {
- IStructuredSelection selection = getSelection();
- files = new IRemoteFile[selection.size()];
- Iterator i = selection.iterator();
- int idx=0;
- while (i.hasNext())
- {
- files[idx++] = (IRemoteFile)i.next();
- }
- }
- return files;
- }
- /**
- * Get the first selected file or folder
- */
- protected IRemoteFile getFirstSelectedFile()
- {
- if (files == null)
- getSelectedFiles();
- if (files.length > 0)
- return files[0];
- else
- return null;
- }
/**
* The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage
@@ -614,5 +646,5 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
{
return null;
- }
+ }
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java
index 7bc7311ee67..5dcec2074ec 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemMoveRemoteFileAction.java
@@ -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
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* 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
* 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
+ * Rupen Mardirossian (IBM) - [210682] Modified MoveRemoteFileJob.runInWorkspace to use SystemCopyDialog for collisions in move operations
********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
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.validators.IValidatorRemoteSelection;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.rse.internal.ui.dialogs.CopyRunnable;
/**
* Move selected files and folders action.
@@ -84,65 +89,103 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
IStatus status = Status.OK_STATUS;
- try
- {
- 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];
- for (int idx=0; copiedOk && (idx0)
{
- copiedOk = false;
- //If this operation is canceled, need to display a proper message to the user.
- if (monitor.isCanceled() && movedFileNames.size() > 0)
+ CopyRunnable cr = new CopyRunnable(existing);
+ Display.getDefault().syncExec(cr);
+ overwrite = cr.getOk();
+ if(!overwrite)
{
- //Get the moved file names
- String movedFileNamesList = (String)(movedFileNames.get(0));
- for (int i=1; i<(movedFileNames.size()); i++)
+ 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 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,
ISystemFileConstants.FILEMSG_MOVE_INTERRUPTED,
IStatus.ERROR, msgTxt, msgDetails);
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)
{
copyComplete(); //Need to reflect the views.
@@ -150,8 +193,7 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
return status;
}
- }
-
+ }
/**
* Constructor
*/
diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java
index dbb0f90961d..497b5d402ac 100644
--- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java
+++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java
@@ -48,6 +48,7 @@
* 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
* 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;
@@ -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.subsystems.files.core.ISystemFilePreferencesConstants;
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.SystemDNDTransferRunnable;
import org.eclipse.rse.internal.ui.view.SystemViewResources;
@@ -1970,7 +1972,6 @@ public class SystemViewRemoteFileAdapter
ISystemFileConstants.FILEMSG_SECURITY_ERROR,
IStatus.ERROR, msgTxt, msgDetails);
resultSet.setMessage(errorMsg);
-
return resultSet;
}
@@ -2021,7 +2022,7 @@ public class SystemViewRemoteFileAdapter
}
}
}
-
+ //getMessage("RSEG1125").makeSubstitution(movedFileName));
if (copiedFileNames != null)
{
String msgTxt = FileResources.FILEMSG_COPY_INTERRUPTED;
@@ -2031,6 +2032,7 @@ public class SystemViewRemoteFileAdapter
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
IStatus.ERROR, msgTxt, msgDetails);
resultSet.setMessage(thisMessage);
+ //SystemMessageDialog.displayErrorMessage(shell, thisMessage);
}
}
}
@@ -2096,10 +2098,12 @@ public class SystemViewRemoteFileAdapter
}
else if (first instanceof IRemoteFile)
{
- List toCopy = new ArrayList();
- List toCopyNames = new ArrayList();
+ //List toCopy = new ArrayList();
+ //List toCopyNames = new ArrayList();
List toCopyBatch = new ArrayList();
-
+ List existing = new ArrayList();
+ boolean overwrite=false;
+
for (int i = 0; i < set.size(); i++)
{
IRemoteFile srcFileOrFolder = (IRemoteFile)set.get(i);
@@ -2133,27 +2137,30 @@ public class SystemViewRemoteFileAdapter
{
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
IRemoteFile existingFileOrFolder = ((IRemoteFileSubSystem)srcSubSystem).getRemoteFileObject(targetFolder, name, monitor);
if (existingFileOrFolder.exists())
{
- RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
+ /*RenameRunnable rr = new RenameRunnable(existingFileOrFolder, toCopyNames);
Display.getDefault().syncExec(rr);
name = rr.getNewName();
-
- if (name != null)
- {
- toCopy.add(srcFileOrFolder);
- toCopyNames.add(name);
- }
+ */
+ existing.add(existingFileOrFolder);
}
- else if (name != null)
+
+ if (name != null)
{
+ //toCopy.add(srcFileOrFolder);
+ //toCopyNames.add(name);
toCopyBatch.add(srcFileOrFolder);
}
+ /*else if (name != null)
+ {
+ toCopyBatch.add(srcFileOrFolder);
+ }*/
}
}
catch (Exception e)
@@ -2167,161 +2174,175 @@ public class SystemViewRemoteFileAdapter
}
}
- for (int x = 0; x < toCopy.size(); x++)
- {
-
- IRemoteFile srcFileOrFolder = (IRemoteFile)toCopy.get(x);
- String name = (String)toCopyNames.get(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);
+
+
SystemMessage copyMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COPY_PROGRESS);
copyMessage.makeSubstitution(srcFileOrFolder.getName(), targetFolder.getName());
if (monitor != null)
{
monitor.beginTask(copyMessage.getLevelOneText(), 100);
}
- */
- try
- {
- if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor))
+
+ try
{
- IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
- resultSet.addResource(copiedFile);
- }
- else
- {
- // need a failed message here
- String msgTxt = NLS.bind(FileResources.FILEMSG_COPY_FILE_FAILED, srcFileOrFolder.getAbsolutePath());
- String msgDetails = FileResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
+ if (targetFS.copy(srcFileOrFolder, targetFolder, name, monitor))
+ {
+ IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, name, monitor);
+ resultSet.addResource(copiedFile);
+ }
+ else
+ {
+ // 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,
ISystemFileConstants.FILEMSG_COPY_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
resultSet.setMessage(msg);
+ }
}
- }
- catch (SystemMessageException e)
- {
- if (monitor.isCanceled() && resultSet.size() > 0)
+ catch (SystemMessageException e)
{
- //Get the moved file names
- Object thisObject = resultSet.get(0);
- String copiedFileNames = null;
- if (thisObject instanceof IRemoteFile)
+ if (monitor.isCanceled() && resultSet.size() > 0)
{
- copiedFileNames = ((IRemoteFile)thisObject).getName();
- for (int i=1; i<(resultSet.size()); i++)
+ //Get the moved file names
+ Object thisObject = resultSet.get(0);
+ String copiedFileNames = null;
+ if (thisObject instanceof IRemoteFile)
{
- if (thisObject instanceof IRemoteFile)
+ copiedFileNames = ((IRemoteFile)thisObject).getName();
+ for (int i=1; i<(resultSet.size()); i++)
{
- copiedFileNames = copiedFileNames + "\n" + ((IRemoteFile)thisObject).getName(); //$NON-NLS-1$
+ 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);
+ //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
{
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);
}
- }
-
- // 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 (toCopyBatch.size() > 0)
{
- if (targetFS.copyBatch(srcFileOrFolders, targetFolder, monitor))
+ try
{
- for (int x = 0; x < toCopyBatch.size(); x++)
+ if (targetFS.copyBatch(srcFileOrFolders, targetFolder, monitor))
{
- IRemoteFile copiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[x].getName(), monitor);
- resultSet.addResource(copiedFile);
+ 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)
+ catch (SystemMessageException e)
{
- //ISystemViewElementAdapter adapter = fromSet.getViewAdapter();
- for (int i = 0; i < srcFileOrFolders.length; i++)
+ if (monitor.isCanceled() && srcFileOrFolders.length > 1)
{
- IRemoteFile thisCopiedFile = null;
- try
+ //ISystemViewElementAdapter adapter = fromSet.getViewAdapter();
+ for (int i = 0; i < srcFileOrFolders.length; i++)
{
- thisCopiedFile = targetFS.getRemoteFileObject(targetFolder, srcFileOrFolders[i].getName(), null);
+ 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);
+ }
}
- catch (SystemMessageException thsiException)
+ if (resultSet.size() > 0)
{
- 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);
+ //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);
-
+ 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);
}
}
- else
+ catch (Exception e)
{
- SystemMessageDialog.displayMessage(e);
+ e.printStackTrace();
}
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
}
}
}
@@ -2329,7 +2350,6 @@ public class SystemViewRemoteFileAdapter
}
return resultSet;
}
-
/**
* 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
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java
index 9d559744c15..2eebb4bc682 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java
@@ -17,6 +17,7 @@
* 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) - [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;
@@ -43,6 +44,9 @@ public class SystemResources extends NLS
public static String BUTTON_CREATE_TOOLTIP;
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
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_VERBIAGE;
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;
// -------------------------
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties
index 24eb0f67967..bd337d94407 100644
--- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties
@@ -18,6 +18,7 @@
# 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 McKnight (IBM) - [223103] [cleanup] fix broken externalized strings
+# Rupen Mardirossian (IBM) - [210692] Define strings for SystemCopyDialog
################################################################################
# NLS_MESSAGEFORMAT_VAR
@@ -33,6 +34,9 @@ BUTTON_ADD=Add
BUTTON_CREATE_LABEL=Create
BUTTON_CREATE_TOOLTIP=Press to create the new resource
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_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_VERBIAGE=A resource named "&1" already exists.
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
#=============================================================
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/CopyRunnable.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/CopyRunnable.java
new file mode 100644
index 00000000000..bac7df7dae2
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/CopyRunnable.java
@@ -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;
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyDialog.java
new file mode 100644
index 00000000000..7dc13c0bf6c
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyDialog.java
@@ -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]);
+ }
+ }
+}
diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyTableProvider.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyTableProvider.java
new file mode 100644
index 00000000000..0fb79f0f06c
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/dialogs/SystemCopyTableProvider.java
@@ -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