[jbosstools-commits] JBoss Tools SVN: r6936 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Mar 14 11:44:54 EDT 2008


Author: dsakovich
Date: 2008-03-14 11:44:54 -0400 (Fri, 14 Mar 2008)
New Revision: 6936

Modified:
   trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
   trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAttributeCreator.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1730

Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml	2008-03-14 15:44:54 UTC (rev 6936)
@@ -878,14 +878,14 @@
 
 	<vpe:tag name="h:panelGrid" case-sensitive="yes">
 		<vpe:template children="yes" modify="yes">
-			<vpe:panelgrid border="{iif(@border='','0','@border')}"
-				style="{@style}" class="{@styleClass}" width="{@width}"
-				frame="{@frame}" rules="{@rules}" columnClasses="{@columnClasses}"
-				footerClass="{@footerClass}" headerClass="{@headerClass}"
-				rowClasses="{@rowClasses}" cellspacing="{@cellspacing}"
+			<vpe:panelgrid border="{iif(@border='','0', at border)}"
+				style="{@style}" class="{@styleClass}" width="{@width}" 
+				dir="{@dir}" frame="{@frame}" rules="{jsfvalue(@rules)}" columnClasses="{@columnClasses}"
+				footerClass="{@footerClass}" headerClass="{@headerClass}"  
+				captionClass="{@captionClass}" captionStyle="{@captionStyle}" rowClasses="{@rowClasses}" cellspacing="{@cellspacing}"
 				cellpadding="{@cellpadding}" bgcolor="{@bgcolor}"
 				title="{tagstring()}" table-size="{@columns}" />
-			<vpe:resize>
+		<vpe:resize>
 				<vpe:width width-attr="width" />
 			</vpe:resize>
 			<vpe:dnd>

Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml	2008-03-14 15:44:54 UTC (rev 6936)
@@ -116,7 +116,7 @@
 		<vpe:if test="not(attrpresent('image'))">
 			<vpe:if test="@type=''">
 				<vpe:template children="no" modify="no">
-					<input type="submit" value="{jsfvalue(@value)}" class="{@styleClass}" style="{@style}" title="{tagstring()}"/>
+					<input type="button" value="{jsfvalue(@value)}" class="{@styleClass}" style="{@style}" title="{tagstring()}"/>
 					<vpe:resize>
 						<vpe:width width-attr="style.width" />
 						<vpe:height height-attr="style.height" />

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAttributeCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAttributeCreator.java	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAttributeCreator.java	2008-03-14 15:44:54 UTC (rev 6936)
@@ -53,17 +53,11 @@
 				visualNodeMap.put(this, visualElement);
 			}
 			VpeValue vpeValue = expression.exec(pageContext, sourceNode);
-			//FIX FOR JBIDE-1484 added by Max Areshkau
-			//commented to fix JBIDE-1484
-//			if (vpeValue != null && vpeValue.stringValue().length() > 0) {
-//				nsIDOMAttr newVisualAttribute = visualDocument.createAttribute(name);
-//				newVisualAttribute.setValue(vpeValue.stringValue());
-//				return new VpeCreatorInfo(newVisualAttribute);
-//			}			
-				nsIDOMAttr newVisualDOMAttribute =  visualDocument.createAttribute(name);
-				newVisualDOMAttribute.setValue(vpeValue==null?null:vpeValue.stringValue());
-				return new VpeCreatorInfo(newVisualDOMAttribute);
-			//END of FIX JBIDE-1484 code
+			if (vpeValue != null && vpeValue.stringValue().length() > 0) {
+				nsIDOMAttr newVisualAttribute = visualDocument.createAttribute(name);
+				newVisualAttribute.setValue(vpeValue.stringValue());
+				return new VpeCreatorInfo(newVisualAttribute);
+			}			
 		}
 		return null;
 	}

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java	2008-03-14 15:44:54 UTC (rev 6936)
@@ -24,11 +24,12 @@
 import org.w3c.dom.NodeList;
 
 public class VpeCreatorUtil {
-	public static final int FASET_TYPE_NONE = 0;
-	public static final int FASET_TYPE_HEADER = 1;
-	public static final int FASET_TYPE_FOOTER = 2;
-	public static final int FASET_TYPE_BODY = 3;
-	public static final int FASET_TYPE_NAVIGATION = 4;
+	public static final int FACET_TYPE_NONE = 0;
+	public static final int FACET_TYPE_HEADER = 1;
+	public static final int FACET_TYPE_FOOTER = 2;
+	public static final int FACET_TYPE_BODY = 3;
+	public static final int FACET_TYPE_NAVIGATION = 4;
+	public static final int FACET_TYPE_CAPTION = 5;
 
 	public static boolean isFacet(Node node) {
 		if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
@@ -48,16 +49,18 @@
 		String value = getFacetName(node);
 		if (value != null) {
 			if ("header".equals(value)) {
-				return FASET_TYPE_HEADER;
+				return FACET_TYPE_HEADER;
 			} else if ("footer".equals(value)) {
-				return FASET_TYPE_FOOTER;
+				return FACET_TYPE_FOOTER;
 			} else if ("body".equals(value)) {
-				return FASET_TYPE_BODY;
+				return FACET_TYPE_BODY;
 			} else if ("navigation".equals(value)) {
-				return FASET_TYPE_NAVIGATION;
+				return FACET_TYPE_NAVIGATION;
+			} else if ("caption".equals(value)) {
+				return FACET_TYPE_CAPTION;
 			}
 		}
-		return FASET_TYPE_NONE;
+		return FACET_TYPE_NONE;
 	}
 
 	public static boolean isInclude(Node node) {
@@ -153,7 +156,7 @@
 					for (int i = 0; i < cnt; i++) {
 						Node child = list.item(i);
 						int type = getFacetType(child, pageContext);
-						if (type != FASET_TYPE_NONE) {
+						if (type != FACET_TYPE_NONE) {
 							return type;
 						}
 					}
@@ -162,7 +165,7 @@
 				}
 			}
 		}
-		return FASET_TYPE_NONE;
+		return FACET_TYPE_NONE;
 	}
 	
 	public static void setAttributes(Element visualElement, Element sourceElement, VpeAttributeInfo[] attrsInfo) {

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java	2008-03-14 15:44:54 UTC (rev 6936)
@@ -7,7 +7,7 @@
  *
  * Contributors:
  *     Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/ 
+ ******************************************************************************/
 package org.jboss.tools.vpe.editor.template;
 
 import java.util.ArrayList;
@@ -28,6 +28,7 @@
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -35,87 +36,157 @@
 
 	private boolean caseSensitive;
 	private VpeExpression tableSizeExpr;
+	private VpeExpression captionClassExpr;
+	private VpeExpression captionStyleExpr;
 	private VpeExpression headerClassExpr;
 	private VpeExpression footerClassExpr;
 	private VpeExpression rowClassesExpr;
 	private VpeExpression columnClassesExpr;
+	private VpeExpression rulesExpr;
+
 	private List propertyCreators;
-//	private Set dependencySet;
-	
-	VpePanelGridCreator(Element gridElement, VpeDependencyMap dependencyMap, boolean caseSensitive) {
+
+	// private Set dependencySet;
+
+	VpePanelGridCreator(Element gridElement, VpeDependencyMap dependencyMap,
+			boolean caseSensitive) {
 		this.caseSensitive = caseSensitive;
 		build(gridElement, dependencyMap);
 	}
 
 	private void build(Element gridElement, VpeDependencyMap dependencyMap) {
-		Attr tableSizeAttr = gridElement.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_TABLE_SIZE);
+
+		NamedNodeMap map = gridElement.getAttributes();
+
+		Attr tableSizeAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_TABLE_SIZE);
 		if (tableSizeAttr != null) {
 			try {
-				VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(tableSizeAttr.getValue(), caseSensitive);
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(tableSizeAttr.getValue(),
+								caseSensitive);
 				tableSizeExpr = info.getExpression();
 				dependencyMap.setCreator(this, info.getDependencySet());
-			} catch(VpeExpressionBuilderException e) {
+			} catch (VpeExpressionBuilderException e) {
 				VpePlugin.reportProblem(e);
 			}
 		}
 
-		Attr headerClassAttr = gridElement.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_HEADER_CLASS);
+		Attr headerClassAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_HEADER_CLASS);
 		if (headerClassAttr != null) {
 			try {
-				VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(headerClassAttr.getValue(), caseSensitive);
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(headerClassAttr.getValue(),
+								caseSensitive);
 				headerClassExpr = info.getExpression();
 				dependencyMap.setCreator(this, info.getDependencySet());
-			} catch(VpeExpressionBuilderException e) {
+			} catch (VpeExpressionBuilderException e) {
 				VpePlugin.reportProblem(e);
 			}
 		}
 
-		Attr footerClassAttr = gridElement.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_FOOTER_CLASS);
+		Attr footerClassAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_FOOTER_CLASS);
 		if (footerClassAttr != null) {
 			try {
-				VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(footerClassAttr.getValue(), caseSensitive);
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(footerClassAttr.getValue(),
+								caseSensitive);
 				footerClassExpr = info.getExpression();
 				dependencyMap.setCreator(this, info.getDependencySet());
-			} catch(VpeExpressionBuilderException e) {
+			} catch (VpeExpressionBuilderException e) {
 				VpePlugin.reportProblem(e);
 			}
 		}
 
-		Attr rowClassesAttr = gridElement.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_ROW_CLASSES);
+		Attr rowClassesAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_ROW_CLASSES);
 		if (rowClassesAttr != null) {
 			try {
-				VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(rowClassesAttr.getValue(), caseSensitive);
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(rowClassesAttr.getValue(),
+								caseSensitive);
 				rowClassesExpr = info.getExpression();
 				dependencyMap.setCreator(this, info.getDependencySet());
-			} catch(VpeExpressionBuilderException e) {
+			} catch (VpeExpressionBuilderException e) {
 				VpePlugin.reportProblem(e);
 			}
 		}
 
-		Attr columnClassesAttr = gridElement.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_COLUMN_CLASSES);
+		Attr columnClassesAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_COLUMN_CLASSES);
 		if (columnClassesAttr != null) {
 			try {
-				VpeExpressionInfo info = VpeExpressionBuilder.buildCompletedExpression(columnClassesAttr.getValue(), caseSensitive);
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(columnClassesAttr.getValue(),
+								caseSensitive);
 				columnClassesExpr = info.getExpression();
 				dependencyMap.setCreator(this, info.getDependencySet());
-			} catch(VpeExpressionBuilderException e) {
+			} catch (VpeExpressionBuilderException e) {
 				VpePlugin.reportProblem(e);
 			}
 		}
 
+		Attr captionClassesAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_CAPTION_CLASS);
+		if (captionClassesAttr != null) {
+			try {
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(
+								captionClassesAttr.getValue(), caseSensitive);
+				captionClassExpr = info.getExpression();
+				dependencyMap.setCreator(this, info.getDependencySet());
+			} catch (VpeExpressionBuilderException e) {
+				VpePlugin.reportProblem(e);
+			}
+		}
+
+		Attr captionStyleAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_CAPTION_STYLE);
+		if (captionStyleAttr != null) {
+			try {
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(captionStyleAttr.getValue(),
+								caseSensitive);
+				captionStyleExpr = info.getExpression();
+				dependencyMap.setCreator(this, info.getDependencySet());
+			} catch (VpeExpressionBuilderException e) {
+				VpePlugin.reportProblem(e);
+			}
+		}
+
+		Attr rulesAttr = gridElement
+				.getAttributeNode(VpeTemplateManager.ATTR_PANELGRID_RULES);
+		if (rulesAttr != null) {
+			try {
+				VpeExpressionInfo info = VpeExpressionBuilder
+						.buildCompletedExpression(rulesAttr.getValue(),
+								caseSensitive);
+				rulesExpr = info.getExpression();
+				dependencyMap.setCreator(this, info.getDependencySet());
+			} catch (VpeExpressionBuilderException e) {
+				VpePlugin.reportProblem(e);
+			}
+		}
+
 		if (VpeTemplateManager.ATTR_GRID_PROPERTIES != null) {
 			for (int i = 0; i < VpeTemplateManager.ATTR_GRID_PROPERTIES.length; i++) {
 				String attrName = VpeTemplateManager.ATTR_GRID_PROPERTIES[i];
 				Attr attr = gridElement.getAttributeNode(attrName);
 				if (attr != null) {
-					if (propertyCreators == null) propertyCreators  = new ArrayList();
-					propertyCreators.add(new VpeAttributeCreator(attrName, attr.getValue(), dependencyMap, caseSensitive));
+					if (propertyCreators == null)
+						propertyCreators = new ArrayList();
+					propertyCreators.add(new VpeAttributeCreator(attrName, attr
+							.getValue(), dependencyMap, caseSensitive));
 				}
 			}
 		}
 	}
 
-	public VpeCreatorInfo _create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
+	public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
+			nsIDOMDocument visualDocument, nsIDOMElement visualElement,
+			Map visualNodeMap) {
 		int tableSize = 1;
 		if (tableSizeExpr != null) {
 			VpeValue vpeValue = tableSizeExpr.exec(pageContext, sourceNode);
@@ -127,176 +198,59 @@
 						tableSize = val;
 					}
 				} catch (Exception e) {
-					VpePlugin.getPluginLog().logError(e);
 				}
 			}
 		}
-		
-		nsIDOMElement visualTable = visualDocument.createElement(HTML.TAG_TABLE);
+
+		nsIDOMElement visualTable = visualDocument
+				.createElement(HTML.TAG_TABLE);
 		VpeCreatorInfo creatorInfo = new VpeCreatorInfo(visualTable);
 
 		if (propertyCreators != null) {
 			for (int i = 0; i < propertyCreators.size(); i++) {
-				VpeCreator creator = (VpeCreator)propertyCreators.get(i);
+				VpeCreator creator = (VpeCreator) propertyCreators.get(i);
 				if (creator != null) {
-					VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
+					VpeCreatorInfo info = creator.create(pageContext,
+							(Element) sourceNode, visualDocument, visualTable,
+							visualNodeMap);
 					if (info != null && info.getVisualNode() != null) {
-						nsIDOMAttr attr = (nsIDOMAttr)info.getVisualNode();
+						nsIDOMAttr attr = (nsIDOMAttr) info.getVisualNode();
 						visualTable.setAttributeNode(attr);
 					}
 				}
 			}
 		}
-		
-		NodeList children = sourceNode.getChildNodes();
-		int count = children != null ? children.getLength() : 0;
-		if (count > 0) {
-			Node header = null;
-			Node footer = null;
-			Node[] sourceChildren = new Node[count];
-			int childrenCount = 0;
-			for (int i = 0; i < count; i++) {
-				Node node = children.item(i);
-				int type = node.getNodeType();
-				if (type == Node.ELEMENT_NODE || type == Node.TEXT_NODE && node.getNodeValue().trim().length() > 0) {
-					if (type == Node.ELEMENT_NODE && (node.getPrefix() + ":facet").equals(node.getNodeName())) {
-						Node nameAttr = node.getAttributes().getNamedItem("name");
-						if (nameAttr != null) {
-							String value = nameAttr.getNodeValue();
-							if ("header".equals(value)) {
-								header = node;
-							} else if ("footer".equals(value)) {
-								footer = node;
-							}
-						}
-					} else {
-						sourceChildren[childrenCount] = node;
-						childrenCount++;
-					}
-				}
-			}
-			if (childrenCount > 0) {
-				if (tableSize == 0) {
-					tableSize = childrenCount;
-				}
-				int rowCount = (childrenCount + tableSize - 1) / tableSize;
 
-				nsIDOMElement visualHead = null;
-				nsIDOMElement visualFoot = null;
-				nsIDOMElement visualBody = visualDocument.createElement(HTML.TAG_TBODY);
-				visualTable.appendChild(visualBody);
-				if (header != null || footer != null) {
-					if (header != null) {
-						visualHead = visualDocument.createElement(HTML.TAG_THEAD);
-						visualTable.appendChild(visualHead);
-					}
-					if (footer != null) {
-						visualFoot = visualDocument.createElement(HTML.TAG_TFOOT);
-						visualTable.appendChild(visualFoot);
-					}
-				}
-				List rowClasses = getClasses(rowClassesExpr, sourceNode, pageContext);
-				List columnClasses = getClasses(columnClassesExpr, sourceNode, pageContext);
-				int rci = 0, cci = 0;
-				for (int i = 0; i < rowCount; i++) {
-					nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TD);
-					if (rowClasses.size() > 0) {
-						visualRow.setAttribute("class", rowClasses.get(rci).toString());
-						rci++;
-						if (rci >= rowClasses.size()) rci = 0;
-					}
-					for (int j = 0; j < tableSize; j++) {
-						nsIDOMElement visualCell = visualDocument.createElement("td");
-						if (columnClasses.size() > 0) {
-							visualCell.setAttribute("class", columnClasses.get(rci).toString());
-							cci++;
-							if (cci >= rowClasses.size()) 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);
-							}
-						}
-					}
-					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);
-
-				for (int i = 0; i < propertyCreators.size(); i++) {
-					VpeCreator creator = (VpeCreator)propertyCreators.get(i);
-					if (creator != null) {
-						VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
-						if (info != null && info.getVisualNode() != null) {
-							nsIDOMAttr attr = (nsIDOMAttr)info.getVisualNode();
-							visualTable.setAttributeNode(attr);
-						}
-					}
-				}
-			}
+		if (rulesExpr != null) {
+			String rules = rulesExpr.exec(pageContext, sourceNode)
+					.stringValue();
+			if (rules.length() > 0)
+				visualTable.setAttribute(
+						VpeTemplateManager.ATTR_PANELGRID_RULES, rules);
 		}
-
-		return creatorInfo;
-	}
-
-	public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
-		int tableSize = 1;
-		if (tableSizeExpr != null) {
-			VpeValue vpeValue = tableSizeExpr.exec(pageContext, sourceNode);
-			if (vpeValue != null) {
-				String strValue = vpeValue.stringValue();
-				try {
-					int val = Integer.valueOf(strValue).intValue();
-					if (val > 0) {
-						tableSize = val;
-					}
-				} catch (Exception e) {}
-			}
-		}
-		
-		nsIDOMElement visualTable = visualDocument.createElement(HTML.TAG_TABLE);
-		VpeCreatorInfo creatorInfo = new VpeCreatorInfo(visualTable);
-
-		if (propertyCreators != null) {
-			for (int i = 0; i < propertyCreators.size(); i++) {
-				VpeCreator creator = (VpeCreator)propertyCreators.get(i);
-				if (creator != null) {
-					VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
-					if (info != null && info.getVisualNode() != null) {
-						nsIDOMAttr attr = (nsIDOMAttr)info.getVisualNode();
-						visualTable.setAttributeNode(attr);
-					}
-				}
-			}
-		}
-		
 		NodeList children = sourceNode.getChildNodes();
 		int count = children != null ? children.getLength() : 0;
 		if (count > 0) {
 			Node header = null;
 			Node footer = null;
+			Node caption = null;
 			Node[] sourceChildren = new Node[count];
 			int childrenCount = 0;
 			for (int i = 0; i < count; i++) {
 				Node node = children.item(i);
 				int type = node.getNodeType();
-				if (type == Node.ELEMENT_NODE || type == Node.TEXT_NODE && node.getNodeValue().trim().length() > 0) {
+				if (type == Node.ELEMENT_NODE || type == Node.TEXT_NODE
+						&& node.getNodeValue().trim().length() > 0) {
 					switch (VpeCreatorUtil.getFacetType(node, pageContext)) {
-					case VpeCreatorUtil.FASET_TYPE_HEADER:
+					case VpeCreatorUtil.FACET_TYPE_HEADER:
 						header = node;
 						break;
-					case VpeCreatorUtil.FASET_TYPE_FOOTER:
+					case VpeCreatorUtil.FACET_TYPE_FOOTER:
 						footer = node;
 						break;
+					case VpeCreatorUtil.FACET_TYPE_CAPTION:
+						caption = node;
+						break;
 					default:
 						sourceChildren[childrenCount] = node;
 						childrenCount++;
@@ -312,41 +266,75 @@
 
 				nsIDOMElement visualHead = null;
 				nsIDOMElement visualFoot = null;
-				nsIDOMElement visualBody = visualDocument.createElement(HTML.TAG_TBODY);
+				nsIDOMElement visualCaption = null;
+				nsIDOMElement visualBody = visualDocument
+						.createElement(HTML.TAG_TBODY);
 				visualTable.appendChild(visualBody);
-				if (header != null || footer != null) {
-					if (header != null) {
-						visualHead = visualDocument.createElement(HTML.TAG_THEAD);
-						visualTable.appendChild(visualHead);
+				if (caption != null) {
+					visualCaption = visualDocument
+							.createElement(HTML.TAG_CAPTION);
+					visualTable.appendChild(visualCaption);
+					VpeChildrenInfo childrenInfo = new VpeChildrenInfo(
+							visualCaption);
+					childrenInfo.addSourceChild(caption);
+					creatorInfo.addChildrenInfo(childrenInfo);
+					if (captionClassExpr != null
+							&& caption.getParentNode() != null) {
+						String captionClass = captionClassExpr.exec(
+								pageContext, caption.getParentNode())
+								.stringValue();
+						visualCaption.setAttribute("class", captionClass);
 					}
-					if (footer != null) {
-						visualFoot = visualDocument.createElement(HTML.TAG_TFOOT);
-						visualTable.appendChild(visualFoot);
+
+					if (captionStyleExpr != null
+							&& caption.getParentNode() != null) {
+						String captionStyle = captionStyleExpr.exec(
+								pageContext, caption.getParentNode())
+								.stringValue();
+						visualCaption.setAttribute("style", captionStyle);
 					}
 				}
-				List rowClasses = getClasses(rowClassesExpr, sourceNode, pageContext);
-				List columnClasses = getClasses(columnClassesExpr, sourceNode, pageContext);
+				if (header != null) {
+					visualHead = visualDocument.createElement(HTML.TAG_THEAD);
+					visualTable.appendChild(visualHead);
+				}
+				if (footer != null) {
+					visualFoot = visualDocument.createElement(HTML.TAG_TFOOT);
+					visualTable.appendChild(visualFoot);
+				}
+
+				List rowClasses = getClasses(rowClassesExpr, sourceNode,
+						pageContext);
+				List columnClasses = getClasses(columnClassesExpr, sourceNode,
+						pageContext);
 				int rci = 0, cci = 0;
 				for (int i = 0; i < rowCount; i++) {
-					nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TR);
+					nsIDOMElement visualRow = visualDocument
+							.createElement(HTML.TAG_TR);
 					if (rowClasses.size() > 0) {
-						visualRow.setAttribute("class", rowClasses.get(rci).toString());
+						visualRow.setAttribute("class", rowClasses.get(rci)
+								.toString());
 						rci++;
-						if (rci >= rowClasses.size()) rci = 0;
+						if (rci >= rowClasses.size())
+							rci = 0;
 					}
 					for (int j = 0; j < tableSize; j++) {
-						nsIDOMElement visualCell = visualDocument.createElement(HTML.TAG_TD);
+						nsIDOMElement visualCell = visualDocument
+								.createElement(HTML.TAG_TD);
 						if (columnClasses.size() > 0) {
-							visualCell.setAttribute("class", columnClasses.get(cci).toString());
+							visualCell.setAttribute("class", columnClasses.get(
+									cci).toString());
 							cci++;
-							if (cci >= columnClasses.size()) cci = 0;
+							if (cci >= columnClasses.size())
+								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);
+								VpeChildrenInfo childrenInfo = new VpeChildrenInfo(
+										visualCell);
 								childrenInfo.addSourceChild(child);
 								creatorInfo.addChildrenInfo(childrenInfo);
 							}
@@ -358,16 +346,22 @@
 						visualTable.appendChild(visualRow);
 					}
 				}
-				makeSpecial(header, visualHead, visualDocument, tableSize, creatorInfo, "th", headerClassExpr, pageContext);
-				makeSpecial(footer, visualFoot, visualDocument, tableSize, creatorInfo, "td", footerClassExpr, pageContext);
+				makeSpecial(header, visualHead, visualDocument, tableSize,
+						creatorInfo, "th", headerClassExpr, pageContext);
+				makeSpecial(footer, visualFoot, visualDocument, tableSize,
+						creatorInfo, "td", footerClassExpr, pageContext);
 
 				for (int i = 0; i < propertyCreators.size(); i++) {
-					VpeCreator creator = (VpeCreator)propertyCreators.get(i);
+					VpeCreator creator = (VpeCreator) propertyCreators.get(i);
 					if (creator != null) {
-						VpeCreatorInfo info = creator.create(pageContext, (Element) sourceNode, visualDocument, visualTable, visualNodeMap);
+						VpeCreatorInfo info = creator.create(pageContext,
+								(Element) sourceNode, visualDocument,
+								visualTable, visualNodeMap);
 						if (info != null && info.getVisualNode() != null) {
-							nsIDOMAttr attr = (nsIDOMAttr)info.getVisualNode();
-							visualTable.setAttributeNode(attr);
+							nsIDOMAttr attr = (nsIDOMAttr) info.getVisualNode();
+							if (attr.getValue().length() > 0) {
+								visualTable.setAttributeNode(attr);
+							}
 						}
 					}
 				}
@@ -377,10 +371,12 @@
 		return creatorInfo;
 	}
 
-	private List getClasses(VpeExpression expression, Node sourceNode, VpePageContext pageContext) {
+	private List getClasses(VpeExpression expression, Node sourceNode,
+			VpePageContext pageContext) {
 		List b = new ArrayList();
 		if (expression != null && sourceNode != null) {
-			String classes = expression.exec(pageContext, sourceNode).stringValue();
+			String classes = expression.exec(pageContext, sourceNode)
+					.stringValue();
 			String[] a = classes.split(",");
 			for (int i = 0; i < a.length; i++) {
 				if (a[i].trim().length() > 0) {
@@ -391,14 +387,18 @@
 		return b;
 	}
 
-	private void makeSpecial(Node header, nsIDOMElement visualHead, nsIDOMDocument visualDocument, int tableSize, VpeCreatorInfo creatorInfo, String cellTag, VpeExpression headerClassExpr, VpePageContext pageContext) {
+	private void makeSpecial(Node header, nsIDOMElement visualHead,
+			nsIDOMDocument visualDocument, int tableSize,
+			VpeCreatorInfo creatorInfo, String cellTag,
+			VpeExpression headerClassExpr, VpePageContext pageContext) {
 		if (header != null && visualHead != null) {
 			nsIDOMElement visualRow = visualDocument.createElement(HTML.TAG_TR);
 			visualHead.appendChild(visualRow);
 			nsIDOMElement visualCell = visualDocument.createElement(cellTag);
 			visualCell.setAttribute("colspan", "" + tableSize);
 			if (headerClassExpr != null && header.getParentNode() != null) {
-				String headerClass = headerClassExpr.exec(pageContext, header.getParentNode()).stringValue();
+				String headerClass = headerClassExpr.exec(pageContext,
+						header.getParentNode()).stringValue();
 				visualCell.setAttribute("class", headerClass);
 			}
 			visualRow.appendChild(visualCell);
@@ -422,7 +422,9 @@
 		return null;
 	}
 
-	public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement, Document visualDocument, Node visualNde, Object data, String name, String value) {
+	public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+			Element sourceElement, Document visualDocument, Node visualNde,
+			Object data, String name, String value) {
 		return true;
 	}
 }

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java	2008-03-14 15:20:35 UTC (rev 6935)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java	2008-03-14 15:44:54 UTC (rev 6936)
@@ -129,11 +129,14 @@
 	static final String ATTR_PANELGRID_FOOTER_CLASS = "footerClass";
 	static final String ATTR_PANELGRID_ROW_CLASSES = "rowClasses";
 	static final String ATTR_PANELGRID_COLUMN_CLASSES = "columnClasses";
-	static final String[] ATTR_PANELGRID_PROPERTIES = {"style","class","width","border","frame","rules","cellspacing","cellpadding","bgcolor","title"};
+	static final String ATTR_PANELGRID_CAPTION_CLASS = "captionClass";
+	static final String ATTR_PANELGRID_CAPTION_STYLE = "captionStyle";
+	static final String ATTR_PANELGRID_RULES = "rules";
+	static final String[] ATTR_PANELGRID_PROPERTIES = {"style","class","width","border","frame","cellspacing","cellpadding","bgcolor","title"};
 
 	static final String ATTR_GRID_LAYOUT = "layout";
 	static final String ATTR_GRID_TABLE_SIZE = "table-size";
-	static final String[] ATTR_GRID_PROPERTIES = {"style","class","width","border","frame","rules","cellspacing","cellpadding","bgcolor","title"};
+	static final String[] ATTR_GRID_PROPERTIES = {"style","class","width","border","frame","cellspacing","cellpadding","bgcolor","title","dir"};
 
 	static final String ATTR_ANY_DISPLAY = "display";
 	static final String ATTR_ANY_ICON = "icon";




More information about the jbosstools-commits mailing list