--- /dev/null
+/*
+ * Copyright (c) 2003-2004 Christopher Lenz and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Christopher Lenz - initial API and implementation
+ *
+ * $Id: CssEditorPreferencePage.java,v 1.1 2004-09-02 18:11:50 jsurfer Exp $
+ */
+
+package net.sourceforge.phpeclipse.css.ui.internal.preferences;
+
+import java.util.Iterator;
+
+import net.sourceforge.phpeclipse.css.ui.CssUI;
+import net.sourceforge.phpeclipse.css.ui.internal.CssUIMessages;
+import net.sourceforge.phpeclipse.css.ui.internal.CssUIPreferences;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
+
+/**
+ * Implements the CSS editor preference page.
+ */
+public class CssEditorPreferencePage extends PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ // Instance Variables ------------------------------------------------------
+
+ private OverlayPreferenceStore overlayStore;
+
+ private CssEditorAppearanceConfigurationBlock appearanceBlock;
+ private CssEditorSyntaxConfigurationBlock syntaxBlock;
+ private CssEditorContentAssistConfigurationBlock contentAssistBlock;
+ private CssEditorAnnotationsConfigurationBlock annotationsBlock;
+ private CssEditorTypingConfigurationBlock typingBlock;
+
+ // PreferencePage Implementation -------------------------------------------
+
+ /**
+ * @see PreferencePage#createContents(Composite)
+ */
+ protected Control createContents(Composite parent) {
+
+ TabFolder folder = new TabFolder(parent, SWT.NONE);
+ TabItem item;
+
+ item = new TabItem(folder, SWT.NONE);
+ item.setText(getString("appearance")); //$NON-NLS-1$
+ item.setControl(createAppearancePage(folder));
+
+ item = new TabItem(folder, SWT.NONE);
+ item.setText(getString("syntax")); //$NON-NLS-1$
+ item.setControl(createSyntaxPage(folder));
+
+ item = new TabItem(folder, SWT.NONE);
+ item.setText(getString("contentAssist")); //$NON-NLS-1$
+ item.setControl(createCodeAssistPage(folder));
+
+ item = new TabItem(folder, SWT.NONE);
+ item.setText(getString("annotations")); //$NON-NLS-1$
+ item.setControl(createAnnotationsPage(folder));
+
+ item = new TabItem(folder, SWT.NONE);
+ item.setText(getString("typing")); //$NON-NLS-1$
+ item.setControl(createTypingPage(folder));
+
+ return folder;
+ }
+
+ /**
+ * @see PreferencePage#dispose()
+ */
+ public void dispose() {
+ if (overlayStore != null) {
+ overlayStore.stopListening();
+ overlayStore = null;
+ }
+ super.dispose();
+ }
+
+ /**
+ * @see PreferencePage#performOk()
+ */
+ public boolean performOk() {
+ overlayStore.propagate();
+ CssUI.getDefault().savePluginPreferences();
+ return true;
+ }
+
+ /**
+ * @see PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ overlayStore.loadDefaults();
+ super.performDefaults();
+ }
+
+ // IWorkbenchPreferencePage Implementation ---------------------------------
+
+ /**
+ * @see IWorkbenchPreferencePage#init(IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ setDescription(getString("description")); //$NON-NLS-1$
+ setPreferenceStore(CssUI.getDefault().getPreferenceStore());
+
+ MarkerAnnotationPreferences preferences =
+ new MarkerAnnotationPreferences();
+ overlayStore = createOverlayStore(preferences);
+ overlayStore.load();
+ overlayStore.startListening();
+ }
+
+ // Private Methods ---------------------------------------------------------
+
+ private OverlayPreferenceStore createOverlayStore(
+ MarkerAnnotationPreferences preferences) {
+
+ OverlayPreferenceStore store =
+ new OverlayPreferenceStore(getPreferenceStore());
+
+ Iterator e = preferences.getAnnotationPreferences().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference info = (AnnotationPreference) e.next();
+ store.addStringKey(info.getColorPreferenceKey());
+ store.addBooleanKey(info.getTextPreferenceKey());
+ store.addBooleanKey(info.getOverviewRulerPreferenceKey());
+ }
+
+ // Appearance
+ store.addIntKey(CssUIPreferences.EDITOR_TAB_WIDTH);
+ store.addBooleanKey(CssUIPreferences.EDITOR_CURRENT_LINE);
+ store.addStringKey(CssUIPreferences.EDITOR_CURRENT_LINE_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_MATCHING_BRACKETS);
+ store.addStringKey(CssUIPreferences.EDITOR_MATCHING_BRACKETS_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_PRINT_MARGIN);
+ store.addStringKey(CssUIPreferences.EDITOR_PRINT_MARGIN_COLOR);
+ store.addIntKey(CssUIPreferences.EDITOR_PRINT_MARGIN_COLUMN);
+ store.addBooleanKey(CssUIPreferences.EDITOR_OVERVIEW_RULER);
+ store.addStringKey(CssUIPreferences.EDITOR_LINE_NUMBER_RULER_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_LINE_NUMBER_RULER);
+
+ // Syntax coloring
+ store.addStringKey(CssUIPreferences.EDITOR_FOREGROUND_COLOR);
+ store.addBooleanKey(
+ CssUIPreferences.EDITOR_FOREGROUND_DEFAULT_COLOR);
+ store.addStringKey(CssUIPreferences.EDITOR_BACKGROUND_COLOR);
+ store.addBooleanKey(
+ CssUIPreferences.EDITOR_BACKGROUND_DEFAULT_COLOR);
+ store.addStringKey(CssUIPreferences.EDITOR_COMMENT_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_COMMENT_BOLD);
+ store.addStringKey(CssUIPreferences.EDITOR_STRING_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_STRING_BOLD);
+ store.addStringKey(CssUIPreferences.EDITOR_PROPERTY_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_PROPERTY_BOLD);
+ store.addStringKey(CssUIPreferences.EDITOR_AT_KEYWORD_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_AT_KEYWORD_BOLD);
+ store.addStringKey(CssUIPreferences.EDITOR_PSEUDO_CLASS_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_PSEUDO_CLASS_BOLD);
+ store.addStringKey(CssUIPreferences.EDITOR_DEFAULT_COLOR);
+ store.addBooleanKey(CssUIPreferences.EDITOR_DEFAULT_BOLD);
+
+ // Content assist
+ store.addBooleanKey(CssUIPreferences.CONTENTASSIST_AUTOINSERT);
+ store.addBooleanKey(CssUIPreferences.CONTENTASSIST_ORDER_PROPOSALS);
+ store.addBooleanKey(CssUIPreferences.CONTENTASSIST_AUTOACTIVATION);
+ store.addIntKey(
+ CssUIPreferences.CONTENTASSIST_AUTOACTIVATION_DELAY);
+ store.addStringKey(
+ CssUIPreferences.CONTENTASSIST_AUTOACTIVATION_TRIGGERS);
+ store.addStringKey(
+ CssUIPreferences.CONTENTASSIST_PROPOSALS_BACKGROUND);
+ store.addStringKey(
+ CssUIPreferences.CONTENTASSIST_PROPOSALS_FOREGROUND);
+
+ // Typing
+ store.addBooleanKey(CssUIPreferences.EDITOR_SPACES_FOR_TABS);
+ store.addBooleanKey(CssUIPreferences.EDITOR_CLOSE_STRINGS);
+ store.addBooleanKey(
+ CssUIPreferences.EDITOR_CLOSE_BRACKETS_AND_PARENS);
+ store.addBooleanKey(CssUIPreferences.EDITOR_CLOSE_BRACES);
+
+ return store;
+ }
+
+ private Control createAppearancePage(Composite parent) {
+ appearanceBlock =
+ new CssEditorAppearanceConfigurationBlock(overlayStore);
+ return appearanceBlock.createControl(parent);
+ }
+
+ private Control createSyntaxPage(Composite parent) {
+ syntaxBlock = new CssEditorSyntaxConfigurationBlock(overlayStore);
+ return syntaxBlock.createControl(parent);
+ }
+
+ private Control createCodeAssistPage(Composite parent) {
+ contentAssistBlock =
+ new CssEditorContentAssistConfigurationBlock(overlayStore);
+ return contentAssistBlock.createControl(parent);
+ }
+
+ private Control createAnnotationsPage(Composite parent) {
+ annotationsBlock =
+ new CssEditorAnnotationsConfigurationBlock(overlayStore);
+ return annotationsBlock.createControl(parent);
+ }
+
+ private Control createTypingPage(Composite parent) {
+ typingBlock = new CssEditorTypingConfigurationBlock(overlayStore);
+ return typingBlock.createControl(parent);
+ }
+
+ private static String getString(String key) {
+ return CssUIMessages.getString(
+ "CssEditorPreferencePage." + key); //$NON-NLS-1$
+ }
+
+}