Bonjour,
je suis en train d'ajouter une page de préférences à mon plug-in. J'étends la classe FieldEditorPreferencePage pour créer ma page.
Pour l'instant ma page ne contient qu'une case à cocher. Sa valeur par défaut est true.
Mon problème est qu'au lancement d'Eclipse avec le plug-in, j'ai l'impression que la valeur de la préférence n'est pas initialisé. Le code suivant renvoit toujours false :
StellentComponentWizardPlugin.getDefault().getPreferenceStore().getBoolean(nom_de_ma_preference)
Par contre, si je modifie la valeur de cette préférence, je récupère bien la bonne valeur. Le problème ne se produit qu'au lancement d'eclipse.
Voici le code de ma classe qui étend FieldEditorPreferencePage :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public class StellentPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public static final String P_COMPLETION_AUTOACTIVATION_BOOLEAN = "fr.tomtom.stellentcomponentwizard.preferences.completionAutoActivationBooleanPreference";
public StellentPreferencePage() {
super(GRID);
setPreferenceStore(StellentComponentWizardPlugin.getDefault().getPreferenceStore());
setDescription(NLS.bind(Messages.UI_PREFERENCES_DESCRIPTION, null));
initializeDefaults();
}
/**
* Sets the default values of the preferences.
*/
private void initializeDefaults() {
IPreferenceStore store = getPreferenceStore();
store.setDefault(P_COMPLETION_AUTOACTIVATION_BOOLEAN, true);
}
/**
* Creates the field editors. Field editors are abstractions of
* the common GUI blocks needed to manipulate various types
* of preferences. Each field editor knows how to save and
* restore itself.
*/
public void createFieldEditors() {
BooleanFieldEditor completionAutoActivationField = new BooleanFieldEditor(
P_COMPLETION_AUTOACTIVATION_BOOLEAN,
NLS.bind(Messages.UI_PREFERENCES_COMPLETION_AUTOACTIVATION_DESCRIPTION, null),
getFieldEditorParent());
this.addField(completionAutoActivationField);
}
public void init(IWorkbench workbench) {
}
} |
Partager