blob: c1d547188d98cec4e14c1124a7a1cdd0c3c6e907 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.exampleprojects;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The main plugin class to be used in the desktop.
*/
public class ExampleProjectsPlugin extends AbstractUIPlugin {
// The shared instance.
private static ExampleProjectsPlugin fgPlugin;
/**
* The constructor.
*/
public ExampleProjectsPlugin(IPluginDescriptor descriptor) {
super(descriptor);
fgPlugin= this;
}
/**
* Returns the shared instance.
*/
public static ExampleProjectsPlugin getDefault() {
return fgPlugin;
}
/**
* Returns the workspace instance.
*/
public static IWorkspace getWorkspace() {
return ResourcesPlugin.getWorkspace();
}
public ImageDescriptor getImageDescriptor(String name) {
try {
URL url= new URL(getDescriptor().getInstallURL(), name);
return ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {
return ImageDescriptor.getMissingImageDescriptor();
}
}
public static String getPluginId() {
return getDefault().getDescriptor().getUniqueIdentifier();
}
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
public static void log(String message) {
log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null));
}
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, "Internal Error", e)); //$NON-NLS-1$
}
}