2 * Copyright (c) 2002-2004 Roberto Gonzalez Rocha 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 * Roberto Gonzalez Rocha - Initial version
10 * Igor Malinin - refactoring, minor changes
12 * $Id: XMLPreferenceInitializer.java,v 1.1 2004-09-02 18:28:03 jsurfer Exp $
14 package net.sourceforge.phpeclipse.xml.ui.internal.preferences;
16 import net.sourceforge.phpeclipse.ui.preferences.ITextStylePreferences;
17 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
18 import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
20 import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
21 import org.eclipse.jface.preference.IPreferenceStore;
22 import org.eclipse.jface.preference.PreferenceConverter;
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.ui.texteditor.AbstractTextEditor;
29 * @author Igor Malinin
31 public class XMLPreferenceInitializer extends AbstractPreferenceInitializer {
33 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
35 public void initializeDefaultPreferences() {
36 IPreferenceStore store = XMLPlugin.getDefault().getPreferenceStore();
38 // TODO: ChainedPreferenceStore does not work for preferences preview
40 PreferenceConverter.setDefault(store,
41 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
43 .getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB());
46 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT,
49 PreferenceConverter.setDefault(store,
50 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
52 .getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
55 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
58 // end of common preferences
60 setDefault(store, IXMLSyntaxConstants.XML_DEFAULT,
61 "0,0,0", ITextStylePreferences.STYLE_NORMAL);
63 setDefault(store, IXMLSyntaxConstants.XML_TAG,
64 "127,0,127", ITextStylePreferences.STYLE_NORMAL);
66 setDefault(store, IXMLSyntaxConstants.XML_ATT_NAME,
67 "0,127,0", ITextStylePreferences.STYLE_NORMAL);
69 setDefault(store, IXMLSyntaxConstants.XML_ATT_VALUE,
70 "0,0,255", ITextStylePreferences.STYLE_NORMAL);
72 setDefault(store, IXMLSyntaxConstants.XML_ENTITY,
73 "127,127,0", ITextStylePreferences.STYLE_NORMAL);
75 setDefault(store, IXMLSyntaxConstants.XML_CDATA,
76 "127,127,0", ITextStylePreferences.STYLE_NORMAL);
78 setDefault(store, IXMLSyntaxConstants.XML_PI,
79 "127,127,127", ITextStylePreferences.STYLE_BOLD);
81 setDefault(store, IXMLSyntaxConstants.XML_COMMENT,
82 "127,0,0", ITextStylePreferences.STYLE_NORMAL);
84 setDefault(store, IXMLSyntaxConstants.XML_DECL,
85 "127,0,127", ITextStylePreferences.STYLE_BOLD);
87 setDefault(store, IXMLSyntaxConstants.XML_SMARTY,
88 "255,0,127", ITextStylePreferences.STYLE_BOLD);
90 setDefault(store, IXMLSyntaxConstants.DTD_CONDITIONAL,
91 "127,127,0", ITextStylePreferences.STYLE_BOLD);
94 private static void setDefault(
95 IPreferenceStore store, String constant, String color, String style
97 store.setDefault(constant + ITextStylePreferences.SUFFIX_FOREGROUND, color);
98 store.setDefault(constant + ITextStylePreferences.SUFFIX_STYLE, style);