arlut.csd.JDataComponent
Class StringSelector

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--arlut.csd.JDataComponent.StringSelector
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, JsetValueCallback, java.awt.MenuContainer, java.io.Serializable

public class StringSelector
extends javax.swing.JPanel
implements java.awt.event.ActionListener, JsetValueCallback

A two-paneled GUI component for adding or removing strings and/or labeled objects from a list, with an optional list of available strings and/or objects to choose from.

StringSelector consists of one or (optionally) two JstringListBox panels and allows the user to move values back and forth between the two panels. Pop-up menus can be attached to each panel, allowing the user to command the client to view or edit objects referenced in either panel. Objects in both panels are sorted alphabetically by label.

The setCallback() method takes an object implementing the JsetValueCallback interface in order to provide live notification of changes performed by the user. The JsetValueCallback implementation is given the opportunity to approve any change made by the user before the GUI is updated to show the change. The JsetValueCallback interface is also used to pass pop-up menu commands to the client.

See Also:
JstringListBox, JsetValueCallback, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.ActionStandin, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  javax.swing.JButton add
           
(package private)  javax.swing.JButton addCustom
           
private  boolean canChoose
           
(package private)  JstringField custom
           
(package private) static boolean debug
           
private  boolean editable
           
(package private)  JstringListBox in
           
(package private)  javax.swing.JPanel inPanel
           
(package private)  javax.swing.JButton inTitle
           
private  boolean mustChoose
           
(package private)  JsetValueCallback my_callback
           
(package private)  java.lang.String org_in
           
(package private)  java.lang.String org_out
           
(package private)  JstringListBox out
           
(package private)  javax.swing.JPanel outPanel
           
(package private)  javax.swing.JButton outTitle
           
(package private)  java.awt.Container parent
           
(package private)  javax.swing.JButton remove
           
 
Fields inherited from class javax.swing.JPanel
defaultLayout, uiClassID
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, actionMap, ACTIONMAP_CREATED, alignmentX, alignmentY, ANCESTOR_INPUTMAP_CREATED, ANCESTOR_USING_BUFFER, ancestorInputMap, ancestorNotifier, autoscroller, border, changeSupport, clientProperties, CREATED_DOUBLE_BUFFER, flags, FOCUS_INPUTMAP_CREATED, focusInputMap, HAS_FOCUS, htmlKey, htmlView, inputVerifier, IS_DOUBLE_BUFFERED, IS_OPAQUE, IS_PAINTING_TILE, IS_PRINTING, IS_PRINTING_ALL, KEY_EVENTS_ENABLED, KEYBOARD_BINDINGS_KEY, listenerList, maximumSize, minimumSize, NEXT_FOCUS, paintImmediatelyClip, paintingChild, preferredSize, readObjectCallbacks, REQUEST_FOCUS_DISABLED, tmpRect, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, verifyInputWhenFocusTarget, vetoableChangeSupport, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, WHEN_IN_FOCUSED_WINDOW_BINDINGS, WIF_INPUTMAP_CREATED, windowInputMap
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
StringSelector(java.awt.Container parent, boolean editable, boolean canChoose, boolean mustChoose)
          Fully specified Constructor for StringSelector
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method handles events from the Add and Remove buttons, and from hitting enter/loss of focus in the custom JstringField.
(package private)  void addItem()
          Internal method to move item from out to in
 void addNewItem(java.lang.Object item, boolean ShouldBeIn)
          Add a new item to the StringSelector.
 java.util.Vector getChosenHandles()
          Returns a Vector of listHandle objects corresponding to the currently selected members.
 java.util.Vector getChosenStrings()
          Returns a Vector of Strings corresponding to the currently selected members.
 boolean isEditable()
          Returns true if this StringSelector is editable.
static void main(java.lang.String[] args)
           
(package private)  void putItemIn(listHandle item)
          this actually does the inserting
(package private)  void removeItem()
          internal method to move item from in to out
 void setButtonText(java.lang.String text)
          Change the text on the add button.
 void setCallback(JsetValueCallback parent)
          Connects this StringSelector to an implementaton of the JsetValueCallback interface in order to provide live notification of changes performed by the user.
 void setCellWidth(int rowWidth)
          This method sets the width of the in and out rows.
 void setCellWidth(java.lang.String template)
          This method sets the width of the in and out rows.
 void setPopups(javax.swing.JPopupMenu inPopup, javax.swing.JPopupMenu outPopup)
          This method attaches popup menus to the in box and out box.
 void setTitles(java.lang.String inString, java.lang.String outString)
          This method sets the titles for the in and out boxes.
 boolean setValuePerformed(JValueObject o)
          Accept a status update from a GUI component in the arlut.csd.JDataComponent package.
 void setVisibleRowCount(int numRows)
          Deprecated. This doesn't work anymore.
(package private)  void takeItemOut(listHandle item)
          this actually moves it from from in to out
 void update(java.util.Vector available, boolean sortAvailable, Compare availComparator, java.util.Vector chosen, boolean sortChosen, Compare chosenComparator)
          Update the StringSelector.
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, checkIfChildObscuredBySibling, clearFocusOwners, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperties, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getFlag, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintWithBuffer, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFlag, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFocusOwner, setLayout, transferFocus, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, constructComponentName, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resetGC, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

debug

static final boolean debug

my_callback

JsetValueCallback my_callback

add

javax.swing.JButton add

remove

javax.swing.JButton remove

in

JstringListBox in

out

JstringListBox out

inPanel

javax.swing.JPanel inPanel

outPanel

javax.swing.JPanel outPanel

inTitle

javax.swing.JButton inTitle

outTitle

javax.swing.JButton outTitle

org_in

java.lang.String org_in

org_out

java.lang.String org_out

addCustom

javax.swing.JButton addCustom

custom

JstringField custom

parent

java.awt.Container parent

editable

private boolean editable

canChoose

private boolean canChoose

mustChoose

private boolean mustChoose
Constructor Detail

StringSelector

public StringSelector(java.awt.Container parent,
                      boolean editable,
                      boolean canChoose,
                      boolean mustChoose)
Fully specified Constructor for StringSelector
Parameters:
parent - AWT container that the StringSelector will be contained in.
editable - If false, this string selector is for display only
canChoose - Choice must be made from vector of choices
mustChoose - Vector of choices is available
Method Detail

setCellWidth

public void setCellWidth(int rowWidth)

This method sets the width of the in and out rows.

Parameters:
width - How many columns wide should each box be? If <= 0, the StringSelector will auto-size the columns

setCellWidth

public void setCellWidth(java.lang.String template)

This method sets the width of the in and out rows.

Parameters:
template - A string to use as the required size of the cells in the in and out boxes.

setTitles

public void setTitles(java.lang.String inString,
                      java.lang.String outString)

This method sets the titles for the in and out boxes. The StringSelector will show these titles, followed by a colon and the current count of elements in the in and/or out boxes.


setPopups

public void setPopups(javax.swing.JPopupMenu inPopup,
                      javax.swing.JPopupMenu outPopup)

This method attaches popup menus to the in box and out box.


isEditable

public boolean isEditable()

Returns true if this StringSelector is editable.

Non-editable StringSelector's only have the chosen list. Editable StringSelector's have both the chosen and available lists.


update

public void update(java.util.Vector available,
                   boolean sortAvailable,
                   Compare availComparator,
                   java.util.Vector chosen,
                   boolean sortChosen,
                   Compare chosenComparator)
Update the StringSelector.

setButtonText

public void setButtonText(java.lang.String text)
Change the text on the add button.

setVisibleRowCount

public void setVisibleRowCount(int numRows)
Deprecated. This doesn't work anymore.


addNewItem

public void addNewItem(java.lang.Object item,
                       boolean ShouldBeIn)

Add a new item to the StringSelector.

This is for adding an item that is not in either list, not selecting an item from the out list.

Parameters:
item - Item to be added. Can be listHandle or String
ShouldBeIn - If true, object will be placed in in list. Otherwise, it goes in out list.

setCallback

public void setCallback(JsetValueCallback parent)

Connects this StringSelector to an implementaton of the JsetValueCallback interface in order to provide live notification of changes performed by the user. The JsetValueCallback implementation is given the opportunity to approve any change made by the user before the GUI is updated to show the change. The JsetValueCallback interface is also used to pass pop-up menu commands to the client.

StringSelector uses the following value type constants from JValueObject to pass status updates to the callback.

See Also:
JsetValueCallback, JValueObject

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method handles events from the Add and Remove buttons, and from hitting enter/loss of focus in the custom JstringField.
Specified by:
actionPerformed in interface java.awt.event.ActionListener

addItem

void addItem()
Internal method to move item from out to in

removeItem

void removeItem()
internal method to move item from in to out

putItemIn

void putItemIn(listHandle item)
this actually does the inserting

takeItemOut

void takeItemOut(listHandle item)
this actually moves it from from in to out

setValuePerformed

public boolean setValuePerformed(JValueObject o)
Description copied from interface: JsetValueCallback
Accept a status update from a GUI component in the arlut.csd.JDataComponent package. This method throws an RMI remote exception to allow the client to call the server for value verification from within a setValuePerformed() method. GUI components that call setValuePerformed() should treate an RMI RemoteException as a failure and not display the proposed value change.
Specified by:
setValuePerformed in interface JsetValueCallback
Following copied from interface: arlut.csd.JDataComponent.JsetValueCallback
Returns:
true if the callback accepted the change and the GUI component should go ahead and display the change made by the user.

getChosenHandles

public java.util.Vector getChosenHandles()

Returns a Vector of listHandle objects corresponding to the currently selected members.


getChosenStrings

public java.util.Vector getChosenStrings()

Returns a Vector of Strings corresponding to the currently selected members.


main

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