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
|
||||
* 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,7 +1321,9 @@ 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++)
|
||||
{
|
||||
|
@ -1347,6 +1354,49 @@ 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
|
||||
/*int severity = status.getSeverity();
|
||||
|
||||
if (severity == IStatus.OK) {
|
||||
name = status.getMessage();
|
||||
toCopyNames.add(name);
|
||||
}
|
||||
else if (severity == IStatus.CANCEL) {
|
||||
|
||||
int code = status.getCode();
|
||||
|
||||
if (code == IStatus.CANCEL) {
|
||||
continue;
|
||||
}
|
||||
else if (code == RenameStatus.CANCEL_ALL) {
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
copyFilesOrFolders.add(srcFileOrFolder);
|
||||
}
|
||||
|
||||
else if (srcFileOrFolder instanceof IContainer)
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -1365,16 +1415,34 @@ public class UniversalFileTransferUtility
|
|||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
String srcCharSet = null;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
srcCharSet = ((IFile)srcFileOrFolder).getCharset(false);
|
||||
|
@ -1415,32 +1483,8 @@ public class UniversalFileTransferUtility
|
|||
return resultSet;
|
||||
}
|
||||
}
|
||||
|
||||
else if (srcFileOrFolder instanceof IContainer)
|
||||
if(srcFileOrFolder instanceof IContainer)
|
||||
{
|
||||
String oldPath = newPathBuf.toString() + name;
|
||||
if (checkForCollisions)
|
||||
{
|
||||
RenameStatus status = checkForCollision(existingFiles, targetFolder, name, oldPath, toCopyNames);
|
||||
int severity = status.getSeverity();
|
||||
|
||||
if (severity == IStatus.OK) {
|
||||
name = status.getMessage();
|
||||
toCopyNames.add(name);
|
||||
}
|
||||
else if (severity == IStatus.CANCEL) {
|
||||
|
||||
int code = status.getCode();
|
||||
|
||||
if (code == IStatus.CANCEL) {
|
||||
continue;
|
||||
}
|
||||
else if (code == RenameStatus.CANCEL_ALL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IContainer directory = (IContainer) srcFileOrFolder;
|
||||
if (!directory.exists())
|
||||
{
|
||||
|
@ -1453,11 +1497,6 @@ public class UniversalFileTransferUtility
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
String newPath = newPathBuf.toString() + name;
|
||||
|
||||
// this is a directory
|
||||
// recursively copy
|
||||
try
|
||||
{
|
||||
if (existingFiles != null)
|
||||
|
@ -1514,7 +1553,7 @@ public class UniversalFileTransferUtility
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -2469,6 +2508,18 @@ 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;
|
||||
|
|
|
@ -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
|
||||
|
@ -20,6 +20,7 @@
|
|||
* 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,7 +74,7 @@ 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;
|
||||
|
@ -166,6 +167,7 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
|
||||
* @param shell Window to host dialog
|
||||
|
@ -197,7 +199,9 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
|||
|
||||
// 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());
|
||||
// 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);
|
||||
|
@ -209,7 +213,35 @@ public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
|||
|
||||
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
|
||||
|
|
|
@ -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,8 +89,13 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
|||
|
||||
IStatus status = Status.OK_STATUS;
|
||||
|
||||
try
|
||||
{
|
||||
//holds existing objects
|
||||
List existing = new ArrayList();
|
||||
//holds objects to be copied
|
||||
List toCopy = new ArrayList();
|
||||
boolean overwrite = false;
|
||||
|
||||
|
||||
int steps = oldObjects.length;
|
||||
monitor.beginTask(msg.getLevelOneText(), steps);
|
||||
copiedOk = true;
|
||||
|
@ -93,22 +103,56 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
|||
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());
|
||||
newName = checkForCollision(getShell(), monitor, targetContainer, oldObject, oldName);
|
||||
//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.
|
||||
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;
|
||||
|
@ -121,7 +165,6 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
|||
{
|
||||
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);
|
||||
|
||||
|
@ -142,7 +185,7 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
|||
copiedOk = false;
|
||||
exc.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
if (movedFiles.size() > 0)
|
||||
{
|
||||
copyComplete(); //Need to reflect the views.
|
||||
|
@ -151,7 +194,6 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
|||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
|
|
@ -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,9 +2098,11 @@ 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++)
|
||||
{
|
||||
|
@ -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();
|
||||
*/
|
||||
existing.add(existingFileOrFolder);
|
||||
}
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
toCopy.add(srcFileOrFolder);
|
||||
toCopyNames.add(name);
|
||||
}
|
||||
}
|
||||
else if (name != null)
|
||||
{
|
||||
//toCopy.add(srcFileOrFolder);
|
||||
//toCopyNames.add(name);
|
||||
toCopyBatch.add(srcFileOrFolder);
|
||||
}
|
||||
/*else if (name != null)
|
||||
{
|
||||
toCopyBatch.add(srcFileOrFolder);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -2167,20 +2174,31 @@ public class SystemViewRemoteFileAdapter
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
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))
|
||||
|
@ -2194,6 +2212,8 @@ public class SystemViewRemoteFileAdapter
|
|||
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);
|
||||
|
@ -2244,8 +2264,10 @@ public class SystemViewRemoteFileAdapter
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
// deal with batch copies now
|
||||
if(existing.size()==0 || overwrite)
|
||||
{
|
||||
IRemoteFile[] srcFileOrFolders = new IRemoteFile[toCopyBatch.size()];
|
||||
for (int x = 0; x < toCopyBatch.size(); x++)
|
||||
{
|
||||
|
@ -2298,7 +2320,6 @@ public class SystemViewRemoteFileAdapter
|
|||
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);
|
||||
|
||||
|
@ -2306,7 +2327,6 @@ public class SystemViewRemoteFileAdapter
|
|||
ISystemFileConstants.FILEMSG_COPY_INTERRUPTED,
|
||||
IStatus.ERROR, msgTxt, msgDetails);
|
||||
SystemMessageDialog.displayErrorMessage(shell, thisMessage);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2327,9 +2347,9 @@ 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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
// -------------------------
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
#=============================================================
|
||||
|
|
|
@ -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