Author: yradtsevich
Date: 2010-07-29 11:36:33 -0400 (Thu, 29 Jul 2010)
New Revision: 23799
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/SpringTemplatePlugin.java
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringFormSelectTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/Spring.java
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/VpeSpringUtil.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
Log:
https://jira.jboss.org/browse/JBIDE-6711
- form:select template is added
- plugin dependencies are updated
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.spring/META-INF/MANIFEST.MF 2010-07-29 15:17:26
UTC (rev 23798)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.spring/META-INF/MANIFEST.MF 2010-07-29 15:36:33
UTC (rev 23799)
@@ -3,9 +3,13 @@
Bundle-Name: %bundleName
Bundle-SymbolicName: org.jboss.tools.vpe.spring;singleton:=true
Bundle-Version: 3.1.0.qualifier
+Bundle-Activator: org.jboss.tools.vpe.spring.SpringTemplatePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.jboss.tools.vpe
+ org.jboss.tools.vpe,
+ org.mozilla.xpcom,
+ org.eclipse.jface.text,
+ org.jboss.tools.jst.jsp
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %vendorName
Bundle-Localization: plugin
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/SpringTemplatePlugin.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/SpringTemplatePlugin.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/SpringTemplatePlugin.java 2010-07-29
15:36:33 UTC (rev 23799)
@@ -0,0 +1,49 @@
+package org.jboss.tools.vpe.spring;
+
+import org.jboss.tools.common.log.BaseUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SpringTemplatePlugin extends BaseUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.jst.vpe.spring";
//$NON-NLS-1$
+
+ // The shared instance
+ private static SpringTemplatePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public SpringTemplatePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static SpringTemplatePlugin getDefault() {
+ return plugin;
+ }
+}
\ No newline at end of file
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringFormSelectTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringFormSelectTemplate.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/SpringFormSelectTemplate.java 2010-07-29
15:36:33 UTC (rev 23799)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.vpe.spring.template;
+
+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.util.HTML;
+import org.jboss.tools.vpe.spring.template.util.Spring;
+import org.jboss.tools.vpe.spring.template.util.VpeSpringUtil;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * VPE template for Spring form:select tag.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ * @see <a
href="http://static.springsource.org/spring/docs/3.0.x/spring-framew...
select tag</>
+ */
+public class SpringFormSelectTemplate extends VpeAbstractTemplate {
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ Element sourceElement = (Element) sourceNode;
+ nsIDOMElement select = visualDocument.createElement(HTML.TAG_SELECT);
+
+ VpeSpringUtil.copyCommonAttributes(sourceElement, select);
+ VpeSpringUtil.copyAttribute(sourceElement, HTML.ATTR_SIZE,
+ select, HTML.ATTR_SIZE);
+ VpeSpringUtil.copyAttribute(sourceElement, HTML.ATTR_MULTIPLE,
+ select, HTML.ATTR_MULTIPLE);
+
+ if (sourceElement.getAttribute(Spring.ATTR_DISABLED).equals(Spring.VALUE_TRUE)) {
+ select.setAttribute(HTML.ATTR_DISABLED, HTML.ATTR_DISABLED);
+ }
+
+ if (sourceElement.hasAttribute("items")) {
+ // an inner 'option' tag has to be generated
+ String optionBody = sourceElement.getAttribute("items");
+ if (sourceElement.hasAttribute("itemLabel")) {
+ optionBody += '.' + sourceElement.getAttribute("itemLabel");
+ }
+
+ nsIDOMElement option = visualDocument.createElement(HTML.TAG_OPTION);
+ select.appendChild(option);
+ }
+
+ return new VpeCreationData(select);
+ }
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/Spring.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/Spring.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/Spring.java 2010-07-29
15:36:33 UTC (rev 23799)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.vpe.spring.template.util;
+
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public class Spring {
+ public static String ATTR_CSS_CLASS = "cssClass"; //$NON-NLS-1$
+ public static String ATTR_CSS_STYLE = "cssStyle"; //$NON-NLS-1$
+ public static final String ATTR_DISABLED = "disabled"; //$NON-NLS-1$
+ public static String ATTR_ID = "id"; //$NON-NLS-1$
+
+ public static final String VALUE_TRUE = "true"; //$NON-NLS-1$
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/VpeSpringUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/VpeSpringUtil.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/src/org/jboss/tools/vpe/spring/template/util/VpeSpringUtil.java 2010-07-29
15:36:33 UTC (rev 23799)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2010 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.vpe.spring.template.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ *
+ */
+public class VpeSpringUtil {
+
+ public static final Map<String, String> COMMON_SPRING_FORM_ATTRIBUTES_MAP
+ = new HashMap<String, String>() {{
+ put(Spring.ATTR_ID, HTML.ATTR_ID);
+ put(Spring.ATTR_CSS_STYLE, HTML.ATTR_STYLE);
+ put(Spring.ATTR_CSS_CLASS, HTML.ATTR_CLASS);
+ }};
+
+ public static void copyAttribute(Element sourceElement, String sourceAttrName,
+ nsIDOMElement visualElement, String visualAttrName) {
+ if (sourceElement.hasAttribute(sourceAttrName)) {
+ String attrValue = sourceElement.getAttribute(sourceAttrName);
+ visualElement.setAttribute(visualAttrName, attrValue);
+ }
+ }
+
+ public static void copyAttributes(Element sourceElement,
+ nsIDOMElement visualElement, Map<String, String> sourceToVisualMap) {
+ for (Entry<String, String> sourceToVisual : sourceToVisualMap.entrySet()) {
+ String sourceAttrName = sourceToVisual.getKey();
+ String visualAttrName = sourceToVisual.getValue();
+ copyAttribute(sourceElement, sourceAttrName, visualElement, visualAttrName);
+ }
+ }
+
+ public static void copyCommonAttributes(Element sourceElement,
+ nsIDOMElement visualElement) {
+ copyAttributes(sourceElement, visualElement,
+ COMMON_SPRING_FORM_ATTRIBUTES_MAP);
+ }
+}
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
15:17:26 UTC (rev 23798)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-29
15:36:33 UTC (rev 23799)
@@ -123,4 +123,17 @@
</vpe:template>
</vpe:tag>
+ <vpe:tag name="form:select" case-sensetive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.vpe.spring.template.SpringFormSelectTemplate">
+ <vpe:resize>
+ <vpe:width width-attr="cssStyle.width" />
+ <vpe:height height-attr="cssStyle.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes"></vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
</vpe:templates>