1 18 package org.visualcontent.authentication.simplecredentials; 19 20 import org.eclipse.core.runtime.IStatus; 21 import org.eclipse.core.runtime.Status; 22 import org.eclipse.jface.dialogs.ErrorDialog; 23 import org.eclipse.jface.resource.ImageDescriptor; 24 import org.eclipse.ui.PlatformUI; 25 import org.eclipse.ui.plugin.AbstractUIPlugin; 26 import org.osgi.framework.BundleContext; 27 28 31 public class SimplecredentialsPlugin extends AbstractUIPlugin { 32 33 private static SimplecredentialsPlugin plugin; 35 36 39 public SimplecredentialsPlugin() { 40 plugin = this; 41 } 42 43 public void log(String message, Throwable t){ 44 45 IStatus status = getErrorStatus(message, t); 46 this.getLog().log(status); 47 } 48 49 private IStatus getErrorStatus(String message, Throwable t) { 50 IStatus status = new Status( 51 Status.ERROR, 52 this.getBundle().getSymbolicName(), 53 Status.OK, 54 message, 55 t); 56 return status; 57 } 58 59 public void showError(String message, Throwable t){ 60 this.log(message,t); 61 IStatus status = getErrorStatus(message, t); 62 ErrorDialog.openError( 64 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 65 null, 66 null, 67 status); 68 } 69 72 public void start(BundleContext context) throws Exception { 73 super.start(context); 74 } 75 76 79 public void stop(BundleContext context) throws Exception { 80 super.stop(context); 81 plugin = null; 82 } 83 84 87 public static SimplecredentialsPlugin getDefault() { 88 return plugin; 89 } 90 91 98 public static ImageDescriptor getImageDescriptor(String path) { 99 return AbstractUIPlugin.imageDescriptorFromPlugin("org.visualcontent.authentication.simplecredentials", path); 100 } 101 } 102 | Popular Tags |