A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.xml.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / preferences / XMLPreferenceInitializer.java
1 /*
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
7  *
8  * Contributors:
9  *     Roberto Gonzalez Rocha - Initial version
10  *     Igor Malinin - refactoring, minor changes
11  *
12  * $Id: XMLPreferenceInitializer.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
13  */
14 package net.sourceforge.phpeclipse.xml.ui.internal.preferences;
15
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;
19
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;
26
27 /**
28  * @author Igor Malinin
29  */
30 public class XMLPreferenceInitializer extends AbstractPreferenceInitializer {
31         /*
32          * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
33          */
34         public void initializeDefaultPreferences() {
35                 final IPreferenceStore store = XMLPlugin.getDefault()
36                                 .getPreferenceStore();
37                 final Display display = Display.getDefault();
38
39                 // TODO: ChainedPreferenceStore does not work for preferences preview
40
41                 display.syncExec(new Runnable() {
42                         public void run() {
43                                 PreferenceConverter.setDefault(store,
44                                                 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, display
45                                                                 .getSystemColor(SWT.COLOR_LIST_FOREGROUND)
46                                                                 .getRGB());
47                         }
48                 });
49
50                 store.setDefault(
51                                 AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT,
52                                 true);
53
54                 display.syncExec(new Runnable() {
55                         public void run() {
56                                 PreferenceConverter.setDefault(store,
57                                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, display
58                                                                 .getSystemColor(SWT.COLOR_LIST_BACKGROUND)
59                                                                 .getRGB());
60                         }
61                 });
62
63                 store.setDefault(
64                                 AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
65                                 true);
66
67                 // end of common preferences
68
69                 setDefault(store, IXMLSyntaxConstants.XML_DEFAULT, "0,0,0",
70                                 ITextStylePreferences.STYLE_NORMAL);
71
72                 setDefault(store, IXMLSyntaxConstants.XML_TAG, "127,0,127",
73                                 ITextStylePreferences.STYLE_NORMAL);
74
75                 setDefault(store, IXMLSyntaxConstants.XML_ATT_NAME, "0,127,0",
76                                 ITextStylePreferences.STYLE_NORMAL);
77
78                 setDefault(store, IXMLSyntaxConstants.XML_ATT_VALUE, "0,0,255",
79                                 ITextStylePreferences.STYLE_NORMAL);
80
81                 setDefault(store, IXMLSyntaxConstants.XML_ENTITY, "127,127,0",
82                                 ITextStylePreferences.STYLE_NORMAL);
83
84                 setDefault(store, IXMLSyntaxConstants.XML_CDATA, "127,127,0",
85                                 ITextStylePreferences.STYLE_NORMAL);
86
87                 setDefault(store, IXMLSyntaxConstants.XML_PI, "127,127,127",
88                                 ITextStylePreferences.STYLE_BOLD);
89
90                 setDefault(store, IXMLSyntaxConstants.XML_COMMENT, "127,0,0",
91                                 ITextStylePreferences.STYLE_NORMAL);
92
93                 setDefault(store, IXMLSyntaxConstants.XML_DECL, "127,0,127",
94                                 ITextStylePreferences.STYLE_BOLD);
95
96                 setDefault(store, IXMLSyntaxConstants.XML_SMARTY, "255,0,127",
97                                 ITextStylePreferences.STYLE_BOLD);
98
99                 setDefault(store, IXMLSyntaxConstants.DTD_CONDITIONAL, "127,127,0",
100                                 ITextStylePreferences.STYLE_BOLD);
101         }
102
103         private static void setDefault(IPreferenceStore store, String constant,
104                         String color, String style) {
105                 store.setDefault(constant + ITextStylePreferences.SUFFIX_FOREGROUND,
106                                 color);
107                 store.setDefault(constant + ITextStylePreferences.SUFFIX_STYLE, style);
108         }
109 }