KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > statushandlers > WorkbenchErrorHandler


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.statushandlers;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.ui.application.WorkbenchAdvisor;
17 import org.eclipse.ui.internal.WorkbenchPlugin;
18 import org.eclipse.ui.internal.statushandlers.StatusNotificationManager;
19
20 /**
21  * This is a default workbench error handler.
22  *
23  * @see WorkbenchAdvisor#getWorkbenchErrorHandler()
24  *
25  * @since 3.3
26  */

27 public class WorkbenchErrorHandler extends AbstractStatusHandler {
28
29     /*
30      * (non-Javadoc)
31      *
32      * @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter,
33      * int)
34      */

35     public void handle(final StatusAdapter statusAdapter, int style) {
36         if (((style & StatusManager.SHOW) == StatusManager.SHOW)
37                 || ((style & StatusManager.BLOCK) == StatusManager.BLOCK)) {
38
39             // INFO status is set in the adapter when the passed adapter has OK
40
// or CANCEL status
41
if (statusAdapter.getStatus().getSeverity() == IStatus.OK
42                     || statusAdapter.getStatus().getSeverity() == IStatus.CANCEL) {
43                 IStatus status = statusAdapter.getStatus();
44                 statusAdapter.setStatus(new Status(IStatus.INFO, status
45                         .getPlugin(), status.getMessage(), status
46                         .getException()));
47             }
48
49             boolean modal = ((style & StatusManager.BLOCK) == StatusManager.BLOCK);
50             StatusNotificationManager.getInstance().addError(statusAdapter,
51                     modal);
52         }
53
54         if ((style & StatusManager.LOG) == StatusManager.LOG) {
55             StatusManager.getManager().addLoggedStatus(
56                     statusAdapter.getStatus());
57             WorkbenchPlugin.getDefault().getLog()
58                     .log(statusAdapter.getStatus());
59         }
60     }
61 }
62
Popular Tags