示例#1
0
 /**
  * If this type contains any children by default, add them.
  *
  * @param engine
  * @param ob
  */
 public void createChildren(Engine engine, OObject ob) {
   ObjectFactory factory = engine.getObjectFactory();
   factory.createChild(ob, UIKeyword.WINDOW_TITLE, Keyword.UNTYPED, "Untitled Window");
   factory.createChild(ob, UIKeyword.BOUNDS, UIKeyword.BOUNDS, "");
   factory.createChild(ob, UIKeyword.CONTENTS, Keyword.UNTYPED, "");
   factory.createChild(ob, Keyword.EVENT_ON_OPEN, Keyword.SCRIPT, "");
   factory.createChild(ob, Keyword.EVENT_ON_CLOSE, Keyword.SCRIPT, "");
 }
示例#2
0
  @Test
  public void forEachWordTest() {
    Interactor interactor = new TestInteractor();
    Engine engine = new Engine(interactor);
    engine.start();

    engine.parseAndRun("create msg : \"one two three\"");
    engine.parseAndRun("create x [for each word]");
    engine.parseAndRun("put \"msg\" into x, in");
    engine.parseAndRun("put \"show here, object\" into x, do");
    engine.parseAndRun("run x");

    assertEquals("three", engine.getLastResult());

    engine.stop();
  }
示例#3
0
  /**
   * This type is runnable, so run it already! Running a window opens it.
   *
   * @param engine
   * @param ob
   * @return
   */
  public void run(Engine engine, OObject ob) {
    //		OWindow.openWindow( this.getTitle( ob ) );
    String title = this.getTitle(ob);

    OWindow w = new OWindow(engine, title);
    w.initFromSpec(ob);
    WindowManager.getInstance().addWindow(title, w);
    w.setVisible(true);

    engine.getEventManager().windowOpened(ob);
  }
示例#4
0
  @Test
  public void createForEachWordTest() {
    Interactor interactor = new TestInteractor();
    Engine engine = new Engine(interactor);
    engine.start();

    engine.parseAndRun("create r [for each word]");

    OObject parent = engine.getContext().findObjectByName("r");
    assertNotNull(parent);

    OObject index_obj = parent.getBucket().findChildByName("index");
    assertNotNull(index_obj);
    assertEquals("0", index_obj.getSimpleValue());
    assertEquals("integer", index_obj.getTypeSpec().getDisplayName());

    OObject obj = parent.getBucket().findChildByName("in");
    assertNotNull(obj);
    assertEquals("alias", obj.getTypeSpec().getDisplayName());

    obj = parent.getBucket().findChildByName("object");
    assertNotNull(obj);
    assertEquals("", obj.getTypeSpec().getDisplayName());

    obj = parent.getBucket().findChildByName("do");
    assertNotNull(obj);
    assertEquals("script", obj.getTypeSpec().getDisplayName());

    engine.parseAndRun("put \"r, do\" into r, in");
    engine.parseAndRun("put \"show here, index\" into r, do");
    engine.parseAndRun("run r");

    assertEquals("3", engine.getLastResult());

    engine.stop();
  }
示例#5
0
 /**
  * If this type contains any children by default, add them.
  *
  * @param engine
  * @param ob
  */
 public void createChildren(Engine engine, OObject ob) {
   ObjectFactory factory = engine.getObjectFactory();
   factory.createChild(ob, Keyword.CHILD_DATA, Keyword.UNTYPED, "");
 }