Exemple #1
0
  public void performJob(String name) {

    bb.addListener(
        GraphAttrSet.name,
        new Listener() {
          public void keyChanged(String key, Object value) {
            GraphModel gm = bb.getData(GraphAttrSet.name);
            try {
              main_interpreter.set(gm.getLabel(), gm);
            } catch (EvalError evalError) {
              evalError.printStackTrace();
            }
          }
        });
    evaluations += "clr(){console.clear();}";
    evaluations = "import graphlab.graph.graph.*;" + evaluations;

    ext_console = (ShellConsole) UIUtils.getComponent(bb, "ShellSideBar");
    ext_console.shell = this;
    final ShellConsole console = ext_console;
    main_interpreter = new Interpreter(console);
    parser = new InwardCommandParser(main_interpreter, this);
    parser.addCommands(new GraphCommands(bb));
    //        parser.addCommands(new ShellServerCommands(bb));
    parser.addCommands(new VertexCommands(bb));
    parser.addCommands(new EdgeCommands(bb));
    parser.addCommands(new NativeCommands(bb));
    evaluations = InwardCommandParser.evaluations;
    ShellCodeCompletion code_completion =
        new ShellCodeCompletion(
            main_interpreter, parser.commands, parser.abbrs, code_completion_dictionary);
    console.setNameCompletion(code_completion);

    new Thread() {
      public void run() {
        try {
          main_interpreter.set("abbreviations", parser.abbrs);
          main_interpreter.set("code_completion_dictionary", code_completion_dictionary);
          main_interpreter.set("evaluations", evaluations);
          main_interpreter.set("console", console);
          main_interpreter.set("blackboard", bb);
          main_interpreter.set("graphdata", new GraphData(bb));
          parser.abbrs.put("_clr", "clr");
          //                    main_interpreter.set("me", Shell.this);
          main_interpreter.eval(evaluations);
        } catch (EvalError evalError) {
          evalError.printStackTrace();
        }
        main_interpreter.run();
      }
    }.start();

    // for not printing 'by niemeyer'
    new Thread() {

      public void run() {
        try {
          Thread.sleep(1000);
          console.clear();
          console.print("bsh % ");
        } catch (InterruptedException e) {
          ExceptionHandler.catchException(e);
        }
      }
    }.start();
  }
Exemple #2
0
 /**
  * @param b
  * @return the available shell for b. (normally the working shell of application)
  */
 public static Shell getCurrentShell(BlackBoard b) {
   return b.getData(NAME);
 }