Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » how to tell the difference between a file being deleted and a project being deleted?
how to tell the difference between a file being deleted and a project being deleted? [message #313109] Thu, 01 March 2007 17:34 Go to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 82
Registered: July 2009
Member
My problem might sound simple:
If a property file (an xml I use to store special data about the project) is
deleted I have to regenerate it.
If the whole project is deleted (the contents too) I must not regenerate the
property file (or else the deletion will stop with an error).

The problem is, that in my ResourceChangeListener in both cases I see the
following:
-The project is in CHANGED state.
-The findMember function of the project returns null for my property file.

I simply don't know how to tell the difference, can anyone help me?

Kristof
Re: how to tell the difference between a file being deleted and a project being deleted? [message #313111 is a reply to message #313109] Thu, 01 March 2007 17:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Kristof,

I don't know much about this, but I believe the deltas form a tree so
when a project is deleted, I think the deleted file delta will be a
child of the deleted project delta and that this would be the way to
tell. You're sure the project's delta isn't a REMOVED delta in the case
of deleting a project? Perhaps the thing that creates the file should
be a builder instead...


Kristof Szabados wrote:
> My problem might sound simple:
> If a property file (an xml I use to store special data about the project) is
> deleted I have to regenerate it.
> If the whole project is deleted (the contents too) I must not regenerate the
> property file (or else the deletion will stop with an error).
>
> The problem is, that in my ResourceChangeListener in both cases I see the
> following:
> -The project is in CHANGED state.
> -The findMember function of the project returns null for my property file.
>
> I simply don't know how to tell the difference, can anyone help me?
>
> Kristof
>
>
>
Re: how to tell the difference between a file being deleted and a project being deleted? [message #313113 is a reply to message #313111] Thu, 01 March 2007 19:16 Go to previous messageGo to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 82
Registered: July 2009
Member
I'm sure.
I first receive a PRE_DELETE event telling me that the project is to be
deleted, from which I assume, that all of it's files will become unavailable
for me too (deleted or not).
After this comes the POST_CHANGE event I mentioned before.

Should I create some internal state machine, describing in what states the
projects are?
(The second event is separated from the first, I could also assume, that the
deletion failed, but some file remained, which is like a simple file
deletion "action").

Kristof


"Ed Merks" <merks@ca.ibm.com> wrote in message
news:es744v$get$1@utils.eclipse.org...
> Kristof,
>
> I don't know much about this, but I believe the deltas form a tree so
> when a project is deleted, I think the deleted file delta will be a
> child of the deleted project delta and that this would be the way to
> tell. You're sure the project's delta isn't a REMOVED delta in the case
> of deleting a project? Perhaps the thing that creates the file should
> be a builder instead...
>
>
> Kristof Szabados wrote:
> > My problem might sound simple:
> > If a property file (an xml I use to store special data about the
project) is
> > deleted I have to regenerate it.
> > If the whole project is deleted (the contents too) I must not regenerate
the
> > property file (or else the deletion will stop with an error).
> >
> > The problem is, that in my ResourceChangeListener in both cases I see
the
> > following:
> > -The project is in CHANGED state.
> > -The findMember function of the project returns null for my property
file.
> >
> > I simply don't know how to tell the difference, can anyone help me?
> >
> > Kristof
> >
> >
> >
Re: how to tell the difference between a file being deleted and a project being deleted? [message #313115 is a reply to message #313113] Thu, 01 March 2007 20:30 Go to previous message
Eclipse UserFriend
Originally posted by: wharley.bea.com

"Kristof Szabados" <szabadosk@yahoo.com> wrote in message
news:es78qs$h3l$1@utils.eclipse.org...
> I'm sure.
> I first receive a PRE_DELETE event telling me that the project is to be
> deleted, from which I assume, that all of it's files will become
> unavailable
> for me too (deleted or not).
> After this comes the POST_CHANGE event I mentioned before.
>
> Should I create some internal state machine, describing in what states the
> projects are?
> (The second event is separated from the first, I could also assume, that
> the
> deletion failed, but some file remained, which is like a simple file
> deletion "action").
>
> Kristof

There's a nice article about resource listeners by John Arthorne, at
http://www.eclipse.org/articles/Article-Resource-deltas/reso urce-deltas.html.

I agree with Ed that you might want to consider using a builder rather than
a resource listener. A builder is a nice way to ensure that a certain file
gets built when it needs to, without getting into threading weirdness and
performance problems, and project deletion is not going to inadvertently
cause your builder to generate a file. Builders also avoid certain problems
with initialization that resource listeners are prone to - e.g., problems
with getting the listener registered in time to respond to events during
startup.
Previous Topic:Plugin not working with Eclipse3.3
Next Topic:export a plugin
Goto Forum:
  


Current Time: Thu Jul 25 06:08:48 GMT 2024

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

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

Back to the top