com.raelity.jvi.swing
Class CommandLine

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.raelity.jvi.swing.CommandLine
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class CommandLine
extends JPanel

This class presents a editable combo box UI for picking up command entry data. A mode, usually a single character like "?" or ":", can be set for display. This UI supports the maintenance of a history of commands. This component builds a keymap through which the action events are delivered. When an event is delivered, the history list is updated. The command line has a label that can be set with setMode(java.lang.String).

Take steps to prevent this component from taking focus throught the focus manager. But ultimately need to subclass the editor component to handle it.

See Also:
Serialized Form

Nested Class Summary
static class CommandLine.CommandLineEntry
          The CommandLine JPanel may be embedded in a Dialog or put on a glass pane; CommandLineEntry is some common handling particularly for the ViCmdEntry interface.
static class CommandLine.FilteredKeymap
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int DEFAULT_HISTORY_SIZE
           
static KeyStroke EXECUTE_KEY
           
 
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.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
CommandLine()
           
 
Method Summary
 void addActionListener(ActionListener l)
          Adds the specified action listener to receive action events from this textfield.
 void append(char c)
          This is used to append characters to the the combo box.
 void clear()
          This is used when the combo box is going to be displayed.
protected  Action createSimpleEvent(String name)
           
protected  void fireActionPerformed(ActionEvent e)
          Take the argument event and create an action event copy with this as its source.
protected  Action[] getActions()
           
protected  JTextComponent.KeyBinding[] getBindings()
           
 String getCommand()
          Retrieve the contents of the command line.
 int getHistorySize()
          the max size of the history list
 List getList()
          retrieve the history list.
 String getMode()
           
 void init(String s)
          This is used to initialize the text of the combo box, needed so that characters entered before the combo box gets focus are not lost.
 void removeActionListener(ActionListener l)
          Removes the specified action listener so that it no longer receives action events from this textfield.
 void setHistorySize(int newHistorySize)
          Use this to limit the size of the history list
 void setList(List<String> newList)
          This installs the history list.
 void setMode(String newMode)
          This sets the mode of the command line, e.g.
 void setupBorder()
           
 void takeFocus(boolean flag)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, 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, addImpl, 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, 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, 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, imageUpdate, 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
 

Field Detail

DEFAULT_HISTORY_SIZE

public static final int DEFAULT_HISTORY_SIZE
See Also:
Constant Field Values

EXECUTE_KEY

public static final KeyStroke EXECUTE_KEY
Constructor Detail

CommandLine

public CommandLine()
Method Detail

init

public void init(String s)
This is used to initialize the text of the combo box, needed so that characters entered before the combo box gets focus are not lost.


append

public void append(char c)
This is used to append characters to the the combo box. It is needed so that characters entered before the combo box gets focus are not lost. If there is a selection, then clear the selection. Do this because typically typed chararacters replace the selection.


setupBorder

public void setupBorder()

clear

public void clear()
This is used when the combo box is going to be displayed. A blank line is put at the head of the list. This blank is automatically removed when the user completes the action.


takeFocus

public void takeFocus(boolean flag)

getCommand

public String getCommand()
Retrieve the contents of the command line. This is typically done in response to a action event.


setMode

public void setMode(String newMode)
This sets the mode of the command line, e.g. ":" or "?".


getMode

public String getMode()

setList

public void setList(List<String> newList)
This installs the history list. This allows multiple history lists to share the same component.


getList

public List getList()
retrieve the history list.


setHistorySize

public void setHistorySize(int newHistorySize)
Use this to limit the size of the history list


getHistorySize

public int getHistorySize()
the max size of the history list


createSimpleEvent

protected Action createSimpleEvent(String name)

getBindings

protected JTextComponent.KeyBinding[] getBindings()

getActions

protected Action[] getActions()

fireActionPerformed

protected void fireActionPerformed(ActionEvent e)
Take the argument event and create an action event copy with this as its source. Then deliver it as needed. Do some maintenance on the LRU history.


addActionListener

public void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this textfield.

Parameters:
l - the action listener

removeActionListener

public void removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this textfield.

Parameters:
l - the action listener