edu.rice.cs.util.swing
Class Utilities

java.lang.Object
  extended by edu.rice.cs.util.swing.Utilities

public class Utilities
extends Object


Field Summary
static String JGOODIES_PACKAGE
           
static boolean TEST_MODE
          True if the program is run in non-interactive test mode.
 
Constructor Summary
Utilities()
           
 
Method Summary
static void clearEventQueue()
          Clears the event queue by waiting until all events currently in the queue have been processed.
static void clearEventQueue(boolean newEvents)
          Clears the event queue by waiting until all events currently in the queue have been processed.
static AbstractAction createDelegateAction(String newName, Action delegate)
           
static PropertyChangeListener enableDisableWith(Action observable, Action observer)
          Enables/disables the second action whenever the first action is enabled/disabled.
static String getClipboardSelection(Component c)
           
static int getComponentIndex(Component component)
          Return the index of the component in the parent container, or -1 if no parent or not found.
static void invokeAndWait(Runnable task)
           
static void invokeLater(Runnable task)
          Runs the task synchronously if the current thread is the event thread; otherwise passes it to the event thread to be run asynchronously after all events already on the queue have been processed.
static boolean isPlasticLaf()
           
static boolean isPlasticLaf(String name)
           
static void setPopupLoc(Window popup, Component owner)
          Determines the location of the popup using a simple, uniform protocol.
static void show(String msg)
          Show a modal debug message box with an OK button regardless of TEST_MODE.
static void showDebug(String msg)
          Shows a modal debug message box with an OK button when not in TEST_MODE.
static void showMessageBox(String msg, String title)
          Shows a modal message box with an OK button.
static void showStackTrace(Throwable t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_MODE

public static volatile boolean TEST_MODE
True if the program is run in non-interactive test mode.


JGOODIES_PACKAGE

public static final String JGOODIES_PACKAGE
See Also:
Constant Field Values
Constructor Detail

Utilities

public Utilities()
Method Detail

invokeLater

public static void invokeLater(Runnable task)
Runs the task synchronously if the current thread is the event thread; otherwise passes it to the event thread to be run asynchronously after all events already on the queue have been processed.


invokeAndWait

public static void invokeAndWait(Runnable task)

clearEventQueue

public static void clearEventQueue()
Clears the event queue by waiting until all events currently in the queue have been processed. Calls clearEventQueue(true);


clearEventQueue

public static void clearEventQueue(boolean newEvents)
Clears the event queue by waiting until all events currently in the queue have been processed. If newEvents is set to true, the method will also wait for all events that have been put in the queue by the events that were just processed, and so on.

Parameters:
newEvents - true if the method should also clear new events that were added by the events just cleared

show

public static void show(String msg)
Show a modal debug message box with an OK button regardless of TEST_MODE.

Parameters:
msg - string to display

showDebug

public static void showDebug(String msg)
Shows a modal debug message box with an OK button when not in TEST_MODE.

Parameters:
msg - string to display

showMessageBox

public static void showMessageBox(String msg,
                                  String title)
Shows a modal message box with an OK button.

Parameters:
msg - string to display

showStackTrace

public static void showStackTrace(Throwable t)

getClipboardSelection

public static String getClipboardSelection(Component c)
Returns:
a string with the current clipboard selection, or null if not available.

createDelegateAction

public static AbstractAction createDelegateAction(String newName,
                                                  Action delegate)
Returns:
an action with a new name that delegates to another action.

isPlasticLaf

public static boolean isPlasticLaf()
Returns:
whether the current LookAndFeel is a Plastic (i.e. JGoodies) LookAndFeel

isPlasticLaf

public static boolean isPlasticLaf(String name)
Parameters:
name - the fully-qualified classname of the LookAndFeel
Returns:
whether a given LookAndFeel name is a Plastic (i.e. JGoodies) LookAndFeel

setPopupLoc

public static void setPopupLoc(Window popup,
                               Component owner)
Determines the location of the popup using a simple, uniform protocol. If the popup has an owner, the popup is centered over the owner. If the popup has no owner(owner == null), the popup is centered over the first monitor. In either case, the popup is moved and scaled if any part of it is not on the screen. This method should be called for all popups to maintain uniformity in the DrJava UI.

Parameters:
popup - the popup window
owner - the parent component for the popup

enableDisableWith

public static PropertyChangeListener enableDisableWith(Action observable,
                                                       Action observer)
Enables/disables the second action whenever the first action is enabled/disabled.

Parameters:
observable - the action that is observed (leads)
observer - the action that follows
Returns:
the PropertyChangeListener used to do the observation

getComponentIndex

public static int getComponentIndex(Component component)
Return the index of the component in the parent container, or -1 if no parent or not found.

Parameters:
component -
Returns:
index of the component in the parent container, or -1 if not found