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 173678
Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/statushandlers/StatusDialog.java (-65 / +61 lines)
Lines 10-27 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.statushandlers;
11
package org.eclipse.ui.statushandlers;
12
12
13
import java.net.URL;
14
import java.util.HashMap;
13
import java.util.HashMap;
15
import java.util.Iterator;
14
import java.util.Iterator;
16
import java.util.Map;
15
import java.util.Map;
17
16
18
import org.eclipse.core.runtime.jobs.Job;
19
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.IAction;
20
import org.eclipse.jface.dialogs.ErrorDialog;
18
import org.eclipse.jface.dialogs.ErrorDialog;
21
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.IDialogConstants;
22
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
20
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
23
import org.eclipse.jface.preference.IPreferenceStore;
21
import org.eclipse.jface.preference.IPreferenceStore;
24
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.viewers.IContentProvider;
22
import org.eclipse.jface.viewers.IContentProvider;
26
import org.eclipse.jface.viewers.ILabelProviderListener;
23
import org.eclipse.jface.viewers.ILabelProviderListener;
27
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.ISelection;
Lines 43-56 Link Here
43
import org.eclipse.swt.widgets.Button;
40
import org.eclipse.swt.widgets.Button;
44
import org.eclipse.swt.widgets.Composite;
41
import org.eclipse.swt.widgets.Composite;
45
import org.eclipse.swt.widgets.Control;
42
import org.eclipse.swt.widgets.Control;
46
import org.eclipse.swt.widgets.Display;
47
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.swt.widgets.Shell;
48
import org.eclipse.ui.internal.WorkbenchPlugin;
44
import org.eclipse.ui.internal.WorkbenchPlugin;
49
import org.eclipse.ui.internal.progress.ProgressManager;
50
import org.eclipse.ui.internal.progress.ProgressManagerUtil;
45
import org.eclipse.ui.internal.progress.ProgressManagerUtil;
51
import org.eclipse.ui.internal.progress.ProgressMessages;
46
import org.eclipse.ui.internal.progress.ProgressMessages;
52
import org.eclipse.ui.progress.IProgressConstants;
47
import org.eclipse.ui.statushandlers.StatusNotificationManager.StatusAdapterInfo;
53
import org.eclipse.ui.statushandlers.StatusNotificationManager.StatusInfo;
54
48
55
/**
49
/**
56
 * A dialog for displaying
50
 * A dialog for displaying
Lines 71-77 Link Here
71
65
72
	private TableViewer statusListViewer;
66
	private TableViewer statusListViewer;
73
67
74
	private StatusInfo selectedStatus;
68
	private StatusAdapterInfo selectedStatus;
75
69
76
	/**
70
	/**
77
	 * Create a new instance of the receiver.
71
	 * Create a new instance of the receiver.
Lines 83-91 Link Here
83
	 * @param displayMask
77
	 * @param displayMask
84
	 */
78
	 */
85
	public StatusDialog(Shell parentShell, String title, String msg,
79
	public StatusDialog(Shell parentShell, String title, String msg,
86
			StatusInfo statusInfo, int displayMask) {
80
			StatusAdapterInfo statusInfo, int displayMask) {
87
		super(parentShell, (title == null ? statusInfo.getStatus().getMessage()
81
		super(parentShell, (title == null ? statusInfo.getStatusAdapter()
88
				: title), msg, statusInfo.getStatus(), displayMask);
82
				.getTitle() : title), msg, statusInfo.getStatusAdapter()
83
				.getStatus(), displayMask);
89
		setShellStyle(SWT.RESIZE | SWT.MIN | getShellStyle());
84
		setShellStyle(SWT.RESIZE | SWT.MIN | getShellStyle());
90
		this.selectedStatus = statusInfo;
85
		this.selectedStatus = statusInfo;
91
		setBlockOnOpen(false);
86
		setBlockOnOpen(false);
Lines 146-152 Link Here
146
	private void updateEnablements() {
141
	private void updateEnablements() {
147
		Button details = getButton(IDialogConstants.DETAILS_ID);
142
		Button details = getButton(IDialogConstants.DETAILS_ID);
148
		if (details != null) {
143
		if (details != null) {
149
			details.setEnabled(selectedStatus.getStatus().isMultiStatus()
144
			details.setEnabled(selectedStatus.getStatusAdapter().getStatus()
145
					.isMultiStatus()
150
					|| isMultipleStatusDialog());
146
					|| isMultipleStatusDialog());
151
		}
147
		}
152
		Button gotoButton = getButton(GOTO_ACTION_ID);
148
		Button gotoButton = getButton(GOTO_ACTION_ID);
Lines 212-228 Link Here
212
208
213
	private IAction getGotoAction() {
209
	private IAction getGotoAction() {
214
210
215
		Object extension = selectedStatus.getExtension();
211
//		Object extension = selectedStatus.getExtension();
216
		Object property = null;
212
//		Object property = null;
217
213
//
218
		if (extension != null && extension instanceof Job) {
214
//		if (extension != null && extension instanceof Job) {
219
			property = ((Job) extension)
215
//			property = ((Job) extension)
220
					.getProperty(IProgressConstants.ACTION_PROPERTY);
216
//					.getProperty(IProgressConstants.ACTION_PROPERTY);
221
		}
217
//		}
222
218
//
223
		if (property instanceof IAction) {
219
//		if (property instanceof IAction) {
224
			return (IAction) property;
220
//			return (IAction) property;
225
		}
221
//		}
226
		return null;
222
		return null;
227
	}
223
	}
228
224
Lines 288-294 Link Here
288
	 * 
284
	 * 
289
	 * @return ErrorInfo
285
	 * @return ErrorInfo
290
	 */
286
	 */
291
	public StatusInfo getSelectedError() {
287
	public StatusAdapterInfo getSelectedError() {
292
		return selectedStatus;
288
		return selectedStatus;
293
	}
289
	}
294
290
Lines 362-368 Link Here
362
			Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
358
			Point newSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
363
			getShell().setSize(newSize);
359
			getShell().setSize(newSize);
364
		}
360
		}
365
		setStatus(selectedStatus.getStatus());
361
		setStatus(selectedStatus.getStatusAdapter().getStatus());
366
	}
362
	}
367
363
368
	private void initLabelProvider() {
364
	private void initLabelProvider() {
Lines 400-446 Link Here
400
			 *      int)
396
			 *      int)
401
			 */
397
			 */
402
			public Image getColumnImage(Object element, int columnIndex) {
398
			public Image getColumnImage(Object element, int columnIndex) {
403
				if (element != null) {
399
//				if (element != null) {
404
					Object extension = ((StatusInfo) element).getExtension();
400
//					Object extension = ((StatusInfo) element).getExtension();
405
					if (extension != null && extension instanceof Job) {
401
//					if (extension != null && extension instanceof Job) {
406
						return getIcon((Job) extension);
402
//						return getIcon((Job) extension);
407
					}
403
//					}
408
				}
404
//				}
409
				return null;
405
				return null;
410
			}
406
			}
411
407
412
			/*
408
			/*
413
			 * Get the icon for the job. Code copied from NewProgressViewer
409
			 * Get the icon for the job. Code copied from NewProgressViewer
414
			 */
410
			 */
415
			private Image getIcon(Job job) {
411
//			private Image getIcon(Job job) {
416
				if (job != null) {
412
//				if (job != null) {
417
413
//
418
					Object property = job
414
//					Object property = job
419
							.getProperty(IProgressConstants.ICON_PROPERTY);
415
//							.getProperty(IProgressConstants.ICON_PROPERTY);
420
416
//
421
					// If we already have an image cached, return it
417
//					// If we already have an image cached, return it
422
					Image im = (Image) imageTable.get(property);
418
//					Image im = (Image) imageTable.get(property);
423
					if (im != null) {
419
//					if (im != null) {
424
						return im;
420
//						return im;
425
					}
421
//					}
426
422
//
427
					// Create an image from the job's icon property or family
423
//					// Create an image from the job's icon property or family
428
					Display display = getShell().getDisplay();
424
//					Display display = getShell().getDisplay();
429
					if (property instanceof ImageDescriptor) {
425
//					if (property instanceof ImageDescriptor) {
430
						im = ((ImageDescriptor) property).createImage(display);
426
//						im = ((ImageDescriptor) property).createImage(display);
431
						imageTable.put(property, im); // Cache for disposal
427
//						imageTable.put(property, im); // Cache for disposal
432
					} else if (property instanceof URL) {
428
//					} else if (property instanceof URL) {
433
						im = ImageDescriptor.createFromURL((URL) property)
429
//						im = ImageDescriptor.createFromURL((URL) property)
434
								.createImage(display);
430
//								.createImage(display);
435
						imageTable.put(property, im); // Cache for disposal
431
//						imageTable.put(property, im); // Cache for disposal
436
					} else {
432
//					} else {
437
						im = ProgressManager.getInstance().getIconFor(job);
433
//						im = ProgressManager.getInstance().getIconFor(job);
438
						// No need to cache since the progress manager will
434
//						// No need to cache since the progress manager will
439
					}
435
//					}
440
					return im;
436
//					return im;
441
				}
437
//				}
442
				return null;
438
//				return null;
443
			}
439
//			}
444
440
445
			/*
441
			/*
446
			 * (non-Javadoc)
442
			 * (non-Javadoc)
Lines 449-455 Link Here
449
			 *      int)
445
			 *      int)
450
			 */
446
			 */
451
			public String getColumnText(Object element, int columnIndex) {
447
			public String getColumnText(Object element, int columnIndex) {
452
				return ((StatusInfo) element).getDisplayString();
448
				return ((StatusAdapterInfo) element).getDisplayString();
453
			}
449
			}
454
450
455
			/*
451
			/*
Lines 480-492 Link Here
480
	 * 
476
	 * 
481
	 * @return ErrorInfo or <code>null</code>.
477
	 * @return ErrorInfo or <code>null</code>.
482
	 */
478
	 */
483
	private StatusInfo getSingleSelection() {
479
	private StatusAdapterInfo getSingleSelection() {
484
		ISelection rawSelection = statusListViewer.getSelection();
480
		ISelection rawSelection = statusListViewer.getSelection();
485
		if (rawSelection != null
481
		if (rawSelection != null
486
				&& rawSelection instanceof IStructuredSelection) {
482
				&& rawSelection instanceof IStructuredSelection) {
487
			IStructuredSelection selection = (IStructuredSelection) rawSelection;
483
			IStructuredSelection selection = (IStructuredSelection) rawSelection;
488
			if (selection.size() == 1) {
484
			if (selection.size() == 1) {
489
				return (StatusInfo) selection.getFirstElement();
485
				return (StatusAdapterInfo) selection.getFirstElement();
490
			}
486
			}
491
		}
487
		}
492
		return null;
488
		return null;
Lines 519-528 Link Here
519
	 * enablements and repopulate the list.
515
	 * enablements and repopulate the list.
520
	 */
516
	 */
521
	void handleSelectionChange() {
517
	void handleSelectionChange() {
522
		StatusInfo newSelection = getSingleSelection();
518
		StatusAdapterInfo newSelection = getSingleSelection();
523
		if (newSelection != null && newSelection != selectedStatus) {
519
		if (newSelection != null && newSelection != selectedStatus) {
524
			selectedStatus = newSelection;
520
			selectedStatus = newSelection;
525
			setStatus(selectedStatus.getStatus());
521
			setStatus(selectedStatus.getStatusAdapter().getStatus());
526
			updateEnablements();
522
			updateEnablements();
527
			showDetailsArea();
523
			showDetailsArea();
528
		}
524
		}
(-)Eclipse UI/org/eclipse/ui/statushandlers/StatusNotificationManager.java (-140 / +37 lines)
Lines 23-29 Link Here
23
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.jobs.Job;
27
import org.eclipse.jface.resource.ImageDescriptor;
26
import org.eclipse.jface.resource.ImageDescriptor;
28
import org.eclipse.jface.resource.JFaceResources;
27
import org.eclipse.jface.resource.JFaceResources;
29
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.osgi.util.NLS;
Lines 33-39 Link Here
33
import org.eclipse.ui.internal.WorkbenchPlugin;
32
import org.eclipse.ui.internal.WorkbenchPlugin;
34
import org.eclipse.ui.internal.progress.ProgressManagerUtil;
33
import org.eclipse.ui.internal.progress.ProgressManagerUtil;
35
import org.eclipse.ui.internal.progress.ProgressMessages;
34
import org.eclipse.ui.internal.progress.ProgressMessages;
36
import org.eclipse.ui.progress.IProgressConstants;
37
import org.eclipse.ui.progress.WorkbenchJob;
35
import org.eclipse.ui.progress.WorkbenchJob;
38
36
39
import com.ibm.icu.text.DateFormat;
37
import com.ibm.icu.text.DateFormat;
Lines 89-118 Link Here
89
	/**
87
	/**
90
	 * Add a new error to the list for the supplied job.
88
	 * Add a new error to the list for the supplied job.
91
	 * 
89
	 * 
92
	 * @param status
90
	 * @param statusAdapter
93
	 */
91
	 */
94
	void addError(IStatus status, Object extension) {
92
	public void addStatusAdapter(StatusAdapter statusAdapter) {
95
93
		StatusAdapterInfo statusAdapterInfo = new StatusAdapterInfo(
96
		// Handle out of memory errors via the workbench
94
				statusAdapter);
97
		final Throwable exception = status.getException();
95
		showError(statusAdapterInfo);
98
		if (exception != null && exception instanceof OutOfMemoryError) {
99
			PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
100
				//TODO change !!! possible invocation loops
101
				/*
102
				 * (non-Javadoc)
103
				 * 
104
				 * @see java.lang.Runnable#run()
105
				 */
106
				public void run() {
107
					// is it really needed
108
					//ExceptionHandler.getInstance().handleException(exception);
109
				}
110
			});
111
112
			return;
113
		}
114
		StatusInfo errorInfo = new StatusInfo(status, extension);
115
		showError(errorInfo);
116
	}
96
	}
117
97
118
	/**
98
	/**
Lines 122-132 Link Here
122
	 * @param statusInfo
102
	 * @param statusInfo
123
	 *            the error to be displayed
103
	 *            the error to be displayed
124
	 */
104
	 */
125
	private void showError(final StatusInfo statusInfo) {
105
	private void showError(final StatusAdapterInfo statusAdapterInfo) {
126
106
127
		if (!PlatformUI.isWorkbenchRunning()) {
107
		if (!PlatformUI.isWorkbenchRunning()) {
128
			// we are shuttting down, so just log
108
			// we are shuttting down, so just log
129
			WorkbenchPlugin.log(statusInfo.getStatus());
109
			WorkbenchPlugin.log(statusAdapterInfo.getStatusAdapter()
110
					.getStatus());
130
			return;
111
			return;
131
		}
112
		}
132
113
Lines 138-155 Link Here
138
119
139
				// Add the error in the UI thread to ensure thread safety in the
120
				// Add the error in the UI thread to ensure thread safety in the
140
				// dialog
121
				// dialog
141
				errors.add(statusInfo);
122
				errors.add(statusAdapterInfo);
142
				if (dialog != null) {
123
				if (dialog != null) {
143
					dialog.refresh();
124
					dialog.refresh();
144
				} else if (Platform.isRunning()) {
125
				} else if (Platform.isRunning()) {
145
					// Delay prompting if the job property is set
126
					// Delay prompting if the job property is set
146
					Object noPromptProperty = null;
127
					Object noPromptProperty = null;
147
					Object extension = statusInfo.getExtension();
128
//					Object extension = statusAdapterInfo.getExtension();
148
129
149
					if (extension != null && extension instanceof Job) {
130
//					if (extension != null && extension instanceof Job) {
150
						noPromptProperty = ((Job) extension)
131
//						noPromptProperty = ((Job) extension)
151
								.getProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY);
132
//								.getProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY);
152
					}
133
//					}
153
134
154
					boolean prompt = true;
135
					boolean prompt = true;
155
					if (noPromptProperty instanceof Boolean) {
136
					if (noPromptProperty instanceof Boolean) {
Lines 158-164 Link Here
158
139
159
					if (prompt) {
140
					if (prompt) {
160
						return openErrorDialog(null /* use default title */,
141
						return openErrorDialog(null /* use default title */,
161
								null /* use default message */, statusInfo);
142
								null /* use default message */, statusAdapterInfo);
162
					}
143
					}
163
				}
144
				}
164
				return Status.OK_STATUS;
145
				return Status.OK_STATUS;
Lines 190-196 Link Here
190
	 * @return IStatus
171
	 * @return IStatus
191
	 */
172
	 */
192
	private IStatus openErrorDialog(String title, String msg,
173
	private IStatus openErrorDialog(String title, String msg,
193
			final StatusInfo statusInfo) {
174
			final StatusAdapterInfo statusAdapterInfo) {
194
		IWorkbench workbench = PlatformUI.getWorkbench();
175
		IWorkbench workbench = PlatformUI.getWorkbench();
195
176
196
		// Abort on shutdown
177
		// Abort on shutdown
Lines 199-205 Link Here
199
			return Status.CANCEL_STATUS;
180
			return Status.CANCEL_STATUS;
200
		}
181
		}
201
		dialog = new StatusDialog(ProgressManagerUtil.getDefaultParent(),
182
		dialog = new StatusDialog(ProgressManagerUtil.getDefaultParent(),
202
				title, msg, statusInfo, IStatus.OK | IStatus.INFO
183
				title, msg, statusAdapterInfo, IStatus.OK | IStatus.INFO
203
						| IStatus.WARNING | IStatus.ERROR);
184
						| IStatus.WARNING | IStatus.ERROR);
204
185
205
		dialog.open();
186
		dialog.open();
Lines 229-236 Link Here
229
		Iterator errorIterator = errorsToRemove.iterator();
210
		Iterator errorIterator = errorsToRemove.iterator();
230
		Set errorStatuses = new HashSet();
211
		Set errorStatuses = new HashSet();
231
		while (errorIterator.hasNext()) {
212
		while (errorIterator.hasNext()) {
232
			StatusInfo next = (StatusInfo) errorIterator.next();
213
			StatusAdapterInfo next = (StatusAdapterInfo) errorIterator.next();
233
			errorStatuses.add(next.getStatus());
214
			errorStatuses.add(next.getStatusAdapter().getStatus());
234
		}
215
		}
235
216
236
		// TODO those classes have default access modifier :/
217
		// TODO those classes have default access modifier :/
Lines 258-324 Link Here
258
	}
239
	}
259
240
260
	/**
241
	/**
261
	 * Display the error for the given job and any other errors that have been
262
	 * accumulated. This method must be invoked from the UI thread.
263
	 * 
264
	 * @param job
265
	 *            the job whose error should be displayed
266
	 * @param title
267
	 *            The title for the dialog
268
	 * @param msg
269
	 *            The message for the dialog.
270
	 * @return <code>true</code> if the info for the job was found and the
271
	 *         error displayed and <code>false</code> otherwise.
272
	 */
273
	public boolean showErrorFor(Job job, String title, String msg) {
274
		if (dialog != null) {
275
			// The dialog is already open so the error is being displayed
276
			return true;
277
		}
278
		StatusInfo info = null;
279
		if (job == null) {
280
			info = getMostRecentJobError();
281
		} else {
282
			info = getErrorInfo(job);
283
		}
284
		if (info != null) {
285
			openErrorDialog(title, msg, info);
286
			return true;
287
		}
288
		return false;
289
	}
290
291
	/*
292
	 * Return the most recent error.
293
	 */
294
	private StatusInfo getMostRecentJobError() {
295
		StatusInfo mostRecentInfo = null;
296
		for (Iterator iter = errors.iterator(); iter.hasNext();) {
297
			StatusInfo info = (StatusInfo) iter.next();
298
			if ((mostRecentInfo == null || info.getTimestamp() > mostRecentInfo
299
					.getTimestamp())
300
					&& info.getExtension() != null
301
					&& info.getExtension() instanceof Job) {
302
				mostRecentInfo = info;
303
			}
304
		}
305
		return mostRecentInfo;
306
	}
307
308
	/*
309
	 * Return the error info for the given job
310
	 */
311
	private StatusInfo getErrorInfo(Job job) {
312
		for (Iterator iter = errors.iterator(); iter.hasNext();) {
313
			StatusInfo info = (StatusInfo) iter.next();
314
			if (info.getExtension() == job) {
315
				return info;
316
			}
317
		}
318
		return null;
319
	}
320
321
	/**
322
	 * Return whether the manager has errors to report.
242
	 * Return whether the manager has errors to report.
323
	 * 
243
	 * 
324
	 * @return whether the manager has errors to report
244
	 * @return whether the manager has errors to report
Lines 340-384 Link Here
340
	 * A wrapper class for statuses displayed in the dialog.
260
	 * A wrapper class for statuses displayed in the dialog.
341
	 * 
261
	 * 
342
	 */
262
	 */
343
	protected static class StatusInfo implements Comparable {
263
	protected static class StatusAdapterInfo implements Comparable {
344
264
345
		private final IStatus status;
265
		private final StatusAdapter statusAdapter;
346
266
347
		private final long timestamp;
267
		private final long timestamp;
348
268
349
		private final Object extension;
350
351
		/**
352
		 * Constructs a simple <code>StatusInfo</code>, without any
353
		 * extensions.
354
		 * 
355
		 * @param status
356
		 *            the root status for this status info
357
		 */
358
		public StatusInfo(IStatus status) {
359
			this(status, null);
360
		}
361
362
		/**
269
		/**
363
		 * Constructs a <code>StatusInfo</code> with a extension (used to
270
		 * Constructs a <code>StatusInfo</code> with a extension (used to
364
		 * retrieve extra properties).
271
		 * retrieve extra properties).
365
		 * 
272
		 * 
366
		 * @param status
273
		 * @param statusAdapter
367
		 *            the root status for this status info
274
		 *            the root status adapter for this info
368
		 * @param extension
369
		 *            the extension
370
		 */
275
		 */
371
		public StatusInfo(IStatus status, Object extension) {
276
		public StatusAdapterInfo(StatusAdapter statusAdapter) {
372
			this.status = status;
277
			this.statusAdapter = statusAdapter;
373
			timestamp = System.currentTimeMillis();
278
			timestamp = System.currentTimeMillis();
374
			this.extension = extension;
375
		}
279
		}
376
280
377
		String getDisplayString() {
281
		String getDisplayString() {
378
			String text = status.getMessage();
282
			String text = statusAdapter.getStatus().getMessage();
379
			if (this.extension != null && this.extension instanceof Job) {
283
			
380
				text = ((Job) extension).getName();
284
//			if (this.extension != null && this.extension instanceof Job) {
381
			}
285
//				text = ((Job) extension).getName();
286
//			}
382
287
383
			return NLS.bind(ProgressMessages.JobInfo_Error, (new Object[] {
288
			return NLS.bind(ProgressMessages.JobInfo_Error, (new Object[] {
384
					text,
289
					text,
Lines 401-434 Link Here
401
		 * @see java.lang.Comparable#compareTo(T)
306
		 * @see java.lang.Comparable#compareTo(T)
402
		 */
307
		 */
403
		public int compareTo(Object arg0) {
308
		public int compareTo(Object arg0) {
404
			if (arg0 instanceof StatusInfo) {
309
			if (arg0 instanceof StatusAdapterInfo) {
405
				// Order ErrorInfo by time received
310
				// Order StatusAdapterInfo by time received
406
				long otherTimestamp = ((StatusInfo) arg0).timestamp;
311
				long otherTimestamp = ((StatusAdapterInfo) arg0).timestamp;
407
				if (timestamp < otherTimestamp) {
312
				if (timestamp < otherTimestamp) {
408
					return -1;
313
					return -1;
409
				} else if (timestamp > otherTimestamp) {
314
				} else if (timestamp > otherTimestamp) {
410
					return 1;
315
					return 1;
411
				} else {
316
				} else {
412
					return getDisplayString().compareTo(
317
					return getDisplayString().compareTo(
413
							((StatusInfo) arg0).getDisplayString());
318
							((StatusAdapterInfo) arg0).getDisplayString());
414
				}
319
				}
415
			}
320
			}
416
			return 0;
321
			return 0;
417
		}
322
		}
418
323
419
		/**
324
		/**
420
		 * @return Returns the status.
325
		 * @return Returns the status adapter.
421
		 */
326
		 */
422
		public IStatus getStatus() {
327
		public StatusAdapter getStatusAdapter() {
423
			return status;
328
			return statusAdapter;
424
		}
329
		}
425
426
		/**
427
		 * @return Returns the extension.
428
		 */
429
		public Object getExtension() {
430
			return extension;
431
		}
432
433
	}
330
	}
434
}
331
}
(-)Eclipse UI/org/eclipse/ui/statushandlers/StatusAdapter.java (-2 / +25 lines)
Lines 38-43 Link Here
38
38
39
	private IStatus status;
39
	private IStatus status;
40
40
41
	private String title;
42
41
	private HashMap adapters;
43
	private HashMap adapters;
42
44
43
	private int handlingHint;
45
	private int handlingHint;
Lines 46-56 Link Here
46
	 * Creates an instance of this class.
48
	 * Creates an instance of this class.
47
	 * 
49
	 * 
48
	 * @param status
50
	 * @param status
49
	 *            the status set in the adapter
51
	 *            the status set in the adapter, not null
50
	 */
52
	 */
51
	public StatusAdapter(IStatus status) {
53
	public StatusAdapter(IStatus status) {
52
		this.status = status;
54
		this.status = status;
53
		adapters = new HashMap();
54
	}
55
	}
55
56
56
	/**
57
	/**
Lines 62-67 Link Here
62
	 *            the adapter instance
63
	 *            the adapter instance
63
	 */
64
	 */
64
	public void addAdapter(Class adapter, Object object) {
65
	public void addAdapter(Class adapter, Object object) {
66
		if (adapters == null) {
67
			adapters = new HashMap();
68
		}
65
		adapters.put(adapter, object);
69
		adapters.put(adapter, object);
66
	}
70
	}
67
71
Lines 71-76 Link Here
71
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
75
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
72
	 */
76
	 */
73
	public Object getAdapter(Class adapter) {
77
	public Object getAdapter(Class adapter) {
78
		if (adapters == null) {
79
			return null;
80
		}
74
		return adapters.get(adapter);
81
		return adapters.get(adapter);
75
	}
82
	}
76
83
Lines 104-107 Link Here
104
	public void setHandlingHint(int handlingHint) {
111
	public void setHandlingHint(int handlingHint) {
105
		this.handlingHint = handlingHint;
112
		this.handlingHint = handlingHint;
106
	}
113
	}
114
115
	/**
116
	 * @return Returns the title. It is the information which can be used in
117
	 *         dialogs' title bars.
118
	 */
119
	public String getTitle() {
120
		return title;
121
	}
122
123
	/**
124
	 * @param title
125
	 *            The title to set.
126
	 */
127
	public void setTitle(String title) {
128
		this.title = title;
129
	}
107
}
130
}
(-)Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchErrorHandler.java (-2 / +2 lines)
Lines 34-41 Link Here
34
	 */
34
	 */
35
	public boolean handle(final StatusAdapter statusAdapter) {
35
	public boolean handle(final StatusAdapter statusAdapter) {
36
		if ((statusAdapter.getHandlingHint() & StatusManager.SHOW) == StatusManager.SHOW) {
36
		if ((statusAdapter.getHandlingHint() & StatusManager.SHOW) == StatusManager.SHOW) {
37
			StatusNotificationManager.getInstance().addError(
37
			StatusNotificationManager.getInstance().addStatusAdapter(
38
					statusAdapter.getStatus(), null);
38
					statusAdapter);
39
		}
39
		}
40
40
41
		if ((statusAdapter.getHandlingHint() & StatusManager.LOG) == StatusManager.LOG) {
41
		if ((statusAdapter.getHandlingHint() & StatusManager.LOG) == StatusManager.LOG) {
(-)Eclipse UI/org/eclipse/ui/internal/JFaceUtil.java (-3 / +13 lines)
Lines 29-34 Link Here
29
import org.eclipse.jface.util.SafeRunnable;
29
import org.eclipse.jface.util.SafeRunnable;
30
import org.eclipse.jface.window.Window;
30
import org.eclipse.jface.window.Window;
31
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.ui.statushandlers.StatusAdapter;
32
import org.eclipse.ui.statushandlers.StatusManager;
33
import org.eclipse.ui.statushandlers.StatusManager;
33
34
34
/**
35
/**
Lines 89-95 Link Here
89
					status = new Status(IStatus.ERROR,
90
					status = new Status(IStatus.ERROR,
90
							WorkbenchPlugin.PI_WORKBENCH, message);
91
							WorkbenchPlugin.PI_WORKBENCH, message);
91
				}
92
				}
92
				StatusManager.getManager().handle(status, StatusManager.SHOW);
93
94
				StatusAdapter statusAdapter = new StatusAdapter(status);
95
				statusAdapter.setTitle(title);
96
				statusAdapter.setHandlingHint(StatusManager.SHOW);
97
98
				StatusManager.getManager().handle(statusAdapter);
93
				return Window.OK;
99
				return Window.OK;
94
			}
100
			}
95
101
Lines 125-132 Link Here
125
				if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
131
				if (severity == IStatus.ERROR || severity == IStatus.WARNING) {
126
					IStatus status = new Status(severity,
132
					IStatus status = new Status(severity,
127
							WorkbenchPlugin.PI_WORKBENCH, message);
133
							WorkbenchPlugin.PI_WORKBENCH, message);
128
					StatusManager.getManager().handle(status,
134
					
129
							StatusManager.SHOW);
135
					StatusAdapter statusAdapter = new StatusAdapter(status);
136
					statusAdapter.setTitle(title);
137
					statusAdapter.setHandlingHint(StatusManager.SHOW);
138
					
139
					StatusManager.getManager().handle(statusAdapter);
130
					return Window.OK;
140
					return Window.OK;
131
				}
141
				}
132
142

Return to bug 173678