import java.awt.*;
import edu.mit.ai.psg.jevaESUI.JevaESGUI;
import edu.mit.ai.psg.jevaES.JevaES;

/** DemoInspectPoint

    An example showing how to invoke a read-eval-print-loop JevaESGUI.repl(..)
    method with an extended environment.  This pop-ups a window where the user
    may inspect and interact with program values by typing Java code
    (and optionally invoking Jexa).
**/
public class DemoInspectPoint {
  public static void main(String[] args) {

    Frame frame = new java.awt.Frame("DemoInspectPoint Frame");
    frame.setLayout(new FlowLayout());
    frame.add(new Label("Resize Me, then try frame.setSize(dim)"));
    frame.setSize(500, 100);
    Dimension dim = frame.getSize();
    frame.show();

    try {
      JevaESGUI.repl                   // Inspect Point:
	(0, "DemoInspectPoint",           //   window title
	 ("InspectPoint: \n"+
	  "  frame: "+frame+"\n"+      //   display available vars and values
	  "  dim: "+dim+"\n"),
	 null, null,
	 JevaES.extendEnv
	 (Frame.class, "frame", frame, //   specify var type, name, value
	  JevaES.extendEnv
	  (Dimension.class, "dim", dim,
	   JevaES.parseEvalStringStatement
	   ("import java.awt.*;",      //   add a default import
	    JevaES.makeDefaultEnv()))));
    } catch (Throwable t) { } // window closed
  }
}