org.iids.aos.gui
Class Util

java.lang.Object
  extended by org.iids.aos.gui.Util

public class Util
extends java.lang.Object

Author:
rjtimmer

Constructor Summary
Util()
           
 
Method Summary
static void addLogOutputStream(java.io.OutputStream o)
          Add an output stream to the logger.
static boolean awtThreadInvokeLater(java.lang.Runnable r)
          Invoke runnable in the event dispatcher thread.
static boolean awtThreadInvokeNow(java.lang.Runnable r)
          Invoke & wait in the event dispatcher thread.
static void disposeWindow(java.awt.Window window)
          Cleanly dispose of a window.
static Diagnoser getDiagnoser()
           
static java.lang.String getLoggingPattern(org.apache.log4j.Level level)
           
static org.apache.log4j.Logger getMainLogger()
          Retrieve the main logger for the gui classes.
static void nonAwtThreadInvokeLater(java.lang.Runnable r)
          Invokes a Runnable in a different thread than the event dispatcher thread.
static void nonAwtThreadInvokeNow(java.lang.Runnable r)
          Deprecated. No sense in using this method, as it blocks the event dispatcher anyway (even though it uses a non-awt thread, it still waits for it..)
static void popDiagnoser()
          Removes the diagnoser op top of the stack.
static void popDiagnoser(Diagnoser d)
          Conditional pop: only remove top diagnoser if it is the exact same object reference as d.
static void popupErrorDialog(java.lang.String msg)
          Pops up a basic error message dialog.
static boolean popupQuestion(java.lang.String msg)
          Pops up an confirmation dialog (YES/NO options).
static void pushDiagnoser(Diagnoser d)
           
static void setDisposeOnEsc(java.awt.Window window)
          Disposes a window if ESC key is pressed when focus is on the window.
static void setHideOnEsc(java.awt.Window window)
          Hides a window if ESC key is pressed when focus is on the window.
static void setKeyAction(java.awt.Window window, int keyCode, java.lang.Runnable action)
          Set window action to perform on ESC key event.
static void setLoggingLevel(org.apache.log4j.Level level)
          Change the logging level at runtime.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

awtThreadInvokeNow

public static boolean awtThreadInvokeNow(java.lang.Runnable r)
Invoke & wait in the event dispatcher thread. Returns only after the runnable was completed.

Parameters:
r - The Runnable to execute.

awtThreadInvokeLater

public static boolean awtThreadInvokeLater(java.lang.Runnable r)
Invoke runnable in the event dispatcher thread. Returns immediately. The Runnable is invoked sometime in the future.

Parameters:
r - The Runnable to execute.

nonAwtThreadInvokeNow

@Deprecated
public static void nonAwtThreadInvokeNow(java.lang.Runnable r)
Deprecated. No sense in using this method, as it blocks the event dispatcher anyway (even though it uses a non-awt thread, it still waits for it..)

Invoke a runnable in a non-AWT thread. Blocking, so this method will return only after the Runnable.run() method finished.

If the current thread is the event dispatcher thread then a new thread is created for the Runnable. Otherwise the current thread runs it.


nonAwtThreadInvokeLater

public static void nonAwtThreadInvokeLater(java.lang.Runnable r)
Invokes a Runnable in a different thread than the event dispatcher thread. Returns immediately, the runnable is executed sometime in the future.


popupErrorDialog

public static void popupErrorDialog(java.lang.String msg)
Pops up a basic error message dialog.

Parameters:
msg - The message to be displayed.

popupQuestion

public static boolean popupQuestion(java.lang.String msg)
Pops up an confirmation dialog (YES/NO options).

Parameters:
msg - The message to be displayed in the dialog.
Returns:
true if the answer clicked in the dialog was "yes" false otherwise.

pushDiagnoser

public static void pushDiagnoser(Diagnoser d)

getDiagnoser

public static Diagnoser getDiagnoser()

popDiagnoser

public static void popDiagnoser()
Removes the diagnoser op top of the stack.


popDiagnoser

public static void popDiagnoser(Diagnoser d)
Conditional pop: only remove top diagnoser if it is the exact same object reference as d. This is checked with == for equality.


setLoggingLevel

public static void setLoggingLevel(org.apache.log4j.Level level)
Change the logging level at runtime.


getLoggingPattern

public static java.lang.String getLoggingPattern(org.apache.log4j.Level level)

getMainLogger

public static org.apache.log4j.Logger getMainLogger()
Retrieve the main logger for the gui classes. This is not the same as the root logger, but it is the logger for the aos.gui package, so for the GUI classes this is effectively the root Logger.


addLogOutputStream

public static void addLogOutputStream(java.io.OutputStream o)
Add an output stream to the logger. Logging now also goes to this output stream, in addition to the existing ones. All will use the same logging pattern (depending on the logging level).


setDisposeOnEsc

public static void setDisposeOnEsc(java.awt.Window window)
Disposes a window if ESC key is pressed when focus is on the window. Uses setKeyAction(java.awt.Window, int, java.lang.Runnable) internally.

Before the window is disposed, it fires a WindowClosing event to all the listeners to notify of the closing window.

Parameters:
window - The window to dispose on ESC.

disposeWindow

public static void disposeWindow(java.awt.Window window)
Cleanly dispose of a window. Passes WINDOW_CLOSING event to all registered WindowListeners before disposing the window, and calls WINDOW_CLOSED after the window has been disposed. This allows the window to be closed programmatically, while behaving similar to closing the window by hand.

Parameters:
window - The window to dispose.

setHideOnEsc

public static void setHideOnEsc(java.awt.Window window)
Hides a window if ESC key is pressed when focus is on the window. Uses setKeyAction(java.awt.Window, int, java.lang.Runnable) internally.

Before hiding the window, this fires a WindowClosing event (even though the window does not really close - it can be made visible again if desired).

Parameters:
window - The window to hide on ESC.

setKeyAction

public static void setKeyAction(java.awt.Window window,
                                int keyCode,
                                java.lang.Runnable action)
Set window action to perform on ESC key event. This will work if ESC is pressed anywhere in the window. Only work for objects that contain a root pane (ie. windows that implement the RootPaneContainer interface) like JFrame, JWindow and JDialog.

Parameters:
window - The Window to register the key event for
keyCode - The keyCode that triggers the event
action - Runnable implementing the action


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.