Author: dmaliarevich
Date: 2011-06-03 06:35:24 -0400 (Fri, 03 Jun 2011)
New Revision: 31804
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/downIcon.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/upIcon.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTogglerTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnGroupTemplate.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/RichFacesOrderingList.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/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToggleControlTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
Log:
https://issues.jboss.org/browse/JBIDE-8950 , rich:collapsibleSubTable,
rich:collapsibleSubTableToggler were added.
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/downIcon.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/downIcon.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/upIcon.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/collapsibleSubTableToggler/upIcon.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+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.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class RichFacesCollapsibleSubTableTemplate extends RichFacesSubTableTemplate {
+
+ public VpeCreationData create(final VpePageContext pageContext,
+ final Node sourceNode, final nsIDOMDocument visualDocument) {
+ final Element sourceElement = (Element)sourceNode;
+ final nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ String style = "display: table-row-group;"; //$NON-NLS-1$
+ if (RichFaces.readCollapsedStateFromSourceNode(sourceNode)) {
+ style = "display: none;"; //$NON-NLS-1$
+ }
+ tbody.setAttribute(HTML.ATTR_STYLE, style);
+ VpeCreationData creationData = new VpeCreationData(tbody);
+ creationData = encodeSubTable(pageContext, creationData, sourceElement,
+ visualDocument, tbody);
+ return creationData;
+ }
+
+ public void toggle(Node sourceNode, String toggleId) {
+ /*
+ * Collapsed state will be changed.
+ * Then the whole template should be rebuilt to apply changes.
+ */
+ if (RichFaces.readCollapsedStateFromSourceNode(sourceNode)) {
+ sourceNode.setUserData(RichFaces.COLLAPSED_STATE, "false", null);
//$NON-NLS-1$
+ } else {
+ sourceNode.setUserData(RichFaces.COLLAPSED_STATE, "true", null);
//$NON-NLS-1$
+ }
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTogglerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTogglerTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesCollapsibleSubTableTogglerTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and 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.template.util.RichFaces;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class RichFacesCollapsibleSubTableTogglerTemplate extends
+ VpeAbstractTemplate implements VpeToggableTemplate {
+
+ @Override
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ nsIDOMElement topSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ topSpan.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, "1");
//$NON-NLS-1$
+
+ nsIDOMElement imgSpan = visualDocument.createElement(HTML.TAG_SPAN);
+ imgSpan.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT,
"true"); //$NON-NLS-1$
+ imgSpan.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, "2");
//$NON-NLS-1$
+
+ nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
+ img.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT, "true");
//$NON-NLS-1$
+ img.setAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, "3"); //$NON-NLS-1$
+
+ if (RichFaces.readCollapsedStateFromSourceNode(sourceNode)) {
+ ComponentUtil.setImg(img, "/collapsibleSubTableToggler/upIcon.gif");
//$NON-NLS-1$
+ } else {
+ ComponentUtil.setImg(img, "/collapsibleSubTableToggler/downIcon.gif");
//$NON-NLS-1$
+ }
+ imgSpan.appendChild(img);
+ topSpan.appendChild(imgSpan);
+
+ VpeCreationData creationData = new VpeCreationData(topSpan);
+ return creationData;
+ }
+
+ @Override
+ public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
+ String toggleId) {
+ Element csttgElement = (Element) sourceNode;
+ String forTable = ""; //$NON-NLS-1$
+ if (csttgElement.hasAttribute("for")) { //$NON-NLS-1$
+ forTable = csttgElement.getAttribute("for"); //$NON-NLS-1$
+ }
+ if (!"".equalsIgnoreCase(forTable)) { //$NON-NLS-1$
+ List<Element> sourceElements = RichFaces.findElementsById(
+ (Element) csttgElement.getOwnerDocument()
+ .getDocumentElement(), forTable, ":collapsibleSubTable"); //$NON-NLS-1$
+ for (Element el : sourceElements) {
+ if (builder != null) {
+ VpeElementMapping elementMapping =
(VpeElementMapping)builder.getDomMapping().getNodeMapping(el);
+ if (elementMapping != null) {
+ VpeTemplate template = elementMapping.getTemplate();
+ if (template instanceof RichFacesCollapsibleSubTableTemplate) {
+ ((RichFacesCollapsibleSubTableTemplate)template).toggle(el, toggleId);
+ if (RichFaces.readCollapsedStateFromSourceNode(sourceNode)) {
+ sourceNode.setUserData(RichFaces.COLLAPSED_STATE, "false", null);
//$NON-NLS-1$
+ } else {
+ sourceNode.setUserData(RichFaces.COLLAPSED_STATE, "true", null);
//$NON-NLS-1$
+ }
+ builder.updateNode(el);
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Update toggler state itself
+ */
+ builder.updateNode(sourceNode);
+ }
+
+ @Override
+ public void stopToggling(Node sourceNode) {
+ /*
+ * Do nothing
+ */
+ }
+
+ class CollapsedState {
+ /*
+ * This attribute should be synchronized with the same one
+ * in RichFacesCollapsibleSubTableTemplate
+ */
+ private boolean collapsed = false;
+
+ public CollapsedState() {
+ super();
+ }
+
+ public boolean isCollapsed() {
+ return collapsed;
+ }
+
+ public void setCollapsed(boolean collapsed) {
+ this.collapsed = collapsed;
+ }
+ }
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnGroupTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnGroupTemplate.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesColumnGroupTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -29,19 +29,17 @@
super();
}
- /** @see RichFacesSubTableTemplate#encode(VpePageContext, VpeCreationData, Element,
nsIDOMDocument, nsIDOMElement) */
+ /** @see RichFacesSubTableTemplate#encodeSubTable(VpePageContext, VpeCreationData,
Element, nsIDOMDocument, nsIDOMElement) */
@Override
- public VpeCreationData encode(VpePageContext pageContext,
+ public VpeCreationData encodeSubTable(VpePageContext pageContext,
VpeCreationData creationData, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement parentVisualNode) {
styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
- return super.encode(pageContext, creationData, sourceElement, visualDocument,
+ return super.encodeSubTable(pageContext, creationData, sourceElement, visualDocument,
parentVisualNode);
}
-
-
@Override
protected String getHeaderClass() {
return "dr-table-header rich-table-header"; //$NON-NLS-1$
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 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesDataTableTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -250,9 +250,9 @@
boolean isColumnGroup = facetBody.getNodeName().endsWith(RichFaces.TAG_COLUMN_GROUP);
boolean isSubTable = facetBody.getNodeName().endsWith(RichFaces.TAG_SUB_TABLE);
if(isColumnGroup) {
- RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
(Element)facetBody, visualDocument, parentTheadOrTfood);
+ RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext,
creationData, (Element)facetBody, visualDocument, parentTheadOrTfood);
} else if(isSubTable) {
- RichFacesSubTableTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
(Element)facetBody, visualDocument, parentTheadOrTfood);
+ RichFacesSubTableTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext, creationData,
(Element)facetBody, visualDocument, parentTheadOrTfood);
} else {
nsIDOMElement tr = visualDocument.createElement(HTML.TAG_TR);
parentTheadOrTfood.appendChild(tr);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesOrderingList.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -502,10 +502,10 @@
.endsWith(":columnGroup"); //$NON-NLS-1$
boolean isSubTable = facetBody.getNodeName().endsWith(":subTable");
//$NON-NLS-1$
if (isColumnGroup) {
- RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
+ RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext,
creationData,
facetBody, visualDocument, tbody);
} else if (isSubTable) {
- RichFacesSubTableTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
+ RichFacesSubTableTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext, creationData,
facetBody, visualDocument, tbody);
} else {
nsIDOMElement tr = visualDocument
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 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesScrollableDataTableTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -321,10 +321,10 @@
.endsWith(":columnGroup"); //$NON-NLS-1$
boolean isSubTable = facetBody.getNodeName().endsWith(":subTable");
//$NON-NLS-1$
if (isColumnGroup) {
- RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
+ RichFacesColumnGroupTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext,
creationData,
facetBody, visualDocument, parentTheadOrTfood);
} else if (isSubTable) {
- RichFacesSubTableTemplate.DEFAULT_INSTANCE.encode(pageContext, creationData,
+ RichFacesSubTableTemplate.DEFAULT_INSTANCE.encodeSubTable(pageContext, creationData,
facetBody, visualDocument, parentTheadOrTfood);
} else {
nsIDOMElement tr = 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 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSubTableTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -44,9 +44,10 @@
public RichFacesSubTableTemplate() {
super();
}
-
- public VpeCreationData encode(final VpePageContext pageContext, VpeCreationData
creationData, final Element sourceElement,
- final nsIDOMDocument visualDocument, nsIDOMElement parentVisualNode) {
+
+ public VpeCreationData encodeSubTable(final VpePageContext pageContext,
+ VpeCreationData creationData, final Element sourceElement,
+ final nsIDOMDocument visualDocument, nsIDOMElement parentVisualNode) {
if(creationData!=null) {
/*
* Encode header
@@ -191,7 +192,7 @@
final Element sourceElement = (Element)sourceNode;
final nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
VpeCreationData creationData = new VpeCreationData(tbody);
- creationData = encode(pageContext, creationData, sourceElement,
+ creationData = encodeSubTable(pageContext, creationData, sourceElement,
visualDocument, tbody);
return creationData;
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToggleControlTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToggleControlTemplate.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToggleControlTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -20,6 +20,7 @@
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
@@ -127,7 +128,9 @@
id = id.trim();
- List<Element> sourceElements = findElementsById
((Element)sourceElement.getOwnerDocument().getDocumentElement(), id);
+ List<Element> sourceElements = RichFaces.findElementsById(
+ (Element) sourceElement.getOwnerDocument()
+ .getDocumentElement(), id, ":togglePanel"); //$NON-NLS-1$
for (Element el : sourceElements) {
if (builder != null) {
@@ -144,27 +147,6 @@
}
}
- private List<Element> findElementsById (Element root, String id) {
- ArrayList<Element> list = new ArrayList<Element>();
- NodeList nodeList = root.getChildNodes();
- for(int i=0; i<nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
-
- if(child instanceof Element) {
- Element childElement = (Element)child;
-
- if (childElement.getNodeName().endsWith(":togglePanel") &&
//$NON-NLS-1$
- id.equals(childElement.getAttribute("id")) ) { //$NON-NLS-1$
- list.add(childElement);
- }
-
- list.addAll(findElementsById(childElement, id));
- }
- }
- return list;
- }
-
-
public void stopToggling(Node sourceNode) {
toggleMap.remove(sourceNode);
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTogglePanelTemplate.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -36,20 +36,13 @@
private static Map toggleMap = new HashMap();
private Map states = null;
-
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
-
Element sourceElement = (Element)sourceNode;
-
nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
-
VpeCreationData creationData = new VpeCreationData(div);
-
states = getStates(sourceElement);
-
String state = getActiveState(sourceElement);
-
Node bodyFacet = null;
if(state!=null) {
bodyFacet = ComponentUtil.getFacet(sourceElement, state, true);
@@ -75,7 +68,6 @@
for (int i = 0; children != null && i < children.getLength(); i++) {
Node child = children.item(i);
-
if (child instanceof Element &&
child.getNodeName().endsWith(":facet")) { //$NON-NLS-1$
Element facet = (Element)child;
if (facet.hasAttribute("name")) { //$NON-NLS-1$
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/util/RichFaces.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -11,9 +11,15 @@
package org.jboss.tools.jsf.vpe.richfaces.template.util;
+import java.util.ArrayList;
+import java.util.List;
+
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.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* contain rich faces tags and general attributes.
@@ -105,6 +111,8 @@
public static final String VALUE_BOTTOM = "bottom"; //$NON-NLS-1$
public static final String VALUE_CENTER = "center"; //$NON-NLS-1$
+ public static final String COLLAPSED_STATE = "collapsedState";
+
private static VpeExpression exprColumnClasses = null;
/**
* Returns the expression to extract style-classes from a {@code
'columnClasses'} attribute.
@@ -140,4 +148,30 @@
return exprRowClasses;
}
+
+ public static List<Element> findElementsById(Element root, String id, String
tagName) {
+ ArrayList<Element> list = new ArrayList<Element>();
+ NodeList nodeList = root.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ if (child instanceof Element) {
+ Element childElement = (Element) child;
+ if (childElement.getNodeName().endsWith(tagName)
+ && id.equals(childElement.getAttribute("id"))) { //$NON-NLS-1$
+ list.add(childElement);
+ }
+ list.addAll(findElementsById(childElement, id, tagName));
+ }
+ }
+ return list;
+ }
+
+ public static boolean readCollapsedStateFromSourceNode(Node sourceNode) {
+ boolean colapsed = false;
+ String collapsedState = (String) sourceNode.getUserData(COLLAPSED_STATE);
+ if ((collapsedState != null) &&
("true".equalsIgnoreCase(collapsedState))){ //$NON-NLS-1$
+ colapsed = true;
+ }
+ return colapsed;
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2011-06-03
10:35:24 UTC (rev 31804)
@@ -51,20 +51,6 @@
<vpe:template children="no" modify="no" />
</vpe:tag>
- <vpe:tag name="rich:comboBox" case-sensitive="yes">
- <vpe:template children="no" modify="no"
- class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesComboBoxTemplate">
- <vpe:resize>
- <vpe:width width-attr="width" />
- </vpe:resize>
- <vpe:dnd>
- <vpe:drag start-enable="yes" />
- <vpe:drop container="no">
- </vpe:drop>
- </vpe:dnd>
- </vpe:template>
- </vpe:tag>
-
<vpe:tag name="rich:calendar" case-sensitive="yes">
<vpe:template children="yes" modify="no"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesCalendarTemplate">
@@ -89,6 +75,20 @@
</vpe:template>
</vpe:tag>
+ <vpe:tag name="rich:comboBox" case-sensitive="yes">
+ <vpe:template children="no" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesComboBoxTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="width" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no">
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:component" case-sensitive="yes">
<vpe:template children="no" modify="no">
</vpe:template>
@@ -112,7 +112,19 @@
</vpe:dnd>
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="rich:collapsibleSubTable"
case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesCollapsibleSubTableTemplate">
+ </vpe:template>
+ </vpe:tag>
+ <vpe:tag name="rich:collapsibleSubTableToggler"
case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesCollapsibleSubTableTogglerTemplate">
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:colorPicker" case-sensitive="yes">
<vpe:template children="yes" modify="no"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesColorPickerTemplate">
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-06-03
10:21:44 UTC (rev 31803)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-06-03
10:35:24 UTC (rev 31804)
@@ -356,62 +356,59 @@
Node sourceNodeProxy = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.getInstance().isELNode(getPageContext(),
- sourceNode)) {
-
- sourceNodeProxy = VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
- sourceNode);
+ if (ElService.getInstance().isELNode(getPageContext(), sourceNode)) {
+ sourceNodeProxy = VpeProxyUtil.createProxyForELExpressionNode(
+ getPageContext(), sourceNode);
try {
- creationData = template.create(getPageContext(),
- sourceNodeProxy, getVisualDocument());
- //Fix for JBIDE-3144, we use proxy and some template can
- //try to cast for not supported interface
+ creationData = template.create(getPageContext(),
+ sourceNodeProxy, getVisualDocument());
+ //Fix for JBIDE-3144, we use proxy and some template can
+ //try to cast for not supported interface
} catch(ClassCastException ex) {
VpePlugin.reportProblem(ex);
sourceNodeProxy = null;
//then we create template without using proxy
- creationData = template.create(getPageContext(), sourceNode,
- getVisualDocument());
+ creationData = template.create(getPageContext(),
+ sourceNode, getVisualDocument());
}
-
} else {
creationData = template.create(getPageContext(), sourceNode,
getVisualDocument());
}
-
} catch (XPCOMException ex) {
VpePlugin.getPluginLog().logError(ex);
VpeTemplate defTemplate = getTemplateManager().getDefTemplate();
creationData = defTemplate.create(getPageContext(), sourceNode,
getVisualDocument());
}
-
+ if (creationData == null) {
+ VpePlugin.getDefault().logError(
+ "!ERROR! VpeCreationData is not initialized for source node '"
//$NON-NLS-1$
+ + sourceNode.getNodeName() + "'"); //$NON-NLS-1$
+ VpeTemplate defTemplate = getTemplateManager().getDefTemplate();
+ creationData = defTemplate.create(getPageContext(), sourceNode,
+ getVisualDocument());
+ }
getPageContext().setCurrentVisualNode(null);
-
+ /*
+ * JBDS crashes when 'creationData' is null
+ */
nsIDOMNode visualNewNode = creationData.getNode();
-
if (sourceNode.getNodeType() == Node.ELEMENT_NODE && visualNewNode == null
&& isShowInvisibleTags()) {
visualNewNode = createInvisbleElementLabel(sourceNode);
}
-
nsIDOMElement border = null;
-
if (visualNewNode != null
&& visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
-
nsIDOMElement visualNewElement = queryInterface(visualNewNode, nsIDOMElement.class);
-
if ((visualNewElement != null) && template.hasImaginaryBorder()) {
-
visualNewElement.setAttribute(HTML.ATTR_STYLE, visualNewElement
.getAttribute(HTML.ATTR_STYLE)
+ VpeStyleUtil.SEMICOLON_STRING + DOTTED_BORDER);
-
}
if (visualNewElement != null) {
correctVisualAttribute(visualNewElement);
}
-
/*
* Create border for unknown tags if specified.
* Update the style attribute. Usually it's DIV or SPAN with text,
@@ -433,20 +430,14 @@
if (sourceNode instanceof Element && visualNewNode != null
&& visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
-
setTooltip((Element) sourceNode, queryInterface(visualNewNode, nsIDOMElement.class));
}
if (registerFlag) {
-
final VpeElementData data = creationData.getElementData();
-
if ((sourceNodeProxy != null) && (data != null)
&& (data.getNodesData() != null)
&& (data.getNodesData().size() > 0)) {
-
- for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData : data
- .getNodesData()) {
-
+ for (org.jboss.tools.vpe.editor.mapping.NodeData nodeData : data.getNodesData()) {
if (nodeData.getSourceNode() != null) {
Node attr = null;
if(sourceNode.getAttributes()!=null) {
@@ -487,8 +478,6 @@
template.validate(getPageContext(), sourceNode, getVisualDocument(),
creationData);
getPageContext().setCurrentVisualNode(null);
-
-
if (border != null) {
return border;
} else {
@@ -497,11 +486,9 @@
}
protected void correctVisualAttribute(nsIDOMElement element) {
-
String styleValue = element.getAttribute(HTML.TAG_STYLE);
String backgroundValue = element
.getAttribute(VpeStyleUtil.PARAMETR_BACKGROND);
-
if (styleValue != null) {
styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
pageContext);
@@ -530,7 +517,6 @@
*/
protected void addChildren(VpeTemplate containerTemplate,
Node sourceContainer, nsIDOMNode visualContainer) {
-
NodeList sourceNodes = sourceContainer.getChildNodes();
int len = sourceNodes.getLength();
int childrenCount = 0;
@@ -542,7 +528,6 @@
childrenCount++;
}
}
-
if (childrenCount == 0) {
setPseudoContent(containerTemplate, sourceContainer,
visualContainer);
@@ -915,14 +900,9 @@
updateNode(sourceText);
return true;
}
-
- // }
- // updateNode(sourceText);
return false;
}
- // }
-
public void setAttribute(Element sourceElement, String name, String value) {
VpeElementMapping elementMapping = (VpeElementMapping) domMapping
.getNodeMapping(sourceElement);
@@ -972,7 +952,6 @@
return null;
}
String toggleId = toggleIdAttr.getNodeValue();
-
if (toggleId == null) {
return null;
}