mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-20 06:35:50 +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:
parent
ee511dba34
commit
788cece9b2
3 changed files with 27 additions and 89 deletions
|
@ -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,30 +259,14 @@ 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;
|
String sep = targetFolder.getSeparator();
|
||||||
} catch (Exception e) {
|
String targetFolderName = targetFolder.getAbsolutePath();
|
||||||
SystemBasePlugin.logError("Exception occurred during copy", e); //$NON-NLS-1$
|
if (!targetFolderName.endsWith(sep))
|
||||||
}
|
copiedFiles.addElement(targetFolderName+sep+newName);
|
||||||
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
|
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
|
// DKM - for cross system copy
|
||||||
else
|
else
|
||||||
|
|
|
@ -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,46 +238,25 @@ 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 srcFileOrFolder = (IRemoteFile) oldObject;
|
||||||
IRemoteFile targetFolder = (IRemoteFile)targetContainer;
|
|
||||||
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
|
|
||||||
|
|
||||||
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
|
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
|
||||||
|
|
||||||
boolean ok = false;
|
ss.move(srcFileOrFolder, targetFolder, newName, monitor);
|
||||||
try {
|
String sep = targetFolder.getSeparator();
|
||||||
ss.move(srcFileOrFolder, targetFolder, newName, monitor);
|
String targetFolderName = targetFolder.getAbsolutePath();
|
||||||
ok = true;
|
String resultPath = null;
|
||||||
} catch (Exception e) {
|
|
||||||
SystemBasePlugin.logError("Exception occurred during a move operation", e); //$NON-NLS-1$
|
if (!targetFolderName.endsWith(sep))
|
||||||
}
|
resultPath = targetFolderName + sep + newName;
|
||||||
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
|
else
|
||||||
{
|
resultPath = targetFolderName + newName;
|
||||||
String sep = targetFolder.getSeparator();
|
|
||||||
String targetFolderName = targetFolder.getAbsolutePath();
|
|
||||||
String resultPath = null;
|
|
||||||
|
|
||||||
if (!targetFolderName.endsWith(sep))
|
copiedFiles.addElement(resultPath);
|
||||||
resultPath = targetFolderName+sep+newName;
|
movedFiles.add(srcFileOrFolder);
|
||||||
else
|
return true;
|
||||||
resultPath = targetFolderName+newName;
|
|
||||||
|
|
||||||
copiedFiles.addElement(resultPath);
|
|
||||||
movedFiles.add(srcFileOrFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue