package org.eparapher.rcp.preferences; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.jface.preference.PathEditor; import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eparapher.core.EParapherManager; import org.eparapher.rcp.Activator; import org.eparapher.rcp.EPReferences; /** * This class represents a preference page that * is contributed to the Preferences dialog. By * subclassing FieldEditorPreferencePage, we * can use the field support built into JFace that allows * us to create a page that is small and knows how to * save, restore and apply itself. *
* This page is used to modify preferences only. They * are stored in the preference store that belongs to * the main plug-in class. That way, preferences can * be accessed directly via the preference store. */ public class EParapherPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { private static Logger log = Logger.getLogger(EParapherPreferencePage.class); public static final String ID = "org.eparapher.rcp.preferences.EParapherPreferencePage"; private final static String[][] LoglevelFamilies = { { "OFF", Level.OFF.toString() }, { "FATAL", Level.FATAL.toString() }, { "ERROR", Level.ERROR.toString() }, { "WARNING", Level.WARN.toString() }, { "INFO", Level.INFO.toString() }, { "DEBUG", Level.DEBUG.toString() }, { "ALL", Level.ALL.toString() } }; PathEditor localdocspath; FileFieldEditor localpsafepath; RadioGroupFieldEditor loglevel; public EParapherPreferencePage() { super(GRID); setPreferenceStore(Activator.getDefault().getPreferenceStore()); setDescription("eParapher Configuration"); } /** * 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() { localdocspath = new PathEditor(PreferenceConstants.P_LOCALDOCPATH, "&Local documents Directories :", "Choose a Path", getFieldEditorParent()); addField(localdocspath); //localpsafepath = new FileFieldEditor( PreferenceConstants.P_LOCALPSAFEPATH, "&Local Personal Safe :", getFieldEditorParent()); //localpsafepath.setEnabled(false, getFieldEditorParent()); //localpsafepath.setStringValue("Not implemented yet"); //addField(localpsafepath); loglevel = new RadioGroupFieldEditor( PreferenceConstants.P_LOGLEVEL,"&eParapher Log level : ", 7, LoglevelFamilies, getFieldEditorParent(), true); addField(loglevel); } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { } public boolean performOk() { //First, save properties boolean save = super.performOk(); //Hot reset for Log4J EParapherManager.setLogLevel(EParapherManager.getInstance().getSettings().getEPLogLevel()); //Refresh document view if (EPReferences.getInstance().getDocviews()!=null) EPReferences.getInstance().getDocviews().refreshView(); return save; } }