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.core.domutil;
015:
016: import org.w3c.dom.Element;
017: import org.w3c.dom.Node;
018:
019: /**
020: * Represents a pattern based DOM tree with a removable root. This structure
021: * may be seen as a tree node list with none or only one tree node.
022: *
023: * <p>The starting point is a root DOM tree node, this node
024: * is saved as the pattern (really a deep clone). This pattern is used
025: * to recreate the root node (the root may be removed).</p>
026: *
027: * <p>The initial root tree node may be initially removed
028: * or kept as is when this tree is created and attached to the underlying DOM.</p>
029: *
030: * @author Jose Maria Arranz Santamaria
031: * @see org.itsnat.core.ItsNatDocument#createElementTree(boolean,Element,boolean,ElementTreeNodeStructure,ElementTreeNodeRenderer)
032: */
033: public interface ElementTree extends ElementGroup {
034: /**
035: * Returns the current structure defined in this tree.
036: *
037: * @return the current structure.
038: * @see #setElementTreeNodeStructure(ElementTreeNodeStructure)
039: */
040: public ElementTreeNodeStructure getElementTreeNodeStructure();
041:
042: /**
043: * Sets the structure defined in this tree.
044: *
045: * @param structure the new structure.
046: * @see #getElementTreeNodeStructure()
047: */
048: public void setElementTreeNodeStructure(
049: ElementTreeNodeStructure structure);
050:
051: /**
052: * Returns the current renderer defined in this tree.
053: *
054: * @return the current renderer.
055: * @see #setElementTreeNodeRenderer(ElementTreeNodeRenderer)
056: */
057: public ElementTreeNodeRenderer getElementTreeNodeRenderer();
058:
059: /**
060: * Sets the renderer defined in this tree.
061: *
062: * @param renderer the new renderer.
063: * @see #getElementTreeNodeRenderer()
064: */
065: public void setElementTreeNodeRenderer(
066: ElementTreeNodeRenderer renderer);
067:
068: /**
069: * Returns the element used as a pattern. This element is a clone of the
070: * original root node parent element used as a pattern.
071: *
072: * @return the pattern element.
073: */
074: public Element getRootPatternElement();
075:
076: /**
077: * Informs whether the current tree has a root tree node (not empty).
078: *
079: * @return true if the tree has a root tree node.
080: * @see #getRootNode()
081: */
082: public boolean hasTreeNodeRoot();
083:
084: /**
085: * Returns the root tree node.
086: *
087: * @return the root tree node or null if the tree is empty.
088: * @see #addRootNode()
089: * @see #removeRootNode()
090: */
091: public ElementTreeNode getRootNode();
092:
093: /**
094: * Adds a root tree node. If the tree already has a root node an exception is thrown.
095: *
096: * <p>The new tree node uses the current structure and renderer of the tree.</p>
097: *
098: * @return the new root node.
099: * @see #getRootNode()
100: * @see #removeRootNode()
101: */
102: public ElementTreeNode addRootNode();
103:
104: /**
105: * Adds a root tree node and renders the value using the
106: * current structure and renderer.
107: * If the tree already has a root node an exception is thrown.
108: *
109: * @return the new root node.
110: * @see #addRootNode()
111: * @see #getElementTreeNodeStructure()
112: * @see #getElementTreeNodeRenderer()
113: */
114: public ElementTreeNode addRootNode(Object value);
115:
116: /**
117: * Removes the current root tree node. If the tree has no root does nothing.
118: *
119: * @see #getRootNode()
120: * @see #addRootNode()
121: */
122: public void removeRootNode();
123:
124: /**
125: * Returns the tree node at the specified row position seeing the tree as a list (root node is 0).
126: *
127: * @param row the row position.
128: * @return the tree node at the specified position or null if the tree is empty or row is out of bounds.
129: */
130: public ElementTreeNode getElementTreeNodeFromRow(int row);
131:
132: /**
133: * Returns the tree node containing the specified node.
134: *
135: * @param node the node to search for.
136: * @return the tree node containing the specified node. Null if not contained by this tree.
137: */
138: public ElementTreeNode getElementTreeNodeFromNode(Node node);
139:
140: /**
141: * Informs whether the original (saved as pattern) markup is used to render.
142: *
143: * <p>The default value is defined by {@link org.itsnat.core.ItsNatDocument#isUsePatternMarkupToRender()}</p>
144: *
145: * @return true if the original markup is used.
146: * @see #setUsePatternMarkupToRender(boolean)
147: */
148: public boolean isUsePatternMarkupToRender();
149:
150: /**
151: * Sets whether the original (saved as pattern) markup is used to render.
152: *
153: * @param value true to enable the use of original markup to render.
154: * @see #isUsePatternMarkupToRender()
155: */
156: public void setUsePatternMarkupToRender(boolean value);
157: }
|