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.2 2005-12-18 15:50:53 bananeweizen 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 final IPreferenceStore store = XMLPlugin.getDefault().getPreferenceStore();
37 final Display display=Display.getDefault();
39 // TODO: ChainedPreferenceStore does not work for preferences preview
41 display.syncExec(new Runnable() {
43 PreferenceConverter.setDefault(store,
44 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
45 display.getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB());
49 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT,
52 display.syncExec(new Runnable() {
54 PreferenceConverter.setDefault(store,
55 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
56 display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
60 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
63 // end of common preferences
65 setDefault(store, IXMLSyntaxConstants.XML_DEFAULT,
66 "0,0,0", ITextStylePreferences.STYLE_NORMAL);
68 setDefault(store, IXMLSyntaxConstants.XML_TAG,
69 "127,0,127", ITextStylePreferences.STYLE_NORMAL);
71 setDefault(store, IXMLSyntaxConstants.XML_ATT_NAME,
72 "0,127,0", ITextStylePreferences.STYLE_NORMAL);
74 setDefault(store, IXMLSyntaxConstants.XML_ATT_VALUE,
75 "0,0,255", ITextStylePreferences.STYLE_NORMAL);
77 setDefault(store, IXMLSyntaxConstants.XML_ENTITY,
78 "127,127,0", ITextStylePreferences.STYLE_NORMAL);
80 setDefault(store, IXMLSyntaxConstants.XML_CDATA,
81 "127,127,0", ITextStylePreferences.STYLE_NORMAL);
83 setDefault(store, IXMLSyntaxConstants.XML_PI,
84 "127,127,127", ITextStylePreferences.STYLE_BOLD);
86 setDefault(store, IXMLSyntaxConstants.XML_COMMENT,
87 "127,0,0", ITextStylePreferences.STYLE_NORMAL);
89 setDefault(store, IXMLSyntaxConstants.XML_DECL,
90 "127,0,127", ITextStylePreferences.STYLE_BOLD);
92 setDefault(store, IXMLSyntaxConstants.XML_SMARTY,
93 "255,0,127", ITextStylePreferences.STYLE_BOLD);
95 setDefault(store, IXMLSyntaxConstants.DTD_CONDITIONAL,
96 "127,127,0", ITextStylePreferences.STYLE_BOLD);
99 private static void setDefault(
100 IPreferenceStore store, String constant, String color, String style
102 store.setDefault(constant + ITextStylePreferences.SUFFIX_FOREGROUND, color);
103 store.setDefault(constant + ITextStylePreferences.SUFFIX_STYLE, style);