Detecting project "move" [message #120593] |
Tue, 02 September 2003 14:26  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
> > >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03403 seconds