Beispiel #1
0
 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);
 }
    /** {@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);
      }
    }
Beispiel #3
0
 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();
 }