/******************************************************************************* * Copyright (c) 2000, 2009 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 edu.illinois.codingtracker.jdt.project.manipulation; 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.MultiStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; public class JavaTestPlugin extends Plugin { private static JavaTestPlugin fgDefault; public JavaTestPlugin() { fgDefault= this; } public static JavaTestPlugin getDefault() { return fgDefault; } public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } public File getFileInPlugin(IPath path) throws CoreException { try { URL installURL= new URL(getBundle().getEntry("/"), path.toString()); URL localURL= FileLocator.toFileURL(installURL); return new File(localURL.getFile()); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getMessage(), e)); } } public static String getPluginId() { return "org.eclipse.jdt.ui.tests"; } public static void log(IStatus status) { getDefault().getLog().log(status); } public static void logErrorMessage(String message) { log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null)); } public static void logErrorStatus(String message, IStatus status) { if (status == null) { logErrorMessage(message); return; } MultiStatus multi= new MultiStatus(getPluginId(), IStatus.ERROR, message, null); multi.add(status); log(multi); } public static void log(Throwable e) { log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getMessage(), e)); } }