public ConstraintsGUI() {
    this.rtTop = new RuleTree(null, false, false); // the Rules
    this.rtTop.addParserGUIListener(this);
    this.rtBottom = new RuleTree(null, true, false); // the Atomics
    this.rtBottom.addParserGUIListener(this);

    JSplitPane treePane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    treePane.setOneTouchExpandable(true);
    treePane.setContinuousLayout(true);
    JScrollPane tmpPane = new JScrollPane(this.rtTop.getTree());
    tmpPane.setSize(170, 210);
    tmpPane.setPreferredSize(new Dimension(170, 210));
    treePane.setTopComponent(tmpPane);
    tmpPane = new JScrollPane(this.rtBottom.getTree());
    tmpPane.setSize(170, 210);
    tmpPane.setPreferredSize(new Dimension(170, 210));
    treePane.setBottomComponent(tmpPane);
    treePane.getTopComponent().setSize(185, 300);
    treePane.getBottomComponent().setSize(185, 300);
    treePane.resetToPreferredSizes();

    this.right = new RuleConstraint(null);

    this.mainPane = new JSplitPane();
    this.mainPane.setOneTouchExpandable(true);
    this.mainPane.setContinuousLayout(true);
    this.mainPane.setRightComponent(this.right.getComponent());
    this.mainPane.setLeftComponent(treePane);

    setGrammar(null);
    setLayout(null);
  }
예제 #2
0
 // Many of the following methods have been added purely
 // so InternalFunctions can work.  Originally, the code in
 // that class was inline here, so its functions had direct
 // access.  I removed it so that students do not need to wade
 // through all the functions!  But, that leaves the question as
 // to what to do with the following methods, but I don't think
 // there's much you can do ...
 public void changeSize(int width, int height) {
   setSize(width, height);
   Component top = splitPane.getTopComponent();
   Component bottom = splitPane.getBottomComponent();
   int totalHeight = top.getHeight() + bottom.getHeight();
   int topHeight = (totalHeight * topProportion) / 100;
   int bottomHeight = (totalHeight * bottomProportion) / 100;
   top.setPreferredSize(new Dimension(width - 10, topHeight));
   bottom.setPreferredSize(new Dimension(width - 10, bottomHeight));
   splitPane.resetToPreferredSizes();
   pack();
 }
 @Override
 public List<IJavaElement> getByPseudoElement(String selector, Object[] params) {
   JSplitPane pane = (JSplitPane) component;
   if (selector.equals("left") || selector.equals("top")) {
     return Arrays.asList(
         JavaElementFactory.createElement(pane.getTopComponent(), getDriver(), getWindow()));
   } else if (selector.equals("right") || selector.equals("bottom")) {
     return Arrays.asList(
         JavaElementFactory.createElement(pane.getBottomComponent(), getDriver(), getWindow()));
   }
   return super.getByPseudoElement(selector, params);
 }
예제 #4
0
  public InterpreterFrame() {
    super("Simple Lisp Interpreter");

    // Create the menu
    menubar = buildMenuBar();
    setJMenuBar(menubar);
    // Create the toolbar
    toolbar = buildToolBar();
    // disable cut and copy actions
    cutAction.setEnabled(false);
    copyAction.setEnabled(false);
    // Setup text area for editing source code
    // and setup document listener so interpreter
    // is notified when current file modified and
    // when the cursor is moved.
    textView = buildEditor();
    textView.getDocument().addDocumentListener(this);
    textView.addCaretListener(this);

    // set default key bindings
    bindKeyToCommand("ctrl C", "(buffer-copy)");
    bindKeyToCommand("ctrl X", "(buffer-cut)");
    bindKeyToCommand("ctrl V", "(buffer-paste)");
    bindKeyToCommand("ctrl E", "(buffer-eval)");
    bindKeyToCommand("ctrl O", "(file-open)");
    bindKeyToCommand("ctrl S", "(file-save)");
    bindKeyToCommand("ctrl Q", "(exit)");

    // Give text view scrolling capability
    Border border =
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(3, 3, 3, 3),
            BorderFactory.createLineBorder(Color.gray));
    JScrollPane topSplit = addScrollers(textView);
    topSplit.setBorder(border);

    // Create tabbed pane for console/problems
    consoleView = makeConsoleArea(10, 50, true);
    problemsView = makeConsoleArea(10, 50, false);
    tabbedPane = buildProblemsConsole();

    // Plug the editor and problems/console together
    // using a split pane. This allows one to change
    // their relative size using the split-bar in
    // between them.
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topSplit, tabbedPane);

    // Create status bar
    statusView = new JLabel(" Status");
    lineNumberView = new JLabel("0:0");
    statusbar = buildStatusBar();

    // Now, create the outer panel which holds
    // everything together
    outerpanel = new JPanel();
    outerpanel.setLayout(new BorderLayout());
    outerpanel.add(toolbar, BorderLayout.PAGE_START);
    outerpanel.add(splitPane, BorderLayout.CENTER);
    outerpanel.add(statusbar, BorderLayout.SOUTH);
    getContentPane().add(outerpanel);

    // tell frame to fire a WindowsListener event
    // but not to close when "x" button clicked.
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(this);
    // set minimised icon to use
    setIconImage(makeImageIcon("spi.png").getImage());

    // setup additional internal functions
    InternalFunctions.setup_internals(interpreter, this);

    // set default window size
    Component top = splitPane.getTopComponent();
    Component bottom = splitPane.getBottomComponent();
    top.setPreferredSize(new Dimension(100, 400));
    bottom.setPreferredSize(new Dimension(100, 200));
    pack();

    // load + run user configuration file (if there is one)
    String homedir = System.getProperty("user.home");
    try {
      interpreter.load(homedir + "/.simplelisp");
    } catch (FileNotFoundException e) {
      // do nothing if file does not exist!
      System.out.println("Didn't find \"" + homedir + "/.simplelisp\"");
    }

    textView.grabFocus();
    setVisible(true);

    // redirect all I/O to problems/console
    redirectIO();

    // start highlighter thread
    highlighter = new DisplayThread(250);
    highlighter.setDaemon(true);
    highlighter.start();
  }