Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Using CopyFilesAndFoldersOperation from a WorkspaceJob
Using CopyFilesAndFoldersOperation from a WorkspaceJob [message #334891] Sat, 07 March 2009 20:47
eric is currently offline ericFriend
Messages: 1
Registered: July 2009
Junior Member
I am having problems using CopyFilesAndFoldersOperation from a
WorkspaceJob. In particular, I am trying to use the methods
copyResourcesInCurrentThread() in a backgroundable job, but I am running
into exceptions resulting from invalid thread access as a result of the
call to IProgressService.run() on line 559. For reference, I am using the
3.4.0 version of the org.eclipse.ui.ide plugin.

It seems to me that when called from copyResourcesInCurrentThread() the
internal implementation of copyResources() (declared on line 532) should
not make its call to copyResources() within a runnable. Apart from the
current problem I am encountering with invalid thread access, I do not
think it is consistent with the javadoc of copyResourcesInCurrentThread()
to make the copyResources() call in this way.

I believe that the implementation of copyFileStores() (on line 776) is
more correct since it uses the "fork" argument to determine whether or not
to perform the actual copy in a runnable. It seems that copyResources()
should be implemented similarly; i.e. lines 551-564 should be replaced
with the following:

if (fork) {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
copyResources(resources, destinationPath, copiedResources,
monitor);
}
};

try {
PlatformUI.getWorkbench().getProgressService().run(fork, true, op);
} catch (InterruptedException e) {
return copiedResources[0];
} catch (InvocationTargetException e) {
display(e);
}
} else {
copyResources(resources, destinationPath, copiedResources, monitor);

}

That implementation fixes the invalid thread access and would seem to be
the behavior which the javadoc specifies.

Does this make sense? If so, I will file a bug on the existing
implementation.

Thanks,

Eric
Previous Topic:unconnected sockets not implemented
Next Topic:Stopping application by binding (key shortcut)
Goto Forum:
  


Current Time: Fri Apr 26 10:43:05 GMT 2024

Powered by FUDForum. Page generated in 0.02655 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top