dsto.dfc.swt.icons
Class ValueLabel

java.lang.Object
  extended by dsto.dfc.swt.icons.ValueLabel

public class ValueLabel
extends Object

A value/label struct for abstracting the information displayed on Button's, Label's, Item's etc. Can also have an optional icon.

Author:
Matthew Phillips

Field Summary
 Icon icon
          The (optional) icon.
 String label
          The user-visible label.
 Object value
          The value associated with this label.
 
Constructor Summary
ValueLabel(String label, boolean value)
          Shortcut to create a new instance with a boolean value.
ValueLabel(String label, Icon icon, Object value)
          Create a new instance.
ValueLabel(String label, int value)
          Shortcut to create a new instance with an integer value.
ValueLabel(String label, Object value)
          Create a new instance.
 
Method Summary
 String getPlainLabel()
          Get the plain label text, with any shortcut "&"'s removed.
static String labelFor(ValueLabel[] valueLabels, Object value)
          Get the label associated with a value.
static String plainLabelFor(ValueLabel[] valueLabels, Object value)
          Get the plain text label associated with a value (see getPlainLabel()).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

public final Object value
The value associated with this label.


label

public final String label
The user-visible label. May include an & shortcut character.


icon

public final Icon icon
The (optional) icon.

Constructor Detail

ValueLabel

public ValueLabel(String label,
                  int value)
Shortcut to create a new instance with an integer value.

See Also:
ValueLabel(String, Icon, Object)

ValueLabel

public ValueLabel(String label,
                  boolean value)
Shortcut to create a new instance with a boolean value.

See Also:
ValueLabel(String, Icon, Object)

ValueLabel

public ValueLabel(String label,
                  Object value)
Create a new instance.

Parameters:
label - The label,
value - The value associated with the label.

ValueLabel

public ValueLabel(String label,
                  Icon icon,
                  Object value)
Create a new instance.

Parameters:
label - The label,
icon - The icon (may be null).
value - The value associated with the label.
Method Detail

getPlainLabel

public String getPlainLabel()
Get the plain label text, with any shortcut "&"'s removed.


labelFor

public static String labelFor(ValueLabel[] valueLabels,
                              Object value)
                       throws IllegalArgumentException
Get the label associated with a value.

Parameters:
valueLabels - The array of value/label's to search.
value - The value to look for.
Returns:
The value associated with the label.
Throws:
IllegalArgumentException - if there is no label for value.

plainLabelFor

public static String plainLabelFor(ValueLabel[] valueLabels,
                                   Object value)
Get the plain text label associated with a value (see getPlainLabel()).

Parameters:
valueLabels - The array of value/label's to search.
value - The value to look for.
Returns:
The value associated with the label.
Throws:
IllegalArgumentException - if there is no label for value.


Copyright © 2008 Commonwealth of Australia