public void add(TreeNode<E> child) { insert(child, getChildCount()); }
public DefaultTreeModel<E> getModel() { return _parent != null ? _parent.getModel() : _model; }
public List<TreeNode<E>> getChildren() { return isLeaf() ? null : _children; }
private void buildModel(TreeNode<Object> rootNode, List<TermMatch> matches) { if (matches.isEmpty()) { rootNode.add(new DefaultTreeNode<Object>(null)); } else { for (TermMatch match : matches) { boolean synonyms = rgrpLookupMode.getSelectedIndex() == 1; TreeNode<Object> parentNode = synonyms ? new DefaultTreeNode<Object>(match) : new DefaultTreeNode<Object>(match, null, false); rootNode.add(parentNode); if (!synonyms) { for (TermType type : RENDERED_TERM_TYPES) { for (Term term : match.getTerms(type)) { parentNode.add(new DefaultTreeNode<Object>(term)); } } } } } }
/** Removes the receiver from its parent. */ public void removeFromParent() { if (_parent != null) _parent.remove(this); }
public TreeNode<E> getChildAt(int childIndex) { return childIndex >= 0 && childIndex < getChildCount() ? _children.get(childIndex) : null; }
/** Creates a branch (non-leaf) node. * @param children a collection of children (they must be {@link DefaultTreeNode} too). * If null or empty, it means * no children at all. However, it still allows to add children. * If it is not allowed, please use {@link #DefaultTreeNode(Object)} instead. */ public DefaultTreeNode(E data, Collection<? extends TreeNode<E>> children, boolean nullAsMax) { _data = data; _children = new TreeNodeChildrenList(); if (children != null) for (TreeNode<E> node : children) add(node); _maxnull = nullAsMax; }
public int getIndex(TreeNode<E> node) { return isLeaf() ? -1 : _children.indexOf(node); }
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); }
public int getChildCount() { return isLeaf() ? 0 : _children.size(); }
public void insert(TreeNode<E> child, int index) { if (isLeaf()) throw new UnsupportedOperationException("Child is not allowed in leaf node"); _children.add(index, child); }
public void remove(int index) { if (isLeaf()) throw new UnsupportedOperationException("Child is not allowed in leaf node"); _children.remove(index); }
public void remove(TreeNode<E> child) { if (isLeaf()) throw new UnsupportedOperationException("Child is not allowed in leaf node"); if (!_children.remove(child)) throw new IllegalArgumentException("not a child of this node"); }