FieldEditorPreferencePage/Fieldeditor usage. [message #902307] |
Thu, 16 August 2012 23:06 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
I'm trying to use FieldEditorPreferencePage and FieldEditors in a Jface/SWT pure environment (no org.eclipse.ui.*).
I've a lot of problems using setPropertyChange() and I tracked down it to the fact FieldEditorPreferencePage.initialize() flatly tromps FieldEditor.propertyChangeListener (in spite of what comments onFieldEditorPreferencePage.propertyChange() say) and I've found no way around (short of copying everything and modifying source).
Also field contents in the pages is very ugly (no justification of field editors).
My code is along the lines:
public class DocEditorPreferencePage extends FieldEditorPreferencePage {
public DocEditorPreferencePage() {
super(FLAT);
}
@Override
protected void createFieldEditors() {
// Create the field editors
{
ColorFieldEditor cfeForeground = new ColorFieldEditor(DocEditor.PREFERENCE_COLOR_FOREGROUND, "Foreground color:", getFieldEditorParent());
cfeForeground.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
getPreferenceStore().setValue(DocEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
}
});
addField(cfeForeground);
}
{
ColorFieldEditor cfeBackground = new ColorFieldEditor(DocEditor.PREFERENCE_COLOR_BACKGROUND, "Background color:", getFieldEditorParent());
cfeBackground.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
getPreferenceStore().setValue(DocEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
}
});
addField(cfeBackground);
}
...
}
public void init() {
// Initialize the preference page
IPreferenceStore store = getPreferenceStore();
// ----------- foreground color --------------------
store.setValue(DocEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
store.putValue(DocEditor.PREFERENCE_COLOR_FOREGROUND, null);
// ---------- background color ----------------------
store.setValue(DocEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true);
store.putValue(DocEditor.PREFERENCE_COLOR_BACKGROUND, null);
...
}
}
What am I missing?
TiA
Mauro
|
|
|
Powered by
FUDForum. Page generated in 0.01866 seconds