+++ /dev/null
-/*
- * Copyright (c) 2002-2004 Roberto Gonzalez Rocha 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:
- * Roberto Gonzalez Rocha - Initial version
- * Igor Malinin - refactoring, minor changes
- *
- * $Id: XMLPreferenceInitializer.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
- */
-package net.sourceforge.phpeclipse.xml.ui.internal.preferences;
-
-/*import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.PropertyResourceBundle;
-*/
-import net.sourceforge.phpdt.core.JavaCore;
-import net.sourceforge.phpdt.ui.PreferenceConstants;
-import net.sourceforge.phpeclipse.ui.IPreferenceConstants;
-
-import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
-import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
-import net.sourceforge.phpeclipse.ui.WebUI;
-import net.sourceforge.phpeclipse.ui.preferences.ITextStylePreferences;
-//import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
-import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
-
-//import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-
-/**
- * @author Igor Malinin
- */
-public class XMLPreferenceInitializer extends AbstractPreferenceInitializer implements IPreferenceConstants {
- /*
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- final IPreferenceStore store = /*XMLPlugin*/WebUI.getDefault()
- .getPreferenceStore();
- final Display display = Display.getDefault();
-
- // TODO: ChainedPreferenceStore does not work for preferences preview
-
- display.syncExec(new Runnable() {
- public void run() {
- PreferenceConverter.setDefault(store,
- AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, display
- .getSystemColor(SWT.COLOR_LIST_FOREGROUND)
- .getRGB());
- }
- });
-
- store.setDefault(
- AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT,
- true);
-
- display.syncExec(new Runnable() {
- public void run() {
- PreferenceConverter.setDefault(store,
- AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, display
- .getSystemColor(SWT.COLOR_LIST_BACKGROUND)
- .getRGB());
- }
- });
-
- store.setDefault(
- AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
- true);
-
- // end of common preferences
-
- setDefault(store, IXMLSyntaxConstants.XML_DEFAULT, "0,0,0",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_TAG, "127,0,127",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_ATT_NAME, "0,127,0",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_ATT_VALUE, "0,0,255",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_ENTITY, "127,127,0",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_CDATA, "127,127,0",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_PI, "127,127,127",
- ITextStylePreferences.STYLE_BOLD);
-
- setDefault(store, IXMLSyntaxConstants.XML_COMMENT, "127,0,0",
- ITextStylePreferences.STYLE_NORMAL);
-
- setDefault(store, IXMLSyntaxConstants.XML_DECL, "127,0,127",
- ITextStylePreferences.STYLE_BOLD);
-
- setDefault(store, IXMLSyntaxConstants.XML_SMARTY, "255,0,127",
- ITextStylePreferences.STYLE_BOLD);
-
- setDefault(store, IXMLSyntaxConstants.DTD_CONDITIONAL, "127,127,0",
- ITextStylePreferences.STYLE_BOLD);
-
- String operatingSystem = Platform.getOS();
- // maxosx, linux, solaris, win32,...
- try {
- /*InputStream is = getDefault()
- .openStream(
- new Path("prefs/default_" + operatingSystem
- + ".properties"));
- PropertyResourceBundle resourceBundle = new PropertyResourceBundle(
- is);
- Enumeration e = resourceBundle.getKeys();
- String key;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- store.setDefault(key, resourceBundle.getString(key));
- }*/
- } catch (Exception e) {
- // no default properties found
- if (operatingSystem.equals(Platform.OS_WIN32)) {
- // store.setDefault(PHP_RUN_PREF, "c:\\apache\\php\\php.exe");
- // store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php
- // -l -f {0}");
- // store.setDefault(MYSQL_RUN_PREF,
- // "c:\\apache\\mysql\\bin\\mysqld-nt.exe");
- // store.setDefault(APACHE_RUN_PREF, "c:\\apache\\apache.exe");
- // store.setDefault(XAMPP_START_PREF,
- // "c:\\xampp\\xampp_start.exe");
- // store.setDefault(XAMPP_STOP_PREF,
- // "c:\\xampp\\xampp_stop.exe");
- // store.setDefault(
- // ETC_HOSTS_PATH_PREF,
- // "c:\\windows\\system32\\drivers\\etc\\hosts");
- } else {
- // store.setDefault(PHP_RUN_PREF, "/apache/php/php");
- // store.setDefault(EXTERNAL_PARSER_PREF, "/apache/php/php -l -f
- // {0}");
- // store.setDefault(MYSQL_RUN_PREF, "/apache/mysql/bin/mysqld");
- // store.setDefault(APACHE_RUN_PREF, "/apache/apache");
- // store.setDefault(XAMPP_START_PREF, "xamp/xampp_start");
- // store.setDefault(XAMPP_STOP_PREF, "xampp/xampp_stop");
- }
- // store.setDefault(MYSQL_PREF, "--standalone");
- // store.setDefault(APACHE_START_PREF, "-c \"DocumentRoot
- // \"{0}\"\"");
- // store.setDefault(APACHE_STOP_PREF, "-k shutdown");
- // store.setDefault(APACHE_RESTART_PREF, "-k restart");
- // store.setDefault(MYSQL_START_BACKGROUND, "true");
- // store.setDefault(APACHE_START_BACKGROUND, "true");
- // store.setDefault(APACHE_STOP_BACKGROUND, "true");
- // store.setDefault(APACHE_RESTART_BACKGROUND, "true");
- }
- store.setDefault(PHP_USERDEF_XMLFILE, "");
- PreferenceConverter.setDefault(store, PHP_TAG, PHPColorProvider.TAG);
- PreferenceConverter.setDefault(store, PHP_KEYWORD,
- PHPColorProvider.KEYWORD);
- PreferenceConverter.setDefault(store, PHP_VARIABLE,
- PHPColorProvider.VARIABLE);
- PreferenceConverter.setDefault(store, PHP_VARIABLE_DOLLAR,
- PHPColorProvider.VARIABLE);
- /*PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME,
- PHPColorProvider.FUNCTION_NAME);*/
-
- setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME,
- ITextStylePreferences.STYLE_BOLD);
-
- PreferenceConverter.setDefault(store, PHP_CONSTANT,
- PHPColorProvider.CONSTANT);
- PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE);
- PreferenceConverter.setDefault(store, PHP_DEFAULT,
- PHPColorProvider.DEFAULT);
- PreferenceConverter.setDefault(store, PHPDOC_KEYWORD,
- PHPColorProvider.PHPDOC_KEYWORD);
-
- PreferenceConverter.setDefault(store, PHPDOC_TAG,
- PHPColorProvider.PHPDOC_TAG);
- PreferenceConverter.setDefault(store, PHPDOC_LINK,
- PHPColorProvider.PHPDOC_LINK);
- PreferenceConverter.setDefault(store, PHPDOC_DEFAULT,
- PHPColorProvider.PHPDOC_DEFAULT);
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR,
- new RGB(127, 0, 85));
- store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true);
- store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false);
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR,
- new RGB(0, 0, 0));
- store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false);
- store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false);
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_BRACE_OPERATOR_COLOR,
- new RGB(0, 0, 0));
- store.setDefault(EDITOR_PHP_BRACE_OPERATOR_BOLD, false);
- store.setDefault(EDITOR_PHP_BRACE_OPERATOR_ITALIC, false);
-
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_KEYWORD_RETURN_COLOR,
- new RGB(127, 0, 85));
- store.setDefault(EDITOR_PHP_KEYWORD_RETURN_BOLD, true);
- store.setDefault(EDITOR_PHP_KEYWORD_RETURN_ITALIC, false);
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_OPERATOR_COLOR,
- new RGB(0, 0, 0));
- store.setDefault(EDITOR_PHP_OPERATOR_BOLD, false);
- store.setDefault(EDITOR_PHP_OPERATOR_ITALIC, false);
-
- PreferenceConverter.setDefault(store, EDITOR_PHP_BRACE_OPERATOR_COLOR,
- new RGB(0, 0, 0));
- store.setDefault(EDITOR_PHP_BRACE_OPERATOR_BOLD, false);
- store.setDefault(EDITOR_PHP_BRACE_OPERATOR_ITALIC, false);
-
- // this will initialize the static fields in the syntaxrdr class
- new PHPSyntaxRdr();
- JavaCore.initializeDefaultPluginPreferences();
- PreferenceConstants.initializeDefaultValues(store);
- }
-
- private static void setDefault(IPreferenceStore store, String constant,
- String color, String style) {
- store.setDefault(constant + ITextStylePreferences.SUFFIX_FOREGROUND,
- color);
- store.setDefault(constant + ITextStylePreferences.SUFFIX_STYLE, style);
- }
-}