package org.eclipse.ui.views.file;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* Controls the plug-in life cycle.
*/
public class Activator extends AbstractUIPlugin {
private static Activator instance;
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
instance = this;
ResourcesPlugin.getWorkspace().addResourceChangeListener(new ViewedFileChangeListener(), IResourceChangeEvent.POST_CHANGE);
}
@Override
public void stop(BundleContext context) throws Exception {
instance = null;
super.stop(context);
}
/**
* Returns the shared instance.
*/
public static Activator getInstance() {
return instance;
}
/**
* Returns the plug-in's identifier.
*/
public static String getId() {
return getInstance().getBundle().getSymbolicName();
}
/**
* Returns an image descriptor for the image file at the given plug-in
* relative path.
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(getId(), path);
}
/**
* Logs an exception with a message.
*/
public static void logError(String message, Throwable throwable) {
getInstance().getLog().log(new Status(IStatus.ERROR, getId(), message, throwable));
}
}