@Override public ConfigurableWrapper addChild(Configurable configurable) { if (myComparator != null) { int index = Arrays.binarySearch(myKids, configurable, myComparator); LOG.assertTrue(index < 0, "similar configurable is already exist"); myKids = ArrayUtil.insert(myKids, -1 - index, configurable); } else { myKids = ArrayUtil.append(myKids, configurable); } return this; }
private void createPainToTree2( final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection paintCollection) { ArrayList a = (ArrayList) paintCollection; DefaultMutableTreeNode parent = root; System.out.println("a = " + a.size()); Iterator i = a.iterator(); // Person lastPerson = null; while (i.hasNext()) { Person p = (Person) i.next(); Object[] pathTree = { root, p.getFio().getLastName(), p.getFio().getMidllName(), p.getFio().getFirstName() }; // int poz=Arrays.binarySearch(pathTree, parent.getUserObject()); List l = Arrays.asList(pathTree); int poz = l.lastIndexOf(parent.getUserObject()); while (poz > -1) { // bvtyf yt cjdgflf.n while (pathTree.length > poz) { DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(pathTree[poz + 1]); treeModel.insertNodeInto(newNode, parent, parent.getChildCount()); parent = newNode; poz = Arrays.binarySearch(pathTree, parent.getUserObject()); } } // TreePath path = new TreePath(pathTree); // TreeNode[] pa = parent.getPath(); // Object[] o = parent.getUserObjectPath(); // if (p.getFio().getFirstName() != (o[o.length - 1])) { // // treeModel.insertNodeInto( // new DefaultMutableTreeNode( // path.getLastPathComponent()), // parent, parent.getChildCount()); // lastPerson = p; // } } }