ca.nengo.config
Class ConfigUtil

java.lang.Object
  extended by ca.nengo.config.ConfigUtil

public class ConfigUtil
extends java.lang.Object

Configuration-related utility methods.

Author:
Bryan Tripp

Nested Class Summary
static class ConfigUtil.ConfigurationPane
           
 
Constructor Summary
ConfigUtil()
           
 
Method Summary
static void configure(java.awt.Dialog owner, java.lang.Object o)
           
static void configure(java.awt.Frame owner, java.lang.Object o)
           
static ConfigUtil.ConfigurationPane createConfigurationPane(java.lang.Object o)
          Shows a tree in which object properties can be edited.
static ConfigurationImpl defaultConfiguration(java.lang.Object configurable)
           
static Configuration getConfiguration(java.lang.Object configurable)
           
static java.lang.Object getDefaultValue(java.lang.Class<?> type)
           
static java.lang.Class<?> getPrimitiveWrapperClass(java.lang.Class<?> c)
           
static void showHelp(java.lang.String text)
          Displays given text in a help window.
static java.lang.String stripSuffix(java.lang.String s, java.lang.String suffix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigUtil

public ConfigUtil()
Method Detail

configure

public static void configure(java.awt.Dialog owner,
                             java.lang.Object o)

configure

public static void configure(java.awt.Frame owner,
                             java.lang.Object o)

createConfigurationPane

public static ConfigUtil.ConfigurationPane createConfigurationPane(java.lang.Object o)
Shows a tree in which object properties can be edited.

Parameters:
o - The Object to configure
Returns:
A Scroll Pane containing the configuration properties

getConfiguration

public static Configuration getConfiguration(java.lang.Object configurable)
Parameters:
configurable - An object
Returns:
configurable.getConfiguration() : Configuration if such a method is defined for configurable, otherwise ConfigUtil.defaultConfiguration(configurable).

defaultConfiguration

public static ConfigurationImpl defaultConfiguration(java.lang.Object configurable)
Parameters:
configurable - An Object
Returns:
A default Configuration with properties of the object, based on reflection of the object's getters and setters.

stripSuffix

public static java.lang.String stripSuffix(java.lang.String s,
                                           java.lang.String suffix)
Parameters:
s - A String
suffix - Something that the string might end with
Returns:
The string with the given suffix removed (if it was there)

getPrimitiveWrapperClass

public static java.lang.Class<?> getPrimitiveWrapperClass(java.lang.Class<?> c)
Parameters:
c - Any class
Returns:
Either c or if c is a primitive class (eg Integer.TYPE), the corresponding wrapper class

getDefaultValue

public static java.lang.Object getDefaultValue(java.lang.Class<?> type)
Parameters:
type - A class
Returns:
If there is a ConfigurationHandler for the class, then getDefaultValue() from that handler, otherwise if there is a zero-arg constructor then the result of that constructor, otherwise null.

showHelp

public static void showHelp(java.lang.String text)
Displays given text in a help window.

Parameters:
text - Help text (html body)