Author: dmaliarevich
Date: 2008-02-14 11:00:11 -0500 (Thu, 14 Feb 2008)
New Revision: 6316
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java
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/util/HTML.java
trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
Log:
http://jira.jboss.com/jira/browse/JBIDE-1744
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -60,6 +60,7 @@
info.addSourceChild(columnElements.getHeader());
}
creatorInfo.addChildrenInfo(info);
+ setCellClass(cell, getColumnAttrValue(sourceNode, "headerClass"));
visualColumnElements.setHeaderCell(cell);
cell = VpeDataTableElements.makeCell(visualDataTableElements.getColumnsFooterRow(),
index, HTML.TAG_TD, visualDocument);
@@ -68,6 +69,7 @@
info.addSourceChild(columnElements.getFooter());
}
creatorInfo.addChildrenInfo(info);
+ setCellClass(cell, getColumnAttrValue(sourceNode, "footerClass"));
visualColumnElements.setFooterCell(cell);
cell = VpeDataTableElements.makeCell(visualDataTableElements.getBodyRow(), index,
HTML.TAG_TD, visualDocument);
@@ -144,4 +146,22 @@
int ind = name2.indexOf(":");
return ind < name2.length() && name1.equals(name2.substring(ind >= 0 ?
ind + 1 : 0));
}
+
+ private void setCellClass(nsIDOMNode cell, String className) {
+ if (cell != null) {
+ if (className != null && className.trim().length() > 0) {
+ ((nsIDOMElement)cell).setAttribute("class", className);
+ }
+ }
+ }
+
+ private String getColumnAttrValue(Node columnNode, String attrName) {
+ if (columnNode != null) {
+ Node attr = columnNode.getAttributes().getNamedItem(attrName);
+ if (attr != null) {
+ return attr.getNodeValue();
+ }
+ }
+ return null;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java 2008-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableCreator.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -104,6 +104,7 @@
}
}
}
+
}
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
@@ -115,6 +116,20 @@
VpeCreatorInfo creatorInfo = new VpeCreatorInfo(visualTable);
nsIDOMElement section = null, row = null, cell = null;
+
+ nsIDOMElement caption;
+ if (true || sourceElements.hasTableCaption()) {
+ caption = visualDocument.createElement(HTML.TAG_CAPTION);
+ visualElements.setTableCaptionTag(caption);
+ if (sourceElements.getTableCaption() != null) {
+ VpeChildrenInfo info = new VpeChildrenInfo(caption);
+ info.addSourceChild(sourceElements.getTableCaption());
+ creatorInfo.addChildrenInfo(info);
+ }
+ }
+ visualTable.appendChild(caption);
+ visualElements.setCaption(caption);
+
if (true || sourceElements.hasHeaderSection()) {
section = visualDocument.createElement(HTML.TAG_THEAD);
if (true || sourceElements.hasTableHeader()) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java 2008-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableElements.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -30,6 +30,7 @@
// }
public static class SourceDataTableElements {
+ private Node tableCaption;
private Node tableHeader;
private List<SourceColumnElements> columns;
private Node tableFooter;
@@ -52,6 +53,8 @@
tableHeader = node;
} else if (!isColumn && isFacet && attrName != null &&
"footer".equals(attrName.getNodeValue())) {
tableFooter = node;
+ } else if (!isColumn && isFacet && attrName != null &&
"caption".equals(attrName.getNodeValue())) {
+ tableCaption = node;
} else if (isColumn) {
if (columns == null) columns = new ArrayList<SourceColumnElements>();
columns.add(new SourceColumnElements(node));
@@ -98,6 +101,10 @@
public boolean hasTableFooter() {
return tableFooter != null;
}
+
+ public boolean hasTableCaption() {
+ return tableCaption != null;
+ }
public boolean hasColumnsHeader() {
for (int i = 0; i < getColumnCount(); i++) {
@@ -130,6 +137,14 @@
public void setTableHeader(Node tableHeader) {
this.tableHeader = tableHeader;
}
+
+ public Node getTableCaption() {
+ return tableCaption;
+ }
+
+ public void setTableCaption(Node tableCaption) {
+ this.tableCaption = tableCaption;
+ }
}
public static class SourceColumnElements {
@@ -229,6 +244,9 @@
}
public static class VisualDataTableElements {
+ private nsIDOMElement caption;
+ private nsIDOMElement tableCaptionTag;
+
private nsIDOMElement header;
private nsIDOMElement tableHeaderRow;
private nsIDOMElement columnsHeaderRow;
@@ -280,6 +298,14 @@
public void setColumnsHeaderRow(nsIDOMElement columnsHeaderRow) {
this.columnsHeaderRow = columnsHeaderRow;
}
+
+ public nsIDOMElement getTableCaptionTag() {
+ return tableCaptionTag;
+ }
+
+ public void setTableCaptionTag(nsIDOMElement tableCaptionTag) {
+ this.tableCaptionTag = tableCaptionTag;
+ }
public nsIDOMElement getFooter() {
return footer;
@@ -296,7 +322,15 @@
public void setHeader(nsIDOMElement header) {
this.header = header;
}
+
+ public nsIDOMElement getCaption() {
+ return caption;
+ }
+ public void setCaption(nsIDOMElement caption) {
+ this.caption = caption;
+ }
+
public nsIDOMElement getTableFooterRow() {
return tableFooterRow;
}
@@ -377,6 +411,7 @@
VpeDataTableElements.getNamedChild(visualParent, HTML.TAG_TFOOT)
);
+ visualDataTableElements.setTableCaptionTag(VpeDataTableElements.getNamedChild(visualDataTableElements.getCaption(),
"caption"));
visualDataTableElements.setTableHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getHeader(),
"tr"));
visualDataTableElements.setColumnsHeaderRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getHeader(),
"tr", 1));
visualDataTableElements.setBodyRow(VpeDataTableElements.getNamedChild(visualDataTableElements.getBody(),
"tr"));
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -34,15 +34,19 @@
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
VpeCreatorInfo creatorInfo = null;
- boolean isHeader = false, isFooter = false;
+ boolean isHeader = false;
+ boolean isFooter = false;
+ boolean isCaption = false;
+
Node nameAttr = sourceNode.getAttributes().getNamedItem("name");
if (nameAttr != null) {
String name = nameAttr.getNodeValue();
isHeader = name.equals("header");
isFooter = name.equals("footer");
+ isCaption = name.equals("caption");
}
- if (isHeader || isFooter) {
+ if (isHeader || isFooter || isCaption) {
Node sourceParent = sourceNode.getParentNode();
if (sourceParent != null) {
nsIDOMNode visualParent = null;
@@ -51,9 +55,11 @@
visualParent = pageContext.getDomMapping().getVisualNode(sourceParent);
}
- nsIDOMNode header = null, footer = null;
+ nsIDOMNode header = null;
+ nsIDOMNode footer = null;
+ nsIDOMNode caption = null;
+
if (visualParent != null &&
visualParent.getNodeName().equalsIgnoreCase("table")) {
-
nsIDOMNodeList children = visualParent.getChildNodes();
long count = children != null ? children.getLength() : 0;
if (count > 0) {
@@ -78,12 +84,17 @@
cell = makeCell(columnsCount, HTML.TAG_TH, visualDocument);
} else if (isFooter) {
cell = makeCell(columnsCount, HTML.TAG_TD, visualDocument);
+ } else if (isCaption) {
+ cell = visualDocument.createElement(HTML.TAG_CAPTION);
}
if (cell != null) {
if (isHeader) {
setCellClass(cell, getTableAttrValue(sourceParent, "headerClass"));
} else if (isFooter) {
setCellClass(cell, getTableAttrValue(sourceParent, "footerClass"));
+ } else if (isCaption) {
+ setCellClass(cell, getTableAttrValue(sourceParent, "captionClass"));
+ setCaptionStyle(cell, getTableAttrValue(sourceParent, "captionStyle"));
}
creatorInfo = new VpeCreatorInfo(cell);
}
@@ -107,6 +118,14 @@
}
}
}
+
+ private void setCaptionStyle(nsIDOMNode cell, String styleName) {
+ if (cell != null) {
+ if (styleName != null && styleName.trim().length() > 0) {
+ ((nsIDOMElement)cell).setAttribute("style", styleName);
+ }
+ }
+ }
private String getTableAttrValue(Node dataTableNode, String attrName) {
if (dataTableNode != null) {
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-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -153,7 +153,7 @@
static final String ATTR_DATATABLE_FOOTER_CLASS = "footerClass";
static final String ATTR_DATATABLE_ROW_CLASSES = "rowClasses";
static final String ATTR_DATATABLE_COLUMN_CLASSES = "columnClasses";
- static final String[] ATTR_DATATABLE_PROPERTIES =
{"bgcolor","border","cellpadding","cellspacing","frame","rules","class","style","title"};
+ static final String[] ATTR_DATATABLE_PROPERTIES = {"width",
"bgcolor","border","cellpadding","cellspacing","frame","rules","class","style","title"};
public static final String ATTR_LINK_HREF = "href";
public static final String ATTR_LINK_REL = "rel";
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-02-14
14:42:05 UTC (rev 6315)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-02-14
16:00:11 UTC (rev 6316)
@@ -32,6 +32,7 @@
public static final String TAG_TBODY = "TBODY"; //$NON-NLS-1$
public static final String TAG_THEAD = "THEAD"; //$NON-NLS-1$
public static final String TAG_TFOOT = "TFOOT"; //$NON-NLS-1$
+ public static final String TAG_CAPTION = "CAPTION"; //$NON-NLS-1$
public static final String TAG_TH = "TH"; //$NON-NLS-1$
public static final String TAG_TR = "TR"; //$NON-NLS-1$
public static final String TAG_TD = "TD"; //$NON-NLS-1$
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2008-02-14
14:42:05 UTC (rev 6315)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/templates/vpe-templates-jsf.xml 2008-02-14
16:00:11 UTC (rev 6316)
@@ -935,7 +935,7 @@
<vpe:tag name="h:dataTable" case-sensitive="yes">
<vpe:template children="yes" modify="no">
- <vpe:datatable bgcolor="{@bgcolor}" border="{@border}"
+ <vpe:datatable width="{@width}" bgcolor="{@bgcolor}"
border="{@border}"
cellpadding="{@cellpadding}" cellspacing="{@cellspacing}"
columnClasses="{@columnClasses}" footerClass="{@footerClass}"
headerClass="{@headerClass}"
rowClasses="{@rowClasses}"