public class OnlineStatus extends Object
isOnline()
to determine whether we are online (and perform
client-side error handling)isOnlineWithNotification(String)
if we should display a
notification message if offlinenetAccessFailed(String, Throwable)
after a network operation to
some TextGrid utility failed (e.g. on an OfflineException
or after a
request to Crud, Search, Auth, Logging etc.)Modifier and Type | Class and Description |
---|---|
static interface |
OnlineStatus.IStatusChangeListener
An
OnlineStatus.IStatusChangeListener 's statusChanged method is called whenever
the online status changed. |
Constructor and Description |
---|
OnlineStatus() |
Modifier and Type | Method and Description |
---|---|
static void |
addOnlineStatusChangeListener(OnlineStatus.IStatusChangeListener listener)
Adds the given listener as a status change listener.
|
static boolean |
isOfflineException(Exception e)
Check if the given exception is known to
occur on network-connection failures
|
static boolean |
isOnline() |
static boolean |
isOnlineWithNotification(String message)
Determines whether we are online.
|
static void |
netAccessFailed(String message,
Throwable cause)
Sets the current status to offline and notifies clients that network
access failed and how they can re-enable their onlineness.
|
protected static void |
notifyOnlineStatusChangeListeners(boolean newStatus)
Notifies the listeners of the new status.
|
static void |
removeOnlineStatusChangeListener(OnlineStatus.IStatusChangeListener listener)
Removes the given class from the list of status change listeners.
|
static void |
setOffline()
Make us offline.
|
static void |
setOnline()
Make us online.
|
static void |
setOnline(boolean newOnlineState)
Make us newOnlineState.
|
static void |
setStatusLineManager(IStatusLineManager statusLineManager) |
protected static void |
showOfflineErrorDialog(String message,
Throwable cause) |
protected static void |
showUnobstrusiveOnlineErrorMessage(String message,
Throwable cause)
Shows an unobstrusive error message due to unwanted offlineness.
|
public static void addOnlineStatusChangeListener(OnlineStatus.IStatusChangeListener listener)
public static void removeOnlineStatusChangeListener(OnlineStatus.IStatusChangeListener listener)
protected static void notifyOnlineStatusChangeListeners(boolean newStatus)
public static boolean isOnline()
public static boolean isOnlineWithNotification(String message)
message
- the message to displaypublic static void setOnline()
public static void setOnline(boolean newOnlineState)
public static void setOffline()
public static boolean isOfflineException(Exception e)
e
- exception to checkpublic static void netAccessFailed(String message, Throwable cause)
message
- a human-readable and localizeable message describing which
operation failed.cause
- the exception that caused the problemprotected static void showUnobstrusiveOnlineErrorMessage(String message, Throwable cause)
message
- The message to display.cause
- An (optional) exception to log. (may be null)protected static void showOfflineErrorDialog(String message, Throwable cause)
public static void setStatusLineManager(IStatusLineManager statusLineManager)