/******************************************************************************* * Copyright (c) 2014 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: * Red Hat - Initial Contribution *******************************************************************************/ package org.eclipse.linuxtools.internal.vagrant.core; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.osgi.framework.BundleContext; public class Activator extends Plugin { private static BundleContext context; static BundleContext getContext() { return context; } // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.linuxtools.vagrant.core"; //$NON-NLS-1$ // The shared instance private static Activator plugin; @Override public void start(BundleContext bundleContext) throws Exception { super.start(bundleContext); plugin = this; } @Override public void stop(BundleContext bundleContext) throws Exception { plugin = null; super.stop(bundleContext); } public static Activator getDefault() { return plugin; } public static void log(IStatus status) { Activator.getDefault().getLog().log(status); } public static void logErrorMessage(String message) { log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, null)); } 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, e.getMessage(), e); } log(status); } }