mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 15:15:25 +02:00
Bug 149133 - adding rules so that the same file can not be concurrently transferred
This commit is contained in:
parent
55925c06dc
commit
6bae465c8c
6 changed files with 112 additions and 9 deletions
|
@ -19,6 +19,7 @@ package org.eclipse.rse.files.ui.resources;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
|
@ -52,6 +53,7 @@ import org.eclipse.rse.ui.ISystemMessages;
|
|||
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.rse.ui.view.SystemDNDTransferRunnable;
|
||||
import org.eclipse.swt.program.Program;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -71,6 +73,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.progress.UIJob;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
|
@ -91,7 +94,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
/**
|
||||
* Internal class for downloading file
|
||||
*/
|
||||
private class InternalDownloadFileRunnable extends WorkspaceModifyOperation
|
||||
private class InternalDownloadFileRunnable extends UIJob
|
||||
//extends WorkspaceModifyOperation
|
||||
{
|
||||
|
||||
private Exception e;
|
||||
|
@ -102,8 +106,11 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
*/
|
||||
private InternalDownloadFileRunnable()
|
||||
{
|
||||
super("Download");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see WorkspaceModifyOperation#execute(IProgressMonitor)
|
||||
*/
|
||||
|
@ -152,6 +159,18 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
try
|
||||
{
|
||||
execute(monitor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
|
||||
private String _editorId = null;
|
||||
|
@ -425,15 +444,22 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
|||
|
||||
if (shell != null)
|
||||
{
|
||||
|
||||
|
||||
|
||||
InternalDownloadFileRunnable downloadFileRunnable = new InternalDownloadFileRunnable();
|
||||
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
|
||||
//ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
|
||||
IFile localFile = getLocalResource();
|
||||
SystemUniversalTempFileListener listener = SystemUniversalTempFileListener.getListener();
|
||||
listener.addIgnoreFile(localFile);
|
||||
|
||||
pmd.run(false, true, downloadFileRunnable);
|
||||
//pmd.run(false, true, downloadFileRunnable);
|
||||
downloadFileRunnable.setRule(getRemoteFile());
|
||||
downloadFileRunnable.schedule();
|
||||
while (!downloadFileRunnable.didComplete())
|
||||
{
|
||||
Display.getDefault().readAndDispatch();
|
||||
//downloadFileRunnable.wait();
|
||||
}
|
||||
|
||||
listener.removeIgnoreFile(localFile);
|
||||
downloadFileRunnable.throwException();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
||||
import org.eclipse.rse.core.subsystems.IRemotePropertyHolder;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
|
@ -50,7 +51,7 @@ import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
|||
* Note for subsystem providers: this method does not capture the set methods that the
|
||||
* RemoteFileImpl class defines. For that, cast to IRemoteFileMutable.
|
||||
*/
|
||||
public interface IRemoteFile extends IRemoteContainer, IRemotePropertyHolder
|
||||
public interface IRemoteFile extends IRemoteContainer, IRemotePropertyHolder, ISchedulingRule
|
||||
{
|
||||
public static final char CONNECTION_DELIMITER = ':';
|
||||
public static final boolean ISROOT_YES = true;
|
||||
|
|
|
@ -24,8 +24,11 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
||||
import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
|
||||
|
@ -1054,4 +1057,67 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
|||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see ISchedulingRule#contains(ISchedulingRule)
|
||||
*/
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
if (this == rule)
|
||||
return true;
|
||||
if (rule instanceof MultiRule) {
|
||||
MultiRule multi = (MultiRule) rule;
|
||||
ISchedulingRule[] children = multi.getChildren();
|
||||
for (int i = 0; i < children.length; i++)
|
||||
if (!contains(children[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (rule instanceof IResource)
|
||||
return true;
|
||||
if (rule instanceof IRemoteFile)
|
||||
{
|
||||
RemoteFile rf = (RemoteFile)rule;
|
||||
return getHostName().equals(rf.getHostName()) &&
|
||||
rf.getAbsolutePath().startsWith(getAbsolutePath());
|
||||
}
|
||||
//if (!(rule instanceof RemoteFileSchedulingRule))
|
||||
// return false;
|
||||
if (rule instanceof RemoteFileSchedulingRule)
|
||||
{
|
||||
return getHostName().equals(((RemoteFileSchedulingRule) rule).getHostName()) &&
|
||||
((RemoteFileSchedulingRule) rule).getAbsolutePath().startsWith(getAbsolutePath());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ISchedulingRule#isConflicting(ISchedulingRule)
|
||||
*/
|
||||
public boolean isConflicting(ISchedulingRule rule)
|
||||
{
|
||||
if (rule instanceof RemoteFile)
|
||||
{
|
||||
String otherPath = ((RemoteFile) rule).getAbsolutePath();
|
||||
String path = this.getAbsolutePath();
|
||||
String otherHost = ((RemoteFile) rule).getHostName();
|
||||
return getHostName().equals(otherHost) && path.startsWith(otherPath) || otherPath.startsWith(path);
|
||||
}
|
||||
else if (rule instanceof RemoteFileSchedulingRule)
|
||||
{
|
||||
String otherPath = ((RemoteFileSchedulingRule) rule).getAbsolutePath();
|
||||
String path = this.getAbsolutePath();
|
||||
String otherHost = ((RemoteFileSchedulingRule) rule).getHostName();
|
||||
return getHostName().equals(otherHost) && path.startsWith(otherPath) || otherPath.startsWith(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHostName()
|
||||
{
|
||||
return getSystemConnection().getHostName();
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.rse.services.files.IHostFile;
|
||||
|
||||
|
||||
|
@ -199,4 +200,7 @@ public class RemoteFileEmpty extends RemoteFile
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -116,24 +116,27 @@ public class SystemPasteFromClipboardAction extends SystemBaseAction implements
|
|||
}
|
||||
**/
|
||||
}
|
||||
/*
|
||||
if (target instanceof ISchedulingRule)
|
||||
{
|
||||
rulesList.add(target);
|
||||
}
|
||||
*/
|
||||
/** FIXME - IREmoteFile is systems.core independent now
|
||||
else if (target instanceof IRemoteFile)
|
||||
{
|
||||
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
||||
}
|
||||
*/
|
||||
/*
|
||||
else
|
||||
{
|
||||
rulesList.add(targetSubSystem);
|
||||
}
|
||||
|
||||
*/
|
||||
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
|
||||
MultiRule rule = new MultiRule(rules);
|
||||
//runnable.setRule(rule);
|
||||
runnable.setRule(rule);
|
||||
}
|
||||
}
|
||||
runnable.schedule();
|
||||
|
|
|
@ -187,17 +187,19 @@ public class SystemViewDataDropAdapter extends ViewerDropAdapter implements ISy
|
|||
}
|
||||
*/
|
||||
}
|
||||
/*
|
||||
if (target instanceof ISchedulingRule)
|
||||
{
|
||||
rulesList.add(target);
|
||||
j++;
|
||||
}
|
||||
*/
|
||||
/** FIXME - can't be coupled with IRemoteFile
|
||||
else if (target instanceof IRemoteFile)
|
||||
{
|
||||
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
||||
}
|
||||
*/
|
||||
|
||||
else if (target instanceof IAdaptable)
|
||||
{
|
||||
ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
|
||||
|
@ -209,6 +211,7 @@ public class SystemViewDataDropAdapter extends ViewerDropAdapter implements ISy
|
|||
j++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
MultiRule rule = null;
|
||||
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
|
||||
|
||||
|
@ -216,7 +219,7 @@ public class SystemViewDataDropAdapter extends ViewerDropAdapter implements ISy
|
|||
|
||||
SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, getViewer(), _sourceType);
|
||||
// DKM - rules are causing problems at the moment
|
||||
//runnable.setRule(rule);
|
||||
runnable.setRule(rule);
|
||||
|
||||
if (target instanceof SystemScratchpad)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue