Author: dvinnichek
Date: 2010-11-02 07:06:56 -0400 (Tue, 02 Nov 2010)
New Revision: 26182
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSelectTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml.xml
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
Log:
added template for <rich:select> element (
https://jira.jboss.org/browse/JBIDE-7448)
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java 2010-11-02
11:06:24 UTC (rev 26181)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAutocompleteTemplate.java 2010-11-02
11:06:56 UTC (rev 26182)
@@ -38,9 +38,8 @@
readAttributes(pageContext, sourceNode);
nsIDOMElement wrapper = visualDocument.createElement(HTML.TAG_SPAN);
- nsIDOMElement element = showButton ? visualDocument
- .createElement(HTML.TAG_SELECT) : visualDocument
- .createElement(HTML.TAG_INPUT);
+ String elementName = showButton ? HTML.TAG_SELECT : HTML.TAG_INPUT;
+ nsIDOMElement element = visualDocument.createElement(elementName);
if (disabled) {
element.setAttribute(RichFaces.ATTR_DISABLED,
RichFaces.ATTR_DISABLED);
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSelectTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSelectTemplate.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSelectTemplate.java 2010-11-02
11:06:56 UTC (rev 26182)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Template for the <rich:select> component.
+ *
+ * @author dvinnichek
+ */
+public class RichFacesSelectTemplate extends AbstractEditableRichFacesTemplate {
+
+ private String defaultLabel;
+ private boolean showButton;
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ readAttributes(pageContext, sourceNode);
+
+ nsIDOMElement wrapper = visualDocument.createElement(HTML.TAG_SPAN);
+ String elementName = showButton ? HTML.TAG_SELECT : HTML.TAG_INPUT;
+ nsIDOMElement element = visualDocument.createElement(elementName);
+ if (defaultLabel != null) {
+ if (HTML.TAG_INPUT.equals(elementName)) {
+ element.setAttribute(RichFaces.ATTR_VALUE, defaultLabel);
+ }
+ if (HTML.TAG_SELECT.equals(elementName)) {
+ nsIDOMElement option = visualDocument.createElement(HTML.TAG_OPTION);
+ nsIDOMText text = visualDocument.createTextNode(defaultLabel);
+ option.appendChild(text);
+ element.appendChild(option);
+ }
+ }
+ wrapper.appendChild(element);
+ VpeCreationData creationData = new VpeCreationData(wrapper);
+
+ return creationData;
+ }
+
+ /**
+ * Read attributes from the source element.
+ *
+ * @param sourceNode
+ * the source node
+ */
+ private void readAttributes(VpePageContext pageContext, Node sourceNode) {
+
+ Element sourceElement = (Element) sourceNode;
+
+ // defaultLabel
+ defaultLabel = sourceElement.hasAttribute(RichFaces.ATTR_DEFAULT_LABEL) ?
sourceElement
+ .getAttribute(RichFaces.ATTR_DEFAULT_LABEL) : null;
+
+ // showButton
+ showButton = sourceElement.hasAttribute(RichFaces.ATTR_SHOW_BUTTON) ? Constants.TRUE
+ .equalsIgnoreCase(sourceElement
+ .getAttribute(RichFaces.ATTR_SHOW_BUTTON)) : true;
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesSelectTemplate.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.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-02
11:06:24 UTC (rev 26181)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2010-11-02
11:06:56 UTC (rev 26182)
@@ -795,5 +795,14 @@
</vpe:dnd>
</vpe:template>
</vpe:tag>
+ <vpe:tag name="rich:select" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesSelectTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="no" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
</vpe:templates>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml.xml 2010-11-02
11:06:56 UTC (rev 26182)
@@ -0,0 +1,22 @@
+<tests>
+ <test id="select1">
+ <SPAN>
+ <SELECT>
+ </SELECT>
+ </SPAN>
+ </test>
+ <test id="select2">
+ <SPAN>
+ <SELECT>
+ <OPTION>
+ start typing for select
+ </OPTION>
+ </SELECT>
+ </SPAN>
+ </test>
+ <test id="select3">
+ <SPAN>
+ <INPUT VALUE="please select" />
+ </SPAN>
+ </test>
+</tests>
\ No newline at end of file
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/select.xhtml.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-02
11:06:24 UTC (rev 26181)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/RichFacesComponentContentTest.java 2010-11-02
11:06:56 UTC (rev 26182)
@@ -376,6 +376,10 @@
performContentTest("components/autocomplete.xhtml");//$NON-NLS-1$
}
+ public void testSelect() throws Throwable {
+ performContentTest("components/select.xhtml");//$NON-NLS-1$
+ }
+
@Override
protected String getTestProjectName() {
return RichFacesAllTests.IMPORT_PROJECT_NAME;