package org.panlab.software.fstoolkit.preferences;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.panlab.software.fstoolkit.Activator;
/**
* This class represents a preference page that
* is contributed to the Preferences dialog. By
* subclassing <samp>FieldEditorPreferencePage</samp>, 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.
* <p>
* 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 FSToolkitPreferencePage
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {
public FSToolkitPreferencePage() {
super(GRID);
setPreferenceStore(Activator.getDefault().getPreferenceStore());
setDescription("General settings for FSToolkit");
}
/**
* 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() {
// addField( new StringFieldEditor(FSToolkitPreferenceConstants.P_PANLABUSERNAME, "Panlab username:", getFieldEditorParent()));
// addField( new PasswordFieldEditor(FSToolkitPreferenceConstants.P_PANLABPASSWORD, "Panlab password:", getFieldEditorParent()) );
//to insert a table see the class TemplaePreferencepage from plugin org.eclipse.ui.workbench.texteditor
//from packageorg.eclipse.ui.texteditor.templates
// addField(new DirectoryFieldEditor(FSToolkitPreferenceConstants.P_PATH,
// "&Directory preference:", getFieldEditorParent()));
// addField(
// new BooleanFieldEditor(
// FSToolkitPreferenceConstants.P_BOOLEAN,
// "&An example of a boolean preference",
// getFieldEditorParent()));
//
// addField(new RadioGroupFieldEditor(
// FSToolkitPreferenceConstants.P_CHOICE,
// "An example of a multiple-choice preference",
// 1,
// new String[][] { { "&Choice 1", "choice1" }, {
// "C&hoice 2", "choice2" }
// }, getFieldEditorParent()));
// addField(
// new StringFieldEditor(FSToolkitPreferenceConstants.P_STRING, "A &text preference:", getFieldEditorParent()));
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
*/
public void init(IWorkbench workbench) {
}
public class PasswordFieldEditor extends StringFieldEditor {
public PasswordFieldEditor(String name,
String label, Composite parent) {
super(name, label, parent);
}
protected void doFillIntoGrid(Composite parent, int numColumns)
{
// Creates the text control
super.doFillIntoGrid(parent, numColumns);
// Now we can set the echo character
getTextControl().setEchoChar('*');
}
}
}