org.das2.dasml
Class OptionListEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JButton
                      extended by org.das2.dasml.OptionListEditor
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.beans.PropertyEditor, java.io.Serializable, javax.accessibility.Accessible, javax.swing.CellEditor, javax.swing.SwingConstants, javax.swing.table.TableCellEditor, OptionList

public class OptionListEditor
extends javax.swing.JButton
implements OptionList, javax.swing.table.TableCellEditor, java.beans.PropertyEditor

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JButton
javax.swing.JButton.AccessibleJButton
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OptionListEditor()
          Creates a new instance of FormChoiceEditor
 
Method Summary
 void addCellEditorListener(javax.swing.event.CellEditorListener l)
          Adds a listener to the list that's notified when the editor stops, or cancels editing.
 void cancelCellEditing()
          Tells the editor to cancel editing and not accept any partially edited value.
 java.lang.String getAsText()
          Gets the property value as text.
 java.lang.Object getCellEditorValue()
          Returns the value contained in the editor.
 java.awt.Component getCustomEditor()
          A PropertyEditor may choose to make available a full custom Component that edits its property value.
 java.lang.String getJavaInitializationString()
          This method is intended for use when generating Java code to set the value of the property.
 ListOption[] getOptions()
           
 java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
          Sets an initial value for the editor.
 java.lang.String[] getTags()
          If the property value must be one of a set of known tagged values, then this method should return an array of the tags.
 java.lang.Object getValue()
          Gets the property value.
 boolean isCellEditable(java.util.EventObject anEvent)
          Asks the editor if it can start editing using anEvent.
 boolean isPaintable()
          Determines whether this property editor is paintable.
static void main(java.lang.String[] args)
           
 void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box)
          Paint a representation of the value into a given area of screen real estate.
 void removeCellEditorListener(javax.swing.event.CellEditorListener l)
          Removes a listener from the list that's notified
 void setAsText(java.lang.String text)
          Set the property value by parsing a given String.
 void setOptions(ListOption[] options)
           
 void setValue(java.lang.Object value)
          Set (or change) the object that is to be edited.
 boolean shouldSelectCell(java.util.EventObject anEvent)
          Returns true if the editing cell should be selected, false otherwise.
 void showDialog()
           
 boolean stopCellEditing()
          Tells the editor to stop editing and accept any partially edited value as the value of the editor.
 boolean supportsCustomEditor()
          Determines whether this property editor supports a custom editor.
 
Methods inherited from class javax.swing.JButton
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
 
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.beans.PropertyEditor
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

OptionListEditor

public OptionListEditor()
Creates a new instance of FormChoiceEditor

Method Detail

showDialog

public void showDialog()

main

public static void main(java.lang.String[] args)

getOptions

public ListOption[] getOptions()
Specified by:
getOptions in interface OptionList

setOptions

public void setOptions(ListOption[] options)
Specified by:
setOptions in interface OptionList

addCellEditorListener

public void addCellEditorListener(javax.swing.event.CellEditorListener l)
Adds a listener to the list that's notified when the editor stops, or cancels editing.

Specified by:
addCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the CellEditorListener

cancelCellEditing

public void cancelCellEditing()
Tells the editor to cancel editing and not accept any partially edited value.

Specified by:
cancelCellEditing in interface javax.swing.CellEditor

getCellEditorValue

public java.lang.Object getCellEditorValue()
Returns the value contained in the editor.

Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
the value contained in the editor

getTableCellEditorComponent

public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
                                                      java.lang.Object value,
                                                      boolean isSelected,
                                                      int row,
                                                      int column)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called.

Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
Parameters:
table - the JTable that is asking the editor to edit; can be null
value - the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value
isSelected - true if the cell is to be rendered with highlighting
row - the row of the cell being edited
column - the column of the cell being edited
Returns:
the component for editing

isCellEditable

public boolean isCellEditable(java.util.EventObject anEvent)
Asks the editor if it can start editing using anEvent. anEvent is in the invoking component coordinate system. The editor can not assume the Component returned by getCellEditorComponent is installed. This method is intended for the use of client to avoid the cost of setting up and installing the editor component if editing is not possible. If editing can be started this method returns true.

Specified by:
isCellEditable in interface javax.swing.CellEditor
Parameters:
anEvent - the event the editor should use to consider whether to begin editing or not
Returns:
true if editing can be started
See Also:
shouldSelectCell(java.util.EventObject)

removeCellEditorListener

public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
Removes a listener from the list that's notified

Specified by:
removeCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the CellEditorListener

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject anEvent)
Returns true if the editing cell should be selected, false otherwise. Typically, the return value is true, because is most cases the editing cell should be selected. However, it is useful to return false to keep the selection from changing for some types of edits. eg. A table that contains a column of check boxes, the user might want to be able to change those checkboxes without altering the selection. (See Netscape Communicator for just such an example) Of course, it is up to the client of the editor to use the return value, but it doesn't need to if it doesn't want to.

Specified by:
shouldSelectCell in interface javax.swing.CellEditor
Parameters:
anEvent - the event the editor should use to start editing
Returns:
true if the editor would like the editing cell to be selected; otherwise returns false
See Also:
isCellEditable(java.util.EventObject)

stopCellEditing

public boolean stopCellEditing()
Tells the editor to stop editing and accept any partially edited value as the value of the editor. The editor returns false if editing was not stopped; this is useful for editors that validate and can not accept invalid entries.

Specified by:
stopCellEditing in interface javax.swing.CellEditor
Returns:
true if editing was stopped; false otherwise

getAsText

public java.lang.String getAsText()
Gets the property value as text.

Specified by:
getAsText in interface java.beans.PropertyEditor
Returns:
The property value as a human editable string.

Returns null if the value can't be expressed as an editable string.

If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().


getCustomEditor

public java.awt.Component getCustomEditor()
A PropertyEditor may choose to make available a full custom Component that edits its property value. It is the responsibility of the PropertyEditor to hook itself up to its editor Component itself and to report property value changes by firing a PropertyChange event.

The higher-level code that calls getCustomEditor may either embed the Component in some larger property sheet, or it may put it in its own individual dialog, or ...

Specified by:
getCustomEditor in interface java.beans.PropertyEditor
Returns:
A java.awt.Component that will allow a human to directly edit the current property value. May be null if this is not supported.

getJavaInitializationString

public java.lang.String getJavaInitializationString()
This method is intended for use when generating Java code to set the value of the property. It should return a fragment of Java code that can be used to initialize a variable with the current property value.

Example results are "2", "new Color(127,127,34)", "Color.orange", etc.

Specified by:
getJavaInitializationString in interface java.beans.PropertyEditor
Returns:
A fragment of Java code representing an initializer for the current value.

getTags

public java.lang.String[] getTags()
If the property value must be one of a set of known tagged values, then this method should return an array of the tags. This can be used to represent (for example) enum values. If a PropertyEditor supports tags, then it should support the use of setAsText with a tag value as a way of setting the value and the use of getAsText to identify the current value.

Specified by:
getTags in interface java.beans.PropertyEditor
Returns:
The tag values for this property. May be null if this property cannot be represented as a tagged value.

getValue

public java.lang.Object getValue()
Gets the property value.

Specified by:
getValue in interface java.beans.PropertyEditor
Returns:
The value of the property. Primitive types such as "int" will be wrapped as the corresponding object type such as "java.lang.Integer".

isPaintable

public boolean isPaintable()
Determines whether this property editor is paintable.

Specified by:
isPaintable in interface java.beans.PropertyEditor
Returns:
True if the class will honor the paintValue method.

paintValue

public void paintValue(java.awt.Graphics gfx,
                       java.awt.Rectangle box)
Paint a representation of the value into a given area of screen real estate. Note that the propertyEditor is responsible for doing its own clipping so that it fits into the given rectangle.

If the PropertyEditor doesn't honor paint requests (see isPaintable) this method should be a silent noop.

The given Graphics object will have the default font, color, etc of the parent container. The PropertyEditor may change graphics attributes such as font and color and doesn't need to restore the old values.

Specified by:
paintValue in interface java.beans.PropertyEditor
Parameters:
gfx - Graphics object to paint into.
box - Rectangle within graphics object into which we should paint.

setAsText

public void setAsText(java.lang.String text)
               throws java.lang.IllegalArgumentException
Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.

Specified by:
setAsText in interface java.beans.PropertyEditor
Parameters:
text - The string to be parsed.
Throws:
java.lang.IllegalArgumentException

setValue

public void setValue(java.lang.Object value)
Set (or change) the object that is to be edited. Primitive types such as "int" must be wrapped as the corresponding object type such as "java.lang.Integer".

Specified by:
setValue in interface java.beans.PropertyEditor
Parameters:
value - The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.

supportsCustomEditor

public boolean supportsCustomEditor()
Determines whether this property editor supports a custom editor.

Specified by:
supportsCustomEditor in interface java.beans.PropertyEditor
Returns:
True if the propertyEditor can provide a custom editor.