Author: yradtsevich
Date: 2008-11-13 12:42:56 -0500 (Thu, 13 Nov 2008)
New Revision: 11769
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
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/VpeVisualDomBuilder.java
Log:
RESOLVED - JBIDE-3012
https://jira.jboss.org/jira/browse/JBIDE-3012
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -44,8 +44,11 @@
}
// general jsf attributes
- /** The attributes. */
- static private Map<String, String> attributes = new HashMap<String,
String>();
+ /**
+ * Contains JSF attributes and appropriate HTML attributes
+ * content of that does not have to be modified in templates.
+ */
+ static final private Map<String, String> attributes = new HashMap<String,
String>();
static {
attributes.put("style", HTML.ATTR_STYLE); //$NON-NLS-1$
@@ -53,20 +56,21 @@
}
/**
- * copy general.
+ * Renames and copies most general JSF attributes from the
+ * {@code sourceElement} to the {@code visualElement}.
*
* @param sourceElement the source element
* @param visualElement the visual element
+ * @see AbstractEditableJsfTemplate#attributes attributes
*/
- protected void copyGeneralJsfAttributes(nsIDOMElement visualElement,
- Element sourceElement) {
-
- Set<String> jsfAttributes = attributes.keySet();
-
- for (String key : jsfAttributes) {
-
- copyAttribute(visualElement, sourceElement, key, attributes
- .get(key));
+ protected void copyGeneralJsfAttributes(Element sourceElement,
+ nsIDOMElement visualElement) {
+
+ Set<Map.Entry<String, String>> jsfAttrEntries = attributes.entrySet();
+
+ for (Map.Entry<String, String> attrEntry : jsfAttrEntries) {
+ copyAttribute(visualElement, sourceElement, attrEntry.getKey(),
+ attrEntry.getValue());
}
}
@@ -88,7 +92,4 @@
.getAttribute(sourceAttributeName));
}
-
-
-
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -61,7 +61,7 @@
*/
protected void copyOutputJsfAttributes(nsIDOMElement visualElement,
Element sourceElement) {
- copyGeneralJsfAttributes(visualElement, sourceElement);
+ copyGeneralJsfAttributes(sourceElement, visualElement);
copyAttribute(visualElement, sourceElement, JSF.ATTR_DIR, HTML.ATTR_DIR);
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextAreaTemplate.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.vpe.jsf.template;
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.AttributeData;
@@ -34,13 +35,16 @@
nsIDOMElement textArea = visualDocument
.createElement(HTML.TAG_TEXTAREA);
- ((nsIDOMHTMLTextAreaElement) textArea
- .queryInterface(nsIDOMHTMLTextAreaElement.NS_IDOMHTMLTEXTAREAELEMENT_IID))
- .setReadOnly(true);
+
+// Commented as fix for JBIDE-3012.
+// ((nsIDOMHTMLTextAreaElement) textArea
+// .queryInterface(nsIDOMHTMLTextAreaElement.NS_IDOMHTMLTEXTAREAELEMENT_IID))
+// .setReadOnly(true);
VpeCreationData creationData = new VpeCreationData(textArea);
- copyGeneralJsfAttributes(textArea, sourceElement);
+ copyGeneralJsfAttributes(sourceElement, textArea);
+ ComponentUtil.copyDisabled(sourceElement, textArea);
copyAttribute(textArea, sourceElement, JSF.ATTR_DIR, HTML.ATTR_DIR);
copyAttribute(textArea, sourceElement, JSF.ATTR_ROWS, HTML.ATTR_ROWS);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfInputTextTemplate.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.vpe.jsf.template;
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.AttributeData;
@@ -34,7 +35,8 @@
VpeCreationData creationData = new VpeCreationData(input);
- copyGeneralJsfAttributes(input, sourceElement);
+ copyGeneralJsfAttributes(sourceElement, input);
+ ComponentUtil.copyDisabled(sourceElement, input);
copyAttribute(input, sourceElement, JSF.ATTR_VALUE, HTML.ATTR_VALUE);
copyAttribute(input, sourceElement, JSF.ATTR_SIZE, HTML.ATTR_SIZE);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -18,6 +18,7 @@
import org.jboss.tools.jsf.vpe.jsf.JsfTemplatePlugin;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMElement;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
@@ -61,26 +62,56 @@
}
return attribute;
}
+
+ /**
+ * Returns {@code true} if the {@code element} has attribute
+ * {@code disabled} and its value is {@link #string2boolean(String) true}
+ */
+ public static boolean isDisabled(Element element) {
+ return ComponentUtil.string2boolean(
+ ComponentUtil.getAttribute(element, JSF.ATTR_DISABLED));
+ }
+
+ /**
+ * Sets attribute {@code "disabled"} of the {@code element} to {@code
"disabled"}
+ * if the parameter {@code disabled} is {@code true},
+ * <br/>
+ * otherwise removes attribute {@code "disabled"} from the {@code element}
+ * if it is present.
+ */
+ public static void setDisabled(nsIDOMElement element, boolean disabled) {
+ if (disabled) {
+ element.setAttribute(HTML.ATTR_DISABLED, HTML.ATTR_DISABLED);
+ } else {
+ element.removeAttribute(HTML.ATTR_DISABLED);
+ }
+ }
+
+ /**
+ * Copies {@code "disabled"} attribute from JSF {@code sourceElement} to
+ * HTML {@code targetElement}.
+ *
+ * @see #isDisabled(Element)
+ * @see #setDisabled(nsIDOMElement, boolean)
+ */
+ public static void copyDisabled(Element sourceElement, nsIDOMElement targetElement) {
+ boolean disabled = ComponentUtil.isDisabled(sourceElement);
+ ComponentUtil.setDisabled(targetElement, disabled);
+ }
/**
* Parses string value retrieved from sourceElement.getAttribure(..) method
* to its boolean value.
* <p>
- * <code>false</code> is returned only if it specified explicitly,
- * otherwise <code>true</code> is returned.
+ * <code>true</code> is returned only if it specified explicitly,
+ * otherwise <code>false</code> is returned.
*
* @param str
* the string to parse
* @return boolean value from string
*/
public static boolean string2boolean(String str) {
- if ((str == null) || ("".equals(str))) {
- return false;
- } else if (("true".equalsIgnoreCase(str))
- || ("false".equalsIgnoreCase(str))) {
- return new Boolean(str).booleanValue();
- }
- return false;
+ return Boolean.parseBoolean(str);
}
/**
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 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-11-13
17:42:56 UTC (rev 11769)
@@ -180,52 +180,108 @@
<!-- Проблема с адресацией от приложения (30 of 4) -->
<vpe:tag name="h:commandButton" case-sensitive="yes">
- <vpe:if test="not(attrpresent('image'))">
- <vpe:if test="(@type='')">
+ <!-- This is a very big if-statement.
+ Its goal is to add support of 'disabled property'
+ DO NOT FORGET TO EDIT 'ELSE' PART IN FUTURE MODIFICATIONS -->
+ <vpe:if test="(@disabled='true')">
+ <vpe:if test="not(attrpresent('image'))">
+ <vpe:if test="(@type='')">
+ <vpe:template children="no" modify="no">z
+ <input type="button" value="{iif(@value='','
',jsfvalue(@value))}"
+ class="{@styleClass}" style="{@style}"
+ title="{tagstring()}" dir="{@dir}"
+ disabled='disabled'/>
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ <vpe:textFormatting use-default-formats="yes">
+ </vpe:textFormatting>
+ </vpe:template>
+ </vpe:if>
+ <vpe:if test="not(@type='')">
+ <vpe:template children="no" modify="no">
+ <input type="{@type}" value="{iif(@value='','
',jsfvalue(@value))}"
+ class="{@styleClass}" style="{@style}"
+ title="{tagstring()}" dir="{@dir}"
+ disabled='disabled'/>
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ <vpe:textFormatting use-default-formats="yes">
+ </vpe:textFormatting>
+ </vpe:template>
+ </vpe:if>
+ </vpe:if>
+ <vpe:if test="attrpresent('image')">
<vpe:template children="no" modify="no">
- <input type="button" value="{iif(@value='','
',jsfvalue(@value))}"
- class="{@styleClass}" style="{@style}"
- title="{tagstring()}" dir="{@dir}"/>
+ <input type="image" src="{src(@image)}"
+ class="{@styleClass}" style="{@style}"
title="{tagstring()}"
+ disabled='disabled'/>
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
</vpe:resize>
- <vpe:dnd>
- <vpe:drag start-enable="yes" />
- </vpe:dnd>
<vpe:textFormatting use-default-formats="yes">
</vpe:textFormatting>
</vpe:template>
</vpe:if>
- <vpe:if test="not(@type='')">
+ </vpe:if>
+ <!--else-->
+ <vpe:if test="not(attrpresent('image'))">
+ <vpe:if test="(@type='')">
+ <vpe:template children="no" modify="no">z
+ <input type="button" value="{iif(@value='','
',jsfvalue(@value))}"
+ class="{@styleClass}" style="{@style}"
+ title="{tagstring()}" dir="{@dir}"/>
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ <vpe:textFormatting use-default-formats="yes">
+ </vpe:textFormatting>
+ </vpe:template>
+ </vpe:if>
+ <vpe:if test="not(@type='')">
+ <vpe:template children="no" modify="no">
+ <input type="{@type}" value="{iif(@value='','
',jsfvalue(@value))}"
+ class="{@styleClass}" style="{@style}"
+ title="{tagstring()}" dir="{@dir}"/>
+ <vpe:resize>
+ <vpe:width width-attr="style.width" />
+ <vpe:height height-attr="style.height" />
+ </vpe:resize>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ <vpe:textFormatting use-default-formats="yes">
+ </vpe:textFormatting>
+ </vpe:template>
+ </vpe:if>
+ </vpe:if>
+ <vpe:if test="attrpresent('image')">
<vpe:template children="no" modify="no">
- <input type="{@type}" value="{iif(@value='','
',jsfvalue(@value))}"
- class="{@styleClass}" style="{@style}"
- title="{tagstring()}" dir="{@dir}"/>
+ <input type="image" src="{src(@image)}"
+ class="{@styleClass}" style="{@style}"
title="{tagstring()}" />
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
</vpe:resize>
- <vpe:dnd>
- <vpe:drag start-enable="yes" />
- </vpe:dnd>
<vpe:textFormatting use-default-formats="yes">
</vpe:textFormatting>
</vpe:template>
</vpe:if>
- </vpe:if>
- <vpe:if test="attrpresent('image')">
- <vpe:template children="no" modify="no">
- <input type="image" src="{src(@image)}"
- class="{@styleClass}" style="{@style}"
title="{tagstring()}" />
- <vpe:resize>
- <vpe:width width-attr="style.width" />
- <vpe:height height-attr="style.height" />
- </vpe:resize>
- <vpe:textFormatting use-default-formats="yes">
- </vpe:textFormatting>
- </vpe:template>
- </vpe:if>
+ <!--end-of-else-->
</vpe:tag>
<!-- Проблема с вложенным параметром (31 of 4) -->
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 2008-11-13
17:24:38 UTC (rev 11768)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-11-13
17:42:56 UTC (rev 11769)
@@ -265,17 +265,17 @@
nsIDOMNode visualContainer) {
nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
-
- // Fix for JBIDE-1097
- try {
- if (visualNewNode != null) {
- nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
- .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
- iDOMInputElement.setReadOnly(true);
- }
- } catch (XPCOMException ex) {
- // just ignore this exception
- }
+// Commented as fix for JBIDE-3012.
+// // Fix for JBIDE-1097
+// try {
+// if (visualNewNode != null) {
+// nsIDOMHTMLInputElement iDOMInputElement = (nsIDOMHTMLInputElement) visualNewNode
+// .queryInterface(nsIDOMHTMLInputElement.NS_IDOMHTMLINPUTELEMENT_IID);
+// iDOMInputElement.setReadOnly(true);
+// }
+// } catch (XPCOMException ex) {
+// // just ignore this exception
+// }
if (visualNewNode != null) {
if (visualNextNode == null) {
visualContainer.appendChild(visualNewNode);