/** * Copyright (c) 2006, 2007 Borland Software Corporation * * 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: * bblajer - initial API and implementation */ package org.eclipse.gmf.internal.runtime.lite; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.gmf.runtime.lite.shortcuts.ShortcutProvidersRegistry; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; 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.gmf.runtime.lite"; // The shared instance private static Activator plugin; /** * The constructor */ public Activator() { plugin = this; } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { super.start(context); } /* * (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { plugin = null; ((ShortcutProvidersRegistryImpl) ShortcutProvidersRegistry.INSTANCE).dispose(); super.stop(context); } /** * Returns the shared instance * * @return the shared instance */ public static Activator getDefault() { return plugin; } public void logError(String error) { logError(error, null); } @Override protected void initializeImageRegistry(ImageRegistry reg) { PluginImages.initialize(); super.initializeImageRegistry(reg); } /** * @param throwable actual error or null could be passed */ public void logError(String error, Throwable throwable) { log(error, throwable, IStatus.ERROR); } private void debug(String message, Throwable throwable) { if (!isDebugging()) { return; } if (message != null) { System.err.println(message); } if (throwable != null) { throwable.printStackTrace(); } } public void logWarning(String error) { logWarning(error, null); } public void logWarning(String error, Throwable throwable) { log(error, throwable, IStatus.WARNING); } private void log(String error, Throwable throwable, int severity) { if (error == null && throwable != null) { error = throwable.getMessage(); } getLog().log(new Status(severity, getBundle().getSymbolicName(), IStatus.OK, error, throwable)); debug(error, throwable); } public static ImageDescriptor getImageDescriptor(String imageFilePath) { return imageDescriptorFromPlugin(getDefault().getBundle().getSymbolicName(), imageFilePath); } }