Author: yradtsevich
Date: 2011-06-22 18:58:34 -0400 (Wed, 22 Jun 2011)
New Revision: 32298
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd
Log:
https://issues.jboss.org/browse/JBIDE-9202 : Possibility for creating templates for custom
libraries
[derived work on the Maxim Areshkau's patch]
- added matching-mode for the vpe:temlate-taglib tag
- changed JSF2 custom composite template declaration using matching-mode
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2011-06-22
22:46:50 UTC (rev 32297)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2011-06-22
22:58:34 UTC (rev 32298)
@@ -8,6 +8,15 @@
prefix="f" />
<vpe:template-taglib
uri="http://java.sun.com/jsf/composite"
prefix="composite" />
+
+ <vpe:template-taglib
uri="http://java\.sun\.com/jsf/composite/.+"
matching-mode="yes"
+ prefix="jsf2-custom-composite" />
+
+ <vpe:tag name="jsf2-custom-composite:.+" matching-mode="yes"
case-sensitive="yes">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.jsf.template.Jsf2CustomComponentTemplate">
+ </vpe:template>
+ </vpe:tag>
<vpe:tag name="f:loadBundle" case-sensitive="yes">
<vpe:template children="no" modify="no">
@@ -1188,11 +1197,6 @@
<!-- </vpe:if>-->
</vpe:tag>
- <vpe:tag name="vpejsf2customTemplate" case-sensitive="yes">
- <vpe:template children="yes" modify="yes"
- class="org.jboss.tools.jsf.vpe.jsf.template.Jsf2CustomComponentTemplate">
- </vpe:template>
- </vpe:tag>
<!-- Default template -->
<vpe:template children="yes" modify="no">
<vpe:any value="{name()}" title="{tagstring()}" />
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2011-06-22
22:46:50 UTC (rev 32297)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2011-06-22
22:58:34 UTC (rev 32298)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template;
+import java.io.Console;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -36,6 +37,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.custom.CustomTLDReference;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
+import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.SourceDomUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
@@ -247,6 +249,9 @@
//added by Denis Vinnichek, for tags which are defined with regexp
static final String ATTR_TAG_MATCHING_MODE = "matching-mode"; //$NON-NLS-1$
+
+ // for taglibs which are defined with regexp
+ static final String ATTR_TEMPLATE_TAGLIB_MATCHING_MODE = ATTR_TAG_MATCHING_MODE;
private static VpeTemplateManager instance = null;
private static Object monitor = new Object();
@@ -255,6 +260,7 @@
* Contains Mapping from URI and namespace
*/
private Map<String,String> templateTaglibs = new HashMap<String,String>();
+ private Map<String,String> matchingTemplateTaglibs = new
HashMap<String,String>();
private Map<String,VpeTemplateSet> caseSensitiveTags = new
HashMap<String,VpeTemplateSet>();
private Map<String,VpeTemplateSet> ignoreSensitiveTags = new
HashMap<String,VpeTemplateSet>();
@@ -280,8 +286,6 @@
//mareshkau, contains a name of custom template
private static final String CUSTOM_TEMPLATE_NAME="vpeCustomTemplate";
//$NON-NLS-1$
- private static final String JSF2_CUSTOM_TEMPLATE="vpejsf2customTemplate";
//$NON-NLS-1$
-
/**
* added by Max Areshkau, JBIDE-1494
* Contains default text formating data
@@ -439,10 +443,7 @@
&& CustomTLDReference.isExistInCustomTlds(pageContext,sourceNodeUri)) {
return VpeTemplateManager.CUSTOM_TEMPLATE_NAME;
}
- if(sourceNodeUri!=null
- &&CustomTLDReference.isExistInJsf2CustomComponenets(pageContext,sourceNodeUri,sourceNode.getLocalName())
) {
- return VpeTemplateManager.JSF2_CUSTOM_TEMPLATE;
- }
+
return sourceNode.getNodeName();
default :
return null;
@@ -451,7 +452,16 @@
}
public String getTemplateTaglibPrefix(String sourceUri) {
- return (String)templateTaglibs.get(sourceUri);
+ String result = templateTaglibs.get(sourceUri);
+ if(result == null){
+ for ( Map.Entry<String, String> entry: matchingTemplateTaglibs.entrySet()) {
+ if(sourceUri.matches( entry.getKey() )){
+ result = entry.getValue();
+ break;
+ }
+ }
+ }
+ return result;
}
private void load() {
@@ -504,7 +514,8 @@
} else if (TAG_TEMPLATE.equals(node.getNodeName())) {
setDefTemplate(createTemplate((Element)node,confElement, true));
} else if (TAG_TEMPLATE_TAGLIB.equals(node.getNodeName())) {
- setTemplateTaglib((Element)node);
+ boolean templateTaglibMatchingMode = Constants.YES_STRING.equals(( (Element)
node).getAttribute(VpeTemplateManager.ATTR_TEMPLATE_TAGLIB_MATCHING_MODE));
+ setTemplateTaglib((Element) node, templateTaglibMatchingMode);
}
}
}
@@ -579,12 +590,16 @@
* Register templates taglibs from templates files
* @param templateTaglibElement
*/
- private void setTemplateTaglib(Element templateTaglibElement) {
+ private void setTemplateTaglib(Element templateTaglibElement, boolean
templateTaglibMatchingMode) {
String uri = templateTaglibElement.getAttribute(ATTR_DIRECTIVE_TAGLIB_URI);
String pefix = templateTaglibElement.getAttribute(ATTR_DIRECTIVE_TAGLIB_PREFIX);
if (uri.length() > 0 && pefix.length() > 0) {
if (!templateTaglibs.containsKey(uri)) {
- templateTaglibs.put(uri, pefix);
+ if (templateTaglibMatchingMode) {
+ matchingTemplateTaglibs.put(uri, pefix);
+ } else {
+ templateTaglibs.put(uri, pefix);
+ }
}
}
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd 2011-06-22 22:46:50 UTC
(rev 32297)
+++ trunk/vpe/tests/org.jboss.tools.vpe.test/scheme/scheme.xsd 2011-06-22 22:58:34 UTC
(rev 32298)
@@ -119,6 +119,7 @@
<xsd:complexType name="TEMPLATE-TAGLIB">
<xsd:attribute name="prefix" use="required"
type="xsd:NCName"/>
<xsd:attribute name="uri" use="required"
type="xsd:anyURI"/>
+ <xsd:attribute name="matching-mode" use="optional"
type="vpe:VPE-BOOLEAN"/>
</xsd:complexType>
<!-- -->
<xsd:complexType name="RESIZE">
@@ -353,6 +354,9 @@
<xsd:attribute name="disabled" type="xsd:string"
use="optional"/>
<xsd:attribute name="id" type="xsd:string"
use="optional"/>
<xsd:attribute name="name" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="height" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="width" type="xsd:string"
use="optional"/>
+ <xsd:attribute name="placeholder" type="xsd:string"
use="optional"/>
</xsd:complexType>
<!-- -->
<xsd:complexType name="HTML_DIV" mixed="true">
@@ -418,7 +422,7 @@
<xsd:attribute name="value" type="xsd:string"
use="optional"/>
</xsd:complexType>
<!-- -->
- <xsd:complexType name="HTML_OPTION">
+ <xsd:complexType name="HTML_OPTION" mixed="true">
<xsd:sequence>
<xsd:element name="value" minOccurs="0"
type="vpe:VALUE" />
</xsd:sequence>