예제 #1
0
    public void actionPerformed(ActionEvent arg0) {
      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();

      if (curTreeNode == null) {
        new MessageBox(calcColumnDialog, "请选择树节点!", MessageBox.MESSAGE, MessageBox.BUTTON_OK)
            .show();
        return;
      }
      if (!curTreeNode.isLeaf()) return;

      int row = treWhere.getSelectionRows()[0];
      DefaultMutableTreeNode nextTreeNode = curTreeNode.getNextNode();
      if (!nextTreeNode.isLeaf()) return;

      DefaultTreeModel model = (DefaultTreeModel) treWhere.getModel();
      DefaultMutableTreeNode parTreeNode = (DefaultMutableTreeNode) curTreeNode.getParent();
      int index = parTreeNode.getIndex(curTreeNode);

      model.removeNodeFromParent(curTreeNode);
      model.insertNodeInto(curTreeNode, parTreeNode, index + 1);
      // 刷新节点中文名称
      if (curTreeNode != null) refreshNodeChName(curTreeNode);
      if (curTreeNode.getPreviousSibling() != null)
        refreshNodeChName(curTreeNode.getPreviousSibling());
      model.nodeChanged(curTreeNode);
      model.nodeChanged(curTreeNode.getPreviousSibling());

      treWhere.repaint();
      treWhere.setSelectionRow(row + 1);
    }
예제 #2
0
  /**
   * Draw all primitives in this layer but do not draw modified ones (they are drawn by the edit
   * layer). Draw nodes last to overlap the ways they belong to.
   */
  @SuppressWarnings("unchecked")
  @Override
  public void paint(final Graphics2D g, final MapView mv, Bounds bounds) {
    updateCount = Main.map.validatorDialog.tree.getUpdateCount();
    DefaultMutableTreeNode root = Main.map.validatorDialog.tree.getRoot();
    if (root == null || root.getChildCount() == 0) return;

    PaintVisitor paintVisitor = new PaintVisitor(g, mv);

    DefaultMutableTreeNode severity = (DefaultMutableTreeNode) root.getLastChild();
    while (severity != null) {
      Enumeration<DefaultMutableTreeNode> errorMessages = severity.breadthFirstEnumeration();
      while (errorMessages.hasMoreElements()) {
        Object tn = errorMessages.nextElement().getUserObject();
        if (tn instanceof TestError) {
          paintVisitor.visit(((TestError) tn));
        }
      }

      // Severities in inverse order
      severity = severity.getPreviousSibling();
    }

    paintVisitor.clearPaintedObjects();
  }