org.rosuda.JGR
Class JGRConsole

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by org.rosuda.ibase.toolkit.TJFrame
                          extended by org.rosuda.JGR.JGRConsole
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, FrameDevice, RMainLoopCallbacks
Direct Known Subclasses:
JGRConsolePlaceholder

public class JGRConsole
extends TJFrame
implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.FocusListener, RMainLoopCallbacks

JGRConsole Console Frame, the main window of JGR.

Author:
Markus Helbig RoSuDa 2003 - 2005
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 int currentHistPosition
           
 int end
          Position where the R splash ends (need for clearing the console
static java.lang.String guiEnv
           
 SyntaxInput input
          Console command input area
 javax.swing.text.Document inputDoc
           
static java.lang.String lastRPrompt
           
static int MENUMODIFIER
           
 ConsoleOutput output
          Console output text panel
 javax.swing.text.Document outputDoc
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.rosuda.ibase.toolkit.FrameDevice
clsAbout, clsBar, clsBox, clsCustom, clsDevPlot, clsEditor, clsFD, clsHelp, clsHist, clsJavaGD, clsLine, clsMain, clsMap, clsMCP, clsObjBrowser, clsPackageUtil, clsPCP, clsPlot, clsPrefs, clsScatter, clsSplash, clsTable, clsTree, clsTreeMap, clsUser, clsVars
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JGRConsole()
           
JGRConsole(java.io.File workSpace)
          Create a new Console window.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          actionPerformed: handle action event: menus.
 void clearconsole()
          Clear the console's content, if it's too full.
 void dispose()
          Close Console, but not before we asked the user if he wants to save opened Editors.
 void execute(java.lang.String cmd)
          Execute a coomand and add it to history
 void execute(java.lang.String cmd, boolean addToHist)
          Execute a command and add it into history.
 void exit()
          Close Console, but not before we asked the user if he wants to save opened Editors.
 void focusGained(java.awt.event.FocusEvent e)
          focusGained: handle focus event, enable and disable cut and paste button.
 void focusLost(java.awt.event.FocusEvent e)
          focusLost: handle focus event.
 int getFontWidth()
          Get the font's width form current settings using FontMetrics.
 java.io.PrintStream getStdErrPrintStream()
           
 java.io.PrintStream getStdOutPrintStream()
           
 java.lang.String getUniqueName(java.lang.String var)
          Gets a unique name based on a starting string
 java.lang.String getUniqueName(java.lang.String var, java.lang.String envName)
          Gets a unique name based on a starting string
 void keyPressed(java.awt.event.KeyEvent ke)
          keyPressed: handle key event, like: adding a new line, history ....
 void keyReleased(java.awt.event.KeyEvent ke)
          keyReleased: handle key event, sending the command.
 void keyTyped(java.awt.event.KeyEvent ke)
          keyTyped: handle key event.
 void loadWorkSpace()
          Load a workspace, R-command: load(...).
 void rBusy(Rengine re, int which)
          Invoke the busy cursor (R callback).
 java.lang.String rChooseFile(Rengine re, int newFile)
          Choose a file invoked be file.choose() (R callback).
 void rFlushConsole(Rengine re)
          Flush the console (R callback). !!
 void rLoadHistory(Rengine re, java.lang.String filename)
          Load history from a file (R callback).
 java.lang.String rReadConsole(Rengine re, java.lang.String prompt, int addToHistory)
          Read the commands from input area (R callback).
 void rSaveHistory(Rengine re, java.lang.String filename)
          Save history to a file (R callback).
 void rShowMessage(Rengine re, java.lang.String message)
          Showing a message from the rengine (R callback).
 void rWriteConsole(Rengine re, java.lang.String text)
          Write output from R into console (old R callback).
 void rWriteConsole(Rengine re, java.lang.String text, int oType)
          Write output from R into console (new R callback).
 void saveWorkSpace(java.lang.String file)
          Save workspace with specified filename, R-command: save.image(...).
 void saveWorkSpaceAs()
          Save workspace to a different file then .RData.
 
Methods inherited from class org.rosuda.ibase.toolkit.TJFrame
add, finalize, getFrame, initPlacement, setWorking
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.rosuda.ibase.toolkit.FrameDevice
addWindowListener, pack, setSize, setVisible
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

output

public ConsoleOutput output
Console output text panel


input

public SyntaxInput input
Console command input area


inputDoc

public javax.swing.text.Document inputDoc

outputDoc

public javax.swing.text.Document outputDoc

MENUMODIFIER

public static final int MENUMODIFIER

currentHistPosition

public int currentHistPosition

end

public int end
Position where the R splash ends (need for clearing the console


guiEnv

public static java.lang.String guiEnv

lastRPrompt

public static java.lang.String lastRPrompt
Constructor Detail

JGRConsole

public JGRConsole()

JGRConsole

public JGRConsole(java.io.File workSpace)
Create a new Console window.

Parameters:
workSpace - workspace which should be loaded when starting JGR
Method Detail

exit

public void exit()
Close Console, but not before we asked the user if he wants to save opened Editors.


dispose

public void dispose()
Close Console, but not before we asked the user if he wants to save opened Editors.

Overrides:
dispose in class TJFrame

execute

public void execute(java.lang.String cmd)
Execute a coomand and add it to history

Parameters:
cmd - command for execution

execute

public void execute(java.lang.String cmd,
                    boolean addToHist)
Execute a command and add it into history.

Parameters:
cmd - command for execution
addToHist - indicates wether the command should be added to history or not

getUniqueName

public java.lang.String getUniqueName(java.lang.String var)
Gets a unique name based on a starting string

Parameters:
var -
Returns:
the value of var concatinated with a number

getUniqueName

public java.lang.String getUniqueName(java.lang.String var,
                                      java.lang.String envName)
Gets a unique name based on a starting string

Parameters:
var -
envName - The name of the enviroment in which to look
Returns:
the value of var concatinated with a number

clearconsole

public void clearconsole()
Clear the console's content, if it's too full.


loadWorkSpace

public void loadWorkSpace()
Load a workspace, R-command: load(...).


saveWorkSpace

public void saveWorkSpace(java.lang.String file)
Save workspace with specified filename, R-command: save.image(...).

Parameters:
file - filename

saveWorkSpaceAs

public void saveWorkSpaceAs()
Save workspace to a different file then .RData.


getFontWidth

public int getFontWidth()
Get the font's width form current settings using FontMetrics.

Returns:
fontwidth

rWriteConsole

public void rWriteConsole(Rengine re,
                          java.lang.String text,
                          int oType)
Write output from R into console (new R callback).

Specified by:
rWriteConsole in interface RMainLoopCallbacks
Parameters:
re - used Rengine
text - output
oType - output type (0=regular, 1=warning/error)

rWriteConsole

public void rWriteConsole(Rengine re,
                          java.lang.String text)
Write output from R into console (old R callback).

Parameters:
re - used Rengine
text - output

rBusy

public void rBusy(Rengine re,
                  int which)
Invoke the busy cursor (R callback).

Specified by:
rBusy in interface RMainLoopCallbacks
Parameters:
re - used Rengine
which - busy (1) or not (0)

rReadConsole

public java.lang.String rReadConsole(Rengine re,
                                     java.lang.String prompt,
                                     int addToHistory)
Read the commands from input area (R callback).

Specified by:
rReadConsole in interface RMainLoopCallbacks
Parameters:
re - used Rengine
prompt - prompt from R
addToHistory - is it an command which to add to the history
Returns:
user's input to be passed to R for evaluation

rShowMessage

public void rShowMessage(Rengine re,
                         java.lang.String message)
Showing a message from the rengine (R callback).

Specified by:
rShowMessage in interface RMainLoopCallbacks
Parameters:
re - used Rengine
message - message from R

rChooseFile

public java.lang.String rChooseFile(Rengine re,
                                    int newFile)
Choose a file invoked be file.choose() (R callback).

Specified by:
rChooseFile in interface RMainLoopCallbacks
Parameters:
re - used Rengine
newFile - if it's a new file
Returns:
path/name of the selected file

rFlushConsole

public void rFlushConsole(Rengine re)
Flush the console (R callback). !! not implemented yet !!

Specified by:
rFlushConsole in interface RMainLoopCallbacks
Parameters:
re - used Rengine

rLoadHistory

public void rLoadHistory(Rengine re,
                         java.lang.String filename)
Load history from a file (R callback).

Specified by:
rLoadHistory in interface RMainLoopCallbacks
Parameters:
re - used Rengine
filename - history file

rSaveHistory

public void rSaveHistory(Rengine re,
                         java.lang.String filename)
Save history to a file (R callback).

Specified by:
rSaveHistory in interface RMainLoopCallbacks
Parameters:
re - used Rengine
filename - history file

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed: handle action event: menus.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
keyTyped: handle key event.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
keyPressed: handle key event, like: adding a new line, history ....

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
keyReleased: handle key event, sending the command.

Specified by:
keyReleased in interface java.awt.event.KeyListener

focusGained

public void focusGained(java.awt.event.FocusEvent e)
focusGained: handle focus event, enable and disable cut and paste button.

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
focusLost: handle focus event.

Specified by:
focusLost in interface java.awt.event.FocusListener

getStdOutPrintStream

public java.io.PrintStream getStdOutPrintStream()

getStdErrPrintStream

public java.io.PrintStream getStdErrPrintStream()