/* * Copyright (c) 2004 Christopher Lenz 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: * Christopher Lenz - initial API and implementation * * $Id: CssCore.java,v 1.1 2004-09-02 18:07:13 jsurfer Exp $ */ package net.sourceforge.phpeclipse.css.core; import net.sourceforge.phpeclipse.css.core.internal.CssCorePreferences; import net.sourceforge.phpeclipse.css.core.internal.profiles.ProfileManager; import net.sourceforge.phpeclipse.css.core.profiles.IProfileManager; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; /** * The main plugin class to be used in the desktop. */ public class CssCore extends Plugin { // Class Variables --------------------------------------------------------- /** The shared instance. */ private static CssCore plugin; // Instance Variables ------------------------------------------------------ /** * The profile manager. */ private IProfileManager profileManager; // Constructors ------------------------------------------------------------ /** * Constructor. */ public CssCore() { plugin = this; } // Public Methods ---------------------------------------------------------- /** * Returns the shared instance. */ public static CssCore getDefault() { return plugin; } /** * Returns the plugin ID. * * @return the plugin ID */ public static String getPluginId() { return getDefault().getBundle().getSymbolicName(); } /** * Returns the object that manages the CSS profiles. * * @return the profile manager */ public synchronized IProfileManager getProfileManager() { if (profileManager == null) { profileManager = new ProfileManager(getPluginPreferences()); } return profileManager; } /** * Writes a status message and the associated exception stack trace (if * provided) to the error log. * * @param status the status to log */ public static void log(IStatus status) { getDefault().getLog().log(status); if (status.getException() != null) { status.getException().printStackTrace(System.err); } } /** * Writes the specified error message and exception stack trace to the error * log. * * @param message the error message * @param e the exception that caused the error, or null to omit * the stack trace in the log */ public static void log(String message, Throwable e) { IStatus status = new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e); log(status); } /** * Writes the specified error message to the error log. * * @param message the error message */ public static void log(String message) { IStatus status = new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null); log(status); } /** * Writes the stack trace of the given exception to the error log. * * @param e the exception that caused the error */ public static void log(Throwable e) { log(e.getMessage(), e); } // Plugin Implementation --------------------------------------------------- /* * @see Plugin#initializeDefaultPluginPreferences() */ protected void initializeDefaultPluginPreferences() { CssCorePreferences.initializeDefaultValues(getPluginPreferences()); } }