com.bluemarsh.jswat.ui
Class GraphicalCommandAdapter

java.lang.Object
  |
  +--com.bluemarsh.jswat.ui.GraphicalCommandAdapter
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.KeyListener

public class GraphicalCommandAdapter
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.KeyListener

Class GraphicalCommandAdapter adapts the input from a text field and sends that input to the CommandManager.

Author:
Nathan Fiedler

Field Summary
protected  CommandManager commandManager
          Where input is sent.
protected  java.lang.String inputBeforeScroll
          The text in the command input field when the user started scrolling through the command history.
protected  javax.swing.JTextField inputField
          Where input comes from.
protected  javax.swing.JLabel inputPrompt
          Prompt label beside the input field.
protected  Log outputLog
          Log to which we print the typed commands for reference.
 
Constructor Summary
GraphicalCommandAdapter(javax.swing.JTextField input, javax.swing.JLabel prompt, CommandManager cmdman, Log log)
          Constructs a GraphicalCommandAdapter that connects the given input field to the given command manager.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Text field was activated by user.
 void keyPressed(java.awt.event.KeyEvent event)
          Invoked when a key has been pressed in the input field.
 void keyReleased(java.awt.event.KeyEvent event)
          Ignored.
 void keyTyped(java.awt.event.KeyEvent event)
          Ignored.
protected  void updatePrompt()
          Change the prompt displayed beside the input field, if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandManager

protected CommandManager commandManager
Where input is sent.

inputField

protected javax.swing.JTextField inputField
Where input comes from.

inputPrompt

protected javax.swing.JLabel inputPrompt
Prompt label beside the input field.

inputBeforeScroll

protected java.lang.String inputBeforeScroll
The text in the command input field when the user started scrolling through the command history. Used to restore the original command input.

outputLog

protected Log outputLog
Log to which we print the typed commands for reference.
Constructor Detail

GraphicalCommandAdapter

public GraphicalCommandAdapter(javax.swing.JTextField input,
                               javax.swing.JLabel prompt,
                               CommandManager cmdman,
                               Log log)
Constructs a GraphicalCommandAdapter that connects the given input field to the given command manager.
Parameters:
input - input field.
cmdman - CommandManager to send input to.
log - Log to print to.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Text field was activated by user. Parse the input and execute the command. Also clears the input field and resets the "current history" value.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - ActionEvent

updatePrompt

protected void updatePrompt()
Change the prompt displayed beside the input field, if necessary.

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Invoked when a key has been pressed in the input field. We take this opportunity to implement the "previous" and "next" command feature.
Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
event - Key event.

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
Ignored.
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
Ignored.
Specified by:
keyTyped in interface java.awt.event.KeyListener