Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 49497 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-1 / +2 lines)
Lines 4-10 Link Here
4
   id="org.eclipse.jface"
4
   id="org.eclipse.jface"
5
   name="%pluginName"
5
   name="%pluginName"
6
   version="3.1.0"
6
   version="3.1.0"
7
   provider-name="%providerName">
7
   provider-name="%providerName"
8
   class="org.eclipse.jface.JFacePlugin">
8
9
9
   <runtime>
10
   <runtime>
10
      <library name="jface.jar">
11
      <library name="jface.jar">
(-)src/org/eclipse/jface/preference/PreferenceDialog.java (-11 / +8 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.core.runtime.ISafeRunnable;
17
import org.eclipse.core.runtime.ISafeRunnable;
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.Status;
21
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.dialogs.DialogMessageArea;
21
import org.eclipse.jface.dialogs.DialogMessageArea;
Lines 29-34 Link Here
29
import org.eclipse.jface.resource.JFaceResources;
28
import org.eclipse.jface.resource.JFaceResources;
30
import org.eclipse.jface.util.Assert;
29
import org.eclipse.jface.util.Assert;
31
import org.eclipse.jface.util.IPropertyChangeListener;
30
import org.eclipse.jface.util.IPropertyChangeListener;
31
import org.eclipse.jface.util.Policy;
32
import org.eclipse.jface.util.PropertyChangeEvent;
32
import org.eclipse.jface.util.PropertyChangeEvent;
33
import org.eclipse.jface.util.SafeRunnable;
33
import org.eclipse.jface.util.SafeRunnable;
34
import org.eclipse.jface.viewers.ISelection;
34
import org.eclipse.jface.viewers.ISelection;
Lines 242-248 Link Here
242
		while (nodes.hasNext()) {
242
		while (nodes.hasNext()) {
243
			final IPreferenceNode node = (IPreferenceNode) nodes.next();
243
			final IPreferenceNode node = (IPreferenceNode) nodes.next();
244
			if (getPage(node) != null) {
244
			if (getPage(node) != null) {
245
				Platform.run(new SafeRunnable() {
245
				SafeRunnable.getRunner().run(new SafeRunnable() {
246
					public void run() {
246
					public void run() {
247
						if (!getPage(node).performCancel())
247
						if (!getPage(node).performCancel())
248
							return;
248
							return;
Lines 830-836 Link Here
830
	 * save any state, and then calls <code>close</code> to close this dialog.
830
	 * save any state, and then calls <code>close</code> to close this dialog.
831
	 */
831
	 */
832
	protected void okPressed() {
832
	protected void okPressed() {
833
		Platform.run(new SafeRunnable() {
833
		SafeRunnable.getRunner().run(new SafeRunnable() {
834
			private boolean errorOccurred;
834
			private boolean errorOccurred;
835
835
836
			/*
836
			/*
Lines 872-883 Link Here
872
			 */
872
			 */
873
			public void handleException(Throwable e) {
873
			public void handleException(Throwable e) {
874
				errorOccurred = true;
874
				errorOccurred = true;
875
				if (Platform.isRunning()) {
875
				
876
					String bundle = Platform.PI_RUNTIME;
876
				Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e));
877
					Platform.getLog(Platform.getBundle(bundle)).log(
877
878
							new Status(IStatus.ERROR, bundle, 0, e.toString(), e));
879
				} else
880
					e.printStackTrace();
881
				clearSelectedNode();
878
				clearSelectedNode();
882
				String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$
879
				String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$
883
				MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$
880
				MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$
Lines 1116-1122 Link Here
1116
		// (this allows lazy page control creation)
1113
		// (this allows lazy page control creation)
1117
		if (currentPage.getControl() == null) {
1114
		if (currentPage.getControl() == null) {
1118
			final boolean[] failed = { false };
1115
			final boolean[] failed = { false };
1119
			Platform.run(new ISafeRunnable() {
1116
			SafeRunnable.getRunner().run(new ISafeRunnable() {
1120
				public void handleException(Throwable e) {
1117
				public void handleException(Throwable e) {
1121
					failed[0] = true;
1118
					failed[0] = true;
1122
				}
1119
				}
Lines 1136-1142 Link Here
1136
		// label can be wrapped.
1133
		// label can be wrapped.
1137
		final Point[] size = new Point[1];
1134
		final Point[] size = new Point[1];
1138
		final Point failed = new Point(-1, -1);
1135
		final Point failed = new Point(-1, -1);
1139
		Platform.run(new ISafeRunnable() {
1136
		SafeRunnable.getRunner().run(new ISafeRunnable() {
1140
			public void handleException(Throwable e) {
1137
			public void handleException(Throwable e) {
1141
				size[0] = failed;
1138
				size[0] = failed;
1142
			}
1139
			}
(-)src/org/eclipse/jface/preference/PreferenceStore.java (-12 / +11 lines)
Lines 21-30 Link Here
21
import java.util.Enumeration;
21
import java.util.Enumeration;
22
import java.util.Properties;
22
import java.util.Properties;
23
23
24
import org.eclipse.jface.resource.JFaceResources;
24
import org.eclipse.jface.util.Assert;
25
import org.eclipse.jface.util.Assert;
25
import org.eclipse.jface.util.IPropertyChangeListener;
26
import org.eclipse.jface.util.IPropertyChangeListener;
26
import org.eclipse.jface.util.ListenerList;
27
import org.eclipse.jface.util.ListenerList;
27
import org.eclipse.jface.util.PropertyChangeEvent;
28
import org.eclipse.jface.util.PropertyChangeEvent;
29
import org.eclipse.jface.util.SafeRunnable;
28
30
29
/**
31
/**
30
 * A concrete preference store implementation based on an internal
32
 * A concrete preference store implementation based on an internal
Lines 129-146 Link Here
129
                && (oldValue == null || !oldValue.equals(newValue))) {
131
                && (oldValue == null || !oldValue.equals(newValue))) {
130
            final PropertyChangeEvent pe = new PropertyChangeEvent(this, name,
132
            final PropertyChangeEvent pe = new PropertyChangeEvent(this, name,
131
                    oldValue, newValue);
133
                    oldValue, newValue);
132
            //	FIXME: need to do this without dependency on
134
133
            // org.eclipse.core.runtime
135
            SafeRunnable.getRunner().run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
134
            //		Platform.run(new
136
            		public void run() {
135
            // SafeRunnable(JFaceResources.getString("PreferenceStore.changeError"))
137
			            for (int i = 0; i < finalListeners.length; ++i) {
136
            // { //$NON-NLS-1$
138
			                IPropertyChangeListener l = (IPropertyChangeListener) finalListeners[i];
137
            //			public void run() {
139
			                l.propertyChange(pe);
138
            for (int i = 0; i < finalListeners.length; ++i) {
140
			            }
139
                IPropertyChangeListener l = (IPropertyChangeListener) finalListeners[i];
141
            		}
140
                l.propertyChange(pe);
142
            });
141
            }
142
            //			}
143
            //		});
144
        }
143
        }
145
    }
144
    }
146
145
(-)src/org/eclipse/jface/util/DelegatingDragAdapter.java (-4 / +3 lines)
Lines 14-20 Link Here
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.swt.dnd.DragSource;
17
import org.eclipse.swt.dnd.DragSource;
19
import org.eclipse.swt.dnd.DragSourceEvent;
18
import org.eclipse.swt.dnd.DragSourceEvent;
20
import org.eclipse.swt.dnd.DragSourceListener;
19
import org.eclipse.swt.dnd.DragSourceListener;
Lines 119-125 Link Here
119
    public void dragFinished(final DragSourceEvent event) {
118
    public void dragFinished(final DragSourceEvent event) {
120
        //		if (Policy.DEBUG_DRAG_DROP)
119
        //		if (Policy.DEBUG_DRAG_DROP)
121
        //			System.out.println("Drag Finished: " + toString()); //$NON-NLS-1$
120
        //			System.out.println("Drag Finished: " + toString()); //$NON-NLS-1$
122
        Platform.run(new SafeRunnable() {
121
        SafeRunnable.getRunner().run(new SafeRunnable() {
123
            public void run() throws Exception {
122
            public void run() throws Exception {
124
                if (currentListener != null) {
123
                if (currentListener != null) {
125
                    // there is a listener that can handle the drop, delegate the event
124
                    // there is a listener that can handle the drop, delegate the event
Lines 151-157 Link Here
151
150
152
        updateCurrentListener(event); // find a listener that can provide the given data type
151
        updateCurrentListener(event); // find a listener that can provide the given data type
153
        if (currentListener != null) {
152
        if (currentListener != null) {
154
            Platform.run(new SafeRunnable() {
153
        	SafeRunnable.getRunner().run(new SafeRunnable() {
155
                public void run() throws Exception {
154
                public void run() throws Exception {
156
                    currentListener.dragSetData(event);
155
                    currentListener.dragSetData(event);
157
                }
156
                }
Lines 180-186 Link Here
180
            final TransferDragSourceListener listener = (TransferDragSourceListener) listeners
179
            final TransferDragSourceListener listener = (TransferDragSourceListener) listeners
181
                    .get(i);
180
                    .get(i);
182
            event.doit = true; // restore event.doit
181
            event.doit = true; // restore event.doit
183
            Platform.run(new SafeRunnable() {
182
            SafeRunnable.getRunner().run(new SafeRunnable() {
184
                public void run() throws Exception {
183
                public void run() throws Exception {
185
                    listener.dragStart(event);
184
                    listener.dragStart(event);
186
                }
185
                }
(-)src/org/eclipse/jface/util/DelegatingDropAdapter.java (-7 / +6 lines)
Lines 14-20 Link Here
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.swt.dnd.DND;
17
import org.eclipse.swt.dnd.DND;
19
import org.eclipse.swt.dnd.DropTargetEvent;
18
import org.eclipse.swt.dnd.DropTargetEvent;
20
import org.eclipse.swt.dnd.DropTargetListener;
19
import org.eclipse.swt.dnd.DropTargetListener;
Lines 164-170 Link Here
164
        // operation change. otherwise the new listener would get a dragEnter 
163
        // operation change. otherwise the new listener would get a dragEnter 
165
        // followed by a dragOperationChanged with the exact same event. 
164
        // followed by a dragOperationChanged with the exact same event. 
166
        if (newListener != null && newListener == oldListener) {
165
        if (newListener != null && newListener == oldListener) {
167
            Platform.run(new SafeRunnable() {
166
            SafeRunnable.getRunner().run(new SafeRunnable() {
168
                public void run() throws Exception {
167
                public void run() throws Exception {
169
                    newListener.dragOperationChanged(event);
168
                    newListener.dragOperationChanged(event);
170
                }
169
                }
Lines 190-196 Link Here
190
        // drag over. otherwise the new listener would get a dragEnter 
189
        // drag over. otherwise the new listener would get a dragEnter 
191
        // followed by a dragOver with the exact same event. 
190
        // followed by a dragOver with the exact same event. 
192
        if (newListener != null && newListener == oldListener) {
191
        if (newListener != null && newListener == oldListener) {
193
            Platform.run(new SafeRunnable() {
192
        	SafeRunnable.getRunner().run(new SafeRunnable() {
194
                public void run() throws Exception {
193
                public void run() throws Exception {
195
                    newListener.dragOver(event);
194
                    newListener.dragOver(event);
196
                }
195
                }
Lines 210-216 Link Here
210
        //			System.out.println("Drop: " + toString()); //$NON-NLS-1$
209
        //			System.out.println("Drop: " + toString()); //$NON-NLS-1$
211
        updateCurrentListener(event);
210
        updateCurrentListener(event);
212
        if (getCurrentListener() != null) {
211
        if (getCurrentListener() != null) {
213
            Platform.run(new SafeRunnable() {
212
        	SafeRunnable.getRunner().run(new SafeRunnable() {
214
                public void run() throws Exception {
213
                public void run() throws Exception {
215
                    getCurrentListener().drop(event);
214
                    getCurrentListener().drop(event);
216
                }
215
                }
Lines 229-235 Link Here
229
        //		if (Policy.DEBUG_DRAG_DROP)
228
        //		if (Policy.DEBUG_DRAG_DROP)
230
        //			System.out.println("Drop Accept: " + toString()); //$NON-NLS-1$
229
        //			System.out.println("Drop Accept: " + toString()); //$NON-NLS-1$
231
        if (getCurrentListener() != null) {
230
        if (getCurrentListener() != null) {
232
            Platform.run(new SafeRunnable() {
231
        	SafeRunnable.getRunner().run(new SafeRunnable() {
233
                public void run() throws Exception {
232
                public void run() throws Exception {
234
                    getCurrentListener().dropAccept(event);
233
                    getCurrentListener().dropAccept(event);
235
                }
234
                }
Lines 318-324 Link Here
318
        if (currentListener == listener)
317
        if (currentListener == listener)
319
            return false;
318
            return false;
320
        if (currentListener != null) {
319
        if (currentListener != null) {
321
            Platform.run(new SafeRunnable() {
320
        	SafeRunnable.getRunner().run(new SafeRunnable() {
322
                public void run() throws Exception {
321
                public void run() throws Exception {
323
                    currentListener.dragLeave(event);
322
                    currentListener.dragLeave(event);
324
                }
323
                }
Lines 328-334 Link Here
328
        //		if (Policy.DEBUG_DRAG_DROP)
327
        //		if (Policy.DEBUG_DRAG_DROP)
329
        //			System.out.println("Current drop listener: " + listener); //$NON-NLS-1$
328
        //			System.out.println("Current drop listener: " + listener); //$NON-NLS-1$
330
        if (currentListener != null) {
329
        if (currentListener != null) {
331
            Platform.run(new SafeRunnable() {
330
        	SafeRunnable.getRunner().run(new SafeRunnable() {
332
                public void run() throws Exception {
331
                public void run() throws Exception {
333
                    currentListener.dragEnter(event);
332
                    currentListener.dragEnter(event);
334
                }
333
                }
(-)src/org/eclipse/jface/util/Policy.java (-55 / +7 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jface.util;
11
package org.eclipse.jface.util;
12
12
13
import org.eclipse.core.runtime.ILog;
14
import org.eclipse.core.runtime.ILogListener;
15
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Platform;
17
import org.osgi.framework.Bundle;
18
14
19
/**
15
/**
20
 * The Policy class is a class to handle debug flags within the JFace plug-in.
16
 * The Policy class is a class to handle debug flags within the JFace plug-in.
Lines 33-39 Link Here
33
     */
29
     */
34
    public static final String JFACE = "org.eclipse.jface";//$NON-NLS-1$
30
    public static final String JFACE = "org.eclipse.jface";//$NON-NLS-1$
35
31
36
    private static ILog log;
32
    private static ILogger log;
37
33
38
    /**
34
    /**
39
     * A flag to indicate whether unparented dialogs should
35
     * A flag to indicate whether unparented dialogs should
Lines 57-127 Link Here
57
     */
53
     */
58
54
59
    public static boolean TRACE_TOOLBAR = DEFAULT;
55
    public static boolean TRACE_TOOLBAR = DEFAULT;
60
    static {
56
61
        if (getDebugOption("/debug")) { //$NON-NLS-1$
62
            DEBUG_DIALOG_NO_PARENT = getDebugOption("/debug/dialog/noparent"); //$NON-NLS-1$
63
            TRACE_ACTIONS = getDebugOption("/trace/actions"); //$NON-NLS-1$
64
            TRACE_TOOLBAR = getDebugOption("/trace/toolbarDisposal"); //$NON-NLS-1$
65
            SHOW_PREFERENCES_NEWLOOK = getDebugOption("/newlook/preferences/showNewLook");//$NON-NLS-1$
66
        }
67
    }
68
57
69
    /**
58
    /**
70
     * Get the dummy log to use if none has been set
59
     * Get the dummy log to use if none has been set
71
     * @return ILog
60
     * @return ILog
72
     */
61
     */
73
    private static ILog getDummyLog() {
62
    private static ILogger getDummyLog() {
74
        return new ILog() {
63
        return new ILogger() {
75
            /*
76
             * (non-Javadoc)
77
             * 
78
             * @see org.eclipse.core.runtime.ILog#addLogListener(org.eclipse.core.runtime.ILogListener)
79
             */
80
            public void addLogListener(ILogListener listener) {
81
                // Do nothing as this is a dummy placeholder
82
            }
83
84
            /*
85
             * (non-Javadoc)
86
             * 
87
             * @see org.eclipse.core.runtime.ILog#getBundle()
88
             */
89
            public Bundle getBundle() {
90
                //Do nothing as this is a dummy placeholder
91
                return null;
92
            }
93
94
            /*
95
             * (non-Javadoc)
96
             * 
97
             * @see org.eclipse.core.runtime.ILog#log(org.eclipse.core.runtime.IStatus)
98
             */
99
            public void log(IStatus status) {
64
            public void log(IStatus status) {
100
                System.err.println(status.getMessage());
65
                System.err.println(status.getMessage());
101
            }
66
            }
102
103
            /*
104
             * (non-Javadoc)
105
             * 
106
             * @see org.eclipse.core.runtime.ILog#removeLogListener(org.eclipse.core.runtime.ILogListener)
107
             */
108
            public void removeLogListener(ILogListener listener) {
109
                //Do nothing as this is a dummy placeholder
110
            }
111
        };
67
        };
112
    }
68
    }
113
69
114
    private static boolean getDebugOption(String option) {
70
115
        if (Platform.isRunning())
116
            return "true".equalsIgnoreCase(Platform.getDebugOption(JFACE + option)); //$NON-NLS-1$
117
        return false;
118
    }
119
71
120
    /**
72
    /**
121
     * Set the log to be forwarding log.
73
     * Set the log to be forwarding log.
122
     * @param forwardingLog
74
     * @param forwardingLog
123
     */
75
     */
124
    public static void setLog(ILog forwardingLog) {
76
    public static void setLog(ILogger forwardingLog) {
125
        log = forwardingLog;
77
        log = forwardingLog;
126
    }
78
    }
127
79
Lines 129-135 Link Here
129
     * Return the log the receiver is using.
81
     * Return the log the receiver is using.
130
     * @return ILog
82
     * @return ILog
131
     */
83
     */
132
    public static ILog getLog() {
84
    public static ILogger getLog() {
133
        if (log == null)
85
        if (log == null)
134
            log = getDummyLog();
86
            log = getDummyLog();
135
        return log;
87
        return log;
(-)src/org/eclipse/jface/util/SafeRunnable.java (+39 lines)
Lines 25-30 Link Here
25
    private String message;
25
    private String message;
26
26
27
    private static boolean ignoreErrors = false;
27
    private static boolean ignoreErrors = false;
28
    
29
    private static ISafeRunnableRunner runner = new ISafeRunnableRunner(){
30
		public void run(ISafeRunnable code) {
31
			try {
32
				code.run();
33
			} catch (Throwable t){
34
				t.printStackTrace();
35
				code.handleException(t);
36
			}			
37
		}};
28
38
29
    /**
39
    /**
30
     * Creates a new instance of SafeRunnable with a default error message.
40
     * Creates a new instance of SafeRunnable with a default error message.
Lines 78-81 Link Here
78
    public static void setIgnoreErrors(boolean flag) {
88
    public static void setIgnoreErrors(boolean flag) {
79
        ignoreErrors = flag;
89
        ignoreErrors = flag;
80
    }
90
    }
91
    
92
	/**
93
	 * @return Returns the runner.
94
	 * 
95
	 * @since 3.1
96
	 */
97
	public static ISafeRunnableRunner getRunner() {
98
		return runner;
99
	}
100
	
101
	/**
102
	 * @param runner The runner to set.
103
	 * 
104
	 * @since 3.1
105
	 */
106
	public static void setRunner(ISafeRunnableRunner runner) {
107
		SafeRunnable.runner = runner;
108
	}
109
	
110
111
	/**
112
	 * Runs SafeRunnable using the ISafeRunnableRunner registered statically.
113
	 * Equivalent to <code>SafeRunnable.getRunner().run(mySafeRunnable)</code>
114
	 * and when running within the Eclipse runtime equivalent to 
115
	 * <code>Platform.run(mySafeRunnable)</code>.
116
	 */
117
	public void runSafely(){
118
		SafeRunnable.getRunner().run(this);
119
	}
81
}
120
}
(-)src/org/eclipse/jface/viewers/AbstractTreeViewer.java (-4 / +3 lines)
Lines 15-21 Link Here
15
import java.util.Enumeration;
15
import java.util.Enumeration;
16
import java.util.List;
16
import java.util.List;
17
17
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.jface.util.Assert;
18
import org.eclipse.jface.util.Assert;
20
import org.eclipse.jface.util.ListenerList;
19
import org.eclipse.jface.util.ListenerList;
21
import org.eclipse.jface.util.SafeRunnable;
20
import org.eclipse.jface.util.SafeRunnable;
Lines 487-493 Link Here
487
            }
486
            }
488
487
489
            // update icon and label
488
            // update icon and label
490
            Platform.run(new UpdateItemSafeRunnable(item, element));
489
            SafeRunnable.getRunner().run(new UpdateItemSafeRunnable(item, element));
491
        }
490
        }
492
    }
491
    }
493
492
Lines 539-545 Link Here
539
        Object[] listeners = treeListeners.getListeners();
538
        Object[] listeners = treeListeners.getListeners();
540
        for (int i = 0; i < listeners.length; ++i) {
539
        for (int i = 0; i < listeners.length; ++i) {
541
            final ITreeViewerListener l = (ITreeViewerListener) listeners[i];
540
            final ITreeViewerListener l = (ITreeViewerListener) listeners[i];
542
            Platform.run(new SafeRunnable() {
541
            SafeRunnable.getRunner().run(new SafeRunnable() {
543
                public void run() {
542
                public void run() {
544
                    l.treeCollapsed(event);
543
                    l.treeCollapsed(event);
545
                }
544
                }
Lines 559-565 Link Here
559
        Object[] listeners = treeListeners.getListeners();
558
        Object[] listeners = treeListeners.getListeners();
560
        for (int i = 0; i < listeners.length; ++i) {
559
        for (int i = 0; i < listeners.length; ++i) {
561
            final ITreeViewerListener l = (ITreeViewerListener) listeners[i];
560
            final ITreeViewerListener l = (ITreeViewerListener) listeners[i];
562
            Platform.run(new SafeRunnable() {
561
            SafeRunnable.getRunner().run(new SafeRunnable() {
563
                public void run() {
562
                public void run() {
564
                    l.treeExpanded(event);
563
                    l.treeExpanded(event);
565
                }
564
                }
(-)src/org/eclipse/jface/viewers/CellEditor.java (-5 / +4 lines)
Lines 11-17 Link Here
11
11
12
package org.eclipse.jface.viewers;
12
package org.eclipse.jface.viewers;
13
13
14
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.jface.util.Assert;
14
import org.eclipse.jface.util.Assert;
16
import org.eclipse.jface.util.IPropertyChangeListener;
15
import org.eclipse.jface.util.IPropertyChangeListener;
17
import org.eclipse.jface.util.ListenerList;
16
import org.eclipse.jface.util.ListenerList;
Lines 300-306 Link Here
300
        Object[] array = listeners.getListeners();
299
        Object[] array = listeners.getListeners();
301
        for (int i = 0; i < array.length; i++) {
300
        for (int i = 0; i < array.length; i++) {
302
            final ICellEditorListener l = (ICellEditorListener) array[i];
301
            final ICellEditorListener l = (ICellEditorListener) array[i];
303
            Platform.run(new SafeRunnable() {
302
            SafeRunnable.getRunner().run(new SafeRunnable() {
304
                public void run() {
303
                public void run() {
305
                    l.applyEditorValue();
304
                    l.applyEditorValue();
306
                }
305
                }
Lines 318-324 Link Here
318
        Object[] array = listeners.getListeners();
317
        Object[] array = listeners.getListeners();
319
        for (int i = 0; i < array.length; i++) {
318
        for (int i = 0; i < array.length; i++) {
320
            final ICellEditorListener l = (ICellEditorListener) array[i];
319
            final ICellEditorListener l = (ICellEditorListener) array[i];
321
            Platform.run(new SafeRunnable() {
320
            SafeRunnable.getRunner().run(new SafeRunnable() {
322
                public void run() {
321
                public void run() {
323
                    l.cancelEditor();
322
                    l.cancelEditor();
324
                }
323
                }
Lines 338-344 Link Here
338
        Object[] array = listeners.getListeners();
337
        Object[] array = listeners.getListeners();
339
        for (int i = 0; i < array.length; i++) {
338
        for (int i = 0; i < array.length; i++) {
340
            final ICellEditorListener l = (ICellEditorListener) array[i];
339
            final ICellEditorListener l = (ICellEditorListener) array[i];
341
            Platform.run(new SafeRunnable() {
340
            SafeRunnable.getRunner().run(new SafeRunnable() {
342
                public void run() {
341
                public void run() {
343
                    l.editorValueChanged(oldValidState, newValidState);
342
                    l.editorValueChanged(oldValidState, newValidState);
344
                }
343
                }
Lines 356-362 Link Here
356
        Object[] array = propertyChangeListeners.getListeners();
355
        Object[] array = propertyChangeListeners.getListeners();
357
        for (int i = 0; i < array.length; i++) {
356
        for (int i = 0; i < array.length; i++) {
358
            final IPropertyChangeListener l = (IPropertyChangeListener) array[i];
357
            final IPropertyChangeListener l = (IPropertyChangeListener) array[i];
359
            Platform.run(new SafeRunnable() {
358
            SafeRunnable.getRunner().run(new SafeRunnable() {
360
                public void run() {
359
                public void run() {
361
                    l.propertyChange(new PropertyChangeEvent(this, actionId,
360
                    l.propertyChange(new PropertyChangeEvent(this, actionId,
362
                            null, null));
361
                            null, null));
(-)src/org/eclipse/jface/viewers/CheckboxTableViewer.java (-2 / +1 lines)
Lines 13-19 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.jface.util.Assert;
16
import org.eclipse.jface.util.Assert;
18
import org.eclipse.jface.util.ListenerList;
17
import org.eclipse.jface.util.ListenerList;
19
import org.eclipse.jface.util.SafeRunnable;
18
import org.eclipse.jface.util.SafeRunnable;
Lines 172-178 Link Here
172
        Object[] array = checkStateListeners.getListeners();
171
        Object[] array = checkStateListeners.getListeners();
173
        for (int i = 0; i < array.length; i++) {
172
        for (int i = 0; i < array.length; i++) {
174
            final ICheckStateListener l = (ICheckStateListener) array[i];
173
            final ICheckStateListener l = (ICheckStateListener) array[i];
175
            Platform.run(new SafeRunnable() {
174
            SafeRunnable.getRunner().run(new SafeRunnable() {
176
                public void run() {
175
                public void run() {
177
                    l.checkStateChanged(event);
176
                    l.checkStateChanged(event);
178
                }
177
                }
(-)src/org/eclipse/jface/viewers/CheckboxTreeViewer.java (-2 / +1 lines)
Lines 13-19 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.jface.util.Assert;
16
import org.eclipse.jface.util.Assert;
18
import org.eclipse.jface.util.ListenerList;
17
import org.eclipse.jface.util.ListenerList;
19
import org.eclipse.jface.util.SafeRunnable;
18
import org.eclipse.jface.util.SafeRunnable;
Lines 129-135 Link Here
129
        Object[] array = checkStateListeners.getListeners();
128
        Object[] array = checkStateListeners.getListeners();
130
        for (int i = 0; i < array.length; i++) {
129
        for (int i = 0; i < array.length; i++) {
131
            final ICheckStateListener l = (ICheckStateListener) array[i];
130
            final ICheckStateListener l = (ICheckStateListener) array[i];
132
            Platform.run(new SafeRunnable() {
131
            SafeRunnable.getRunner().run(new SafeRunnable() {
133
                public void run() {
132
                public void run() {
134
                    l.checkStateChanged(event);
133
                    l.checkStateChanged(event);
135
                }
134
                }
(-)src/org/eclipse/jface/viewers/LabelProvider.java (-2 / +1 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jface.viewers;
11
package org.eclipse.jface.viewers;
12
12
13
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.jface.util.ListenerList;
13
import org.eclipse.jface.util.ListenerList;
15
import org.eclipse.jface.util.SafeRunnable;
14
import org.eclipse.jface.util.SafeRunnable;
16
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.graphics.Image;
Lines 65-71 Link Here
65
        Object[] listeners = this.listeners.getListeners();
64
        Object[] listeners = this.listeners.getListeners();
66
        for (int i = 0; i < listeners.length; ++i) {
65
        for (int i = 0; i < listeners.length; ++i) {
67
            final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
66
            final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
68
            Platform.run(new SafeRunnable() {
67
            SafeRunnable.getRunner().run(new SafeRunnable() {
69
                public void run() {
68
                public void run() {
70
                    l.labelProviderChanged(event);
69
                    l.labelProviderChanged(event);
71
                }
70
                }
(-)src/org/eclipse/jface/viewers/StructuredViewer.java (-6 / +5 lines)
Lines 14-20 Link Here
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.core.runtime.Platform;
18
import org.eclipse.jface.util.Assert;
17
import org.eclipse.jface.util.Assert;
19
import org.eclipse.jface.util.IOpenEventListener;
18
import org.eclipse.jface.util.IOpenEventListener;
20
import org.eclipse.jface.util.ListenerList;
19
import org.eclipse.jface.util.ListenerList;
Lines 633-639 Link Here
633
		Object[] listeners = doubleClickListeners.getListeners();
632
		Object[] listeners = doubleClickListeners.getListeners();
634
		for (int i = 0; i < listeners.length; ++i) {
633
		for (int i = 0; i < listeners.length; ++i) {
635
			final IDoubleClickListener l = (IDoubleClickListener) listeners[i];
634
			final IDoubleClickListener l = (IDoubleClickListener) listeners[i];
636
			Platform.run(new SafeRunnable() {
635
			SafeRunnable.getRunner().run(new SafeRunnable() {
637
				public void run() {
636
				public void run() {
638
					l.doubleClick(event);
637
					l.doubleClick(event);
639
				}
638
				}
Lines 654-660 Link Here
654
		Object[] listeners = openListeners.getListeners();
653
		Object[] listeners = openListeners.getListeners();
655
		for (int i = 0; i < listeners.length; ++i) {
654
		for (int i = 0; i < listeners.length; ++i) {
656
			final IOpenListener l = (IOpenListener) listeners[i];
655
			final IOpenListener l = (IOpenListener) listeners[i];
657
			Platform.run(new SafeRunnable() {
656
			SafeRunnable.getRunner().run(new SafeRunnable() {
658
				public void run() {
657
				public void run() {
659
					l.open(event);
658
					l.open(event);
660
				}
659
				}
Lines 676-682 Link Here
676
		Object[] listeners = postSelectionChangedListeners.getListeners();
675
		Object[] listeners = postSelectionChangedListeners.getListeners();
677
		for (int i = 0; i < listeners.length; ++i) {
676
		for (int i = 0; i < listeners.length; ++i) {
678
			final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
677
			final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
679
			Platform.run(new SafeRunnable() {
678
			SafeRunnable.getRunner().run(new SafeRunnable() {
680
				public void run() {
679
				public void run() {
681
					l.selectionChanged(event);
680
					l.selectionChanged(event);
682
				}
681
				}
Lines 1213-1219 Link Here
1213
	 * @param element
1212
	 * @param element
1214
	 */
1213
	 */
1215
	protected final void refreshItem(Widget widget, Object element) {
1214
	protected final void refreshItem(Widget widget, Object element) {
1216
		Platform.run(new UpdateItemSafeRunnable(widget, element, true));
1215
		SafeRunnable.getRunner().run(new UpdateItemSafeRunnable(widget, element, true));
1217
	}
1216
	}
1218
1217
1219
	/**
1218
	/**
Lines 1643-1649 Link Here
1643
	 *            the element
1642
	 *            the element
1644
	 */
1643
	 */
1645
	protected final void updateItem(Widget widget, Object element) {
1644
	protected final void updateItem(Widget widget, Object element) {
1646
		Platform.run(new UpdateItemSafeRunnable(widget, element, true));
1645
		SafeRunnable.getRunner().run(new UpdateItemSafeRunnable(widget, element, true));
1647
	}
1646
	}
1648
1647
1649
	/**
1648
	/**
(-)src/org/eclipse/jface/viewers/Viewer.java (-2 / +1 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jface.viewers;
11
package org.eclipse.jface.viewers;
12
12
13
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.jface.util.Assert;
13
import org.eclipse.jface.util.Assert;
15
import org.eclipse.jface.util.ListenerList;
14
import org.eclipse.jface.util.ListenerList;
16
import org.eclipse.jface.util.SafeRunnable;
15
import org.eclipse.jface.util.SafeRunnable;
Lines 158-164 Link Here
158
        Object[] listeners = selectionChangedListeners.getListeners();
157
        Object[] listeners = selectionChangedListeners.getListeners();
159
        for (int i = 0; i < listeners.length; ++i) {
158
        for (int i = 0; i < listeners.length; ++i) {
160
            final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
159
            final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
161
            Platform.run(new SafeRunnable() {
160
            SafeRunnable.getRunner().run(new SafeRunnable() {
162
                public void run() {
161
                public void run() {
163
                    l.selectionChanged(event);
162
                    l.selectionChanged(event);
164
                }
163
                }
(-)src/org/eclipse/jface/JFacePlugin.java (+53 lines)
Added Link Here
1
package org.eclipse.jface;
2
3
import org.eclipse.core.runtime.ISafeRunnable;
4
import org.eclipse.core.runtime.IStatus;
5
import org.eclipse.core.runtime.Platform;
6
import org.eclipse.core.runtime.Plugin;
7
import org.eclipse.jface.util.ILogger;
8
import org.eclipse.jface.util.ISafeRunnableRunner;
9
import org.eclipse.jface.util.Policy;
10
import org.eclipse.jface.util.SafeRunnable;
11
import org.osgi.framework.BundleContext;
12
13
/**
14
 * JFace Plug-in responsible for wiring the Platform 
15
 * and JFace together.
16
 * 
17
 * @author Chris Gross (schtoo@schtoo.com)
18
 */
19
public class JFacePlugin extends Plugin {
20
21
	/**
22
	 * 
23
	 */
24
	public JFacePlugin() {
25
		super();
26
	}
27
28
	public void start(BundleContext context) throws Exception {
29
		super.start(context);
30
		
31
		//Set the Platform to run all SafeRunnables
32
		SafeRunnable.setRunner(new ISafeRunnableRunner(){
33
			public void run(ISafeRunnable code) {
34
				Platform.run(code);
35
			}});
36
		
37
		//Log all errors to the main runtime log
38
		Policy.setLog(new ILogger(){
39
			public void log(IStatus status) {
40
				Platform.getLog(Platform.getBundle(Platform.PI_RUNTIME)).log(status);
41
			}});
42
		
43
		//Get all debug options from Platform		
44
		if ("true".equalsIgnoreCase(Platform.getDebugOption("/debug"))) { //$NON-NLS-1$ //$NON-NLS-2$
45
			Policy.DEBUG_DIALOG_NO_PARENT = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/debug/dialog/noparent")); //$NON-NLS-1$ //$NON-NLS-2$
46
			Policy.TRACE_ACTIONS = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/actions")); //$NON-NLS-1$ //$NON-NLS-2$
47
			Policy.TRACE_TOOLBAR = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/trace/toolbarDisposal")); //$NON-NLS-1$ //$NON-NLS-2$
48
			Policy.SHOW_PREFERENCES_NEWLOOK = "true".equalsIgnoreCase(Platform.getDebugOption(Policy.JFACE + "/newlook/preferences/showNewLook"));//$NON-NLS-1$ //$NON-NLS-2$
49
		}
50
		
51
	}
52
53
}
(-)src/org/eclipse/jface/util/ILogger.java (+19 lines)
Added Link Here
1
package org.eclipse.jface.util;
2
3
import org.eclipse.core.runtime.IStatus;
4
5
/**
6
 * A mechanism to log errors throughout JFace.
7
 * 
8
 * @author Chris Gross (schtoo@schtoo.com)
9
 */
10
public interface ILogger {
11
	
12
	/**
13
	 * Logs the given status.
14
	 * 
15
	 * @param status status to log
16
	 */
17
	public void log(IStatus status);
18
19
}
(-)src/org/eclipse/jface/util/ISafeRunnableRunner.java (+20 lines)
Added Link Here
1
package org.eclipse.jface.util;
2
3
import org.eclipse.core.runtime.ISafeRunnable;
4
import org.eclipse.core.runtime.Platform;
5
6
/**
7
 * @author Chris Gross (schtoo@schtoo.com)
8
 */
9
public interface ISafeRunnableRunner {
10
	
11
	/**
12
	 * Runs the runnable.  All ISafeRunnableRunners must catch any exception
13
	 * thrown by the ISafeRunnable and pass the exception to 
14
	 * ISafeRunnable.handleException();
15
	 *
16
	 * @see Platform#run(ISafeRunnable)
17
	 */
18
	public abstract void run(ISafeRunnable code);
19
	
20
}

Return to bug 49497