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);
  }
Ejemplo n.º 2
0
  /** Show the errorPane for error output */
  private void showErrorPane() {
    if (errorShown) {
      return;
    }

    // the first time the errortext is shown we need to pack() it
    // to make it have the right size.
    boolean isFirstShow = false;
    if (errorText == null) {
      isFirstShow = true;
      createErrorPane();
    }

    getContentPane().remove(scrollPane);

    // We want to know if it is not the first time
    // This means a "clear" has been used to remove the splitpane
    // when this re-adds the scrollPane to the terminal area
    // it implicitly removes it from the splitpane as it can only have one
    // owner. The side-effect of this is the splitpane's
    // top component becomes null.
    if (!isFirstShow) splitPane.setTopComponent(scrollPane);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.resetToPreferredSizes();

    if (isFirstShow) {
      pack();
    } else {
      validate();
    }

    errorShown = true;
  }
Ejemplo n.º 3
0
  /**
   * This method adds a component to the JSplitPane. The constraints object is a string that
   * identifies where this component should go. If the constraints is not a known one, it will throw
   * an IllegalArgumentException. The valid constraints are LEFT, TOP, RIGHT, BOTTOM and DIVIDER.
   *
   * @param comp The component to add.
   * @param constraints The constraints string to use.
   * @param index Where to place to component in the list of components.
   * @throws IllegalArgumentException When the constraints is not a known identifier.
   */
  protected void addImpl(Component comp, Object constraints, int index) {
    int left = 0;
    int right = 1;
    int div = 2;
    int place;
    if (constraints == null) {
      if (leftComponent == null) constraints = LEFT;
      else if (rightComponent == null) constraints = RIGHT;
    }

    if (constraints instanceof String) {
      String placement = (String) constraints;

      if (placement.equals(BOTTOM) || placement.equals(RIGHT)) {
        if (rightComponent != null) remove(rightComponent);
        rightComponent = comp;
      } else if (placement.equals(LEFT) || placement.equals(TOP)) {
        if (leftComponent != null) remove(leftComponent);
        leftComponent = comp;
      } else if (placement.equals(DIVIDER)) constraints = null;
      else throw new IllegalArgumentException("Constraints is not a known identifier.");

      // If no dividerLocation has been set, then we need to trigger an
      // initial layout.
      if (getDividerLocation() != -1) resetToPreferredSizes();

      super.addImpl(comp, constraints, index);
    }
  }
Ejemplo n.º 4
0
  /**
   * Hide the left part of the main split pane if both it's components are visible. If either of
   * them are visible, show it.
   */
  private void layoutSplitPane() {
    boolean visible = channelListPanel.isVisible() || metadataPanel.isVisible();

    if (leftPanel.isVisible() != visible) {
      leftPanel.setVisible(visible);
      splitPane.resetToPreferredSizes();
    }
  }
Ejemplo n.º 5
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();
 }