[jbosstools-commits] JBoss Tools SVN: r23802 - in trunk/vpe/plugins/org.jboss.tools.vpe.spring: templates and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jul 29 12:17:02 EDT 2010


Author: dmaliarevich
Date: 2010-07-29 12:17:01 -0400 (Thu, 29 Jul 2010)
New Revision: 23802

Added:
   trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringTextAreaTemplate.java
Modified:
   trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
Log:
https://jira.jboss.org/browse/JBIDE-6711 , form:textarea template was added.

Added: trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringTextAreaTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringTextAreaTemplate.java	                        (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringTextAreaTemplate.java	2010-07-29 16:17:01 UTC (rev 23802)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.vpe.spring.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+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.spring.template.util.Spring;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Class for <form:textarea> 
+ *  
+ * @author dmaliarevich
+ */
+public class SpringTextAreaTemplate extends VpeAbstractTemplate {
+
+	public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+			nsIDOMDocument visualDocument) {
+		final nsIDOMElement textarea = visualDocument.createElement(HTML.TAG_TEXTAREA);
+		VisualDomUtil.copyAttributes(sourceNode, textarea);
+		Element sourceElement = (Element) sourceNode;
+		/*
+		 * Attributes "class" and "style" should correspond to the
+		 * Spring's "cssClass" and "cssStyle"
+		 */
+		textarea.setAttribute(
+				HTML.ATTR_CLASS,
+				(sourceElement.hasAttribute(Spring.ATTR_CSS_CLASS) 
+						? sourceElement.getAttribute(Spring.ATTR_CSS_CLASS) 
+						: Constants.EMPTY));
+		textarea.setAttribute(
+				HTML.ATTR_STYLE,
+				(sourceElement.hasAttribute(Spring.ATTR_CSS_STYLE) 
+						? sourceElement.getAttribute(Spring.ATTR_CSS_STYLE) 
+						: Constants.EMPTY));
+		
+		/*
+		 * Add text children to the text area
+		 */
+		final NodeList childNodes = sourceNode.getChildNodes();
+		final int childNodesLength = childNodes.getLength();
+		for (int i = 0; i < childNodesLength; i++) {
+			final Node child = childNodes.item(i);
+			if (child.getNodeType() == Node.TEXT_NODE) {
+				final nsIDOMNode text = visualDocument.createTextNode(child.getNodeValue());
+				textarea.appendChild(text);
+			}
+		}
+		
+		final VpeCreationData creationData = new VpeCreationData(textarea);
+
+		final VpeElementData textElementsData = new VpeElementData();
+		textElementsData.addNodeData(new NodeData(sourceNode.getLastChild(), textarea));
+		creationData.setElementData(textElementsData);
+
+		return creationData;
+	}
+
+}

Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml	2010-07-29 16:06:19 UTC (rev 23801)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml	2010-07-29 16:17:01 UTC (rev 23802)
@@ -106,7 +106,7 @@
 		<vpe:template children="no" modify="no">
 			<input type="text" id="{@id}" class="{@cssClass}" 
 				style="{@cssStyle}" size="{@size}" dir="{@dir}"
-				disabled="{@disabled}"  />
+				disabled="{@disabled}" />
 		</vpe:template>
 	</vpe:tag>
 	
@@ -115,6 +115,11 @@
 			<label id="{@id}" class="{@cssClass}" style="{@cssStyle}"
 				 for="{@for}" dir="{@dir}">
 			</label>
+			<vpe:dnd>
+				<vpe:drag start-enable="yes" />
+			</vpe:dnd>
+			<vpe:textFormatting use-default-formats="yes">
+			</vpe:textFormatting>
 		</vpe:template>
 	</vpe:tag>
 	
@@ -136,6 +141,7 @@
 			</vpe:dnd>
 		</vpe:template>
 	</vpe:tag>
+	
 		<vpe:tag name="form:option" case-sensitive="yes">
 		<vpe:if test="@disabled='true'">
 			<vpe:template children="yes" modify="yes">
@@ -152,4 +158,15 @@
 				</option>
 		</vpe:template>
 	</vpe:tag>
+
+	<vpe:tag name="form:textarea" case-sensitive="no">
+		 <vpe:template children="yes" modify="yes" 
+		 	class="org.jboss.tools.vpe.spring.template.SpringTextAreaTemplate">
+		 	<vpe:resize>
+				<vpe:width width-attr="cssStyle.width" />
+				<vpe:height height-attr="cssStyle.height" />
+			</vpe:resize>
+		</vpe:template>
+	</vpe:tag>	 
+	
 </vpe:templates>



More information about the jbosstools-commits mailing list