001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.comp.ui;
015:
016: import org.itsnat.comp.ItsNatTree;
017: import javax.swing.tree.RowMapper;
018: import javax.swing.tree.TreePath;
019: import org.w3c.dom.Element;
020: import org.w3c.dom.Node;
021:
022: /**
023: * Is the base interface of the User Interface of a tree component.
024: *
025: * <p>Tree nodes are managed using the current tree structure
026: * and renderer.</p>
027: *
028: * <p>Current implementation uses the tree data model when necessary and relays heavily on
029: * {@link org.itsnat.core.domutil.ElementTree} and related interfaces/objects.</p>
030: *
031: * <p>If the tree is rootless there is no markup to the root, method calls
032: * like <code>getParentElementFromRow(0)</code> returns null.</p>
033: *
034: * <p>Current implementation does not use the data model </p>
035: *
036: * @author Jose Maria Arranz Santamaria
037: * @see ItsNatTree#getItsNatTreeUI()
038: * @see ItsNatTree#getItsNatTreeCellRenderer()
039: * @see ItsNatTree#getItsNatTreeStructure()
040: */
041: public interface ItsNatTreeUI extends ItsNatElementComponentUI {
042: /**
043: * Returns the associated component object.
044: *
045: * @return the component object.
046: */
047: public ItsNatTree getItsNatTree();
048:
049: /**
050: * Adds a root tree node and renders the value using the
051: * current structure and renderer.
052: *
053: * <p>If the tree already has a root node an exception is thrown.</p>
054: *
055: * @param dataNodeRoot the data value of the new root node.
056: * @see org.itsnat.core.domutil.ElementTree#addRootNode()
057: */
058: public void addRootNode(Object dataNodeRoot);
059:
060: /**
061: * Removes the current root tree node, if the tree is empty does nothing.
062: * If the tree is rootless the tree is completely removed.
063: *
064: * @see org.itsnat.core.domutil.ElementTree#removeRootNode()
065: */
066: public void removeRootNode();
067:
068: /**
069: * Inserts a new child tree node at the specified position below the parent tree node
070: * specified by its path.
071: *
072: * @param index 0 based index of the new tree node relative to the parent.
073: * @param parentPath the path of the parent tree node.
074: * @see org.itsnat.core.domutil.ElementTreeNodeList#insertTreeNodeAt(int,Object)
075: */
076: public void insertTreeNodeAt(int index, TreePath parentPath);
077:
078: /**
079: * Inserts a new child tree node at the position specified by its path.
080: *
081: * @param path path of the new tree node.
082: * @see #insertTreeNodeAt(int,TreePath)
083: */
084: public void insertTreeNodeAt(TreePath path);
085:
086: /**
087: * Removes the child tree node specified by its index relative to the tree node parent
088: * specified by its path.
089: *
090: * @param index 0 based index of the child tree node to remove.
091: * @param parentPath the path of the parent tree node.
092: * @see org.itsnat.core.domutil.ElementTreeNodeList#removeTreeNodeAt(int)
093: */
094: public void removeTreeNodeAt(int index, TreePath parentPath);
095:
096: /**
097: * Removes the child tree node specified by its path.
098: *
099: * @param path path of the tree node to remove.
100: * @see #removeTreeNodeAt(int,TreePath)
101: */
102: public void removeTreeNodeAt(TreePath path);
103:
104: /**
105: * Removes all tree nodes below the specified parent tree node by its path.
106: *
107: * @param parentPath the path of the parent tree node.
108: */
109: public void removeAllChildTreeNodes(TreePath parentPath);
110:
111: /**
112: * Renders the submitted data value of the child tree node specified
113: * by its index relative to the tree node parent specified by its path.
114: *
115: * @param index 0 based index of the child tree node to render.
116: * @param parentPath the path of the parent tree node.
117: * @param hasFocus if this child tree node has the focus. Current ItsNat implementation ever passes false.
118: * @see org.itsnat.core.domutil.ElementTreeNode#setValue(Object)
119: */
120: public void setTreeNodeValueAt(int index, TreePath parentPath,
121: boolean hasFocus);
122:
123: /**
124: * Renders the submitted data value of the tree node specified by its path.
125: *
126: * @param path path of the tree node.
127: * @param hasFocus if this child tree node has the focus. Current ItsNat implementation ever passes false.
128: * @see #setTreeNodeValueAt(int,TreePath,boolean)
129: */
130: public void setTreeNodeValueAt(TreePath path, boolean hasFocus);
131:
132: /**
133: * Returns the parent element of the tree node at the specified row position seeing the tree as a list (root node is 0).
134: *
135: * @param row the row position.
136: * @return the parent element of the tree node at the specified position or null if the tree is empty or row is out of bounds.
137: * @see ItsNatTreeCellUI#getParentElement()
138: * @see org.itsnat.core.domutil.ElementGroup#getParentElement()
139: */
140: public Element getParentElementFromRow(int row);
141:
142: /**
143: * Returns the content element of the tree node at the specified row position seeing the tree as a list (root node is 0).
144: *
145: * @param row the row position.
146: * @return the content element of the tree node at the specified position or null if the tree is empty or row is out of bounds.
147: * @see ItsNatTreeCellUI#getContentElement()
148: * @see org.itsnat.comp.ItsNatTreeStructure#getContentElement(ItsNatTree,int,Element)
149: * @see org.itsnat.core.domutil.ElementTreeNode#getContentElement()
150: */
151: public Element getContentElementFromRow(int row);
152:
153: /**
154: * Returns the handle element of the tree node at the specified row position seeing the tree as a list (root node is 0).
155: *
156: * @param row the row position.
157: * @return the handle element of the tree node at the specified position or null if the tree is empty or row is out of bounds.
158: * @see ItsNatTreeCellUI#getHandleElement()
159: * @see org.itsnat.comp.ItsNatTreeStructure#getHandleElement(ItsNatTree,int,Element)
160: * @see org.itsnat.core.domutil.ElementTreeNode#getHandleElement()
161: */
162: public Element getHandleElementFromRow(int row);
163:
164: /**
165: * Returns the icon element of the tree node at the specified row position seeing the tree as a list (root node is 0).
166: *
167: * @param row the row position.
168: * @return the icon element of the tree node at the specified position or null if the tree is empty or row is out of bounds.
169: * @see ItsNatTreeCellUI#getIconElement()
170: * @see org.itsnat.comp.ItsNatTreeStructure#getIconElement(ItsNatTree,int,Element)
171: * @see org.itsnat.core.domutil.ElementTreeNode#getIconElement()
172: */
173: public Element getIconElementFromRow(int row);
174:
175: /**
176: * Returns the label element of the tree node at the specified row position seeing the tree as a list (root node is 0).
177: *
178: * @param row the row position.
179: * @return the label element of the tree node at the specified position or null if the tree is empty or row is out of bounds.
180: * @see ItsNatTreeCellUI#getLabelElement()
181: * @see org.itsnat.comp.ItsNatTreeStructure#getLabelElement(ItsNatTree,int,Element)
182: * @see org.itsnat.core.domutil.ElementTreeNode#getLabelElement()
183: */
184: public Element getLabelElementFromRow(int row);
185:
186: /**
187: * Returns the parent element of the tree node specified by the tree path.
188: *
189: * @param path the tree node path.
190: * @return the parent element of the tree node.
191: * @see #getParentElementFromRow(int)
192: */
193: public Element getParentElementFromTreePath(TreePath path);
194:
195: /**
196: * Returns the content element of the tree node specified by the tree path.
197: *
198: * @param path the tree node path.
199: * @return the content element of the tree node.
200: * @see #getContentElementFromRow(int)
201: */
202: public Element getContentElementFromTreePath(TreePath path);
203:
204: /**
205: * Returns the handle element of the tree node specified by the tree path.
206: *
207: * @param path the tree node path.
208: * @return the handle element of the tree node.
209: * @see #getHandleElementFromRow(int)
210: */
211: public Element getHandleElementFromTreePath(TreePath path);
212:
213: /**
214: * Returns the icon element of the tree node specified by the tree path.
215: *
216: * @param path the tree node path.
217: * @return the icon element of the tree node.
218: * @see #getIconElementFromRow(int)
219: */
220: public Element getIconElementFromTreePath(TreePath path);
221:
222: /**
223: * Returns the label element of the tree node specified by the tree path.
224: *
225: * @param path the tree node path.
226: * @return the label element of the tree node.
227: * @see #getLabelElementFromRow(int)
228: */
229: public Element getLabelElementFromTreePath(TreePath path);
230:
231: /**
232: * Returns the object info of the tree node at the specified row position seeing the tree as a list (root node is 0).
233: *
234: * @param row the row position.
235: * @return the object info of the tree node at the specified position or null
236: * if the tree is empty or row is out of bounds.
237: * This object is ever the same per tree node and may be used to save any context data.
238: * @see org.itsnat.core.domutil.ElementTree#getElementTreeNodeFromRow(int)
239: */
240: public ItsNatTreeCellUI getItsNatTreeCellUIFromRow(int row);
241:
242: /**
243: * Returns the object info of the tree node specified by the tree path.
244: *
245: * @param path the tree node path.
246: * @return the object info of the tree node.
247: * This object is ever the same per tree node and may be used to save any context data.
248: * @see #getItsNatTreeCellUIFromRow(int)
249: */
250: public ItsNatTreeCellUI getItsNatTreeCellUIFromTreePath(
251: TreePath path);
252:
253: /**
254: * Returns the object info of the tree node containing the specified node.
255: *
256: * @param node the node to search for.
257: * @return the tree node containing the specified node. Null if not contained by this tree.
258: * This object is ever the same per tree node and may be used to save any context data.
259: * @see org.itsnat.core.domutil.ElementTree#getElementTreeNodeFromNode(Node)
260: */
261: public ItsNatTreeCellUI getItsNatTreeCellUIFromNode(Node node);
262:
263: /**
264: * Informs whether the original (saved as pattern) markup is used to render.
265: *
266: * <p>The default value is defined by {@link org.itsnat.core.ItsNatDocument#isUsePatternMarkupToRender()}</p>
267: *
268: * @return true if the original markup is used.
269: * @see #setUsePatternMarkupToRender(boolean)
270: */
271: public boolean isUsePatternMarkupToRender();
272:
273: /**
274: * Sets whether the original (saved as pattern) markup is used to render.
275: *
276: * @param value true to enable the use of original markup to render.
277: * @see #isUsePatternMarkupToRender()
278: */
279: public void setUsePatternMarkupToRender(boolean value);
280: }
|