### Eclipse Workspace Patch 1.0 #P org.jboss.tools.jsf.vpe.jsf Index: src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java =================================================================== --- src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/jsf/template/JsfFacet.java (working copy) @@ -10,13 +10,21 @@ ******************************************************************************/ package org.jboss.tools.jsf.vpe.jsf.template; +import java.util.List; + +import org.jboss.tools.jsf.vpe.jsf.template.util.JSF; +import org.jboss.tools.jst.web.tld.TaglibData; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; +import org.jboss.tools.vpe.editor.util.XmlUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; +import org.mozilla.interfaces.nsIDOMNode; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -34,53 +42,64 @@ * .vpe.editor.context.VpePageContext, org.w3c.dom.Node, * org.mozilla.interfaces.nsIDOMDocument) */ - public VpeCreationData create(VpePageContext pageContext, Node sourceNode, - nsIDOMDocument visualDocument) { - nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV); - VpeCreationData creationData = new VpeCreationData(div); - NodeList children = sourceNode.getChildNodes(); - boolean jsfComponentFound = false; - /* - * Only one JSF component may be present inside a facet tag, if more are - * present only the first one is rendered and the other ones are - * ignored. - */ - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); -// String sourcePrefix = child.getPrefix(); -// if (XmlUtil.hasTaglib(sourceNode, pageContext, sourcePrefix)) { -// String sourceNodeUri = XmlUtil.getTaglibUri(sourceNode, pageContext, sourcePrefix); - if( ((child.getNodeType()==Node.TEXT_NODE) && - (child.getNodeValue()!=null) - && (child.getNodeValue().trim().length()>0) - ) ||(child.getNodeType() == Node.ELEMENT_NODE)) { - VpeChildrenInfo childrenInfo = new VpeChildrenInfo(div); - childrenInfo.addSourceChild(child); - creationData.addChildrenInfo(childrenInfo); - jsfComponentFound = true; - break; + public VpeCreationData create(VpePageContext pageContext, Node sourceNode, + nsIDOMDocument visualDocument) { + Element sourceElement = (Element) sourceNode; + Node facetParent = null; + nsIDOMElement facetVisualTag = null; + + NodeList children = sourceNode.getChildNodes(); + boolean jsfComponentFound = false; + + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * By rendering facet to existed visual node + * we avoid unwarranted tag creation for facet element. + */ + facetParent = sourceNode.getParentNode(); + nsIDOMNode facetParentVisualTag = pageContext.getDomMapping().getVisualNode(facetParent); + facetVisualTag = VisualDomUtil.findVisualTagWithFacetAttribute( + facetParentVisualTag, sourceElement.getAttribute(JSF.ATTR_NAME)); + /* + * When no tag found use 'SPAN' tag by default. + * So facet will be rendered in any case. + */ + if (null == facetVisualTag) { + facetVisualTag = visualDocument.createElement(HTML.TAG_SPAN); } - //commented by Maksim Areshkau as fix for https://jira.jboss.org/jira/browse/JBIDE-5744 -// if ((child.getNodeType() == Node.ELEMENT_NODE)){ -//// && (VisualDomUtil.JSF_CORE_URI.equalsIgnoreCase(sourceNodeUri) -//// || VisualDomUtil.JSF_HTML_URI.equalsIgnoreCase(sourceNodeUri) -//// || VisualDomUtil.RICH_FACES_URI.equalsIgnoreCase(sourceNodeUri) -//// || VisualDomUtil.A4J_URI.equalsIgnoreCase(sourceNodeUri) -//// || VisualDomUtil.FACELETS_URI.equalsIgnoreCase(sourceNodeUri))) { -// VpeChildrenInfo childrenInfo = new VpeChildrenInfo(div); -// childrenInfo.addSourceChild(child); -// creationData.addChildrenInfo(childrenInfo); -// jsfComponentFound = true; -// break; -//// } -// } - } - - if (!jsfComponentFound) { - div.setAttribute(HTML.ATTR_STYLE, "display: none; "); //$NON-NLS-1$ - creationData.addChildrenInfo(new VpeChildrenInfo(div)); - } - - return creationData; + + VpeCreationData creationData = new VpeCreationData(facetVisualTag); + /* + * Only one JSF component may be present inside a facet tag, if more are + * present only the first one is rendered and the other ones are + * ignored. + */ + for (int i = children.getLength() - 1; i >= 0 ; i--) { + Node child = children.item(i); + String sourcePrefix = child.getPrefix(); + List taglibs = XmlUtil.getTaglibsForNode(sourceNode, + pageContext); + TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix( + sourcePrefix, taglibs); + if (null != sourceNodeTaglib) { + String sourceNodeUri = sourceNodeTaglib.getUri(); + if (VisualDomUtil.JSF_CORE_URI.equalsIgnoreCase(sourceNodeUri) + || VisualDomUtil.JSF_HTML_URI.equalsIgnoreCase(sourceNodeUri) + || VisualDomUtil.RICH_FACES_URI.equalsIgnoreCase(sourceNodeUri) + || VisualDomUtil.A4J_URI.equalsIgnoreCase(sourceNodeUri) + || VisualDomUtil.FACELETS_URI.equalsIgnoreCase(sourceNodeUri)) { + VpeChildrenInfo childrenInfo = new VpeChildrenInfo(facetVisualTag); + childrenInfo.addSourceChild(child); + creationData.addChildrenInfo(childrenInfo); + jsfComponentFound = true; + break; + } + } + } + if (!jsfComponentFound) { + facetVisualTag.setAttribute(HTML.ATTR_STYLE, "display: none; "); //$NON-NLS-1$ + creationData.addChildrenInfo(new VpeChildrenInfo(facetVisualTag)); + } + return creationData; } } #P org.jboss.tools.vpe Index: src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java =================================================================== --- src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java (working copy) @@ -98,7 +98,12 @@ public static final String PARENT = "PARENT"; //$NON-NLS-1$ public static final String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$ public static final String VPE_USER_TOGGLE_LOOKUP_PARENT = "vpe-user-toggle-lookup-parent"; //$NON-NLS-1$ - + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * Attribute that specifies the place where JSF facet should be rendered. + */ + public static final String VPE_FACET = "VPE-FACET"; //$NON-NLS-1$ + private static final String PSEUDO_ELEMENT = "br"; //$NON-NLS-1$ private static final String PSEUDO_ELEMENT_ATTR = "vpe:pseudo-element"; //$NON-NLS-1$ private static final String INIT_ELEMENT_ATTR = "vpe:init-element"; //$NON-NLS-1$ @@ -284,8 +289,13 @@ * @param visualContainer visual container, cannot be {@code null} * @return {@code true} if and only if the visual representation is created and added successfully */ - private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode, - nsIDOMNode visualContainer) { + private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode, nsIDOMNode visualContainer) { + if (sourceNode.toString().indexOf("h:outputText/@[1568, 1603] ()") > -1) { + System.out.println("My Out 11"); + } + if (sourceNode.toString().indexOf("h:outputText/@[1153, 1188] ()") > -1) { + System.out.println("My Out 22"); + } try { nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer); // Commented as fix for JBIDE-3012. @@ -299,11 +309,28 @@ // } catch (XPCOMException ex) { // // just ignore this exception // } + if (visualNewNode != null) { - if (visualNextNode == null) { - visualContainer.appendChild(visualNewNode); - } else { - visualContainer.insertBefore(visualNewNode, visualNextNode); + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * Do not add additional visual node for f:facet + * when it is inserted into existing one. + */ + nsIDOMElement element = null; + try { + element = (nsIDOMElement) visualNewNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID); + } catch (org.mozilla.xpcom.XPCOMException e) { + /* + * Cannot parse node to element, + * do nothing + */ + } + if (!((null != element) && element.hasAttribute(VPE_FACET))) { + if (visualNextNode == null) { + visualContainer.appendChild(visualNewNode); + } else { + visualContainer.insertBefore(visualNewNode, visualNextNode); + } } return true; } @@ -688,9 +715,8 @@ if (sourceChildren != null) { for (int j = 0; j < sourceChildren.size(); j++) { Node child = (Node) sourceChildren.get(j); - if ((!isInvisibleNode(child)) - && addNode((Node) sourceChildren.get(j), null, - visualParent)) { + if ((!isInvisibleNode(child)) + && addNode(child, null, visualParent)) { childrenCount++; } } Index: src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java =================================================================== --- src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java (working copy) @@ -20,6 +20,7 @@ import org.jboss.tools.vpe.editor.template.VpeTemplateManager; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; public class SourceDomUtil { private static final Set templatesNamespacesWithRendered=new HashSet(); @@ -91,4 +92,20 @@ } return result; } + + public static Element getFacetByName(Element sourceElement, String facetName) { + Element facetElement = null; + NodeList children = sourceElement.getChildNodes(); + for (int i = 0; i < children.getLength(); i++) { + Node node = children.item(i); + if ((facetName != null) + && (node instanceof Element) + && (node.getNodeName() != null) + && (node.getNodeName().indexOf(":facet") > 0) //$NON-NLS-1$ + && (facetName.equalsIgnoreCase((((Element) node)).getAttribute("name")))) { //$NON-NLS-1$ + facetElement = (Element) node; + } + } + return facetElement; + } } Index: src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java =================================================================== --- src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java (working copy) @@ -11,11 +11,16 @@ package org.jboss.tools.vpe.editor.util; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.eclipse.swt.graphics.Point; +import org.jboss.tools.jst.web.tld.TaglibData; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; +import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; import org.mozilla.interfaces.nsIDOMDocument; @@ -33,6 +38,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.w3c.dom.Text; public class VisualDomUtil { @@ -42,6 +48,10 @@ public static String RICH_FACES_URI = "http://richfaces.org/rich"; //$NON-NLS-1$ public static String A4J_URI = "http://richfaces.org/a4j"; //$NON-NLS-1$ public static String FACELETS_URI = "http://java.sun.com/jsf/facelets"; //$NON-NLS-1$ + + public static String FACET_JSF_TAG = "FACET-JSF-TAG"; //$NON-NLS-1$ + public static String FACET_ODD_TAGS = "FACET-ODD-TAGS"; //$NON-NLS-1$ + public static String FACET_HTML_TAGS = "FACET-HTML-TAGS"; //$NON-NLS-1$ private static final String ACCESSIBILITY_SERVICE_CONTRACT_ID = "@mozilla.org/accessibilityService;1"; //$NON-NLS-1$ // private static Reference accessibilityServiceCache = null; @@ -381,4 +391,149 @@ } return creationData; } + + /** + * Finds visual tag with 'VPE-FACET' attribute in it. + * Facet element should be rendered into this tag. + * + * @param facetsParentNode node for which its facet should be rendered. + * @param facetName facet's name to compare to 'VPE-FACET' attribute value. + * @return found visual tag or 'null' otherwise. + */ + public static nsIDOMElement findVisualTagWithFacetAttribute( + nsIDOMNode facetsParentNode, String facetName) { + + nsIDOMElement tagForFacet = null; + if (null != facetsParentNode) { + nsIDOMNodeList nodeList = facetsParentNode.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + nsIDOMElement element = null; + try { + element = (nsIDOMElement) nodeList.item(i).queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID); + } catch (org.mozilla.xpcom.XPCOMException e) { + /* + * Cannot parse node to element, return null. + */ + return null; + } + /* + * If current tag has 'VPE-FACET' attribute + * with the corresponding facet name. + * Then return this tag. + */ + if (element.hasAttribute(VpeVisualDomBuilder.VPE_FACET)) { + String facetAttributeName = element.getAttribute(VpeVisualDomBuilder.VPE_FACET); + /* + * In some cases there could be several footer in one visual node. + * For instance, header and footer could be in single column cell. + * Thus VPE-FACET can contain several facet names + * separated by whitespace, i.e. "header footer". + */ + if (facetAttributeName.indexOf(facetName) >= 0) { + return element; + } + } + /* + * Else search in children + */ + tagForFacet = findVisualTagWithFacetAttribute(element, facetName); + /* + * When tag is found in children it will be returned + */ + if (null != tagForFacet) { + return tagForFacet; + } + } + } + /* + * If nothing matched return null + */ + return tagForFacet; + } + + /** + * Clarifies JSF facet element's children: JSF tags, other tags, HTML, text. + * (For JSF Facet cannot display more than one JSF component). + * Results are put into the map with keys: + *

'FACET-JSF-TAG' - for suitable JSF element + *

'FACET-ODD-TAGS' - for superfluous elements + *

'FACET-HTML-TAG' - for HTML elements and plain text + * + * @param facet the facet + * @param pageContext the page context + * @return map with arranged elements or empty map if nothing was found. + */ + public static Map> findFacetElements(Node facet, VpePageContext pageContext) { + Map> facetChildren = new HashMap>(); + List jsfTag = new ArrayList(0); + List oddTags = new ArrayList(0); + List htmlTags = new ArrayList(0); + facetChildren.put(FACET_JSF_TAG, jsfTag); + facetChildren.put(FACET_ODD_TAGS, oddTags); + facetChildren.put(FACET_HTML_TAGS, htmlTags); + if (null != facet) { + NodeList children = facet.getChildNodes(); + Node lastJSFComponent = null; + for (int i = 0; i < children.getLength() ; i++) { + Node child = children.item(i); + String sourcePrefix = child.getPrefix(); + List taglibs = XmlUtil.getTaglibsForNode(child, + pageContext); + TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix( + sourcePrefix, taglibs); + /* + * Here will be nodes with taglibs + * Plain html tags and text - will not. + */ + if (null != sourceNodeTaglib) { + String sourceNodeUri = sourceNodeTaglib.getUri(); + if ((JSF_CORE_URI.equalsIgnoreCase(sourceNodeUri) + || JSF_HTML_URI.equalsIgnoreCase(sourceNodeUri) + || RICH_FACES_URI.equalsIgnoreCase(sourceNodeUri) + || A4J_URI.equalsIgnoreCase(sourceNodeUri) + || FACELETS_URI.equalsIgnoreCase(sourceNodeUri))) { + /* + * Mark the correct jsf component + * and add it to the odd list for further correction. + */ + lastJSFComponent = child; + oddTags.add(child); + } else { + /* + * All other tags: JSF, RF, FACELETS, A4J. + */ + oddTags.add(child); + } + } else { + /* + * Plain html and text + */ + if (child instanceof Text) { + /* + * For text nodes we should omit empty strings + */ + Text textNode = (Text) child; + if (textNode.getNodeValue().trim().length() > 0) { + htmlTags.add(child); + } + } else { + /* + * If it is not text then it is normal html tag + */ + htmlTags.add(child); + } + } + } + /* + * Fill the correct JSF component: + * remove it from the odd list and add to the jsf list. + */ + if (null != lastJSFComponent) { + oddTags.remove(lastJSFComponent); + jsfTag.add(lastJSFComponent); + } + } + return facetChildren; + } + } Index: src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java =================================================================== --- src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java (working copy) @@ -192,7 +192,7 @@ // div.appendChild(visualDocument.createTextNode(redundantText)); div.appendChild(outterTable); - if (true || sourceElements.hasTableCaption()) { + if (sourceElements.hasTableCaption()) { caption = visualDocument.createElement(HTML.TAG_CAPTION); if (sourceElements.getTableCaption() != null) { VpeChildrenInfo info = new VpeChildrenInfo(caption); Index: src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java =================================================================== --- src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java (working copy) @@ -15,6 +15,7 @@ import java.util.Map; import org.jboss.tools.vpe.VpePlugin; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.expression.VpeExpression; import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder; @@ -23,6 +24,7 @@ import org.jboss.tools.vpe.editor.template.expression.VpeExpressionInfo; import org.jboss.tools.vpe.editor.template.expression.VpeValue; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.jboss.tools.vpe.editor.util.VpeClassUtil; import org.mozilla.interfaces.nsIDOMAttr; import org.mozilla.interfaces.nsIDOMDocument; @@ -30,7 +32,6 @@ import org.mozilla.interfaces.nsIDOMNode; import org.w3c.dom.Attr; import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -265,6 +266,23 @@ if (tableSize == 0) { tableSize = childrenCount; } + Map> captionFacetChildren = null; + Map> headerFacetChildren = null; + Map> footerFacetChildren = null; + captionFacetChildren = VisualDomUtil.findFacetElements(caption, pageContext); + headerFacetChildren = VisualDomUtil.findFacetElements(header, pageContext); + footerFacetChildren = VisualDomUtil.findFacetElements(footer, pageContext); + /* + * Add additional table cell for odd facet's elements. + */ + boolean captionHtmlElementsPresents = ((null != captionFacetChildren) && (captionFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + boolean headerHtmlElementsPresents = ((null != headerFacetChildren) && (headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + boolean footerHtmlElementsPresents = ((null != footerFacetChildren) && (footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + boolean htmlFacetsElementsPresents = captionHtmlElementsPresents || headerHtmlElementsPresents || footerHtmlElementsPresents; + boolean htmlFacetsElementsRendered = false; + if (htmlFacetsElementsPresents) { + childrenCount++; + } int rowCount = (childrenCount + tableSize - 1) / tableSize; nsIDOMElement visualHead = null; @@ -275,8 +293,7 @@ visualCaption = visualDocument .createElement(HTML.TAG_CAPTION); visualTable.appendChild(visualCaption); - VpeChildrenInfo childrenInfo = new VpeChildrenInfo( - visualCaption); + VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualCaption); childrenInfo.addSourceChild(caption); creatorInfo.addChildrenInfo(childrenInfo); if (captionClassExpr != null @@ -317,8 +334,7 @@ for (int i = 0; i < rowCount; i++) { int cci = 0; // index of column class. Reset on every new row. - nsIDOMElement visualRow = visualDocument - .createElement(HTML.TAG_TR); + nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TR); if (rowClasses.size() > 0) { visualRow.setAttribute(HTML.ATTR_CLASS, rowClasses.get(rci) .toString()); @@ -330,8 +346,7 @@ if (i*tableSize+j >= childrenCount) { break; } - nsIDOMElement visualCell = visualDocument - .createElement(HTML.TAG_TD); + nsIDOMElement visualCell = visualDocument.createElement(HTML.TAG_TD); if (columnClasses.size() > 0) { visualCell.setAttribute(HTML.ATTR_CLASS, columnClasses.get( cci).toString()); @@ -340,27 +355,64 @@ cci = 0; } visualRow.appendChild(visualCell); - int sourceIndex = tableSize * i + j; - if (sourceIndex < childrenCount) { - Node child = sourceChildren[sourceIndex]; - if (child != header && child != footer) { - VpeChildrenInfo childrenInfo = new VpeChildrenInfo( - visualCell); - childrenInfo.addSourceChild(child); - creatorInfo.addChildrenInfo(childrenInfo); - } - } + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * Add odd facets elements to the first table cell + */ + if (htmlFacetsElementsPresents && !htmlFacetsElementsRendered) { + VpeChildrenInfo childrenInfo = null; + if (captionHtmlElementsPresents) { + for (Node node : captionFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childrenInfo = new VpeChildrenInfo(visualCell); + childrenInfo.addSourceChild(node); + creatorInfo.addChildrenInfo(childrenInfo); + } + } + if (headerHtmlElementsPresents) { + for (Node node : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childrenInfo = new VpeChildrenInfo(visualCell); + childrenInfo.addSourceChild(node); + creatorInfo.addChildrenInfo(childrenInfo); + } + } + if (footerHtmlElementsPresents) { + for (Node node : footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childrenInfo = new VpeChildrenInfo(visualCell); + childrenInfo.addSourceChild(node); + creatorInfo.addChildrenInfo(childrenInfo); + } + } + htmlFacetsElementsRendered = true; + } else { + + int sourceIndex = tableSize * i + j; + if (sourceIndex < childrenCount) { + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * Correct index when odd facets elements presents + */ + if (htmlFacetsElementsPresents) { + sourceIndex = sourceIndex-1; + } + Node child = sourceChildren[sourceIndex]; + if (child != header && child != footer) { + VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualCell); + childrenInfo.addSourceChild(child); + creatorInfo.addChildrenInfo(childrenInfo); + } + } } + } if (visualBody != null) { visualBody.appendChild(visualRow); } else { visualTable.appendChild(visualRow); } } - makeSpecial(header, visualHead, visualDocument, tableSize, - creatorInfo, HTML.TAG_TH, headerClassExpr, pageContext); - makeSpecial(footer, visualFoot, visualDocument, tableSize, - creatorInfo, HTML.TAG_TD, footerClassExpr, pageContext); + makeSpecial(header, "header", visualHead, visualDocument, tableSize, //$NON-NLS-1$ + creatorInfo, HTML.TAG_TH, headerClassExpr, pageContext); + makeSpecial(footer, "footer", visualFoot, visualDocument, tableSize, //$NON-NLS-1$ + creatorInfo, HTML.TAG_TD, footerClassExpr, pageContext); for (int i = 0; i < propertyCreators.size(); i++) { VpeCreator creator = (VpeCreator) propertyCreators.get(i); @@ -382,24 +434,25 @@ return creatorInfo; } - private void makeSpecial(Node header, nsIDOMElement visualHead, + private void makeSpecial(Node facet, String facetName, nsIDOMElement visualHead, nsIDOMDocument visualDocument, int tableSize, VpeCreatorInfo creatorInfo, String cellTag, VpeExpression headerClassExpr, VpePageContext pageContext) throws VpeExpressionException { - if (header != null && visualHead != null) { + if (facet != null && visualHead != null) { nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TR); visualHead.appendChild(visualRow); nsIDOMElement visualCell = visualDocument.createElement(cellTag); visualCell.setAttribute(HTML.ATTR_COLSPAN, "" + tableSize); //$NON-NLS-1$ - if (headerClassExpr != null && header.getParentNode() != null) { + if (headerClassExpr != null && facet.getParentNode() != null) { String headerClass = headerClassExpr.exec(pageContext, - header.getParentNode()).stringValue(); + facet.getParentNode()).stringValue(); visualCell.setAttribute(HTML.ATTR_CLASS, headerClass); } visualRow.appendChild(visualCell); VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualCell); - childrenInfo.addSourceChild(header); + childrenInfo.addSourceChild(facet); creatorInfo.addChildrenInfo(childrenInfo); + visualCell.setAttribute(VpeVisualDomBuilder.VPE_FACET, facetName); } } Index: src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java =================================================================== --- src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java (working copy) @@ -10,18 +10,18 @@ ******************************************************************************/ package org.jboss.tools.vpe.editor.template; +import java.util.List; import java.util.Map; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeDataTableElements.SourceColumnElements; -import org.jboss.tools.vpe.editor.template.VpeDataTableElements.SourceDataTableElements; import org.jboss.tools.vpe.editor.template.VpeDataTableElements.VisualColumnElements; import org.jboss.tools.vpe.editor.template.VpeDataTableElements.VisualDataTableElements; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMNode; -import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -90,8 +90,45 @@ } setCellClass(cell, styleClass); visualColumnElements.setFooterCell(cell); - + + /* + * Find elements from the f:facet + */ + Map> headerFacetChildren = null; + Map> footerFacetChildren = null; + headerFacetChildren = VisualDomUtil.findFacetElements(columnElements.getHeader(), pageContext); + footerFacetChildren = VisualDomUtil.findFacetElements(columnElements.getFooter(), pageContext); + boolean headerHtmlElementsPresents = ((null != headerFacetChildren) && (headerFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + boolean footerHtmlElementsPresents = ((null != footerFacetChildren) && (footerFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + + /* + * Create column body cell. (TD) + */ cell = VpeDataTableElements.makeCell(visualDataTableElements.getBodyRow(), index, HTML.TAG_TD, visualDocument); + + /* + * Add HTML elements to the body cell. + * Correct facet will be rendered while JsfFacet template creating. + */ + VpeChildrenInfo childrenInfo = new VpeChildrenInfo(cell); + if (headerHtmlElementsPresents) { + for (Node node : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childrenInfo.addSourceChild(node); + } + } + if (footerHtmlElementsPresents) { + for (Node node : footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childrenInfo.addSourceChild(node); + } + } + /* + * If any elements were added they will be shown + * otherwise empty childrenInfo will be added. + */ + creatorInfo.addChildrenInfo(childrenInfo); + NodeList list = sourceNode.getChildNodes(); int cnt = list != null ? list.getLength() : 0; if (cnt > 0) { Index: src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java =================================================================== --- src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java (revision 21395) +++ src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java (working copy) @@ -30,7 +30,7 @@ @Override public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Map visualNodeMap) { VpeCreatorInfo creatorInfo = null; - + boolean isHeader = false; boolean isFooter = false; #P org.jboss.tools.jsf.vpe.richfaces Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesProgressBarTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesProgressBarTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesProgressBarTemplate.java (working copy) @@ -13,196 +13,208 @@ package org.jboss.tools.jsf.vpe.richfaces.template; -import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; -import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; import org.jboss.tools.vpe.editor.context.VpePageContext; +import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; -import org.jboss.tools.vpe.editor.util.VpeStyleUtil; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.w3c.dom.Element; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** * Template for tag. * - * @author Eugene Stherbin + * @author dmaliarevich */ -public class RichFacesProgressBarTemplate extends AbstractRichFacesTemplate { +public class RichFacesProgressBarTemplate extends VpeAbstractTemplate /*AbstractRichFacesTemplate*/ { - /** The Constant DEFAULT_HEIGHT. */ - private static final String DEFAULT_HEIGHT = " height:13px;"; //$NON-NLS-1$ - - /** The Constant CSS_EXTENSION. */ private static final String CSS_EXTENSION = "progressBar"; //$NON-NLS-1$ + private static final String CSS_PATH = "progressBar/progressBar.css"; //$NON-NLS-1$ + private static final String NBSP = "\u00A0"; //$NON-NLS-1$ - /** The Constant CSS_STYLE. */ - private static final String CSS_STYLE = "/progressBar.css"; //$NON-NLS-1$ - - /** The Constant FACET. */ - private static final String FACET = "facet"; //$NON-NLS-1$ - - /** The Constant OUTPUT_TEXT. */ - private static final String OUTPUT_TEXT = "outputText"; //$NON-NLS-1$ - - /** The Constant PROGRESS_DIV_STYLE_CLASSES. */ - private static final String PROGRESS_DIV_STYLE_CLASSES = "rich-progress-bar-block rich-progress-bar-width rich-progress-bar-shell"; //$NON-NLS-1$ - - /** The Constant TEXT_ALIGN_LEFT. */ - private static final String TEXT_ALIGN_LEFT = "; text-align:left;"; //$NON-NLS-1$ - - /** The Constant UPLOADED_DIV. */ - private static final String UPLOADED_DIV = "rich-progress-bar-height rich-progress-bar-uploaded null"; //$NON-NLS-1$ - - /** The percentage. */ - private String percentage = "60%"; //$NON-NLS-1$ - - /** The style. */ - private String style; - - /** The style class. */ - private String styleClass; + private static final String DEFAULT_HEIGHT = "height: 13px;"; //$NON-NLS-1$ + private static final String DEFAULT_UPLOADED_STATUS = "60%"; //$NON-NLS-1$ - private String sourceLabel; - - /** - * Create. - * - * @param visualDocument the visual document - * @param sourceNode the source node - * @param pageContext the page context - * - * @return the vpe creation data - * - * @see - * org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools - * .vpe.editor.context.VpePageContext, org.w3c.dom.Node, - * org.mozilla.interfaces.nsIDOMDocument) - */ + private static final String CSS_PB_BLOCK = "rich-progress-bar-block"; //$NON-NLS-1$ + private static final String CSS_PB_SHELL = "rich-progress-bar-shell"; //$NON-NLS-1$ + private static final String CSS_PB_UPLOADED = "rich-progress-bar-uploaded"; //$NON-NLS-1$ + private static final String CSS_PB_HEIGHT = "rich-progress-bar-height"; //$NON-NLS-1$ + private static final String CSS_PB_WIDTH = "rich-progress-bar-width"; //$NON-NLS-1$ + private static final String CSS_PB_SHELL_DIG = "rich-progress-bar-shell-dig"; //$NON-NLS-1$ + private static final String CSS_PB_UPLOADED_DIG = "rich-progress-bar-uploaded-dig"; //$NON-NLS-1$ + private static final String CSS_PB_REMAINED = "rich-progress-bar-remained"; //$NON-NLS-1$ + private static final String CSS_PB_PADDING = "rich-progress-bar-padding"; //$NON-NLS-1$ + private static final String CSS_PB_COMPLETED = "rich-progress-bar-completed"; //$NON-NLS-1$ + private static final String CSS_PB_HEIGHT_DIG = "rich-progress-bar-height-dig"; //$NON-NLS-1$ + private static final String CSS_PB_VPE_TEXT = "rich-progress-bar-vpe-text"; //$NON-NLS-1$ + public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { + /* + * Add CSS link to the current page + */ + ComponentUtil.setCSSLink(pageContext, CSS_PATH, CSS_EXTENSION); + Element sourceElement = (Element) sourceNode; + + /* + * Get source element attributes + */ + String style = ComponentUtil.getAttribute(sourceElement, HTML.ATTR_STYLE); + String styleClass = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS); + String sourceLabel = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_LABEL); + if (ComponentUtil.isBlank(styleClass)) { + styleClass = Constants.EMPTY; + } + if (ComponentUtil.isBlank(style)) { + style = DEFAULT_HEIGHT; + } + + /* + * Create tags + */ + nsIDOMElement progressDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement remainDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement uploadDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement completeDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement vpeTextDiv = visualDocument.createElement(HTML.TAG_DIV); - ComponentUtil.setCSSLink(pageContext, getCssStyle(), getCssExtension()); - final Element source = (Element) sourceNode; - prepareData(source); + /* + * if there are any suitable facets or lable value + * or supplementary HTML tags from facets + * then progress bar has more divs than usual. + */ + Element initialFacet = SourceDomUtil.getFacetByName(sourceElement, "initial"); + Map> initialFacetChildren = VisualDomUtil.findFacetElements(initialFacet, pageContext); + boolean initialFacetHtmlChildrenPresent = initialFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0; - final nsIDOMElement progressDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV); - final nsIDOMElement uploadDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV); - - String clazz = PROGRESS_DIV_STYLE_CLASSES; - if (ComponentUtil.isNotBlank(this.styleClass)) { - clazz = clazz + " " + this.styleClass; //$NON-NLS-1$ - } - progressDiv.setAttribute(HTML.ATTR_CLASS, clazz); - progressDiv.setAttribute(HTML.ATTR_STYLE, this.style + TEXT_ALIGN_LEFT); - final List elements = new ArrayList(); - final NodeList list = sourceNode.getChildNodes(); - - for(int i = 0 ; i < list.getLength() ; i ++ ){ - if(list.item(i).getNodeName().equalsIgnoreCase("h:outputText")){ //$NON-NLS-1$ - elements.add(list.item(i)); - } - } - - if(ComponentUtil.isNotBlank(this.sourceLabel) || elements.size() > 0){ - final nsIDOMElement labelDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV); - // labelDiv.setAttribute(HTML.ATTR_CLASS, "rich-progress-bar-width rich-progress-bar-remained rich-progress-bar-padding"); - labelDiv.setAttribute(HTML.ATTR_STYLE,this.style+"; font-weight: bold; position: relative; text-align: center; "); //$NON-NLS-1$ - uploadDiv.appendChild(labelDiv); - if (elements.size() > 0) { - final StringBuffer sb = new StringBuffer(); - - for (Node n : elements) { - sb.append(ComponentUtil.getAttribute((Element)n, "value")); //$NON-NLS-1$ - } - labelDiv.appendChild(visualDocument.createTextNode(sb.toString())); - } else { - labelDiv.appendChild(visualDocument.createTextNode(this.sourceLabel)); - } - } - uploadDiv.setAttribute(HTML.ATTR_CLASS, UPLOADED_DIV); + Element completeFacet = SourceDomUtil.getFacetByName(sourceElement, "complete"); + Map> completeFacetChildren = VisualDomUtil.findFacetElements(completeFacet, pageContext); + boolean completeFacetHtmlChildrenPresent = completeFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0; - uploadDiv.setAttribute(HTML.ATTR_STYLE, this.style + VpeStyleUtil.SEMICOLON_STRING + VpeStyleUtil.PARAMETER_WIDTH - + VpeStyleUtil.COLON_STRING + this.percentage); - // rootDiv.appendChild(progressDiv); - progressDiv.appendChild(uploadDiv); - List childrens = ComponentUtil.getChildren(source); - final VpeCreationData data = new VpeCreationData(progressDiv); - data.addChildrenInfo(new VpeChildrenInfo(null)); + List children = ComponentUtil.getChildren(sourceElement, true); + boolean progressBarWithLabel = initialFacetHtmlChildrenPresent + || completeFacetHtmlChildrenPresent + || (children.size() > 0) + || ComponentUtil.isNotBlank(sourceLabel); + + /* + * Create VpeCreationData + */ + VpeCreationData creationData = new VpeCreationData(progressDiv); +// VpeChildrenInfo vpeTextInfo = new VpeChildrenInfo(progressDiv); +// for (Node child : children) { +// System.out.println("--add child=[" + child.getNodeName() + ", " +// + child.getNodeValue() + "]"); +// vpeTextInfo.addSourceChild(child); +// } +// creationData.addChildrenInfo(vpeTextInfo); + + /* + * Filling in the divs + */ + if (progressBarWithLabel) { + progressDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_BLOCK + + Constants.WHITE_SPACE + CSS_PB_WIDTH + + Constants.WHITE_SPACE + CSS_PB_SHELL_DIG + + Constants.WHITE_SPACE + styleClass); + remainDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_WIDTH + + Constants.WHITE_SPACE + CSS_PB_REMAINED + + Constants.WHITE_SPACE + CSS_PB_PADDING); + uploadDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_UPLOADED_DIG); + vpeTextDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_HEIGHT_DIG + + Constants.WHITE_SPACE + CSS_PB_UPLOADED_DIG + + Constants.WHITE_SPACE + CSS_PB_VPE_TEXT); + completeDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_HEIGHT_DIG + + Constants.WHITE_SPACE + CSS_PB_WIDTH + + Constants.WHITE_SPACE + CSS_PB_COMPLETED + + Constants.WHITE_SPACE + CSS_PB_PADDING); + /* + * Adding facets HTML elements + */ + VpeChildrenInfo vpeTextInfo = new VpeChildrenInfo(vpeTextDiv); + if (initialFacetHtmlChildrenPresent) { + for (Node node : initialFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + vpeTextInfo.addSourceChild(node); + } + } + if (completeFacetHtmlChildrenPresent) { + for (Node node : completeFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + vpeTextInfo.addSourceChild(node); + } + } + + /* + * Add the rest bar's content + */ + for (Node child : children) { + vpeTextInfo.addSourceChild(child); + } + + /* + * Adding ChildrenInfo to CreationData + */ + creationData.addChildrenInfo(vpeTextInfo); + + /* + * Adding label to the bar's content + */ + if (ComponentUtil.isNotBlank(sourceLabel)) { + vpeTextDiv.appendChild(visualDocument.createTextNode(sourceLabel)); + } + + /* + * Creating tags structure + */ + progressDiv.appendChild(remainDiv); + progressDiv.appendChild(uploadDiv); + progressDiv.appendChild(vpeTextDiv); + uploadDiv.appendChild(completeDiv); + /* + * Add nbsp; for correct div height + */ + remainDiv.appendChild(visualDocument.createTextNode(NBSP)); + completeDiv.appendChild(visualDocument.createTextNode(NBSP)); + } else { + progressDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_BLOCK + + Constants.WHITE_SPACE + CSS_PB_WIDTH + + Constants.WHITE_SPACE + CSS_PB_SHELL + + Constants.WHITE_SPACE + styleClass); + uploadDiv.setAttribute(HTML.ATTR_CLASS, CSS_PB_HEIGHT + + Constants.WHITE_SPACE + CSS_PB_UPLOADED); + /* + * Creating tags structure + */ + progressDiv.appendChild(uploadDiv); + } + + /* + * Adding common styles + */ + remainDiv.setAttribute(HTML.ATTR_STYLE, style); + uploadDiv.setAttribute(HTML.ATTR_STYLE, "width: " + + DEFAULT_UPLOADED_STATUS + "; " + style); + completeDiv.setAttribute(HTML.ATTR_STYLE, style); + vpeTextDiv.setAttribute(HTML.ATTR_STYLE, style); - if (childrens.size() > 0) { - final VpeChildrenInfo info = new VpeChildrenInfo(progressDiv); - data.addChildrenInfo(info); - for (Node n : childrens) { - if (n.getNodeName().indexOf(FACET) > 1 - || n.getNodeName().indexOf(OUTPUT_TEXT) > 1) { - info.addSourceChild(n); - } - } - } -// -// DOMTreeDumper dump = new DOMTreeDumper(); -// dump.dumpToStream(System.err, progressDiv); - return data; + return creationData; } - /** - * Gets the css extension. - * - * @return the css extension - */ - private String getCssExtension() { - return CSS_EXTENSION; - } - - /** - * Gets the css style. - * - * @return the css style - */ - private String getCssStyle() { - return getCssExtension() + CSS_STYLE; - } - - /** - * Checks if is recreate at attr change. - * - * @param sourceElement the source element - * @param visualDocument the visual document - * @param value the value - * @param visualNode the visual node - * @param data the data - * @param pageContext the page context - * @param name the name - * - * @return true, if is recreate at attr change - */ @Override public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String value) { return true; } - /** - * Prepare data. - * - * @param source the source - */ - private void prepareData(Element source) { - this.styleClass = ComponentUtil.getAttribute(source, RichFaces.ATTR_STYLE_CLASS); - this.style = ComponentUtil.getAttribute(source, HTML.ATTR_STYLE); - this.sourceLabel = ComponentUtil.getAttribute(source, "label"); //$NON-NLS-1$ - if (ComponentUtil.isBlank(this.style)) { - this.style = DEFAULT_HEIGHT; - } - - } - } Index: resources/progressBar/progressBar.css =================================================================== --- resources/progressBar/progressBar.css (revision 21395) +++ resources/progressBar/progressBar.css (working copy) @@ -11,7 +11,18 @@ margin-bottom: 2px; } -.rich-progress-bar-height { +.rich-progress-bar-shell-dig { + border-color: #BED6F8; + border: 1px solid; + color: #000000; + font-family: Arial, Verdana, sans-serif; + font-size: 11px; + margin-bottom: 2px; + overflow: hidden; + position: relative; +} + +.rich-progress-bar-height,.rich-progress-bar-height-dig { height: 13px; } @@ -21,12 +32,35 @@ background-image: url(upload_status.gif); } +.rich-progress-bar-uploaded-dig { + position: absolute; + top: 0; + left: 0; + overflow: hidden; + border-color: #BED6F8; +} + .rich-progress-bar-remained { font-weight: bold; position: relative; text-align: center; + background-color: #FFFFFF; } +.rich-progress-bar-completed { + background-repeat: repeat-x; + background-color: #E79A00; + background-image : url(upload_status.gif); + font-weight : bold; + text-align: center; + background-image: url(upload_status.gif); +} + .rich-progress-bar-padding { padding: 0pt; +} + +.rich-progress-bar-vpe-text { + font-weight : bold; + text-align: center; } \ No newline at end of file Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataDefinitionListTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataDefinitionListTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataDefinitionListTemplate.java (working copy) @@ -10,8 +10,8 @@ ******************************************************************************/ package org.jboss.tools.jsf.vpe.richfaces.template; -import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; @@ -22,12 +22,13 @@ import org.jboss.tools.vpe.editor.template.expression.VpeExpression; import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.jboss.tools.vpe.editor.util.VpeClassUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.w3c.dom.Element; import org.w3c.dom.Node; -import org.w3c.dom.NodeList; /** * Creates rich:dataDefinitionList template. @@ -38,12 +39,9 @@ public class RichFacesDataDefinitionListTemplate extends VpeAbstractTemplate { /** - * + * CSS settings */ private static final String DEFAULT_DD_CLASS = "columnClass"; //$NON-NLS-1$ - private static final String FACET_URI = "http://java.sun.com/jsf/core"; //$NON-NLS-1$ - private static final String FACET_NAME_ATTR = "name"; //$NON-NLS-1$ - private static final String FACET_NAME_ATTR_VALUE = "term"; //$NON-NLS-1$ private static final String STYLE_RESOURCES_PATH = "/dataDefinitionList/dataDefinitionList.css"; //$NON-NLS-1$ /** @@ -59,7 +57,10 @@ * The document of the visual tree. * @return The information on the created node of the visual tree. */ - public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { + public VpeCreationData create(VpePageContext pageContext, Node sourceNode, + nsIDOMDocument visualDocument) { + + Element sourceElement = (Element) sourceNode; nsIDOMElement listElement = visualDocument.createElement(HTML.TAG_DL); ComponentUtil.setCSSLink( pageContext, @@ -68,37 +69,24 @@ VpeCreationData creationData = new VpeCreationData(listElement); creationData.addChildrenInfo(new VpeChildrenInfo(null)); - - Element child = null; - NodeList list = sourceNode.getChildNodes(); - // sets attributes for list ComponentUtil.correctAttribute((Element)sourceNode, listElement, RichFaces.ATTR_STYLE, HTML.ATTR_STYLE, null, null); ComponentUtil.correctAttribute((Element)sourceNode, listElement, RichFaces.ATTR_STYLE_CLASS, HTML.ATTR_CLASS, null, "listClass"); //$NON-NLS-1$ + Element termFacet = SourceDomUtil.getFacetByName(sourceElement, + RichFaces.NAME_FACET_TERM); + Map> termFacetChildren = VisualDomUtil + .findFacetElements(termFacet, pageContext); + Node termNode= ComponentUtil.getFacetBody(termFacetChildren); + + /* + * Encode body of the tag. + * Add text nodes to children list also. + */ + List children = ComponentUtil.getChildren(sourceElement, true); - Element facetElement = null; - List dataDefinitionElements = new ArrayList(); - for (int i = 0; i < list.getLength(); i++) { - Node nodeChild = list.item(i); - if (!(nodeChild instanceof Element)) { - continue; - } - child = (Element) nodeChild; - - if (!child.getLocalName().equals(RichFaces.TAG_FACET)) { - dataDefinitionElements.add(child); - } else if (facetElement == null - && (FACET_URI.equals(pageContext.getSourceTaglibUri(child))) - && child.getAttribute(FACET_NAME_ATTR) != null - && child.getAttribute(FACET_NAME_ATTR).equals( - FACET_NAME_ATTR_VALUE)) { - facetElement = child; - } - } - final List rowClasses; try { final VpeExpression exprRowClasses = RichFaces.getExprRowClasses(); @@ -116,55 +104,37 @@ // this is OK, rows still equals 1 } + VpeChildrenInfo childInfo = null; for (int row = 0; row < rows; row++) { - if (facetElement != null) { + if (termNode != null) { insertDtElement(sourceNode, visualDocument, - creationData, listElement, facetElement); - + creationData, listElement, termNode); } - if (!dataDefinitionElements.isEmpty()) { + if ((termFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0) + || !children.isEmpty()) { String ddClass = DEFAULT_DD_CLASS; if (rowClassesSize > 0) { ddClass+= " " + rowClasses.get(row % rowClassesSize); //$NON-NLS-1$ } - insertDdElement(sourceNode, visualDocument, - creationData, listElement, dataDefinitionElements, - ddClass); + nsIDOMElement dd = visualDocument.createElement(HTML.TAG_DD); + dd.setAttribute(HTML.ATTR_CLASS, ddClass); + listElement.appendChild(dd); + + childInfo = new VpeChildrenInfo(dd); + for (Node child : termFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childInfo.addSourceChild(child); + } + for (Node child : children) { + childInfo.addSourceChild(child); + } + creationData.addChildrenInfo(childInfo); } } return creationData; } /** - * Insert elements in list - * - * @param sourceNode - * The current node of the source tree. - * @param visualDocument - * The document of the visual tree. - * @param creationData - * @param parentList - * @param childElement - * @param styleClass class of this DD element - */ - private void insertDdElement(Node sourceNode, - nsIDOMDocument visualDocument, VpeCreationData creationData, - nsIDOMElement parentList, List childElements, String styleClass) { - nsIDOMElement dd = visualDocument.createElement(HTML.TAG_DD); - - dd.setAttribute(HTML.ATTR_CLASS, styleClass); - - parentList.appendChild(dd); - - VpeChildrenInfo vpeChildrenInfo = new VpeChildrenInfo(dd); - for (Element childElement : childElements) { - vpeChildrenInfo.addSourceChild(childElement); - } - creationData.addChildrenInfo(vpeChildrenInfo); - } - - /** * Insert listDataDefinition facet to HTML DT element * * @param sourceNode @@ -177,7 +147,7 @@ */ private void insertDtElement(Node sourceNode, nsIDOMDocument visualDocument, VpeCreationData creationData, nsIDOMElement parentList, - Element facetElement) { + Node facetElement) { nsIDOMElement dt = visualDocument.createElement(HTML.TAG_DT); ComponentUtil.correctAttribute( (Element) sourceNode, Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java (working copy) @@ -11,12 +11,18 @@ package org.jboss.tools.jsf.vpe.richfaces.template; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.w3c.dom.Element; @@ -43,28 +49,57 @@ div.setAttribute("style", style); //$NON-NLS-1$ } - // Encode Header - Node header = ComponentUtil.getFacet(sourceElement, "header", true); //$NON-NLS-1$ - if(header!=null) { - nsIDOMElement headerDiv = visualDocument.createElement("div"); //$NON-NLS-1$ + /* + * Encode the Header Facet + * Find elements from the f:facet + */ + Map> headerFacetChildren = null; + Element headerFacet = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_HEADER); + if (headerFacet != null) { + headerFacetChildren = VisualDomUtil.findFacetElements(headerFacet, pageContext); + nsIDOMElement headerDiv = visualDocument.createElement(HTML.TAG_DIV); + /* + * By adding attribute VPE-FACET to this visual node + * we force JsfFacet to be rendered inside it. + */ + headerDiv.setAttribute(VpeVisualDomBuilder.VPE_FACET, RichFaces.NAME_FACET_HEADER); div.appendChild(headerDiv); - String headerClass = sourceElement.getAttribute("headerClass"); //$NON-NLS-1$ - headerDiv.setAttribute("class", "dr-pnl-h rich-panel-header " + (headerClass==null?"":headerClass)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - headerDiv.setAttribute("style", ComponentUtil.getHeaderBackgoundImgStyle()); //$NON-NLS-1$ + String headerClass = sourceElement.getAttribute(RichFaces.ATTR_HEADER_CLASS); + headerDiv.setAttribute(HTML.ATTR_CLASS, + "dr-pnl-h rich-panel-header " + (headerClass == null ? "" : headerClass)); //$NON-NLS-1$ //$NON-NLS-2$ + headerDiv.setAttribute(HTML.ATTR_STYLE, + ComponentUtil.getHeaderBackgoundImgStyle()); VpeChildrenInfo headerInfo = new VpeChildrenInfo(headerDiv); - headerInfo.addSourceChild(header); + headerInfo.addSourceChild(headerFacet); creationData.addChildrenInfo(headerInfo); } - // Encode Body - nsIDOMElement bodyDiv = visualDocument.createElement("div"); //$NON-NLS-1$ + /* + * Encode rich:panel content + */ + nsIDOMElement bodyDiv = visualDocument.createElement(HTML.TAG_DIV); div.appendChild(bodyDiv); - String bodyClass = sourceElement.getAttribute("bodyClass"); //$NON-NLS-1$ - bodyDiv.setAttribute("class", "dr-pnl-b rich-panel-body " + (bodyClass==null?"":bodyClass)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + String bodyClass = sourceElement.getAttribute(RichFaces.ATTR_BODY_CLASS); + bodyDiv.setAttribute(HTML.ATTR_CLASS, + "dr-pnl-b rich-panel-body " + (bodyClass == null ? "" : bodyClass)); //$NON-NLS-1$ //$NON-NLS-2$ + /* + * If there are some odd HTML elements from facet + * add them to the panel body first. + */ + boolean headerHtmlElementsPresents = ((headerFacetChildren != null) && (headerFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + VpeChildrenInfo bodyInfo = new VpeChildrenInfo(bodyDiv); + if (headerHtmlElementsPresents) { + for (Node node : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + bodyInfo.addSourceChild(node); + } + } + + /* + * Add the rest panel's content + */ List children = ComponentUtil.getChildren(sourceElement, true); - VpeChildrenInfo bodyInfo = new VpeChildrenInfo(bodyDiv); for (Node child : children) { bodyInfo.addSourceChild(child); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesExtendedDataTableTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesExtendedDataTableTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesExtendedDataTableTemplate.java (working copy) @@ -147,8 +147,8 @@ tr.setAttribute(HTML.ATTR_CLASS, styleClass); filterTR.setAttribute(HTML.ATTR_CLASS, styleClass); } - encodeHeaderFacets(vpeCreationData, tr, filterTR, visualDocument, - columns, + encodeHeaderFacets(pageContext, vpeCreationData, tr, filterTR, + visualDocument, columns, DR_TABLE_SUBHEADERCELL_RICH_TABLE_SUBHEADERCELL, headerClass); // Add footer @@ -163,8 +163,8 @@ if (styleFooterClass != null) { tfootTR.setAttribute(HTML.ATTR_CLASS, styleFooterClass); } - encodeFooterFacets(vpeCreationData, tfootTR, visualDocument, - columns, + encodeFooterFacets(pageContext, vpeCreationData, tfootTR, + visualDocument, columns, DR_TABLE_SUBFOOTERCELL_RICH_TABLE_SUBFOOTERCELL, styleFooterClass); @@ -284,9 +284,10 @@ * @param skinCellClass * @param footerClass */ - public static void encodeFooterFacets(VpeCreationData creationData, - nsIDOMElement parentTr, nsIDOMDocument visualDocument, - ArrayList footers, String skinCellClass, String footerClass) { + public void encodeFooterFacets(VpePageContext pageContext, + VpeCreationData creationData, nsIDOMElement parentTr, + nsIDOMDocument visualDocument, ArrayList footers, + String skinCellClass, String footerClass) { String classAttribute = "footerClass"; //$NON-NLS-1$ String styleClass = EMPTY; for (Element column : footers) { @@ -302,11 +303,19 @@ if (colspan != null && colspan.length() > 0) { td.setAttribute(HTML.ATTR_COLSPAN, colspan); } - Element facetBody = ComponentUtil.getFacet(column, FOOTER); - - VpeChildrenInfo child = new VpeChildrenInfo(td); - child.addSourceChild(facetBody); - creationData.addChildrenInfo(child); + /* + * Get all facet's children. And display only the first one JSF tag. + */ + Node facetBody = ComponentUtil.getFacetBody(pageContext, column, + RichFaces.NAME_FACET_FOOTER); + /* + * Add suitable facet child if there is any. + */ + if (null != facetBody) { + VpeChildrenInfo child = new VpeChildrenInfo(td); + child.addSourceChild(facetBody); + creationData.addChildrenInfo(child); + } } nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); @@ -325,10 +334,10 @@ * @param skinCellClass * @param headerClass */ - public static void encodeHeaderFacets(VpeCreationData creationData, - nsIDOMElement parentTr, nsIDOMElement filterTR, - nsIDOMDocument visualDocument, ArrayList headers, - String skinCellClass, String headerClass) { + public void encodeHeaderFacets(VpePageContext pageContext, + VpeCreationData creationData, nsIDOMElement parentTr, + nsIDOMElement filterTR, nsIDOMDocument visualDocument, + ArrayList headers, String skinCellClass, String headerClass) { String classAttribute = "headerClass"; //$NON-NLS-1$ String styleClass = EMPTY; // Check filter @@ -361,11 +370,19 @@ if (colspan != null && colspan.length() > 0) { td.setAttribute(HTML.ATTR_COLSPAN, colspan); } - Element facetBody = ComponentUtil.getFacet(column, HEADER); - - VpeChildrenInfo child = new VpeChildrenInfo(span); - child.addSourceChild(facetBody); - creationData.addChildrenInfo(child); + /* + * Get all facet's children. And display only the first one JSF tag. + */ + Node facetBody = ComponentUtil.getFacetBody(pageContext, column, + RichFaces.NAME_FACET_HEADER); + /* + * Add suitable facet child if there is any. + */ + if (null != facetBody) { + VpeChildrenInfo child = new VpeChildrenInfo(span); + child.addSourceChild(facetBody); + creationData.addChildrenInfo(child); + } // Add filter if (existFilters) { nsIDOMElement filterTD = visualDocument @@ -413,28 +430,7 @@ td.appendChild(visualDocument.createTextNode(SPACE)); filterTR.appendChild(td); } - - /** - * Checks, whether it is necessary to re-create an element at change of - * attribute - * - * @param pageContext - * Contains the information on edited page. - * @param sourceElement - * The current element of the source tree. - * @param visualDocument - * The document of the visual tree. - * @param visualNode - * The current node of the visual tree. - * @param data - * The arbitrary data, built by a method create - * @param name - * Attribute name - * @param value - * Attribute value - * @return true if it is required to re-create an element at a - * modification of attribute, false otherwise. - */ + @Override public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement, nsIDOMDocument visualDocument, Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractInplaceTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractInplaceTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractInplaceTemplate.java (working copy) @@ -64,9 +64,6 @@ /** The Constant RICH_INPLACE_VIEW_DEFAULT_STYLE_CLASS. */ protected static final String RICH_INPLACE_VIEW_DEFAULT_STYLE_CLASS = "rich-inplace-view"; //$NON-NLS-1$ - /** The Constant VPE_USER_TOGGLE_ID_ATTR. */ - public static final String VPE_USER_TOGGLE_ID_ATTR = "vpe-user-toggle-id"; //$NON-NLS-1$ - /** The button images. */ protected final Map buttonImages = new HashMap(); @@ -105,7 +102,7 @@ */ protected nsIDOMElement createRootSpanTemplateMethod(Element source, nsIDOMDocument visualDocument, Attributes attrs) { final nsIDOMElement rootSpan = visualDocument.createElement(HTML.TAG_SPAN); - rootSpan.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(this.isToggle)); + rootSpan.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(this.isToggle)); String rootStyleClass = "rich-inplace" + getCssStylesSuffix(); //$NON-NLS-1$ for (String sc : getRootSpanClasses(attrs)) { if (ComponentUtil.isNotBlank(sc)) { @@ -346,10 +343,12 @@ /* * Encoding controls facet */ - Element facetElement = ComponentUtil.getFacetElement((Element) sourceNode, "controls", true); //$NON-NLS-1$ - if (facetElement != null) { + Element controlFacet = ComponentUtil.getFacetElement( + (Element) sourceNode, RichFaces.NAME_FACET_CONTROLS, false); + + if (controlFacet != null) { VpeChildrenInfo childrenInfo = new VpeChildrenInfo(divButtons); - childrenInfo.addSourceChild(facetElement); + childrenInfo.addSourceChild(controlFacet); creationData.addChildrenInfo(childrenInfo); } else { // Create "Apply" button @@ -371,7 +370,7 @@ String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(saveControlIconImg, pageContext, true); applyButtonImg.setAttribute(HTML.ATTR_SRC, imgFullPath); } - applyButtonImg.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + applyButtonImg.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); // Create "Cancel" button final nsIDOMElement cancelButtonImg = visualDocument.createElement(HTML.TAG_INPUT); @@ -392,7 +391,7 @@ String imgFullPath = VpeStyleUtil.addFullPathToImgSrc(cancelControlIconImg, pageContext, true); cancelButtonImg.setAttribute(HTML.ATTR_SRC, imgFullPath); } - cancelButtonImg.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + cancelButtonImg.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); divButtons.appendChild(applyButtonImg); divButtons.appendChild(cancelButtonImg); Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java (working copy) @@ -77,7 +77,6 @@ private static Map toggleMap = new HashMap(); public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { - Element sourceElement = (Element)sourceNode; nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE); @@ -184,7 +183,7 @@ if(child.getNodeName().endsWith(TAB)) { i++; if (active) { - RichFacesTabTemplate.encodeBody(creationData, + RichFacesTabTemplate.encodeBody(pageContext, creationData, (Element) child, visualDocument, inerTr, true, ComponentUtil.getAttribute(sourceElement, CONTENT_CLASS) Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java (working copy) @@ -11,14 +11,18 @@ package org.jboss.tools.jsf.vpe.richfaces.template; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; -import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.HTML; import org.jboss.tools.vpe.editor.util.ResourceUtil; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMText; @@ -73,7 +77,7 @@ String barContentStyleClass, String barContentStyle, String toggleId) { nsIDOMElement div = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); + .createElement(HTML.TAG_DIV); if (creationData == null) { creationData = new VpeCreationData(div); @@ -81,9 +85,9 @@ parentVisualElement.appendChild(div); } - div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, barStyleClass + div.setAttribute(HTML.ATTR_CLASS, barStyleClass + DR_PNLBAR_RICH_PANELBAR_DR_PNLBAR_EXT); - div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, barStyle); + div.setAttribute(HTML.ATTR_STYLE, barStyle); div.setAttribute(VPE_USER_TOGGLE_ID, toggleId); // Encode Header @@ -126,12 +130,12 @@ if (active) { nsIDOMElement tr2 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); + .createElement(HTML.TAG_TR); nsIDOMElement td2 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); + .createElement(HTML.TAG_TD); tr2.appendChild(td2); - tr2.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, PERCENT_100); - tr2.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, PERCENT_100); + tr2.setAttribute(HTML.ATTR_WIDTH, PERCENT_100); + tr2.setAttribute(HTML.ATTR_HEIGHT, PERCENT_100); if (creationData == null) { creationData = new VpeCreationData(tr2); } else { @@ -139,38 +143,54 @@ } nsIDOMElement contentTable = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TABLE); + .createElement(HTML.TAG_TABLE); td2.appendChild(contentTable); - contentTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, + contentTable.setAttribute(HTML.ATTR_CELLPADDING, ZERO); - contentTable.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, + contentTable.setAttribute(HTML.ATTR_WIDTH, PERCENT_100); - contentTable.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, + contentTable.setAttribute(HTML.ATTR_HEIGHT, PERCENT_100); nsIDOMElement tbody = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TBODY); + .createElement(HTML.TAG_TBODY); contentTable.appendChild(tbody); nsIDOMElement tr = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); + .createElement(HTML.TAG_TR); tbody.appendChild(tr); nsIDOMElement td = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); + .createElement(HTML.TAG_TD); tr.appendChild(td); String tdClass = DR_PNLBAR_C_RICH_PANELBAR_CONTENT + barContentStyleClass + SPACE + internContentClass; String tdStyle = barContentStyle + SPACE + internContentStyle; - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, tdClass); - td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tdStyle); + td.setAttribute(HTML.ATTR_CLASS, tdClass); + td.setAttribute(HTML.ATTR_STYLE, tdStyle); - List children = ComponentUtil - .getChildren(sourceElement, true); + Element labelFacet = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_LABEL); + Map> labelFacetChildren = VisualDomUtil.findFacetElements(labelFacet, pageContext); + boolean labelFacetHtmlChildrenPresent = labelFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0; + List children = ComponentUtil.getChildren(sourceElement, true); + + /* + * Add HTML elements from facet + */ VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td); + if (labelFacetHtmlChildrenPresent) { + for (Node node : labelFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + bodyInfo.addSourceChild(node); + } + } + + /* + * Add the rest item's content + */ for (Node child : children) { bodyInfo.addSourceChild(child); } @@ -201,43 +221,46 @@ String styleClass, String style, String toggleId) { nsIDOMElement div = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); + .createElement(HTML.TAG_DIV); parentDiv.appendChild(div); - div.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); - div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style); + div.setAttribute(HTML.ATTR_CLASS, styleClass); + div.setAttribute(HTML.ATTR_STYLE, style); div.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - Element facet = ComponentUtil.getFacet(sourceElement, LABEL); + Element facetBody = ComponentUtil.getFacet(sourceElement, LABEL); + + if (facetBody == null) { + /* + * Display label attribute or default label + */ + Attr attr = null; + if (sourceElement.hasAttribute(LABEL)) { + attr = sourceElement.getAttributeNode(LABEL); + } + if (attr != null) { + String itemLabel = attr.getNodeValue(); + String bundleValue = ResourceUtil.getBundleValue(pageContext, + attr.getValue()); + nsIDOMText text; + // if bundleValue differ from value then will be represent + // bundleValue, but text will be not edit + if (!itemLabel.equals(bundleValue)) { + text = visualDocument.createTextNode(bundleValue); - if (facet == null) { - Attr attr = null; - if (sourceElement.hasAttribute(LABEL)) { - attr = sourceElement.getAttributeNode(LABEL); - } - if (attr != null) { - String itemLabel = attr.getNodeValue(); - String bundleValue = ResourceUtil.getBundleValue(pageContext, - attr.getValue()); - nsIDOMText text; - // if bundleValue differ from value then will be represent - // bundleValue, but text will be not edit - if (!itemLabel.equals(bundleValue)) { - text = visualDocument.createTextNode(bundleValue); + } else { + text = visualDocument.createTextNode(itemLabel); + } + div.appendChild(text); + } else { + div.appendChild(visualDocument.createTextNode(DEFAULT_LABEL)); + } } else { - text = visualDocument.createTextNode(itemLabel); + VpeChildrenInfo facetInfo = new VpeChildrenInfo(div); + facetInfo.addSourceChild(facetBody); + vpeCreationData.addChildrenInfo(facetInfo); } - div.appendChild(text); - } else { - div.appendChild(visualDocument.createTextNode(DEFAULT_LABEL)); - } - } else { - VpeChildrenInfo facetInfo = new VpeChildrenInfo(div); - facetInfo.addSourceChild(facet); - vpeCreationData.addChildrenInfo(facetInfo); - } - } } \ No newline at end of file Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplateHelper.java (working copy) @@ -240,7 +240,7 @@ buttonBackground.setAttribute(HTML.ATTR_CLASS, styleClasess.get(BUTTON_BACKGROUND)); buttonBackground.setAttribute(HTML.ATTR_READONLY, Constants.TRUE); - buttonBackground.setAttribute(RichFacesAbstractInplaceTemplate.VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + buttonBackground.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); if (sourceButtonStyle != null) { buttonBackground.setAttribute(HTML.ATTR_STYLE, sourceButtonStyle); } @@ -250,7 +250,7 @@ ; buttonIcon.setAttribute(HTML.ATTR_CLASS, styleClasess.get(BUTTON_ICON)); buttonIcon.setAttribute(HTML.ATTR_READONLY, Constants.TRUE); - buttonIcon.setAttribute(RichFacesAbstractInplaceTemplate.VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + buttonIcon.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); if (sourceButtonStyle != null) { buttonIcon.setAttribute(HTML.ATTR_STYLE, sourceButtonStyle); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataGridTemplate.java (working copy) @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.StringTokenizer; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; @@ -21,6 +22,7 @@ import org.jboss.tools.vpe.editor.template.VpeCreationData; import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; @@ -55,35 +57,50 @@ String tableClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS); table.setAttribute(HTML.ATTR_CLASS, "dr-table rich-table " + (tableClass==null?Constants.EMPTY:tableClass)); //$NON-NLS-1$ - // Encode colgroup definition. + /* + * Encode colgroup definition. + */ int columnsLength = getColumnsCount(sourceElement); nsIDOMElement colgroup = visualDocument.createElement(HTML.TAG_COLGROUP); colgroup.setAttribute(HTML.ATTR_SPAN, String.valueOf(columnsLength)); table.appendChild(colgroup); + + /* + * Encode Caption + */ + Element caption = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_CAPTION); + Map> captionFacetChildren = VisualDomUtil.findFacetElements(caption, pageContext); + Node captionBody = ComponentUtil.getFacetBody(captionFacetChildren); + encodeCaption(pageContext, creationData, sourceElement, visualDocument, table, captionBody); - //Encode Caption - encodeCaption(creationData, sourceElement, visualDocument, table); - - // Encode Header - Element header = ComponentUtil.getFacet(sourceElement, RichFaces.NAME_FACET_HEADER); - if(header!=null) { + /* + * Encode Header + */ + Element header = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_HEADER); + Map> headerFacetChildren = VisualDomUtil.findFacetElements(header, pageContext); + Node headerBody = ComponentUtil.getFacetBody(headerFacetChildren); + if (headerBody != null) { nsIDOMElement thead = visualDocument.createElement(HTML.TAG_THEAD); table.appendChild(thead); String headerClass = (String) sourceElement.getAttribute(RichFaces.ATTR_HEADER_CLASS); - encodeTableHeaderOrFooterFacet(pageContext, creationData, thead, columnsLength, visualDocument, header, + encodeTableHeaderOrFooterFacet(pageContext, creationData, thead, columnsLength, visualDocument, headerBody, "dr-table-header rich-table-header", //$NON-NLS-1$ "dr-table-header-continue rich-table-header-continue", //$NON-NLS-1$ "dr-table-headercell rich-table-headercell", //$NON-NLS-1$ headerClass, HTML.TAG_TD); } - // Encode Footer - Element footer = ComponentUtil.getFacet(sourceElement, RichFaces.NAME_FACET_FOOTER); - if (footer != null) { + /* + * Encode Footer + */ + Element footer = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_FOOTER); + Map> footerFacetChildren = VisualDomUtil.findFacetElements(footer, pageContext); + Node footerBody = ComponentUtil.getFacetBody(footerFacetChildren); + if (footerBody != null) { nsIDOMElement tfoot = visualDocument.createElement(HTML.TAG_TFOOT); table.appendChild(tfoot); String footerClass = (String) sourceElement.getAttribute(RichFaces.ATTR_FOOTER_CLASS); - encodeTableHeaderOrFooterFacet(pageContext, creationData, tfoot, columnsLength, visualDocument, footer, + encodeTableHeaderOrFooterFacet(pageContext, creationData, tfoot, columnsLength, visualDocument, footerBody, "dr-table-footer rich-table-footer", //$NON-NLS-1$ "dr-table-footer-continue rich-table-footer-continue", //$NON-NLS-1$ "dr-table-footercell rich-table-footercell", //$NON-NLS-1$ @@ -95,9 +112,9 @@ /* * https://jira.jboss.org/jira/browse/JBIDE-3491 + * Encode body. * Add text nodes to children list too. */ - //Create mapping to Encode body List children = ComponentUtil.getChildren(sourceElement, true); sourceElement.getAttribute(RichFaces.ATTR_ELEMENTS); @@ -113,8 +130,33 @@ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); tr.appendChild(td); td.setAttribute(HTML.ATTR_CLASS, "dr-table-cell rich-table-cell " + getColumnClass(columnIndex)); //$NON-NLS-1$ + /* + * Add HTML elements from caption, header and footer. + */ + VpeChildrenInfo childInfo = null; + if (captionFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0) { + childInfo = new VpeChildrenInfo(td); + for (Node child : captionFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childInfo.addSourceChild(child); + } + creationData.addChildrenInfo(childInfo); + } + if (headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0) { + childInfo = new VpeChildrenInfo(td); + for (Node child : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childInfo.addSourceChild(child); + } + creationData.addChildrenInfo(childInfo); + } + if (footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0) { + childInfo = new VpeChildrenInfo(td); + for (Node child : footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + childInfo.addSourceChild(child); + } + creationData.addChildrenInfo(childInfo); + } if(!children.isEmpty()) { - VpeChildrenInfo childInfo = new VpeChildrenInfo(td); + childInfo = new VpeChildrenInfo(td); for (Node child : children) { childInfo.addSourceChild(child); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java (working copy) @@ -11,17 +11,21 @@ package org.jboss.tools.jsf.vpe.richfaces.template; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; -import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.HTML; import org.jboss.tools.vpe.editor.util.ResourceUtil; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; -import org.mozilla.interfaces.nsIDOMText; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -39,7 +43,6 @@ private final static String VPE_USER_TOGGLE_ID = "vpe-user-toggle-id"; //$NON-NLS-1$ private static final String DISABLED = "disabled"; //$NON-NLS-1$ - private static final String LABEL = "label"; //$NON-NLS-1$ private static final String LABEL_WIDTH = "labelWidth"; //$NON-NLS-1$ private static final String CSS_HEADER = "rich-tab-header"; //$NON-NLS-1$ @@ -76,16 +79,17 @@ * @param contentStyle * @return the tab body */ - public static VpeCreationData encodeBody(VpeCreationData creationData, + public static VpeCreationData encodeBody( + VpePageContext pageContext, + VpeCreationData creationData, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement parentTr, boolean active, String contentClass, String contentStyle) { + nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); - nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); - if(creationData==null) { creationData = new VpeCreationData(td); } else { @@ -94,61 +98,80 @@ if(!active) { return creationData; } -// td.setAttribute("style", "position: relative;"); - td.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, HUNDRED_PERCENTS); + td.setAttribute(HTML.ATTR_HEIGHT, HUNDRED_PERCENTS); - nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE); + nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE); td.appendChild(table); - table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, TEN); - table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, HUNDRED_PERCENTS); - table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,RichFacesTabPanelTemplate.CSS_CONTENT_POSITION); - table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, BODY_TABLE_STYLE); + table.setAttribute(HTML.ATTR_BORDER, ZERO); + table.setAttribute(HTML.ATTR_CELLPADDING, TEN); + table.setAttribute(HTML.ATTR_CELLSPACING, ZERO); + table.setAttribute(HTML.ATTR_WIDTH, HUNDRED_PERCENTS); + table.setAttribute(HTML.ATTR_CLASS,RichFacesTabPanelTemplate.CSS_CONTENT_POSITION); + table.setAttribute(HTML.ATTR_STYLE, BODY_TABLE_STYLE); - nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR); + nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR); table.appendChild(tr); - td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + td = visualDocument.createElement(HTML.TAG_TD); tr.appendChild(td); - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR) + td.setAttribute(HTML.ATTR_CLASS, + ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS) + SPACE + contentClass); - td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, - ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLE_ATTR) + td.setAttribute(HTML.ATTR_STYLE, + ComponentUtil.getAttribute(sourceElement, HTML.ATTR_STYLE) + STYLE_SEMICOLUMN + contentStyle); + Map> labelFacetChildren = null; + Element labelFacet = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_LABEL); + if (null != labelFacet) { + labelFacetChildren = VisualDomUtil.findFacetElements(labelFacet, pageContext); + } + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * If there are some odd HTML elements from facet + * add them to the panel body first. + */ + boolean labelHtmlElementsPresents = ((labelFacetChildren != null) && (labelFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td); + if (labelHtmlElementsPresents) { + for (Node node : labelFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + bodyInfo.addSourceChild(node); + } + } + + /* + * Add the rest tab's content + */ List children = ComponentUtil.getChildren(sourceElement, true); - VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td); for (Node child : children) { bodyInfo.addSourceChild(child); } creationData.addChildrenInfo(bodyInfo); - return creationData; } public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { - nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV); - //table.setAttribute("include-tab", ""); + nsIDOMElement table = visualDocument.createElement(HTML.TAG_DIV); VpeCreationData creationData = new VpeCreationData(table); - nsIDOMElement headerTable = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE); - headerTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); - headerTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO); - headerTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO); + nsIDOMElement headerTable = visualDocument.createElement(HTML.TAG_TABLE); + headerTable.setAttribute(HTML.ATTR_BORDER, ZERO); + headerTable.setAttribute(HTML.ATTR_CELLPADDING, ZERO); + headerTable.setAttribute(HTML.ATTR_CELLSPACING, ZERO); headerTable.setAttribute(TAB_HEADER_ATTR, YES); - headerTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, - HtmlComponentUtil.CSS_DISPLAY + headerTable.setAttribute(HTML.ATTR_STYLE, + HTML.STYLE_PARAMETER_DISPLAY + ":" + DISABLED_ELEMENT_STYLE + STYLE_SEMICOLUMN); //$NON-NLS-1$ - headerTable.appendChild(encodeHeader(pageContext, creationData, (Element)sourceNode, visualDocument, table, false, EMPTY, EMPTY, EMPTY, EMPTY,EMPTY)); - nsIDOMElement bodyTable = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE); - bodyTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); - bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO); - bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO); + headerTable.appendChild(encodeHeader(pageContext, creationData, + (Element) sourceNode, visualDocument, table, false, EMPTY, + EMPTY, EMPTY, EMPTY, EMPTY)); + nsIDOMElement bodyTable = visualDocument.createElement(HTML.TAG_TABLE); + bodyTable.setAttribute(HTML.ATTR_BORDER, ZERO); + bodyTable.setAttribute(HTML.ATTR_CELLPADDING, ZERO); + bodyTable.setAttribute(HTML.ATTR_CELLSPACING, ZERO); bodyTable.setAttribute(TAB_BODY_ATTR, YES); - //bodyTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HtmlComponentUtil.CSS_DISPLAY+" : "+DISABLED_ELEMENT_STYLE+";"); //$NON-NLS-1$ //$NON-NLS-2$ table.appendChild(headerTable); table.appendChild(bodyTable); - encodeBody(creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY, EMPTY); + encodeBody(pageContext, creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY, EMPTY); return creationData; } @@ -175,10 +198,9 @@ String inactiveTabClass, String disabledTabClass, String toggleId) { - - nsIDOMElement headerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + nsIDOMElement headerTd = visualDocument.createElement(HTML.TAG_TD); parentTr.appendChild(headerTd); - headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HEADER_TD_STYLE); + headerTd.setAttribute(HTML.ATTR_STYLE, HEADER_TD_STYLE); String styleClass = RichFacesTabPanelTemplate.CSS_CELL_DISABLED + SPACE + CSS_DISABLED; if(!TRUE.equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) { @@ -188,26 +210,26 @@ styleClass = RichFacesTabPanelTemplate.CSS_CELL_INACTIVE; } } - headerTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); + headerTd.setAttribute(HTML.ATTR_CLASS, styleClass); headerTd.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE); + nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE); headerTd.appendChild(table); - table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HEADER_TABLE_STYLE); + table.setAttribute(HTML.ATTR_BORDER, ZERO); + table.setAttribute(HTML.ATTR_CELLPADDING, ZERO); + table.setAttribute(HTML.ATTR_CELLSPACING, ZERO); + table.setAttribute(HTML.ATTR_STYLE, HEADER_TABLE_STYLE); table.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - nsIDOMElement mainTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR); + nsIDOMElement mainTr = visualDocument.createElement(HTML.TAG_TR); table.appendChild(mainTr); encodeSpacer(mainTr, visualDocument); - nsIDOMElement mainTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + nsIDOMElement mainTd = visualDocument.createElement(HTML.TAG_TD); mainTr.appendChild(mainTd); mainTd.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE); + table = visualDocument.createElement(HTML.TAG_TABLE); mainTd.appendChild(table); String labelWidth = ComponentUtil.getAttribute(sourceElement, LABEL_WIDTH); @@ -228,15 +250,15 @@ labelWidth = HUNDRED_PERCENTS; } tableStyle += WIDTH_STYLE_NAME + labelWidth + STYLE_SEMICOLUMN; - table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, tableStyle); - table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO); - table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO); + table.setAttribute(HTML.ATTR_STYLE, tableStyle); + table.setAttribute(HTML.ATTR_BORDER, ZERO); + table.setAttribute(HTML.ATTR_CELLPADDING, ZERO); + table.setAttribute(HTML.ATTR_CELLSPACING, ZERO); table.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR); + nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR); table.appendChild(tr); - mainTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + mainTd = visualDocument.createElement(HTML.TAG_TD); tr.appendChild(mainTd); styleClass = CSS_HEADER @@ -257,18 +279,30 @@ + SPACE + inactiveTabClass; } } - String tabStyleClass = ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR); + String tabStyleClass = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS); styleClass += SPACE + headerClass + SPACE + tabStyleClass; - mainTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); + mainTd.setAttribute(HTML.ATTR_CLASS, styleClass); mainTd.setAttribute(VPE_USER_TOGGLE_ID, toggleId); - Node labelFacet = ComponentUtil.getFacet(sourceElement, LABEL, true); + + /* + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * Encode the Label Facet + * Find elements from the f:facet + */ + Element labelFacet = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_LABEL); if (null != labelFacet) { - VpeChildrenInfo child = new VpeChildrenInfo(mainTd); - child.addSourceChild(labelFacet); - creationData.addChildrenInfo(child); - } else if (sourceElement.hasAttribute(LABEL)) { - Attr labelAttr = sourceElement.getAttributeNode(LABEL); + /* + * By adding attribute VPE-FACET to this visual node + * we force JsfFacet to be rendered inside it + * without creating an additional and superfluous visual tag. + */ + mainTd.setAttribute(VpeVisualDomBuilder.VPE_FACET, RichFaces.NAME_FACET_LABEL); + VpeChildrenInfo labelInfo = new VpeChildrenInfo(mainTd); + labelInfo.addSourceChild(labelFacet); + creationData.addChildrenInfo(labelInfo); + } else if (sourceElement.hasAttribute(RichFaces.ATTR_LABEL)) { + Attr labelAttr = sourceElement.getAttributeNode(RichFaces.ATTR_LABEL); if (null != labelAttr) { String bundleValue = ResourceUtil.getBundleValue(pageContext, labelAttr.getValue()); mainTd.appendChild(visualDocument.createTextNode(bundleValue)); @@ -285,20 +319,20 @@ * Add */ private static void encodeSpacer(nsIDOMElement parentTr, nsIDOMDocument visualDocument) { - nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); parentTr.appendChild(td); - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, + td.setAttribute(HTML.ATTR_CLASS, RichFacesTabPanelTemplate.CSS_SIDE_CELL + SPACE + RichFacesTabPanelTemplate.CSS_SIDE_BORDER); String style = ComponentUtil.getBackgoundImgStyle(BORDER_FILE_PATH); - td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style); - nsIDOMElement img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG); + td.setAttribute(HTML.ATTR_STYLE, style); + nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG); td.appendChild(img); ComponentUtil.setImg(img, SPACER_FILE_PATH); - img.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, ONE); - img.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, ONE); - img.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO); + img.setAttribute(HTML.ATTR_WIDTH, ONE); + img.setAttribute(HTML.ATTR_HEIGHT, ONE); + img.setAttribute(HTML.ATTR_BORDER, ZERO); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java (working copy) @@ -20,15 +20,18 @@ import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.HTML; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -// This template defines the toggling methods but doesn't implements VpeToggableTemplate -// because of external toggle control. - +/** + * This template defines the toggling methods + * but doesn't implements VpeToggableTemplate + * because of external toggle control. + */ public class RichFacesTogglePanelTemplate extends VpeAbstractTemplate { private static Map toggleMap = new HashMap(); @@ -39,7 +42,7 @@ Element sourceElement = (Element)sourceNode; - nsIDOMElement div = visualDocument.createElement("div"); //$NON-NLS-1$ + nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV); VpeCreationData creationData = new VpeCreationData(div); Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java (working copy) @@ -11,7 +11,11 @@ package org.jboss.tools.jsf.vpe.richfaces.template; import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; @@ -19,8 +23,8 @@ import org.jboss.tools.vpe.editor.template.VpeCreationData; import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; import org.jboss.tools.vpe.editor.util.VisualDomUtil; -import org.jboss.tools.vpe.editor.util.VpeStyleUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMNode; @@ -29,11 +33,10 @@ import org.w3c.dom.NodeList; public class RichFacesDataTableTemplate extends VpeAbstractTemplate { - + public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { Element sourceElement = (Element)sourceNode; - nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE); VisualDomUtil.copyAttributes(sourceNode, table); @@ -59,19 +62,33 @@ colgroup.appendChild(col); } } + + /* + * Encode Caption + */ + Element caption = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_CAPTION); + Map> captionFacetChildren = VisualDomUtil.findFacetElements(caption, pageContext); + Node captionNode= null; + if (captionFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).size() > 0) { + captionNode = captionFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).get(0); + } + encodeCaption(pageContext, creationData, sourceElement, visualDocument,table,captionNode); - //Encode Caption - encodeCaption(creationData, sourceElement, visualDocument, table); - - // Encode Header - Node header = ComponentUtil.getFacet((Element)sourceElement, RichFaces.NAME_FACET_HEADER,true); - final boolean hasColumnWithHeader = hasColumnWithFacet(columns, RichFaces.NAME_FACET_HEADER); - if(header!=null || hasColumnWithHeader) { + /* + * Encode Header + */ + Element header = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_HEADER); + Map> headerFacetChildren = VisualDomUtil.findFacetElements(header, pageContext); + boolean headerJsfElementPresents = headerFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).size() > 0; + boolean hasColumnWithHeader = hasColumnWithFacet(columns, RichFaces.NAME_FACET_HEADER); + if(headerJsfElementPresents || hasColumnWithHeader) { nsIDOMElement thead = visualDocument.createElement(HTML.TAG_THEAD); table.appendChild(thead); String headerClass = (String) sourceElement.getAttribute(RichFaces.ATTR_HEADER_CLASS); - if(header != null) { - encodeTableHeaderOrFooterFacet(pageContext, creationData, thead, columnsLength, visualDocument, header, + if(headerJsfElementPresents) { + Node node = headerFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).get(0); + encodeTableHeaderOrFooterFacet(pageContext, creationData, + thead, columnsLength, visualDocument, node, "dr-table-header rich-table-header", //$NON-NLS-1$ "dr-table-header-continue rich-table-header-continue", //$NON-NLS-1$ "dr-table-headercell rich-table-headercell", //$NON-NLS-1$ @@ -84,16 +101,21 @@ if(styleClass!=null) { tr.setAttribute(HTML.ATTR_CLASS, styleClass); } - encodeHeaderOrFooterFacets(pageContext, creationData, tr, visualDocument, columns, + encodeHeaderOrFooterFacets(pageContext, creationData, tr, + visualDocument, columns, "dr-table-subheadercell rich-table-subheadercell", //$NON-NLS-1$ headerClass, RichFaces.NAME_FACET_HEADER, HTML.TAG_TD); } } - // Encode Footer - Node footer = ComponentUtil.getFacet((Element)sourceElement, RichFaces.NAME_FACET_FOOTER,true); - final boolean hasColumnWithFooter = hasColumnWithFacet(columns, RichFaces.NAME_FACET_FOOTER); - if (footer != null || hasColumnWithFooter) { + /* + * Encode Footer + */ + Element footer = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_FOOTER); + Map> footerFacetChildren = VisualDomUtil.findFacetElements(footer, pageContext); + boolean footerJsfElementPresents = footerFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).size() > 0; + boolean hasColumnWithFooter = hasColumnWithFacet(columns, RichFaces.NAME_FACET_FOOTER); + if (footerJsfElementPresents || hasColumnWithFooter) { nsIDOMElement tfoot = visualDocument.createElement(HTML.TAG_TFOOT); table.appendChild(tfoot); String footerClass = (String) sourceElement.getAttribute(RichFaces.ATTR_FOOTER_CLASS); @@ -104,12 +126,15 @@ if(styleClass!=null) { tr.setAttribute(HTML.ATTR_CLASS, styleClass); } - encodeHeaderOrFooterFacets(pageContext, creationData, tr, visualDocument, columns, + encodeHeaderOrFooterFacets(pageContext, creationData, tr, + visualDocument, columns, "dr-table-subfootercell rich-table-subfootercell", //$NON-NLS-1$ footerClass, RichFaces.NAME_FACET_FOOTER, HTML.TAG_TD); } - if (footer != null) { - encodeTableHeaderOrFooterFacet(pageContext, creationData, tfoot, columnsLength, visualDocument, footer, + if (footerJsfElementPresents) { + Node node = footerFacetChildren.get(VisualDomUtil.FACET_JSF_TAG).get(0); + encodeTableHeaderOrFooterFacet(pageContext, creationData, + tfoot, columnsLength, visualDocument, node, "dr-table-footer rich-table-footer", //$NON-NLS-1$ "dr-table-footer-continue rich-table-footer-continue", //$NON-NLS-1$ "dr-table-footercell rich-table-footercell", //$NON-NLS-1$ @@ -123,10 +148,15 @@ return creationData; } - protected void encodeCaption(VpeCreationData creationData, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement table) { - //Encode caption - Element captionFromFacet = ComponentUtil.getFacet(sourceElement, RichFaces.NAME_FACET_CAPTION); - if (captionFromFacet != null) { + protected void encodeCaption(VpePageContext pageContext, + VpeCreationData creationData, Element sourceElement, + nsIDOMDocument visualDocument, nsIDOMElement table, + Node captionBody) { + + /* + * Encode caption + */ + if (null != captionBody) { String captionClass = (String) table.getAttribute(RichFaces.ATTR_CAPTION_CLASS); String captionStyle = (String) table.getAttribute(RichFaces.ATTR_CAPTION_STYLE); @@ -143,53 +173,72 @@ } VpeChildrenInfo cap = new VpeChildrenInfo(caption); - cap.addSourceChild(captionFromFacet); + /* + * Display existing JSF component + */ + cap.addSourceChild(captionBody); creationData.addChildrenInfo(cap); } } - public static void encodeHeaderOrFooterFacets(VpePageContext pageContext, VpeCreationData creationData, - nsIDOMElement parentTr, nsIDOMDocument visualDocument, ArrayList headersOrFooters, - String skinCellClass, String headerClass, String facetName, String element) { + public static void encodeHeaderOrFooterFacets(VpePageContext pageContext, + VpeCreationData creationData, nsIDOMElement parentTr, + nsIDOMDocument visualDocument, ArrayList headersOrFooters, + String skinCellClass, String headerClass, String facetName, + String element) { + for (Element column : headersOrFooters) { - String classAttribute = facetName + "Class"; //$NON-NLS-1$ - - String columnHeaderClass = column.getAttribute(classAttribute); - nsIDOMElement td = visualDocument.createElement(element); - parentTr.appendChild(td); - String styleClass = ComponentUtil.encodeStyleClass(null, skinCellClass, headerClass, columnHeaderClass); - if (!RichFacesColumnTemplate.isVisible(column)) { - VisualDomUtil.setSubAttribute(td, HTML.ATTR_STYLE, - HTML.STYLE_PARAMETER_DISPLAY, HTML.STYLE_VALUE_NONE); + Element facet = SourceDomUtil.getFacetByName(column, facetName); + /* + * If facet is null unwanted cells might be added. + * Thus do not add TD for such facets. + */ + if (null != facet) { + String classAttribute = facetName + "Class"; //$NON-NLS-1$ + + String columnHeaderClass = column.getAttribute(classAttribute); + nsIDOMElement td = visualDocument.createElement(element); + parentTr.appendChild(td); + String styleClass = ComponentUtil.encodeStyleClass(null, skinCellClass, headerClass, columnHeaderClass); + if (!RichFacesColumnTemplate.isVisible(column)) { + VisualDomUtil.setSubAttribute(td, HTML.ATTR_STYLE, + HTML.STYLE_PARAMETER_DISPLAY, HTML.STYLE_VALUE_NONE); + } + td.setAttribute(HTML.ATTR_CLASS, styleClass); + td.setAttribute(HTML.ATTR_SCOPE, "col"); //$NON-NLS-1$ + String colspan = column.getAttribute("colspan"); //$NON-NLS-1$ + if(colspan!=null && colspan.length()>0) { + td.setAttribute(HTML.ATTR_COLSPAN, colspan); + } + + if (RichFaces.NAME_FACET_HEADER.equals(facetName)) { + nsIDOMElement icon = RichFacesColumnTemplate.getHeaderIcon(pageContext, column, visualDocument); + if (icon != null) { + td.appendChild(icon); + } + } + /* + * Add facet source here + */ + VpeChildrenInfo childrenInfo = new VpeChildrenInfo(td); + childrenInfo.addSourceChild(facet); + creationData.addChildrenInfo(childrenInfo); } - td.setAttribute(HTML.ATTR_CLASS, styleClass); - td.setAttribute(HTML.ATTR_SCOPE, "col"); //$NON-NLS-1$ - String colspan = column.getAttribute("colspan"); //$NON-NLS-1$ - if(colspan!=null && colspan.length()>0) { - td.setAttribute(HTML.ATTR_COLSPAN, colspan); - } - Node facetBody = ComponentUtil.getFacet(column, facetName,true); - - nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN); - td.appendChild(span); - if (RichFaces.NAME_FACET_HEADER.equals(facetName)) { - nsIDOMElement icon = RichFacesColumnTemplate.getHeaderIcon(pageContext, column, visualDocument); - if (icon != null) { - td.appendChild(icon); - } - } - - VpeChildrenInfo childrenInfo = new VpeChildrenInfo(span); - childrenInfo.addSourceChild(facetBody); - creationData.addChildrenInfo(childrenInfo); - } } - protected void encodeTableHeaderOrFooterFacet(final VpePageContext pageContext, VpeCreationData creationData, - nsIDOMElement parentTheadOrTfood, int columns, nsIDOMDocument visualDocument, Node facetBody, - String skinFirstRowClass, String skinRowClass, String skinCellClass, String facetBodyClass, String element) { + protected void encodeTableHeaderOrFooterFacet( + final VpePageContext pageContext, VpeCreationData creationData, + nsIDOMElement parentTheadOrTfood, int columns, + nsIDOMDocument visualDocument, Node facetBody, + String skinFirstRowClass, String skinRowClass, + String skinCellClass, String facetBodyClass, String facetVisualNode) { + + if (null == facetBody) { + RichFacesTemplatesActivator.getDefault().logError("Facet Body is null !"); //$NON-NLS-1$ + } + boolean isColumnGroup = facetBody.getNodeName().endsWith(RichFaces.TAG_COLUMN_GROUP); boolean isSubTable = facetBody.getNodeName().endsWith(RichFaces.TAG_SUB_TABLE); if(isColumnGroup) { @@ -207,7 +256,7 @@ String style = ComponentUtil.getHeaderBackgoundImgStyle(); tr.setAttribute(HTML.ATTR_STYLE, style); - nsIDOMElement td = visualDocument.createElement(element); + nsIDOMElement td = visualDocument.createElement(facetVisualNode); tr.appendChild(td); styleClass = ComponentUtil.encodeStyleClass(null, skinCellClass, facetBodyClass, null); Index: src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java (working copy) @@ -18,6 +18,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; @@ -31,6 +32,8 @@ import org.jboss.tools.vpe.editor.util.ElService; import org.jboss.tools.vpe.editor.util.FileUtil; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMElement; import org.mozilla.interfaces.nsIDOMNode; import org.mozilla.interfaces.nsIDOMNodeList; @@ -185,30 +188,21 @@ String facetName, boolean last) { NodeList children = parentElement.getChildNodes(); - if (children != null) { - int index = last ? children.getLength()-1 : 0; int step = last ? -1 : 1; int stopIndex = last ? -1 : children.getLength(); - while (index != stopIndex) { - Node child = children.item(index); - if ((child.getNodeType() == Node.ELEMENT_NODE) && RichFaces.TAG_FACET.equals(child.getLocalName()) && facetName.equals(((Element) child) .getAttribute(RichFaces.ATTR_NAME))) { return (Element) child; } - index += step; - } - } - return null; } @@ -375,7 +369,8 @@ NodeList nodeList = sourceElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node child = nodeList.item(i); - if ((child instanceof Element || returnTextNodes) && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$ + if ((child instanceof Element && !child.getNodeName().equals("f:facet")) //$NON-NLS-1$ + || (returnTextNodes && (null != child.getNodeValue()) && (child.getNodeValue().trim().length() > 0))) { children.add(child); } } @@ -971,4 +966,47 @@ } return widthDouble; } -} \ No newline at end of file + + /** + * If there are several JSF tags inside RichFaces tag + * only the first one will be returned. + * + * @param pageContext the page context + * @param sourceElement the source element + * @param facetName the name of the facet + * @return the first JSF tag + */ + public static Node getFacetBody(VpePageContext pageContext, + Element sourceElement, String facetName) { + Element facet = SourceDomUtil.getFacetByName(sourceElement, facetName); + Map> facetChildren = VisualDomUtil + .findFacetElements(facet, pageContext); + return getFacetBody(facetChildren); + } + + /** + * Select the first JSF component among facet's children + * + * @param facetChildren the map returned from + * {@link VisualDomUtil#findFacetElements(Element, VpePageContext)} + * @return the first JSF tag + */ + public static Node getFacetBody(Map> facetChildren) { + Node facetBody = null; + /* + * Display the first JSF Tag + */ + if (facetChildren.get(VisualDomUtil.FACET_ODD_TAGS).size() > 0) { + List oddTags = new ArrayList(0); + oddTags.addAll(facetChildren.get(VisualDomUtil.FACET_ODD_TAGS)); + facetBody = oddTags.get(0); + } else if (facetChildren.get(VisualDomUtil.FACET_JSF_TAG).size() > 0) { + /* + * Display the last JSF Tag + */ + facetBody = facetChildren.get(VisualDomUtil.FACET_JSF_TAG).get(0); + } + return facetBody; + } + +} Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java (working copy) @@ -4,10 +4,8 @@ package org.jboss.tools.jsf.vpe.richfaces.template; import java.util.ArrayList; -import java.util.List; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; -import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil; import org.jboss.tools.jsf.vpe.richfaces.Messages; import org.jboss.tools.jsf.vpe.richfaces.RichFacesTemplatesActivator; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; @@ -15,6 +13,7 @@ import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; +import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; @@ -37,7 +36,6 @@ private static final String DEFAULT_HEIGHT = "200px"; //$NON-NLS-1$ private static final String DEFAULT_WIDTH = "300px"; //$NON-NLS-1$ - private static final String CAPTION_FACET = "caption"; //$NON-NLS-1$ private static final String TOP_CONTROL_FACET = "topControl"; //$NON-NLS-1$ private static final String UP_CONTROL_FACET = "upControl"; //$NON-NLS-1$ private static final String DOWN_CONTROL_FACET = "downControl"; //$NON-NLS-1$ @@ -45,17 +43,7 @@ private static final String HEADER = "header"; //$NON-NLS-1$ private static final String HEADER_CLASS = "headerClass"; //$NON-NLS-1$ - private static final String FOOTER = "footer"; //$NON-NLS-1$ - private static final String FOOTER_CLASS = "footerClass"; //$NON-NLS-1$ - private static final String CAPTION_CLASS = "captionClass"; //$NON-NLS-1$ - private static final String CAPTION_STYLE = "captionStyle"; //$NON-NLS-1$ - private static final String SPACE = " "; //$NON-NLS-1$ - private static final String STYLE_FOR_LOW_SCROLL = "overflow: scroll; width: 100%; height: 17px;"; //$NON-NLS-1$ - private static final String STYLE_FOR_RIGHT_SCROLL = "overflow: scroll; width: 17px; height: 100%;"; //$NON-NLS-1$ - - private static final int NUM_ROW = 1; - private static final String TOP_CONTROL_IMG = "orderingList/top.gif"; //$NON-NLS-1$ private static final String UP_CONTROL_IMG = "orderingList/up.gif"; //$NON-NLS-1$ private static final String DOWN_CONTROL_IMG = "orderingList/down.gif"; //$NON-NLS-1$ @@ -94,7 +82,6 @@ private static final String UP_CONTROL_CLASS = "upControlClass"; //$NON-NLS-1$ private static final String DOWN_CONTROL_CLASS = "downControlClass"; //$NON-NLS-1$ private static final String BOTTOM_CONTROL_CLASS = "bottomControlClass"; //$NON-NLS-1$ - private static final String ROW_CLASSES = "rowClasses"; //$NON-NLS-1$ private static final String CSS_CAPTION_CLASS = "rich-ordering-list-caption"; //$NON-NLS-1$ @@ -112,16 +99,12 @@ private static final String CSS_HEADER_CLASS = "rich-ordering-list-header"; //$NON-NLS-1$ private static final String CSS_TABLE_HEADER_CLASS = "rich-ordering-list-table-header"; //$NON-NLS-1$ private static final String CSS_TABLE_HEADER_CELL_CLASS = "rich-ordering-list-table-header-cell"; //$NON-NLS-1$ - private static final String CSS_FOOTER_CLASS = "rich-ordering-list-footer"; //$NON-NLS-1$ - private static final String CSS_TABLE_FOOTER_CLASS = "rich-ordering-list-table-footer"; //$NON-NLS-1$ - private static final String CSS_TABLE_FOOTER_CELL_CLASS = "rich-ordering-list-table-footer-cell"; //$NON-NLS-1$ private static final String CSS_LIST_BODY_CLASS = "rich-ordering-list-body"; //$NON-NLS-1$ private static final String CSS_LIST_OUTPUT_CLASS = "rich-ordering-list-output"; //$NON-NLS-1$ private static final String CSS_LIST_CONTENT_CLASS = "rich-ordering-list-content"; //$NON-NLS-1$ private static final String CSS_LIST_ITEMS_CLASS = "rich-ordering-list-items"; //$NON-NLS-1$ private static final String CSS_LIST_ROW_CLASS = "rich-ordering-list-row"; //$NON-NLS-1$ - private static final String CSS_LIST_CELL_CLASS = "rich-ordering-list-cell"; //$NON-NLS-1$ /* * (non-Javadoc) @@ -132,6 +115,15 @@ public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { + /* + * Setting up ordering list css file + */ + ComponentUtil.setCSSLink(pageContext, "orderingList/orderingList.css", //$NON-NLS-1$ + "richFacesOrderingList"); //$NON-NLS-1$ + + /* + * Getting source node attributes + */ Element sourceElement = (Element) sourceNode; String width = sourceElement.getAttribute(WIDTH); @@ -144,156 +136,97 @@ String controlsVerticalAlign = sourceElement.getAttribute(CONTROLS_VERTICAL_ALIGN); String captionLabel = sourceElement.getAttribute(CAPTION_LABEL); - // --------------------- COMMON TABLE ------------------------ + /* + * Crating tags structure + */ + nsIDOMElement tableCommon = visualDocument.createElement(HTML.TAG_TABLE); + nsIDOMElement tableBody = visualDocument.createElement(HTML.TAG_TBODY); + nsIDOMElement tableCaptionRow = visualDocument.createElement(HTML.TAG_TR); + nsIDOMElement tableCaptionCell = visualDocument.createElement(HTML.TAG_TD); + nsIDOMElement tableCaptionDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement tableListAndButtonsRow = visualDocument.createElement(HTML.TAG_TR); + nsIDOMElement leftCell = visualDocument.createElement(HTML.TAG_TD); + nsIDOMElement rightCell = visualDocument.createElement(HTML.TAG_TD); + nsIDOMElement tableListCell; + nsIDOMElement tableButtonsCell; + tableCaptionCell.appendChild(tableCaptionDiv); + tableCaptionRow.appendChild(tableCaptionCell); + tableBody.appendChild(tableCaptionRow); + tableListAndButtonsRow.appendChild(leftCell); + tableListAndButtonsRow.appendChild(rightCell); + tableBody.appendChild(tableListAndButtonsRow); + tableCommon.appendChild(tableBody); - ComponentUtil.setCSSLink(pageContext, "orderingList/orderingList.css", //$NON-NLS-1$ - "richFacesOrderingList"); //$NON-NLS-1$ + /* + * Set correct controls position + */ + if ("left".equalsIgnoreCase(controlsHorizontalAlign)) { //$NON-NLS-1$ + tableButtonsCell = leftCell; + tableListCell = rightCell; + tableButtonsCell.setAttribute(HTML.ATTR_STYLE, "width: 1%;"); //$NON-NLS-1$ + } else { + tableButtonsCell = rightCell; + tableListCell = leftCell; + } - nsIDOMElement tableCommon = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TABLE); - + /* + * Creating template's VpeCreationData. + */ VpeCreationData creationData = new VpeCreationData(tableCommon); - - nsIDOMElement dataRow = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); - tableCommon.setAttribute(HtmlComponentUtil.HTML_ATR_WIDTH, (width == null ? DEFAULT_WIDTH : width)); - tableCommon.setAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT, (height == null ? DEFAULT_HEIGHT : height)); + /* + * Setting required attributes + */ + tableCommon.setAttribute(HTML.ATTR_WIDTH, (width == null ? DEFAULT_WIDTH : width)); + tableCommon.setAttribute(HTML.ATTR_HEIGHT, (height == null ? DEFAULT_HEIGHT : height)); + tableCommon.setAttribute(HTML.ATTR_CLASS, CSS_LIST_BODY_CLASS); + tableCaptionCell.setAttribute(HTML.ATTR_CLASS, CSS_CAPTION_CLASS); - tableCommon.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_LIST_BODY_CLASS); - tableCommon.appendChild(dataRow); - - // ---------------------caption td------------------------ - - nsIDOMElement captionRow_TD_DIV = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - captionRow_TD_DIV.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_CAPTION_CLASS); - captionRow_TD_DIV.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, - "width: " + (listWidth == null ? DEFAULT_LIST_WIDTH : listWidth) + "px;" //$NON-NLS-1$ //$NON-NLS-2$ - +"height: " + (listHeight == null ? DEFAULT_LIST_WIDTH : listHeight) + "px;"); //$NON-NLS-1$ //$NON-NLS-2$ - - Element captionFacet = ComponentUtil.getFacet(sourceElement, CAPTION_FACET); + /* + * Encoding table caption + */ + Element captionFacet = ComponentUtil.getFacet(sourceElement, RichFaces.NAME_FACET_CAPTION); if (null != captionFacet) { - // Creating table caption with facet content - nsIDOMElement fecetDiv = encodeFacetsToDiv(pageContext, captionFacet, false, CSS_CAPTION_CLASS, "", creationData, visualDocument); //$NON-NLS-1$ - captionRow_TD_DIV.appendChild(fecetDiv); + /* + * Encode caption facet + */ + VpeChildrenInfo captionInfo = new VpeChildrenInfo(tableCaptionDiv); + captionInfo.addSourceChild(captionFacet); + creationData.addChildrenInfo(captionInfo); } else { - captionRow_TD_DIV.appendChild(visualDocument.createTextNode(captionLabel)); + /* + * Get value from caption label + */ + tableCaptionCell.appendChild(visualDocument.createTextNode(captionLabel)); } - // ---------------------row with list table and buttons------------------------ - nsIDOMElement dataRow_leftTD = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); - dataRow.appendChild(dataRow_leftTD); - - nsIDOMElement dataRow_rightTD = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); - dataRow.appendChild(dataRow_rightTD); - - nsIDOMElement tableListTD; - nsIDOMElement buttonsTD; - - if ("left".equalsIgnoreCase(controlsHorizontalAlign)) { //$NON-NLS-1$ - buttonsTD = dataRow_leftTD; - tableListTD = dataRow_rightTD; - buttonsTD.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "width: 1%;"); //$NON-NLS-1$ - } else { - tableListTD = dataRow_leftTD; - buttonsTD = dataRow_rightTD; - } - - // ---------------------buttons------------------------ + /* + * Encode controls + */ if (!"none".equalsIgnoreCase(controlsType)) { //$NON-NLS-1$ nsIDOMElement controlsDiv = createControlsDiv(pageContext, creationData, visualDocument, sourceElement); - buttonsTD.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, + tableButtonsCell.setAttribute(HTML.ATTR_CLASS, CSS_BUTTON_VALIGN_CLASS); - buttonsTD.setAttribute(HtmlComponentUtil.HTML_ALIGN_ATTR, "center"); //$NON-NLS-1$ + tableButtonsCell.setAttribute(HTML.ATTR_ALIGN, "center"); //$NON-NLS-1$ if ((null != controlsVerticalAlign) && ("".equals(controlsVerticalAlign))){ //$NON-NLS-1$ - buttonsTD.setAttribute(HtmlComponentUtil.HTML_ATTR_VALIGN, ("center" //$NON-NLS-1$ + tableButtonsCell.setAttribute(HTML.ATTR_VALIGN, ("center" //$NON-NLS-1$ .equalsIgnoreCase(controlsVerticalAlign) ? "middle" //$NON-NLS-1$ : controlsVerticalAlign)); } - buttonsTD.appendChild(controlsDiv); + tableButtonsCell.appendChild(controlsDiv); } - // -------------------------------------------- - - // ---------------------listTable------------------------ - nsIDOMElement listDiv = createListTableDiv(visualDocument, sourceElement, creationData, pageContext); - tableListTD.appendChild(captionRow_TD_DIV); - tableListTD.appendChild(listDiv); - // -------------------------------------------- + /* + * Encode ordering list itself + */ + tableListCell.appendChild(createResultList(pageContext, creationData, visualDocument, + sourceElement)); return creationData; } /** - * Creates the list table div. - * - * @param visualDocument the visual document - * @param sourceElement the source element - * @param creationData the creation data - * @param pageContext the page context - * - * @return the element - */ - private nsIDOMElement createListTableDiv(nsIDOMDocument visualDocument, - Element sourceElement, VpeCreationData creationData, VpePageContext pageContext) { - - nsIDOMElement listOutputDiv = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - - nsIDOMElement listTable = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TABLE); - nsIDOMElement tr1 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); - nsIDOMElement tr2 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); - - listOutputDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "overflow:hidden;width:100%;"); //$NON-NLS-1$ - listTable.appendChild(tr1); - listTable.appendChild(tr2); - listOutputDiv.appendChild(listTable); - - // ---------------------tr1------------------------ - nsIDOMElement tr1_TD1 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); - tr1.appendChild(tr1_TD1); - - nsIDOMElement tr1_TD2 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); - tr1.appendChild(tr1_TD2); - - nsIDOMElement tr1_TD2_DIV = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - tr1_TD2_DIV.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, - STYLE_FOR_RIGHT_SCROLL); - tr1_TD2.appendChild(tr1_TD2_DIV); - - // ------------------------------------------------------- - - // ---------------------tr2------------------------ - nsIDOMElement tr2_TD = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TD); - tr2.appendChild(tr2_TD); - - nsIDOMElement tr2_TD_DIV = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - tr2_TD_DIV.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, - STYLE_FOR_LOW_SCROLL); - tr2_TD.appendChild(tr2_TD_DIV); - - // -------------------------------------------- - - nsIDOMElement contentDiv = createResultList(pageContext, creationData, visualDocument, - sourceElement); - tr1_TD1.appendChild(contentDiv); - - return listOutputDiv; - } - - /** * Creates the controls div. * * @param creationData the creation data @@ -323,9 +256,9 @@ boolean orderControlsVisible = ComponentUtil.string2boolean(orderControlsVisibleStr); String controlsClass = sourceElement.getAttribute(CONTROLS_CLASS); - nsIDOMElement buttonsDiv = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV); - buttonsDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_CONTROLS_CLASS + " " + controlsClass + " " //$NON-NLS-1$ //$NON-NLS-2$ + nsIDOMElement buttonsDiv = visualDocument.createElement(HTML.TAG_DIV); + buttonsDiv.setAttribute(HTML.ATTR_CLASS, + CSS_CONTROLS_CLASS + " " + (null != controlsClass ? controlsClass + " " : "") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + CSS_BUTTON_LAYOUT_CLASS); Element top_control_facet = ComponentUtil.getFacet(sourceElement, TOP_CONTROL_FACET); @@ -378,43 +311,44 @@ * @param cssStyleName the css style name * @param customStyleClass the custom style class * - * @return the ns idom element + * @return the element */ private nsIDOMElement createSingleButtonDiv(final VpePageContext pageContext, VpeCreationData creationData, nsIDOMDocument visualDocument, String btnName, String imgName, boolean showButtonLabels, Element buttonFacet, String cssStyleName, String customStyleClass) { - nsIDOMElement div1 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - nsIDOMElement div2 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - nsIDOMElement a = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_A); - nsIDOMElement div3 = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - nsIDOMElement img = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_IMG); + nsIDOMElement div1 = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement div2 = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement a = visualDocument.createElement(HTML.TAG_A); + nsIDOMElement div3 = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG); - div1.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-buttons-border" + " " + cssStyleName + " " + customStyleClass); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - div2.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_BUTTON_CLASS); + div1.setAttribute(HTML.ATTR_CLASS, + "dr-buttons-border" + " " + cssStyleName //$NON-NLS-1$ //$NON-NLS-2$ + + (null != customStyleClass ? " " + customStyleClass : "")); //$NON-NLS-1$ //$NON-NLS-2$ + div2.setAttribute(HTML.ATTR_CLASS, CSS_BUTTON_CLASS); String resourceFolder = RichFacesTemplatesActivator.getPluginResourcePath(); String divStyle = "width: 100%;background-image: url(file://" + resourceFolder + BUTTON_BG + ");"; //$NON-NLS-1$ //$NON-NLS-2$ - div2.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, divStyle); + div2.setAttribute(HTML.ATTR_STYLE, divStyle); div1.appendChild(div2); if (null != buttonFacet) { // Creating button with facet content - nsIDOMElement fecetDiv = encodeFacetsToDiv(pageContext, buttonFacet, true, cssStyleName, customStyleClass, creationData, visualDocument); + nsIDOMElement fecetDiv = encodeControlsFacets(pageContext, + buttonFacet, cssStyleName, customStyleClass, + creationData, visualDocument); div2.appendChild(fecetDiv); } else { - a.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_BUTTON_SELECTION_CLASS); - div3.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, CSS_BUTTON_CONTENT_CLASS); + a.setAttribute(HTML.ATTR_CLASS, CSS_BUTTON_SELECTION_CLASS); + div3.setAttribute(HTML.ATTR_CLASS, CSS_BUTTON_CONTENT_CLASS); div2.appendChild(a); a.appendChild(div3); - // Creating button with image and label + /* + * Creating button with image and label + */ ComponentUtil.setImg(img, imgName); img.setAttribute(HTML.ATTR_WIDTH, "15"); //$NON-NLS-1$ img.setAttribute(HTML.ATTR_HEIGHT, "15"); //$NON-NLS-1$ @@ -438,152 +372,126 @@ */ private nsIDOMElement createResultList(final VpePageContext pageContext, VpeCreationData creationData, nsIDOMDocument visualDocument, Element sourceElement) { - nsIDOMElement contentDiv = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - nsIDOMElement contentTable = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TABLE); - nsIDOMElement thead = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_THEAD); - nsIDOMElement tfoot = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TFOOT); + /* + * Create list elements + */ + nsIDOMElement contentDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement contentTable = visualDocument.createElement(HTML.TAG_TABLE); + nsIDOMElement thead = visualDocument.createElement(HTML.TAG_THEAD); + /* + * Get list columns + */ ArrayList columns = getColumns(sourceElement); - int columnsLength = getColumnsCount(sourceElement, columns); - // ---------- HEADER ----------- - // Encode Header - Element header = ComponentUtil.getFacet(sourceElement, HEADER); + /* + * Encode Header + */ ArrayList columnsHeaders = ComponentUtil.getColumnsWithFacet(columns, HEADER); - if (header != null || !columnsHeaders.isEmpty()) { - String headerClass = (String) sourceElement - .getAttribute(HEADER_CLASS); - /* - if (header != null) { - encodeTableHeaderOrFooterFacet(creationData, thead, - columnsLength, visualDocument, header, - CSS_HEADER_CLASS, - CSS_HEADER_CLASS, - headerClass, HtmlComponentUtil.HTML_TAG_TD); + if (!columnsHeaders.isEmpty()) { + String headerClass = (String) sourceElement.getAttribute(HEADER_CLASS); + nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR); + thead.appendChild(tr); + String styleClass = ComponentUtil.encodeStyleClass(null, + CSS_HEADER_CLASS + " " + CSS_TABLE_HEADER_CLASS, Constants.EMPTY, //$NON-NLS-1$ + headerClass); + if (styleClass != null) { + tr.setAttribute(HTML.ATTR_CLASS,styleClass); } - */ - if (!columnsHeaders.isEmpty()) { - nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR); - thead.appendChild(tr); - String styleClass = ComponentUtil.encodeStyleClass(null, - CSS_HEADER_CLASS + " " + CSS_TABLE_HEADER_CLASS, null, //$NON-NLS-1$ - headerClass); - if (styleClass != null) { - tr.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - styleClass); + + /* + * Encoding columns headers + */ + for (Element column : columnsHeaders) { + String columnHeaderClass = column.getAttribute(RichFaces.ATTR_HEADER_CLASS); + nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); + tr.appendChild(td); + td.setAttribute(HTML.ATTR_BACKGROUND, "file:///" //$NON-NLS-1$ + + ComponentUtil.getAbsoluteResourcePath(HEADER_CELL_BG).replace('\\', '/')); + styleClass = ComponentUtil.encodeStyleClass(null, CSS_TABLE_HEADER_CELL_CLASS, + headerClass, columnHeaderClass); + td.setAttribute(HTML.ATTR_CLASS, styleClass); + + String colspan = column.getAttribute(HTML.ATTR_COLSPAN); + if (colspan != null && colspan.length() > 0) { + td.setAttribute(HTML.ATTR_COLSPAN, colspan); } - encodeHeaderOrFooterFacets(creationData, tr, visualDocument, - columnsHeaders, - CSS_TABLE_HEADER_CELL_CLASS, - headerClass, HEADER, HtmlComponentUtil.HTML_TAG_TD); + Element facetBody = ComponentUtil.getFacet(column, RichFaces.NAME_FACET_HEADER); + VpeChildrenInfo child = new VpeChildrenInfo(td); + child.addSourceChild(facetBody); + creationData.addChildrenInfo(child); } } - - // ---------- FOOTER ----------- - // Encode Footer - /* - Element footer = ComponentUtil.getFacet(sourceElement, FOOTER); - ArrayList columnsFooters = ComponentUtil.getColumnsWithFacet(columns, FOOTER); - if (footer != null || !columnsFooters.isEmpty()) { - String footerClass = (String) sourceElement - .getAttribute(FOOTER_CLASS); - if (!columnsFooters.isEmpty()) { - nsIDOMElement tr = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); - tfoot.appendChild(tr); - String styleClass = ComponentUtil.encodeStyleClass(null, - CSS_TABLE_HEADER_CLASS + " " + CSS_TABLE_HEADER_CELL_CLASS, null, - footerClass); - if (styleClass != null) { - tr.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - styleClass); - } - encodeHeaderOrFooterFacets(creationData, tr, visualDocument, - columnsFooters, - CSS_TABLE_FOOTER_CLASS + " " + CSS_TABLE_FOOTER_CELL_CLASS, - footerClass, FOOTER, HtmlComponentUtil.HTML_TAG_TD); - } - - if (footer != null) { - encodeTableHeaderOrFooterFacet(creationData, tfoot, - columnsLength, visualDocument, footer, - CSS_FOOTER_CLASS, - CSS_HEADER_CLASS, - footerClass, HtmlComponentUtil.HTML_TAG_TD); - } - - } - */ - // ---------- CONTENT ----------- + /* + * Encode content + */ String listWidth = sourceElement.getAttribute(LIST_WIDTH); String listHeight = sourceElement.getAttribute(LIST_HEIGHT); String listClass = sourceElement.getAttribute(LIST_CLASS); - // TODO: implement support of rowClasses - // following line commented by yradtsevich because the variable rowClasses was not used - //String rowClasses = sourceElement.getAttribute(ROW_CLASSES); + /* + * TODO: implement support of rowClasses + * following line commented by yradtsevich + * because the variable rowClasses was not used + */ +// String rowClasses = sourceElement.getAttribute(ROW_CLASSES); - String divStyle = HtmlComponentUtil.HTML_WIDTH_ATTR + " : " //$NON-NLS-1$ + String divStyle = HTML.ATTR_WIDTH + " : " //$NON-NLS-1$ + (listWidth == null ? DEFAULT_LIST_WIDTH : listWidth) + ";" //$NON-NLS-1$ - + HtmlComponentUtil.HTML_HEIGHT_ATTR + " : " //$NON-NLS-1$ - + (listHeight == null ? DEFAULT_LIST_HEIGHT : listHeight) + ";"; //$NON-NLS-1$ + + HTML.ATTR_HEIGHT + " : " //$NON-NLS-1$ + + (listHeight == null ? DEFAULT_LIST_HEIGHT : listHeight) + ";" //$NON-NLS-1$ + + "overflow: scroll;"; //$NON-NLS-1$ - contentDiv.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, divStyle); + contentDiv.setAttribute(HTML.ATTR_STYLE, divStyle); - contentDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, + contentDiv.setAttribute(HTML.ATTR_CLASS, CSS_LIST_OUTPUT_CLASS + " " + CSS_LIST_CONTENT_CLASS); //$NON-NLS-1$ - contentTable.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, + contentTable.setAttribute(HTML.ATTR_CLASS, CSS_LIST_ITEMS_CLASS + " " + (null == listClass ? "" : listClass)); //$NON-NLS-1$ //$NON-NLS-2$ - contentTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, "1"); //$NON-NLS-1$ + contentTable.setAttribute(HTML.ATTR_CELLSPACING, "1"); //$NON-NLS-1$ VisualDomUtil.copyAttributes(sourceElement, contentTable); - contentTable.removeAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT); - contentTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "width: 100%;"); //$NON-NLS-1$ + contentTable.removeAttribute(HTML.ATTR_HEIGHT); + contentTable.setAttribute(HTML.ATTR_STYLE, "width: 100%;"); //$NON-NLS-1$ - // ---------- FINALIZING and children encoding ----------- + /* + * Encode children + */ contentTable.appendChild(thead); - RichFacesDataTableChildrenEncoder childrenEncoder = new RichFacesDataTableChildrenEncoder(creationData, visualDocument, - sourceElement, contentTable); + RichFacesDataTableChildrenEncoder childrenEncoder = new RichFacesDataTableChildrenEncoder( + creationData, visualDocument, sourceElement, contentTable); childrenEncoder.setRowClasses(CSS_LIST_ROW_CLASS, CSS_LIST_ROW_CLASS); childrenEncoder.encodeChildren(); - //contentTable.appendChild(tfoot); contentDiv.appendChild(contentTable); - //outputDiv.appendChild(contentDiv); return contentDiv; - //return outputDiv; } - + /** - * Encodes facets to div. + * Encodes controls facets to DIV element with TABLE. * + * @param pageContext * @param facetBody the facet body - * @param isControlFacet the is control facet * @param cssStyleName the css style name * @param customStyleClass the custom style class * @param creationData the creation data * @param visualDocument the visual document - * - * @return the element + * @return the DIV element with facet */ - private nsIDOMElement encodeFacetsToDiv(final VpePageContext pageContext, Element facetBody, - boolean isControlFacet, String cssStyleName, - String customStyleClass, VpeCreationData creationData, - nsIDOMDocument visualDocument) { - nsIDOMElement fecetDiv = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_DIV); - nsIDOMElement table = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TABLE); - nsIDOMElement tbody = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TBODY); + private nsIDOMElement encodeControlsFacets(final VpePageContext pageContext, + Element facetBody, String cssStyleName, String customStyleClass, + VpeCreationData creationData, nsIDOMDocument visualDocument) { + /* + * Create table for facet + */ + nsIDOMElement fecetDiv = visualDocument.createElement(HTML.TAG_DIV); + nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE); + nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY); + boolean isColumnGroup = facetBody.getNodeName() .endsWith(":columnGroup"); //$NON-NLS-1$ boolean isSubTable = facetBody.getNodeName().endsWith(":subTable"); //$NON-NLS-1$ @@ -595,155 +503,40 @@ facetBody, visualDocument, tbody); } else { nsIDOMElement tr = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); + .createElement(HTML.TAG_TR); tbody.appendChild(tr); - nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD); + nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD); tr.appendChild(td); - td.setAttribute(HtmlComponentUtil.HTML_SCOPE_ATTR, - HtmlComponentUtil.HTML_TAG_COLGROUP); + td.setAttribute(HTML.ATTR_SCOPE, + HTML.TAG_COLGROUP); VpeChildrenInfo child = new VpeChildrenInfo(td); child.addSourceChild(facetBody); creationData.addChildrenInfo(child); - - if (isControlFacet) { - - tr.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_BUTTON_CLASS); - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_BUTTON_CONTENT_CLASS + " " + cssStyleName + " " //$NON-NLS-1$ //$NON-NLS-2$ - + customStyleClass); - - fecetDiv.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_BUTTON_CLASS + " " + CSS_BUTTON_CONTENT_CLASS + " " //$NON-NLS-1$ //$NON-NLS-2$ - + cssStyleName + " " + customStyleClass); //$NON-NLS-1$ - - } + + /* + * It is always controls facet + */ + tr.setAttribute(HTML.ATTR_CLASS,CSS_BUTTON_CLASS); + td.setAttribute(HTML.ATTR_CLASS, + CSS_BUTTON_CONTENT_CLASS + " " + cssStyleName + " " //$NON-NLS-1$ //$NON-NLS-2$ + + customStyleClass); + + fecetDiv.setAttribute(HTML.ATTR_CLASS, + CSS_BUTTON_CLASS + " " + CSS_BUTTON_CONTENT_CLASS + " " //$NON-NLS-1$ //$NON-NLS-2$ + + cssStyleName + " " + customStyleClass); //$NON-NLS-1$ } - - if (isControlFacet) { - table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_BUTTON_CONTENT_CLASS); - } else { - table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, - CSS_CAPTION_CLASS); - } - + + table.setAttribute(HTML.ATTR_CLASS,CSS_BUTTON_CONTENT_CLASS); table.appendChild(tbody); fecetDiv.appendChild(table); return fecetDiv; - //return table; } /** * - * @param creationData - * @param parentTheadOrTfood - * @param columns - * @param visualDocument - * @param facetBody - * @param skinFirstRowClass - * @param skinRowClass - * @param skinCellClass - * @param facetBodyClass - * @param element - */ - private void encodeTableHeaderOrFooterFacet(final VpePageContext pageContext, VpeCreationData creationData, - nsIDOMElement parentTheadOrTfood, int columns, - nsIDOMDocument visualDocument, Element facetBody, - String skinFirstRowClass, String skinCellClass, - String facetBodyClass, String element) { - boolean isColumnGroup = facetBody.getNodeName() - .endsWith(":columnGroup"); //$NON-NLS-1$ - boolean isSubTable = facetBody.getNodeName().endsWith(":subTable"); //$NON-NLS-1$ - if (isColumnGroup) { - RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData, - facetBody, visualDocument, parentTheadOrTfood); - } else if (isSubTable) { - RichFacesSubTableTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData, - facetBody, visualDocument, parentTheadOrTfood); - } else { - nsIDOMElement tr = visualDocument - .createElement(HtmlComponentUtil.HTML_TAG_TR); - parentTheadOrTfood.appendChild(tr); - - String styleClass = ComponentUtil.encodeStyleClass(null, skinFirstRowClass, - facetBodyClass, null); - if (styleClass != null) { - tr.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); - } - String style = ComponentUtil.getHeaderBackgoundImgStyle(); - tr.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style); - - nsIDOMElement td = visualDocument.createElement(element); - tr.appendChild(td); - - styleClass = ComponentUtil.encodeStyleClass(null, skinCellClass, facetBodyClass, - null); - if (styleClass != null) { - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); - } - - // the cell spans the entire row - td.setAttribute(HTML.ATTR_COLSPAN, HTML.VALUE_COLSPAN_ALL); - td.setAttribute(HtmlComponentUtil.HTML_SCOPE_ATTR, - HtmlComponentUtil.HTML_TAG_COLGROUP); - - VpeChildrenInfo child = new VpeChildrenInfo(td); - child.addSourceChild(facetBody); - creationData.addChildrenInfo(child); - } - } - - /** - * - * @param creationData - /** - * - * @param creationData - * @param parentTr - * @param visualDocument - * @param headersOrFooters - * @param skinCellClass - * @param headerClass - * @param facetName - * @param element - */ - private static void encodeHeaderOrFooterFacets(VpeCreationData creationData, - nsIDOMElement parentTr, nsIDOMDocument visualDocument, - ArrayList headersOrFooters, String skinCellClass, - String headerClass, String facetName, String element) { - for (Element column : headersOrFooters) { - String classAttribute = facetName + "Class"; //$NON-NLS-1$ - String columnHeaderClass = column.getAttribute(classAttribute); - nsIDOMElement td = visualDocument.createElement(element); - parentTr.appendChild(td); - - td.setAttribute(HtmlComponentUtil.HTML_ATTR_BACKGROUND, "file:///" //$NON-NLS-1$ - + ComponentUtil.getAbsoluteResourcePath(HEADER_CELL_BG).replace('\\', '/')); - - String styleClass = ComponentUtil.encodeStyleClass(null, skinCellClass, - headerClass, columnHeaderClass); - td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass); - td.setAttribute("scop", "col"); //$NON-NLS-1$ //$NON-NLS-2$ - - String colspan = column - .getAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN); - if (colspan != null && colspan.length() > 0) { - td.setAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN, colspan); - } - Element facetBody = ComponentUtil.getFacet(column, facetName); - - VpeChildrenInfo child = new VpeChildrenInfo(td); - child.addSourceChild(facetBody); - creationData.addChildrenInfo(child); - } - } - - /** - * * @param parentSourceElement * @return list of columns */ @@ -761,106 +554,13 @@ return columns; } - /** - * - * @param sourceElement - * @param columns - * @return - */ - private int getColumnsCount(Element sourceElement, - ArrayList columns) { - int count = 0; - // check for exact value in component - try { - count = Integer.parseInt(sourceElement.getAttribute("columns")); //$NON-NLS-1$ - } catch (NumberFormatException e) { - // calculate max html columns count for all columns/rows children. - count = calculateRowColumns(sourceElement, columns); - } - return count; - } - - /* - * Calculate max number of columns per row. For rows, recursive calculate - * max length. - */ - private int calculateRowColumns(Element sourceElement, - ArrayList columns) { - int count = 0; - int currentLength = 0; - for (Element column : columns) { - if (ComponentUtil.isRendered(column)) { - String nodeName = column.getNodeName(); - if (nodeName.endsWith(":columnGroup")) { //$NON-NLS-1$ - // Store max calculated value of previous rows. - count = Math.max(currentLength, count); - // Calculate number of columns in row. - currentLength = calculateRowColumns(sourceElement, - getColumns(column)); - // Store max calculated value - count = Math.max(currentLength, count); - currentLength = 0; - String colspanStr = column - .getAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN); - - } else if (nodeName.equals(sourceElement.getPrefix() + COLUMN) || - nodeName.equals(sourceElement.getPrefix() + COLUMNS)) { - String breakBeforeStr = column.getAttribute("breakBefore"); //$NON-NLS-1$ - boolean breakBefore = Boolean.getBoolean(breakBeforeStr); - - // For new row, save length of previous. - if (breakBefore) { - count = Math.max (currentLength, count); - currentLength = 0; - } - - try { - String colspanStr = column - .getAttribute(HtmlComponentUtil.HTML_TABLE_COLSPAN); - currentLength += Integer.parseInt(colspanStr); - } catch (NumberFormatException e) { - currentLength++; - } - } else if (nodeName.endsWith(COLUMN)) { - // UIColumn always have colspan == 1. - currentLength++; - } - - } - } - count = Math.max (currentLength, count); - return count; - } - - /** - * Checks, whether it is necessary to re-create an element at change of - * attribute - * - * @param pageContext - * Contains the information on edited page. - * @param sourceElement - * The current element of the source tree. - * @param visualDocument - * The document of the visual tree. - * @param visualNode - * The current node of the visual tree. - * @param data - * The arbitrary data, built by a method create - * @param name - * Attribute name - * @param value - * Attribute value - * @return true if it is required to re-create an element at - * a modification of attribute, false otherwise. - */ + @Override public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String value) { return true; } - /* (non-Javadoc) - * @see org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#validate(org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument, org.jboss.tools.vpe.editor.template.VpeCreationData) */ @Override public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, VpeCreationData data) { Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceInputTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceInputTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceInputTemplate.java (working copy) @@ -13,8 +13,11 @@ import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; @@ -57,50 +60,92 @@ * The document of the visual tree. * @return The information on the created node of the visual tree. */ - public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) { - ComponentUtil.setCSSLink(pageContext, getCssStyle(), getCssExtension()); - Element sourceElement = (Element) sourceNode; - final Attributes attrs = new Attributes(sourceElement); - /* - * Prepare data - */ - prepareData(pageContext, sourceElement); + public VpeCreationData create(VpePageContext pageContext, Node sourceNode, + nsIDOMDocument visualDocument) { + ComponentUtil.setCSSLink(pageContext, getCssStyle(), getCssExtension()); + Element sourceElement = (Element) sourceNode; + final Attributes attrs = new Attributes(sourceElement); + /* + * Prepare data + */ + prepareData(pageContext, sourceElement); + + final nsIDOMElement rootSpan = createRootSpanTemplateMethod( + sourceElement, visualDocument, attrs); + final nsIDOMElement innerInput1 = visualDocument + .createElement(HTML.TAG_INPUT); + nsIDOMElement topContainer = VisualDomUtil.createBorderlessContainer(visualDocument); + nsIDOMElement textContainer = VisualDomUtil.createBorderlessContainer(visualDocument); + topContainer.appendChild(textContainer); + topContainer.appendChild(rootSpan); + VpeCreationData creationData = new VpeCreationData(topContainer); + + /* + * Encode body. + * Add text nodes to children list too. + */ + List children = ComponentUtil.getChildren(sourceElement, true); + VpeChildrenInfo spanInfo = null; + if(!children.isEmpty()) { + spanInfo = new VpeChildrenInfo(textContainer); + for (Node child : children) { + spanInfo.addSourceChild(child); + } + creationData.addChildrenInfo(spanInfo); + } + + if (isToggle) { + rootSpan.appendChild(innerInput1); + innerInput1.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, + String.valueOf(0)); + innerInput1.setAttribute(HTML.ATTR_CLASS, "rich-inplace-field"); //$NON-NLS-1$ + innerInput1.setAttribute(HTML.ATTR_STYLE, + "top: 0px; width: " + this.inputWidth + Constants.SEMICOLON); //$NON-NLS-1$ + innerInput1.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT); + innerInput1.setAttribute("autocomplete", "off"); //$NON-NLS-1$ //$NON-NLS-2$ - final nsIDOMElement rootSpan = createRootSpanTemplateMethod(sourceElement, visualDocument, attrs); - final nsIDOMElement innerInput1 = visualDocument.createElement(HTML.TAG_INPUT); - VpeCreationData creationData = VisualDomUtil.createTemplateWithTextContainer( - sourceElement, rootSpan, HTML.TAG_SPAN, visualDocument); - if (isToggle) { - rootSpan.appendChild(innerInput1); - innerInput1.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); - innerInput1.setAttribute(HTML.ATTR_CLASS, "rich-inplace-field"); //$NON-NLS-1$ - innerInput1.setAttribute(HTML.ATTR_STYLE, "top: 0px; width: " + this.inputWidth + Constants.SEMICOLON); //$NON-NLS-1$ - innerInput1.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT); - innerInput1.setAttribute("autocomplete", "off"); //$NON-NLS-1$ //$NON-NLS-2$ + if (attrs.isShowControls()) { + rootSpan.appendChild(createControlsDiv(pageContext, sourceNode, + visualDocument, creationData, attrs)); + } + } else { + innerInput1 + .setAttribute(HTML.ATTR_STYLE, + "width: " + this.inputWidth + "; position: absolute; left: -32767px;"); //$NON-NLS-1$ //$NON-NLS-2$ + innerInput1.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_BUTTON); - if (attrs.isShowControls()) { - rootSpan.appendChild(createControlsDiv(pageContext, sourceNode, - visualDocument, creationData, attrs)); - } - } else { - innerInput1.setAttribute(HTML.ATTR_STYLE, - "width: " + this.inputWidth + "; position: absolute; left: -32767px;"); //$NON-NLS-1$ //$NON-NLS-2$ - innerInput1.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_BUTTON); + /* + * Add empty children info to avoid children processing. Only + * available child is "controls" facet + */ + // creationData.addChildrenInfo(new VpeChildrenInfo(rootSpan)); + } + /* + * Add HTML tags from controls facet + */ + Element controlFacet = ComponentUtil.getFacetElement( + (Element) sourceNode, RichFaces.NAME_FACET_CONTROLS, false); + Map> controlFacetChildren = VisualDomUtil + .findFacetElements(controlFacet, pageContext); + + spanInfo = new VpeChildrenInfo(textContainer); + for (Node child : controlFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + spanInfo.addSourceChild(child); + } + if ((null != spanInfo.getSourceChildren()) + && (spanInfo.getSourceChildren().size() > 0)) { + creationData.addChildrenInfo(spanInfo); + } + + if (!isToggle) { + rootSpan + .appendChild(visualDocument.createTextNode(getValue(attrs))); + } else { + innerInput1.setAttribute(HTML.ATTR_VALUE, getValue(attrs)); + } + return creationData; + } - /* - * Add empty children info to avoid children processing. - * Only available child is "controls" facet - */ -// creationData.addChildrenInfo(new VpeChildrenInfo(rootSpan)); - } - if (!isToggle) { - rootSpan.appendChild(visualDocument.createTextNode(getValue(attrs))); - } else { - innerInput1.setAttribute(HTML.ATTR_VALUE, getValue(attrs)); - } - return creationData; - } - /** * Gets the css extension. * @@ -119,12 +164,6 @@ return "inplaceInput/inplaceInput.css"; //$NON-NLS-1$ } - /** - * Gets the css styles suffix. - * - * @return the css styles suffix - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getCssStylesSuffix() - */ @Override protected String getCssStylesSuffix() { return Constants.EMPTY; @@ -175,9 +214,6 @@ super.prepareImages(source); } - /** - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getCssStylesControlSuffix() - */ @Override public String getCssStylesControlSuffix() { return "-input"; //$NON-NLS-1$ Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java (working copy) @@ -12,6 +12,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; @@ -51,8 +52,33 @@ td.setAttribute(HTML.ATTR_CLASS, columnClass); final VpeCreationData creationData = new VpeCreationData(td); - // Create mapping to Encode body + Element headerFacet = SourceDomUtil.getFacetByName(sourceElement, + RichFaces.NAME_FACET_HEADER); + Element footerFacet = SourceDomUtil.getFacetByName(sourceElement, + RichFaces.NAME_FACET_FOOTER); + Map> headerFacetChildren = VisualDomUtil + .findFacetElements(headerFacet, pageContext); + Map> footerFacetChildren = VisualDomUtil + .findFacetElements(footerFacet, pageContext); + boolean headerHtmlElementPresents = headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0; + boolean footerHtmlElementPresents = footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS).size() > 0; + /* + * Encode html elements from facets to the column body + */ VpeChildrenInfo tdInfo = new VpeChildrenInfo(td); + if (headerHtmlElementPresents) { + for (Node child : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + tdInfo.addSourceChild(child); + } + } + if (footerHtmlElementPresents) { + for (Node child : footerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + tdInfo.addSourceChild(child); + } + } + /* + * Encode body + */ List children = ComponentUtil.getChildren(sourceElement,true); for (Node child : children) { if (!isFacet(child)) { Index: src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java (working copy) @@ -42,12 +42,14 @@ public static final String ATTR_LOCALE = "locale"; //$NON-NLS-1$ public static final String ATTR_CONTROLS_TYPE = "controlsType"; //$NON-NLS-1$ public static final String ATTR_DEFAULT_LABEL = "defaultLabel"; //$NON-NLS-1$ + public static final String ATTR_LABEL = "label"; //$NON-NLS-1$ public static final String ATTR_DIRECTION = "direction"; //$NON-NLS-1$ public static final String ATTR_JOINT_POINT = "jointPoint"; //$NON-NLS-1$ public static final String ATTR_DISABLED = "disabled";//$NON-NLS-1$ public static final String ATTR_ELEMENTS = "elements"; //$NON-NLS-1$ + public static final String ATTR_HEADER_CLASS = "headerClass"; //$NON-NLS-1$ + public static final String ATTR_BODY_CLASS = "bodyClass"; //$NON-NLS-1$ public static final String ATTR_FOOTER_CLASS = "footerClass"; //$NON-NLS-1$ - public static final String ATTR_HEADER_CLASS = "headerClass"; //$NON-NLS-1$ public static final String ATTR_INPUT_CLASS = "inputClass"; //$NON-NLS-1$ public static final String ATTR_INPUT_SIZE = "inputSize"; //$NON-NLS-1$ public static final String ATTR_INPUT_STYLE = "inputStyle"; //$NON-NLS-1$ @@ -75,9 +77,12 @@ public static final String ATTR_POSITION = "position"; //$NON-NLS-1$ /** FACETS NAMES **/ + public static final String NAME_FACET_LABEL = "label"; //$NON-NLS-1$ public static final String NAME_FACET_CAPTION = "caption"; //$NON-NLS-1$ public static final String NAME_FACET_FOOTER = "footer"; //$NON-NLS-1$ public static final String NAME_FACET_HEADER = "header"; //$NON-NLS-1$ + public static final String NAME_FACET_TERM = "term"; //$NON-NLS-1$ + public static final String NAME_FACET_CONTROLS = "controls"; //$NON-NLS-1$ /** jsf tags which are used with richFaces. */ public static final String TAG_COLUMN = "column"; //$NON-NLS-1$ Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessageTemplate.java (working copy) @@ -15,11 +15,11 @@ import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; import org.jboss.tools.vpe.editor.VpeSourceDomBuilder; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; -import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; @@ -40,14 +40,11 @@ protected static String FATAL_MESSAGE = "Fatal message"; //$NON-NLS-1$ protected static String INFO_MESSAGE = "Info message"; //$NON-NLS-1$ protected static String WARNING_MESSAGE = "Warning message"; //$NON-NLS-1$ + protected static String FACET_TAG_NAME = ":facet"; //$NON-NLS-1$ protected static String[] markers = { "passedMarker", "errorMarker", //$NON-NLS-1$ //$NON-NLS-2$ "fatalMarker", "infoMarker", "warnMarker" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - protected static String FACET_TAG_NAME = "facet"; //$NON-NLS-1$ - - protected static String NAME_ATTRIBUTE_NAME = "name"; //$NON-NLS-1$ - private final static String MESSAGE_STYLE = "padding-left: 1px;padding-right: 1px;padding-top: 1px;padding-bottom: 1px"; //$NON-NLS-1$ public VpeCreationData create(VpePageContext pageContext, Node sourceNode, @@ -235,6 +232,7 @@ if (!(facets.get(markers[i]) instanceof Element)) continue; else { + td.setAttribute(VpeVisualDomBuilder.VPE_FACET, markers[i]); childrenInfo.addSourceChild(facets.get(markers[i])); } tr.appendChild(td); @@ -271,20 +269,15 @@ NodeList nodeList = sourceElement.getChildNodes(); HashMap facets = new HashMap(); - for (int i = 0; i < nodeList.getLength(); i++) { - - if (!(nodeList.item(i) instanceof Element)) - continue; - - String facetName = nodeList.item(i).getPrefix() + Constants.COLON - + FACET_TAG_NAME; - - if (nodeList.item(i).getNodeName().equalsIgnoreCase(facetName) + if (!(nodeList.item(i) instanceof Element)){ + continue; + } + if (nodeList.item(i).getNodeName().endsWith(FACET_TAG_NAME) && searchInMarker(((Element) nodeList.item(i)) - .getAttribute(NAME_ATTRIBUTE_NAME))) { + .getAttribute(RichFaces.ATTR_NAME))) { facets.put(((Element) nodeList.item(i)) - .getAttribute(NAME_ATTRIBUTE_NAME), nodeList.item(i)); + .getAttribute(RichFaces.ATTR_NAME), nodeList.item(i)); } } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceSelectTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceSelectTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInplaceSelectTemplate.java (working copy) @@ -14,6 +14,7 @@ import java.util.List; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeCreationData; import org.jboss.tools.vpe.editor.util.Constants; @@ -77,7 +78,7 @@ final nsIDOMElement innerInput2 = visualDocument.createElement(HTML.TAG_INPUT); preapareInputBase(innerInput1); preapareInputBase(innerInput2); - innerInput1.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + innerInput1.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); innerInput1.setAttribute("autocomplete", "off"); //$NON-NLS-1$ //$NON-NLS-2$ innerInput1.setAttribute(HTML.ATTR_CLASS, "rich-inplace-select-field"); //$NON-NLS-1$ innerInput1.setAttribute(HTML.ATTR_VALUE, @@ -118,7 +119,7 @@ final nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV); div.setAttribute(HTML.ATTR_CLASS, "rich-inplace-select-width-list"); //$NON-NLS-1$ - div.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + div.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); div.setAttribute(HTML.ATTR_STYLE, "position: absolute; height: 100px; left: 0px; top: 22px; visibility: visible;"); //$NON-NLS-1$ final nsIDOMElement shadowDiv = visualDocument.createElement(HTML.TAG_DIV); @@ -152,7 +153,7 @@ final nsIDOMElement listPositionDiv = visualDocument.createElement(HTML.TAG_DIV); listPositionDiv.setAttribute(HTML.ATTR_CLASS, "rich-inplace-select-list-position"); //$NON-NLS-1$ - listPositionDiv.setAttribute(VPE_USER_TOGGLE_ID_ATTR, String.valueOf(0)); + listPositionDiv.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, String.valueOf(0)); final nsIDOMElement listDecarationDiv = visualDocument.createElement(HTML.TAG_DIV); listDecarationDiv.setAttribute(HTML.ATTR_CLASS, "rich-inplace-select-list-decoration"); //$NON-NLS-1$ @@ -219,44 +220,21 @@ return div; } - /** - * Gets the css extension. - * - * @return the css extension - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getCssExtension() - */ @Override protected String getCssExtension() { return INPLACE_SELECT_EXT; } - /** - * Gets the css style. - * - * @return the css style - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getCssStyle() - */ @Override protected String getCssStyle() { return INPLACE_SELECT_CSS; } - /** - * Gets the css styles suffix. - * - * @return the css styles suffix - */ @Override protected String getCssStylesSuffix() { return "-select"; //$NON-NLS-1$ } - /** - * Gets the root span classes. - * - * @return the root span classes - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getRootSpanClasses() - */ @Override protected String[] getRootSpanClasses(Attributes attrs) { String[] result = new String[3]; @@ -315,26 +293,17 @@ this.controlsVerticalPositions.put(HTML.VALUE_ALIGN_CENTER, "100px"); //$NON-NLS-1$ } - /** - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getCssStylesControlSuffix() - */ @Override protected String getCssStylesControlSuffix() { return this.getCssStylesSuffix(); } - /** - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getControlPositionsSubStyles() - */ @Override protected String getControlPositionsSubStyles(Attributes attrs) { return "top:0px ; left: " + controlsVerticalPositions.get(attrs.getControlsVerticalPosition()) //$NON-NLS-1$ + ";left: " + controlsHorizontalPositions.get(attrs.getControlsHorizontalPosition()) + Constants.SEMICOLON; //$NON-NLS-1$ } - /** - * @see org.jboss.tools.jsf.vpe.richfaces.template.RichFacesAbstractInplaceTemplate#getMainControlsDivCssClass() - */ @Override protected String getMainControlsDivCssClass() { return "rich-inplace" + getCssStylesControlSuffix() + "-control-set"; //$NON-NLS-1$ //$NON-NLS-2$ Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesMessagesTemplate.java (working copy) @@ -13,6 +13,8 @@ import java.util.HashMap; import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil; +import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces; +import org.jboss.tools.vpe.editor.VpeVisualDomBuilder; import org.jboss.tools.vpe.editor.context.VpePageContext; import org.jboss.tools.vpe.editor.template.VpeChildrenInfo; import org.jboss.tools.vpe.editor.template.VpeCreationData; @@ -26,14 +28,11 @@ public class RichFacesMessagesTemplate extends RichFacesMessageTemplate { - private static final String LAYOUT = "layout"; //$NON-NLS-1$ - private static final String TABLE = "table"; //$NON-NLS-1$ - private static final String CSS_RICH_MESSAGES - = "rich-messages"; //$NON-NLS-1$ - private static final String CSS_RICH_MESSAGES_MARKER - = "rich-messages-marker"; //$NON-NLS-1$ - private static final String CSS_RICH_MESSAGES_LABEL - = "rich-messages-label"; //$NON-NLS-1$ + private static final String LAYOUT = "layout"; //$NON-NLS-1$ + private static final String TABLE = "table"; //$NON-NLS-1$ + private static final String CSS_RICH_MESSAGES = "rich-messages"; //$NON-NLS-1$ + private static final String CSS_RICH_MESSAGES_MARKER = "rich-messages-marker"; //$NON-NLS-1$ + private static final String CSS_RICH_MESSAGES_LABEL = "rich-messages-label"; //$NON-NLS-1$ @Override public VpeCreationData create(VpePageContext pageContext, Node sourceNode, @@ -127,6 +126,8 @@ if (facet != null) { final VpeChildrenInfo childrenInfo = new VpeChildrenInfo(marker); + marker.setAttribute(VpeVisualDomBuilder.VPE_FACET, facet + .getAttribute(RichFaces.ATTR_NAME)); creationData.addChildrenInfo(childrenInfo); childrenInfo.addSourceChild(facet); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSimpleTogglePanelTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSimpleTogglePanelTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSimpleTogglePanelTemplate.java (working copy) @@ -24,6 +24,8 @@ import org.jboss.tools.vpe.editor.template.VpeToggableTemplate; import org.jboss.tools.vpe.editor.util.Constants; import org.jboss.tools.vpe.editor.util.HTML; +import org.jboss.tools.vpe.editor.util.SourceDomUtil; +import org.jboss.tools.vpe.editor.util.VisualDomUtil; import org.mozilla.interfaces.nsIDOMDocument; import org.mozilla.interfaces.nsIDOMElement; import org.w3c.dom.Element; @@ -87,19 +89,36 @@ headerDiv.setAttribute(HTML.ATTR_STYLE, "position : relative; " //$NON-NLS-1$ + ComponentUtil.getHeaderBackgoundImgStyle()); - // http://jira.jboss.com/jira/browse/JBIDE-791 - Element firstElementOfHeaderFacet = ComponentUtil.getFacet( - sourceElement, RichFaces.NAME_FACET_HEADER); - if (firstElementOfHeaderFacet != null) { - VpeChildrenInfo headerInfo = new VpeChildrenInfo(headerDiv); - headerInfo.addSourceChild(firstElementOfHeaderFacet); + /* + * http://jira.jboss.com/jira/browse/JBIDE-791 + * https://jira.jboss.org/jira/browse/JBIDE-3373 + * + * Encode the Header Facet + * Find elements from the f:facet + */ + Map> headerFacetChildren = null; + Element headerFacet = SourceDomUtil.getFacetByName(sourceElement, RichFaces.NAME_FACET_HEADER); + if (headerFacet != null) { + headerFacetChildren = VisualDomUtil.findFacetElements(headerFacet, pageContext); + /* + * By adding attribute VPE-FACET to this visual node + * we force JsfFacet to be rendered inside it + * without creating an additional and superfluous visual tag. + */ + headerDiv.setAttribute(VpeVisualDomBuilder.VPE_FACET, RichFaces.NAME_FACET_HEADER); + /* + * Add header facet to the ChildrenInfo + */ + VpeChildrenInfo headerInfo = new VpeChildrenInfo(headerDiv); + headerInfo.addSourceChild(headerFacet); creationData.addChildrenInfo(headerInfo); } else { - String label = ComponentUtil - .getAttribute(sourceElement, ATTR_LABEL); - headerDiv.appendChild(visualDocument.createTextNode(label)); + /* + * Otherwise show label attribute value as panel header + */ + headerDiv.appendChild(visualDocument.createTextNode(ComponentUtil + .getAttribute(sourceElement, ATTR_LABEL))); } - // /// nsIDOMElement switchDiv = visualDocument.createElement(HTML.TAG_DIV); headerDiv.appendChild(switchDiv); @@ -147,9 +166,24 @@ + Constants.WHITE_SPACE + CSS_RICH_STGLPANEL_BODY + Constants.WHITE_SPACE + ComponentUtil.getAttribute(sourceElement, ATTR_BODY_CLASS)); - + + /* + * If there are some odd HTML elements from facet + * add them to the panel body first. + */ + boolean headerHtmlElementsPresents = ((headerFacetChildren != null) && (headerFacetChildren + .get(VisualDomUtil.FACET_HTML_TAGS).size() > 0)); + VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td); + if (headerHtmlElementsPresents) { + for (Node node : headerFacetChildren.get(VisualDomUtil.FACET_HTML_TAGS)) { + bodyInfo.addSourceChild(node); + } + } + + /* + * Add the rest panel's content + */ List children = ComponentUtil.getChildren(sourceElement, true); - VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td); for (Node child : children) { bodyInfo.addSourceChild(child); } Index: src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java =================================================================== --- src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java (revision 21395) +++ src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java (working copy) @@ -47,9 +47,10 @@ public VpeCreationData encode(final VpePageContext pageContext, VpeCreationData creationData, final Element sourceElement, final nsIDOMDocument visualDocument, nsIDOMElement parentVisualNode) { - if(creationData!=null) { - // Encode header + /* + * Encode header + */ encodeHeader(pageContext, creationData, sourceElement, visualDocument, parentVisualNode); } @@ -132,7 +133,8 @@ if(parentVisualNode!=null) { // Encode footer - encodeFooter(pageContext, creationData, sourceElement, visualDocument, parentVisualNode); + encodeFooter(pageContext, creationData, sourceElement, + visualDocument, parentVisualNode); } return creationData; } @@ -190,36 +192,58 @@ final Element sourceElement = (Element)sourceNode; final nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY); VpeCreationData creationData = new VpeCreationData(tbody); - creationData = encode(pageContext, creationData, sourceElement, visualDocument, tbody); + creationData = encode(pageContext, creationData, sourceElement, + visualDocument, tbody); return creationData; } protected void encodeHeader(final VpePageContext pageContext, final VpeCreationData creationData, final Element sourceElement, final nsIDOMDocument visualDocument, final nsIDOMElement parentVisualNode) { - encodeHeaderOrFooter(pageContext, creationData, sourceElement, visualDocument, parentVisualNode, RichFaces.NAME_FACET_HEADER, "dr-subtable-header rich-subtable-header", "dr-subtable-headercell rich-subtable-headercell"); //$NON-NLS-1$ //$NON-NLS-2$ + encodeHeaderOrFooter( + pageContext, + creationData, + sourceElement, + visualDocument, + parentVisualNode, + RichFaces.NAME_FACET_HEADER, + "dr-subtable-header rich-subtable-header", //$NON-NLS-1$ + "dr-subtable-headercell rich-subtable-headercell"); //$NON-NLS-1$ } protected void encodeFooter(final VpePageContext pageContext, final VpeCreationData creationData, final Element sourceElement, final nsIDOMDocument visualDocument, final nsIDOMElement parentVisualNode) { - encodeHeaderOrFooter(pageContext, creationData, sourceElement, visualDocument, parentVisualNode, RichFaces.NAME_FACET_FOOTER, "dr-subtable-footer rich-subtable-footer", "dr-subtable-footercell rich-subtable-footercell"); //$NON-NLS-1$ //$NON-NLS-2$ + encodeHeaderOrFooter( + pageContext, + creationData, + sourceElement, + visualDocument, + parentVisualNode, + RichFaces.NAME_FACET_FOOTER, + "dr-subtable-footer rich-subtable-footer", //$NON-NLS-1$ + "dr-subtable-footercell rich-subtable-footercell"); //$NON-NLS-1$ } - protected void encodeHeaderOrFooter(final VpePageContext pageContext, final VpeCreationData creationData, - final Element sourceElement, final nsIDOMDocument visualDocument, final nsIDOMElement parentVisualNode, - final String facetName, final String trClass, final String tdClass) { - final ArrayList columns = RichFacesDataTableTemplate.getColumns(sourceElement); - //final ArrayList columnsHeaders = ComponentUtil.getColumnsWithFacet(columns, facetName); - final boolean hasColumnWithFacet = RichFacesDataTableTemplate.hasColumnWithFacet(columns, facetName); - if(hasColumnWithFacet) { + protected void encodeHeaderOrFooter(final VpePageContext pageContext, + final VpeCreationData creationData, final Element sourceElement, + final nsIDOMDocument visualDocument, + final nsIDOMElement parentVisualNode, final String facetName, + final String trClass, final String tdClass) { + + final ArrayList columns = RichFacesDataTableTemplate + .getColumns(sourceElement); + // final ArrayList columnsHeaders = + // ComponentUtil.getColumnsWithFacet(columns, facetName); + final boolean hasColumnWithFacet = RichFacesDataTableTemplate + .hasColumnWithFacet(columns, facetName); + if (hasColumnWithFacet) { final nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR); parentVisualNode.appendChild(tr); final String styleClass = trClass; - if(styleClass!=null) { + if (styleClass != null) { tr.setAttribute(HTML.ATTR_CLASS, styleClass); } - RichFacesDataTableTemplate.encodeHeaderOrFooterFacets(pageContext, creationData, tr, visualDocument, columns, - tdClass, - null, facetName, HTML.TAG_TD); + RichFacesDataTableTemplate.encodeHeaderOrFooterFacets(pageContext, + creationData, tr, visualDocument, columns, tdClass, null, + facetName, HTML.TAG_TD); } - } private boolean isHeader(final Element sourceElement) {