org.jpop.gui
Class ProcessConsole

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.jpop.gui.ProcessConsole
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
JeditPoplog, PoplogProcessConsole

public abstract class ProcessConsole
extends javax.swing.JPanel

Displays a process's (by default bash) out, err and in streams in different text areas. The input is a normal JTextArea, and out and err are displayed using OutputTextPanes

Version:
1.0
Author:
dsm
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int STDERR
          Indicates the respective tab to be selected
static int STDOUT
          Indicates the respective tab to be selected
 
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
ProcessConsole()
          Constructor for BufferConsole
 
Method Summary
 void addTool(java.awt.Component c)
          Adds a tool to the ProcessConsole object
 void appendToStderr(java.lang.String s)
          Appends a string to the stderr text area
 void appendToStdin(java.lang.String s)
          Appends a string to the stdin text area
 void appendToStdout(java.lang.String s)
          Appends a string to the stdout text area
 void close()
          Closes the object
abstract  void debug(java.lang.String msg)
          Adds debugging capabilities to this object
 void execBufferedReader(java.io.BufferedReader br)
          Executes input from a buffered reader
 void execFile(java.io.File f)
          Sends the contents of File f to the running process
 java.awt.Dimension getInputPanelSize()
          Gets the input panel size attribute of the ProcessConsole object
 java.awt.Dimension getInputPanePreferredSize()
          Gets the input pane preferred size attribute of the ProcessConsole object
 IOControl getIOControl()
          Gets the IO control attribute of the ProcessConsole object
 java.awt.Dimension getOutputTabsPreferredSize()
          Gets the output tabs preferred size attribute of the ProcessConsole object
 java.awt.Dimension getOutputTabsSize()
          Gets the input panel size attribute of the ProcessConsole object
 java.io.PrintStream getPrinter()
          Gets the printer attribute of the ProcessConsole object
 java.lang.String getProcessName()
          Gets the process name attribute of the ProcessConsole object
 java.awt.Color getStderrColor()
          Gets the stderr color attribute of the ProcessConsole object
 java.lang.String getStderrText()
          Gets the stderr text attribute of the ProcessConsole object
 java.awt.Color getStdinColor()
          Gets the stdin color attribute of the ProcessConsole object
 java.lang.String getStdinText()
          Gets the stdin text attribute of the ProcessConsole object
 java.awt.Color getStdoutColor()
          Gets the stdout color attribute of the ProcessConsole object
 java.lang.String getStdoutText()
          Gets the stdout text attribute of the ProcessConsole object
 boolean isRespawnable()
          Gets the respawnable attribute of the ProcessConsole object
 boolean isRunning()
          Gets the running attribute of the ProcessConsole object
 boolean isVerticalSplit()
          Gets the vertical split attribute of the ProcessConsole object
 void kill()
          Kills the process regardless of its respawnable flag.
static void main(java.lang.String[] args)
          The main program for the ProcessConsole class.
protected  void makeOutputPanes()
          Makes and sets the output tabs.
abstract  void processKilled()
          This happens when the process stops running for whatever reason.
abstract  void processStarted()
          This happens when the process starts running for whatever reason.
 void removeTool(java.awt.Component c)
          removes a tool from the ProcessConsole object
 void respawn()
          Restarts the process regardless of whether the process is respawnable or not.
 void setInputPanePreferredSize(java.awt.Dimension d)
          Sets the input pane preferred size attribute of the ProcessConsole object
 void setOutputTabsPreferredSize(java.awt.Dimension d)
          Sets the output tabs preferred size attribute of the ProcessConsole object
 void setProcessName(java.lang.String processName)
          Sets the process name attribute of the ProcessConsole object
 void setRespawnable(boolean respawnable)
          Sets the respawnable attribute of the ProcessConsole object.
 void setSelectedTab(int tab)
          sets the selected tab in the tabbed pane
 void setStderrColor(java.awt.Color stderrColor)
          Sets the stderr color attribute of the ProcessConsole object.
 void setStderrReader(java.io.BufferedReader br)
          Sets the stderr reader value of the ProcessConsole object
 void setStderrText(java.lang.String s)
          Sets the stderr text attribute of the ProcessConsole object
 void setStdinColor(java.awt.Color stdinColor)
          Sets the stdin color attribute of the ProcessConsole object.
 void setStdinText(java.lang.String s)
          Sets the stdin text attribute of the ProcessConsole object
 void setStdoutColor(java.awt.Color stdoutColor)
          Sets the stdout color attribute of the ProcessConsole object.
 void setStdoutReader(java.io.BufferedReader br)
          Sets the stdout reader value of the ProcessConsole object
 void setStdoutText(java.lang.String s)
          Sets the stdout text attribute of the ProcessConsole object
 void setVerticalSplit(boolean verticalSplit)
          Sets the vertical split attribute of the ProcessConsole object
 void spawn()
          Spawns the native process
 void stderrPaneRequestFocus()
          calls requestFocus()
abstract  void stderrTextChanged()
          this method is called when the text in stderr is changed by a method, like appendToStderr() or setStderrText().
 void stdinPaneRequestFocus()
          calls requestFocus()
abstract  void stdinTextChanged()
          this method is called when the text in stdin is changed by a method, like appendToStdin() or setStdinText().
 void stdoutPaneRequestFocus()
          calls requestFocus()
abstract  void stdoutTextChanged()
          this method is called when the text in stdout is changed by a method, like appendToStdout() or setStdoutText().
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, 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

STDOUT

public static final int STDOUT
Indicates the respective tab to be selected

See Also:
Constant Field Values

STDERR

public static final int STDERR
Indicates the respective tab to be selected

See Also:
Constant Field Values
Constructor Detail

ProcessConsole

public ProcessConsole()
Constructor for BufferConsole

Method Detail

main

public static void main(java.lang.String[] args)
The main program for the ProcessConsole class. Just for testing.

Parameters:
args - The command line arguments

kill

public final void kill()
Kills the process regardless of its respawnable flag.


respawn

public final void respawn()
Restarts the process regardless of whether the process is respawnable or not. A shorthand for "kill(); spawn();"


spawn

public final void spawn()
Spawns the native process


setInputPanePreferredSize

public void setInputPanePreferredSize(java.awt.Dimension d)
Sets the input pane preferred size attribute of the ProcessConsole object

Parameters:
d - The new inputPanePreferredSize value

setOutputTabsPreferredSize

public void setOutputTabsPreferredSize(java.awt.Dimension d)
Sets the output tabs preferred size attribute of the ProcessConsole object

Parameters:
d - The new outputTabsPreferredSize value

setProcessName

public void setProcessName(java.lang.String processName)
Sets the process name attribute of the ProcessConsole object

Parameters:
processName - The new processName value

setRespawnable

public void setRespawnable(boolean respawnable)
Sets the respawnable attribute of the ProcessConsole object. When the process dies, if this flag is true, the process respawns instead, otherwise nothing happens. By default true.

Parameters:
respawnable - The new respawnable value

setSelectedTab

public void setSelectedTab(int tab)
sets the selected tab in the tabbed pane

Parameters:
tab - the index of the tab to select (one of STDOUT or STDERR)

setStderrColor

public void setStderrColor(java.awt.Color stderrColor)
Sets the stderr color attribute of the ProcessConsole object. By default red

Parameters:
stderrColor - The new stderrColor value

setStderrReader

public void setStderrReader(java.io.BufferedReader br)
Sets the stderr reader value of the ProcessConsole object

Parameters:
br - The new stderrReader value

setStderrText

public void setStderrText(java.lang.String s)
Sets the stderr text attribute of the ProcessConsole object

Parameters:
s - The new stderrText value

setStdinColor

public void setStdinColor(java.awt.Color stdinColor)
Sets the stdin color attribute of the ProcessConsole object. By default blue

Parameters:
stdinColor - The new stdinColor value

setStdinText

public void setStdinText(java.lang.String s)
Sets the stdin text attribute of the ProcessConsole object

Parameters:
s - The new stdinText value

setStdoutColor

public void setStdoutColor(java.awt.Color stdoutColor)
Sets the stdout color attribute of the ProcessConsole object. By default black

Parameters:
stdoutColor - The new stdoutColor value

setStdoutReader

public void setStdoutReader(java.io.BufferedReader br)
Sets the stdout reader value of the ProcessConsole object

Parameters:
br - The new stdoutReader value

setStdoutText

public void setStdoutText(java.lang.String s)
Sets the stdout text attribute of the ProcessConsole object

Parameters:
s - The new stdoutText value

setVerticalSplit

public void setVerticalSplit(boolean verticalSplit)
Sets the vertical split attribute of the ProcessConsole object

Parameters:
verticalSplit - The new verticalSplit value

getIOControl

public IOControl getIOControl()
Gets the IO control attribute of the ProcessConsole object

Returns:
The iOControl value

getInputPanePreferredSize

public java.awt.Dimension getInputPanePreferredSize()
Gets the input pane preferred size attribute of the ProcessConsole object

Returns:
The inputPanePreferredSize value

getInputPanelSize

public java.awt.Dimension getInputPanelSize()
Gets the input panel size attribute of the ProcessConsole object

Returns:
The inputPanelSize value

getOutputTabsPreferredSize

public java.awt.Dimension getOutputTabsPreferredSize()
Gets the output tabs preferred size attribute of the ProcessConsole object

Returns:
The outputTabsPreferredSize value

getOutputTabsSize

public java.awt.Dimension getOutputTabsSize()
Gets the input panel size attribute of the ProcessConsole object

Returns:
The outputTabsSize value

getPrinter

public java.io.PrintStream getPrinter()
Gets the printer attribute of the ProcessConsole object

Returns:
The printer value

getProcessName

public java.lang.String getProcessName()
Gets the process name attribute of the ProcessConsole object

Returns:
The processName value

getStderrColor

public java.awt.Color getStderrColor()
Gets the stderr color attribute of the ProcessConsole object

Returns:
The stderrColor value

getStderrText

public java.lang.String getStderrText()
Gets the stderr text attribute of the ProcessConsole object

Returns:
The stderrText value

getStdinColor

public java.awt.Color getStdinColor()
Gets the stdin color attribute of the ProcessConsole object

Returns:
The stdinColor value

getStdinText

public java.lang.String getStdinText()
Gets the stdin text attribute of the ProcessConsole object

Returns:
The stdinText value

getStdoutColor

public java.awt.Color getStdoutColor()
Gets the stdout color attribute of the ProcessConsole object

Returns:
The stdoutColor value

getStdoutText

public java.lang.String getStdoutText()
Gets the stdout text attribute of the ProcessConsole object

Returns:
The stdoutText value

isRespawnable

public boolean isRespawnable()
Gets the respawnable attribute of the ProcessConsole object

Returns:
The respawnable value

isRunning

public boolean isRunning()
Gets the running attribute of the ProcessConsole object

Returns:
The running value

isVerticalSplit

public boolean isVerticalSplit()
Gets the vertical split attribute of the ProcessConsole object

Returns:
The verticalSplit value

addTool

public void addTool(java.awt.Component c)
Adds a tool to the ProcessConsole object

Parameters:
c - The feature to be added to the toolBar

appendToStderr

public void appendToStderr(java.lang.String s)
Appends a string to the stderr text area

Parameters:
s - The String to append

appendToStdin

public void appendToStdin(java.lang.String s)
Appends a string to the stdin text area

Parameters:
s - The String to append

appendToStdout

public void appendToStdout(java.lang.String s)
Appends a string to the stdout text area

Parameters:
s - The String to append

close

public void close()
           throws java.io.IOException
Closes the object

Throws:
java.io.IOException - When the process can't be destroyed

debug

public abstract void debug(java.lang.String msg)
Adds debugging capabilities to this object

Parameters:
msg - The message

execBufferedReader

public void execBufferedReader(java.io.BufferedReader br)
                        throws java.io.IOException
Executes input from a buffered reader

Parameters:
br -
Throws:
java.io.IOException

execFile

public void execFile(java.io.File f)
Sends the contents of File f to the running process

Parameters:
f - The file to read and send to the process

processKilled

public abstract void processKilled()
This happens when the process stops running for whatever reason. This method can be changed by any subclass to be treated as an event handler.


processStarted

public abstract void processStarted()
This happens when the process starts running for whatever reason. This method can be changed by any subclass to be treated as an event handler.


removeTool

public void removeTool(java.awt.Component c)
removes a tool from the ProcessConsole object

Parameters:
c - The feature to be removed from the toolBar

stderrPaneRequestFocus

public void stderrPaneRequestFocus()
calls requestFocus()


stderrTextChanged

public abstract void stderrTextChanged()
this method is called when the text in stderr is changed by a method, like appendToStderr() or setStderrText(). Override to use as an event


stdinPaneRequestFocus

public void stdinPaneRequestFocus()
calls requestFocus()


stdinTextChanged

public abstract void stdinTextChanged()
this method is called when the text in stdin is changed by a method, like appendToStdin() or setStdinText(). Override to use as an event


stdoutPaneRequestFocus

public void stdoutPaneRequestFocus()
calls requestFocus()


stdoutTextChanged

public abstract void stdoutTextChanged()
this method is called when the text in stdout is changed by a method, like appendToStdout() or setStdoutText(). Override to use as an event


makeOutputPanes

protected void makeOutputPanes()
Makes and sets the output tabs. If this is not done the input pane is put on the center and the tabs never appear