Package de.tuhrig.thofu

Examples of de.tuhrig.thofu.Interpreter


  @Before
  public void reset() {

    this.parser = new ProceduralParser();
   
    this.interpreter = new Interpreter();
  }
View Full Code Here


  private IInterpreter interpreter;

  @Before
  public void reset() {

    interpreter = new Interpreter();
  }
View Full Code Here

      @Override
      public void actionPerformed(ActionEvent arg0) {

        debugger.setDebugg(false);
       
        setInterpreter(new Interpreter());
       
        if(editor.openFiles())
          markGrubby();
        else
          markFresh();
      }
    });

    save.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {

        editor.save();
      }
    });

    saveAs.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {

        int returnVal = fc.showSaveDialog(ThoFuUi.this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {

          editor.saveAs(fc.getSelectedFile());
        }
      }
    });

    open.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {
       
        int returnVal = fc.showOpenDialog(ThoFuUi.this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {

          open(fc.getSelectedFile());
        }
      }
    });
   
    newFile.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {

        int returnVal = fc.showSaveDialog(ThoFuUi.this);

        if (returnVal == JFileChooser.APPROVE_OPTION) {

          open(fc.getSelectedFile());
        }
      }
    });

    about.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {

        String content = new Util().read(getClass(), "README.md");

        new HtmlViewer(content)
      }
    });
   
    exit.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {

        promptUnsavedWarningIfDirty();
             
        System.exit(0);
      }
    });

    JMenu file = SwingFactory.createMenu("File", "icons/Write Document.png");
    file.add(newFile);
    file.add(open);
    file.add(new JSeparator());
    file.add(save);
    file.add(saveAll);
    file.add(saveAs);
    file.add(new JSeparator());
    file.add(close);
    file.add(closeAll);
    file.add(new JSeparator());
    file.add(exit);
   
    final JMenu syntax = new JMenu("Syntax");
    SwingFactory.setIcon(syntax, "icons/Rename Document.png");

    JRadioButtonMenuItem defaultSyntax = new JRadioButtonMenuItem("Default");
    SwingFactory.setIcon(defaultSyntax, "icons/Purple Ball.png");
   
    JRadioButtonMenuItem proceduralSyntax = new JRadioButtonMenuItem("Procedural");
    SwingFactory.setIcon(proceduralSyntax, "icons/Orange Ball.png");

    ButtonGroup group = new ButtonGroup();
    group.add(defaultSyntax);
    group.add(proceduralSyntax);
   
    syntax.add(defaultSyntax);
    syntax.add(proceduralSyntax);
   
    defaultSyntax.addActionListener(new ActionListener() {
     
      @Override
      public void actionPerformed(ActionEvent e) {
     
        interpreter.setParser(new DefaultParser());
       
        repl.setSyntax(SyntaxConstants.SYNTAX_STYLE_LISP);
        editor.setSyntax(SyntaxConstants.SYNTAX_STYLE_LISP);
       
        log.log("Default syntax");
      }
    });
   
    defaultSyntax.setSelected(true);
   
    proceduralSyntax.addActionListener(new ActionListener() {
     
      @Override
      public void actionPerformed(ActionEvent e) {
     
        interpreter.setParser(new ProceduralParser());
     
        repl.setSyntax(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
        editor.setSyntax(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
       
        log.log("Procedural syntax");
      }
    });
   
    final JMenu edit = SwingFactory.createMenu("Edit", "icons/Menu.png");

    edit.addMenuListener(new MenuListener() {
     
      @Override
      public void menuSelected(MenuEvent arg0) {
       
          edit.removeAll();

          JMenu editorMenu = SwingFactory.createMenu("Editor", "icons/editor.png", editor.getPopupMenu());
          edit.add(editorMenu);
         
        if(editor.getPopupMenu() == null) {

          editorMenu.setEnabled(false);
        }
       
        JMenu replMenu = SwingFactory.createMenu("Console", "icons/console.png", repl.getPopupMenu());
        edit.add(replMenu);
       
        edit.add(syntax);
      }
     
      @Override
      public void menuDeselected(MenuEvent arg0) {}
     
      @Override
      public void menuCanceled(MenuEvent arg0) {}
    });
   
   

    JMenu run = SwingFactory.createMenu("Run", "icons/Gear Alt.png");
    run.add(start);
    run.add(reset);
    run.add(stop);
   
    JMenu info = SwingFactory.createMenu("More", "icons/Add.png");
    info.add(about);
   
    JMenuBar menubar = SwingFactory.createMenuBar();
    menubar.add(file);
    menubar.add(edit);
    menubar.add(run);
    menubar.add(info);

    this.setJMenuBar(menubar);

    this.addWindowListener(new WindowAdapter() {

      @Override
      public void windowClosing(WindowEvent e) {

        promptUnsavedWarningIfDirty();       
      }
    });
   
    this.markFresh();
    this.setInterpreter(new Interpreter());
    this.getContentPane().add(status, BorderLayout.NORTH);
    this.getContentPane().add(msp, BorderLayout.CENTER);
    this.getContentPane().add(running, BorderLayout.SOUTH);
   
    this.setExtendedState(Frame.MAXIMIZED_BOTH);
View Full Code Here

  private Environment environment;

  @Before
  public void reset() {

    this.environment = new Interpreter().getEnvironment();

    this.cons = (LOperation) environment.get(LSymbol.get("cons"));
  }
View Full Code Here

TOP

Related Classes of de.tuhrig.thofu.Interpreter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.