001: /*******************************************************************************
002: * Copyright (c) 2006, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: * Sebastian Davids <sdavids@gmx.de> - bug 132479 - [FieldAssist] Field assist example improvements
011: *******************************************************************************/package org.eclipse.ui.examples.fieldassist.preferences;
012:
013: import org.eclipse.jface.dialogs.Dialog;
014: import org.eclipse.jface.preference.*;
015: import org.eclipse.swt.SWT;
016: import org.eclipse.swt.widgets.Label;
017: import org.eclipse.ui.IWorkbenchPreferencePage;
018: import org.eclipse.ui.IWorkbench;
019: import org.eclipse.ui.examples.fieldassist.FieldAssistPlugin;
020: import org.eclipse.ui.examples.fieldassist.TaskAssistExampleMessages;
021:
022: /**
023: * This class represents a preference page that is contributed to the
024: * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>,
025: * we can use the field support built into JFace that allows us to create a page
026: * that is small and knows how to save, restore and apply itself.
027: * <p>
028: * This page is used to modify preferences only. They are stored in the
029: * preference store that belongs to the main plug-in class. That way,
030: * preferences can be accessed directly via the preference store.
031: */
032:
033: public class FieldAssistPreferencePage extends
034: FieldEditorPreferencePage implements IWorkbenchPreferencePage {
035:
036: /**
037: * Create the FieldAssistPreferencePage
038: */
039: public FieldAssistPreferencePage() {
040: super (GRID);
041: setPreferenceStore(FieldAssistPlugin.getDefault()
042: .getPreferenceStore());
043: setDescription(TaskAssistExampleMessages.Preferences_Description);
044: }
045:
046: /**
047: * Creates the field editors. Field editors are abstractions of the common
048: * GUI blocks needed to manipulate various types of preferences. Each field
049: * editor knows how to save and
050: */
051: public void createFieldEditors() {
052: addField(new RadioGroupFieldEditor(
053: PreferenceConstants.PREF_DECORATOR_VERTICALLOCATION,
054: TaskAssistExampleMessages.Preferences_DecoratorVert,
055: 1,
056: new String[][] {
057: {
058: TaskAssistExampleMessages.Preferences_DecoratorTop,
059: PreferenceConstants.PREF_DECORATOR_VERTICALLOCATION_TOP },
060: {
061: TaskAssistExampleMessages.Preferences_DecoratorCenter,
062: PreferenceConstants.PREF_DECORATOR_VERTICALLOCATION_CENTER },
063: {
064: TaskAssistExampleMessages.Preferences_DecoratorBottom,
065: PreferenceConstants.PREF_DECORATOR_VERTICALLOCATION_BOTTOM } },
066: getFieldEditorParent()));
067:
068: addField(new RadioGroupFieldEditor(
069: PreferenceConstants.PREF_DECORATOR_HORIZONTALLOCATION,
070: TaskAssistExampleMessages.Preferences_DecoratorHorz,
071: 1,
072: new String[][] {
073: {
074: TaskAssistExampleMessages.Preferences_DecoratorLeft,
075: PreferenceConstants.PREF_DECORATOR_HORIZONTALLOCATION_LEFT },
076: {
077: TaskAssistExampleMessages.Preferences_DecoratorRight,
078: PreferenceConstants.PREF_DECORATOR_HORIZONTALLOCATION_RIGHT } },
079: getFieldEditorParent()));
080:
081: IntegerFieldEditor editor = new IntegerFieldEditor(
082: PreferenceConstants.PREF_DECORATOR_MARGINWIDTH,
083: TaskAssistExampleMessages.Preferences_DecoratorMargin,
084: getFieldEditorParent());
085: editor.setValidRange(0, 10);
086: addField(editor);
087:
088: Label label = new Label(getFieldEditorParent(), SWT.WRAP);
089: label
090: .setText(TaskAssistExampleMessages.Preferences_ErrorIndicator);
091: addField(new BooleanFieldEditor(
092: PreferenceConstants.PREF_SHOWERRORMESSAGE,
093: TaskAssistExampleMessages.Preferences_ShowErrorMessage,
094: getFieldEditorParent()));
095:
096: addField(new BooleanFieldEditor(
097: PreferenceConstants.PREF_SHOWERRORDECORATION,
098: TaskAssistExampleMessages.Preferences_ShowErrorDecorator,
099: getFieldEditorParent()));
100:
101: label = new Label(getFieldEditorParent(), SWT.WRAP);
102: label
103: .setText(TaskAssistExampleMessages.Preferences_RequiredFieldIndicator);
104: addField(new BooleanFieldEditor(
105: PreferenceConstants.PREF_SHOWREQUIREDFIELDLABELINDICATOR,
106: TaskAssistExampleMessages.Preferences_ShowRequiredFieldLabelIndicator,
107: getFieldEditorParent()));
108:
109: addField(new BooleanFieldEditor(
110: PreferenceConstants.PREF_SHOWREQUIREDFIELDDECORATION,
111: TaskAssistExampleMessages.Preferences_ShowRequiredFieldDecorator,
112: getFieldEditorParent()));
113:
114: label = new Label(getFieldEditorParent(), SWT.WRAP);
115: label
116: .setText(TaskAssistExampleMessages.Preferences_DecoratorDetails);
117: addField(new BooleanFieldEditor(
118: PreferenceConstants.PREF_SHOWWARNINGDECORATION,
119: TaskAssistExampleMessages.Preferences_ShowWarningDecorator,
120: getFieldEditorParent()));
121: addField(new BooleanFieldEditor(
122: PreferenceConstants.PREF_SHOWCONTENTPROPOSALCUE,
123: TaskAssistExampleMessages.Preferences_ShowProposalCue,
124: getFieldEditorParent()));
125:
126: Dialog.applyDialogFont(getFieldEditorParent());
127: }
128:
129: /*
130: * (non-Javadoc)
131: *
132: * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
133: */
134: public void init(IWorkbench workbench) {
135: }
136:
137: }
|