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.JGR.toolkit.iFrame
                          extended by org.rosuda.JGR.JGRConsole
All Implemented Interfaces:
ActionListener, FocusListener, KeyListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, RMainLoopCallbacks

public class JGRConsole
extends iFrame
implements ActionListener, KeyListener, 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
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 int end
          Position where the R splash ends (need for clearing the console
 SyntaxInput input
          Console command input area
 ConsoleOutput output
          Console output text panel
 
Fields inherited from class org.rosuda.JGR.toolkit.iFrame
clsAbout, clsEditor, clsHelp, clsJavaGD, clsMain, clsObjBrowser, clsPackageUtil, clsPlot, clsPrefs, clsSplash, clsTable, clsUser, MYEntry
 
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 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(File workSpace)
          Create a new Console window.
 
Method Summary
 void actionPerformed(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(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(FocusEvent e)
          focusGained: handle focus event, enable and disable cut and paste button.
 void focusLost(FocusEvent e)
          focusLost: handle focus event.
 int getFontWidth()
          Get the font's width form current settings using FontMetrics.
 void help(String help)
          Start the help-browser, first parse for the keyword.
 boolean isHelpCMD(String cmd)
          Parse command if it is a helpcommand.
 void keyPressed(KeyEvent ke)
          keyPressed: handle key event, like: adding a new line, history ....
 void keyReleased(KeyEvent ke)
          keyReleased: handle key event, sending the command.
 void keyTyped(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).
 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, String filename)
          Load history from a file (R callback).
 String rReadConsole(Rengine re, String prompt, int addToHistory)
          Read the commands from input area (R callback).
 void rSaveHistory(Rengine re, String filename)
          Save history to a file (R callback).
 void rShowMessage(Rengine re, String message)
          Showing a message from the rengine (R callback).
 void rWriteConsole(Rengine re, String text)
          Write output from R into console (R callback).
 void saveWorkSpace(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.JGR.toolkit.iFrame
cursorDefault, cursorWait, finalize, getMYEntry, initPlacement, setMinimumSize, setWorking, show
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, 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, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, 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, paint, 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, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, setSize, setSize, setVisible, 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 java.awt.MenuContainer
getFont, postEvent
 

Field Detail

output

public ConsoleOutput output
Console output text panel


input

public SyntaxInput input
Console command input area


end

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

Constructor Detail

JGRConsole

public JGRConsole()

JGRConsole

public JGRConsole(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 Window

execute

public void execute(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

isHelpCMD

public boolean isHelpCMD(String cmd)
Parse command if it is a helpcommand.

Parameters:
cmd - command which should be executed
Returns:
true if help should be started, false if not

help

public void help(String help)
Start the help-browser, first parse for the keyword.

Parameters:
help - help-command

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(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,
                          String text)
Write output from R into console (R callback).

Specified by:
rWriteConsole in interface RMainLoopCallbacks
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 String rReadConsole(Rengine re,
                           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,
                         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 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,
                         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,
                         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(ActionEvent e)
actionPerformed: handle action event: menus.

Specified by:
actionPerformed in interface ActionListener

keyTyped

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

Specified by:
keyTyped in interface KeyListener

keyPressed

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

Specified by:
keyPressed in interface KeyListener

keyReleased

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

Specified by:
keyReleased in interface KeyListener

focusGained

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

Specified by:
focusGained in interface FocusListener

focusLost

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

Specified by:
focusLost in interface FocusListener