001: /*******************************************************************************
002: * Copyright (c) 2006 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: *******************************************************************************/package org.eclipse.ui.examples.fieldassist.preferences;
011:
012: import org.eclipse.jface.preference.*;
013: import org.eclipse.ui.IWorkbenchPreferencePage;
014: import org.eclipse.ui.IWorkbench;
015: import org.eclipse.ui.examples.fieldassist.FieldAssistPlugin;
016: import org.eclipse.ui.examples.fieldassist.TaskAssistExampleMessages;
017:
018: /**
019: * This class represents a preference page that is contributed to the
020: * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>,
021: * we can use the field support built into JFace that allows us to create a page
022: * that is small and knows how to save, restore and apply itself.
023: * <p>
024: * This page is used to modify preferences only. They are stored in the
025: * preference store that belongs to the main plug-in class. That way,
026: * preferences can be accessed directly via the preference store.
027: */
028:
029: public class ContentAssistPreferencePage extends
030: FieldEditorPreferencePage implements IWorkbenchPreferencePage {
031:
032: /**
033: * Create a ContentAssistPreferencePage
034: */
035: public ContentAssistPreferencePage() {
036: super (GRID);
037: setPreferenceStore(FieldAssistPlugin.getDefault()
038: .getPreferenceStore());
039: setDescription(TaskAssistExampleMessages.Preferences_ContentAssistDescription);
040: }
041:
042: /**
043: * Creates the field editors. Field editors are abstractions of the common
044: * GUI blocks needed to manipulate various types of preferences. Each field
045: * editor knows how to save and
046: */
047: public void createFieldEditors() {
048: addField(new RadioGroupFieldEditor(
049: PreferenceConstants.PREF_CONTENTASSISTKEY,
050: TaskAssistExampleMessages.Preferences_ContentAssistKey,
051: 1,
052: new String[][] {
053: {
054: PreferenceConstants.PREF_CONTENTASSISTKEY1,
055: PreferenceConstants.PREF_CONTENTASSISTKEY1 },
056: {
057: PreferenceConstants.PREF_CONTENTASSISTKEY2,
058: PreferenceConstants.PREF_CONTENTASSISTKEY2 },
059: {
060: PreferenceConstants.PREF_CONTENTASSISTKEYAUTO,
061: PreferenceConstants.PREF_CONTENTASSISTKEYAUTO },
062: {
063: PreferenceConstants.PREF_CONTENTASSISTKEYAUTOSUBSET,
064: PreferenceConstants.PREF_CONTENTASSISTKEYAUTOSUBSET }, },
065: getFieldEditorParent()));
066:
067: IntegerFieldEditor editor = new IntegerFieldEditor(
068: PreferenceConstants.PREF_CONTENTASSISTDELAY,
069: TaskAssistExampleMessages.Preferences_ContentAssistDelay,
070: getFieldEditorParent());
071: editor.setValidRange(0, 10000);
072: addField(editor);
073:
074: addField(new BooleanFieldEditor(
075: PreferenceConstants.PREF_CONTENTASSISTKEY_PROPAGATE,
076: TaskAssistExampleMessages.Preferences_ContentAssistKeyPropagate,
077: getFieldEditorParent()));
078:
079: addField(new BooleanFieldEditor(
080: PreferenceConstants.PREF_SHOWSECONDARYPOPUP,
081: TaskAssistExampleMessages.Preferences_ShowSecondaryPopup,
082: getFieldEditorParent()));
083:
084: addField(new RadioGroupFieldEditor(
085: PreferenceConstants.PREF_CONTENTASSISTRESULT,
086: TaskAssistExampleMessages.Preferences_ContentAssistResult,
087: 1,
088: new String[][] {
089: {
090: TaskAssistExampleMessages.Preferences_ContentAssistResultReplace,
091: PreferenceConstants.PREF_CONTENTASSISTRESULT_REPLACE },
092: {
093: TaskAssistExampleMessages.Preferences_ContentAssistResultInsert,
094: PreferenceConstants.PREF_CONTENTASSISTRESULT_INSERT },
095: {
096: TaskAssistExampleMessages.Preferences_ContentAssistResultNone,
097: PreferenceConstants.PREF_CONTENTASSISTRESULT_NONE } },
098: getFieldEditorParent()));
099:
100: addField(new RadioGroupFieldEditor(
101: PreferenceConstants.PREF_CONTENTASSISTFILTER,
102: TaskAssistExampleMessages.Preferences_ContentAssistFilter,
103: 1,
104: new String[][] {
105: {
106: TaskAssistExampleMessages.Preferences_ContentAssistFilterCharacter,
107: PreferenceConstants.PREF_CONTENTASSISTFILTER_CHAR },
108: {
109: TaskAssistExampleMessages.Preferences_ContentAssistFilterCumulative,
110: PreferenceConstants.PREF_CONTENTASSISTFILTER_CUMULATIVE },
111: {
112: TaskAssistExampleMessages.Preferences_ContentAssistFilterNone,
113: PreferenceConstants.PREF_CONTENTASSISTFILTER_NONE } },
114: getFieldEditorParent()));
115:
116: }
117:
118: /*
119: * (non-Javadoc)
120: *
121: * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
122: */
123: public void init(IWorkbench workbench) {
124: }
125:
126: }
|