arlut.csd.JDataComponent
Class JstringListBox

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JList
                          |
                          +--arlut.csd.JDataComponent.JstringListBox
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, Compare, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.Scrollable, java.io.Serializable

public class JstringListBox
extends javax.swing.JList
implements java.awt.event.ActionListener, javax.swing.event.ListSelectionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Compare

A sorted listbox that handles listHandle's. JstringListBox supports pop-up menus and uses the

See Also:
Invid, listHandle, StringSelector, JsetValueCallback, Serialized Form

Field Summary
(package private)  arlut.csd.JDataComponent.JsetValueCallback callback
          The callback we'l use to report user activities.
(package private)  arlut.csd.Util.Compare comparator
          The comparator to use for putting items in sort order if the JstringListBox was most recently with sorting request.
(package private) static boolean debug
           
private  boolean doSort
          If true, the JstringListBox will sort items.
private  int dragNode
           
private  boolean dragOk
          If true, this JstringListBox will allow nodes to be dragged up and down in the list.
(package private)  java.lang.String maxWidthString
          The default maximum width string
(package private)  javax.swing.DefaultListModel model
           
(package private)  javax.swing.JPopupMenu popup
          The popup menu to be displayed on right-click.
(package private)  int popUpIndex
           
private  int startDragIndex
           
(package private)  int width
           
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
JstringListBox()
          Default Constructor
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          For the pop up menu callback.
 void addItem(java.lang.Object o)
          Add an item to the list box.
 int compare(java.lang.Object a, java.lang.Object b)
          Default comparator, does a string comparison on the toString() output of the objects for ordering.
 boolean containsItem(java.lang.Object o)
          Returns true if the item is in the list
 boolean containsLabel(java.lang.String string)
          Returns true if the list contains an object with the specified label.
 boolean containsString(java.lang.String string)
          Returns true if the list contains an object with the specified label.
 java.util.Vector getHandles()
          Returns all handles
 arlut.csd.JDataComponent.listHandle getSelectedHandle()
          This returns the whole listHandle.
 java.util.Vector getSelectedHandles()
          Returns all the selected handles.
 java.lang.Object getSelectedItem()
          This returns the object, without the label.
 java.lang.String getSelectedLabel()
          This returns just the label.
 int getSizeOfList()
           
 void insertHandleAt(arlut.csd.JDataComponent.listHandle handle, int row)
          Use this one to skip the sorting.
 void load(java.util.Vector items, int width, boolean sort, arlut.csd.Util.Compare comparator)
          This method loads a Vector of items into this list box.
 void mouseClicked(java.awt.event.MouseEvent e)
          For the MouseListener interface
 void mouseDragged(java.awt.event.MouseEvent e)
          For the MouseMotionListener interface
 void mouseEntered(java.awt.event.MouseEvent e)
          For the MouseListener interface
 void mouseExited(java.awt.event.MouseEvent e)
          For the MouseListener interface
 void mouseMoved(java.awt.event.MouseEvent e)
          For the MouseMotionListener interface
 void mousePressed(java.awt.event.MouseEvent e)
          For the mouseListener interface
 void mouseReleased(java.awt.event.MouseEvent e)
          For the MouseListener interface
 void moveItem(int sourceRow, int targetRow)
          This method moves an item around in the list.
 void registerPopupMenu(javax.swing.JPopupMenu popup)
          This method associates a node-linked popup menu to this listbox.
 void removeItem(java.lang.Object o)
          Remove an item from list.
 void removeLabel(java.lang.String s)
          Remove an object by label
 void setCallback(arlut.csd.JDataComponent.JsetValueCallback callback)
          Connects this JstringListBox to an implementaton of the JsetValueCallback interface in order to provide live notification of changes performed by the user.
 void setCellWidth(int width)
          This method sets the default cell width for this list.
 void setCellWidth(java.lang.String template)
          This method sets the default cell width for this list.
 void setDragEnabled(boolean dragOk)
          This method enables and disables item dragging in this list.
 void setSelected(java.lang.Object o)
          Sets the selected item.
 void setSelectedLabel(java.lang.String s)
          This selects the item with the given label.
 void setSelectedLabel(java.lang.String s, boolean ensureVisible)
          This selects the item with the given label.
 void setSize(int size)
          Convenience method to set the size on the model.
 void valueChanged(javax.swing.event.ListSelectionEvent e)
          For the ListSelectionListener
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setModel, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
 

Field Detail

debug

static final boolean debug
See Also:
Constant Field Values

width

int width

popUpIndex

int popUpIndex

model

javax.swing.DefaultListModel model

dragOk

private boolean dragOk

If true, this JstringListBox will allow nodes to be dragged up and down in the list.


doSort

private boolean doSort

If true, the JstringListBox will sort items. This variable is set by the value of the sort parameter in the most recent load() call.


callback

arlut.csd.JDataComponent.JsetValueCallback callback

The callback we'l use to report user activities.


popup

javax.swing.JPopupMenu popup

The popup menu to be displayed on right-click.


startDragIndex

private int startDragIndex

dragNode

private int dragNode

comparator

arlut.csd.Util.Compare comparator

The comparator to use for putting items in sort order if the JstringListBox was most recently with sorting request.


maxWidthString

java.lang.String maxWidthString

The default maximum width string

Constructor Detail

JstringListBox

public JstringListBox()
Default Constructor

Method Detail

registerPopupMenu

public void registerPopupMenu(javax.swing.JPopupMenu popup)

This method associates a node-linked popup menu to this listbox.


load

public void load(java.util.Vector items,
                 int width,
                 boolean sort,
                 arlut.csd.Util.Compare comparator)

This method loads a Vector of items into this list box. Elements of the items Vector may be Strings or listHandle objects.

If sort is true, the items will be sorted in display order before being loaded into this list box.

Any values previously in the list box will be removed.

Parameters:
items - A Vector of Strings or listHandles
width - If less than zero, the listbox's cell width will be left unchanged. If set to zero, the listbox's cell width will be calculated based on the longest string in the items Vector. If greater than zero, the cell width will be set to <width> columns wide.
sort - If true, the items Vector will be sorted in place before being set into the listbox.
comparator - Typically an instance of an inner class that implements the arlut.csd.Util.Compare interface, used to guide the sort process. If this is null, the sort will be performed using a normal string ordering sort.

setCellWidth

public void setCellWidth(int width)

This method sets the default cell width for this list.


setCellWidth

public void setCellWidth(java.lang.String template)

This method sets the default cell width for this list.


setDragEnabled

public void setDragEnabled(boolean dragOk)

This method enables and disables item dragging in this list.

Overrides:
setDragEnabled in class javax.swing.JList

setSize

public void setSize(int size)
Convenience method to set the size on the model.


setCallback

public void setCallback(arlut.csd.JDataComponent.JsetValueCallback callback)

Connects this JstringListBox 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.

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

See Also:
JsetValueCallback, JValueObject

addItem

public void addItem(java.lang.Object o)
Add an item to the list box.

Parameters:
o - Can be a String or listHandle.

moveItem

public void moveItem(int sourceRow,
                     int targetRow)

This method moves an item around in the list.


insertHandleAt

public void insertHandleAt(arlut.csd.JDataComponent.listHandle handle,
                           int row)
Use this one to skip the sorting. Called by all the add methods.


removeItem

public void removeItem(java.lang.Object o)
Remove an item from list.

Parameters:
o - can be listHandle or String

removeLabel

public void removeLabel(java.lang.String s)
Remove an object by label

Parameters:
s - Label of object to remove.

getSizeOfList

public int getSizeOfList()

containsLabel

public boolean containsLabel(java.lang.String string)
Returns true if the list contains an object with the specified label.


containsString

public boolean containsString(java.lang.String string)
Returns true if the list contains an object with the specified label. Since everything is a listHandle internally, this is the same as containsLabel


containsItem

public boolean containsItem(java.lang.Object o)
Returns true if the item is in the list

Parameters:
o - Can be a String(label) or listHandle

setSelectedLabel

public void setSelectedLabel(java.lang.String s)
This selects the item with the given label.


setSelectedLabel

public void setSelectedLabel(java.lang.String s,
                             boolean ensureVisible)
This selects the item with the given label.


setSelected

public void setSelected(java.lang.Object o)
Sets the selected item.

Parameters:
o - Can be listHandle or String

getSelectedLabel

public java.lang.String getSelectedLabel()
This returns just the label.


getSelectedHandle

public arlut.csd.JDataComponent.listHandle getSelectedHandle()
This returns the whole listHandle.


getSelectedHandles

public java.util.Vector getSelectedHandles()
Returns all the selected handles.


getHandles

public java.util.Vector getHandles()
Returns all handles


getSelectedItem

public java.lang.Object getSelectedItem()
This returns the object, without the label.


valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
For the ListSelectionListener

Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
For the MouseListener interface

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
For the MouseListener interface

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
For the MouseListener interface

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
For the mouseListener interface

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
For the MouseListener interface

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
For the MouseMotionListener interface

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
For the MouseMotionListener interface

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
For the pop up menu callback. We use the popUpIndex variable to identify the item in the list that the popup menu was issued on.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

compare

public int compare(java.lang.Object a,
                   java.lang.Object b)

Default comparator, does a string comparison on the toString() output of the objects for ordering.

Specified by:
compare in interface Compare