blob: a73fc22770d5a49378b18cb2228f7cf320f7b4f9 [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2009 Red Hat
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Rob Stryker - initial implementation and ongoing maintenance
******************************************************************************/
package org.eclipse.wst.common.componentcore.ui;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class ModuleCoreUIPlugin extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.wst.common.modulecore.ui"; //$NON-NLS-1$
// The shared instance
private static ModuleCoreUIPlugin plugin;
private static ModuleCoreUIPlugin singleton;
/**
* The constructor for this plugin
*/
public ModuleCoreUIPlugin() {
super();
singleton = this;
}
/**
* Returns the singleton instance of this plugin.
*
* @return org.eclipse.wst.server.ui.internal.plugin.ServerUIPlugin
*/
public static ModuleCoreUIPlugin getInstance() {
return singleton;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static ModuleCoreUIPlugin getDefault() {
return plugin;
}
public static void log(Exception e) {
log(e.getMessage(), e);
}
public static void log(String message, Exception e) {
IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message, e);
getDefault().getLog().log(status);
}
public static IStatus createStatus(int severity, int aCode,
String aMessage, Throwable exception) {
return new Status(severity, PLUGIN_ID, aCode,
aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
}
public static IStatus createErrorStatus(int aCode, String aMessage,
Throwable exception) {
return createStatus(IStatus.ERROR, aCode, aMessage, exception);
}
public static IStatus createStatus(int severity, String message, Throwable exception) {
return new Status(severity, PLUGIN_ID, message, exception);
}
public static IStatus createStatus(int severity, String message) {
return createStatus(severity, message, null);
}
public static void logError(Throwable exception) {
Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( createStatus(IStatus.ERROR, exception.getMessage(), exception));
}
public static void logError(CoreException exception) {
Platform.getLog(Platform.getBundle(PLUGIN_ID)).log( exception.getStatus() );
}
}