1 11 12 package org.eclipse.ui.internal; 13 14 import org.eclipse.core.runtime.ISafeRunnable; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Platform; 17 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 18 import org.eclipse.core.runtime.preferences.InstanceScope; 19 import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; 20 import org.eclipse.jface.internal.InternalPolicy; 21 import org.eclipse.jface.preference.JFacePreferences; 22 import org.eclipse.jface.util.ILogger; 23 import org.eclipse.jface.util.ISafeRunnableRunner; 24 import org.eclipse.jface.util.Policy; 25 import org.eclipse.jface.util.SafeRunnable; 26 import org.eclipse.ui.statushandlers.StatusManager; 27 28 33 final class JFaceUtil { 34 35 private JFaceUtil() { 36 } 38 39 42 public static void initializeJFace() { 43 SafeRunnable.setRunner(new ISafeRunnableRunner() { 45 public void run(ISafeRunnable code) { 46 Platform.run(code); 47 } 48 }); 49 50 Policy.setLog(new ILogger() { 53 public void log(IStatus status) { 54 if (status.getSeverity() == IStatus.WARNING 55 || status.getSeverity() == IStatus.ERROR) { 56 StatusManager.getManager().handle(status); 57 } else { 58 WorkbenchPlugin.log(status); 59 } 60 } 61 }); 62 63 64 if ("true".equalsIgnoreCase(Platform.getDebugOption("/debug"))) { Policy.DEBUG_DIALOG_NO_PARENT = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/dialog/noparent")); Policy.TRACE_ACTIONS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/actions")); Policy.TRACE_TOOLBAR = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/toolbarDisposal")); InternalPolicy.DEBUG_LOG_REENTRANT_VIEWER_CALLS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/viewers/reentrantViewerCalls")); } 71 } 72 73 77 public static void initializeJFacePreferences() { 78 IEclipsePreferences rootNode = (IEclipsePreferences) Platform.getPreferencesService().getRootNode().node(InstanceScope.SCOPE); 79 final String workbenchName = WorkbenchPlugin.getDefault().getBundle().getSymbolicName(); 80 81 rootNode.addNodeChangeListener(new IEclipsePreferences.INodeChangeListener() { 82 87 public void added(NodeChangeEvent event) { 88 if (!event.getChild().name().equals(workbenchName)) { 89 return; 90 } 91 ((IEclipsePreferences) event.getChild()).addPreferenceChangeListener(PlatformUIPreferenceListener.getSingleton()); 92 93 } 94 99 public void removed(NodeChangeEvent event) { 100 102 } 103 }); 104 105 JFacePreferences.setPreferenceStore(WorkbenchPlugin.getDefault().getPreferenceStore()); 106 } 107 } 108 | Popular Tags |