Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Event for newly created Projects
Event for newly created Projects [message #733505] Tue, 04 October 2011 21:53 Go to next message
Neil Bartlett is currently offline Neil BartlettFriend
Messages: 93
Registered: July 2009
Member
Hello all,

I would like my tool to perform a task each time a new project having a
particular nature is *created*. This needs to include at least the
following scenarios:

* Project created using a "New Project" wizard
* Project imported into workspace for first time using "Import Existing
Project" wizard
* Project imported from CVS, Git or other source control.

To this end, I have written an IResourceListener and registered it with
the workspace. I expected to receive a ResourceEvent containing a delta
for the IProject with kind=ADDED and flags=OPEN. Furthermore I expected
that subsequent changes to files in the project would give me deltas of
kind=CHANGED against the project... i.e. I would never see the
ADDED/OPEN delta again for the same project.

However what actually happens is I get ADDED/OPEN events *many* times
against the project. I receive at least 5 such events in quick
succession during an "Import Existing Project" operation, and then I
keep getting them on subsequent changes inside the project. Eclipse even
gives me ADDED/OPEN events during startup, on all the projects in the
workspace!

Could somebody give me a hint what is going on here? Is there a better
way to be notified exactly once when a project is created?

Many thanks,
Neil
Re: Event for newly created Projects [message #734968 is a reply to message #733505] Mon, 10 October 2011 14:19 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 04.10.2011 23:53, Neil Bartlett wrote:
> Hello all,
>
> I would like my tool to perform a task each time a new project having
> a particular nature is *created*. This needs to include at least the
> following scenarios:
>
> * Project created using a "New Project" wizard
> * Project imported into workspace for first time using "Import
> Existing Project" wizard
> * Project imported from CVS, Git or other source control.
>
> To this end, I have written an IResourceListener and registered it
> with the workspace. I expected to receive a ResourceEvent containing a
> delta for the IProject with kind=ADDED and flags=OPEN. Furthermore I
> expected that subsequent changes to files in the project would give me
> deltas of kind=CHANGED against the project... i.e. I would never see
> the ADDED/OPEN delta again for the same project.
>
> However what actually happens is I get ADDED/OPEN events *many* times
> against the project. I receive at least 5 such events in quick
> succession during an "Import Existing Project" operation, and then I
> keep getting them on subsequent changes inside the project. Eclipse
> even gives me ADDED/OPEN events during startup, on all the projects in
> the workspace!
>
> Could somebody give me a hint what is going on here? Is there a better
> way to be notified exactly once when a project is created?
The add event is also sent when folders and files are added you need to
check whether the delta's resource is a project and whether the delta's
kind is IResourceDelta.ADDED.

Dani
>
> Many thanks,
> Neil
Previous Topic:Find Next in Console View
Next Topic:Mac snow leopard update site issue
Goto Forum:
  


Current Time: Fri Apr 19 12:49:08 GMT 2024

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

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

Back to the top