Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Re: Preferences: dependencies of FieldEditors
Re: Preferences: dependencies of FieldEditors [message #467863] Mon, 03 August 2009 08:35 Go to next message
Benjamin Bihler is currently offline Benjamin BihlerFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Remo!


> I solved a similar problem this way:

> RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor("foo", "bar", 1,
> new String[][]{{"Label1", "Value1"}, {"Label2", "Value2"}},
> getFieldEditorParent());
> rgfe.setPropertyChangeListener(new IPropertyChangeListener(){
> public void propertyChange(PropertyChangeEvent event) {
> //paste your code here...
> }
> });

I had already tried this and now I have tried it again: it does not work
here. If I copy and paste your code into my FieldEditorPreferencePage, the
method "propertyChange(...)" is never called! Do you perhaps know the
reason why?


Bye,
Benjamin
Re: Preferences: dependencies of FieldEditors [message #478493 is a reply to message #467863] Thu, 06 August 2009 10:22 Go to previous messageGo to next message
Remo Loetscher is currently offline Remo LoetscherFriend
Messages: 18
Registered: July 2009
Junior Member
In that case I suppose that your own PropertyChangeListener will be
replaced by another listener.
As Javadoc of FieldEditor#setPropertyChangeListener() says:
"Note that field editors can support only a single listener."

Remo


Benjamin Bihler wrote:
> Hi Remo!
>
>
>> I solved a similar problem this way:
>
>> RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor("foo", "bar",
>> 1, new String[][]{{"Label1", "Value1"}, {"Label2", "Value2"}},
>> getFieldEditorParent());
>> rgfe.setPropertyChangeListener(new IPropertyChangeListener(){
>> public void propertyChange(PropertyChangeEvent event) {
>> //paste your code here...
>> }
>> });
>
> I had already tried this and now I have tried it again: it does not work
> here. If I copy and paste your code into my FieldEditorPreferencePage,
> the method "propertyChange(...)" is never called! Do you perhaps know
> the reason why?
>
>
> Bye,
> Benjamin
>
Re: Preferences: dependencies of FieldEditors [message #478540 is a reply to message #467863] Thu, 06 August 2009 10:34 Go to previous messageGo to next message
Remo Loetscher is currently offline Remo LoetscherFriend
Messages: 18
Registered: July 2009
Junior Member
Hi Benajamin,

If you add your fieldeditor in your sublcass of
FieldEditorPreferencePage using the "addField()"-method, the
FieldEditorPreferencePage itself registers as PropertyChangeListener and
overwrites therefore your listener.
If any registered FieldEditor changes its value the method "public void
propertyChange(PropertyChangeEvent event)" of FieldEditorPreferencePage
will be called.
If you override this method in your class, you're able to react on this
change in an appropriate way. e.g. en-/disable fields...

hth,

Remo

Benjamin Bihler wrote:
> Hi Remo!
>
>
>> I solved a similar problem this way:
>
>> RadioGroupFieldEditor rgfe = new RadioGroupFieldEditor("foo", "bar",
>> 1, new String[][]{{"Label1", "Value1"}, {"Label2", "Value2"}},
>> getFieldEditorParent());
>> rgfe.setPropertyChangeListener(new IPropertyChangeListener(){
>> public void propertyChange(PropertyChangeEvent event) {
>> //paste your code here...
>> }
>> });
>
> I had already tried this and now I have tried it again: it does not work
> here. If I copy and paste your code into my FieldEditorPreferencePage,
> the method "propertyChange(...)" is never called! Do you perhaps know
> the reason why?
>
>
> Bye,
> Benjamin
>
Re: Preferences: dependencies of FieldEditors [message #479191 is a reply to message #478540] Mon, 10 August 2009 08:31 Go to previous messageGo to next message
Benjamin Bihler is currently offline Benjamin BihlerFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Remo,


> If you override this method in your class, you're able to react on this
> change in an appropriate way. e.g. en-/disable fields...

I have tried it: you are right! If I override the propertyChange method of
my field editor preference page, I can easily react on user clicks. This
would lead to a much better source code. But there is still one problem
left: initialization! :-( When the values from the preference store are
loaded, the property change method is not called. Also there is no easy
way to query the state of a radio button group (for example in method
"createContents").

https://bugs.eclipse.org/bugs/show_bug.cgi?id=129722

So I did not manage to initialize the preference dependencies correctly
and thus I probably will stick to my version... :-(


Thank you very much and bye,
Benjamin
Re: Preferences: dependencies of FieldEditors [message #479290 is a reply to message #479191] Mon, 10 August 2009 14:58 Go to previous messageGo to next message
Remo Loetscher is currently offline Remo LoetscherFriend
Messages: 18
Registered: July 2009
Junior Member
Hi Benjamin,

If you have created the RadioGroupFieldEditor like the following:

rgfe = new RadioGroupFieldEditor("foo", "bar", 1, new
String[][]{{"Label1", "Value1"}, {"Label2", "Value2"}},
getFieldEditorParent());

you can do your ui state initialization in the "protected void
initialize()"-Method:

@Override
protected void initialize() {
super.initialize();
String selectedButton =
rgfe.getPreferenceStore().getString(rgfe.getPreferenceName() );
}

The selectedButton variable holds either "Value1" or "Value2".

With this information you're able to en-/disable the right part(s).

hth,

Remo

Benjamin Bihler wrote:
> Hi Remo,
>
>
>> If you override this method in your class, you're able to react on
>> this change in an appropriate way. e.g. en-/disable fields...
>
> I have tried it: you are right! If I override the propertyChange method
> of my field editor preference page, I can easily react on user clicks.
> This would lead to a much better source code. But there is still one
> problem left: initialization! :-( When the values from the preference
> store are loaded, the property change method is not called. Also there
> is no easy way to query the state of a radio button group (for example
> in method "createContents").
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=129722
>
> So I did not manage to initialize the preference dependencies correctly
> and thus I probably will stick to my version... :-(
>
>
> Thank you very much and bye,
> Benjamin
>
Re: Preferences: dependencies of FieldEditors [message #479552 is a reply to message #479290] Tue, 11 August 2009 14:18 Go to previous message
Benjamin Bihler is currently offline Benjamin BihlerFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Remo,


thank you very much! My mistake was that I tried to read the preferences
in the method "createContents", but "initialize" would have been the right
choice! Now it works perfectly!


Ciao,
Benjamin
Previous Topic:Modifying
Next Topic:Wait for async
Goto Forum:
  


Current Time: Thu Apr 25 13:22:24 GMT 2024

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

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

Back to the top