001: /*******************************************************************************
002: * Copyright (c) 2005, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.examples.navigator;
011:
012: import org.eclipse.core.runtime.IStatus;
013: import org.eclipse.core.runtime.Status;
014: import org.eclipse.ui.plugin.AbstractUIPlugin;
015: import org.osgi.framework.BundleContext;
016:
017: /**
018: * The activator class controls the plug-in life cycle
019: */
020: public class Activator extends AbstractUIPlugin {
021:
022: /** The plug-in ID */
023: public static final String PLUGIN_ID = "org.eclipse.ui.examples.navigator"; //$NON-NLS-1$
024:
025: // The shared instance
026: private static Activator plugin;
027:
028: /**
029: * The constructor
030: */
031: public Activator() {
032: plugin = this ;
033: }
034:
035: /*
036: * (non-Javadoc)
037: * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
038: */
039: public void start(BundleContext context) throws Exception {
040: super .start(context);
041: }
042:
043: /*
044: * (non-Javadoc)
045: * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
046: */
047: public void stop(BundleContext context) throws Exception {
048: plugin = null;
049: super .stop(context);
050: }
051:
052: /**
053: * Returns the shared instance
054: *
055: * @return the shared instance
056: */
057: public static Activator getDefault() {
058: return plugin;
059: }
060:
061: /**
062: * Record an error against this plugin's log.
063: *
064: * @param aCode
065: * @param aMessage
066: * @param anException
067: */
068: public static void logError(int aCode, String aMessage,
069: Throwable anException) {
070: getDefault().getLog().log(
071: createErrorStatus(aCode, aMessage, anException));
072: }
073:
074: /**
075: *
076: * Record a message against this plugin's log.
077: *
078: * @param severity
079: * @param aCode
080: * @param aMessage
081: * @param exception
082: */
083: public static void log(int severity, int aCode, String aMessage,
084: Throwable exception) {
085: log(createStatus(severity, aCode, aMessage, exception));
086: }
087:
088: /**
089: *
090: * Record a status against this plugin's log.
091: *
092: * @param aStatus
093: */
094: public static void log(IStatus aStatus) {
095: getDefault().getLog().log(aStatus);
096: }
097:
098: /**
099: * Create a status associated with this plugin.
100: *
101: * @param severity
102: * @param aCode
103: * @param aMessage
104: * @param exception
105: * @return A status configured with this plugin's id and the given parameters.
106: */
107: public static IStatus createStatus(int severity, int aCode,
108: String aMessage, Throwable exception) {
109: return new Status(severity, PLUGIN_ID, aCode,
110: aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
111: }
112:
113: /**
114: *
115: * @param aCode
116: * @param aMessage
117: * @param exception
118: * @return A status configured with this plugin's id and the given parameters.
119: */
120: public static IStatus createErrorStatus(int aCode, String aMessage,
121: Throwable exception) {
122: return createStatus(IStatus.ERROR, aCode, aMessage, exception);
123: }
124: }
|