Class StatusManager
- java.lang.Object
-
- org.eclipse.ui.statushandlers.StatusManager
-
public class StatusManager extends Object
StatusManager is the entry point for all statuses to be reported in the user interface.
Handlers shoudn't be used directly but through the StatusManager singleton which keeps the status handling policy and chooses handlers.
StatusManager.getManager().handle(IStatus)andhandle(IStatus status, int style)are the methods are the primary access points to the StatusManager.Acceptable styles (can be combined with logical OR)
- NONE - a style indicating that the status should not be acted on. This is used by objects such as log listeners that do not want to report a status twice
- LOG - a style indicating that the status should be logged only
- SHOW - a style indicating that handlers should show a problem to an user
without blocking the calling method while awaiting user response. This is
generally done using a non modal
Dialog - BLOCK - a style indicating that the handling should block the UI until
the user has responded. This is generally done using a modal window such as a
Dialog
Handlers are intended to be accessed via the status manager. The StatusManager chooses which handler should be used for a particular error. There are two ways for adding handlers to the handling flow. First using extension point
org.eclipse.ui.statusHandlers, second by the workbench advisor and its methodWorkbenchAdvisor.getWorkbenchErrorHandler(). If a handler is associated with a product, it is used instead of this defined in advisor.- Since:
- 3.3
- See Also:
AbstractStatusHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStatusManager.INotificationListenerThis interface allows for listening to status handling framework changes.static interfaceStatusManager.INotificationTypesThis interface declares types of notification.
-
Field Summary
Fields Modifier and Type Field Description static intBLOCKA style indicating that the handling should block the calling thread until the status has been handled.static intLOGA style indicating that the status should be logged only.static intNONEA style indicating that the status should not be acted on.static intSHOWA style indicating that handlers should show a problem to an user without blocking the calling method while awaiting user response.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(StatusManager.INotificationListener listener)Adds a listener to the StatusManager.voidaddLoggedStatus(IStatus status)This method informs the StatusManager that this IStatus is being handled by the handler and to ignore it when it shows up in our ILogListener.voidfireNotification(int type, StatusAdapter[] adapters)This method should be called by custom status handlers when an event occurs.static StatusManagergetManager()Returns StatusManager singleton instance.voidhandle(CoreException coreException, String pluginId)Handles given CoreException.voidhandle(IStatus status)Handles the given status.voidhandle(IStatus status, int style)Handles the given status due to the style.voidhandle(StatusAdapter statusAdapter)Handles the given status adapter.voidhandle(StatusAdapter statusAdapter, int style)Handles the given status adapter due to the style.voidremoveListener(StatusManager.INotificationListener listener)Removes a listener from StatusManager.voidunregister()Unregisters the StatusManager from the workbench.
-
-
-
Field Detail
-
NONE
public static final int NONE
A style indicating that the status should not be acted on. This is used by objects such as log listeners that do not want to report a status twice.- See Also:
- Constant Field Values
-
LOG
public static final int LOG
A style indicating that the status should be logged only.- See Also:
- Constant Field Values
-
SHOW
public static final int SHOW
A style indicating that handlers should show a problem to an user without blocking the calling method while awaiting user response. This is generally done using a non modalDialog.- See Also:
- Constant Field Values
-
BLOCK
public static final int BLOCK
A style indicating that the handling should block the calling thread until the status has been handled.A typical usage of this would be to ensure that the user's actions are blocked until they've dealt with the status in some manner. It is therefore likely but not required that the
StatusHandlerwould achieve this through the use of a modal dialog.Due to the fact that use of
BLOCKwill block UI, care should be taken in this use of this flag.- See Also:
- Constant Field Values
-
-
Method Detail
-
getManager
public static StatusManager getManager()
Returns StatusManager singleton instance.- Returns:
- the manager instance
-
handle
public void handle(StatusAdapter statusAdapter, int style)
-
handle
public void handle(StatusAdapter statusAdapter)
Handles the given status adapter. TheLOGstyle is used when this method is called.- Parameters:
statusAdapter- the status adapter
-
handle
public void handle(IStatus status, int style)
-
handle
public void handle(IStatus status)
Handles the given status. TheLOGstyle is used when this method is called.- Parameters:
status- the status to handle
-
handle
public void handle(CoreException coreException, String pluginId)
Handles given CoreException. This method has been introduced to prevent anti-pattern:
that does not print the stack trace to the log.StatusManager.getManager().handle(coreException.getStatus());- Parameters:
coreException- a CoreException to be handled.pluginId- the unique identifier of the relevant plug-in- Since:
- 3.4
- See Also:
handle(IStatus)
-
addLoggedStatus
public void addLoggedStatus(IStatus status)
This method informs the StatusManager that this IStatus is being handled by the handler and to ignore it when it shows up in our ILogListener.- Parameters:
status- already handled and logged status
-
fireNotification
public void fireNotification(int type, StatusAdapter[] adapters)This method should be called by custom status handlers when an event occurs. This method has no effect if statushandler does not support particular event type.- Parameters:
type- - type of the event.adapters- - array of affectedStatusAdapters.- Since:
- 3.5
- See Also:
StatusManager.INotificationTypes,AbstractStatusHandler.supportsNotification(int)
-
addListener
public void addListener(StatusManager.INotificationListener listener)
Adds a listener to the StatusManager.- Parameters:
listener- - a listener to be added.- Since:
- 3.5
-
removeListener
public void removeListener(StatusManager.INotificationListener listener)
Removes a listener from StatusManager.- Parameters:
listener- - a listener to be removed.- Since:
- 3.5
-
unregister
public void unregister()
Unregisters the StatusManager from the workbench. Called by the framework during shutdown, should not be called by client code.- Since:
- 3.117
-
-