blob: 0af12d83c6cac6b13b5a0b43f8de3977d765b381 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014, 2019 1C-Soft LLC and others.
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Vladimir Piskarev (1C) - initial API and implementation
*******************************************************************************/
package org.eclipse.handly.internal;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator
extends Plugin
{
public static final String PLUGIN_ID = "org.eclipse.handly"; //$NON-NLS-1$
private static final boolean IS_RESOURCES_BUNDLE_AVAILABLE =
Platform.getBundle("org.eclipse.core.resources") != null; //$NON-NLS-1$
private static Activator plugin;
public Activator()
{
plugin = this;
}
public static Activator getDefault()
{
return plugin;
}
public static void logError(String msg, Throwable e)
{
plugin.getLog().log(createErrorStatus(msg, e));
}
public static void logError(Throwable e)
{
logError(e.getMessage(), e);
}
public static IStatus createErrorStatus(String msg, Throwable e)
{
return new Status(IStatus.ERROR, PLUGIN_ID, 0, msg, e);
}
public static IStatus createWarningStatus(String msg)
{
return new Status(IStatus.WARNING, PLUGIN_ID, 0, msg, null);
}
public static boolean isResourcesBundleAvailable()
{
return IS_RESOURCES_BUNDLE_AVAILABLE;
}
@Override
public void stop(BundleContext context) throws Exception
{
super.stop(context);
plugin = null;
}
}