/******************************************************************************* * Copyright (c) 2007-2009 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is 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 * * Contributor: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ package org.jboss.tools.hibernate.ui.test; import java.io.File; import java.io.IOException; import java.net.URL; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; 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 * * @author Vitali Yemialyanchyk */ public class UiTestPlugin extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.jboss.tools.hibernate.ui.test"; //$NON-NLS-1$ // The shared instance private static UiTestPlugin plugin; /** * The constructor */ public UiTestPlugin() { } /* * (non-Javadoc) * * @see * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext * ) */ public void start(BundleContext context) throws Exception { super.start(context); setPlugin(this); } /* * (non-Javadoc) * * @see * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext * ) */ public void stop(BundleContext context) throws Exception { setPlugin(null); super.stop(context); } /** * Returns the shared instance * * @return the shared instance */ public static UiTestPlugin getDefault() { return plugin; } private static void setPlugin(UiTestPlugin plugin) { UiTestPlugin.plugin = plugin; } public File getFileInPlugin(IPath path) throws CoreException { try { URL installURL = new URL(getBundle().getEntry("/"), path.toString()); //$NON-NLS-1$ URL localURL = FileLocator.toFileURL(installURL); return new File(localURL.getFile()); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, getBundle() .getSymbolicName(), IStatus.ERROR, e.getMessage(), e)); } } }