Author: yradtsevich
Date: 2008-11-18 11:20:05 -0500 (Tue, 18 Nov 2008)
New Revision: 11868
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java
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/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
Log:
CODING IN PROGRESS - issue JBIDE-2877: <rich:dataTable>, <rich:column>
interaction
https://jira.jboss.org/jira/browse/JBIDE-2877
Item #5 has been fixed: "visible="false" doesn't work for the column
inside rich:dataTable correctly..."
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java 2008-11-18
15:02:41 UTC (rev 11867)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnTemplate.java 2008-11-18
16:20:05 UTC (rev 11868)
@@ -22,6 +22,7 @@
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.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -35,31 +36,32 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
Element sourceElement = (Element)sourceNode;
- VpeCreationData creationData;
- boolean visible =
!RichFaces.VAL_FALSE.equals(sourceElement.getAttribute(RichFaces.ATTR_VISIBLE));
- if (visible) {
- nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
- String columnClass = getColumnClass(sourceElement);
- ComponentUtil.copyAttributes(sourceNode, td);
- td.setAttribute(HTML.ATTR_CLASS, columnClass);
- creationData = new VpeCreationData(td);
-
- // Create mapping to Encode body
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(td);
- List<Node> children = ComponentUtil.getChildren(sourceElement,true);
- for (Node child : children) {
- if (!isFacet(child)) {
- tdInfo.addSourceChild(child);
- }
+ boolean visible = isVisible(sourceElement);
+
+ nsIDOMElement td = visualDocument.createElement(HTML.TAG_TD);
+
+ if (!visible) {
+ VisualDomUtil.setSubAttribute(td, HTML.ATTR_STYLE,
+ HTML.STYLE_PARAMETER_DISPLAY, HTML.STYLE_VALUE_NONE);
+ }
+
+ String columnClass = getColumnClass(sourceElement);
+ ComponentUtil.copyAttributes(sourceNode, td);
+ td.setAttribute(HTML.ATTR_CLASS, columnClass);
+ final VpeCreationData creationData = new VpeCreationData(td);
+
+ // Create mapping to Encode body
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(td);
+ List<Node> children = ComponentUtil.getChildren(sourceElement,true);
+ for (Node child : children) {
+ if (!isFacet(child)) {
+ tdInfo.addSourceChild(child);
}
- creationData.addChildrenInfo(tdInfo);
+ }
+ creationData.addChildrenInfo(tdInfo);
- } else {
- creationData = new VpeCreationData(null);
- creationData.setChildrenInfoList(new ArrayList<VpeChildrenInfo>(0));
- }
-
+
return creationData;
}
@@ -161,10 +163,19 @@
return null;
}
}
-
+
public static boolean isBreakBefore(Node child) {
String breakBeforeVal = ((Element)child).getAttribute(RichFaces.ATTR_BREAK_BEFORE);
boolean breakBefore = breakBeforeVal != null &&
breakBeforeVal.equalsIgnoreCase(RichFaces.VAL_TRUE);
return breakBefore;
}
+
+ /**
+ * Returns {@code true} if the {@code column} is visible.
+ *
+ * @param column should be not {@code null}
+ */
+ public static boolean isVisible(Element column) {
+ return !RichFaces.VAL_FALSE.equals(column.getAttribute(RichFaces.ATTR_VISIBLE));
+ }
}
\ No newline at end of file
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-18
15:02:41 UTC (rev 11867)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2008-11-18
16:20:05 UTC (rev 11868)
@@ -19,6 +19,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.VisualDomUtil;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -157,6 +159,10 @@
nsIDOMElement td = visualDocument.createElement(element);
parentTr.appendChild(td);
String styleClass = 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$
@@ -177,6 +183,7 @@
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(span);
childrenInfo.addSourceChild(facetBody);
creationData.addChildrenInfo(childrenInfo);
+
}
}
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-18
15:02:41 UTC (rev 11867)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2008-11-18
16:20:05 UTC (rev 11868)
@@ -310,6 +310,12 @@
parentTr.appendChild(td);
String styleClass = 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(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
td.setAttribute("scop", "col");
String colspan = column
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-18
15:02:41 UTC (rev 11867)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-18
16:20:05 UTC (rev 11868)
@@ -113,6 +113,8 @@
public static final String VALUE_ALIGN_CENTER = "center"; //$NON-NLS-1$
public static final String VALUE_CLEAR_BOTH = "both"; //$NON-NLS-1$
+ public static final String STYLE_PARAMETER_DISPLAY = "display"; //$NON-NLS-1$
+ public static final String STYLE_VALUE_NONE = "none"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_WIDTH = "width"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_TOP = "top"; //$NON-NLS-1$
public static final String STYLE_PARAMETER_LEFT = "left"; //$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-18
15:02:41 UTC (rev 11867)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VisualDomUtil.java 2008-11-18
16:20:05 UTC (rev 11868)
@@ -11,6 +11,7 @@
package org.jboss.tools.vpe.editor.util;
import org.eclipse.swt.graphics.Point;
+import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMEvent;
import org.mozilla.interfaces.nsIDOMMouseEvent;
import org.mozilla.interfaces.nsIDOMNSRange;
@@ -19,6 +20,7 @@
import org.mozilla.interfaces.nsIDOMNodeList;
import org.mozilla.interfaces.nsIDOMRange;
import org.mozilla.interfaces.nsISelection;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -121,4 +123,33 @@
containerParent.removeChild(node);
}
+ /**
+ * Sets the style of the attribute of the element to the value.
+ * If the sub-attribute is present already, it replaces its value.
+ * <P/>
+ * Example: {@code <element attributeName="subAttributeName :
subAttributeValue;">}
+ * <P/>
+ * Should be used mainly to set HTML STYLE attribute:
+ * {@code setSubAttribute(div, "STYLE", "width",
"100%")}
+ */
+ public static void setSubAttribute(nsIDOMElement element,
+ String attributeName, String subAttributeName,
+ String subAttributeValue) {
+ String attributeValue = element.getAttribute(attributeName);
+ if (attributeValue == null) {
+ attributeValue = new String();
+ } else {// remove old sub-attribute from the attributeValue
+ attributeValue = VpeStyleUtil.deleteFromString(attributeValue,
+ subAttributeName, Constants.SEMICOLON);
+ }
+ if (attributeValue.length() > 0) {
+ if (!attributeValue.endsWith(Constants.SEMICOLON))
+ attributeValue += Constants.SEMICOLON;
+ }
+
+ attributeValue += subAttributeName + Constants.COLON
+ + subAttributeValue + Constants.SEMICOLON;
+
+ element.setAttribute(attributeName, attributeValue);
+ }
}