2 * Copyright (c) 2003-2004 Christopher Lenz and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Christopher Lenz - initial API and implementation
11 * $Id: CssEditorPreferencePage.java,v 1.1 2004-09-02 18:11:50 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.ui.internal.preferences;
16 import java.util.Iterator;
18 import net.sourceforge.phpeclipse.css.ui.CssUI;
19 import net.sourceforge.phpeclipse.css.ui.internal.CssUIMessages;
20 import net.sourceforge.phpeclipse.css.ui.internal.CssUIPreferences;
22 import org.eclipse.jface.preference.PreferencePage;
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Control;
26 import org.eclipse.swt.widgets.TabFolder;
27 import org.eclipse.swt.widgets.TabItem;
28 import org.eclipse.ui.IWorkbench;
29 import org.eclipse.ui.IWorkbenchPreferencePage;
30 import org.eclipse.ui.texteditor.AnnotationPreference;
31 import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
34 * Implements the CSS editor preference page.
36 public class CssEditorPreferencePage extends PreferencePage
37 implements IWorkbenchPreferencePage {
39 // Instance Variables ------------------------------------------------------
41 private OverlayPreferenceStore overlayStore;
43 private CssEditorAppearanceConfigurationBlock appearanceBlock;
44 private CssEditorSyntaxConfigurationBlock syntaxBlock;
45 private CssEditorContentAssistConfigurationBlock contentAssistBlock;
46 private CssEditorAnnotationsConfigurationBlock annotationsBlock;
47 private CssEditorTypingConfigurationBlock typingBlock;
49 // PreferencePage Implementation -------------------------------------------
52 * @see PreferencePage#createContents(Composite)
54 protected Control createContents(Composite parent) {
56 TabFolder folder = new TabFolder(parent, SWT.NONE);
59 item = new TabItem(folder, SWT.NONE);
60 item.setText(getString("appearance")); //$NON-NLS-1$
61 item.setControl(createAppearancePage(folder));
63 item = new TabItem(folder, SWT.NONE);
64 item.setText(getString("syntax")); //$NON-NLS-1$
65 item.setControl(createSyntaxPage(folder));
67 item = new TabItem(folder, SWT.NONE);
68 item.setText(getString("contentAssist")); //$NON-NLS-1$
69 item.setControl(createCodeAssistPage(folder));
71 item = new TabItem(folder, SWT.NONE);
72 item.setText(getString("annotations")); //$NON-NLS-1$
73 item.setControl(createAnnotationsPage(folder));
75 item = new TabItem(folder, SWT.NONE);
76 item.setText(getString("typing")); //$NON-NLS-1$
77 item.setControl(createTypingPage(folder));
83 * @see PreferencePage#dispose()
85 public void dispose() {
86 if (overlayStore != null) {
87 overlayStore.stopListening();
94 * @see PreferencePage#performOk()
96 public boolean performOk() {
97 overlayStore.propagate();
98 CssUI.getDefault().savePluginPreferences();
103 * @see PreferencePage#performDefaults()
105 protected void performDefaults() {
106 overlayStore.loadDefaults();
107 super.performDefaults();
110 // IWorkbenchPreferencePage Implementation ---------------------------------
113 * @see IWorkbenchPreferencePage#init(IWorkbench)
115 public void init(IWorkbench workbench) {
116 setDescription(getString("description")); //$NON-NLS-1$
117 setPreferenceStore(CssUI.getDefault().getPreferenceStore());
119 MarkerAnnotationPreferences preferences =
120 new MarkerAnnotationPreferences();
121 overlayStore = createOverlayStore(preferences);
123 overlayStore.startListening();
126 // Private Methods ---------------------------------------------------------
128 private OverlayPreferenceStore createOverlayStore(
129 MarkerAnnotationPreferences preferences) {
131 OverlayPreferenceStore store =
132 new OverlayPreferenceStore(getPreferenceStore());
134 Iterator e = preferences.getAnnotationPreferences().iterator();
135 while (e.hasNext()) {
136 AnnotationPreference info = (AnnotationPreference) e.next();
137 store.addStringKey(info.getColorPreferenceKey());
138 store.addBooleanKey(info.getTextPreferenceKey());
139 store.addBooleanKey(info.getOverviewRulerPreferenceKey());
143 store.addIntKey(CssUIPreferences.EDITOR_TAB_WIDTH);
144 store.addBooleanKey(CssUIPreferences.EDITOR_CURRENT_LINE);
145 store.addStringKey(CssUIPreferences.EDITOR_CURRENT_LINE_COLOR);
146 store.addBooleanKey(CssUIPreferences.EDITOR_MATCHING_BRACKETS);
147 store.addStringKey(CssUIPreferences.EDITOR_MATCHING_BRACKETS_COLOR);
148 store.addBooleanKey(CssUIPreferences.EDITOR_PRINT_MARGIN);
149 store.addStringKey(CssUIPreferences.EDITOR_PRINT_MARGIN_COLOR);
150 store.addIntKey(CssUIPreferences.EDITOR_PRINT_MARGIN_COLUMN);
151 store.addBooleanKey(CssUIPreferences.EDITOR_OVERVIEW_RULER);
152 store.addStringKey(CssUIPreferences.EDITOR_LINE_NUMBER_RULER_COLOR);
153 store.addBooleanKey(CssUIPreferences.EDITOR_LINE_NUMBER_RULER);
156 store.addStringKey(CssUIPreferences.EDITOR_FOREGROUND_COLOR);
158 CssUIPreferences.EDITOR_FOREGROUND_DEFAULT_COLOR);
159 store.addStringKey(CssUIPreferences.EDITOR_BACKGROUND_COLOR);
161 CssUIPreferences.EDITOR_BACKGROUND_DEFAULT_COLOR);
162 store.addStringKey(CssUIPreferences.EDITOR_COMMENT_COLOR);
163 store.addBooleanKey(CssUIPreferences.EDITOR_COMMENT_BOLD);
164 store.addStringKey(CssUIPreferences.EDITOR_STRING_COLOR);
165 store.addBooleanKey(CssUIPreferences.EDITOR_STRING_BOLD);
166 store.addStringKey(CssUIPreferences.EDITOR_PROPERTY_COLOR);
167 store.addBooleanKey(CssUIPreferences.EDITOR_PROPERTY_BOLD);
168 store.addStringKey(CssUIPreferences.EDITOR_AT_KEYWORD_COLOR);
169 store.addBooleanKey(CssUIPreferences.EDITOR_AT_KEYWORD_BOLD);
170 store.addStringKey(CssUIPreferences.EDITOR_PSEUDO_CLASS_COLOR);
171 store.addBooleanKey(CssUIPreferences.EDITOR_PSEUDO_CLASS_BOLD);
172 store.addStringKey(CssUIPreferences.EDITOR_DEFAULT_COLOR);
173 store.addBooleanKey(CssUIPreferences.EDITOR_DEFAULT_BOLD);
176 store.addBooleanKey(CssUIPreferences.CONTENTASSIST_AUTOINSERT);
177 store.addBooleanKey(CssUIPreferences.CONTENTASSIST_ORDER_PROPOSALS);
178 store.addBooleanKey(CssUIPreferences.CONTENTASSIST_AUTOACTIVATION);
180 CssUIPreferences.CONTENTASSIST_AUTOACTIVATION_DELAY);
182 CssUIPreferences.CONTENTASSIST_AUTOACTIVATION_TRIGGERS);
184 CssUIPreferences.CONTENTASSIST_PROPOSALS_BACKGROUND);
186 CssUIPreferences.CONTENTASSIST_PROPOSALS_FOREGROUND);
189 store.addBooleanKey(CssUIPreferences.EDITOR_SPACES_FOR_TABS);
190 store.addBooleanKey(CssUIPreferences.EDITOR_CLOSE_STRINGS);
192 CssUIPreferences.EDITOR_CLOSE_BRACKETS_AND_PARENS);
193 store.addBooleanKey(CssUIPreferences.EDITOR_CLOSE_BRACES);
198 private Control createAppearancePage(Composite parent) {
200 new CssEditorAppearanceConfigurationBlock(overlayStore);
201 return appearanceBlock.createControl(parent);
204 private Control createSyntaxPage(Composite parent) {
205 syntaxBlock = new CssEditorSyntaxConfigurationBlock(overlayStore);
206 return syntaxBlock.createControl(parent);
209 private Control createCodeAssistPage(Composite parent) {
211 new CssEditorContentAssistConfigurationBlock(overlayStore);
212 return contentAssistBlock.createControl(parent);
215 private Control createAnnotationsPage(Composite parent) {
217 new CssEditorAnnotationsConfigurationBlock(overlayStore);
218 return annotationsBlock.createControl(parent);
221 private Control createTypingPage(Composite parent) {
222 typingBlock = new CssEditorTypingConfigurationBlock(overlayStore);
223 return typingBlock.createControl(parent);
226 private static String getString(String key) {
227 return CssUIMessages.getString(
228 "CssEditorPreferencePage." + key); //$NON-NLS-1$