Author: dmaliarevich
Date: 2009-03-26 11:52:50 -0400 (Thu, 26 Mar 2009)
New Revision: 14343
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForEachTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForTokensTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/util/JstlUtil.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/AbstractOutputJstlTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/templates/vpe-templates-jstl.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-3548, Templates for c:forEach and c:forTokes were
added.
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/AbstractOutputJstlTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/AbstractOutputJstlTemplate.java 2009-03-26
15:28:03 UTC (rev 14342)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/AbstractOutputJstlTemplate.java 2009-03-26
15:52:50 UTC (rev 14343)
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jsf.vpe.jstl.template;
-
-import org.jboss.tools.jsf.vpe.jsf.template.util.model.VpeElementProxyData;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-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.mozilla.interfaces.nsIDOMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public abstract class AbstractOutputJstlTemplate extends VpeAbstractTemplate {
-
- /**
- *
- * @param element
- * @return
- */
- public Attr getOutputAttributeNode(Element element) {
- if (element.hasAttribute(HTML.ATTR_VALUE)) {
- return element.getAttributeNode(HTML.ATTR_VALUE);
- }
-
- return null;
- }
-
- /**
- *
- * @param pageContext
- * @param visualDocument
- * @param sourceElement
- * @param targetVisualElement
- * @param creationData
- */
- protected void processOutputAttribute(VpePageContext pageContext,
- nsIDOMDocument visualDocument, Element sourceElement,
- nsIDOMElement targetVisualElement, VpeCreationData creationData) {
-
- VpeElementProxyData elementData = new VpeElementProxyData();
-
- Attr outputAttr = getOutputAttributeNode(sourceElement);
-
- if (outputAttr != null) {
-
- // prepare value
- String newValue = prepareAttrValue(pageContext, sourceElement, outputAttr);
- // if escape then contents of value (or other attribute) is only
- // text
-// if (!sourceElement.hasAttribute(JSF.ATTR_ESCAPE)
-// || "true".equalsIgnoreCase(sourceElement //$NON-NLS-1$
-// .getAttribute(JSF.ATTR_ESCAPE))) {
-//
-// String value = outputAttr.getValue();
-//
-// nsIDOMText text;
-// // if bundleValue differ from value then will be represent
-// // bundleValue, but text will be not edit
-// boolean isEditable = value.equals(newValue);
-//
-// text = visualDocument.createTextNode(newValue);
-// // add attribute for ability of editing
-//
-// elementData.addNodeData(new AttributeData(outputAttr, text,
-// isEditable));
-//
-// targetVisualElement.appendChild(text);
-//
-// }
- }
-
- creationData.setElementData(elementData);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#setPseudoContent
- * (org.jboss.tools.vpe.editor.context.VpePageContext, org.w3c.dom.Node,
- * org.mozilla.interfaces.nsIDOMNode, org.mozilla.interfaces.nsIDOMDocument)
- */
- @Override
- public void setPseudoContent(VpePageContext pageContext,
- Node sourceContainer, nsIDOMNode visualContainer,
- nsIDOMDocument visualDocument) {
- // Empty
- }
-
- @Override
- public NodeData getNodeData(nsIDOMNode node, VpeElementData elementData,
- VpeDomMapping domMapping) {
- // TODO Auto-generated method stub
- NodeData nodeData = super.getNodeData(node, elementData, domMapping);
- if (nodeData == null) {
-
- VpeNodeMapping nodeMapping = domMapping.getNodeMapping(node);
-
- if (nodeMapping != null) {
- if (nodeMapping instanceof VpeElementMapping) {
- nodeData = super.getNodeData(node,
- ((VpeElementMapping) nodeMapping).getElementData(),
- domMapping);
- }
-// else if (nodeMapping.getType() == VpeNodeMapping.TEXT_MAPPING) {
-// nodeData = new NodeData(nodeMapping.getSourceNode(), node,
-// true);
-// }
- }
- }
- return nodeData;
- }
-
- @Override
- public nsIDOMNode getVisualNodeByBySourcePosition(
- VpeElementMapping elementMapping, int focusPosition,
- int anchorPosition, VpeDomMapping domMapping) {
- nsIDOMNode node = null;
-
- if ((elementMapping.getElementData() instanceof VpeElementProxyData)
- && (((VpeElementProxyData) elementMapping.getElementData())
- .getNodelist() != null)) {
- VpeElementProxyData elementProxyData = (VpeElementProxyData)
elementMapping.getElementData();
-
-// VpeNodeMapping nodeMapping = NodeProxyUtil.findNodeByPosition(
-// domMapping, elementProxyData.getNodelist(), focusPosition,
-// anchorPosition);
-
-// if (nodeMapping != null) {
-//
-// if (nodeMapping instanceof VpeElementMapping) {
-// node = super.getVisualNodeByBySourcePosition(
-// (VpeElementMapping) nodeMapping, focusPosition,
-// anchorPosition, domMapping);
-// } else {
-// node = nodeMapping.getVisualNode();
-// }
-// }
- }
-
- if (node == null) {
- node = super.getVisualNodeByBySourcePosition(elementMapping,
- focusPosition, anchorPosition, domMapping);
- }
- return node;
- }
-
- protected String prepareAttrValue(VpePageContext pageContext, Element parent, Attr attr)
{
- return attr.getNodeValue();
- }
-}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForEachTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForEachTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForEachTemplate.java 2009-03-26
15:52:50 UTC (rev 14343)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.jstl.template;
+
+import java.util.List;
+
+import org.jboss.tools.jsf.vpe.jstl.template.util.JstlUtil;
+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.VisualDomUtil;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Class for c:forEach template
+ *
+ * @author dmaliarevich
+ *
+ */
+public class JstlForEachTemplate extends VpeAbstractTemplate {
+
+ private final int TIMES_TO_ITERATE = 3;
+
+ public JstlForEachTemplate() {
+ super();
+ }
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ Element sourceElement = (Element) sourceNode;
+ nsIDOMElement span = VisualDomUtil.createBorderlessContainer(visualDocument);
+ List<Node> children = JstlUtil.getChildren(sourceElement);
+ VpeCreationData creationData = new VpeCreationData(span);
+
+ VpeChildrenInfo spanInfo = new VpeChildrenInfo(span);
+ creationData.addChildrenInfo(spanInfo);
+ for(int i = 0; i < TIMES_TO_ITERATE; i++) {
+ for (Node child : children) {
+ spanInfo.addSourceChild(child);
+ }
+ }
+ return creationData;
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForEachTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForTokensTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForTokensTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForTokensTemplate.java 2009-03-26
15:52:50 UTC (rev 14343)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.jstl.template;
+
+import java.util.List;
+
+import org.jboss.tools.jsf.vpe.jstl.template.util.JstlUtil;
+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.VisualDomUtil;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Class for c:forTokens template
+ *
+ * @author dmaliarevich
+ *
+ */
+public class JstlForTokensTemplate extends VpeAbstractTemplate {
+
+ private final int TIMES_TO_ITERATE = 3;
+
+ public JstlForTokensTemplate() {
+ super();
+ }
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ Element sourceElement = (Element) sourceNode;
+ nsIDOMElement span = VisualDomUtil.createBorderlessContainer(visualDocument);
+ List<Node> children = JstlUtil.getChildren(sourceElement);
+ VpeCreationData creationData = new VpeCreationData(span);
+ VpeChildrenInfo spanInfo = new VpeChildrenInfo(span);
+ creationData.addChildrenInfo(spanInfo);
+ for(int i = 0; i < TIMES_TO_ITERATE; i++) {
+ for (Node child : children) {
+ spanInfo.addSourceChild(child);
+ }
+ }
+ return creationData;
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlForTokensTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/util/JstlUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/util/JstlUtil.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/util/JstlUtil.java 2009-03-26
15:52:50 UTC (rev 14343)
@@ -0,0 +1,36 @@
+package org.jboss.tools.jsf.vpe.jstl.template.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Class encapsulates JSTL utils.
+ *
+ * @author dmaliarevich
+ *
+ */
+public class JstlUtil {
+
+ /**
+ * Gets all children of the source element
+ * including text nodes.
+ *
+ * @param sourceElement
+ * the source element
+ *
+ * @return the children
+ */
+ public static List<Node> getChildren(Element sourceElement) {
+ ArrayList<Node> children = new ArrayList<Node>();
+ NodeList nodeList = sourceElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ children.add(child);
+ }
+ return children;
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/util/JstlUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/templates/vpe-templates-jstl.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/templates/vpe-templates-jstl.xml 2009-03-26
15:28:03 UTC (rev 14342)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/templates/vpe-templates-jstl.xml 2009-03-26
15:52:50 UTC (rev 14343)
@@ -42,14 +42,14 @@
</vpe:tag>
<vpe:tag name="c:forEach" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
- <div />
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.jstl.template.JstlForEachTemplate">
</vpe:template>
</vpe:tag>
<vpe:tag name="c:forTokens" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
- <div />
+ <vpe:template children="yes" modify="yes"
+
class="org.jboss.tools.jsf.vpe.jstl.template.JstlForTokensTemplate">
</vpe:template>
</vpe:tag>