Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » IResourceChangeListener's PRE_DELETE event not work for IFile
IResourceChangeListener's PRE_DELETE event not work for IFile [message #312059] Tue, 30 January 2007 09:28 Go to next message
Eddie Man is currently offline Eddie ManFriend
Messages: 102
Registered: July 2009
Senior Member
I had register a IResourceChangeListener to the workspace (PRE_DELETE |
PRE_CLOSE), but I found that this listener does not work for delete a
IFile in the navigator view. Did I get any wrong? or anyway can do that?

Thanks
Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312088 is a reply to message #312059] Tue, 30 January 2007 17:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: claire.reynaud.trango-systems.com

Eddie Man a écrit :
> I had register a IResourceChangeListener to the workspace (PRE_DELETE |
> PRE_CLOSE), but I found that this listener does not work for delete a
> IFile in the navigator view.

IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are projects events. You should use IResourceChangeEvent.POST_CHANGE to get notified of a file deletion.
See IResourceChangeEvent javadoc.

Regards,
Claire

Did I get any wrong? or anyway can do that?
>
> Thanks
> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312099 is a reply to message #312088] Wed, 31 January 2007 02:21 Go to previous messageGo to next message
Eddie Man is currently offline Eddie ManFriend
Messages: 102
Registered: July 2009
Senior Member
But I need to get the contents of the file, so cannot using POST_CHANGE
event, any alternative?

claire reynaud wrote:
> Eddie Man a écrit :
>> I had register a IResourceChangeListener to the workspace (PRE_DELETE
>> | PRE_CLOSE), but I found that this listener does not work for delete
>> a IFile in the navigator view.
>
> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are
> projects events. You should use IResourceChangeEvent.POST_CHANGE to get
> notified of a file deletion.
> See IResourceChangeEvent javadoc.
>
> Regards,
> Claire
>
> Did I get any wrong? or anyway can do that?
>>
>> Thanks
>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312100 is a reply to message #312099] Wed, 31 January 2007 04:06 Go to previous messageGo to next message
Snjezana Peco is currently offline Snjezana PecoFriend
Messages: 789
Registered: July 2009
Senior Member
You should use IResourceDelta.REMOVED.
You will get this constante before a file has been deleted or moved.

Snjeza

Eddie Man wrote:
> But I need to get the contents of the file, so cannot using POST_CHANGE
> event, any alternative?
>
> claire reynaud wrote:
>> Eddie Man a écrit :
>>> I had register a IResourceChangeListener to the workspace (PRE_DELETE
>>> | PRE_CLOSE), but I found that this listener does not work for delete
>>> a IFile in the navigator view.
>>
>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are
>> projects events. You should use IResourceChangeEvent.POST_CHANGE to
>> get notified of a file deletion.
>> See IResourceChangeEvent javadoc.
>>
>> Regards,
>> Claire
>>
>> Did I get any wrong? or anyway can do that?
>>>
>>> Thanks
>>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312102 is a reply to message #312100] Wed, 31 January 2007 08:10 Go to previous messageGo to next message
Eddie Man is currently offline Eddie ManFriend
Messages: 102
Registered: July 2009
Senior Member
IWorkspace.addResourceChangeListener(listener, IResourceDelta.REMOVED) ?

seems not work


Snjezana Peco wrote:
> You should use IResourceDelta.REMOVED.
> You will get this constante before a file has been deleted or moved.
>
> Snjeza
>
> Eddie Man wrote:
>> But I need to get the contents of the file, so cannot using
>> POST_CHANGE event, any alternative?
>>
>> claire reynaud wrote:
>>> Eddie Man a écrit :
>>>> I had register a IResourceChangeListener to the workspace
>>>> (PRE_DELETE | PRE_CLOSE), but I found that this listener does not
>>>> work for delete a IFile in the navigator view.
>>>
>>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE
>>> are projects events. You should use IResourceChangeEvent.POST_CHANGE
>>> to get notified of a file deletion.
>>> See IResourceChangeEvent javadoc.
>>>
>>> Regards,
>>> Claire
>>>
>>> Did I get any wrong? or anyway can do that?
>>>>
>>>> Thanks
>>>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312108 is a reply to message #312102] Wed, 31 January 2007 10:45 Go to previous messageGo to next message
Snjezana Peco is currently offline Snjezana PecoFriend
Messages: 789
Registered: July 2009
Senior Member
Try the following:
IWorkspace.addResourceChangeListener(listener)
....
public void resourceChanged(IResourceChangeEvent e) {
IResourceDelta delta=e.getDelta();
if (delta.getKind() == IResourceDelta.REMOVED) {
if (IResourceDelta.MOVED_TO & delta.getFlags() == 0) {
// the file is deleted
} else {
// the file is moved
}
}
}

Snjeza

Eddie Man wrote:
> IWorkspace.addResourceChangeListener(listener, IResourceDelta.REMOVED) ?
>
> seems not work
>
>
> Snjezana Peco wrote:
>> You should use IResourceDelta.REMOVED.
>> You will get this constante before a file has been deleted or moved.
>>
>> Snjeza
>>
>> Eddie Man wrote:
>>> But I need to get the contents of the file, so cannot using
>>> POST_CHANGE event, any alternative?
>>>
>>> claire reynaud wrote:
>>>> Eddie Man a écrit :
>>>>> I had register a IResourceChangeListener to the workspace
>>>>> (PRE_DELETE | PRE_CLOSE), but I found that this listener does not
>>>>> work for delete a IFile in the navigator view.
>>>>
>>>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE
>>>> are projects events. You should use IResourceChangeEvent.POST_CHANGE
>>>> to get notified of a file deletion.
>>>> See IResourceChangeEvent javadoc.
>>>>
>>>> Regards,
>>>> Claire
>>>>
>>>> Did I get any wrong? or anyway can do that?
>>>>>
>>>>> Thanks
>>>>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312126 is a reply to message #312099] Wed, 31 January 2007 18:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

There is no event that occurs before deletion of a file.
--

Eddie Man wrote:
> But I need to get the contents of the file, so cannot using POST_CHANGE
> event, any alternative?
>
> claire reynaud wrote:
>
>> Eddie Man a écrit :
>>
>>> I had register a IResourceChangeListener to the workspace (PRE_DELETE
>>> | PRE_CLOSE), but I found that this listener does not work for delete
>>> a IFile in the navigator view.
>>
>>
>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are
>> projects events. You should use IResourceChangeEvent.POST_CHANGE to
>> get notified of a file deletion.
>> See IResourceChangeEvent javadoc.
>>
>> Regards,
>> Claire
>>
>> Did I get any wrong? or anyway can do that?
>>
>>>
>>> Thanks
>>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312263 is a reply to message #312126] Mon, 05 February 2007 19:40 Go to previous messageGo to next message
David Kyle is currently offline David KyleFriend
Messages: 125
Registered: July 2009
Senior Member
Look in Resource#unprotectedDelete(...) to see that the deletion of a
IResource.FILE and IResource.FOLDER do not call a workspace broadcast with a
PRE_DELETE event.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=48291 was filled back in 2003
about this lack of functionality and according to John it will not be fixed.

It is causing us problems since we need to keep files (+1 Terabyte) open and
we need the PRE_DELETE event to know to close the file so it can be deleted
and its editor can be closed.

David

"John Arthorne" <john@eclipsefaq.org> wrote in message
news:epqma1$5eb$2@utils.eclipse.org...
> There is no event that occurs before deletion of a file.
> --
>
> Eddie Man wrote:
> > But I need to get the contents of the file, so cannot using POST_CHANGE
> > event, any alternative?
> >
> > claire reynaud wrote:
> >
> >> Eddie Man a
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312300 is a reply to message #312263] Tue, 06 February 2007 13:41 Go to previous messageGo to next message
Michael Valenta is currently offline Michael ValentaFriend
Messages: 560
Registered: July 2009
Senior Member
David,

The Resource model of Eclipse is optimized for the standard cases you
would get during code development. What you are describing sounds more
like a database that is contained in a file. Do you gain anything by
having your files appear in a workspace project? (i.e. Are they shared
with a code repository? Can users rename a file?). If you are not
getting much benefit from the Resource model, you may want to consider
creating your own model.

If you feel you want to stick with using Workspace projects, you may
want to check out this link and specifically the ResourceChangeValidator.

http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/team_model_model.htm

It won't give you a chance to close the file but it will give you a
chance to warn the user that they either need to close the editor first
or, better yet, run the delete operation that you provide so that all
the necessary cleanup happens.

Michael



David Kyle wrote:
> Look in Resource#unprotectedDelete(...) to see that the deletion of a
> IResource.FILE and IResource.FOLDER do not call a workspace broadcast with a
> PRE_DELETE event.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=48291 was filled back in 2003
> about this lack of functionality and according to John it will not be fixed.
>
> It is causing us problems since we need to keep files (+1 Terabyte) open and
> we need the PRE_DELETE event to know to close the file so it can be deleted
> and its editor can be closed.
>
> David
>
> "John Arthorne" <john@eclipsefaq.org> wrote in message
> news:epqma1$5eb$2@utils.eclipse.org...
>> There is no event that occurs before deletion of a file.
>> --
>>
>> Eddie Man wrote:
>>> But I need to get the contents of the file, so cannot using POST_CHANGE
>>> event, any alternative?
>>>
>>> claire reynaud wrote:
>>>
>>>> Eddie Man a écrit :
>>>>
>>>>> I had register a IResourceChangeListener to the workspace (PRE_DELETE
>>>>> | PRE_CLOSE), but I found that this listener does not work for delete
>>>>> a IFile in the navigator view.
>>>>
>>>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are
>>>> projects events. You should use IResourceChangeEvent.POST_CHANGE to
>>>> get notified of a file deletion.
>>>> See IResourceChangeEvent javadoc.
>>>>
>>>> Regards,
>>>> Claire
>>>>
>>>> Did I get any wrong? or anyway can do that?
>>>>
>>>>> Thanks
>>>>> Eddie
>
>
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312302 is a reply to message #312099] Tue, 06 February 2007 13:44 Go to previous messageGo to next message
Michael Valenta is currently offline Michael ValentaFriend
Messages: 560
Registered: July 2009
Senior Member
Eddie,

In most cases, you can get the previous contents from the local history
(see IFile#getHistory). If you must be guaranteed to have access to the
old contents, then you will have to maintain a cache of the contents
yourself which you can keep up-to-date using resources deltas.

Michael

Eddie Man wrote:
> But I need to get the contents of the file, so cannot using POST_CHANGE
> event, any alternative?
>
> claire reynaud wrote:
>> Eddie Man a écrit :
>>> I had register a IResourceChangeListener to the workspace (PRE_DELETE
>>> | PRE_CLOSE), but I found that this listener does not work for delete
>>> a IFile in the navigator view.
>>
>> IResourceChangeEvent.PRE_CLOSE and IResourceChangeEvent.PRE_DELETE are
>> projects events. You should use IResourceChangeEvent.POST_CHANGE to
>> get notified of a file deletion.
>> See IResourceChangeEvent javadoc.
>>
>> Regards,
>> Claire
>>
>> Did I get any wrong? or anyway can do that?
>>>
>>> Thanks
>>> Eddie
Re: IResourceChangeListener's PRE_DELETE event not work for IFile [message #312322 is a reply to message #312300] Tue, 06 February 2007 16:17 Go to previous message
David Kyle is currently offline David KyleFriend
Messages: 125
Registered: July 2009
Senior Member
Michael,

You are correct in thinking of the seismic file as a database. The files are
produced from a processing engine which can run for hours to weeks at a
time, on one or more CPU clusters (50+ CPUs per cluster). The data is stored
in a "flat" file for performance reasons. No SQL database on earth can
manipulate the data fast enough for us.

http://grus.berkeley.edu/~jrg/ngst/fft/salt.gif

Imagine this image to be 3 meters high and 30 meters wide at 90 DPI. A
seismic file would contain hundreds if not thousands of these slices. We
render any part of the seismic file as fast as the user can hit the keyboard
to switch from one slice to the next, zoom in/out, or scroll about. All in
java. All in Eclipse RCP.

We gain a great deal from having the seismic files in the workspace. It
allows our users to opt out of using our Eclipse RCP based interactive and
deal directly with the NFS files. The typical user workspace contains
numerous projects and thousands of files. We link to a number of high
performance disk farms (usually 11TB or larger). Typical seismic file sizes
are 20 GB with extremely large files in the 800GB to 1 TB. The users also
need to deal with image files (GIF, PNG, JPG), text files, PDF files, etc.

The size and speed at which we have to manipulate the seismic files usually
"break" typical software and hardware systems. We have been impressed with
how little of Eclipse RCP has "broken" under our extreme demands.

In our context, the workspace has nothing to do with traditional java source
code. In fact our users are not programmers but geophysicists.

Aside from the missing PRE_DELETE event on IFile and IFolders we see alot of
benefit from the resource model. It allows us to bring in eclipse and third
party plugins.

David

"Michael Valenta" <Michael_Valenta@ca.ibm.com> wrote in message
news:eqa0gq$sui$1@utils.eclipse.org...
> David,
>
> The Resource model of Eclipse is optimized for the standard cases you
> would get during code development. What you are describing sounds more
> like a database that is contained in a file. Do you gain anything by
> having your files appear in a workspace project? (i.e. Are they shared
> with a code repository? Can users rename a file?). If you are not
> getting much benefit from the Resource model, you may want to consider
> creating your own model.
>
> If you feel you want to stick with using Workspace projects, you may
> want to check out this link and specifically the ResourceChangeValidator.
>
>
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/team_model_model.htm
>
> It won't give you a chance to close the file but it will give you a
> chance to warn the user that they either need to close the editor first
> or, better yet, run the delete operation that you provide so that all
> the necessary cleanup happens.
>
> Michael
>
>
>
> David Kyle wrote:
> > Look in Resource#unprotectedDelete(...) to see that the deletion of a
> > IResource.FILE and IResource.FOLDER do not call a workspace broadcast
with a
> > PRE_DELETE event.
> >
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=48291 was filled back in
2003
> > about this lack of functionality and according to John it will not be
fixed.
> >
> > It is causing us problems since we need to keep files (+1 Terabyte) open
and
> > we need the PRE_DELETE event to know to close the file so it can be
deleted
> > and its editor can be closed.
> >
> > David
> >
> > "John Arthorne" <john@eclipsefaq.org> wrote in message
> > news:epqma1$5eb$2@utils.eclipse.org...
> >> There is no event that occurs before deletion of a file.
> >> --
> >>
> >> Eddie Man wrote:
> >>> But I need to get the contents of the file, so cannot using
POST_CHANGE
> >>> event, any alternative?
> >>>
> >>> claire reynaud wrote:
> >>>
> >>>> Eddie Man a
Previous Topic:IWatchExpressionDelegate thread safe
Next Topic:Drag and Drop to Properties View
Goto Forum:
  


Current Time: Thu Jul 18 06:21:54 GMT 2024

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

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

Back to the top