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 23:06
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 424
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: Sat Dec 20 06:40:19 GMT 2014

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

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