Author: mareshkau
Date: 2008-11-05 12:20:00 -0500 (Wed, 05 Nov 2008)
New Revision: 11530
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/inputNumberSpinner/inputNumberSpinner.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml.xml
Log:
JBIDE-2913 fix from izhukov
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/inputNumberSpinner/inputNumberSpinner.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/inputNumberSpinner/inputNumberSpinner.css 2008-11-05
17:04:43 UTC (rev 11529)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/inputNumberSpinner/inputNumberSpinner.css 2008-11-05
17:20:00 UTC (rev 11530)
@@ -1,47 +1,38 @@
-.ins-input {
- border: 1px;
- padding: 0px 0px 0px 3px;
- background: none transparent scroll repeat 0% 0%;
- margin-top: 1px;
- font-family: Arial, Verdana, sans-serif;
- font-size: 11px;
- line-height: 14px;
- height: 14px;
-
-
+.dr-spnr-i {
+ border: 0 none;
+ padding: 0px 0px 0px 3px;
+ background: transparent none repeat scroll 0 0;
+ margin: 0px;
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 11px;
}
-.ins-dr-spnr-e{
- background-color : #ffffff;
- padding: 0px;
- margin: 0px;
- background-position: left top;
- background-repeat: repeat-x;
- border-left: #000000 1px solid;
- border-top: #000000 1px solid;
- border-bottom: #b0b0b0 1px solid;
- border-right: #b0b0b0 1px solid;
+.dr-spnr-e {
+ background-color: #ffffff;
+ padding: 0px;
+ margin: 0px;
+ background-position: left top;
+ background-repeat: repeat-x;
+ border-color: #D4CFC7;
+ border-width: 1px 0 1px 1px;
+ border-style: inset;
}
.dr-spnr-bn {
- border: 0px;
- margin-top: 0px;
- margin-bottom: 0px;
- margin-right-value: 0px;
- margin-left-value: 0px;
-
+ border-style: none;
+ display: block;
+ margin: 0 1px 1px 0;
}
.dr-spnr-b {
- width: 14px;
- border: 1px;
- background-image: url(background-arrows.jpg);
- border-style: solid;
- padding: 0px;
- margin: 0px;
- background-position: left top;
- background-repeat: repeat-x;
- font-size: 0px;
- background-color:#D4CFC7;
- border-color:#D4CFC7;
-}
+ background-image: url(background-arrows.jpg);
+ background-color: #D4CFC7;
+ border-color: #D4CFC7;
+ border-style: solid;
+ padding: 0px;
+ margin: 0px;
+ background-position: left top;
+ background-repeat: repeat-x;
+ font-size: 0px;
+ border-width: 1px;
+}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-11-05
17:04:43 UTC (rev 11529)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSpinnerTemplate.java 2008-11-05
17:20:00 UTC (rev 11530)
@@ -1,308 +1,329 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.jsf.vpe.richfaces.template;
-
-import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
-import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.AttributeData;
-import org.jboss.tools.vpe.editor.mapping.NodeData;
-import org.jboss.tools.vpe.editor.mapping.VpeElementData;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Template for input number spinner control
- */
-public class RichFacesInputNumberSpinnerTemplate extends
-/* AbstractRichFacesInputNumberTemplate */AbstractEditableRichFacesTemplate {
-
- /** CSS_FILE_NAME */
- final static private String CSS_FILE_NAME =
"inputNumberSpinner/inputNumberSpinner.css"; //$NON-NLS-1$
-
- /** IMAGE_NAME_UP */
- final static private String IMAGE_NAME_UP = "/inputNumberSpinner/up.gif";
//$NON-NLS-1$
-
- /** IMAGE_NAME_DOWN */
- final static private String IMAGE_NAME_DOWN = "/inputNumberSpinner/down.gif";
//$NON-NLS-1$
-
- /** DEFAULT_INPUT_SIZE */
- final static private String DEFAULT_INPUT_SIZE = "10"; //$NON-NLS-1$
-
- /** DEFAULT_INPUT_STYLE */
- final static private String DEFAULT_INPUT_STYLE = "ins-input"; //$NON-NLS-1$
-
- final static private String ZERO_STRING = "0"; //$NON-NLS-1$
-
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
-
- // Set a css for this element
- ComponentUtil.setCSSLink(pageContext, CSS_FILE_NAME,
- "richFacesInputNumberSpinner"); //$NON-NLS-1$
-
- Element sourceElement = (Element) sourceNode;
-
- nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
- table.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- table.setAttribute(HTML.ATTR_CELLPADDING, ZERO_STRING);
- table.setAttribute(HTML.ATTR_CELLSPACING, ZERO_STRING);
-
- VpeElementData elementData = new VpeElementData();
-
- nsIDOMElement row = visualDocument
- .createElement(HTML.TAG_TR);
-
- // create input element
- nsIDOMElement cellInput = visualDocument.createElement(HTML.TAG_TD);
- cellInput.setAttribute(HTML.ATTR_CLASS, "ins-dr-spnr-e"); //$NON-NLS-1$
- cellInput.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_ALIGN_TOP);
- cellInput.appendChild(createInputElement(visualDocument, sourceElement,
- elementData));
- row.appendChild(cellInput);
-
- // create arrows cell
- nsIDOMElement cellArrows = visualDocument.createElement(HTML.TAG_TD);
- cellArrows.setAttribute(HTML.ATTR_CLASS, "dr-spnr-b"); //$NON-NLS-1$
- cellArrows.setAttribute(HTML.ATTR_VALIGN, HTML.VALUE_ALIGN_MIDDLE);
- cellArrows.appendChild(createArrowsElement(visualDocument, sourceNode));
- row.appendChild(cellArrows);
-
- table.appendChild(row);
-
- String tmp = getAttribute(sourceElement, RichFaces.ATTR_STYLE);
- table.setAttribute(HTML.ATTR_STYLE, tmp);
-
- // Create return variable contain template
- VpeCreationData creationData = new VpeCreationData(table);
-
- creationData.setElementData(elementData);
-
- return creationData;
- }
-
- /**
- * Create a HTML-part containg arrows elements
- *
- * @param visualDocument
- * The current node of the source tree.
- * @param sourceNode
- * The document of the visual tree.
- * @return a HTML-part containg arrows elements
- */
- private nsIDOMElement createArrowsElement(nsIDOMDocument visualDocument,
- Node sourceNode) {
- nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
-
- table.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- table.setAttribute(HTML.ATTR_CELLPADDING, ZERO_STRING);
- table.setAttribute(HTML.ATTR_CELLSPACING, ZERO_STRING);
-
- nsIDOMElement rowUp = visualDocument.createElement(HTML.TAG_TR);
- nsIDOMElement cellUp = visualDocument.createElement(HTML.TAG_TD);
-
- nsIDOMElement imageUpElement = visualDocument
- .createElement(HTML.TAG_INPUT);
-
- ComponentUtil.setImg(imageUpElement, IMAGE_NAME_UP);
-
- imageUpElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- imageUpElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
- imageUpElement.setAttribute(HTML.ATTR_CLASS, "dr-spnr-bn"); //$NON-NLS-1$
-
- cellUp.appendChild(imageUpElement);
- rowUp.appendChild(cellUp);
- table.appendChild(rowUp);
-
- nsIDOMElement rowDown = visualDocument.createElement(HTML.TAG_TR);
- nsIDOMElement cellDown = visualDocument.createElement(HTML.TAG_TD);
-
- nsIDOMElement imageDownElement = visualDocument
- .createElement(HTML.TAG_INPUT);
-
- ComponentUtil.setImg(imageDownElement, IMAGE_NAME_DOWN);
-
- imageDownElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
- imageDownElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
- imageDownElement.setAttribute(HTML.ATTR_CLASS, "dr-spnr-bn"); //$NON-NLS-1$
- cellDown.appendChild(imageDownElement);
- rowDown.appendChild(cellDown);
- table.appendChild(rowDown);
-
- return table;
- }
-
- /**
- * Create a HTML-part containg input element
- *
- * @param visualDocument
- * The current node of the source tree.
- * @param sourceNode
- * The document of the visual tree.
- * @param elementData
- * @return a HTML-part containg input element
- */
- private nsIDOMElement createInputElement(nsIDOMDocument visualDocument,
- Element sourceElement, VpeElementData elementData) {
- nsIDOMElement inputElement = visualDocument
- .createElement(HTML.TAG_INPUT);
-
- inputElement
- .setAttribute(HTML.ATTR_CLASS, getInputClass(sourceElement));
-
- inputElement
- .setAttribute(HTML.ATTR_STYLE, getInputStyle(sourceElement));
-
- inputElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
-
- inputElement.setAttribute(HTML.ATTR_SIZE, getInputSize(sourceElement));
- inputElement
- .setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
-
- if ((sourceElement).hasAttribute(RichFaces.ATTR_VALUE)) {
- elementData.addNodeData(new NodeData(sourceElement
- .getAttributeNode(RichFaces.ATTR_VALUE), inputElement, true));
- } else {
- elementData.addNodeData(new AttributeData(
- RichFaces.ATTR_VALUE, inputElement, true));
- }
-
- return inputElement;
- }
-
- /**
- * Return a input value
- *
- * @param sourceNode
- * a sourceNode
- * @return a input value
- */
- private String getInputValue(Element sourceElement) {
- String returnValue = getAttribute(sourceElement, RichFaces.ATTR_VALUE);
- return returnValue;
- }
-
- /**
- * Return a input style
- *
- * @param sourceNode
- * a sourceNode
- * @return a input style
- */
- private String getInputStyle(Element sourceElement) {
- String returnValue = getAttribute(sourceElement,
- RichFaces.ATTR_INPUT_STYLE);
- return returnValue;
- }
-
- /**
- * Return a input size
- *
- * @param sourceNode
- * a sourceNode
- * @return a input size
- */
- protected String getInputSize(Element sourceElement) {
- String returnValue = getDefaultInputSize();
- String tmp = getAttribute(sourceElement, RichFaces.ATTR_INPUT_SIZE);
- if (tmp.length() != 0) {
- returnValue = tmp;
- }
- return returnValue;
- }
-
- /**
- * Return a input class
- *
- * @param sourceNode
- * a sourceNode
- * @return a input class
- */
- public String getInputClass(Element sourceElement) {
- String returnValue = getDefaultInputClass();
- String tmp = getAttribute(sourceElement, RichFaces.ATTR_INPUT_CLASS);
- if (tmp.length() != 0) {
- returnValue = new StringBuffer().append(returnValue).append(" ")
//$NON-NLS-1$
- .append(tmp).toString();
- }
- return returnValue;
- }
-
- /**
- *
- * @see
com.exadel.vpe.editor.template.VpeAbstractTemplate#setAttribute(com.exadel.vpe.editor.context.VpePageContext,
- * org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.Node,
- * java.lang.Object, java.lang.String, java.lang.String)
- */
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
- String name, String value) {
- // 1. Call super method
- super.setAttribute(pageContext, sourceElement, visualDocument,
- visualNode, data, name, value);
-
- nsIDOMElement table = (nsIDOMElement) visualNode
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
- nsIDOMNodeList listTable = table.getChildNodes();
- nsIDOMNode nodeTr = listTable.item(0);
- nsIDOMNodeList listTr = nodeTr.getChildNodes();
- nsIDOMNode nodeTd = listTr.item(0);
-
- nsIDOMNodeList listTd = nodeTd.getChildNodes();
- nsIDOMNode entry0 = listTd.item(0);
-
- nsIDOMElement inputElement = (nsIDOMElement) entry0
- .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
-
- inputElement
- .setAttribute(HTML.ATTR_CLASS, getInputClass(sourceElement));
-
- inputElement
- .setAttribute(HTML.ATTR_STYLE, getInputStyle(sourceElement));
-
- inputElement.setAttribute(HTML.ATTR_SIZE, getInputSize(sourceElement));
- inputElement
- .setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
-
- // 3. Set a style for main container
- String strStyle = getAttribute(sourceElement, RichFaces.ATTR_STYLE);
- table.setAttribute(HTML.ATTR_STYLE, strStyle);
- }
-
- public String getDefaultInputSize() {
- return DEFAULT_INPUT_SIZE;
- }
-
- public String getDefaultInputClass() {
- return DEFAULT_INPUT_STYLE;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007 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.jsf.vpe.richfaces.template;
+
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.template.util.RichFaces;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.AttributeData;
+import org.jboss.tools.vpe.editor.mapping.NodeData;
+import org.jboss.tools.vpe.editor.mapping.VpeElementData;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Template for input number spinner control
+ */
+public class RichFacesInputNumberSpinnerTemplate extends
+/* AbstractRichFacesInputNumberTemplate */AbstractEditableRichFacesTemplate {
+
+ /** CSS_FILE_NAME */
+ final static private String CSS_FILE_NAME =
"inputNumberSpinner/inputNumberSpinner.css"; //$NON-NLS-1$
+
+ /** IMAGE_NAME_UP */
+ final static private String IMAGE_NAME_UP = "/inputNumberSpinner/up.gif";
//$NON-NLS-1$
+
+ /** IMAGE_NAME_DOWN */
+ final static private String IMAGE_NAME_DOWN = "/inputNumberSpinner/down.gif";
//$NON-NLS-1$
+
+ /** DEFAULT_INPUT_SIZE */
+ final static private String DEFAULT_INPUT_SIZE = "10"; //$NON-NLS-1$
+
+ /** DEFAULT_INPUT_STYLE */
+ final static private String DEFAULT_INPUT_STYLE = "dr-spnr-i"; //$NON-NLS-1$
+
+ /** DEFAULT_INPUT_CONTAINER_STYLE */
+ final static private String DEFAULT_INPUT_CONTAINER_STYLE = "dr-spnr-e";
//$NON-NLS-1$
+
+ /** DEFAULT_BUTTONS_STYLE */
+ final static private String DEFAULT_BUTTONS_STYLE = "dr-spnr-b";
//$NON-NLS-1$
+
+ /** DEFAULT_BUTTON_STYLE */
+ final static private String DEFAULT_BUTTON_STYLE = "dr-spnr-bn";
//$NON-NLS-1$
+
+ final static private String ZERO_STRING = "0"; //$NON-NLS-1$
+
+ /** DISABLED_INPUT_STYLE applied for INPUT tag element in case of DISABLING */
+ final static private String DISABLED_INPUT_STYLE = "color:gray";
//$NON-NLS-1$
+
+ /* RichFaces styles for component elements */
+ /** RICH_SPINNER_C_STYLE */
+ final static private String RICH_SPINNER_C_STYLE = "rich-spinner-c";
//$NON-NLS-1$
+
+ /** RICH_SPINNER_INPUT_CONTAINER_STYLE */
+ final static private String RICH_SPINNER_INPUT_CONTAINER_STYLE =
"rich-spinner-input-container"; //$NON-NLS-1$
+
+ /** RICH_SPINNER_INPUT_STYLE */
+ final static private String RICH_SPINNER_INPUT_STYLE = "rich-spinner-input";
//$NON-NLS-1$
+
+ /** RICH_SPINNER_BUTTON_STYLE */
+ final static private String RICH_SPINNER_BUTTON_STYLE = "rich-spinner-button";
//$NON-NLS-1$
+
+ /** RICH_SPINNER_BUTTONS_STYLE */
+ final static private String RICH_SPINNER_BUTTONS_STYLE =
"rich-spinner-buttons"; //$NON-NLS-1$
+
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ // Set a css for this element
+ ComponentUtil.setCSSLink(pageContext, CSS_FILE_NAME,
"richFacesInputNumberSpinner"); //$NON-NLS-1$
+
+ Element sourceElement = (Element) sourceNode;
+
+ nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
+ table.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
+ table.setAttribute(HTML.ATTR_CELLPADDING, ZERO_STRING);
+ table.setAttribute(HTML.ATTR_CELLSPACING, ZERO_STRING);
+
+ VpeElementData elementData = new VpeElementData();
+
+ nsIDOMElement row = visualDocument.createElement(HTML.TAG_TR);
+
+ // create input element
+ nsIDOMElement cellInput = visualDocument.createElement(HTML.TAG_TD);
+ cellInput.setAttribute(HTML.ATTR_CLASS, DEFAULT_INPUT_CONTAINER_STYLE + " "
//$NON-NLS-1$
+ + RICH_SPINNER_INPUT_CONTAINER_STYLE);
+ cellInput.appendChild(createInputElement(visualDocument, sourceElement, elementData));
+ row.appendChild(cellInput);
+
+ // create arrows cell
+ nsIDOMElement cellArrows = visualDocument.createElement(HTML.TAG_TD);
+ cellArrows.setAttribute(HTML.ATTR_CLASS, DEFAULT_BUTTONS_STYLE + " "
//$NON-NLS-1$
+ + RICH_SPINNER_BUTTONS_STYLE);
+ cellArrows.appendChild(createArrowsElement(visualDocument, sourceNode));
+ row.appendChild(cellArrows);
+
+ table.appendChild(row);
+
+ String tmp = getAttribute(sourceElement, RichFaces.ATTR_STYLE);
+ table.setAttribute(HTML.ATTR_STYLE, tmp);
+ tmp = getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS);
+ tmp = new StringBuffer().append(RICH_SPINNER_C_STYLE).append("
").append(tmp).toString(); //$NON-NLS-1$
+ table.setAttribute(HTML.ATTR_CLASS, tmp);
+
+ // Create return variable contain template
+ VpeCreationData creationData = new VpeCreationData(table);
+
+ creationData.setElementData(elementData);
+
+ return creationData;
+ }
+
+ /**
+ * Create a HTML-part containg arrows elements
+ *
+ * @param visualDocument
+ * The current node of the source tree.
+ * @param sourceNode
+ * The document of the visual tree.
+ * @return a HTML-part containg arrows elements
+ */
+ private nsIDOMElement createArrowsElement(nsIDOMDocument visualDocument,
+ Node sourceNode) {
+ nsIDOMElement table = visualDocument.createElement(HTML.TAG_TABLE);
+
+ table.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
+ table.setAttribute(HTML.ATTR_CELLPADDING, ZERO_STRING);
+ table.setAttribute(HTML.ATTR_CELLSPACING, ZERO_STRING);
+
+ nsIDOMElement rowUp = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement cellUp = visualDocument.createElement(HTML.TAG_TD);
+
+ nsIDOMElement imageUpElement = visualDocument.createElement(HTML.TAG_INPUT);
+
+ ComponentUtil.setImg(imageUpElement, IMAGE_NAME_UP);
+
+ imageUpElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
+ imageUpElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
+ imageUpElement.setAttribute(HTML.ATTR_CLASS, DEFAULT_BUTTON_STYLE + " "
//$NON-NLS-1$
+ + RICH_SPINNER_BUTTON_STYLE);
+
+ cellUp.appendChild(imageUpElement);
+ rowUp.appendChild(cellUp);
+ table.appendChild(rowUp);
+
+ nsIDOMElement rowDown = visualDocument.createElement(HTML.TAG_TR);
+ nsIDOMElement cellDown = visualDocument.createElement(HTML.TAG_TD);
+
+ nsIDOMElement imageDownElement = visualDocument.createElement(HTML.TAG_INPUT);
+
+ ComponentUtil.setImg(imageDownElement, IMAGE_NAME_DOWN);
+
+ imageDownElement.setAttribute(HTML.ATTR_BORDER, ZERO_STRING);
+ imageDownElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_IMAGE);
+ imageDownElement.setAttribute(HTML.ATTR_CLASS, DEFAULT_BUTTON_STYLE + " "
//$NON-NLS-1$
+ + RICH_SPINNER_BUTTON_STYLE);
+ cellDown.appendChild(imageDownElement);
+ rowDown.appendChild(cellDown);
+ table.appendChild(rowDown);
+
+ return table;
+ }
+
+ /**
+ * Create a HTML-part containg input element
+ *
+ * @param visualDocument
+ * The current node of the source tree.
+ * @param sourceNode
+ * The document of the visual tree.
+ * @param elementData
+ * @return a HTML-part containg input element
+ */
+ private nsIDOMElement createInputElement(nsIDOMDocument visualDocument,
+ Element sourceElement, VpeElementData elementData) {
+ nsIDOMElement inputElement = visualDocument.createElement(HTML.TAG_INPUT);
+
+ inputElement.setAttribute(HTML.ATTR_CLASS, getInputClass(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_STYLE, getInputStyle(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_TEXT);
+ inputElement.setAttribute(HTML.ATTR_SIZE, getInputSize(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
+
+ if ((sourceElement).hasAttribute(RichFaces.ATTR_VALUE)) {
+ elementData.addNodeData(new NodeData(sourceElement
+ .getAttributeNode(RichFaces.ATTR_VALUE), inputElement, true));
+ } else {
+ elementData.addNodeData(new AttributeData(RichFaces.ATTR_VALUE, inputElement, true));
+ }
+
+ return inputElement;
+ }
+
+ /**
+ * Return a input value
+ *
+ * @param sourceNode
+ * a sourceNode
+ * @return a input value
+ */
+ private String getInputValue(Element sourceElement) {
+ String returnValue = getAttribute(sourceElement, RichFaces.ATTR_VALUE);
+ return returnValue;
+ }
+
+ /**
+ * Return a input style
+ *
+ * @param sourceNode
+ * a sourceNode
+ * @return a input style
+ */
+ private String getInputStyle(Element sourceElement) {
+ String returnValue = getAttribute(sourceElement, RichFaces.ATTR_INPUT_STYLE);
+ if ((sourceElement).hasAttribute(RichFaces.ATTR_DISABLED)) {
+ String disabled = getAttribute(sourceElement, RichFaces.ATTR_DISABLED);
+ if (disabled != null && disabled.equals("true")) { //$NON-NLS-1$
+ returnValue = new StringBuffer().append(returnValue).append(" ; ")
//$NON-NLS-1$
+ .append(DISABLED_INPUT_STYLE).toString();
+ }
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Return a input size
+ *
+ * @param sourceNode
+ * a sourceNode
+ * @return a input size
+ */
+ protected String getInputSize(Element sourceElement) {
+ String returnValue = getDefaultInputSize();
+ String tmp = getAttribute(sourceElement, RichFaces.ATTR_INPUT_SIZE);
+ if (tmp.length() != 0) {
+ returnValue = tmp;
+ }
+ return returnValue;
+ }
+
+ /**
+ * Return a input class
+ *
+ * @param sourceNode
+ * a sourceNode
+ * @return a input class
+ */
+ public String getInputClass(Element sourceElement) {
+ String returnValue = getDefaultInputClass();
+ // append default richfaces component style class
+ returnValue += " " + RICH_SPINNER_INPUT_STYLE; //$NON-NLS-1$
+ // append custom input style class
+ String tmp = getAttribute(sourceElement, RichFaces.ATTR_INPUT_CLASS);
+ if (tmp.length() != 0) {
+ returnValue = new StringBuffer().append(returnValue).append(" ")
//$NON-NLS-1$
+ .append(tmp).toString();
+ }
+ return returnValue;
+ }
+
+ /**
+ *
+ * @see
com.exadel.vpe.editor.template.VpeAbstractTemplate#setAttribute(com.exadel.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Element, org.w3c.dom.Document, org.w3c.dom.Node,
+ * java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ // 1. Call super method
+ super.setAttribute(pageContext, sourceElement, visualDocument, visualNode, data, name,
value);
+
+ nsIDOMElement table = (nsIDOMElement)
visualNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ nsIDOMNodeList listTable = table.getChildNodes();
+ nsIDOMNode nodeTr = listTable.item(0);
+ nsIDOMNodeList listTr = nodeTr.getChildNodes();
+ nsIDOMNode nodeTd = listTr.item(0);
+
+ nsIDOMNodeList listTd = nodeTd.getChildNodes();
+ nsIDOMNode entry0 = listTd.item(0);
+
+ nsIDOMElement inputElement = (nsIDOMElement)
entry0.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ inputElement.setAttribute(HTML.ATTR_CLASS, getInputClass(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_STYLE, getInputStyle(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_SIZE, getInputSize(sourceElement));
+ inputElement.setAttribute(HTML.ATTR_VALUE, getInputValue(sourceElement));
+
+ // 3. Set a style for main container
+ String strStyle = getAttribute(sourceElement, RichFaces.ATTR_STYLE);
+ table.setAttribute(HTML.ATTR_STYLE, strStyle);
+ }
+
+ public String getDefaultInputSize() {
+ return DEFAULT_INPUT_SIZE;
+ }
+
+ public String getDefaultInputClass() {
+ return DEFAULT_INPUT_STYLE;
+ }
+}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml 2008-11-05
17:04:43 UTC (rev 11529)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml 2008-11-05
17:20:00 UTC (rev 11530)
@@ -1,17 +1,20 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich">
-
-<head>
-</head>
-<body>
-<f:view>
- <rich:inputNumberSpinner id="inputNumberSpinner" value="50">
- </rich:inputNumberSpinner>
-</f:view>
-</body>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+<head>
+</head>
+<body>
+<f:view>
+ <rich:inputNumberSpinner id="inputNumberSpinner"
value="50">
+ </rich:inputNumberSpinner>
+ <rich:inputNumberSpinner id="inputNumberSpinnerCustomCSS"
value="50"
+ styleClass="componentStyleClass"
inputClass="inputStyleClass"
+ inputStyle="font-style: italic;">
+ </rich:inputNumberSpinner>
+</f:view>
+</body>
</html>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml.xml 2008-11-05
17:04:43 UTC (rev 11529)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/inputNumberSpinner.xhtml.xml 2008-11-05
17:20:00 UTC (rev 11530)
@@ -1,25 +1,26 @@
<tests>
<test id="inputNumberSpinner">
- <TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0"
>
+ <TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0"
STYLE=""
+ CLASS="rich-spinner-c">
<TR>
- <TD VALIGN="top" CLASS="ins-dr-spnr-e">
- <INPUT TYPE="text" CLASS="ins-input" STYLE=""
SIZE="10"
- VALUE="50"/>
+ <TD CLASS="dr-spnr-e rich-spinner-input-container">
+ <INPUT TYPE="text" CLASS="dr-spnr-i rich-spinner-input"
+ STYLE="" SIZE="10" VALUE="50" />
</TD>
- <TD VALIGN="middle" CLASS="dr-spnr-b">
+ <TD CLASS="dr-spnr-b rich-spinner-buttons">
<TABLE CELLSPACING="0" CELLPADDING="0"
BORDER="0">
<TR>
<TD>
<INPUT TYPE="image" BORDER="0"
SRC="/.*resources/inputNumberSpinner/up.gif/"
- CLASS="dr-spnr-bn"/>
+ CLASS="dr-spnr-bn rich-spinner-button" />
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="image" BORDER="0"
SRC="/.*resources/inputNumberSpinner/down.gif/"
- CLASS="dr-spnr-bn"/>
+ CLASS="dr-spnr-bn rich-spinner-button" />
</TD>
</TR>
</TABLE>
@@ -27,4 +28,33 @@
</TR>
</TABLE>
</test>
+ <test id="inputNumberSpinnerCustomCSS">
+ <TABLE CELLSPACING="0" CELLPADDING="0"
BORDER="0" STYLE=""
+ CLASS="rich-spinner-c componentStyleClass">
+ <TR>
+ <TD CLASS="dr-spnr-e rich-spinner-input-container">
+ <INPUT TYPE="text" CLASS="dr-spnr-i
rich-spinner-input inputStyleClass"
+ STYLE="font-style: italic;" SIZE="10"
VALUE="50" />
+ </TD>
+ <TD CLASS="dr-spnr-b rich-spinner-buttons">
+ <TABLE CELLSPACING="0" CELLPADDING="0"
BORDER="0">
+ <TR>
+ <TD>
+ <INPUT TYPE="image" BORDER="0"
+
SRC="/.*resources/inputNumberSpinner/up.gif/"
+ CLASS="dr-spnr-bn rich-spinner-button"
/>
+ </TD>
+ </TR>
+ <TR>
+ <TD>
+ <INPUT TYPE="image" BORDER="0"
+
SRC="/.*resources/inputNumberSpinner/down.gif/"
+ CLASS="dr-spnr-bn rich-spinner-button"
/>
+ </TD>
+ </TR>
+ </TABLE>
+ </TD>
+ </TR>
+ </TABLE>
+ </test>
</tests>
\ No newline at end of file