Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java?rev=696555&r1=696554&r2=696555&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/WikiTagBase.java Wed Sep 17 20:17:43 2008 @@ -86,7 +86,7 @@ * [EMAIL PROTECTED] com.ecyrd.jspwiki.action.WikiActionBeanFactory#findActionBean(javax.servlet.ServletRequest)}. * (That method retrieves the WikiActionBean from page scope.). * If the WikiActionBean is a WikiContext, a specific reference to the WikiContext - * will be set also. Both of these available as protected fields [EMAIL PROTECTED] #m_actionBean} and + * will be set also. Both of these available as protected fields [EMAIL PROTECTED] #m_wikiActionBean} and * [EMAIL PROTECTED] #m_wikiContext}, respectively. It is considered an error condition if the * WikiActionBean cannot be retrieved from the PageContext. * It's also an error condition if the WikiActionBean is actually a WikiContext, and it
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/url/StripesURLConstructor.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/url/StripesURLConstructor.java?rev=696555&r1=696554&r2=696555&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/url/StripesURLConstructor.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/url/StripesURLConstructor.java Wed Sep 17 20:17:43 2008 @@ -75,13 +75,12 @@ * ActionBean class is not a WikiContext subclass, the value of the * <code>page</code> parameter is ignored. * - * @param beanClass the WikiActionBean subclass to use - * @param page the wiki page; if <code>null</code>, the front page will - * be used - * @param params the query parameters to append to the end of the URL; may - * be <code>null</code> if no parameters + * @param context the wiki request context to use + * @param name the target of the action, typically the wiki page * @param absolute If <code>true</code>, will generate an absolute URL * regardless of properties setting. + * @param parameters the query parameters to append to the end of the URL; may + * be <code>null</code> if no parameters * @return the URL */ @Override Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java?rev=696555&r1=696554&r2=696555&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/AbstractNode.java Wed Sep 17 20:17:43 2008 @@ -39,54 +39,31 @@ m_type = type; } - /* - * (non-Javadoc) - * + /** * @see com.ecyrd.jspwiki.ui.stripes.Node#addChild(com.ecyrd.jspwiki.ui.stripes.Node) */ public void addChild( Node node ) { // Set parent/child relationships node.setParent( this ); + + // Add the node m_children.add( node ); + } - // If this node is a "combined node," split it into two - if( m_type == NodeType.HTML_COMBINED_TAG ) - { - // Check that this node has a parent - if( m_parent == null ) - { - throw new IllegalStateException( "Node has no parent!" ); - } - - // Change node type to start tag - m_type = NodeType.HTML_START_TAG; - - // Build new end tag & set its parent - Tag endNode = new Tag( m_doc, NodeType.HTML_END_TAG ); - endNode.setName( m_name ); - // FIXME - // endNode.setText( NodeType.HTML_END_TAG.getTagEnd() + m_name + - // NodeType.HTML_END_TAG.getTagEnd() ); - endNode.setParent( m_parent ); - - // Insert as sibling of this node - List<Node> siblings = m_parent.getChildren(); - int index = siblings.indexOf( this ); - if( index == siblings.size() - 1 ) - { - siblings.add( endNode ); - } - else - { - siblings.add( index, endNode ); - } - } + /** + * @see com.ecyrd.jspwiki.ui.stripes.Node#addChild(Node, int) + */ + public void addChild( Node node, int index ) + { + // Set parent/child relationships + node.setParent( this ); + + // Add the node + m_children.add( index, node ); } - /* - * (non-Javadoc) - * + /** * @see com.ecyrd.jspwiki.ui.stripes.Node#getChildren() */ public List<Node> getChildren() Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Node.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Node.java?rev=696555&r1=696554&r2=696555&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Node.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Node.java Wed Sep 17 20:17:43 2008 @@ -14,20 +14,21 @@ public abstract JspDocument getJspDocument(); /** - * Adds a child to the current AbstractNode. If the AbstractNode is of type - * [EMAIL PROTECTED] NodeType#HTML_COMBINED_TAG}, the tag will be split into two nodes - * (start tag and end tag), with the child AbstractNode inserted between the two. + * Adds a child to the current Node. * * @param node the node to insert - * @param value the node to insert in between the split nodes - * @throws IllegalArgumentException if the supplied node to split is not of - * type [EMAIL PROTECTED] NodeType#HTML_START_TAG}, - * [EMAIL PROTECTED] NodeType#HTML_START_TAG} or - * [EMAIL PROTECTED] NodeType#HTML_COMBINED_TAG} - * @throws IllegalStateException if the current AbstractNode must be split, and does - * not have a parent. */ public abstract void addChild( Node node ); + + /** + * Adds a child to the current Node before a specified position + * in the list of children. If the position is 0, the Node will be + * inserted before the first child. + * + * @param node the node to insert + * @param index the position to insert the Node into + */ + public abstract void addChild( Node node, int index ); /** * Returns the child nodes of this node, as a defensive copy of the Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Tag.java URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Tag.java?rev=696555&r1=696554&r2=696555&view=diff ============================================================================== --- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Tag.java (original) +++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/tests/com/ecyrd/jspwiki/ui/stripes/Tag.java Wed Sep 17 20:17:43 2008 @@ -15,11 +15,10 @@ private List<Attribute> m_attributes = new ArrayList<Attribute>(); /** - * * @param doc the parent JspDocument * @param type */ - public Tag ( JspDocument doc, NodeType type ) + public Tag( JspDocument doc, NodeType type ) { super( doc, type ); } @@ -104,33 +103,109 @@ sb.append( getValue() ); sb.append( "\"]" ); - return sb.toString(); } - - public String getValue() + return sb.toString(); + } + + /** + * Adds a child to the current Node. If the Node is of type + * [EMAIL PROTECTED] NodeType#HTML_COMBINED_TAG}, the tag will be split into two nodes + * (start tag and end tag), with the child Node inserted between the two. + * + * @param node the node to insert + * @param value the node to insert in between the split nodes + * @throws IllegalStateException if the current Node must be split, and does + * not have a parent. + */ + public void addChild( Node node ) { - if ( m_type != NodeType.HTML_START_TAG ) + if( m_children.size() == 0 ) + { + addChild( node, 0 ); + } + else + { + super.addChild( node ); + } + } + + /** + * Adds a child to the current Node before a specified position in the list + * of children. If the position is 0, the Node will be inserted before the + * first child. If the Node is of type [EMAIL PROTECTED] NodeType#HTML_COMBINED_TAG}, + * the tag will be split into two nodes (start tag and end tag), with the + * child Node inserted between the two. + * + * @param node the node to insert + * @param index the position to insert the Node into + * @throws IllegalStateException if the current Node must be split, and does + * not have a parent. + */ + public void addChild( Node node, int index ) + { + if( m_parent == null ) + { + throw new IllegalStateException( "Node does not have a parent!" ); + } + + // If this node is a "combined node," split it into two + if( m_type == NodeType.HTML_COMBINED_TAG ) + { + // Change node type to start tag + m_type = NodeType.HTML_START_TAG; + + // Build new end tag & set its parent + Tag endNode = new Tag( m_doc, NodeType.HTML_END_TAG ); + endNode.setName( m_name ); + + // FIXME + // endNode.setText( NodeType.HTML_END_TAG.getTagEnd() + m_name + + // NodeType.HTML_END_TAG.getTagEnd() ); + endNode.setParent( m_parent ); + + // Insert as sibling of this node + List<Node> siblings = m_parent.getChildren(); + int startTagPos = siblings.indexOf( this ); + if( startTagPos == siblings.size() - 1 ) + { + m_parent.addChild( endNode ); + } + else + { + m_parent.addChild( endNode, startTagPos + 1 ); + } + } + else + { + super.addChild( node, index ); + } + } + + public String getValue() + { + if( m_type != NodeType.HTML_START_TAG ) { return null; } return super.getValue(); } - + /** - * Returns the string that represents the Tag, including the name and attributes, but not any child nodes. + * Returns the string that represents the Tag, including the name and + * attributes, but not any child nodes. */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append( m_type.getTagStart() ); - + // HTML nodes and JSP directives are formatted in mostly the same way. - if ( isHtmlNode() || m_type == NodeType.JSP_DIRECTIVE ) + if( isHtmlNode() || m_type == NodeType.JSP_DIRECTIVE ) { - if ( m_type == NodeType.JSP_DIRECTIVE ) + if( m_type == NodeType.JSP_DIRECTIVE ) { sb.append( ' ' ); } - sb.append( m_name ); + sb.append( m_name ); if( m_attributes.size() > 0 ) { for( Attribute attr : m_attributes ) @@ -140,15 +215,16 @@ } } } - + // Everything else is just the start/end tags plus the children nodes - else { - for ( Node child : m_children ) + else + { + for( Node child : m_children ) { sb.append( child.toString() ); } } - + sb.append( m_type.getTagEnd() ); return sb.toString(); }
