| 1 11 package org.eclipse.ui.internal.navigator.resources.plugin; 12 13 import org.eclipse.core.resources.IWorkspace; 14 import org.eclipse.core.resources.ResourcesPlugin; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.ui.plugin.AbstractUIPlugin; 18 19 32 public class WorkbenchNavigatorPlugin extends AbstractUIPlugin { 33 private static WorkbenchNavigatorPlugin plugin; 35 36 37 public static String PLUGIN_ID = "org.eclipse.ui.navigator.resources"; 39 42 public WorkbenchNavigatorPlugin() { 43 super(); 44 plugin = this; 45 } 46 47 50 public static WorkbenchNavigatorPlugin getDefault() { 51 return plugin; 52 } 53 54 57 public static IWorkspace getWorkspace() { 58 return ResourcesPlugin.getWorkspace(); 59 } 60 61 66 public static void log(String message, IStatus status) { 67 if (message != null) { 68 getDefault().getLog().log( 69 new Status(IStatus.ERROR, PLUGIN_ID, 0, message, null)); 70 System.err.println(message + "\nReason:"); } 72 if(status != null) { 73 getDefault().getLog().log(status); 74 System.err.println(status.getMessage()); 75 } 76 } 77 78 88 public static IStatus createStatus(int severity, int aCode, 89 String aMessage, Throwable exception) { 90 return new Status(severity, PLUGIN_ID, aCode, 91 aMessage != null ? aMessage : "No message.", exception); } 93 94 102 public static IStatus createErrorStatus(int aCode, String aMessage, 103 Throwable exception) { 104 return createStatus(IStatus.ERROR, aCode, aMessage, exception); 105 } 106 107 108 115 public static IStatus createErrorStatus(String aMessage, Throwable exception) { 116 return createStatus(IStatus.ERROR, 0, aMessage, exception); 117 } 118 119 125 public static IStatus createErrorStatus(String aMessage) { 126 return createStatus(IStatus.ERROR, 0, aMessage, null); 127 } 128 129 130 136 public static IStatus createInfoStatus(String aMessage) { 137 return createStatus(IStatus.INFO, 0, aMessage, null); 138 } 139 140 141 147 public static IStatus createWarningStatus(String aMessage) { 148 return createStatus(IStatus.WARNING, 0, aMessage, null); 149 } 150 } 151 | Popular Tags |