/*********************************************************************** * Copyright (c) 2007 Anyware Technologies * * 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: * Anyware Technologies - initial API and implementation * * $Id: Activator.java,v 1.4 2008/05/19 09:26:31 jlescot Exp $ **********************************************************************/ package org.eclipse.emf.ecoretools.internal; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; 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 Activator extends AbstractUIPlugin { /** The plug-in ID */ public static final String PLUGIN_ID = "org.eclipse.emf.ecoretools"; //$NON-NLS-1$ // The shared instance private static Activator plugin; /** * The constructor */ public Activator() { plugin = this; } /** * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ @Override public void start(BundleContext context) throws Exception { super.start(context); } /** * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); } /** * Returns the shared instance * * @return the shared instance */ public static Activator getDefault() { return plugin; } /** * Log an IStatus * * @param status * Status of an operation */ public static void log(IStatus status) { getDefault().getLog().log(status); } /** * Log a message with given level into the Eclipse log file * * @param message * the message to log * @param level * the message priority */ public static void log(String message, int level) { IStatus status = null; status = new Status(level, PLUGIN_ID, IStatus.OK, message, null); log(status); } /** * Log an exception into the Eclipse log file * * @param e * the exception to log */ public static void log(Throwable e) { if (e instanceof InvocationTargetException) e = ((InvocationTargetException) e).getTargetException(); IStatus status = null; if (e instanceof CoreException) status = ((CoreException) e).getStatus(); else status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, Messages.Activator_Error, e); log(status); } }