Author: dmaliarevich
Date: 2009-06-01 10:26:50 -0400 (Mon, 01 Jun 2009)
New Revision: 15623
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/page/page-basic.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPageTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageAllFacets.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithNestedLayouts.xhtml.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4381, attributes processing was added to
rich:page, junits were updated.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/page/page-basic.css
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/page/page-basic.css 2009-06-01
14:18:36 UTC (rev 15622)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/page/page-basic.css 2009-06-01
14:26:50 UTC (rev 15623)
@@ -23,14 +23,11 @@
}
.rich-page-sidebar {
- float: left;
position: relative;
width: 12.3077em;
}
.rich-page-main {
- float: right;
- margin-left: -30em;
width: 100%;
}
@@ -38,7 +35,6 @@
float: none;
width: auto;
position: static;
- margin-left: 13.3077em;
}
.rich-page-footer {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPageTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPageTemplate.java 2009-06-01
14:18:36 UTC (rev 15622)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPageTemplate.java 2009-06-01
14:26:50 UTC (rev 15623)
@@ -1,11 +1,14 @@
package org.jboss.tools.jsf.vpe.richfaces.template;
+import java.math.BigDecimal;
+
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.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.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -18,7 +21,6 @@
private static final String CSS_SIMPLE_THEME_STYLE_PATH =
"page/page-theme_simple.css"; //$NON-NLS-1$
private static final String COMPONENT_NAME = "richFacesPage";
//$NON-NLS-1$
-// private static final String FACET_NAME_PAGE_HEADER = "pageHeader";
//$NON-NLS-1$
private static final String FACET_NAME_SUBHEADER = "subheader"; //$NON-NLS-1$
private static final String FACET_NAME_SIDEBAR = "sidebar"; //$NON-NLS-1$
@@ -33,6 +35,12 @@
private static final String CSS_PAGE_FOOTER = "rich-page-footer";
//$NON-NLS-1$
private static final String CSS_PAGE_FOOTER_CONTENT =
"rich-page-footer-content"; //$NON-NLS-1$
+ private static final String STYLE_SIDEBAR_LEFT = "float: left;";
//$NON-NLS-1$
+ private static final String STYLE_PAGE_MAIN_RIGHT = "float: right;margin-left:
-30em;"; //$NON-NLS-1$
+
+ private static final String STYLE_SIDEBAR_RIGHT = "float: right;";
//$NON-NLS-1$
+ private static final String STYLE_PAGE_MAIN_LEFT = "float: left;margin-right:
-30em;"; //$NON-NLS-1$
+
/**
* Constructor
*/
@@ -71,19 +79,37 @@
creationData = new VpeCreationData(pageDiv);
/*
- * Add basic style classes.
+ * Add basic style classes and attributes.
*/
String styleClass = CSS_PAGE;
if (ComponentUtil.isNotBlank(attrs.getStyleClass())) {
- styleClass += attrs.getStyleClass();
+ styleClass += Constants.WHITE_SPACE + attrs.getStyleClass();
}
+ pageDiv.setAttribute(HTML.ATTR_CLASS, styleClass);
+ String style = Constants.EMPTY;
+ /*
+ * Page's width in 'em' does not affect its size in VPE,
+ * so width should be set in 'px' to come into effect.
+ */
+ if (ComponentUtil.isNotBlank(attrs.getWidth())) {
+ style += Constants.WHITE_SPACE + "; width: " + attrs.getWidth() +
"px;"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
if (ComponentUtil.isNotBlank(attrs.getStyle())) {
- pageDiv.setAttribute(HTML.ATTR_STYLE, attrs.getStyle());
+ style += Constants.WHITE_SPACE + attrs.getStyle();
}
- pageDiv.setAttribute(HTML.ATTR_CLASS, styleClass);
+ pageDiv.setAttribute(HTML.ATTR_STYLE, style);
+ if (ComponentUtil.isNotBlank(attrs.getDir())) {
+ pageDiv.setAttribute(HTML.ATTR_DIR, attrs.getDir());
+ }
+
pageContentDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_CONTENT);
pageMainDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_MAIN);
- pageBodyDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_BODY);
+ String bodyClass = CSS_PAGE_BODY;
+ if (ComponentUtil.isNotBlank(attrs.getBodyClass())) {
+ bodyClass += Constants.WHITE_SPACE + attrs.getBodyClass();
+ }
+ pageBodyDiv.setAttribute(HTML.ATTR_CLASS, bodyClass);
/*
* 1)
@@ -94,10 +120,14 @@
if(headerFacet != null) {
pageHeaderDiv = visualDocument.createElement(HTML.TAG_DIV);
pageHeaderContentDiv = visualDocument.createElement(HTML.TAG_DIV);
-
- pageHeaderDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_HEADER);
+
+ String headerClass = CSS_PAGE_HEADER;
+ if (ComponentUtil.isNotBlank(attrs.getHeaderClass())) {
+ headerClass += Constants.WHITE_SPACE + attrs.getHeaderClass();
+ }
+ pageHeaderDiv.setAttribute(HTML.ATTR_CLASS, headerClass);
pageHeaderContentDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_HEADER_CONTENT);
-
+
pageHeaderDiv.appendChild(pageHeaderContentDiv);
pageDiv.appendChild(pageHeaderDiv);
@@ -114,7 +144,11 @@
Element subHeaderFacet = ComponentUtil.getFacet(sourceElement, FACET_NAME_SUBHEADER);
if(subHeaderFacet != null) {
pageSubHeaderDiv = visualDocument.createElement(HTML.TAG_DIV);
- pageSubHeaderDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_SUBHEADER);
+ String subheaderClass = CSS_PAGE_SUBHEADER;
+ if (ComponentUtil.isNotBlank(attrs.getSubHeaderClass())) {
+ subheaderClass += Constants.WHITE_SPACE + attrs.getSubHeaderClass();
+ }
+ pageSubHeaderDiv.setAttribute(HTML.ATTR_CLASS, subheaderClass);
pageDiv.appendChild(pageSubHeaderDiv);
VpeChildrenInfo subHeaderInfo = new VpeChildrenInfo(pageSubHeaderDiv);
@@ -136,9 +170,49 @@
Element sidebarFacet = ComponentUtil.getFacet(sourceElement, FACET_NAME_SIDEBAR);
if(sidebarFacet != null) {
pageSidebarDiv = visualDocument.createElement(HTML.TAG_DIV);
- pageSidebarDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_SIDEBAR);
+ String sidebarClass = CSS_PAGE_SIDEBAR;
+ if (ComponentUtil.isNotBlank(attrs.getSiderbarClass())) {
+ sidebarClass += Constants.WHITE_SPACE + attrs.getSiderbarClass();
+ }
+ pageSidebarDiv.setAttribute(HTML.ATTR_CLASS, sidebarClass);
pageContentDiv.appendChild(pageSidebarDiv);
+
+ /*
+ * Processing attributes for sidebar style, width and position.
+ */
+ String sidebarStyle = Constants.EMPTY;
+ String pageMainDivStyle = Constants.EMPTY;
+ String pageBodyStyle = Constants.EMPTY;
+ double widthDouble = parseWidth(attrs.getSidebarWidth());
+ if (widthDouble != -1) {
+ sidebarStyle += Constants.WHITE_SPACE + "; width: " + widthDouble +
"em;"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ /*
+ * If sidebar position 'right' is specified explicitly
+ * add 'float: right' style to the sidebar,
+ * otherwise default 'left' position will be used.
+ */
+ if (ComponentUtil.isNotBlank(attrs.getSidebarPosition())
+ && RichFaces.VALUE_RIGHT.equalsIgnoreCase(attrs
+ .getSidebarPosition())) {
+ sidebarStyle += Constants.WHITE_SPACE + STYLE_SIDEBAR_RIGHT;
+ pageMainDivStyle += Constants.WHITE_SPACE + STYLE_PAGE_MAIN_LEFT;
+ if (widthDouble != -1) {
+ pageBodyStyle += Constants.WHITE_SPACE + ";margin-right: " + widthDouble +
"em;"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ sidebarStyle += Constants.WHITE_SPACE + STYLE_SIDEBAR_LEFT;
+ pageMainDivStyle += Constants.WHITE_SPACE + STYLE_PAGE_MAIN_RIGHT;
+ if (widthDouble != -1) {
+ pageBodyStyle += Constants.WHITE_SPACE + ";margin-left: " + widthDouble +
"em;"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ pageSidebarDiv.setAttribute(HTML.ATTR_STYLE, sidebarStyle);
+ pageMainDiv.setAttribute(HTML.ATTR_STYLE, pageMainDivStyle);
+ pageBodyDiv.setAttribute(HTML.ATTR_STYLE, pageBodyStyle);
+
VpeChildrenInfo sidebarInfo = new VpeChildrenInfo(pageSidebarDiv);
sidebarInfo.addSourceChild(sidebarFacet);
creationData.addChildrenInfo(sidebarInfo);
@@ -166,8 +240,11 @@
if(footerFacet != null) {
pageFooterDiv = visualDocument.createElement(HTML.TAG_DIV);
pageFooterContentDiv = visualDocument.createElement(HTML.TAG_DIV);
-
- pageFooterDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_FOOTER);
+ String footerClass = CSS_PAGE_FOOTER;
+ if (ComponentUtil.isNotBlank(attrs.getFooterClass())) {
+ footerClass += Constants.WHITE_SPACE + attrs.getFooterClass();
+ }
+ pageFooterDiv.setAttribute(HTML.ATTR_CLASS, footerClass);
pageFooterContentDiv.setAttribute(HTML.ATTR_CLASS, CSS_PAGE_FOOTER_CONTENT);
pageFooterDiv.appendChild(pageFooterContentDiv);
@@ -181,6 +258,36 @@
return creationData;
}
+ /**
+ * Parses string width value from 'px' into 'em'.
+ *
+ * @param widthAttribute width attribute value.
+ * @return width value in 'em' or -1 if the value wasn't parsed.
+ */
+ private double parseWidth(String widthAttribute) {
+ double widthDouble = -1;
+ if (ComponentUtil.isNotBlank(widthAttribute)) {
+ try {
+ int widthInt = Integer.parseInt(widthAttribute);
+ /*
+ * Parse 'px' to 'em'.
+ */
+ widthDouble = widthInt / 13.33333;
+ /*
+ * Set Double fraction precision to 5 numbers.
+ */
+ BigDecimal b = new BigDecimal(widthDouble).setScale(5,
+ BigDecimal.ROUND_HALF_UP);
+ widthDouble = b.doubleValue();
+ } catch (NumberFormatException e) {
+ /*
+ * Do nothing, default width will be applied.
+ */
+ }
+ }
+ return widthDouble;
+ }
+
class Attributes {
/*
@@ -190,26 +297,29 @@
private final String CONTENT_CLASS = "contentClass"; //$NON-NLS-1$
private final String FOOTER_CLASS = "footerClass"; //$NON-NLS-1$
private final String HEADER_CLASS = "headerClass"; //$NON-NLS-1$
+ private final String SUBHEADER_CLASS = "subheaderClass"; //$NON-NLS-1$
private final String LANG = "lang"; //$NON-NLS-1$
private final String MARKUP_TYPE = "markupType"; //$NON-NLS-1$
private final String NAMESPACE = "namespace"; //$NON-NLS-1$
private final String PAGE_TITLE = "pageTitle"; //$NON-NLS-1$
private final String SIDERBAR_CLASS = "siderbarClass"; //$NON-NLS-1$
- private final String SIDERBAR_POSITION = "siderbarPosition"; //$NON-NLS-1$
- private final String SIDERBAR_WIDTH = "siderbarWidth"; //$NON-NLS-1$
+ private final String SIDEBAR_POSITION = "sidebarPosition"; //$NON-NLS-1$
+ private final String SIDEBAR_WIDTH = "sidebarWidth"; //$NON-NLS-1$
private final String THEME = "theme"; //$NON-NLS-1$
private String bodyClass;
private String contentClass;
private String footerClass;
private String headerClass;
+ private String subheaderClass;
+ private String dir;
private String lang;
private String markupType;
private String namespace;
private String pageTitle;
private String siderbarClass;
- private String siderbarPosition;
- private String siderbarWidth;
+ private String sidebarPosition;
+ private String sidebarWidth;
private String style;
private String styleClass;
private String theme;
@@ -220,13 +330,15 @@
contentClass = sourceElement.getAttribute(CONTENT_CLASS);
footerClass = sourceElement.getAttribute(FOOTER_CLASS);
headerClass = sourceElement.getAttribute(HEADER_CLASS);
+ subheaderClass = sourceElement.getAttribute(SUBHEADER_CLASS);
+ dir = sourceElement.getAttribute(HTML.ATTR_DIR);
lang = sourceElement.getAttribute(LANG);
markupType = sourceElement.getAttribute(MARKUP_TYPE);
namespace = sourceElement.getAttribute(NAMESPACE);
pageTitle = sourceElement.getAttribute(PAGE_TITLE);
siderbarClass = sourceElement.getAttribute(SIDERBAR_CLASS);
- siderbarPosition = sourceElement.getAttribute(SIDERBAR_POSITION);
- siderbarWidth = sourceElement.getAttribute(SIDERBAR_WIDTH);
+ sidebarPosition = sourceElement.getAttribute(SIDEBAR_POSITION);
+ sidebarWidth = sourceElement.getAttribute(SIDEBAR_WIDTH);
style = sourceElement.getAttribute(HTML.ATTR_STYLE);
styleClass = sourceElement.getAttribute(RichFaces.ATTR_STYLE_CLASS);
theme = sourceElement.getAttribute(THEME);
@@ -257,7 +369,15 @@
public String getHeaderClass() {
return headerClass;
}
+
+ public String getSubHeaderClass() {
+ return subheaderClass;
+ }
+ public String getDir() {
+ return dir;
+ }
+
public String getMarkupType() {
return markupType;
}
@@ -274,12 +394,12 @@
return siderbarClass;
}
- public String getSiderbarPosition() {
- return siderbarPosition;
+ public String getSidebarPosition() {
+ return sidebarPosition;
}
- public String getSiderbarWidth() {
- return siderbarWidth;
+ public String getSidebarWidth() {
+ return sidebarWidth;
}
public String getStyle() {
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageAllFacets.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageAllFacets.xhtml.xml 2009-06-01
14:18:36 UTC (rev 15622)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageAllFacets.xhtml.xml 2009-06-01
14:26:50 UTC (rev 15623)
@@ -1,7 +1,7 @@
<tests>
<test id="id1">
- <DIV STYLE="background-color: white;"
CLASS="rich-pagesomeClass">
+ <DIV STYLE="background-color: white;" CLASS="rich-page
someClass">
<DIV CLASS="rich-page-header">
<DIV CLASS="rich-page-header-content">
<SPAN STYLE="font-size: 2em;">
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml.xml 2009-06-01
14:18:36 UTC (rev 15622)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithLayout.xhtml.xml 2009-06-01
14:26:50 UTC (rev 15623)
@@ -1,27 +1,28 @@
<tests>
<test id="id1">
- <DIV STYLE="background-color: white;"
CLASS="rich-pagesomeClass">
- <DIV CLASS="rich-page-header">
+
+ <DIV CLASS="rich-page someClass" STYLE="width: 800px;
background-color: white;">
+ <DIV CLASS="rich-page-header headerClass">
<DIV CLASS="rich-page-header-content">
<SPAN STYLE="font-size: 2em;">
HEADER
</SPAN>
</DIV>
</DIV>
- <DIV CLASS="rich-page-subheader">
+ <DIV CLASS="rich-page-subheader subheaderClass">
<SPAN STYLE="font-size: 2em;">
SUBHEADER
- </SPAN>
+ </SPAN>
</DIV>
<DIV CLASS="rich-page-content">
- <DIV CLASS="rich-page-sidebar">
+ <DIV CLASS="rich-page-sidebar" STYLE="width: 15em; float:
right;">
<SPAN STYLE="font-size: 2em;">
SIDEBAR
</SPAN>
</DIV>
- <DIV CLASS="rich-page-main">
- <DIV CLASS="rich-page-body">
+ <DIV CLASS="rich-page-main" STYLE="float: left; margin-right:
-30em;">
+ <DIV CLASS="rich-page-body bodyClass" STYLE="margin-right:
15em;">
<H1 STYLE="-moz-user-modify: read-write;">
<SPAN CLASS="vpe-text">
BODY START
@@ -31,7 +32,7 @@
<DIV WIDTH="100%" STYLE="width: 100%;">
<SPAN CLASS="vpe-text">
TOP PANEL
- </SPAN>
+ </SPAN>
</DIV>
<DIV WIDTH="50%" STYLE="width: 50%; float: left;">
<SPAN CLASS="vpe-text">
@@ -56,7 +57,7 @@
</DIV>
</DIV>
</DIV>
- <DIV CLASS="rich-page-footer">
+ <DIV CLASS="rich-page-footer footerClass">
<DIV CLASS="rich-page-footer-content">
<SPAN STYLE="font-size: 2em;">
FOOTER
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithNestedLayouts.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithNestedLayouts.xhtml.xml 2009-06-01
14:18:36 UTC (rev 15622)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/page/pageWithNestedLayouts.xhtml.xml 2009-06-01
14:26:50 UTC (rev 15623)
@@ -1,6 +1,6 @@
<tests>
<test id="id1">
- <DIV STYLE="background-color: white;"
CLASS="rich-pagesomeClass">
+ <DIV STYLE="width: 600px; background-color: white;" CLASS="rich-page
someClass">
<DIV CLASS="rich-page-header">
<DIV CLASS="rich-page-header-content">
<SPAN STYLE="font-size: 2em;">