예제 #1
0
파일: TreeUtil.java 프로젝트: jexp/idea2
 public static void moveSelectedRow(final JTree tree, final int direction) {
   final TreePath selectionPath = tree.getSelectionPath();
   final DefaultMutableTreeNode treeNode =
       (DefaultMutableTreeNode) selectionPath.getLastPathComponent();
   final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeNode.getParent();
   final int idx = parent.getIndex(treeNode);
   parent.remove(treeNode);
   parent.insert(treeNode, idx + direction);
   ((DefaultTreeModel) tree.getModel()).reload(parent);
   selectNode(tree, treeNode);
 }
예제 #2
0
    /** {@inheritDoc} */
    @Override
    public void insert(final MutableTreeNode aNewChild, final int aChildIndex) {
      super.insert(aNewChild, aChildIndex);

      Object newChildUserObject = ((ElementTreeNode) aNewChild).getUserObject();

      if ((this.userObject instanceof ElementGroup)
          && (newChildUserObject instanceof SignalElement)) {
        // Move the actual element as well...
        ((ElementGroup) this.userObject)
            .moveChannel((SignalElement) newChildUserObject, aChildIndex);
      }
    }
예제 #3
0
파일: TreeView.java 프로젝트: jexp/idea2
 public void addMessages(AntMessage[] messages) {
   DefaultMutableTreeNode parentNode =
       (DefaultMutableTreeNode) myParentPath.getLastPathComponent();
   int[] indices = new int[messages.length];
   for (int i = 0; i < messages.length; i++) {
     AntMessage message = messages[i];
     MessageNode messageNode = createMessageNode(message);
     indices[i] = parentNode.getChildCount();
     parentNode.insert(messageNode, indices[i]);
     myMessageItems.add(messageNode);
   }
   myTreeModel.nodesWereInserted(parentNode, indices);
   handleExpansion();
 }