org.activemath.util
Class Console

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.TextComponent
          extended by java.awt.TextArea
              extended by org.activemath.util.Console
All Implemented Interfaces:
TextListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible
Direct Known Subclasses:
StreamedConsole

public class Console
extends TextArea
implements TextListener

This class is a TextArea which behaves like a Unix-Shell. If the User entered a Command (this means has typed ENTER) an ActionEvent is thrown an the method getActionCommand() of ActionEvent returns a String Representation of the user-input. After a command was entered the Console is disabled for input until setResult() is called.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.TextArea
TextArea.AccessibleAWTTextArea
 
Nested classes/interfaces inherited from class java.awt.TextComponent
TextComponent.AccessibleAWTTextComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  int commandPromptPosition
           
 int lastKeyPressed
           
protected static String prompt
           
protected  int resultPosition
           
protected  int toAddAtNextTextValueChanged
           
 
Fields inherited from class java.awt.TextArea
SCROLLBARS_BOTH, SCROLLBARS_HORIZONTAL_ONLY, SCROLLBARS_NONE, SCROLLBARS_VERTICAL_ONLY
 
Fields inherited from class java.awt.TextComponent
textListener
 
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
Console(int rows, int lines)
          The Constructor.
 
Method Summary
 String cursoredCommand()
           
 void destroy()
           
 String executeCommand(String command)
           
 void executeControlD(KeyEvent e)
           
 String fireCommand(String command)
           
 String getCommand()
           
 String getPreviousCommand()
           
 String getUnpreviousCommand()
           
 void init()
           
 void insertCommand(String command)
           
 void loadLeftHereCommand()
           
static void main(String[] args)
           
 void processKeyEvent(KeyEvent e)
           
 void resetCommand()
           
 void setCommand(String command)
           
 void setResult(String result)
          With this Method you can set the result for an entered command.
 void textValueChanged(TextEvent evt)
          This method is invoked after the text value has changed.
 
Methods inherited from class java.awt.TextArea
addNotify, append, appendText, getAccessibleContext, getColumns, getMinimumSize, getMinimumSize, getPreferredSize, getPreferredSize, getRows, getScrollbarVisibility, insert, insertText, minimumSize, minimumSize, paramString, preferredSize, preferredSize, replaceRange, replaceText, setColumns, setRows
 
Methods inherited from class java.awt.TextComponent
addTextListener, enableInputMethods, getBackground, getCaretPosition, getInputMethodRequests, getListeners, getSelectedText, getSelectionEnd, getSelectionStart, getText, getTextListeners, isEditable, processEvent, processTextEvent, removeNotify, removeTextListener, select, selectAll, setBackground, setCaretPosition, setEditable, setSelectionEnd, setSelectionStart, setText
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

prompt

protected static final String prompt
See Also:
Constant Field Values

commandPromptPosition

protected int commandPromptPosition

resultPosition

protected int resultPosition

toAddAtNextTextValueChanged

protected int toAddAtNextTextValueChanged

lastKeyPressed

public int lastKeyPressed
Constructor Detail

Console

public Console(int rows,
               int lines)
The Constructor. Creates a new Console with the specified number of rows and lines.

Method Detail

init

public void init()

processKeyEvent

public void processKeyEvent(KeyEvent e)
Overrides:
processKeyEvent in class Component

textValueChanged

public void textValueChanged(TextEvent evt)
This method is invoked after the text value has changed. a test it then performed if the last character is indeed the end of line if yes, the command is sent.

Specified by:
textValueChanged in interface TextListener

setResult

public void setResult(String result)
With this Method you can set the result for an entered command. It will always occur just beneath the entered command.


setCommand

public void setCommand(String command)

getCommand

public String getCommand()

executeControlD

public void executeControlD(KeyEvent e)

fireCommand

public String fireCommand(String command)

executeCommand

public String executeCommand(String command)

destroy

public void destroy()

getPreviousCommand

public String getPreviousCommand()

getUnpreviousCommand

public String getUnpreviousCommand()

insertCommand

public void insertCommand(String command)

cursoredCommand

public String cursoredCommand()

loadLeftHereCommand

public void loadLeftHereCommand()

resetCommand

public void resetCommand()

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception