adm
Class CChoice

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Choice
              |
              +--adm.CChoice

public class CChoice
extends java.awt.Choice
implements CInterface, DeviceListener, java.awt.event.ItemListener

CChoice is subclass of awt.Choice. It is used to control a device/property value of enumerated type. If the connected device/property is not an Enum data type, three items "Invalid", deviceName and propertyName will be shown in the choice. The selection is fixed on the first item (Invalid).

The state change event action is built into this widget. When the item state is changed, the cursor will change to the waiting cursor and a set action will be sent to the control system. If the set fails, the selected item (display) will revert to the old one and an error message will be printed to standard output. The selection is also disabled.

Since:
adm0.2
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CChoice()
          Null constructor.
CChoice(java.lang.String dName, java.lang.String pName)
          Null constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent event)
          Get the Enum value from control system and add to the choice at first call.
 java.lang.String getDeviceName()
          Return the device name to which this component is connected.
 java.lang.String getPropertyName()
          Return the device property name to which this component is connected.
 void itemStateChanged(java.awt.event.ItemEvent evt)
          To send the new value to the control system.
 void setDeviceAndPropertyName(java.lang.String newDeviceName, java.lang.String newPropertyName)
          Set device name and device property name
 void setDeviceName(java.lang.String newName)
          Set the Device name
 void setPropertyName(java.lang.String newName)
          Set device property name
 
Methods inherited from class java.awt.Choice
add, addItem, addItemListener, addNotify, countItems, getItem, getItemCount, getSelectedIndex, getSelectedItem, getSelectedObjects, insert, remove, remove, removeAll, removeItemListener, select, select
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CChoice

public CChoice()
Null constructor.

CChoice

public CChoice(java.lang.String dName,
               java.lang.String pName)
Null constructor with device name and property name
Parameters:
dName - device name
pName - property name
Method Detail

setDeviceName

public void setDeviceName(java.lang.String newName)
Set the Device name
Specified by:
setDeviceName in interface CInterface
Parameters:
newName - the name of device you want to connect

getDeviceName

public java.lang.String getDeviceName()
Return the device name to which this component is connected. If device name is not set, return empty string "".
Specified by:
getDeviceName in interface CInterface

setPropertyName

public void setPropertyName(java.lang.String newName)
Set device property name
Specified by:
setPropertyName in interface CInterface
Parameters:
newName - the name of device property you want to connect

getPropertyName

public java.lang.String getPropertyName()
Return the device property name to which this component is connected. If property name is not set, return empty string "".
Specified by:
getPropertyName in interface CInterface

setDeviceAndPropertyName

public void setDeviceAndPropertyName(java.lang.String newDeviceName,
                                     java.lang.String newPropertyName)
Set device name and device property name
Parameters:
newDeviceName - the device name you want to connect
newPropertyName - the device property name you want to connect

deviceChanged

public void deviceChanged(DeviceEvent event)
Get the Enum value from control system and add to the choice at first call. Change the select item to the current Enum when the control system updates.
Specified by:
deviceChanged in interface DeviceListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent evt)
To send the new value to the control system. The cursor change to waiting cursor. The setListener will keep track the error message return from the control system and set the cursor back to default cursor.
Specified by:
itemStateChanged in interface java.awt.event.ItemListener