edu.mit.ai.psg.jevaESUI
Class JevaESGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.mit.ai.psg.ui.patches.FrameableApplet
                                |
                                +--edu.mit.ai.psg.jevaESUI.JevaESGUI

public class JevaESGUI
extends FrameableApplet

JevaESGUI is a graphical (windowed) user interface for the JevaES Java evaluator for expression & statements. JevaESGUI can be used as

JevaESGUI invokes JevaES, which accepts Java 1.2 Expressions or Statements (plus import and package, but no class declarations nor inner classes). Previous results (including nulls) are stored in a Vector:
.  localResults.get(n) 
Local streams localOut, localErr can be used in place of System.out, System.err. In any situation, results can be explored in an outline tree using Jexa, and objects found in Jexa can become parameters of statements and expressions.

See Also:
edu.mit.ai.psg.jevaES, edu.mit.ai.psg.jexa, JevaESUI, JevaESCLI, Serialized Form

Field Summary
static Font defaultFont
          Default font for new windows, e.g.,
static int leftmostOptionBit
           
protected static Dimension minSizeAsButton
          default: 200x30
protected static Dimension minSizeInPlace
          default: 300x300
protected static String pkBindLocalApplet
           
protected static String pkHerald
           
protected static String pkInitStatements
           
protected static String pkMessage
           
static int redirectStreamsBit
          The option bit redirectStreamsBit tells JevaESGUI to redirecting System#out and System#err to its output pane.
static PrintStream systemErr
          Saved system.err present when loaded
static PrintStream systemOut
          Saved system.out present when loaded
 
Fields inherited from class edu.mit.ai.psg.ui.patches.FrameableApplet
pkBgColor, pkTextColor, pkTitle, titleFont
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JevaESGUI()
           
 
Method Summary
static Object awaitResult(Container container)
          Wait for a JevaESGUIFrame or JevaESGUIPanel to return a value.
protected  IEnv bindAppletEnv(int options)
          if "bindApplet" parameter is set, make env binding "localApplet" to this applet with its class as type
 String getAppletInfo()
          returns default herald
 String getAppletTitle()
          default applet title: getParameter(pkTitle) or ""
protected  String getButtonStartedText()
          default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStarted )
protected  String getButtonStartingText()
          default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStarting )
protected  String getButtonStartText()
          default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStart )
protected  Dimension getMinSizeAsButton()
          default: minSizeAsButton
protected  Dimension getMinSizeInPlace()
          default: minSizeInPlace
 String[][] getParameterInfo()
          Applet parameters: message: text to display after herald herald: text to display text in place of herald bindLocalApplet: if "true", binds "localApplet" to this applet (for debugging applets); other applets on same page can then be accessed through localApplet.FrameableApplet.getAppletList()().
 Frame initFrameApplet()
          creates a new JevaESGUIFrame
 void initPanelInPlaceApplet()
          Display applet in place on page.
static boolean isRedirectingStreams(int options)
           
static void main(String[] arguments)
          Application Startup: Starts a window at which users can type top level expressions.
static Object repl()
          Read-Eval-Print-Loop: creates a new window in which user may type java expressions and statements, including return to return a value.
static Object repl(int options, String title, String initialMessage, Class returnClass, Class[] throwsClasses, IEnv env)
           
static Object repl(int options, String title, String initialMessage, Class returnClass, Class[] throwsClasses, IEnv env, String initStatements)
          Read-Eval-Print-Loop: creates a new window in which user may type java expressions and statements, including return to return a value.
static void replTop()
          Top read-eval-print-loop: creates a new window in which user may type java expressions and statements.
static void replTop(int options, String title, String initStatements)
           
static void replTop(int options, String title, String initialMessage, String initStatements)
           
 
Methods inherited from class edu.mit.ai.psg.ui.patches.FrameableApplet
getAppletList, getParameter, getTitleIcon, init, initAppletColors, initButtonForFrameApplet, makeButtonForFrame
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minSizeInPlace

protected static Dimension minSizeInPlace
default: 300x300

minSizeAsButton

protected static Dimension minSizeAsButton
default: 200x30

pkHerald

protected static final String pkHerald

pkMessage

protected static final String pkMessage

pkBindLocalApplet

protected static final String pkBindLocalApplet

pkInitStatements

protected static final String pkInitStatements

systemOut

public static PrintStream systemOut
Saved system.out present when loaded

systemErr

public static PrintStream systemErr
Saved system.err present when loaded

defaultFont

public static Font defaultFont
Default font for new windows, e.g.,
java.util.Map attributes = new java.util.HashMap(1);
attributes.put(java.awt.font.TextAttribute.FAMILY, "Monospaced");
defaultFont = java.awt.Font.getFont(attributes);
(Initialization specifies only logical font family, since system default size will vary with locale, e.g., for Aisan languages.)
See Also:
Font.getFont(Map)

redirectStreamsBit

public static final int redirectStreamsBit
The option bit redirectStreamsBit tells JevaESGUI to redirecting System#out and System#err to its output pane. This bit should not be set unless the JevaESGUI window will remain available for the remainder of the time the java program is running (e.g., top level application loop), and permission to set System.out and System.err is available, (e.g., not in applet security sandbox).

Options are specified at startup in calls to replTop(int, String, String) or repl(int, String, String, Class, Class[], IEnv). Option bits are |'ed together into a 32 bit int. 0 is default for each option. See JevaES for additional options (JevaES options are used by JevaESGUI only if no env is supplied.)


leftmostOptionBit

public static final int leftmostOptionBit
Constructor Detail

JevaESGUI

public JevaESGUI()
Method Detail

main

public static void main(String[] arguments)
Application Startup: Starts a window at which users can type top level expressions.
usage: java edu.mit.ai.psg.jevaESUI.JevaESGUI
[-noredirect] [-title "title"] [-font ["name"] [size]] 
options:
-noredirect Don't redirect System.out and System.err to pane
-title "title" Use "title" for window title.
-font "name" Use named font (default: defaultFont)
-font "size" Use font point size (default: defaultFont)
-font "name" "size" Use font and size.
-initStatements "statements" run statements before start (e.g., imports)
-message "text" display text after herald
-herald "text" display text in place of herald
(Note: -font uses Font.Font(String, int, int) to create fonts, which returns a default font if there are problems. It also doesn't work well for non-logical fonts in the first release of Java 1.2 on NT)

getMinSizeInPlace

protected Dimension getMinSizeInPlace()
default: minSizeInPlace
Overrides:
getMinSizeInPlace in class FrameableApplet
Tags copied from class: FrameableApplet
See Also:
FrameableApplet.init()

getMinSizeAsButton

protected Dimension getMinSizeAsButton()
default: minSizeAsButton
Overrides:
getMinSizeAsButton in class FrameableApplet
Tags copied from class: FrameableApplet
See Also:
FrameableApplet.init()

getAppletTitle

public String getAppletTitle()
Description copied from class: FrameableApplet
default applet title: getParameter(pkTitle) or ""
Overrides:
getAppletTitle in class FrameableApplet

initPanelInPlaceApplet

public void initPanelInPlaceApplet()
Display applet in place on page. Suggested applet size: 580 x 420.
Overrides:
initPanelInPlaceApplet in class FrameableApplet
See Also:
FrameableApplet.initPanelInPlaceApplet(), getParameterInfo()

getButtonStartText

protected String getButtonStartText()
default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStart )
Overrides:
getButtonStartText in class FrameableApplet

getButtonStartingText

protected String getButtonStartingText()
default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStarting )
Overrides:
getButtonStartingText in class FrameableApplet

getButtonStartedText

protected String getButtonStartedText()
default: JevaESUI.getJevaESUIBundleString( JevaESGUIAppletStarted )
Overrides:
getButtonStartedText in class FrameableApplet

initFrameApplet

public Frame initFrameApplet()
creates a new JevaESGUIFrame
Overrides:
initFrameApplet in class FrameableApplet
See Also:
getParameterInfo()

bindAppletEnv

protected IEnv bindAppletEnv(int options)
if "bindApplet" parameter is set, make env binding "localApplet" to this applet with its class as type

getParameterInfo

public String[][] getParameterInfo()
Applet parameters: For more parameters, see FrameableApplet.getParameterInfo()
Overrides:
getParameterInfo in class FrameableApplet

getAppletInfo

public String getAppletInfo()
returns default herald
Overrides:
getAppletInfo in class Applet

isRedirectingStreams

public static boolean isRedirectingStreams(int options)

replTop

public static void replTop()
Top read-eval-print-loop: creates a new window in which user may type java expressions and statements. Returns when window is closed.

replTop

public static void replTop(int options,
                           String title,
                           String initStatements)

replTop

public static void replTop(int options,
                           String title,
                           String initialMessage,
                           String initStatements)

repl

public static Object repl()
                   throws Throwable,
                          AWTException
Read-Eval-Print-Loop: creates a new window in which user may type java expressions and statements, including return to return a value.
Throws:
Throwable - --- throws anything user throws.
AWTException - if window is closed.

repl

public static Object repl(int options,
                          String title,
                          String initialMessage,
                          Class returnClass,
                          Class[] throwsClasses,
                          IEnv env)
                   throws Throwable,
                          AWTException

repl

public static Object repl(int options,
                          String title,
                          String initialMessage,
                          Class returnClass,
                          Class[] throwsClasses,
                          IEnv env,
                          String initStatements)
                   throws Throwable,
                          AWTException
Read-Eval-Print-Loop: creates a new window in which user may type java expressions and statements, including return to return a value.
Parameters:
options - Option flag bits or'ed together; 0 is default. Applets need JevaES.suppressPackageNameChecksBit due to security sandbox,
title - Non-null text replaces window title; helps identify window if initialMessage has scrolled away.
initialMessage - Non-null text replaces herald; if called from a breakpoint, a good practice is to show user contents of env.
returnClass - user may only return a value of this class (like method return type); Object.class allows anything. Use void.class for void result. If null, never returns (like a top level loop).
throwsClasses - user may only throw Throwables which are instances of these classes, or instances of Error or RuntimeException (like method throw declarations). If null, defaults to no declarations.
env - initial environment created with JevaES.makeDefaultEnv, JevaES.extendEnv(), or JevaES.parseEval..Statement If null, defaults to JevaES.makeDefaultEnv() .
initStatements - initial statements to run. (Convenience feature for extending env from command line or applet parameter, e.g., to specify default imports for user input.) If null, defaults to no statements.
Throws:
Throwable - --- throws anything user throws compatibile with throwsClasses
AWTException - if window is closed.

awaitResult

public static Object awaitResult(Container container)
                          throws Throwable,
                                 AWTException
Wait for a JevaESGUIFrame or JevaESGUIPanel to return a value. Called by repl after constructing and showing a JevaESGUIFrame.
Parameters:
container - must be JevaESGUIFrame or JevaESGUIPanel

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu