private void enableTreeNode(TreeNode treeNode) { if (!treeNode.isEnabled()) { treeNode.setEnabled(true); // recursevely call the enable on parent nodes, until the whole path is enabled if (treeNode.getParent() != null) { enableTreeNode(treeNode.getParent()); } } }
private void removeParentNode(TreeNode parentNode) { TreeNode superParentNode = parentNode.getParent(); if (superParentNode != null) { superParentNode.removeChild(parentNode); if (!superParentNode.hasChildNodes()) removeParentNode(superParentNode); } }
private void disableTreeNode(TreeNode treeNode) { if (treeNode.isEnabled()) { boolean isAnyChildEnabled = false; Collection<TreeNode> childNodes = treeNode.getChildNodes(); if (childNodes != null) { for (TreeNode childNode : childNodes) { if (childNode.isEnabled()) { isAnyChildEnabled = true; break; } } } // if none of the childs are enabled, disable the parent if (!isAnyChildEnabled) { treeNode.setEnabled(false); // recursevely call the disable on parent nodes if (treeNode.getParent() != null) { disableTreeNode(treeNode.getParent()); } } } }