Author: yradtsevich
Date: 2008-11-17 14:18:56 -0500 (Mon, 17 Nov 2008)
New Revision: 11854
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableStyleClassesApplier.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/scrollableDataTable.xhtml.xml
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/VisualDomUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java
Log:
CODING IN PROGRESS - issue JBIDE-2877: <rich:dataTable>, <rich:column>
interaction
https://jira.jboss.org/jira/browse/JBIDE-2877
Attributes 'columnClasses' and 'rowClasses' of <rich:dataTable> and
<rich:scrollableDataTable> now are supported by VPE.
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.vpe.richfaces.template;
-
-import java.util.List;
-
-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.VpeChildrenInfo;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * The class {@code RichFacesDataTableChildrenEncoder} encodes children of a {@code
rich:*Table}.
- *
- * <BR/>Use this class as follows:
- * <blockquote><pre>
- * RichFacesDataTableChildrenEncoder encoder
- * = new RichFacesDataTableChildrenEncoder(
- * creationData, visualDocument, sourceElement, table);
- * encoder.encodeChildren();</pre></blockquote>
- *
- * Method {@link #validateChildren(VpePageContext, Node, nsIDOMDocument, VpeCreationData)
validateChildren}
- * MUST be invoked from {@link VpeTemplate#validate(VpePageContext, Node, nsIDOMDocument,
VpeCreationData) validate}
- * method of the caller of this class:
- * <blockquote><pre>
- * public void validate(VpePageContext pageContext, Node sourceNode,
- * nsIDOMDocument visualDocument, VpeCreationData data) {
- * RichFacesDataTableChildrenEncoder.validateChildren(
- * pageContext, sourceNode, visualDocument, data);
- * ...
- * }</pre></blockquote>
- *
- * @author yradtsevich
- * */
-class RichFacesDataTableChildrenEncoder {
- private String firstRowClass = "dr-table-firstrow rich-table-firstrow";
- private String nonFirstRowClass = "dr-table-row rich-table-row";
-
- /**@param firstRowClass the class of the first row in the table
- * @param nonFirstRowClass the class of all rows in the table except the first one*/
- public void setRowClasses(final String firstRowClass, final String nonFirstRowClass) {
- this.firstRowClass = firstRowClass;
- this.nonFirstRowClass = nonFirstRowClass;
- }
-
- /**Non-HTML tag that is used to create temporary containers for {@code rich:subTable}
and {@code rich:columnGroup}.*/
- private static final String TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER =
"subTableOrColumnGroup-container"; //$NON-NLS-1$
- private final VpeCreationData creationData;
- private final nsIDOMDocument visualDocument;
- private final Element sourceElement;
- private final nsIDOMElement table;
-
- public RichFacesDataTableChildrenEncoder(final VpeCreationData creationData,
- final nsIDOMDocument visualDocument, final Element sourceElement,
- final nsIDOMElement table) {
- this.creationData = creationData;
- this.visualDocument = visualDocument;
- this.sourceElement = sourceElement;
- this.table = table;
- }
-
- /**
- * Creates containers in {@code table} for {@code sourceElement}'s children
- * and adds appropriate objects of {@link VpeChildrenInfo} to {@code creationData}.
- *
- * <BR/>It knows about following tags:
- * {@code rich:column, rich:columns, rich:subTable} and {@code rich:columnGroup}.
- * <BR/>For any another tag it uses {@link #addElementToTable(Node)} method.
- * */
- public void encodeChildren() {
- final List<Node> children = ComponentUtil.getChildren(sourceElement);
- boolean createNewRow = true;
- for (final Node child : children) {
- final String nodeName = child.getNodeName();
- if (nodeName.endsWith(RichFaces.TAG_COLUMN) ||
- nodeName.endsWith(RichFaces.TAG_COLUMNS)) {
- createNewRow |= RichFacesColumnTemplate.isBreakBefore(child);
- addColumnToRow(child, createNewRow);
- createNewRow = false;
- } else if(nodeName.endsWith(RichFaces.TAG_SUB_TABLE)
- || nodeName.endsWith(RichFaces.TAG_COLUMN_GROUP)) {
- addSubTableOrColumnGroupToTable(child);
- createNewRow = true;
- } else if (!VpeCreatorUtil.isFacet(child)) {
- addElementToTable(child);
- createNewRow = true;
- }
- }
- }
-
- /**
- * Makes necessary changes in the table's body after all children of the table have
been encoded.
- * */
- public static void validateChildren(final VpePageContext pageContext, final Node
sourceNode,
- final nsIDOMDocument visualDocument, final VpeCreationData creationData) {
- final nsIDOMNode visualNode = creationData.getNode();
- fixSubTables(visualNode);
- }
-
- /**
- * Creates a container for {@code subTableOrColumnGroupNode} in {@code table}
- * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
- * <BR/>The container is the tag {@link
#TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER}.
- * */
- private nsIDOMElement addSubTableOrColumnGroupToTable(final Node
subTableOrColumnGroupNode) {
- final nsIDOMElement subTableOrColumnGroupContainer =
visualDocument.createElement(TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER);
- table.appendChild(subTableOrColumnGroupContainer);
- final VpeChildrenInfo childInfo = new VpeChildrenInfo(subTableOrColumnGroupContainer);
- childInfo.addSourceChild(subTableOrColumnGroupNode);
- creationData.addChildrenInfo(childInfo);
-
- return subTableOrColumnGroupContainer;
- }
-
- private nsIDOMElement currentRow = null;
- private VpeChildrenInfo currentRowChildrenInfo = null;
- private int rowNumber = 0;
- /**
- * Creates a container for {@code columnNode} in {@code table}
- * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
- * <BR/>If the parameter {@code createNewRow} is {@code true} then it creates
the
- * container in a new row.
- * */
- private nsIDOMElement addColumnToRow(final Node columnNode, final boolean createNewRow)
{
- if ( createNewRow || (currentRow == null) ) {
- currentRow = visualDocument.createElement(HTML.TAG_TR);
- table.appendChild(currentRow);
- currentRowChildrenInfo = new VpeChildrenInfo(currentRow);
- creationData.addChildrenInfo(currentRowChildrenInfo);
- rowNumber++;
- if (rowNumber == 1) {
- currentRow.setAttribute(HTML.ATTR_CLASS, firstRowClass); //$NON-NLS-1$
- } else {
- currentRow.setAttribute(HTML.ATTR_CLASS, nonFirstRowClass); //$NON-NLS-1$
- }
- }
-
- currentRowChildrenInfo.addSourceChild(columnNode);
- return currentRow;
- }
-
- /**
- * Creates a row container for {@code node} in {@code table}
- * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
- * <BR/>The container spans the entire row.
- * */
- private void addElementToTable(final Node node) {
- final nsIDOMElement tr = this.visualDocument.createElement(HTML.TAG_TR);
- table.appendChild(tr);
- final nsIDOMElement td = this.visualDocument.createElement(HTML.TAG_TD);
-
- td.setAttribute(HTML.ATTR_COLSPAN, HTML.VALUE_COLSPAN_ALL);
- tr.appendChild(td);
- final VpeChildrenInfo childInfo = new VpeChildrenInfo(td);
- childInfo.addSourceChild(node);
- creationData.addChildrenInfo(childInfo);
- }
-
- /**
- * Replaces all occurencies of {@link #TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER} tag in
- * the {@code visualNode} by the tag's child.
- * @see #addSubTableOrColumnGroupToTable(Node)
- */
- private static void fixSubTables(final nsIDOMNode visualNode) {
- final nsIDOMElement element = (nsIDOMElement) visualNode;
- final nsIDOMNodeList subTableContainers =
element.getElementsByTagName(TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER);
- final long length = subTableContainers.getLength();
- for (int i = 0; i < length; i++) {
- final nsIDOMNode subTableContainer = subTableContainers.item(0);
- final nsIDOMNodeList subTableContainerChildren = subTableContainer.getChildNodes();
- final nsIDOMNode containerParent = subTableContainer.getParentNode();
- if (subTableContainerChildren != null
- && subTableContainerChildren.getLength() == 1) {
- final nsIDOMNode subTableMainTag = subTableContainerChildren.item(0);
- subTableContainer.removeChild(subTableMainTag);
- containerParent.insertBefore(subTableMainTag, subTableContainer);
- } else {
- final RuntimeException e = new RuntimeException("This is probably a bug.
subTable-container should have one inner tag.");//$NON-NLS-1$
- RichFacesTemplatesActivator.getPluginLog().logError(e);
- }
- containerParent.removeChild(subTableContainer);
- }
- }
-}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.util.List;
+
+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.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+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.mozilla.interfaces.nsIDOMNodeList;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * The class {@code RichFacesDataTableChildrenEncoder} encodes children of a {@code
rich:*Table}.
+ *
+ * <BR/>Use this class as follows:
+ * <blockquote><pre>
+ * RichFacesDataTableChildrenEncoder encoder
+ * = new RichFacesDataTableChildrenEncoder(
+ * creationData, visualDocument, sourceElement, table);
+ * encoder.encodeChildren();</pre></blockquote>
+ *
+ * Method {@link #validateChildren(VpePageContext, Node, nsIDOMDocument, VpeCreationData)
validateChildren}
+ * MUST be invoked from {@link VpeTemplate#validate(VpePageContext, Node, nsIDOMDocument,
VpeCreationData) validate}
+ * method of the caller of this class:
+ * <blockquote><pre>
+ * public void validate(VpePageContext pageContext, Node sourceNode,
+ * nsIDOMDocument visualDocument, VpeCreationData data) {
+ * RichFacesDataTableChildrenEncoder.validateChildren(
+ * pageContext, sourceNode, visualDocument, data);
+ * ...
+ * }</pre></blockquote>
+ *
+ * @author yradtsevich
+ * */
+class RichFacesDataTableChildrenEncoder {
+ private String firstRowClass = "dr-table-firstrow rich-table-firstrow";
//$NON-NLS-1$
+ private String nonFirstRowClass = "dr-table-row rich-table-row";
//$NON-NLS-1$
+
+ /**@param firstRowClass the class of the first row in the table
+ * @param nonFirstRowClass the class of all rows in the table except the first one*/
+ public void setRowClasses(final String firstRowClass, final String nonFirstRowClass) {
+ this.firstRowClass = firstRowClass;
+ this.nonFirstRowClass = nonFirstRowClass;
+ }
+
+ /**Non-HTML tag that is used to create temporary containers for {@code rich:subTable}
and {@code rich:columnGroup}.*/
+ private static final String TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER =
"subTableOrColumnGroup-container"; //$NON-NLS-1$
+ private final VpeCreationData creationData;
+ private final nsIDOMDocument visualDocument;
+ private final Element sourceElement;
+ private final nsIDOMElement table;
+
+ public RichFacesDataTableChildrenEncoder(final VpeCreationData creationData,
+ final nsIDOMDocument visualDocument, final Element sourceElement,
+ final nsIDOMElement table) {
+ this.creationData = creationData;
+ this.visualDocument = visualDocument;
+ this.sourceElement = sourceElement;
+ this.table = table;
+ }
+
+ /**
+ * Creates containers in {@code table} for {@code sourceElement}'s children
+ * and adds appropriate objects of {@link VpeChildrenInfo} to {@code creationData}.
+ *
+ * <BR/>It knows about following tags:
+ * {@code rich:column, rich:columns, rich:subTable} and {@code rich:columnGroup}.
+ * <BR/>For any another tag it uses {@link #addElementToTable(Node)} method.
+ * */
+ public void encodeChildren() {
+ final List<Node> children = ComponentUtil.getChildren(sourceElement);
+ boolean createNewRow = true;
+ for (final Node child : children) {
+ final String nodeName = child.getNodeName();
+ if (nodeName.endsWith(RichFaces.TAG_COLUMN) ||
+ nodeName.endsWith(RichFaces.TAG_COLUMNS)) {
+ createNewRow |= RichFacesColumnTemplate.isBreakBefore(child);
+ addColumnToRow(child, createNewRow);
+ createNewRow = false;
+ } else if(nodeName.endsWith(RichFaces.TAG_SUB_TABLE)
+ || nodeName.endsWith(RichFaces.TAG_COLUMN_GROUP)) {
+ addSubTableOrColumnGroupToTable(child);
+ createNewRow = true;
+ } else if (!VpeCreatorUtil.isFacet(child)) {
+ addElementToTable(child);
+ createNewRow = true;
+ }
+ }
+ }
+
+ /**
+ * Makes necessary changes in the table's body after all children of the table have
been encoded.
+ */
+ public static void validateChildren(final VpePageContext pageContext, final Node
sourceNode,
+ final nsIDOMDocument visualDocument, final VpeCreationData creationData) {
+ final nsIDOMNode visualNode = creationData.getNode();
+ fixSubTables(visualNode);
+ }
+
+ /**
+ * Creates a container for {@code subTableOrColumnGroupNode} in {@code table}
+ * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
+ * <BR/>The container is the tag {@link
#TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER}.
+ */
+ private nsIDOMElement addSubTableOrColumnGroupToTable(final Node
subTableOrColumnGroupNode) {
+ final nsIDOMElement subTableOrColumnGroupContainer =
visualDocument.createElement(TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER);
+ table.appendChild(subTableOrColumnGroupContainer);
+ final VpeChildrenInfo childInfo = new VpeChildrenInfo(subTableOrColumnGroupContainer);
+ childInfo.addSourceChild(subTableOrColumnGroupNode);
+ creationData.addChildrenInfo(childInfo);
+
+ return subTableOrColumnGroupContainer;
+ }
+
+ private nsIDOMElement currentRow = null;
+ private VpeChildrenInfo currentRowChildrenInfo = null;
+ private int rowNumber = 0;
+ /**
+ * Creates a container for {@code columnNode} in {@code table}
+ * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
+ * <BR/>If the parameter {@code createNewRow} is {@code true} then it creates
the
+ * container in a new row.
+ * */
+ private nsIDOMElement addColumnToRow(final Node columnNode, final boolean createNewRow)
{
+ if ( createNewRow || (currentRow == null) ) {
+ currentRow = visualDocument.createElement(HTML.TAG_TR);
+ table.appendChild(currentRow);
+ currentRowChildrenInfo = new VpeChildrenInfo(currentRow);
+ creationData.addChildrenInfo(currentRowChildrenInfo);
+ rowNumber++;
+ if (rowNumber == 1) {
+ currentRow.setAttribute(HTML.ATTR_CLASS, firstRowClass);
+ } else {
+ currentRow.setAttribute(HTML.ATTR_CLASS, nonFirstRowClass);
+ }
+ }
+
+ currentRowChildrenInfo.addSourceChild(columnNode);
+ return currentRow;
+ }
+
+ /**
+ * Creates a row container for {@code node} in {@code table}
+ * and adds an appropriate object of {@link VpeChildrenInfo} to {@code creationData}.
+ * <BR/>The container spans the entire row.
+ * */
+ private void addElementToTable(final Node node) {
+ final nsIDOMElement tr = this.visualDocument.createElement(HTML.TAG_TR);
+ table.appendChild(tr);
+ final nsIDOMElement td = this.visualDocument.createElement(HTML.TAG_TD);
+
+ td.setAttribute(HTML.ATTR_COLSPAN, HTML.VALUE_COLSPAN_ALL);
+ tr.appendChild(td);
+ final VpeChildrenInfo childInfo = new VpeChildrenInfo(td);
+ childInfo.addSourceChild(node);
+ creationData.addChildrenInfo(childInfo);
+ }
+
+ /**
+ * Replaces all occurencies of {@link #TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER} tag in
+ * the {@code visualNode} by the tag's child.
+ * @see #addSubTableOrColumnGroupToTable(Node)
+ */
+ private static void fixSubTables(final nsIDOMNode visualNode) {
+ final nsIDOMElement element = (nsIDOMElement) visualNode;
+ final nsIDOMNodeList subTableContainers =
element.getElementsByTagName(TAG_SUB_TABLE_OR_COLUMN_GROUP_CONTAINER);
+ final long length = subTableContainers.getLength();
+ for (int i = 0; i < length; i++) {
+ final nsIDOMNode subTableContainer = subTableContainers.item(0);
+ final nsIDOMNodeList subTableContainerChildren = subTableContainer.getChildNodes();
+
+ if (subTableContainerChildren == null
+ || subTableContainerChildren.getLength() != 1) {
+ final RuntimeException e = new RuntimeException("This is probably a bug.
subTable-container should have one inner tag.");//$NON-NLS-1$
+ RichFacesTemplatesActivator.getPluginLog().logError(e);
+ }
+
+ VisualDomUtil.replaceNodeByItsChildren(subTableContainer);
+ }
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableChildrenEncoder.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableStyleClassesApplier.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableStyleClassesApplier.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableStyleClassesApplier.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import java.util.List;
+
+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.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpression;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilderException;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeClassUtil;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.w3c.dom.Node;
+
+/**
+ * Class {@code RichFacesDataTableStyleClassesApplier} should be used in templates
+ * of tags that support attributes {@code 'rowClasses'} and {@code
'columnClasses'}.
+ * <P/>
+ * It expects it is used in pair with {@link RichFacesDataTableChildrenEncoder}.
+ *
+ * @author yradtsevich
+ */
+public class RichFacesDataTableStyleClassesApplier {
+ private static final String COLUMN_CLASSES_EXPRESSION =
+ "{@" + RichFaces.ATTR_COLUMN_CLASSES + "}"; //$NON-NLS-1$
//$NON-NLS-2$
+ private static final String ROW_CLASSES_EXPRESSION =
+ "{@" + RichFaces.ATTR_ROW_CLASSES + "}"; //$NON-NLS-1$
//$NON-NLS-2$
+ private final List<String> rowClasses;
+ private final List<String> columnClasses;
+
+ /**
+ * Constructs {@code RichFacesDataTableStyleClassesApplier}.
+ *
+ * @param visualDocument an object of {@link nsIDOMDocument}
+ * @param pageContext an object of {@link VpePageContext}
+ * @param sourceNode an object of a tag that could have
+ * attributes {@code 'rowClasses'} and {@code 'columnClasses'}.
+ */
+ public RichFacesDataTableStyleClassesApplier(final nsIDOMDocument visualDocument,
+ final VpePageContext pageContext, final Node sourceNode) {
+ VpeExpression rowClassesExpr;
+ VpeExpression columnClassesExpr;
+ try {
+ rowClassesExpr = VpeExpressionBuilder
+ .buildCompletedExpression(ROW_CLASSES_EXPRESSION, true).getExpression();
+ columnClassesExpr = VpeExpressionBuilder
+ .buildCompletedExpression(COLUMN_CLASSES_EXPRESSION, true).getExpression();
+ } catch (final VpeExpressionBuilderException e) {
+ throw new RuntimeException(e);
+ }
+
+ try {
+ rowClasses = VpeClassUtil.getClasses(rowClassesExpr, sourceNode,
+ pageContext);
+ columnClasses = VpeClassUtil.getClasses(columnClassesExpr, sourceNode,
+ pageContext);
+ } catch (final VpeExpressionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Applies style-classes specified in attributes {@code 'rowClasses'} and
+ * {@code 'columnClasses'} of {@code sourceNode} to the {@code targetTable}.
+ * <P/>
+ * This method should be used in
+ * {@link VpeAbstractTemplate#validate(VpePageContext, Node, nsIDOMDocument,
VpeCreationData) validate()}
+ * method of a template after
+ * {@link RichFacesDataTableChildrenEncoder#validateChildren(VpePageContext, Node,
nsIDOMDocument, VpeCreationData) RichFacesDataTableChildrenEncoder.validateChildren()}
+ * is called.
+ * <P/>
+ * The basic idea of the method is to add appropriate rowClasses only
+ * to the direct TR children of the table and add appropriate columnClasses
+ * only to direct TD children of that TRs. It gives us opportunity to separate
+ * TRs and TDs that created by the tag directly from TRs and TDs created
+ * by the tag's children.
+ */
+ public void applyClasses(final nsIDOMElement targetTable) {
+ final nsIDOMNodeList tableChildren = targetTable.getChildNodes();
+ int rowIndex = 0;
+ final int tableChildrenLength = (int) tableChildren.getLength();
+ for (int i = 0; i < tableChildrenLength; i++) {
+ final nsIDOMNode tableChild = tableChildren.item(i);
+ if (tableChild.getNodeType() == nsIDOMNode.ELEMENT_NODE
+ && HTML.TAG_TR.equalsIgnoreCase( tableChild.getNodeName() )) {
+ final nsIDOMElement row =
+ (nsIDOMElement) tableChild.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ applyClass(rowClasses, row, rowIndex);
+
+ applyClassesToCells(row);
+ rowIndex++;
+ }
+ }
+ }
+
+ /**
+ * Applies style-classes specified in attribute {@code 'columnClasses'}
+ * of {@code sourceNode} to the {@code row}.
+ */
+ private void applyClassesToCells(final nsIDOMElement row) {
+ final int columnClassesSize = columnClasses.size();
+ if (columnClassesSize > 0) {
+ final nsIDOMNodeList rowChildren = row.getChildNodes();
+ int columnIndex = 0;
+ int rowChildrenLength = (int)rowChildren.getLength();
+ for (int j = 0; j < rowChildrenLength; j++) {
+ final nsIDOMNode rowChild = rowChildren.item(j);
+ if (rowChild.getNodeType() == nsIDOMNode.ELEMENT_NODE
+ && HTML.TAG_TD.equalsIgnoreCase( rowChild.getNodeName() )) {
+ final nsIDOMElement cell =
+ (nsIDOMElement) rowChild.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ applyClass(columnClasses, cell, columnIndex);
+
+ columnIndex++;
+ }
+ }
+ }
+ }
+
+ /**
+ * Applies appropriate style-class from the list {@code classes} to the
+ * {@code element} (a row or a cell) position of that is {@code elementIndex}.
+ */
+ private static void applyClass(final List<String> classes, final nsIDOMElement
element,
+ int elementIndex) {
+ int classesSize = classes.size();
+ if (classesSize > 0) {
+ final String clazz = classes.get(elementIndex % classesSize);
+ String actualClass = element.getAttribute(HTML.ATTR_CLASS);
+ if (actualClass == null) {
+ actualClass = clazz;
+ } else {
+ actualClass+= HTML.VALUE_CLASS_DELIMITER + clazz;
+ }
+ element.setAttribute(HTML.ATTR_CLASS, actualClass);
+ }
+ }
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -11,7 +11,6 @@
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.template.util.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
@@ -333,6 +332,11 @@
public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data) {
RichFacesDataTableChildrenEncoder.validateChildren(pageContext, sourceNode,
visualDocument, data);
+
+ final RichFacesDataTableStyleClassesApplier styleClassesApplier =
+ new RichFacesDataTableStyleClassesApplier(visualDocument,
+ pageContext, sourceNode);
+ styleClassesApplier.applyClasses((nsIDOMElement) data.getNode());
}
@Override
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -15,14 +15,18 @@
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+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;
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.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -51,6 +55,7 @@
private static String STYLE_FOR_RIGHT_SCROLL = "overflow: scroll; width: 17px;
height: 100%;";
private static final int NUM_ROW = 5;
+ private static final String TAG_MAIN_TABLE_WRAPPER = "mainTable-wrapper";
//$NON-NLS-1$
/**
* Creates a node of the visual tree on the node of the source tree. This
@@ -131,18 +136,21 @@
div.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, divStyle);
- nsIDOMElement table = visualDocument
+ nsIDOMElement mainTable = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
- ComponentUtil.copyAttributes(sourceNode, table);
- table.removeAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT);
- div.appendChild(table);
+ ComponentUtil.copyAttributes(sourceNode, mainTable);
+ mainTable.removeAttribute(HtmlComponentUtil.HTML_ATR_HEIGHT);
+ nsIDOMElement mainTableWrapper = visualDocument.createElement(TAG_MAIN_TABLE_WRAPPER);
+ mainTableWrapper.appendChild(mainTable);
+ div.appendChild(mainTableWrapper);
+
ComponentUtil.setCSSLink(pageContext,
"scrollableDataTable/scrollableDataTable.css",
"richFacesDataTable");
String tableClass = sourceElement
.getAttribute(HtmlComponentUtil.HTML_STYLECLASS_ATTR);
- table
+ mainTable
.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
"dr-table rich-table "
+ (tableClass == null ? "" : tableClass));
@@ -154,10 +162,10 @@
.createElement(HtmlComponentUtil.HTML_TAG_COLGROUP);
colgroup.setAttribute(HtmlComponentUtil.HTML_TAG_SPAN, String
.valueOf(columnsLength));
- table.appendChild(colgroup);
+ mainTable.appendChild(colgroup);
// Encode Caption
- encodeCaption(creationData, sourceElement, visualDocument, table);
+ encodeCaption(creationData, sourceElement, visualDocument, mainTable);
// Encode Header
Element header = ComponentUtil.getFacet(sourceElement, HEADER);
@@ -165,7 +173,7 @@
if (header != null || !columnsHeaders.isEmpty()) {
nsIDOMElement thead = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_THEAD);
- table.appendChild(thead);
+ mainTable.appendChild(thead);
String headerClass = (String) sourceElement
.getAttribute(HEADER_CLASS);
if (header != null) {
@@ -199,7 +207,7 @@
if (footer != null || !columnsFooters.isEmpty()) {
nsIDOMElement tfoot = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TFOOT);
- table.appendChild(tfoot);
+ mainTable.appendChild(tfoot);
String footerClass = (String) sourceElement
.getAttribute(FOOTER_CLASS);
if (!columnsFooters.isEmpty()) {
@@ -230,11 +238,11 @@
nsIDOMElement tbody = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_TBODY);
- table.appendChild(tbody);
+ mainTable.appendChild(tbody);
for (int i = 0; i < NUM_ROW; i++) {
new RichFacesDataTableChildrenEncoder(creationData, visualDocument,
- sourceElement, table).encodeChildren();
+ sourceElement, mainTable).encodeChildren();
}
return creationData;
@@ -552,8 +560,40 @@
public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data) {
RichFacesDataTableChildrenEncoder.validateChildren(pageContext, sourceNode,
visualDocument, data);
+ applyStyleClasses(pageContext, sourceNode, visualDocument, data);
}
+ private void applyStyleClasses(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+
+ nsIDOMElement element = (nsIDOMElement) data.getNode();
+ final nsIDOMNodeList mainTableWrappers =
element.getElementsByTagName(TAG_MAIN_TABLE_WRAPPER);
+
+ if (mainTableWrappers == null
+ || mainTableWrappers.getLength() != 1) {
+ final RuntimeException e = new RuntimeException("This is probably a bug. There
should be exatly one " + TAG_MAIN_TABLE_WRAPPER);//$NON-NLS-1$
+ RichFacesTemplatesActivator.getPluginLog().logError(e);
+ }
+ final nsIDOMNode mainTableWrapper = mainTableWrappers.item(0);
+ final nsIDOMNodeList mainTableWrapperChildren = mainTableWrapper.getChildNodes();
+
+ if (mainTableWrapperChildren == null
+ || mainTableWrapperChildren.getLength() != 1) {
+ final RuntimeException e = new RuntimeException("This is probably a bug. " +
TAG_MAIN_TABLE_WRAPPER + " should have exactly one child.");//$NON-NLS-1$
//$NON-NLS-2$
+ RichFacesTemplatesActivator.getPluginLog().logError(e);
+ }
+
+ final nsIDOMElement mainTable = (nsIDOMElement) mainTableWrapperChildren.item(0)
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ final RichFacesDataTableStyleClassesApplier styleClassesApplier =
+ new RichFacesDataTableStyleClassesApplier(visualDocument,
+ pageContext, sourceNode);
+ styleClassesApplier.applyClasses(mainTable);
+
+ VisualDomUtil.replaceNodeByItsChildren(mainTableWrapper);
+ }
+
// @Override
// public void removeAttribute(VpePageContext pageContext,
// Element sourceElement, nsIDOMDocument visualDocument,
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -177,7 +177,8 @@
if (columnStyle == null) {
columnStyle = visualDocument.createAttribute(HTML.ATTR_CLASS);
}
- columnStyle.setNodeValue(columnStyle.getNodeValue() + ' ' +
getColumnClass(column));
+ columnStyle.setNodeValue(columnStyle.getNodeValue() + HTML.VALUE_CLASS_DELIMITER
+ + getColumnClass(column));
column++;
}
}
@@ -249,27 +250,27 @@
}
protected String getRowClass(final int row) {
- StringBuffer rowClass = new StringBuffer(DEAFAULT_CELL_CLASS);
+ String rowClass = DEAFAULT_CELL_CLASS;
if (rowClasses != null) {
final int rowClassesSize = rowClasses.size();
if(rowClassesSize > 0) {
- rowClass = new StringBuffer(rowClasses.get(row % rowClassesSize));
+ rowClass = rowClasses.get(row % rowClassesSize);
}
}
- return rowClass.toString();
+ return rowClass;
}
private String getColumnClass(final int column) {
- StringBuffer columnClass = new StringBuffer(DEAFAULT_CELL_CLASS);
+ String columnClass = DEAFAULT_CELL_CLASS;
if (columnClasses != null) {
final int columnClassesSize = columnClasses.size();
if (columnClassesSize > 0) {
- columnClass = new StringBuffer(columnClasses.get(column % columnClassesSize));
+ columnClass = columnClasses.get(column % columnClassesSize);
}
}
- return columnClass.toString();
+ return columnClass;
}
private void initClasses(final Node sourceNode, final VpePageContext pageContext) {
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/scrollableDataTable.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/scrollableDataTable.xhtml.xml 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/scrollableDataTable.xhtml.xml 2008-11-17
19:18:56 UTC (rev 11854)
@@ -42,102 +42,102 @@
<TBODY>
</TBODY>
<TR CLASS="dr-table-firstrow rich-table-firstrow">
- <TD ID="make" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="make" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.make}</SPAN>
</TD>
- <TD ID="model" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="model" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.model}</SPAN>
</TD>
- <TD ID="price" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="price" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.price}</SPAN>
</TD>
- <TD ID="mileage" CLASS="dr-table-cell
rich-table-cell">
+ <TD ID="mileage" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.mileage}</SPAN>
</TD>
- <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell">
+ <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell col">
<SPAN> #{category.vin}</SPAN>
</TD>
- <TD ID="stock" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="stock" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.stock}</SPAN>
</TD>
</TR>
<TR CLASS="dr-table-firstrow rich-table-firstrow">
- <TD ID="make" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="make" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.make}</SPAN>
</TD>
- <TD ID="model" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="model" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.model}</SPAN>
</TD>
- <TD ID="price" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="price" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.price}</SPAN>
</TD>
- <TD ID="mileage" CLASS="dr-table-cell
rich-table-cell">
+ <TD ID="mileage" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.mileage}</SPAN>
</TD>
- <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell">
+ <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell col">
<SPAN> #{category.vin}</SPAN>
</TD>
- <TD ID="stock" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="stock" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.stock}</SPAN>
</TD>
</TR>
<TR CLASS="dr-table-firstrow rich-table-firstrow">
- <TD ID="make" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="make" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.make}</SPAN>
</TD>
- <TD ID="model" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="model" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.model}</SPAN>
</TD>
- <TD ID="price" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="price" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.price}</SPAN>
</TD>
- <TD ID="mileage" CLASS="dr-table-cell
rich-table-cell">
+ <TD ID="mileage" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.mileage}</SPAN>
</TD>
- <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell">
+ <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell col">
<SPAN> #{category.vin}</SPAN>
</TD>
- <TD ID="stock" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="stock" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.stock}</SPAN>
</TD>
</TR>
<TR CLASS="dr-table-firstrow rich-table-firstrow">
- <TD ID="make" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="make" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.make}</SPAN>
</TD>
- <TD ID="model" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="model" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.model}</SPAN>
</TD>
- <TD ID="price" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="price" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.price}</SPAN>
</TD>
- <TD ID="mileage" CLASS="dr-table-cell
rich-table-cell">
+ <TD ID="mileage" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.mileage}</SPAN>
</TD>
- <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell">
+ <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell col">
<SPAN> #{category.vin}</SPAN>
</TD>
- <TD ID="stock" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="stock" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.stock}</SPAN>
</TD>
</TR>
<TR CLASS="dr-table-firstrow rich-table-firstrow">
- <TD ID="make" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="make" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.make}</SPAN>
</TD>
- <TD ID="model" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="model" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.model}</SPAN>
</TD>
- <TD ID="price" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="price" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.price}</SPAN>
</TD>
- <TD ID="mileage" CLASS="dr-table-cell
rich-table-cell">
+ <TD ID="mileage" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.mileage}</SPAN>
</TD>
- <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell">
+ <TD WIDTH="200" ID="vin" CLASS="dr-table-cell
rich-table-cell col">
<SPAN> #{category.vin}</SPAN>
</TD>
- <TD ID="stock" CLASS="dr-table-cell rich-table-cell">
+ <TD ID="stock" CLASS="dr-table-cell rich-table-cell
col">
<SPAN> #{category.stock}</SPAN>
</TD>
</TR>
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-11-17
19:06:38 UTC (rev 11853)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -102,6 +102,7 @@
public static final String VALUE_ALIGN_TOP = "top"; //$NON-NLS-1$
public static final String VALUE_ALIGN_RIGHT = "right"; //$NON-NLS-1$
public static final String VALUE_ALIGN_MIDDLE = "middle"; //$NON-NLS-1$
+ public static final String VALUE_CLASS_DELIMITER = " "; //$NON-NLS-1$
public static final String VALUE_TYPE_TEXT = "text"; //$NON-NLS-1$
public static final String VALUE_TYPE_PASSWORD = "password"; //$NON-NLS-1$
public static final String VALUE_TYPE_IMAGE = "image"; //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -12,7 +12,6 @@
import org.eclipse.swt.graphics.Point;
import org.mozilla.interfaces.nsIDOMEvent;
-import org.mozilla.interfaces.nsIDOMEventTarget;
import org.mozilla.interfaces.nsIDOMMouseEvent;
import org.mozilla.interfaces.nsIDOMNSRange;
import org.mozilla.interfaces.nsIDOMNSUIEvent;
@@ -102,4 +101,24 @@
return inRange;
}
+ /**
+ * Appends all children of the {@code node} to its parent at the point before the {@code
node}
+ * and removes the {@code node} from the list of its parent's children.
+ *
+ * @param node should be not null
+ */
+ public static void replaceNodeByItsChildren(nsIDOMNode node) {
+ final nsIDOMNodeList subTableContainerChildren = node.getChildNodes();
+ final nsIDOMNode containerParent = node.getParentNode();
+ if (subTableContainerChildren != null) {
+ final int length = (int) subTableContainerChildren.getLength();
+ for (int i = 0; i < length; i++) {
+ final nsIDOMNode child = subTableContainerChildren.item(i);
+ node.removeChild(child);
+ containerParent.insertBefore(child, node);
+ }
+ }
+ containerParent.removeChild(node);
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java 2008-11-17
19:06:38 UTC (rev 11853)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java 2008-11-17
19:18:56 UTC (rev 11854)
@@ -23,9 +23,6 @@
*
*/
public class VpeClassUtil {
- /**
- *
- */
private static final String CLASSES_DELIMITER = ","; //$NON-NLS-1$
/**