/** * Returns currently selected plugin definition, or null if none selected. * * @return Definition of the currently selected plugin. */ private PluginDefinition selectedPluginDefinition() { return (PluginDefinition) (tree.getSelectedNode() == null ? null : tree.getSelectedNode().getData()); }
/** * Set the selected state of this node. * * @param selected The new selected state. * @param notifyClient If true, notify the client of the state change. * @param notifyParent If true, notify the parent tree view of the state change. */ /*package*/ void _setSelected(boolean selected, boolean notifyClient, boolean notifyParent) { if (propertyChange("selected", this.selected, this.selected = selected, notifyClient) && notifyParent) { Treeview treeview = getTreeview(); if (treeview != null) { if (selected) { treeview.setSelectedNode(this); } else if (treeview.getSelectedNode() == this) { treeview.setSelectedNode(null); } } } }
/** * Rebuilds the tree from original target, canceling any pending changes. */ private void resetTree() { currentItem = null; proxies.clear(); tree.destroyChildren(); initTree(getTargetElement(), tree); selectNode((Treenode) tree.getFirstChild()); hasChanged = false; }
/** * Sets the selection if the added node or one of its descendants is flagged as selected. * * @see org.fujion.component.BaseComponent#afterAddChild(org.fujion.component.BaseComponent) */ @Override protected void afterAddChild(BaseComponent child) { Treenode selnode = findSelected((Treenode) child, null); if (selnode != null) { setSelectedNode(selnode); } }
/** * Selecting an item sets it as the starting point for a search. */ @EventHandler(value = "change", target = "@tree") private void onChange$tree() { Treenode node = tree.getSelectedNode(); iterator = tree.iterator(); while (iterator.next() != node) { //NOP } }
/** * When the viewer changes the topic selection, highlight that topic in the tree (if it exists). * * @see HelpViewBase#onTopicSelected(HelpTopic) */ @Override public void onTopicSelected(HelpTopic topic) { if (topic != selectedTopic) { selectedTopic = topic; tree.setSelectedNode(topics.get(topic)); } }
/** * Perform a search. */ @EventHandler(value = "click", target = "btnSearch") private void onClick$btnSearch() { txtSearch.setFocus(true); lblNotFound.setVisible(false); String text = txtSearch.getValue(); tree.setSelectedNode(null); if (text != null && !text.isEmpty()) { text = text.toLowerCase(); iterator = iterator == null ? tree.iterator() : iterator; while (iterator.hasNext()) { Treenode node = iterator.next(); if (node.getLabel().toLowerCase().contains(text)) { node.makeVisible(); node.setSelected(true); return; } } iterator = null; lblNotFound.setVisible(true); } }
/** * Collapses all nodes. */ public void collapseAll() { expandOrCollapse(this, true); }
@Override public void doClose() { tree.focus(); EventUtil.post(ChangeEvent.TYPE, tree, null); // Must be done asynchronously to allow server to sync with client changes }
/** * Returns the tree item associated with the specified \-delimited path. * * @param tree Tree to search. * @param path \-delimited path to search. * @param create If true, tree nodes are created if they do not already exist. * @param clazz Class of Treenode to create. * @param matchMode The match mode. * @return The tree item corresponding to the specified path, or null if not found. */ public static Treenode findNode(Treeview tree, String path, boolean create, Class<? extends Treenode> clazz, MatchMode matchMode) { if (tree.getChildCount() == 0 && !create) { return null; } return CWFUtil.findNode(tree, clazz, path, create, matchMode); }
private Treenode findSelected(Treenode node, Treenode selnode) { if (node.isSelected()) { if (selnode != null) { selnode._setSelected(false, true, false); } selnode = node; } for (BaseComponent child : node.getChildren()) { selnode = findSelected((Treenode) child, selnode); } return selnode; }
/** * Refreshes the component tree. */ private void refresh() { refreshPending = false; ElementBase selectedElement = selectedElement(); tree.destroyChildren(); dragId = 0; buildTree(rootElement, null, selectedElement); updateDroppable(); updateControls(); }
private void _setTreeSelected(Treenode selectedNode) { Treeview treeview = getTreeview(); if (treeview != null) { treeview.setSelectedNode(selectedNode); } }
/** * Expands all nodes. */ public void expandAll() { expandOrCollapse(this, false); }
/** * Returns currently selected UI element, or null if none selected. * * @return Currently selected element (may be null). */ private ElementUI selectedElement() { return getElement(tree.getSelectedNode()); }
/** * Causes a new tree node to be selected and the display state to be updated. * * @param node = Item to be selected. */ private void selectNode(Treenode node) { tree.setSelectedNode(node); selectionChanged(); }
private void expandOrCollapse(BaseComponent parent, boolean collapse) { for (BaseComponent child : parent.getChildren()) { ((Treenode) child).setCollapsed(collapse); expandOrCollapse(child, collapse); } }
/** * Move the selected tree node up one level. */ @EventHandler(value = "click", target = "@btnUp") private void onClick$btnUp() { Treenode node = tree.getSelectedNode(); Treenode sib = (Treenode) node.getPreviousSibling(); swap(sib, node); }
/** * Refresh a subtree of the component tree. Called recursively. * * @param root Root UI element of the subtree. * @param parentNode Tree node that will be the parent node of the subtree. * @param selectedElement The currently selected element. */ private void buildTree(ElementBase root, Treenode parentNode, ElementBase selectedElement) { Treenode node = createNode(root); node.setParent(parentNode == null ? tree : parentNode); if (root == selectedElement) { tree.setSelectedNode(node); } for (ElementBase child : root.getChildren()) { buildTree(child, node, selectedElement); } }
/** * Move the selected tree node down one level. */ @EventHandler(value = "click", target = "@btnDown") private void onClick$btnDown() { Treenode node = tree.getSelectedNode(); Treenode sib = (Treenode) node.getNextSibling(); swap(node, sib); }