1 11 package org.eclipse.jdt.apt.ui.internal; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.core.runtime.Status; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.swt.widgets.Shell; 17 import org.eclipse.ui.IWorkbenchWindow; 18 import org.eclipse.ui.plugin.AbstractUIPlugin; 19 import org.osgi.framework.BundleContext; 20 21 24 public class AptUIPlugin extends AbstractUIPlugin { 25 26 private static AptUIPlugin plugin; 28 29 public static final String PLUGIN_ID = "org.eclipse.jdt.apt.ui"; 32 35 public static final int STATUS_EXCEPTION = 1; 36 public static final int INTERNAL_ERROR = 2; 37 38 41 public AptUIPlugin() { 42 plugin = this; 43 } 44 45 48 public void start(BundleContext context) throws Exception { 49 super.start(context); 50 } 51 52 55 public void stop(BundleContext context) throws Exception { 56 super.stop(context); 57 plugin = null; 58 } 59 60 63 public static AptUIPlugin getDefault() { 64 return plugin; 65 } 66 67 public static IWorkbenchWindow getActiveWorkbenchWindow() { 68 return getDefault().getWorkbench().getActiveWorkbenchWindow(); 69 } 70 71 public static Shell getActiveWorkbenchShell() { 72 IWorkbenchWindow window= getActiveWorkbenchWindow(); 73 if (window != null) { 74 return window.getShell(); 75 } 76 return null; 77 } 78 79 86 public static ImageDescriptor getImageDescriptor(String path) { 87 return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); 88 } 89 90 public static void log(IStatus status) { 91 getDefault().getLog().log(status); 92 } 93 94 public static void log(Throwable e) { 95 log(new Status(IStatus.ERROR, PLUGIN_ID, STATUS_EXCEPTION, Messages.AptUIPlugin_exceptionThrown, e)); 96 } 97 98 } 99 | Popular Tags |