blob: 4cd0e0296fbb4006c3076255a7ce01753f5f865e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.testplugin;
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.Status;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.ui.plugin.AbstractUIPlugin;
public class JavaTestPlugin extends AbstractUIPlugin {
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));
}
}