Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Detecting project "move"
Detecting project "move" [message #120593] Tue, 02 September 2003 14:26 Go to next message
Eclipse UserFriend
We have our product specific files in Eclipse project directory. When
Eclipse project is renamed or moved, we need to take care of our own
files. Simple file copy is not sufficient. When Eclipse project is
renamed, I noticed I get POST_CHANGE event with ADDED delta and REMOVED
delta, as well as PRE_DELETE event. It is sufficient for me to do what I
need to do. However, when project is "moved", the only event I see is
POST_CHANGE event with CHANGED delta. It would be OK, if I can figure out
the "before" and "after" locations of the project. I tried the following
code:

IResourceDelta[] changedDeltas =
event.getDelta().getAffectedChildren(IResourceDelta.CHANGED) ;
if (changedDeltas[0].getResource().getType() == IResource.PROJECT) {
IPath from = changedDeltas[0].getMovedFromPath();
IPath to = changedDeltas[0].getMovedToPath();
}

In the above code, both 'from' and 'to' are null's. What would be the
proper way to obtain the "before" and "after" locations of the project
when it is moved by user?

Thanks in advance,
JK
Re: Detecting project "move" [message #121808 is a reply to message #120593] Wed, 03 September 2003 06:12 Go to previous messageGo to next message
Eclipse UserFriend
You can use the MOVED_FROM and MOVED_TO flags, e.g.

if (changedDeltas[0].getFlags() & IResourceDelta.MOVED_FROM) != 0) {
IPath from = changedDeltas[0].getMovedFromPath();
}

Jerome

"JK Lah" <jk.lah@intel.com> wrote in message
news:bj2nbo$fk7$1@eclipse.org...
> We have our product specific files in Eclipse project directory. When
> Eclipse project is renamed or moved, we need to take care of our own
> files. Simple file copy is not sufficient. When Eclipse project is
> renamed, I noticed I get POST_CHANGE event with ADDED delta and REMOVED
> delta, as well as PRE_DELETE event. It is sufficient for me to do what I
> need to do. However, when project is "moved", the only event I see is
> POST_CHANGE event with CHANGED delta. It would be OK, if I can figure out
> the "before" and "after" locations of the project. I tried the following
> code:
>
> IResourceDelta[] changedDeltas =
> event.getDelta().getAffectedChildren(IResourceDelta.CHANGED) ;
> if (changedDeltas[0].getResource().getType() == IResource.PROJECT) {
> IPath from = changedDeltas[0].getMovedFromPath();
> IPath to = changedDeltas[0].getMovedToPath();
> }
>
> In the above code, both 'from' and 'to' are null's. What would be the
> proper way to obtain the "before" and "after" locations of the project
> when it is moved by user?
>
> Thanks in advance,
> JK
>
Re: Detecting project "move" [message #122263 is a reply to message #121808] Wed, 03 September 2003 13:03 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for the reply. However, the value of changedDeltas[0].getFlags()
is 0x80000 which is DESCRIPTION. I don't receive any other event when I
move project. I am using Eclipse 2.1.1 on Windows. Is there something I
am missing?

JK

Jerome Lanneluc wrote:

> You can use the MOVED_FROM and MOVED_TO flags, e.g.

> if (changedDeltas[0].getFlags() & IResourceDelta.MOVED_FROM) != 0) {
> IPath from = changedDeltas[0].getMovedFromPath();
> }

> Jerome

> "JK Lah" <jk.lah@intel.com> wrote in message
> news:bj2nbo$fk7$1@eclipse.org...
> > We have our product specific files in Eclipse project directory. When
> > Eclipse project is renamed or moved, we need to take care of our own
> > files. Simple file copy is not sufficient. When Eclipse project is
> > renamed, I noticed I get POST_CHANGE event with ADDED delta and REMOVED
> > delta, as well as PRE_DELETE event. It is sufficient for me to do what I
> > need to do. However, when project is "moved", the only event I see is
> > POST_CHANGE event with CHANGED delta. It would be OK, if I can figure out
> > the "before" and "after" locations of the project. I tried the following
> > code:
> >
> > IResourceDelta[] changedDeltas =
> > event.getDelta().getAffectedChildren(IResourceDelta.CHANGED) ;
> > if (changedDeltas[0].getResource().getType() == IResource.PROJECT) {
> > IPath from = changedDeltas[0].getMovedFromPath();
> > IPath to = changedDeltas[0].getMovedToPath();
> > }
> >
> > In the above code, both 'from' and 'to' are null's. What would be the
> > proper way to obtain the "before" and "after" locations of the project
> > when it is moved by user?
> >
> > Thanks in advance,
> > JK
> >
Re: Detecting project "move" [message #122565 is a reply to message #122263] Thu, 04 September 2003 05:48 Go to previous message
Eclipse UserFriend
I just looked at the IResource.move(...) methods and it looks like you can
rename a project only by changing its description.Unfortunately I don't
think you can get the previous description (as you can get the MovedFromPath
for other resources).

You should enter a feature request (against Platform/Core).

Jerome

"JK Lah" <jk.lah@intel.com> wrote in message
news:bj56ss$v7k$1@eclipse.org...
> Thanks for the reply. However, the value of changedDeltas[0].getFlags()
> is 0x80000 which is DESCRIPTION. I don't receive any other event when I
> move project. I am using Eclipse 2.1.1 on Windows. Is there something I
> am missing?
>
> JK
>
> Jerome Lanneluc wrote:
>
> > You can use the MOVED_FROM and MOVED_TO flags, e.g.
>
> > if (changedDeltas[0].getFlags() & IResourceDelta.MOVED_FROM) != 0) {
> > IPath from = changedDeltas[0].getMovedFromPath();
> > }
>
> > Jerome
>
> > "JK Lah" <jk.lah@intel.com> wrote in message
> > news:bj2nbo$fk7$1@eclipse.org...
> > > We have our product specific files in Eclipse project directory. When
> > > Eclipse project is renamed or moved, we need to take care of our own
> > > files. Simple file copy is not sufficient. When Eclipse project is
> > > renamed, I noticed I get POST_CHANGE event with ADDED delta and
REMOVED
> > > delta, as well as PRE_DELETE event. It is sufficient for me to do
what I
> > > need to do. However, when project is "moved", the only event I see is
> > > POST_CHANGE event with CHANGED delta. It would be OK, if I can figure
out
> > > the "before" and "after" locations of the project. I tried the
following
> > > code:
> > >
> > > IResourceDelta[] changedDeltas =
> > > event.getDelta().getAffectedChildren(IResourceDelta.CHANGED) ;
> > > if (changedDeltas[0].getResource().getType() == IResource.PROJECT) {
> > > IPath from = changedDeltas[0].getMovedFromPath();
> > > IPath to = changedDeltas[0].getMovedToPath();
> > > }
> > >
> > > In the above code, both 'from' and 'to' are null's. What would be the
> > > proper way to obtain the "before" and "after" locations of the project
> > > when it is moved by user?
> > >
> > > Thanks in advance,
> > > JK
> > >
>
>
Previous Topic:M3 editor issues?
Next Topic:[ANN] Advanced Eclipse SWT Designer, version 1.1.2
Goto Forum:
  


Current Time: Fri May 09 17:26:23 EDT 2025

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

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

Back to the top