Home » Eclipse Projects » Eclipse Platform » how to trap eclipse save action
how to trap eclipse save action [message #97495] |
Tue, 22 July 2003 12:55  |
Eclipse User |
|
|
|
Originally posted by: bhaskar.calavista.com
Hi All,
Is there any way of trapping Eclipse save action (when user clicks on
the Save button on the toolbar).
Thanks,
Bhaskar
|
|
| | | |
Re: how to trap eclipse save action [message #97656 is a reply to message #97597] |
Tue, 22 July 2003 16:52   |
Eclipse User |
|
|
|
Originally posted by: bhaskar.calavista.com
Rich,
Thanks for the response. I already had read that article and my
redecoration is very similar to that explained in that article.
I am also using IWorkspace.addResourceChangeListener() but having
two problems:
1) It tells me about every change going in the workspace. Since I am only
interested in save events, is there any way of getting only this
informatiom through IWorkspace.addResourceChangeListener().
2) I was unable to get the name of the resource on which changes happened.
Everytime I used IResourceChangedEvent getResoource() method, I got null
in return.
What do u specifically mean by not adding my resource change listener
as a startup Plugin. Does that mean that I should not use my startup()
method of my main plugin class (CtkPlugin.java in my case) for registering
resource change listener class? If yes, then how will I get to know about
the changes?
One more problem....when I am using my decorators, every time some
decoration changes, the changes are not seen in the workspace. Only when
I again click on OK or apply in Windows>Preferences>Workbench>Label
decoration the changes appears on the workspace. Again, I have tried my
best to remain close to the methods described in the above mentioned
article. what could be wrong??
Thanks,
Bhaskar
Richard L. Kulp wrote:
> Read this:
> http://www.eclipsecorner.org/articles/Article-Decorators/dec orators.html
> Pay attention to Redecorate section, also to listen for changes, use
> IWorkspace.addResourceChangeListener(). Remember to remove yourself when
> no longer needed.
> Also don't add yourself as a startup plugin (you may think this is
> necessary so that you can add yourself as a resource change listener,
> but if you are using the decorators correctly you will be started when
> necessary and can add yourself at that time).
> Rich
|
|
|
Re: how to trap eclipse save action [message #97730 is a reply to message #97656] |
Tue, 22 July 2003 19:10   |
Eclipse User |
|
|
|
Originally posted by: richkulp.NOSPAM.us.ibm.com
Bhaskar wrote:
> Rich,
> Thanks for the response. I already had read that article and my
> redecoration is very similar to that explained in that article.
> I am also using IWorkspace.addResourceChangeListener() but having
> two problems:
> 1) It tells me about every change going in the workspace. Since I am only
> interested in save events, is there any way of getting only this
> information through IWorkspace.addResourceChangeListener().
No, you can only specify notification during certain phases, such as
PRE_AUTO_BUILD or POST_CHANGE. You are probably most interested in
POST_BUILD. That way you won't get Close notifications. But you would be
interested in Adds (because this is then either a new resource or the
resource has been moved somewhere else, in either case you would want to
change the decoration, no?).
Really, how you process resource change events is complicated. See this:
http://www.eclipsecorner.org/articles/Article-Resource-delta s/resource-deltas.html
> 2) I was unable to get the name of the resource on which changes happened.
> Every time I used IResourceChangedEvent getResoource() method, I got null
> in return.
>
> What do u specifically mean by not adding my resource change listener
> as a startup Plugin. Does that mean that I should not use my startup()
> method of my main plugin class (CtkPlugin.java in my case) for registering
> resource change listener class? If yes, then how will I get to know about
> the changes?
I meant don't use the startup extension point in the plugin.xml. This
extension point forces your plugin to be activated immediately on
startup of the entire workbench. You don't want to do that. Let Eclipse
determine that it is time to be activated.
You should still use your startup() method to listen to resource
changes, but your plugin won't be activated until necessary. And the
decoration mechanism can determine when to activate for you.
>
> One more problem....when I am using my decorators, every time some
> decoration changes, the changes are not seen in the workspace. Only when
> I again click on OK or apply in Windows>Preferences>Workbench>Label
> decoration the changes appears on the workspace. Again, I have tried my
> best to remain close to the methods described in the above mentioned
> article. what could be wrong??
As shown in the article, your label decorator (which should be
light-weight decorator registered with workbench as I think yours is),
needs to fire a label change event whenever a resource needs to be
redecorated. Take a close look at the Redecorates section of the
article. You resource listener needs to fire this refresh against your
decorator when the resource changes. As in the example, there is an
exposed public method that says refresh(List). The List is a list of the
IResource's that have changed and need new decorations.
>
> Thanks,
> Bhaskar
>
> Richard L. Kulp wrote:
>
>
>>Read this:
>
>
>> http://www.eclipsecorner.org/articles/Article-Decorators/dec orators.html
>
>
>>Pay attention to Redecorate section, also to listen for changes, use
>>IWorkspace.addResourceChangeListener(). Remember to remove yourself when
>>no longer needed.
>
>
>>Also don't add yourself as a startup plugin (you may think this is
>>necessary so that you can add yourself as a resource change listener,
>>but if you are using the decorators correctly you will be started when
>>necessary and can add yourself at that time).
>
>
>>Rich
>
>
>
--
Thanks, Rich Kulp
|
|
|
Re: how to trap eclipse save action [message #97757 is a reply to message #97730] |
Tue, 22 July 2003 19:32   |
Eclipse User |
|
|
|
Originally posted by: bhaskar.calavista.com
Rich,
Thanks for the detailed reply. I just tried the POST_AUTO_BUILD of
IResourceChangeEvent Interface. Yes it is telling me the modifications of
the workspace but it is still not telling the name of the resource that
has been modified. I tried event.getResource().getName() but I am getting
a null pointer Exception (same is the problem with POST_CHANGE). Is there
any way of getting the resource name?
I will try ur decorators suggestions soon.
Thanks,
Bhaskar
Richard L. Kulp wrote:
> Bhaskar wrote:
> > Rich,
> > Thanks for the response. I already had read that article and my
> > redecoration is very similar to that explained in that article.
> > I am also using IWorkspace.addResourceChangeListener() but having
> > two problems:
> > 1) It tells me about every change going in the workspace. Since I am only
> > interested in save events, is there any way of getting only this
> > information through IWorkspace.addResourceChangeListener().
> No, you can only specify notification during certain phases, such as
> PRE_AUTO_BUILD or POST_CHANGE. You are probably most interested in
> POST_BUILD. That way you won't get Close notifications. But you would be
> interested in Adds (because this is then either a new resource or the
> resource has been moved somewhere else, in either case you would want to
> change the decoration, no?).
> Really, how you process resource change events is complicated. See this:
>
http://www.eclipsecorner.org/articles/Article-Resource-delta s/resource-deltas.html
> > 2) I was unable to get the name of the resource on which changes happened.
> > Every time I used IResourceChangedEvent getResoource() method, I got null
> > in return.
> >
> > What do u specifically mean by not adding my resource change listener
> > as a startup Plugin. Does that mean that I should not use my startup()
> > method of my main plugin class (CtkPlugin.java in my case) for registering
> > resource change listener class? If yes, then how will I get to know about
> > the changes?
> I meant don't use the startup extension point in the plugin.xml. This
> extension point forces your plugin to be activated immediately on
> startup of the entire workbench. You don't want to do that. Let Eclipse
> determine that it is time to be activated.
> You should still use your startup() method to listen to resource
> changes, but your plugin won't be activated until necessary. And the
> decoration mechanism can determine when to activate for you.
> >
> > One more problem....when I am using my decorators, every time some
> > decoration changes, the changes are not seen in the workspace. Only when
> > I again click on OK or apply in Windows>Preferences>Workbench>Label
> > decoration the changes appears on the workspace. Again, I have tried my
> > best to remain close to the methods described in the above mentioned
> > article. what could be wrong??
> As shown in the article, your label decorator (which should be
> light-weight decorator registered with workbench as I think yours is),
> needs to fire a label change event whenever a resource needs to be
> redecorated. Take a close look at the Redecorates section of the
> article. You resource listener needs to fire this refresh against your
> decorator when the resource changes. As in the example, there is an
> exposed public method that says refresh(List). The List is a list of the
> IResource's that have changed and need new decorations.
> >
> > Thanks,
> > Bhaskar
|
|
|
Re: how to trap eclipse save action [message #97921 is a reply to message #97757] |
Wed, 23 July 2003 02:19   |
Eclipse User |
|
|
|
Originally posted by: bhaskar.calavista.com
Rich,
I just read
http://www.eclipsecorner.org/articles/Article-Resource-delta s/resource-deltas.html
article. I am pretty sure that now I will be able to get the modified
resources (although I have not tried it yet). Thanks for it. Regarding
decorator thing, I am not implementing light weight decorators. Should I
do this to solve my problem. My problem was :
"when I am using my decorators, every time some decoration changes, the
changes are not seen in the workspace. Only when I again click on OK or
apply in Windows>Preferences>Workbench>Label decoration the changes
appears on the workspace. Again, I have tried my best to remain close to
the methods described in the above mentioned article. what could be
wrong??"
Ur response was:
> > As shown in the article, your label decorator (which should be
> > light-weight decorator registered with workbench as I think yours is),
> > needs to fire a label change event whenever a resource needs to be
> > redecorated. Take a close look at the Redecorates section of the
> > article. You resource listener needs to fire this refresh against your
> > decorator when the resource changes. As in the example, there is an
> > exposed public method that says refresh(List). The List is a list of the
> > IResource's that have changed and need new decorations.
right now I am refresing every resource (not the changed resource only). I
don't think that this could be the problem although it is pretty
inefficient. My refresh method is calling another method which fires the
refresh. But this firing, somehow, is unheard by DecorateImage() method.
How can this happen. Again eveything is similar to the example given in
decorators article.
Thanks once again for all ur responses.
Bhaskar
Bhaskar wrote:
> Rich,
> Thanks for the detailed reply. I just tried the POST_AUTO_BUILD of
> IResourceChangeEvent Interface. Yes it is telling me the modifications of
> the workspace but it is still not telling the name of the resource that
> has been modified. I tried event.getResource().getName() but I am getting
> a null pointer Exception (same is the problem with POST_CHANGE). Is there
> any way of getting the resource name?
> I will try ur decorators suggestions soon.
> Thanks,
> Bhaskar
|
|
| |
Re: how to trap eclipse save action [message #98530 is a reply to message #98456] |
Wed, 23 July 2003 11:57  |
Eclipse User |
|
|
|
Originally posted by: bhaskar.calavista.com
Rich,
Sorry to say but I have already tried that DemoDecorator example given in
that article :-) . Anyways, thanks for taking out time for responding me.
I hope I should be able to do it today.
Thanks,
Bhaskar
Richard L. Kulp wrote:
> You've reached the limit of my understanding. :-)
> I've never actually implemented the decorators using the Eclipse
> decorator manager. Maybe you should try the demo from the decorators
> sample article and understand how that one works. Then it may give you
> clues as to why yours isn't working.
> Rich
|
|
|
Goto Forum:
Current Time: Fri Jun 20 18:01:54 EDT 2025
Powered by FUDForum. Page generated in 0.19175 seconds
|