Skip to main content


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: 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
Previous Topic:how does org.eclipse.jface.text.idocument modify content?
Next Topic:WizardPage depend of previous WizardPages
Goto Forum:
  


Current Time: Thu Apr 18 03:46:46 GMT 2024

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

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

Back to the top