Author: mareshkau
Date: 2009-10-30 13:07:47 -0400 (Fri, 30 Oct 2009)
New Revision: 18373
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/JSF.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/WEB-INF/lib/jbide2550.jar
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/resources/ezcomp/loginPanel.xhtml
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/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5100
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JSF2CompositeAttributeTemplate.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.jsf.template;
+
+import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
+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.mozilla.interfaces.nsIDOMDocument;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Template for composite:attribute tag
+ *
+ * @author mareshkau
+ *
+ */
+public class JSF2CompositeAttributeTemplate extends VpeAbstractTemplate{
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ Element sourceElement = (Element) sourceNode;
+ String name = sourceElement.getAttribute(JSF.ATTR_NAME);
+ String defaultValue = sourceElement.getAttribute(JSF.ATTR_DEFAULT);
+ //we should register attributes only if we process this as custom component, but not
when we open component definition page
+ if(!pageContext.getVisualBuilder().isCurrentMainDocument()){
+ String compositionCustomElementAttributeKey =
Jsf2CustomComponentTemplate.JSF2_CUSTOM_COMPONENT_PARAMETR_KEY +name;
+ if(pageContext.getCustomElementsAttributes().containsKey(compositionCustomElementAttributeKey)){
+ pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name,
+ pageContext.getCustomElementsAttributes().get(compositionCustomElementAttributeKey));
+ }else if(defaultValue!=null) {
+ pageContext.addAttributeInCustomElementsMap(JSF.CUSTOM_COMPONENT_ATTR_PREFIX+name,
defaultValue);
+ }
+ }
+ //it's invisible component
+ return new VpeCreationData(null);
+ }
+
+
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/Jsf2CustomComponentTemplate.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -18,6 +18,8 @@
import org.jboss.tools.vpe.editor.template.VpeCustomTemplate;
import org.jboss.tools.vpe.editor.template.custom.CustomTLDReference;
import org.jboss.tools.vpe.editor.util.XmlUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
@@ -28,6 +30,8 @@
*/
public class Jsf2CustomComponentTemplate extends VpeCustomTemplate{
+ public static final String JSF2_CUSTOM_COMPONENT_PARAMETR_KEY =
"vpe_jsf2_custom_param_"; //$NON-NLS-1$
+
@Override
protected IStorage getCustomTemplateStorage(VpePageContext pageContext, Node
sourceNode){
String sourcePrefix = sourceNode.getPrefix();
@@ -40,8 +44,26 @@
return null;
}
- String sourceNodeUri = sourceNodeTaglib.getUri();
-
+ String sourceNodeUri = sourceNodeTaglib.getUri();
return CustomTLDReference.getJsf2CustomComponentStorage(pageContext, sourceNodeUri,
sourceNode.getLocalName());
}
+ /**
+ * Temparary add to attribute for custom el expressions
+ * @author mareshkau
+ *
+ * @param pageContext Page Context
+ * @param sourceNode source Node
+ * @param processedFile processed File
+ * @return resourceReferences - unchanged resource references
+ */
+ @Override
+ protected void addAttributesToELExcpressions(
+ final Node sourceNode, final VpePageContext vpePageContext){
+ NamedNodeMap attributesMap = sourceNode.getAttributes();
+
+ for(int i=0;i<attributesMap.getLength();i++) {
+ Attr attr = (Attr) attributesMap.item(i);
+ vpePageContext.addAttributeInCustomElementsMap(Jsf2CustomComponentTemplate.JSF2_CUSTOM_COMPONENT_PARAMETR_KEY+attr.getName(),
attr.getValue());
+ }
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/JSF.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/JSF.java 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/JSF.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -62,5 +62,10 @@
public static final String ATTR_TITLE = "title"; //$NON-NLS-1$
public static final String ATTR_LANG = "lang"; //$NON-NLS-1$
-
+
+ public static final String ATTR_NAME = "name"; //$NON-NLS-1$
+
+ public static final String ATTR_DEFAULT = "default"; //$NON-NLS-1$
+
+ public static final String CUSTOM_COMPONENT_ATTR_PREFIX="cc.attrs.";
//$NON-NLS-1$
}
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 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2009-10-30
17:07:47 UTC (rev 18373)
@@ -929,6 +929,12 @@
<vpe:template children="yes" modify="no"/>
</vpe:if>
</vpe:tag>
+
+ <vpe:tag name="composite:attribute" case-sensitive="yes">
+ <vpe:if test="tld_version('min=2.0')">
+ <vpe:template children="no" modify="no"
class="org.jboss.tools.jsf.vpe.jsf.template.JSF2CompositeAttributeTemplate"
/>
+ </vpe:if>
+ </vpe:tag>
<vpe:tag name="composite:actionSource" case-sensitive="yes">
<vpe:if test="tld_version('min=2.0')">
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/WEB-INF/lib/jbide2550.jar
===================================================================
(Binary files differ)
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml 2009-10-30
17:07:47 UTC (rev 18373)
@@ -11,7 +11,7 @@
<h:body>
<h:form id="jbide5015">
<jar:echo echo="Hello, Custom Jsf 2.O Components" />
- <ez:loginPanel id="loginPanel">
+ <ez:loginPanel id="loginPanel" login="LOgin">
<f:actionListener for="loginEvent"
binding="#{bean.loginEventListener}" />
</ez:loginPanel>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5015/login.xhtml.xml 2009-10-30
17:07:47 UTC (rev 18373)
@@ -1,15 +1,14 @@
<tests>
<test id="jbide5015">
-<FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;" >
-<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;" >
+<FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;">
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
<DIV STYLE="-moz-user-modify: read-only;">
<DIV STYLE="display: none; -moz-user-modify: read-only;">
<H1 STYLE="-moz-user-modify: read-only;">
Not present in rendered output
</H1>
</DIV>
-<DIV STYLE="-moz-user-modify: read-only;"><BR
VPE:PSEUDO-ELEMENT="yes" STYLE="font-style: italic; color: green;
-moz-user-modify: read-only;"/>
-
+<DIV STYLE="-moz-user-modify: read-only;">
<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
<H1 STYLE="-moz-user-modify: read-only;">
<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
@@ -20,7 +19,7 @@
</DIV>
</DIV>
</DIV>
-<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;" >
<DIV STYLE="-moz-user-modify: read-only;">
<DIV STYLE="display: none; -moz-user-modify: read-only;">
<H1 STYLE="-moz-user-modify: read-only;">
@@ -31,20 +30,20 @@
<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
<P STYLE="-moz-user-modify: read-only;">
<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
-Username:
+User Name
</SPAN>
<INPUT STYLE="-moz-user-modify: read-only;"/>
</P>
<P STYLE="-moz-user-modify: read-only;">
<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
-Password:
+#{cc.attrs.password}
</SPAN>
<INPUT TYPE="password" STYLE="-moz-user-modify: read-only;"/>
</P>
<P STYLE="-moz-user-modify: read-only;">
-<INPUT TYPE="button" VALUE="login" STYLE="-moz-user-modify:
read-only;"/>
+<INPUT TYPE="button" VALUE="LOgin" STYLE="-moz-user-modify:
read-only;"/>
</P>
</DIV>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/resources/ezcomp/loginPanel.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/resources/ezcomp/loginPanel.xhtml 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/resources/ezcomp/loginPanel.xhtml 2009-10-30
17:07:47 UTC (rev 18373)
@@ -11,11 +11,14 @@
<body>
<composite:interface>
<composite:actionSource name="loginEvent" />
+ <composite:attribute name ="login" default="login"/>
+ <composite:attribute name="username" default = "User Name"/>
+ <composite:attribute name="password"/>
</composite:interface>
<composite:implementation>
- <p>Username: <h:inputText id="usernameInput" /></p>
- <p>Password: <h:inputSecret id="passwordInput" /></p>
- <p><h:commandButton id="loginEvent" value="login"
/></p>
+ <p><h:outputText value="#{cc.attrs.username}" /> <h:inputText
id="usernameInput" /></p>
+ <p><h:outputText value="#{cc.attrs.password}" /> <h:inputSecret
id="passwordInput" /></p>
+ <p><h:commandButton value="#{cc.attrs.login}"
id="loginEvent"/></p>
</composite:implementation>
</body>
-</html>
\ No newline at end of file
+</html>
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 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -2150,7 +2150,7 @@
return false;
}
- protected boolean isCurrentMainDocument() {
+ public boolean isCurrentMainDocument() {
return includeStack.size() <= 1;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -88,8 +88,8 @@
* Removes attribute from custom attribute map
* @param sourceBuilder
*/
- public void removeAttributeFromCustomElementMap(String key) {
- getCustomElementsAttributes().remove(key);
+ public void clearCustomElementAttributesMap() {
+ getCustomElementsAttributes().clear();
}
public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-10-30
16:56:56 UTC (rev 18372)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-10-30
17:07:47 UTC (rev 18373)
@@ -95,7 +95,7 @@
VpeCreationData creationData = createInclude(
document, visualDocument);
- VpeCustomTemplate.addAttributesToELExcpressions(
+ addAttributesToELExcpressions(
sourceNode, pageContext);
creationData.setData(storage);
pageContext.getVisualBuilder().pushIncludeStack(
@@ -107,22 +107,22 @@
@Override
public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data){
- NamedNodeMap attributesMap = sourceNode.getAttributes();
- for(int i=0;i<attributesMap.getLength();i++) {
- Attr attr = (Attr) attributesMap.item(i);
- pageContext.removeAttributeFromCustomElementMap(attr.getName());
- }
+
+ pageContext.clearCustomElementAttributesMap();
+
super.validate(pageContext, sourceNode, visualDocument, data);
}
/**
* Temparary add to attribute for custom el expressions
+ * @author mareshkau
+ *
* @param pageContext Page Context
* @param sourceNode source Node
* @param processedFile processed File
* @return resourceReferences - unchanged resource references
*/
- private static final void addAttributesToELExcpressions(
+ protected void addAttributesToELExcpressions(
final Node sourceNode, final VpePageContext vpePageContext){
NamedNodeMap attributesMap = sourceNode.getAttributes();