1 13 package org.eclipse.jface.util; 14 15 import java.util.Comparator ; 16 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.jface.dialogs.AnimatorFactory; 19 import org.eclipse.jface.dialogs.ErrorSupportProvider; 20 21 27 public class Policy { 28 29 32 public static final boolean DEFAULT = false; 33 34 37 public static final String JFACE = "org.eclipse.jface"; 39 private static ILogger log; 40 41 private static Comparator viewerComparator; 42 43 private static AnimatorFactory animatorFactory; 44 45 48 public static boolean DEBUG_DIALOG_NO_PARENT = DEFAULT; 49 50 53 public static boolean TRACE_ACTIONS = DEFAULT; 54 55 58 59 public static boolean TRACE_TOOLBAR = DEFAULT; 60 61 private static ErrorSupportProvider errorSupportProvider; 62 63 66 private static ILogger getDummyLog() { 67 return new ILogger() { 68 public void log(IStatus status) { 69 System.err.println(status.getMessage()); 70 if (status.getException() != null) { 71 status.getException().printStackTrace(System.err); 72 } 73 } 74 }; 75 } 76 77 85 public static void setLog(ILogger logger) { 86 log = logger; 87 } 88 89 98 public static ILogger getLog() { 99 if (log == null) { 100 log = getDummyLog(); 101 } 102 return log; 103 } 104 105 110 private static Comparator getDefaultComparator() { 111 return new Comparator () { 112 126 public int compare(Object s1, Object s2) { 127 return ((String ) s1).compareTo((String ) s2); 128 } 129 }; 130 } 131 132 138 public static Comparator getComparator() { 139 if (viewerComparator == null) { 140 viewerComparator = getDefaultComparator(); 141 } 142 return viewerComparator; 143 } 144 145 152 public static void setComparator(Comparator comparator) { 153 org.eclipse.core.runtime.Assert.isTrue(viewerComparator == null); 154 viewerComparator = comparator; 155 } 156 157 166 public static void setAnimatorFactory(AnimatorFactory factory) { 167 animatorFactory = factory; 168 } 169 170 178 public static AnimatorFactory getAnimatorFactory() { 179 if (animatorFactory == null) 180 animatorFactory = new AnimatorFactory(); 181 return animatorFactory; 182 } 183 184 190 public static void setErrorSupportProvider(ErrorSupportProvider provider) { 191 errorSupportProvider = provider; 192 } 193 194 200 public static ErrorSupportProvider getErrorSupportProvider() { 201 return errorSupportProvider; 202 } 203 204 } 205 | Popular Tags |