mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-19 22:25:52 +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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
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.RSEUIPlugin;
|
||||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||||
|
import org.eclipse.rse.ui.view.SystemDNDTransferRunnable;
|
||||||
import org.eclipse.swt.program.Program;
|
import org.eclipse.swt.program.Program;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
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.actions.WorkspaceModifyOperation;
|
||||||
import org.eclipse.ui.ide.IDE;
|
import org.eclipse.ui.ide.IDE;
|
||||||
import org.eclipse.ui.part.FileEditorInput;
|
import org.eclipse.ui.part.FileEditorInput;
|
||||||
|
import org.eclipse.ui.progress.UIJob;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
@ -91,7 +94,8 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
/**
|
/**
|
||||||
* Internal class for downloading file
|
* Internal class for downloading file
|
||||||
*/
|
*/
|
||||||
private class InternalDownloadFileRunnable extends WorkspaceModifyOperation
|
private class InternalDownloadFileRunnable extends UIJob
|
||||||
|
//extends WorkspaceModifyOperation
|
||||||
{
|
{
|
||||||
|
|
||||||
private Exception e;
|
private Exception e;
|
||||||
|
@ -102,8 +106,11 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
*/
|
*/
|
||||||
private InternalDownloadFileRunnable()
|
private InternalDownloadFileRunnable()
|
||||||
{
|
{
|
||||||
|
super("Download");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see WorkspaceModifyOperation#execute(IProgressMonitor)
|
* @see WorkspaceModifyOperation#execute(IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
|
@ -152,6 +159,18 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
throw e;
|
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;
|
private String _editorId = null;
|
||||||
|
@ -428,12 +447,19 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP
|
||||||
|
|
||||||
|
|
||||||
InternalDownloadFileRunnable downloadFileRunnable = new InternalDownloadFileRunnable();
|
InternalDownloadFileRunnable downloadFileRunnable = new InternalDownloadFileRunnable();
|
||||||
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
|
//ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
|
||||||
IFile localFile = getLocalResource();
|
IFile localFile = getLocalResource();
|
||||||
SystemUniversalTempFileListener listener = SystemUniversalTempFileListener.getListener();
|
SystemUniversalTempFileListener listener = SystemUniversalTempFileListener.getListener();
|
||||||
listener.addIgnoreFile(localFile);
|
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);
|
listener.removeIgnoreFile(localFile);
|
||||||
downloadFileRunnable.throwException();
|
downloadFileRunnable.throwException();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.eclipse.rse.subsystems.files.core.subsystems;
|
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
||||||
import org.eclipse.rse.core.subsystems.IRemotePropertyHolder;
|
import org.eclipse.rse.core.subsystems.IRemotePropertyHolder;
|
||||||
import org.eclipse.rse.model.IHost;
|
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
|
* Note for subsystem providers: this method does not capture the set methods that the
|
||||||
* RemoteFileImpl class defines. For that, cast to IRemoteFileMutable.
|
* 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 char CONNECTION_DELIMITER = ':';
|
||||||
public static final boolean ISROOT_YES = true;
|
public static final boolean ISROOT_YES = true;
|
||||||
|
|
|
@ -24,8 +24,11 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.Platform;
|
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.SystemBasePlugin;
|
||||||
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
import org.eclipse.rse.core.subsystems.IRemoteContainer;
|
||||||
import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
|
import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType;
|
||||||
|
@ -1054,4 +1057,67 @@ public abstract class RemoteFile implements IRemoteFile, IAdaptable, Comparable
|
||||||
{
|
{
|
||||||
return "";
|
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;
|
package org.eclipse.rse.subsystems.files.core.subsystems;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.rse.services.files.IHostFile;
|
import org.eclipse.rse.services.files.IHostFile;
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,4 +200,7 @@ public class RemoteFileEmpty extends RemoteFile
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -116,24 +116,27 @@ public class SystemPasteFromClipboardAction extends SystemBaseAction implements
|
||||||
}
|
}
|
||||||
**/
|
**/
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (target instanceof ISchedulingRule)
|
if (target instanceof ISchedulingRule)
|
||||||
{
|
{
|
||||||
rulesList.add(target);
|
rulesList.add(target);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/** FIXME - IREmoteFile is systems.core independent now
|
/** FIXME - IREmoteFile is systems.core independent now
|
||||||
else if (target instanceof IRemoteFile)
|
else if (target instanceof IRemoteFile)
|
||||||
{
|
{
|
||||||
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rulesList.add(targetSubSystem);
|
rulesList.add(targetSubSystem);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
|
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
|
||||||
MultiRule rule = new MultiRule(rules);
|
MultiRule rule = new MultiRule(rules);
|
||||||
//runnable.setRule(rule);
|
runnable.setRule(rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runnable.schedule();
|
runnable.schedule();
|
||||||
|
|
|
@ -187,17 +187,19 @@ public class SystemViewDataDropAdapter extends ViewerDropAdapter implements ISy
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (target instanceof ISchedulingRule)
|
if (target instanceof ISchedulingRule)
|
||||||
{
|
{
|
||||||
rulesList.add(target);
|
rulesList.add(target);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/** FIXME - can't be coupled with IRemoteFile
|
/** FIXME - can't be coupled with IRemoteFile
|
||||||
else if (target instanceof IRemoteFile)
|
else if (target instanceof IRemoteFile)
|
||||||
{
|
{
|
||||||
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
rulesList.add(new RemoteFileSchedulingRule((IRemoteFile)target));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
else if (target instanceof IAdaptable)
|
else if (target instanceof IAdaptable)
|
||||||
{
|
{
|
||||||
ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
|
ISystemDragDropAdapter targetAdapter = (ISystemDragDropAdapter) ((IAdaptable) target).getAdapter(ISystemDragDropAdapter.class);
|
||||||
|
@ -209,6 +211,7 @@ public class SystemViewDataDropAdapter extends ViewerDropAdapter implements ISy
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
MultiRule rule = null;
|
MultiRule rule = null;
|
||||||
ISchedulingRule[] rules = (ISchedulingRule[])rulesList.toArray(new ISchedulingRule[rulesList.size()]);
|
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);
|
SystemDNDTransferRunnable runnable = new SystemDNDTransferRunnable(target, srcObjects, getViewer(), _sourceType);
|
||||||
// DKM - rules are causing problems at the moment
|
// DKM - rules are causing problems at the moment
|
||||||
//runnable.setRule(rule);
|
runnable.setRule(rule);
|
||||||
|
|
||||||
if (target instanceof SystemScratchpad)
|
if (target instanceof SystemScratchpad)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue