001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.wicket.markup.html.tree;
018:
019: import java.util.Collection;
020:
021: import javax.swing.tree.TreeNode;
022:
023: /**
024: * Tree state holds information about a tree such as which nodes are expanded /
025: * collapsed and which nodes are selected, It can also fire callbacks on
026: * listener in case any of the information changed.
027: *
028: * @author Matej Knopp
029: */
030: public interface ITreeState {
031: /**
032: * Adds a tree state listener. On state change events on the listener are
033: * fired.
034: *
035: * @param l
036: * Listener to add
037: */
038: void addTreeStateListener(ITreeStateListener l);
039:
040: /**
041: * Collapses all nodes of the tree.
042: */
043: void collapseAll();
044:
045: /**
046: * Collapses the given node.
047: *
048: * @param node
049: * Node to collapse
050: */
051: void collapseNode(TreeNode node);
052:
053: /**
054: * Expands all nodes of the tree.
055: */
056: void expandAll();
057:
058: /**
059: * Expands the given node.
060: *
061: * @param node
062: * Node to expand
063: */
064: void expandNode(TreeNode node);
065:
066: /**
067: * Returns the collection of all selected nodes.
068: *
069: * @return The collection of selected nodes
070: */
071: Collection getSelectedNodes();
072:
073: /**
074: * Returns whether multiple nodes can be selected.
075: *
076: * @return True if mutliple nodes can be selected
077: */
078: boolean isAllowSelectMultiple();
079:
080: /**
081: * Returns true if the given node is expanded.
082: *
083: * @param node
084: * The node to inspect
085: * @return True if the node is expanded
086: */
087: boolean isNodeExpanded(TreeNode node);
088:
089: /**
090: * Returns true if the given node is selected, false otherwise.
091: *
092: * @param node
093: * The node to inspect
094: * @return True if the node is selected
095: */
096: boolean isNodeSelected(TreeNode node);
097:
098: /**
099: * Removes a tree state listener.
100: *
101: * @param l
102: * The listener to remove
103: */
104: void removeTreeStateListener(ITreeStateListener l);
105:
106: /**
107: * Marks given node as selected (or unselected) according to the selected
108: * value.
109: * <p>
110: * If tree is in single selection mode and a new node is selected, old node
111: * is automatically unselected (and the event is fired on listeners).
112: *
113: * @param node
114: * The node to select or deselect
115: * @param selected
116: * If true, the node will be selected, otherwise, the node will
117: * be unselected
118: */
119: void selectNode(TreeNode node, boolean selected);
120:
121: /**
122: * Sets whether multiple nodes can be selected.
123: *
124: * @param value
125: * If true, multiple nodes can be selected. If false, only one
126: * node at a time can be selected
127: */
128: void setAllowSelectMultiple(boolean value);
129: }
|