Example usage for javax.swing.tree MutableTreeNode getChildAt

List of usage examples for javax.swing.tree MutableTreeNode getChildAt

Introduction

In this page you can find the example usage for javax.swing.tree MutableTreeNode getChildAt.

Prototype

TreeNode getChildAt(int childIndex);

Source Link

Document

Returns the child TreeNode at index childIndex.

Usage

From source file:SortTreeDemo.java

private int findIndexFor(MutableTreeNode child, MutableTreeNode parent, int i1, int i2) {
    if (i1 == i2) {
        return comparator.compare(child, parent.getChildAt(i1)) <= 0 ? i1 : i1 + 1;
    }//from w w  w.  j  a v a 2s . c  om
    int half = (i1 + i2) / 2;
    if (comparator.compare(child, parent.getChildAt(half)) <= 0) {
        return findIndexFor(child, parent, i1, half);
    }
    return findIndexFor(child, parent, half + 1, i2);
}

From source file:MainClass.java

private int findIndexFor(MutableTreeNode child, MutableTreeNode parent) {
    int cc = parent.getChildCount();
    if (cc == 0) {
        return 0;
    }/*ww  w . ja v a 2 s . c  o m*/
    if (cc == 1) {
        return comparator.compare(child, parent.getChildAt(0)) <= 0 ? 0 : 1;
    }
    return findIndexFor(child, parent, 0, cc - 1);
}

From source file:SortTreeDemo.java

private int findIndexFor(MutableTreeNode child, MutableTreeNode parent) {
    int cc = parent.getChildCount();
    if (cc == 0) {
        return 0;
    }/*from  w  w w  . j  a  v  a 2  s  .c  om*/
    if (cc == 1) {
        return comparator.compare(child, parent.getChildAt(0)) <= 0 ? 0 : 1;
    }
    return findIndexFor(child, parent, 0, cc - 1); // First & last index
}

From source file:org.openconcerto.erp.model.FamilleArticleTree.java

/**
 * Ajoute un noeud dans l'arbre dans l'ordre alphabtique
 * /*  ww  w.  j a  va 2 s  . c  o m*/
 * @param nodeToAdd
 * @param nodeParent
 */
private void addNode(FamilleTreeNode nodeToAdd, MutableTreeNode nodeParent) {
    int n = 0;
    for (; n < nodeParent.getChildCount(); n++) {
        if (nodeToAdd.toString().compareToIgnoreCase(nodeParent.getChildAt(n).toString()) < 0) {
            break;
        }
    }
    model.insertNodeInto(nodeToAdd, nodeParent, n);
}

From source file:org.openconcerto.erp.model.FamilleArticleTree.java

/**
 * /*from ww w  .ja va 2 s  .  c o  m*/
 * @param row
 * @param nodeParent
 */
private void modifyNode(SQLRow row, MutableTreeNode nodeParent) {
    for (int i = 0; i < nodeParent.getChildCount(); i++) {
        Object o = nodeParent.getChildAt(i);
        if (o instanceof VariableRowTreeNode) {
            VariableRowTreeNode v = (VariableRowTreeNode) o;
            if (v.getID() == row.getID()) {
                v.setRow(row);
                model.nodeChanged(v);
            }
        }
    }
}

From source file:org.openconcerto.erp.model.FamilleArticleTree.java

private void removeNode(SQLRow row, MutableTreeNode nodeParent) {
    for (int i = 0; i < nodeParent.getChildCount(); i++) {
        Object o = nodeParent.getChildAt(i);
        if (o instanceof FamilleTreeNode) {
            FamilleTreeNode v = (FamilleTreeNode) o;
            if (v.getId() == row.getID()) {
                model.removeNodeFromParent(v);
            }/*  www. j a va  2s  .  co  m*/
        }
    }
}

From source file:org.openconcerto.erp.model.RubriquePayeTree.java

private static void addNode(VariableRowTreeNode nodeToAdd, MutableTreeNode nodeParent) {
    int n = 0;//from w w  w . j  a v a 2s . c  o  m
    for (; n < nodeParent.getChildCount(); n++) {
        if (nodeToAdd.toString().compareToIgnoreCase(nodeParent.getChildAt(n).toString()) < 0) {
            break;
        }
    }
    model.insertNodeInto(nodeToAdd, nodeParent, n);
}

From source file:org.openconcerto.erp.model.RubriquePayeTree.java

private static void modifyNode(SQLRow row, MutableTreeNode nodeParent) {
    for (int i = 0; i < nodeParent.getChildCount(); i++) {
        Object o = nodeParent.getChildAt(i);
        if (o instanceof VariableRowTreeNode) {
            VariableRowTreeNode v = (VariableRowTreeNode) o;
            if (v.getID() == row.getID()) {
                v.setRow(row);// www  .  j a v  a 2s.c  o m
                model.nodeChanged(v);
            }
        }
    }
}

From source file:org.openconcerto.erp.model.RubriquePayeTree.java

private static void removeNode(SQLRow row, MutableTreeNode nodeParent) {
    for (int i = 0; i < nodeParent.getChildCount(); i++) {
        Object o = nodeParent.getChildAt(i);
        if (o instanceof VariableRowTreeNode) {
            VariableRowTreeNode v = (VariableRowTreeNode) o;
            if (v.getID() == row.getID()) {
                model.removeNodeFromParent(v);
            }/*from   w ww  . j ava2  s .com*/
        }
    }
}