KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
15
16 import org.eclipse.ui.application.WorkbenchAdvisor;
17
18 /**
19  * <p>
20  * Status handlers are part of the status handling facility. The facility is
21  * responsible for handling errors and other important issues in Eclipse based
22  * applications. The handlers are responsible for presenting this errors by
23  * logging or showing error dialogs.
24  * </p>
25  *
26  * <p>
27  * All status handlers extends
28  * <code>org.eclipse.ui.statushandlers.AbstractStatusHandler</code>. Each
29  * handler implements <code>handle(StatusAdapter status, int style)</code>.
30  * This method handles statuses due to handling style. The style indicates how
31  * status handler should handle a status.
32  * </p>
33  *
34  * <p>
35  * For acceptable styles check {@link StatusManager}.
36  * </p>
37  *
38  * <p>
39  * Handlers shoudn't be used directly but through the {@link StatusManager}. It
40  * chooses which handler should be used for handling. There are two ways for
41  * adding handlers to the handling flow. First using extension point
42  * <code>org.eclipse.ui.statusHandlers</code>, second by the workbench
43  * advisor and its method {@link WorkbenchAdvisor#getWorkbenchErrorHandler()}.
44  * If a handler is associated with a product, it is used instead of this defined
45  * in advisor.
46  * </p>
47  *
48  * <p>
49  * A status handler has the id and a set of parameters. The handler can use them
50  * during handling. If the handler is added as an extension, both are set during
51  * initialization of the handler using elements and attributes of
52  * <code>statusHandler</code> element.
53  * </p>
54  *
55  * @since 3.3
56  */

57 public abstract class AbstractStatusHandler {
58
59     private Map JavaDoc params;
60
61     private String JavaDoc id;
62
63     /**
64      * Handles {@link StatusAdapter} objects based on the set style.
65      *
66      * @param statusAdapter
67      * the status adapter. May not be <code>null</code>.
68      * @param style
69      * style constant. Acceptable values are defined in
70      * {@link StatusManager} and can be combined with logical OR.
71      *
72      * @see StatusManager#BLOCK
73      * @see StatusManager#NONE
74      * @see StatusManager#SHOW
75      * @see StatusManager#LOG
76      */

77     public abstract void handle(StatusAdapter statusAdapter, int style);
78
79     /**
80      * Returns all parameters of the handler.
81      *
82      * @return the parameters
83      */

84     public Map JavaDoc getParams() {
85         return params;
86     }
87
88     /**
89      * Returns the value of the handler's parameter identified by the given key,
90      * or <code>null</code> if this handler has no such parameter.
91      *
92      * @param key
93      * the name of the property
94      * @return the value of the parameter, or <code>null</code> if this
95      * handler has no such parameter
96      */

97     public Object JavaDoc getParam(Object JavaDoc key) {
98         if (params != null) {
99             return params.get(key);
100         }
101
102         return null;
103     }
104
105     /**
106      * Sets the parameters for the handler. If the handler is added via the
107      * <code> org.eclipse.ui.statushandlers extension</code>, the parameters are set
108      * during initialization of the handler using <code>parameter</code>
109      * elements from <code>statusHandler</code>
110      * element.
111      *
112      * @param params
113      * the parameters to set
114      */

115     public void setParams(Map JavaDoc params) {
116         this.params = params;
117     }
118
119     /**
120      * Returns the id of the handler.
121      *
122      * @return the id
123      */

124     public String JavaDoc getId() {
125         return id;
126     }
127
128     /**
129      * Sets the id for the handler. If the handler is added as an extension, the
130      * id is set during initialization of the handler using <code>id</code>
131      * attribute of <code>statusHandler</code> element.
132      *
133      * @param id
134      * the id to set
135      */

136     public void setId(String JavaDoc id) {
137         this.id = id;
138     }
139 }
140
Popular Tags