Major Problem with IResourceChangeListener and Import [message #78469] |
Thu, 19 June 2003 12:32  |
Eclipse User |
|
|
|
Originally posted by: bharatkhatri2000.yahoo.com
I have implemented a view similar to navigator, and a context menu similar
to that of navigator on top of my view. The menu has operations like
copy/paste etc. which are accomplished through workspace API. Then I have
a resource change listener which listens to changes in the worspace as a
result of above operations, and udates my view accordingly. If I copy
multiple files from one location to another by doing a multiple select,
all these changes are notified to my listener one-by-one. This is good so
far.
I added the import action to the context menu by using
org.eclipse.ui.actions.ImportResourcesAction class. When I import a single
file from some location into some workspace location, the file is copied
and my view is updated. But when I try to import multiple files (or even a
single folder with multiple files), all the files are copied to workspace,
but my listener is notified of only the first file that was added in the
import (or only the folder in case of importing a folder). So my view is
not correct because my listener was not notified of all changes.
Any help or suggestions are appreciated.
Thanks
Bharat
|
|
|
Re: Major Problem with IResourceChangeListener and Import [message #78551 is a reply to message #78469] |
Thu, 19 June 2003 13:50  |
Eclipse User |
|
|
|
Originally posted by: chaves-no-spam.inf.ufsc.br
You will get your listener called once for each workspace operation
peformed (see IWorkspace.run). If you wrapped the copy of all files inside
a workspace operation, you would get only one IResourceChangeEvent,
reporting changes for all copied/moved/deleted resources. Since you are
not doing that (you are getting one event per operation. The import
resource action uses a workspace operation, and this is why you are
getting only one event object. But the delta contains information about
all created/modified resources. You should consider using the Core Tools,
available from the Eclipse Core Developpment Resources page:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-core-home/index.html
It has a nice view called Delta Spy that shows the deltas for any changes
made to the workspace. For instance, when I imported two files into a
project called "foo", the Delta Spy view showed this:
/[*]: {}
/foo[*]: {}
/foo/file1.txt[+]: {}
/foo/file2.txt[+]: {}
That means that the workspace root and the foo project were changed (*),
and the files file1.txt and file2.txt were added (+) to the foo project.
Deleting file2.txt would produce the following delta:
/[*]: {}
/foo[*]: {}
/foo/file2.txt[-]: {}
Source code for the Core Tools is available, so it is a good way for
developers to understand how Eclipse behaves internally and how to use the
runtime and resources core APIs.
Regards,
Rafael
|
|
|
Powered by
FUDForum. Page generated in 0.06507 seconds