2 * Copyright (c) 2004 Christopher Lenz 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 * Christopher Lenz - initial API and implementation
11 * $Id: CssCore.java,v 1.1 2004-09-02 18:07:13 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.core;
16 import net.sourceforge.phpeclipse.css.core.internal.CssCorePreferences;
17 import net.sourceforge.phpeclipse.css.core.internal.profiles.ProfileManager;
18 import net.sourceforge.phpeclipse.css.core.profiles.IProfileManager;
20 import org.eclipse.core.runtime.IStatus;
21 import org.eclipse.core.runtime.Plugin;
22 import org.eclipse.core.runtime.Status;
25 * The main plugin class to be used in the desktop.
27 public class CssCore extends Plugin {
29 // Class Variables ---------------------------------------------------------
31 /** The shared instance. */
32 private static CssCore plugin;
34 // Instance Variables ------------------------------------------------------
37 * The profile manager.
39 private IProfileManager profileManager;
41 // Constructors ------------------------------------------------------------
50 // Public Methods ----------------------------------------------------------
53 * Returns the shared instance.
55 public static CssCore getDefault() {
60 * Returns the plugin ID.
62 * @return the plugin ID
64 public static String getPluginId() {
65 return getDefault().getBundle().getSymbolicName();
69 * Returns the object that manages the CSS profiles.
71 * @return the profile manager
73 public synchronized IProfileManager getProfileManager() {
74 if (profileManager == null) {
75 profileManager = new ProfileManager(getPluginPreferences());
77 return profileManager;
81 * Writes a status message and the associated exception stack trace (if
82 * provided) to the error log.
84 * @param status the status to log
86 public static void log(IStatus status) {
87 getDefault().getLog().log(status);
88 if (status.getException() != null) {
89 status.getException().printStackTrace(System.err);
94 * Writes the specified error message and exception stack trace to the error
97 * @param message the error message
98 * @param e the exception that caused the error, or <tt>null</tt> to omit
99 * the stack trace in the log
101 public static void log(String message, Throwable e) {
102 IStatus status = new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR,
108 * Writes the specified error message to the error log.
110 * @param message the error message
112 public static void log(String message) {
113 IStatus status = new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR,
119 * Writes the stack trace of the given exception to the error log.
121 * @param e the exception that caused the error
123 public static void log(Throwable e) {
124 log(e.getMessage(), e);
127 // Plugin Implementation ---------------------------------------------------
130 * @see Plugin#initializeDefaultPluginPreferences()
132 protected void initializeDefaultPluginPreferences() {
133 CssCorePreferences.initializeDefaultValues(getPluginPreferences());