public TreeModelEvent refactorEvent(TreeModelEvent event) {
      if (visibleNodes != null) {
        List<Object> children = new ArrayList<Object>(event.getChildren().length);
        List<Integer> indicieList = new ArrayList<Integer>(event.getChildIndices().length);

        for (Object node : event.getChildren()) {
          visibleNodes.add(node);
        }

        Object parent = event.getTreePath().getLastPathComponent();
        for (Object node : event.getChildren()) {
          children.add(node);
          indicieList.add(getIndexOfChild(parent, node));
        }

        int[] indicies = new int[indicieList.size()];
        for (int i = 0; i < indicies.length; i++) {
          indicies[i] = indicieList.get(i);
        }
        event =
            new TreeModelEvent(
                event.getSource(), event.getTreePath(), indicies, children.toArray(new Object[0]));
      }
      return event;
    }
  /**
   * Causes an {@link SmallStepNodeComponent#update() on all
   * nodes that have changed.<br>
   * <br>
   * When all updates are done relayouts the View.
   *
   * @see #relayout()
   */
  @Override
  protected void nodesChanged(TreeModelEvent event) {
    boolean relayout = false;
    Object[] children = event.getChildren();
    if (children == null) {

      // if the children are null and the path only contains one element
      // this element is the root node.
      if (event.getPath().length == 1) {
        SmallStepProofNode proofNode = (SmallStepProofNode) event.getPath()[0];
        SmallStepNodeComponent nodeComponent = (SmallStepNodeComponent) proofNode.getUserObject();
        if (nodeComponent != null) {
          nodeComponent.update();
          relayout = true;
        }
      }
    } else {
      for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof ProofNode) {
          SmallStepProofNode proofNode = (SmallStepProofNode) children[i];

          SmallStepNodeComponent nodeComponent = (SmallStepNodeComponent) proofNode.getUserObject();
          if (nodeComponent != null) {
            nodeComponent.update();
            relayout = true;
          }
        }
      }
    }
    if (relayout) {
      relayout();
    }
  }
  @Override
  public void treeNodesChanged(TreeModelEvent e) {
    if (adjusting) {
      return;
    }
    adjusting = true;
    TreePath parent = e.getTreePath();
    Object[] children = e.getChildren();
    DefaultTreeModel model = (DefaultTreeModel) e.getSource();

    DefaultMutableTreeNode node;
    CheckBoxNode c; // = (CheckBoxNode)node.getUserObject();
    if (children != null && children.length == 1) {
      node = (DefaultMutableTreeNode) children[0];
      c = (CheckBoxNode) node.getUserObject();
      onCheckboxStatusChanged(node);
      DefaultMutableTreeNode n = (DefaultMutableTreeNode) parent.getLastPathComponent();
      while (n != null) {
        updateParentUserObject(n);
        DefaultMutableTreeNode tmp = (DefaultMutableTreeNode) n.getParent();
        if (tmp == null) {
          break;
        } else {
          n = tmp;
        }
      }
      model.nodeChanged(n);
    } else {
      node = (DefaultMutableTreeNode) model.getRoot();
      c = (CheckBoxNode) node.getUserObject();
    }
    updateAllChildrenUserObject(node, c.status);
    model.nodeChanged(node);
    adjusting = false;
  }
  /**
   * DOCUMENT ME!
   *
   * @param e DOCUMENT ME!
   */
  public void treeNodesRemoved(TreeModelEvent e) {
    Object[] inserts = e.getChildren();

    for (int i = 0; i < inserts.length; i++) {
      Variable var = (Variable) ((SimpleTreeNode) inserts[i]).getUserObject();
      this.vm.undeclareVariable(var.getVariableName());
    }
  }
Esempio n. 5
0
 @Override
 public void treeNodesRemoved(TreeModelEvent e) {
   for (Object t : e.getChildren()) {
     if (((FileSystemEntry) t).isLoadingNode) {
       loadingNodeCount--;
     }
   }
 }
  /** Just saves the node that has been inserted. */
  @Override
  protected void nodesInserted(TreeModelEvent event) {
    Object[] children = event.getChildren();

    if (children != null) {
      this.jumpNode = (ProofNode) children[0];
    } else {
      this.jumpNode = null;
    }
  }
  /**
   * Removes all userobjects from the nodes that will be removed by the {@link SmallStepProofModel}
   * later.
   */
  @Override
  protected void nodesRemoved(TreeModelEvent event) {
    Object[] children = event.getChildren();
    if (children == null) {
      return;
    }
    for (int i = 0; i < children.length; i++) {
      if (children[i] instanceof ProofNode) {
        SmallStepProofNode proofNode = (SmallStepProofNode) children[i];

        SmallStepNodeComponent nodeComponent = (SmallStepNodeComponent) proofNode.getUserObject();
        if (nodeComponent != null) {
          remove(nodeComponent);
          proofNode.setUserObject(null);
        }
      }
    }
  }
Esempio n. 8
0
  /**
   * Handles the event of a node changing.
   *
   * @param event the TreeModelEvent
   */
  @Override
  public void treeNodesChanged(TreeModelEvent event) {
    /* at this point the TreeModel has already called setUserObject on the node;
     * get the value set by that function call and rename the task to that. */

    /* there may be several changed nodes; loop through all of them */
    for (Object obj : event.getChildren()) {
      /* must be node */
      if (!(obj instanceof Task)) continue;

      /* the node's userObject must be set to a String */
      Task node = (Task) obj;
      if (!(node.getUserObject() instanceof String)) continue; /* TODO error? */

      /* rename */
      this.rename(node, (String) node.getUserObject());
    }
  }