Mp3dings 
20100427

de.mospace.swing
Class ProcessIOPane

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 de.mospace.swing.IOPane
                      extended by de.mospace.swing.ProcessIOPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ProcessIOPane
extends IOPane

A JComponent that provides a command line system shell. System processes are started by entering commands in the input field of this IOPane. Error and output streams of the system processes thus started are redirected to the output area of this IOPane. The commands are executed one after the other unless they end with an '&' character. ProcessIOPanes have a command line history but otherwise dispose of only very limited built-in capabilities ('cd' and 'clear', process interruption with CTRL-C, no I/O redirection). Run your operating system shell (e.g. bash) inside the ProcessIOPane if you need a fully-featured shell.

Version:
$Revision: 12 $ ($Date: 2007-07-27 11:48:53 +0200 (Fr, 27 Jul 2007) $)
Author:
Moritz Ringler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.mospace.swing.IOPane
IOPane.History, IOPane.VectorHistory
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class de.mospace.swing.IOPane
echoAL, prependPrompt
 
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
ProcessIOPane(int rows, int cols)
          Creates a new ProcessIOPane.
 
Method Summary
protected  boolean builtin(String s)
          Checks whether s is a built-in command and if so executes it.
 void enqueue(ProcessRunnable command)
          Enqueues and executes the specified job as if it had been started from the input field of this ProcessIOPane.
 Action[] getControlActions()
          Returns the control actions for this ProcessIOPane.
 OutputStream getOutputStream()
          returns a new OutputStream that writes to the output area
protected  Preferences getPref()
           
 RunnableQueue getRunnableQueue()
          Returns the RunnableQueue in which this ProcessIOPane stores jobs awaiting execution.
 String getSystemShell()
           
 Action getSystemShellAction()
           
 String getWorkingDirectory()
           
static String guessSystemShell()
           
 void interrupt()
          Interrupts the currently running process and deletes all jobs awaiting execution.
 String querySystemShell()
           
 void runInCallerThread(ProcessRunnable command)
          Runs the specified job in the calling thread.
 void setSystemShell(String command)
           
 void setWorkingDirectory(String path)
          Sets the working directory of new processes started from this IOPane.
 
Methods inherited from class de.mospace.swing.IOPane
addActionListener, append, getActionListeners, getDocument, getHistory, getInput, getMaxLines, getOutputArea, getPrompt, getScrollPane, removeActionListener, setBackground, setMaxLines
 
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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessIOPane

public ProcessIOPane(int rows,
                     int cols)
Creates a new ProcessIOPane.

Parameters:
rows - number of text rows >= 0
cols - number of text columns >= 0 in a row
Throws:
IllegalArgumentException - if the rows or columns arguments are negative.
Method Detail

setSystemShell

public void setSystemShell(String command)

getSystemShell

public String getSystemShell()

querySystemShell

public String querySystemShell()

guessSystemShell

public static String guessSystemShell()

getControlActions

public Action[] getControlActions()
Returns the control actions for this ProcessIOPane. The first element in the returned array calls interrupt() in the body of its acionPerformed method. The second element removes all output from the output area of this IOPane.


getSystemShellAction

public Action getSystemShellAction()

getRunnableQueue

public RunnableQueue getRunnableQueue()
Returns the RunnableQueue in which this ProcessIOPane stores jobs awaiting execution. Jobs that you enqueue directly to the returned RunnableQueue will not have their output and error streams redirected to this IOPane by default.

Returns:
the RunnableQueue assiociated with this ProcessIOPane
See Also:
enqueue(de.mospace.lang.ProcessRunnable)

enqueue

public void enqueue(ProcessRunnable command)
Enqueues and executes the specified job as if it had been started from the input field of this ProcessIOPane. Jobs that you enqueue with this method will have their output and error streams redirected to and will get input from this IOPane. If command.getWorkingDirectory() == null the working directory of the command will be set to the working directory of this ProcessIOPane.

Parameters:
command - the job to enqueue and execute
See Also:
getRunnableQueue(), RunnableQueue.enqueue(de.mospace.lang.RunnableQueue.Job)

runInCallerThread

public void runInCallerThread(ProcessRunnable command)
Runs the specified job in the calling thread. Jobs that you run with this method will have their output and error streams redirected to this IOPane. They will not be able to accept input from this IOPane.


setWorkingDirectory

public void setWorkingDirectory(String path)
Sets the working directory of new processes started from this IOPane. The working directory can be set interactively by using the 'cd' built-in.


getWorkingDirectory

public String getWorkingDirectory()

getOutputStream

public OutputStream getOutputStream()
returns a new OutputStream that writes to the output area


builtin

protected boolean builtin(String s)
Checks whether s is a built-in command and if so executes it.


getPref

protected Preferences getPref()

interrupt

public void interrupt()
Interrupts the currently running process and deletes all jobs awaiting execution.


Mp3dings 
20100427