I created one ComboFieldEditor
in my code and I want to get the value before storing it in the Preference store. In the case of StringFieldEditor
there is one method like getStringValue()
. But in the case of ComboFieldEditor
, there is no such method.So How can I get those values which I gave and use them?
Asked
Active
Viewed 1,106 times
3

Stijn Geukens
- 15,454
- 8
- 66
- 101

Anu
- 405
- 1
- 4
- 16
2 Answers
2
@codejammer - your (first) solution doesn't work for me for some reason (most probably because FieldEditorPreferencePage sets himself as listener).
So my solution is that if your preference page class extends FieldEditorPreferencePage you can override propertyChange function (don't forget to execute this function from superclass). In propertyChange I can check from which field comes event (PropertyChangeEvent.getSource()) and then get new value (PropertyChangeEvent.getNewValue()).
@Override
public void propertyChange(PropertyChangeEvent event) {
super.propertyChange(event);
if(event.getSource() == myCombo){
//do your stuff here, or store new value in variable
System.out.println(event.getNewValue());
}
}

tomekK
- 748
- 8
- 19
-
Thank you so much! I was already considering to use a Combo and do all the storing and loading stuff by myself. codejammer’s solution also does not work for me. – bugybunny Jul 08 '15 at 15:11
2
combofieldeditor.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
System.out.print(event.getNewValue());
}
});
The getNewValue will provide you the user selected value. Alternately you can call store and read from the preference store.

codejammer
- 1,636
- 1
- 14
- 27