1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-29 11:13:34 +02:00

[230821] [api][breaking] IRemoteFileSubsystem is inconsistent with IFileService

https://bugs.eclipse.org/bugs/show_bug.cgi?id=230821
This commit is contained in:
David Dykstal 2008-05-23 19:40:33 +00:00
parent ee511dba34
commit 788cece9b2
3 changed files with 27 additions and 89 deletions

View file

@ -32,12 +32,10 @@ import java.util.Vector;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents; import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilter;
@ -48,13 +46,9 @@ import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog; import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog;
import org.eclipse.rse.internal.files.ui.Activator;
import org.eclipse.rse.internal.files.ui.FileResources;
import org.eclipse.rse.internal.files.ui.ISystemFileConstants;
import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager; import org.eclipse.rse.internal.files.ui.resources.SystemRemoteEditManager;
import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.services.clientserver.SystemEncodingUtil; import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
@ -265,23 +259,8 @@ implements IValidatorRemoteSelection
if (targetConnection == srcConnection) if (targetConnection == srcConnection)
{ {
ss = targetFolder.getParentRemoteFileSubSystem(); ss = targetFolder.getParentRemoteFileSubSystem();
try {
ss.copy(srcFileOrFolder, targetFolder, newName, null); ss.copy(srcFileOrFolder, targetFolder, newName, null);
ok = true; ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during copy", e); //$NON-NLS-1$
}
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);
}
else
{
String sep = targetFolder.getSeparator(); String sep = targetFolder.getSeparator();
String targetFolderName = targetFolder.getAbsolutePath(); String targetFolderName = targetFolder.getAbsolutePath();
if (!targetFolderName.endsWith(sep)) if (!targetFolderName.endsWith(sep))
@ -289,7 +268,6 @@ implements IValidatorRemoteSelection
else else
copiedFiles.addElement(targetFolderName+newName); copiedFiles.addElement(targetFolderName+newName);
} }
}
// DKM - for cross system copy // DKM - for cross system copy
else else
{ {

View file

@ -46,20 +46,19 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.files.ui.Activator; import org.eclipse.rse.internal.files.ui.Activator;
import org.eclipse.rse.internal.files.ui.FileResources; import org.eclipse.rse.internal.files.ui.FileResources;
import org.eclipse.rse.internal.files.ui.ISystemFileConstants; import org.eclipse.rse.internal.files.ui.ISystemFileConstants;
import org.eclipse.rse.internal.ui.dialogs.CopyRunnable;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.actions.SystemBaseCopyAction; import org.eclipse.rse.ui.actions.SystemBaseCopyAction;
import org.eclipse.rse.ui.messages.SystemMessageDialog; import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection; import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.rse.internal.ui.dialogs.CopyRunnable;
/** /**
* Move selected files and folders action. * Move selected files and folders action.
@ -239,32 +238,13 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
* @param monitor Usually not needed * @param monitor Usually not needed
* @see SystemBaseCopyAction#doCopy(Object, Object, String, IProgressMonitor) * @see SystemBaseCopyAction#doCopy(Object, Object, String, IProgressMonitor)
*/ */
protected boolean doCopy(Object targetContainer, Object oldObject, String newName, IProgressMonitor monitor) protected boolean doCopy(Object targetContainer, Object oldObject, String newName, IProgressMonitor monitor) throws Exception {
throws Exception
{
IRemoteFile targetFolder = (IRemoteFile) targetContainer; IRemoteFile targetFolder = (IRemoteFile) targetContainer;
IRemoteFile srcFileOrFolder = (IRemoteFile) oldObject; IRemoteFile srcFileOrFolder = (IRemoteFile) oldObject;
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem(); IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
boolean ok = false;
try {
ss.move(srcFileOrFolder, targetFolder, newName, monitor); ss.move(srcFileOrFolder, targetFolder, newName, monitor);
ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during a move operation", e); //$NON-NLS-1$
}
if (!ok)
{
String msgTxt = NLS.bind(FileResources.FILEMSG_MOVE_FILE_FAILED, srcFileOrFolder.getName());
String msgDetails = FileResources.FILEMSG_MOVE_FILE_FAILED_DETAILS;
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ISystemFileConstants.FILEMSG_MOVE_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
throw new SystemMessageException(msg);
}
else
{
String sep = targetFolder.getSeparator(); String sep = targetFolder.getSeparator();
String targetFolderName = targetFolder.getAbsolutePath(); String targetFolderName = targetFolder.getAbsolutePath();
String resultPath = null; String resultPath = null;
@ -276,9 +256,7 @@ public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
copiedFiles.addElement(resultPath); copiedFiles.addElement(resultPath);
movedFiles.add(srcFileOrFolder); movedFiles.add(srcFileOrFolder);
} return true;
return ok;
} }
/** /**

View file

@ -2806,7 +2806,6 @@ public class SystemViewRemoteFileAdapter
*/ */
public boolean doDeleteBatch(Shell shell, List resourceSet, IProgressMonitor monitor) throws Exception public boolean doDeleteBatch(Shell shell, List resourceSet, IProgressMonitor monitor) throws Exception
{ {
boolean ok;
IRemoteFileSubSystem ss = null; IRemoteFileSubSystem ss = null;
IRemoteFile[] files = new IRemoteFile[resourceSet.size()]; IRemoteFile[] files = new IRemoteFile[resourceSet.size()];
for (int i = 0; i < resourceSet.size(); i++) for (int i = 0; i < resourceSet.size(); i++)
@ -2834,7 +2833,6 @@ public class SystemViewRemoteFileAdapter
} }
catch (Exception exc) catch (Exception exc)
{ {
ok = false;
String msgTxt = NLS.bind(FileResources.FILEMSG_DELETE_FILE_FAILED, file.toString()); String msgTxt = NLS.bind(FileResources.FILEMSG_DELETE_FILE_FAILED, file.toString());
String msgDetails = FileResources.FILEMSG_DELETE_FILE_FAILED_DETAILS; String msgDetails = FileResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;
@ -2846,19 +2844,9 @@ public class SystemViewRemoteFileAdapter
} }
if (ss != null) if (ss != null)
{ {
try {
ss.deleteBatch(files, monitor); ss.deleteBatch(files, monitor);
ok = true;
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during batch delete", e); //$NON-NLS-1$
ok = false;
}
return ok;
}
else
{
return false;
} }
return true;
} }
// FOR COMMON RENAME ACTIONS // FOR COMMON RENAME ACTIONS
/** /**
@ -2936,7 +2924,6 @@ public class SystemViewRemoteFileAdapter
*/ */
public boolean doRename(Shell shell, Object element, String newName, IProgressMonitor monitor) throws Exception public boolean doRename(Shell shell, Object element, String newName, IProgressMonitor monitor) throws Exception
{ {
boolean ok = true;
IRemoteFile file = (IRemoteFile) element; IRemoteFile file = (IRemoteFile) element;
IRemoteFileSubSystem ss = file.getParentRemoteFileSubSystem(); IRemoteFileSubSystem ss = file.getParentRemoteFileSubSystem();
@ -2948,12 +2935,7 @@ public class SystemViewRemoteFileAdapter
localResource = UniversalFileTransferUtility.getTempFileFor(file); localResource = UniversalFileTransferUtility.getTempFileFor(file);
} }
try {
ss.rename(file, newName, monitor); ss.rename(file, newName, monitor);
} catch (Exception e) {
SystemBasePlugin.logError("Exception occurred during rename", e); //$NON-NLS-1$
ok = false;
}
if (localResource != null && localResource.exists()) if (localResource != null && localResource.exists())
{ {
@ -2976,7 +2958,7 @@ public class SystemViewRemoteFileAdapter
// //sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, file, file.getParentRemoteFile(), file.getParentRemoteFileSubSystem(), null, null); // //sr.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_RENAMED, file, file.getParentRemoteFile(), file.getParentRemoteFileSubSystem(), null, null);
// } // }
// file.markStale(true); // file.markStale(true);
return ok; return true;
} }