[jbosstools-commits] JBoss Tools SVN: r43002 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates and 2 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Mon Aug 13 13:15:57 EDT 2012
Author: dmaliarevich
Date: 2012-08-13 13:15:57 -0400 (Mon, 13 Aug 2012)
New Revision: 43002
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFLogTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.ajax4jsf.test/resources/ajax4jsfTests/WebContent/pages/components/log.xhtml.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-12421 - <a4j:log> template was updated.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFLogTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFLogTemplate.java 2012-08-13 08:41:03 UTC (rev 43001)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/src/org/jboss/tools/jsf/vpe/ajax4jsf/template/Ajax4JSFLogTemplate.java 2012-08-13 17:15:57 UTC (rev 43002)
@@ -11,16 +11,10 @@
package org.jboss.tools.jsf.vpe.ajax4jsf.template;
-
-import java.util.List;
-
-import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
import org.jboss.tools.jsf.vpe.richfaces.template.RichFaces;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
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.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
@@ -35,67 +29,56 @@
* @author Igor Zhukov
*/
public class Ajax4JSFLogTemplate extends VpeAbstractTemplate {
+
+ private static final String CLEAR_BUTTON = "Clear"; //$NON-NLS-1$
- /** DEFAULT_DIV_SIZE */
- private final static String DEFAULT_WIDTH = "800px"; //$NON-NLS-1$
- private final static String DEFAULT_HEIGHT = "600px"; //$NON-NLS-1$
- private final static String DEFAULT_OVERFLOW = "auto"; //$NON-NLS-1$
-
- private final static String CLEAR_BUTTON = "Clear"; //$NON-NLS-1$
-
- /**
- * The Constructor.
- */
- public Ajax4JSFLogTemplate() {
- super();
- }
-
- /**
- * Creates a node of the visual tree on the node of the source tree.
- *
- * @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) {
- // cast to Element
Element sourceElement = (Element) sourceNode;
-
nsIDOMElement divElement = visualDocument.createElement(HTML.TAG_DIV);
-
String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
- // set STYLE attributes
- // check 'overflow' attribute
- String parameterValue = VpeStyleUtil.getParameterFromStyleAttribute(style, HTML.STYLE_PARAMETER_OVERFLOW);
- if (parameterValue == null || parameterValue.equals(Constants.EMPTY)) {
- parameterValue = ComponentUtil.getAttribute(sourceElement, HTML.STYLE_PARAMETER_OVERFLOW, DEFAULT_OVERFLOW);
- style = VpeStyleUtil.setParameterInStyle(style, HTML.STYLE_PARAMETER_OVERFLOW, parameterValue);
+ /*
+ * Set OVERFLOW to the STYLE
+ */
+ if (sourceElement.hasAttribute(HTML.STYLE_PARAMETER_OVERFLOW)) {
+ style = VpeStyleUtil.setParameterInStyle(style,
+ HTML.STYLE_PARAMETER_OVERFLOW,
+ sourceElement.getAttribute(HTML.STYLE_PARAMETER_OVERFLOW));
}
- // check 'width' attribute
- parameterValue = VpeStyleUtil.getParameterFromStyleAttribute(style, HTML.ATTR_WIDTH);
- if (parameterValue == null || parameterValue.equals(Constants.EMPTY)) {
- parameterValue = ComponentUtil.getAttribute(sourceElement, HTML.ATTR_WIDTH, DEFAULT_WIDTH);
- style = VpeStyleUtil.setParameterInStyle(style, HTML.ATTR_WIDTH, parameterValue);
+ /*
+ * Set WIDTH to the STYLE
+ */
+ int size;
+ if (sourceElement.hasAttribute(HTML.ATTR_WIDTH)) {
+ size = VpeStyleUtil.cssSizeToInt(sourceElement.getAttribute(HTML.ATTR_WIDTH));
+ if (size != -1) {
+ style = VpeStyleUtil.setSizeInStyle(style, HTML.ATTR_WIDTH, size);
+ }
}
- // check 'height' attribute
- parameterValue = VpeStyleUtil.getParameterFromStyleAttribute(style, HTML.ATTR_HEIGHT);
- if (parameterValue == null || parameterValue.equals(Constants.EMPTY)) {
- parameterValue = ComponentUtil.getAttribute(sourceElement, HTML.ATTR_HEIGHT, DEFAULT_HEIGHT);
- style = VpeStyleUtil.setParameterInStyle(style, HTML.ATTR_HEIGHT, parameterValue);
+ /*
+ * Set HEIGHT to the STYLE
+ */
+ if (sourceElement.hasAttribute(HTML.ATTR_HEIGHT)) {
+ size = VpeStyleUtil.cssSizeToInt(sourceElement.getAttribute(HTML.ATTR_HEIGHT));
+ if (size != -1) {
+ style = VpeStyleUtil.setSizeInStyle(style, HTML.ATTR_HEIGHT, size);
+ }
}
+ /*
+ * Set STYLE to the DIV
+ */
divElement.setAttribute(HTML.ATTR_STYLE, style);
- // set CLASS attribute
- String styleClass = ComponentUtil.getAttribute(sourceElement, RichFaces.ATTR_STYLE_CLASS);
- if (!Constants.EMPTY.equals(styleClass)) {
- divElement.setAttribute(HTML.ATTR_CLASS, styleClass);
+ /*
+ * Set CLASS attribute to the DIV
+ */
+ if (sourceElement.hasAttribute(RichFaces.ATTR_STYLE_CLASS)) {
+ divElement.setAttribute(HTML.ATTR_CLASS,
+ sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS));
}
- // create 'Clear' button
+ /*
+ * Create 'Clear' button
+ */
nsIDOMElement clearButton = visualDocument.createElement(HTML.TAG_BUTTON);
clearButton.appendChild(visualDocument.createTextNode(CLEAR_BUTTON));
clearButton.setAttribute(HTML.ATTR_TYPE, HTML.VALUE_TYPE_BUTTON);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2012-08-13 08:41:03 UTC (rev 43001)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/templates/vpe-templates-ajax4jsf.xml 2012-08-13 17:15:57 UTC (rev 43002)
@@ -225,6 +225,10 @@
<vpe:template children="yes" modify="no"
class="org.jboss.tools.jsf.vpe.ajax4jsf.template.Ajax4JSFLogTemplate">
<vpe:pseudoContent defaultText="no" />
+ <vpe:resize>
+ <vpe:width width-attr="width" />
+ <vpe:height height-attr="height" />
+ </vpe:resize>
</vpe:template>
</vpe:tag>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.ajax4jsf.test/resources/ajax4jsfTests/WebContent/pages/components/log.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.ajax4jsf.test/resources/ajax4jsfTests/WebContent/pages/components/log.xhtml.xml 2012-08-13 08:41:03 UTC (rev 43001)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.ajax4jsf.test/resources/ajax4jsfTests/WebContent/pages/components/log.xhtml.xml 2012-08-13 17:15:57 UTC (rev 43002)
@@ -1,43 +1,51 @@
<tests>
<test id="log">
- <DIV STYLE="overflow: auto; width: 800px; height: 600px;">
- <BUTTON TYPE="button">Clear</BUTTON>
- </DIV>
+ <DIV STYLE="">
+ <BUTTON TYPE="button">
+ Clear
+ </BUTTON>
+ </DIV>
</test>
- <test id="compliteLog">
- <DIV>
- <DIV>
- <SPAN STYLE="-moz-user-modify: read-write;">
- <SPAN CLASS="vpe-text">
- f:verbatim
- </SPAN>
- </SPAN>
- <SPAN CLASS="vpe-text">
- Over Text For loadStyle
- </SPAN>
- </DIV>
- <DIV STYLE="overflow: auto; color: red; background-color: red; width: 400px; height: 100px;"
- CLASS="myClass">
- <BUTTON TYPE="button">Clear</BUTTON>
- </DIV>
- </DIV>
- </test>
- <test id="compliteLog2">
- <DIV>
- <DIV>
- <SPAN STYLE="-moz-user-modify: read-write;">
- <SPAN CLASS="vpe-text">
- f:verbatim
- </SPAN>
- </SPAN>
- <SPAN CLASS="vpe-text">
- Over Text For loadStyle
- </SPAN>
- </DIV>
- <DIV STYLE="overflow: auto; color: red; background-color: red; width: 350px; height: 250px;"
- CLASS="myClass">
- <BUTTON TYPE="button">Clear</BUTTON>
- </DIV>
- </DIV>
- </test>
+ <test id="compliteLog">
+ <DIV CLASS="vpe-text">
+ <DIV CLASS="vpe-text">
+ <SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ f:verbatim
+ </SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Over Text For loadStyle
+ </SPAN>
+ </DIV>
+ <DIV
+ STYLE="color: red; overflow: auto; background-color: red; width: 400px; height: 100px;"
+ CLASS="myClass">
+ <BUTTON TYPE="button">
+ Clear
+ </BUTTON>
+ </DIV>
+ </DIV>
+ </test>
+ <test id="compliteLog2">
+ <DIV CLASS="vpe-text">
+ <DIV CLASS="vpe-text">
+ <SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ f:verbatim
+ </SPAN>
+ </SPAN>
+ <SPAN CLASS="vpe-text">
+ Over Text For loadStyle
+ </SPAN>
+ </DIV>
+ <DIV
+ STYLE="color: red; overflow: auto; background-color: red; width: 350px; height: 250px;"
+ CLASS="myClass">
+ <BUTTON TYPE="button">
+ Clear
+ </BUTTON>
+ </DIV>
+ </DIV>
+ </test>
</tests>
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2012-08-13 08:41:03 UTC (rev 43001)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2012-08-13 17:15:57 UTC (rev 43002)
@@ -178,8 +178,9 @@
String parameter = sizeAttribute.substring(dotPosition + 1, sizeAttribute.length());
String style = sourceElement.getAttribute(attribute);
- if (style == null || EMPTY_STRING.equals(style))
+ if (style == null || EMPTY_STRING.equals(style)) {
return -1;
+ }
int parameterPosition = style.indexOf(parameter);
if (parameterPosition >= 0) {
@@ -999,4 +1000,26 @@
return colorStr;
}
// org.jboss.tools.jst.css.dialog.common.Util.getColor(..)
+
+ /**
+ * Converts "100px" to integer 100
+ *
+ * @param sizeString string for width or height
+ * @return size number
+ */
+ public static int cssSizeToInt(String sizeString) {
+ int size = -1;
+ if (sizeString != null && !EMPTY_STRING.equalsIgnoreCase(sizeString)) {
+ int pxPosition = sizeString.indexOf(PX_STRING);
+ if (pxPosition >= 0) {
+ sizeString = sizeString.substring(0, pxPosition).trim();
+ }
+ try {
+ size = Integer.parseInt(sizeString);
+ } catch (NumberFormatException e) {
+ //do nothing
+ }
+ }
+ return size;
+ }
}
\ No newline at end of file
More information about the jbosstools-commits
mailing list