|
|
Re: Monitoring changes to JDT project-specific settings [message #1006743 is a reply to message #1006189] |
Fri, 01 February 2013 16:26 |
Eric Rizzo Messages: 3070 Registered: July 2009 |
Senior Member |
|
|
Dani Megert wrote on Wed, 30 January 2013 06:51
> On 29.01.2013 17:28, Eric Rizzo wrote:
> > I posed this question to the Platform forum yesterday, but I think it
> > might be more precisely directed here.
> >
> > How can I listen for changes to project properties (ie, things that
> > are changes in a project's Properties dialog pages)? I know that
> > IPreferenceStore allows me to register a property change listener, but
> > I don't know how to get a hold of the preference store for a
> > particular project. Specifically, I'm writing a custom PropertyPage
> > that needs to respond to changes in the various JDT property pages. I
> > don't see an obvious hook into the availability of the project's
> > preference store during the lifecycle of my own PropertyPage.
>
> Since those property pages are per-project you also need to create
> project scopes and then attach the listeners there, e.g.
> IEclipsePreferences node= new
> ProjectScope(yourProjec).getNode(JavaCore.PLUGIN_ID);
> node.addPreferenceChangeListener(anIPreferenceChangeListener);
>
> Note that some of the JDT properties come from JDT Core and some from
> JDT UI.
>
> Dani
> >
Thanks, Dani. That helps a lot.
However, it seems that PropertyPage objects are created lazily by the Properties dialog, so my page's setElement() (from where I know which IProject to use for the scope) isn't called until/unless my page is selected by the user. So I can't rely on registering the listener there (if user opens the dialog but doesn't click on my property page, it wouldn't be registered to receive the events). Where should I be adding this listener so that it is guaranteed to be listening even if my page isn't ever viewed?
Thanks again,
Eric
|
|
|
Re: Monitoring changes to JDT project-specific settings [message #1007072 is a reply to message #1006743] |
Mon, 04 February 2013 10:46 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
On 01.02.2013 17:26, Eric Rizzo wrote:
> Dani Megert wrote on Wed, 30 January 2013 06:51
>> On 29.01.2013 17:28, Eric Rizzo wrote:
>> > I posed this question to the Platform forum yesterday, but I think
>> it > might be more precisely directed here.
>> >
>> > How can I listen for changes to project properties (ie, things that
>> > are changes in a project's Properties dialog pages)? I know that >
>> IPreferenceStore allows me to register a property change listener,
>> but > I don't know how to get a hold of the preference store for a >
>> particular project. Specifically, I'm writing a custom PropertyPage >
>> that needs to respond to changes in the various JDT property pages. I
>> > don't see an obvious hook into the availability of the project's >
>> preference store during the lifecycle of my own PropertyPage.
>>
>> Since those property pages are per-project you also need to create
>> project scopes and then attach the listeners there, e.g.
>> IEclipsePreferences node= new
>> ProjectScope(yourProjec).getNode(JavaCore.PLUGIN_ID);
>> node.addPreferenceChangeListener(anIPreferenceChangeListener);
>>
>> Note that some of the JDT properties come from JDT Core and some from
>> JDT UI.
>>
>> Dani
>> >
>
> Thanks, Dani. That helps a lot.
> However, it seems that PropertyPage objects are created lazily by the
> Properties dialog, so my page's setElement() (from where I know which
> IProject to use for the scope) isn't called until/unless my page is
> selected by the user. So I can't rely on registering the listener
> there (if user opens the dialog but doesn't click on my property page,
> it wouldn't be registered to receive the events). Where should I be
> adding this listener so that it is guaranteed to be listening even if
> my page isn't ever viewed?
It depends what area of your app is interested in the changes. If it is
e.g. a view, then I'd add it when the view gets opened and remove it on
dispose. If that is not enough, you might want to add the listeners when
your plug-in starts.
Dani
>
> Thanks again,
> Eric
>
>
|
|
|
Re: Monitoring changes to JDT project-specific settings [message #1007137 is a reply to message #1007072] |
Mon, 04 February 2013 15:23 |
Eric Rizzo Messages: 3070 Registered: July 2009 |
Senior Member |
|
|
Dani Megert wrote on Mon, 04 February 2013 05:46On 01.02.2013 17:26, Eric Rizzo wrote:
> Thanks, Dani. That helps a lot.
> However, it seems that PropertyPage objects are created lazily by the
> Properties dialog, so my page's setElement() (from where I know which
> IProject to use for the scope) isn't called until/unless my page is
> selected by the user. So I can't rely on registering the listener
> there (if user opens the dialog but doesn't click on my property page,
> it wouldn't be registered to receive the events). Where should I be
> adding this listener so that it is guaranteed to be listening even if
> my page isn't ever viewed?
It depends what area of your app is interested in the changes. If it is
e.g. a view, then I'd add it when the view gets opened and remove it on
dispose. If that is not enough, you might want to add the listeners when
your plug-in starts.
Dani
It's a new PropertyPage that I'm creating. That's my challenge, it isn't created until it's actually selected by the user. I suppose I could have the listener created/added in my plugin's activator, although with lazy activation I'm not sure that will even happen until my PluginPage is selected/shown.
|
|
|
Powered by
FUDForum. Page generated in 0.03970 seconds