wt.clients.util
Class EnumeratedList

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.List
          extended bywt.clients.util.EnumeratedList
All Implemented Interfaces:
Accessible, ImageObserver, ItemSelectable, MenuContainer, Serializable

public class EnumeratedList
extends List

This class allows the selection of the allowable values for a specified EnumeratedType class in a choice list.



Supported API: true

Extendable: false Sample code:


        static public void main(String args[])
        {
            if (args.length == 0 )
            {
                System.out.println("supply enumeration class");
                return;
            }

            String classname = args[0];
                class DriverFrame extends java.awt.Frame
                {
                    EnumeratedList choice = null;
                        public DriverFrame(String title)
                        {
                super(title);
                                addWindowListener(new java.awt.event.WindowAdapter() {
                                        public void windowClosing(java.awt.event.WindowEvent event)
                                        {
                                                dispose();	  // free the system resources
                                                System.exit(0); // close the application
                                        }
                                });
                                setLayout(new java.awt.BorderLayout());
                                setSize(300,300);
                                choice = new EnumeratedList();
                                choice.setDisplayNonSelectable(true);

                                add(choice, "Center");

                                choice.addItemListener( new java.awt.event.ItemListener() {
                                    public void itemStateChanged(ItemEvent ie)
                                    {
                                        EnumeratedType value = choice.getSelectedEnumeratedType();
                                        System.out.println("Selected value is now " + value);
                                    }
                                });
                        }
                        public void setClass(String name)
                        {
                                try {
                                    choice.setEnumeratedTypeClassName(name);
                            }
                            catch(PropertyVetoException pve)
                            {
                                pve.printStackTrace();
                            }
                        }

                        public void setClass(Class a_class)
                        {
                                try {
                                    choice.setEnumeratedTypeClass(a_class);
                            }
                            catch(PropertyVetoException pve)
                            {
                                pve.printStackTrace();

                            }
                    }
                }
        DriverFrame df;
        df = new DriverFrame("EnumeratedList Test");
        df.setClass(classname);
        df.show();
        }

 

See Also:
wt.fc.EnumeratedType;, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.List
List.AccessibleAWTList
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  boolean allChoiceAllowed
           
private  boolean blankChoiceAllowed
           
protected  Hashtable displayedValues
           
private  boolean displayNonSelectable
           
private  Class enumeratedTypeClass
           
protected static ResourceBundle resource
           
protected static String RESOURCE
           
protected  EnumeratedType[] valueSet
           
 
Fields inherited from class java.awt.List
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
EnumeratedList(int shown)
           
 
Method Summary
static WTContext getContext()
           
 Class getEnumeratedTypeClass()
          Returns the class of the EnumeratedType used by this component.
 String getEnumeratedTypeClassName()
          Gets the class name of the EnumeratedType used by this component.
static ResourceBundle getLabelsRB()
           
static String getLocalizedMessage(String key, Object[] params)
           
static String getLocalizedValue(String key)
           
 EnumeratedType getSelectedEnumeratedType()
          Gets a representation of the current choice as an EnumeratedList.
protected  String getSimpleName(Class a_class)
          Helper method to get the name of the class without the package qualification.
protected static void initResources()
           
 boolean isAllChoiceAllowed()
          Determines if an "All" choice has been added to the list.
 boolean isBlankChoiceAllowed()
          Determines if an blank choice has been added to the list.
 boolean isDisplayNonSelectable()
          Returns true if items in the list for the EnumeratedList marked as non-selectable will be displayed in the list.
static void main(String[] args)
          A main method that demonstrates how to use this class and allows testing.
protected  void redrawList()
          Internal method to redraw the choice list.
 void setAllChoiceAllowed(boolean choice)
          Sets if an "All" choice should be added to the list.
 void setBlankChoiceAllowed(boolean choice)
          Sets if a blank choice should be added to the list.
 void setDisplayNonSelectable(boolean value)
          Sets if items in the list for the EnumeratedList marked as non-selectable should be displayed in the list.
 void setEnumeratedTypeClass(Class enumeratedTypeClass)
          Sets the EnumeratedType class to be used by this component.
 void setEnumeratedTypeClassName(String enumeratedTypeClassName)
          Sets the class name of the EnumeratedType used by this component.
 void setSelectedEnumeratedType(EnumeratedType type)
          Sets the selected item in this Choice to be the item with the specified EnumeratedType value.
 
Methods inherited from class java.awt.List
add, add, addActionListener, addItem, addItem, addItemListener, addNotify, allowsMultipleSelections, clear, countItems, delItem, delItems, deselect, getAccessibleContext, getActionListeners, getItem, getItemCount, getItemListeners, getItems, getListeners, getMinimumSize, getMinimumSize, getPreferredSize, getPreferredSize, getRows, getSelectedIndex, getSelectedIndexes, getSelectedItem, getSelectedItems, getSelectedObjects, getVisibleIndex, isIndexSelected, isMultipleMode, isSelected, makeVisible, minimumSize, minimumSize, paramString, preferredSize, preferredSize, processActionEvent, processEvent, processItemEvent, remove, remove, removeActionListener, removeAll, removeItemListener, removeNotify, replaceItem, select, setMultipleMode, setMultipleSelections
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

enumeratedTypeClass

private Class enumeratedTypeClass

valueSet

protected EnumeratedType[] valueSet

displayedValues

protected Hashtable displayedValues

allChoiceAllowed

private boolean allChoiceAllowed

blankChoiceAllowed

private boolean blankChoiceAllowed

displayNonSelectable

private boolean displayNonSelectable

RESOURCE

protected static String RESOURCE

resource

protected static ResourceBundle resource
Constructor Detail

EnumeratedList

public EnumeratedList(int shown)
Method Detail

setEnumeratedTypeClass

public void setEnumeratedTypeClass(Class enumeratedTypeClass)
                            throws PropertyVetoException
Sets the EnumeratedType class to be used by this component.

This will populate the choice component with the list of selectable values for the specified EnumeratedType.

Throws:
PropertyVetoException
See Also:
getEnumeratedTypeClass()

getEnumeratedTypeClass

public Class getEnumeratedTypeClass()
Returns the class of the EnumeratedType used by this component.

Returns:
Class the EnumeratedType class used in the component
See Also:
setEnumeratedTypeClass(java.lang.Class)

setEnumeratedTypeClassName

public void setEnumeratedTypeClassName(String enumeratedTypeClassName)
                                throws PropertyVetoException
Sets the class name of the EnumeratedType used by this component.

This will populate the choice component with the list of selectable values for the specified EnumeratedType.

Throws:
PropertyVetoException
See Also:
getEnumeratedTypeClassName()

getEnumeratedTypeClassName

public String getEnumeratedTypeClassName()
Gets the class name of the EnumeratedType used by this component.

Returns:
the fully qualified class name of the EnumeratedType used
See Also:
setEnumeratedTypeClassName(java.lang.String)

isAllChoiceAllowed

public boolean isAllChoiceAllowed()
Determines if an "All" choice has been added to the list.

Returns:
true if the all choice is allowed; false otherwise.
See Also:
setAllChoiceAllowed(boolean)

setAllChoiceAllowed

public void setAllChoiceAllowed(boolean choice)
Sets if an "All" choice should be added to the list.

See Also:
isAllChoiceAllowed()

setDisplayNonSelectable

public void setDisplayNonSelectable(boolean value)
Sets if items in the list for the EnumeratedList marked as non-selectable should be displayed in the list.

See Also:
isDisplayNonSelectable()

isDisplayNonSelectable

public boolean isDisplayNonSelectable()
Returns true if items in the list for the EnumeratedList marked as non-selectable will be displayed in the list.

Returns:
true if items in the list for the EnumeratedList marked as non-selectable will be displayed in the list.
See Also:
setDisplayNonSelectable(boolean)

redrawList

protected void redrawList()
Internal method to redraw the choice list. Called whenever a relevant property is set for the bean.


isBlankChoiceAllowed

public boolean isBlankChoiceAllowed()
Determines if an blank choice has been added to the list.

Returns:
true if the blank choice is allowed; false otherwise.
See Also:
setBlankChoiceAllowed(boolean)

setBlankChoiceAllowed

public void setBlankChoiceAllowed(boolean choice)
Sets if a blank choice should be added to the list.

See Also:
isBlankChoiceAllowed()

getSimpleName

protected String getSimpleName(Class a_class)
Helper method to get the name of the class without the package qualification.


setSelectedEnumeratedType

public void setSelectedEnumeratedType(EnumeratedType type)
Sets the selected item in this Choice to be the item with the specified EnumeratedType value.

See Also:
getSelectedEnumeratedType()

getSelectedEnumeratedType

public EnumeratedType getSelectedEnumeratedType()
Gets a representation of the current choice as an EnumeratedList.

See Also:
setSelectedEnumeratedType(wt.fc.EnumeratedType)

initResources

protected static void initResources()

getContext

public static WTContext getContext()

getLocalizedMessage

public static String getLocalizedMessage(String key,
                                         Object[] params)

getLabelsRB

public static ResourceBundle getLabelsRB()

getLocalizedValue

public static String getLocalizedValue(String key)

main

public static void main(String[] args)
A main method that demonstrates how to use this class and allows testing.