1 package com.sri.common.taglib; 2 3 /*** 4 * <tt>Composite</tt> Tree Node interface. Allows for iterating children (if any) 5 * and all information needed to render the tree node. 6 * 7 * @author Michael Rimov 8 */ 9 public interface TreeNode { 10 11 /*** 12 * If there are no children then getNested() returns NO_CHILDREN which 13 * is a <tt>Special Case</tt> of no children nodes. 14 */ 15 TreeNode[] NO_CHILDREN = new TreeNode[0]; 16 17 /*** 18 * Retrieve the Label of the tree node. 19 * 20 * @return String the label 21 */ 22 String getLabel(); 23 24 /*** 25 * Retrieve the link if the node is clicked. 26 * 27 * @return String url for the link of the node. 28 */ 29 String getLink(); 30 31 32 /*** 33 * Retrieve the CSS style for the node when it is selected. (Or for folders, 34 * when its children are selected or it is open) 35 * 36 * @return String 37 */ 38 String getSelectedStyle(); 39 40 /*** 41 * Retrieve the CSS style for the node when it is unselected. (Or for 42 * folders, when it is closed) 43 * 44 * @return String 45 */ 46 String getUnselectedStyle(); 47 48 /*** 49 * Retrieve all children (may be an empty array) if no children. 50 * 51 * @return TreeNode[] or TreeNode.NO_CHILDREN if there are none. 52 */ 53 TreeNode[] getNested(); 54 55 /*** 56 * Retrieve url of the icon associated with the node. This is 57 * optional, and if it is set, the image tag will be set inside 58 * the <a> tag. 59 * 60 * @return String 61 */ 62 String getIconUrl(); 63 64 /*** 65 * Returns true if this node is selected. If it is a folder node, 66 * then it should normally appear open as well. 67 * 68 * @return true if it or its children are selected. 69 */ 70 boolean isSelected(); 71 72 /*** 73 * Manipulator that sets the selected value to true. Expected behavior 74 * is that when something is selected, all parents are selected. If something 75 * is de-selected, then all parents are de-selected. 76 * 77 * @param selectionValue true if the value should be selected. 78 */ 79 void setSelected(boolean selectionValue); 80 81 /*** 82 * Expands all folder nodes by marking them selected without marking 83 * any leaf nodes necessarily selected. 84 */ 85 void expandAllFolders(); 86 87 /*** 88 * Collapses all folders by marking the root node as unselected. 89 */ 90 void collapseAllFolders(); 91 92 }