/******************************************************************************* * Copyright (c) 2001, 2006 IBM Corporation and others. * 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jem.internal.plugin; /* * $RCSfile: JavaPlugin.java,v $ $Revision: 1.14 $ $Date: 2009/07/09 20:12:32 $ */ import org.eclipse.core.runtime.Plugin; import org.osgi.framework.BundleContext; import org.eclipse.jem.internal.adapters.jdom.JavaJDOMAdapterFactory; import org.eclipse.jem.internal.java.adapters.jdk.JavaJDKAdapterFactory; import org.eclipse.jem.java.util.JavaContext; import org.eclipse.jem.util.logger.proxy.Logger; import org.eclipse.jem.util.logger.proxyrender.EclipseLogger; import org.eclipse.jem.util.plugin.JEMUtilPlugin; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import java.lang.Throwable; import org.eclipse.core.runtime.CoreException; /** * This is a top-level class of the java plugin tool. * * @see AbstractUIPlugin for additional information on UI plugins */ public class JavaPlugin extends Plugin { //the ID for this plugin (added automatically by logging quickfix) public static final String PLUGIN_ID = "org.eclipse.jem.workbench"; //$NON-NLS-1$ private static JavaPlugin INSTANCE; private Logger logger; /** * Create the Java plugin and cache its default instance */ public JavaPlugin() { INSTANCE = this; } public Logger getLogger() { if (logger == null) logger = EclipseLogger.getEclipseLogger(this); return logger; } /** * Get the plugin singleton. */ static public JavaPlugin getDefault() { return INSTANCE; } /* (non-Javadoc) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); INSTANCE = this; JavaContext.setReflectionAdapterFactoryClass(JavaJDOMAdapterFactory.class); JEMUtilPlugin.getPluginResourceSet().getAdapterFactories().add(new JavaJDKAdapterFactory()); } 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() ); } }