Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » FieldEditorPreferencePage/Fieldeditor usage.
FieldEditorPreferencePage/Fieldeditor usage. [message #902307] Thu, 16 August 2012 19:06
Mauro Condarelli is currently offline Mauro Condarelli
Messages: 397
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
Previous Topic:please delete this
Next Topic:how does org.eclipse.jface.text.idocument modify content?
Goto Forum:
  


Current Time: Wed Apr 23 19:55:31 EDT 2014

Powered by FUDForum. Page generated in 0.01661 seconds