com.threerings.util
Class ToolUtil

java.lang.Object
  extended by com.threerings.util.ToolUtil

public class ToolUtil
extends Object

Contains some static classes and methods used by our various (Swing-based) tool applications.


Nested Class Summary
static class ToolUtil.EditablePrefs
          A simple editable object used to manipulate preferences.
static class ToolUtil.WrappedTransfer
          A Transferable available in two flavors: one for use within a single VM and one that uses binary export/import to exchange data between different VMs.
 
Field Summary
static DataFlavor LOCAL_WRAPPED_FLAVOR
          A data flavor for referenced local wrapped objects (on this VM).
static DataFlavor SERIALIZED_WRAPPED_FLAVOR
          A data flavor for serialized wrapped objects (from another VM).
static DataFlavor[] WRAPPED_FLAVORS
          The flavors for local and serialized wrapped objects.
 
Constructor Summary
ToolUtil()
           
 
Method Summary
static void configureLog(String logfile)
          Unless directed otherwise by a system property, redirects console output to the named log file.
static Action createAction(ActionListener listener, com.threerings.util.MessageBundle msgs, String command, int mnemonic, int accelerator)
          Creates an action with the specified command, mnemonic, and (optional) accelerator.
static Action createAction(ActionListener listener, com.threerings.util.MessageBundle msgs, String command, int mnemonic, int accelerator, int modifiers)
          Creates an action with the specified command, mnemonic, and (optional) accelerator key/modifiers.
static JButton createButton(ActionListener listener, com.threerings.util.MessageBundle msgs, String action)
          Creates a button with the specified action.
static JButton createButton(ActionListener listener, com.threerings.util.MessageBundle msgs, String action, String key)
          Creates a button with the specified action and translation key.
static JCheckBoxMenuItem createCheckBoxMenuItem(ActionListener listener, com.threerings.util.MessageBundle msgs, String action, int mnemonic, int accelerator)
          Creates a check box menu item with the specified action, mnemonic, and (optional) accelerator.
static JCheckBoxMenuItem createCheckBoxMenuItem(ActionListener listener, com.threerings.util.MessageBundle msgs, String action, int mnemonic, int accelerator, int modifiers)
          Creates a check box menu item with the specified action, mnemonic, and (optional) accelerator key/modifiers.
static DataFlavor createLocalFlavor(Class<?> clazz)
          Creates a data flavor for transferring local references to objects of the specified class.
static JMenu createMenu(com.threerings.util.MessageBundle msgs, String name, int mnemonic)
          Creates a menu with the specified name and mnemonic.
static JMenuItem createMenuItem(ActionListener listener, com.threerings.util.MessageBundle msgs, String action, int mnemonic, int accelerator)
          Creates a menu item with the specified action, mnemonic, and (optional) accelerator.
static JMenuItem createMenuItem(ActionListener listener, com.threerings.util.MessageBundle msgs, String action, int mnemonic, int accelerator, int modifiers)
          Creates a menu item with the specified action, mnemonic, and (optional) accelerator key/modifiers.
static Object getWrappedTransferData(Transferable t)
          Returns the wrapped transfer data from the supplied transferable, or null if the wrapped flavors are not supported (or an exception occurs).
static void windowAdded()
          Notes that a window has been added.
static void windowRemoved()
          Notes that a window has been removed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCAL_WRAPPED_FLAVOR

public static final DataFlavor LOCAL_WRAPPED_FLAVOR
A data flavor for referenced local wrapped objects (on this VM).


SERIALIZED_WRAPPED_FLAVOR

public static final DataFlavor SERIALIZED_WRAPPED_FLAVOR
A data flavor for serialized wrapped objects (from another VM).


WRAPPED_FLAVORS

public static final DataFlavor[] WRAPPED_FLAVORS
The flavors for local and serialized wrapped objects.

Constructor Detail

ToolUtil

public ToolUtil()
Method Detail

createLocalFlavor

public static DataFlavor createLocalFlavor(Class<?> clazz)
Creates a data flavor for transferring local references to objects of the specified class.


getWrappedTransferData

public static Object getWrappedTransferData(Transferable t)
Returns the wrapped transfer data from the supplied transferable, or null if the wrapped flavors are not supported (or an exception occurs).


configureLog

public static void configureLog(String logfile)
Unless directed otherwise by a system property, redirects console output to the named log file.


createMenu

public static JMenu createMenu(com.threerings.util.MessageBundle msgs,
                               String name,
                               int mnemonic)
Creates a menu with the specified name and mnemonic.


createMenuItem

public static JMenuItem createMenuItem(ActionListener listener,
                                       com.threerings.util.MessageBundle msgs,
                                       String action,
                                       int mnemonic,
                                       int accelerator)
Creates a menu item with the specified action, mnemonic, and (optional) accelerator.


createMenuItem

public static JMenuItem createMenuItem(ActionListener listener,
                                       com.threerings.util.MessageBundle msgs,
                                       String action,
                                       int mnemonic,
                                       int accelerator,
                                       int modifiers)
Creates a menu item with the specified action, mnemonic, and (optional) accelerator key/modifiers.


createCheckBoxMenuItem

public static JCheckBoxMenuItem createCheckBoxMenuItem(ActionListener listener,
                                                       com.threerings.util.MessageBundle msgs,
                                                       String action,
                                                       int mnemonic,
                                                       int accelerator)
Creates a check box menu item with the specified action, mnemonic, and (optional) accelerator.


createCheckBoxMenuItem

public static JCheckBoxMenuItem createCheckBoxMenuItem(ActionListener listener,
                                                       com.threerings.util.MessageBundle msgs,
                                                       String action,
                                                       int mnemonic,
                                                       int accelerator,
                                                       int modifiers)
Creates a check box menu item with the specified action, mnemonic, and (optional) accelerator key/modifiers.


createAction

public static Action createAction(ActionListener listener,
                                  com.threerings.util.MessageBundle msgs,
                                  String command,
                                  int mnemonic,
                                  int accelerator)
Creates an action with the specified command, mnemonic, and (optional) accelerator.


createAction

public static Action createAction(ActionListener listener,
                                  com.threerings.util.MessageBundle msgs,
                                  String command,
                                  int mnemonic,
                                  int accelerator,
                                  int modifiers)
Creates an action with the specified command, mnemonic, and (optional) accelerator key/modifiers.


createButton

public static JButton createButton(ActionListener listener,
                                   com.threerings.util.MessageBundle msgs,
                                   String action)
Creates a button with the specified action.


createButton

public static JButton createButton(ActionListener listener,
                                   com.threerings.util.MessageBundle msgs,
                                   String action,
                                   String key)
Creates a button with the specified action and translation key.


windowAdded

public static void windowAdded()
Notes that a window has been added. When the window is removed, it should call windowRemoved().


windowRemoved

public static void windowRemoved()
Notes that a window has been removed. When the window count reaches zero, the app will exit.



Copyright © 2011. All Rights Reserved.