DESY ACOP Beans Home

com.cosylab.gui.adapters
Class ConverterUtilities

java.lang.Object
  extended by com.cosylab.gui.adapters.ConverterUtilities

public class ConverterUtilities
extends java.lang.Object

A utility class for Converter manipulation.

Author:
Jaka Bobnar, Cosylab

Nested Class Summary
protected static class ConverterUtilities.CustomizerDialog
           
 
Field Summary
protected static java.util.HashMap<Converter,ConverterUtilities.CustomizerDialog> cache
           
 
Constructor Summary
ConverterUtilities()
           
 
Method Summary
static java.lang.String composeFunctionString(ConverterChain chain, java.lang.String value)
          Composes a function from the given chain of converters.
static java.lang.String composeFunctionString(Converter converter, java.lang.String value)
          Composes a function from the given converter.
protected static void dispatchValues(Converter converter, java.util.Map<java.lang.String,java.lang.Number> values)
          Sets the converter's fields with new values obtained from the editor dialog.
protected static java.util.Map<java.lang.String,java.lang.Number> extractInitialValues(Converter converter)
          Obtains initial values of converter's fields.
static Converter getConverterFromString(java.lang.String converterToString)
          Constructs a converter from a string.
protected static java.lang.String[] getFieldNames(Converter converter)
          Returns the names of the fields that will be visible in the dialog.
static java.lang.String getInitializationString(Converter converter)
          Constructs an initialization string used by PropertyEditor.
static boolean isEditable(Converter converter)
          Checks if converter is editable.
static void main(java.lang.String[] args)
           
static boolean showEditorDialog(java.awt.Component parent, Converter converter)
          Shows a dialog window with converter editor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected static java.util.HashMap<Converter,ConverterUtilities.CustomizerDialog> cache
Constructor Detail

ConverterUtilities

public ConverterUtilities()
Method Detail

showEditorDialog

public static boolean showEditorDialog(java.awt.Component parent,
                                       Converter converter)
Shows a dialog window with converter editor.

Parameters:
parent - parent of the dialog
converter - converter to be edited
Returns:
returns true if editing was confirmed or false if it was cancelled

extractInitialValues

protected static java.util.Map<java.lang.String,java.lang.Number> extractInitialValues(Converter converter)
Obtains initial values of converter's fields. Method returns a map of all fields with their corresponding values. The name of the field (the key in the map) should be the same as returned by getFieldNames(Converter) method.

Parameters:
converter -
Returns:

dispatchValues

protected static void dispatchValues(Converter converter,
                                     java.util.Map<java.lang.String,java.lang.Number> values)
Sets the converter's fields with new values obtained from the editor dialog.

Parameters:
converter -
values -

getFieldNames

protected static java.lang.String[] getFieldNames(Converter converter)
Returns the names of the fields that will be visible in the dialog.

Parameters:
converter -
Returns:

isEditable

public static boolean isEditable(Converter converter)
Checks if converter is editable.

Parameters:
converter -
Returns:
true if editable

composeFunctionString

public static java.lang.String composeFunctionString(ConverterChain chain,
                                                     java.lang.String value)
Composes a function from the given chain of converters. Parameter value is the input value that converter transforms. If converter does f(x) this method should give a string representing the f(value).

Parameters:
chain -
value -
Returns:

composeFunctionString

public static java.lang.String composeFunctionString(Converter converter,
                                                     java.lang.String value)
Composes a function from the given converter. Parameter value is the input value that converter transforms. If converter does f(x) this method should give a string representing the f(value).

Parameters:
converter -
value -
Returns:

getInitializationString

public static java.lang.String getInitializationString(Converter converter)
Constructs an initialization string used by PropertyEditor.

Parameters:
converter -
Returns:

getConverterFromString

public static Converter getConverterFromString(java.lang.String converterToString)
Constructs a converter from a string. The given string is expected to be the same as converter.toString() would return.

Parameters:
converterToString -
Returns:

main

public static void main(java.lang.String[] args)
                 throws java.beans.PropertyVetoException
Throws:
java.beans.PropertyVetoException


Copyright © 2010. All Rights Reserved.