01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.statushandlers;
11:
12: import org.eclipse.core.runtime.IStatus;
13: import org.eclipse.core.runtime.Status;
14: import org.eclipse.ui.application.WorkbenchAdvisor;
15: import org.eclipse.ui.internal.WorkbenchPlugin;
16: import org.eclipse.ui.internal.statushandlers.StatusNotificationManager;
17:
18: /**
19: * This is a default workbench error handler.
20: *
21: * @see WorkbenchAdvisor#getWorkbenchErrorHandler()
22: *
23: * @since 3.3
24: */
25: public class WorkbenchErrorHandler extends AbstractStatusHandler {
26:
27: /*
28: * (non-Javadoc)
29: *
30: * @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter,
31: * int)
32: */
33: public void handle(final StatusAdapter statusAdapter, int style) {
34: if (((style & StatusManager.SHOW) == StatusManager.SHOW)
35: || ((style & StatusManager.BLOCK) == StatusManager.BLOCK)) {
36:
37: // INFO status is set in the adapter when the passed adapter has OK
38: // or CANCEL status
39: if (statusAdapter.getStatus().getSeverity() == IStatus.OK
40: || statusAdapter.getStatus().getSeverity() == IStatus.CANCEL) {
41: IStatus status = statusAdapter.getStatus();
42: statusAdapter.setStatus(new Status(IStatus.INFO, status
43: .getPlugin(), status.getMessage(), status
44: .getException()));
45: }
46:
47: boolean modal = ((style & StatusManager.BLOCK) == StatusManager.BLOCK);
48: StatusNotificationManager.getInstance().addError(
49: statusAdapter, modal);
50: }
51:
52: if ((style & StatusManager.LOG) == StatusManager.LOG) {
53: StatusManager.getManager().addLoggedStatus(
54: statusAdapter.getStatus());
55: WorkbenchPlugin.getDefault().getLog().log(
56: statusAdapter.getStatus());
57: }
58: }
59: }
|