/** @deprecated As of release 6.0.0, replaced with {@link #addOpenObject} * and {@link #removeOpenObject}. */ public void setOpen(TreeNode<E> child, boolean open) { final int[] path = getPath(child); if (path != null && path.length > 0) { if (open) addOpenPath(path); else removeOpenPath(path); } }
/** @deprecated As of release 6.0.0, replaced with {@link #addToSelection}. */ @SuppressWarnings("unchecked") public void addSelection(Object obj) { if (obj instanceof TreeNode) addToSelection((TreeNode) obj); }
/** Sorts the data. * * <p>Notice: it invokes {@link #beforeSort} and {@link #afterSort} * to save and restore the selection and open states. * If you prefer not to preserve objects and prefer to save the paths, * you can override {@link #beforeSort} to do nothing but returning null. * If you prefer to clear the selection, you can override {@link #beforeSort} * to clear {@link #_selection} and return null. * * @param cmpr the comparator. * @param ascending whether to sort in the ascending order. * It is ignored since this implementation uses cmprt to compare. */ public void sort(Comparator<TreeNode<E>> cmpr, final boolean ascending) { _sorting = cmpr; _sortDir = ascending; TreeNode<E> root = getRoot(); if (root != null) { final Object ctx = beforeSort(); sort0(root, cmpr); afterSort(ctx); //before firing event fireEvent(TreeDataEvent.STRUCTURE_CHANGED, null, 0, 0); } }
@SuppressWarnings("unchecked") public Object clone() { final DefaultTreeModel clone = (DefaultTreeModel) super.clone(); final TreeNode cloneRoot = (TreeNode) getRoot().clone(); cloneRoot.setModel(this); clone.setRootDirectly(cloneRoot); return clone; } }
/** @deprecated As of release 6.0.0, replaced with {@link #isObjectOpened}. */ public boolean isOpen(Object child) { return isObjectOpened(child); }
/** @deprecated As of release 6.0.0, replaced with {@link #removeFromSelection}. */ public void removeSelection(Object obj) { removeFromSelection(obj); }
/** * Returns the path from the child, where the path indicates the child is * placed in the whole tree. * @param child the node we are interested in * @since 6.0.0 */ public int[] getPath(TreeNode<E> child) { final TreeNode<E> root = getRoot(); List<Integer> p = new ArrayList<Integer>(); while (root != child) { TreeNode<E> parent = child.getParent(); if (parent != null) { for (int i = 0, j = parent.getChildCount(); i < j; i++) { if (parent.getChildAt(i) == child) { p.add(0, i); break; } } child = parent; } else break; // ZK-838 } final Integer[] objs = p.toArray(new Integer[p.size()]); final int[] path = new int[objs.length]; for (int i = 0; i < objs.length; i++) path[i] = objs[i].intValue(); return path; }
public void onClick$btnSearch() { String text = txtSearch.getValue().trim(); boolean synonym = rgrpLookupMode.getSelectedIndex() == 1; FMDate date = new FMDate(datSearch.getValue()); Long max = (Long) rgrpMaxResults.getSelectedItem().getValue(); String[] filters = getSelectedSubsets(); List<TermMatch> matches = TermUtil.lookupSCT(text, synonym, date, max, filters); TreeNode<Object> rootNode = new DefaultTreeNode<>(null, null, false); buildModel(rootNode, matches); DefaultTreeModel<Object> model = new DefaultTreeModel<>(rootNode); treeSearch.setModel(model); }