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 |
Benjamin Bihler 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 |
Remo Loetscher 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 |
Remo Loetscher 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 #479290 is a reply to message #479191] |
Mon, 10 August 2009 14:58 |
Remo Loetscher 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
>
|
|
| |
Goto Forum:
Current Time: Wed Feb 05 06:05:10 GMT 2025
Powered by FUDForum. Page generated in 0.03730 seconds
|