private void removeNodeFromParent(DefaultMutableTreeNode node) {
    TreeNode parent = node.getParent();
    int idx = parent.getIndex(node);
    node.removeFromParent();

    (getModel()).nodesWereRemoved(parent, new int[] {idx}, new TreeNode[] {node});
  }
예제 #2
0
파일: TreeState.java 프로젝트: jexp/idea2
  private static List<PathElement> createPath(final TreePath treePath) {
    final ArrayList<PathElement> result = new ArrayList<PathElement>();
    for (int i = 0; i < treePath.getPathCount(); i++) {
      final Object pathComponent = treePath.getPathComponent(i);
      if (pathComponent instanceof DefaultMutableTreeNode) {
        final DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathComponent;
        final TreeNode parent = node.getParent();

        final Object userObject = node.getUserObject();
        if (userObject instanceof NodeDescriptor) {
          final NodeDescriptor nodeDescriptor = (NodeDescriptor) userObject;
          // nodeDescriptor.update();
          final int childIndex = parent != null ? parent.getIndex(node) : 0;
          result.add(
              new PathElement(
                  getDescriptorKey(nodeDescriptor),
                  getDescriptorType(nodeDescriptor),
                  childIndex,
                  nodeDescriptor));
        } else {
          result.add(new PathElement("", "", 0, userObject));
        }
      } else {
        return null;
      }
    }
    return result;
  }
예제 #3
0
 /**
  * 刷新节点中文名称
  *
  * @param node
  */
 private void refreshNodeChName(TreeNode node) {
   TreeNode parNode = node.getParent();
   int index = parNode.getIndex(node);
   Caliber cal = (Caliber) ((DefaultMutableTreeNode) node).getUserObject();
   if (index == 0) {
     cal.setFirstNode(true);
   } else {
     cal.setFirstNode(false);
   }
 }
 private boolean isMovingAvailable(final CheckedTreeNode toolNode, Direction dir) {
   TreeNode parent = toolNode.getParent();
   int index = parent.getIndex(toolNode);
   return dir.isAvailable(index, parent.getChildCount());
 }