JBoss Rich Faces SVN: r13281 - in trunk/ui: componentControl/src/main/java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-03-30 05:08:16 -0400 (Mon, 30 Mar 2009)
New Revision: 13281
Modified:
trunk/ui/componentControl/src/main/config/component/componentControl.xml
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
Log:
https://jira.jboss.org/jira/browse/RF-6275
This fix should be done in contextMenu and not in componentControl
Modified: trunk/ui/componentControl/src/main/config/component/componentControl.xml
===================================================================
--- trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-03-30 08:42:21 UTC (rev 13280)
+++ trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-03-30 09:08:16 UTC (rev 13281)
@@ -37,7 +37,6 @@
<description>
Disable default action for target event ( append "return false;" to JavaScript )
</description>
- <defaultvalue><![CDATA[getEvent().equalsIgnoreCase("onContextMenu")]]></defaultvalue>
</property>
<property>
<name>event</name>
Modified: trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
--- trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-03-30 08:42:21 UTC (rev 13280)
+++ trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-03-30 09:08:16 UTC (rev 13281)
@@ -21,9 +21,7 @@
package org.richfaces.component;
-import javax.el.ELException;
import javax.el.ValueExpression;
-import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIParameter;
@@ -44,8 +42,8 @@
* JSF component class
*
*/
-public abstract class UIComponentControl extends UIComponentBase implements
- AjaxSupport {
+public abstract class UIComponentControl extends UIComponentBase
+ implements AjaxSupport {
public static final String COMPONENT_TYPE = "org.richfaces.ComponentControl";
@@ -53,19 +51,6 @@
private static final Log log = LogFactory.getLog(UIComponentControl.class);
- /*
- * Disable default action for target event ( append "return false;" to
- * JavaScript )
- */
- public static final String DISABLE_DEFAULT = "disableDefault";
-
- private boolean disableDefault = false;
-
- private boolean disableDefaultSet = false;
-
- public static final String ON_CONTEXT_MENU = "onContextMenu";
-
-
/**
* @return JavaScript eventString. Rebuild on every call, since can be in
* loop ( as in dataTable ) with different parameters.
@@ -212,46 +197,4 @@
public abstract void setAttachTiming(String attachTiming);
public abstract String getAttachTiming();
-
- public boolean isDisableDefault() {
- if (this.disableDefaultSet) {
- return ON_CONTEXT_MENU.equalsIgnoreCase(getEvent());
- }
-
- ValueExpression ve = getValueExpression(DISABLE_DEFAULT);
- if (ve != null) {
- try {
- Boolean value = (Boolean) ve.getValue(getFacesContext().getELContext());
- if (value != null) {
- return value;
- }
- } catch (ELException e) {
- throw new FacesException(e);
- }
- }
-
- return this.disableDefault;
- }
-
- public void setDisableDefault(boolean disableDefault) {
- this.disableDefault = disableDefault;
- this.disableDefaultSet = true;
- }
-
- @Override
- public Object saveState(FacesContext context) {
- Object[] state = new Object[9];
- state[0] = super.saveState(context);
- state[1] = disableDefault;
- state[2] = disableDefaultSet;
- return state;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- Object[] states = (Object[]) state;
- super.restoreState(context, states[0]);
- disableDefault = (Boolean) states[1];
- disableDefaultSet = (Boolean) states[2];
- }
}
Modified: trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
===================================================================
--- trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2009-03-30 08:42:21 UTC (rev 13280)
+++ trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2009-03-30 09:08:16 UTC (rev 13281)
@@ -58,7 +58,7 @@
<description>
Forbids default handling for adjusted event. Default value "true".
</description>
- <defaultvalue>false</defaultvalue>
+ <defaultvalue><![CDATA[getEvent().equalsIgnoreCase("onContextMenu")]]></defaultvalue>
</property>
<property>
<name>showDelay</name>
Modified: trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
===================================================================
--- trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java 2009-03-30 08:42:21 UTC (rev 13280)
+++ trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java 2009-03-30 09:08:16 UTC (rev 13281)
@@ -21,7 +21,11 @@
package org.richfaces.component;
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
/**
* @author Maksim Kaszynski
@@ -30,27 +34,66 @@
public abstract class UIContextMenu extends UIComponentBase implements MenuComponent {
public static final String COMPONENT_TYPE = "org.richfaces.ContextMenu";
+ public static final String ON_CONTEXT_MENU = "onContextMenu";
+ public static final String DISABLE_DEFAULT_MENU = "disableDefaultMenu";
+
+ private boolean disableDefaultMenu = false;
+ private boolean disableDefaultMenuSet = false;
+
public abstract boolean isAttached();
-
public abstract void setAttached(boolean b);
-
+
public abstract String getAttachTo();
-
public abstract void setAttachTo(String attachTo);
public abstract String getAttachTiming();
-
public abstract void setAttachTiming(String attachTo);
public abstract String getEvent();
-
public abstract void setEvent(String event);
- public abstract boolean isDisableDefaultMenu();
-
- public abstract void setDisableDefaultMenu(boolean b);
-
public abstract void setShowDelay(Integer showDelay);
public abstract Integer getShowDelay();
+ public boolean isDisableDefaultMenu() {
+ if (this.disableDefaultMenuSet) {
+ return ON_CONTEXT_MENU.equalsIgnoreCase(getEvent());
+ }
+
+ ValueExpression ve = getValueExpression(DISABLE_DEFAULT_MENU);
+ if (ve != null) {
+ try {
+ Boolean value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ if (value != null) {
+ return value;
+ }
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ return this.disableDefaultMenu;
+ }
+
+ public void setDisableDefaultMenu(boolean disableDefault) {
+ this.disableDefaultMenu = disableDefault;
+ this.disableDefaultMenuSet = true;
+ }
+
+ @Override
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[9];
+ state[0] = super.saveState(context);
+ state[1] = isDisableDefaultMenu();
+ state[2] = disableDefaultMenuSet;
+ return state;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object state) {
+ Object[] states = (Object[]) state;
+ super.restoreState(context, states[0]);
+ disableDefaultMenu = (Boolean) states[1];
+ disableDefaultMenuSet = (Boolean) states[2];
+ }
}
15 years, 1 month
JBoss Rich Faces SVN: r13280 - trunk/test-applications/richfaces-docs/web/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-03-30 04:42:21 -0400 (Mon, 30 Mar 2009)
New Revision: 13280
Added:
trunk/test-applications/richfaces-docs/web/src/main/webapp/richPage.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-6419https://jira.jboss.org/jira/bro...
added new features
Added: trunk/test-applications/richfaces-docs/web/src/main/webapp/richPage.xhtml
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/webapp/richPage.xhtml (rev 0)
+++ trunk/test-applications/richfaces-docs/web/src/main/webapp/richPage.xhtml 2009-03-30 08:42:21 UTC (rev 13280)
@@ -0,0 +1,33 @@
+<f:view xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+
+<rich:page sidebarPosition="left" sidebarWidth="300"
+ theme="" title="advisory" contentType="text/html; charset=UTF-8" >
+
+ <f:facet name="pageHeader" >
+ <title>Page Title 2</title>
+<link href="stylesheet/theme.css" rel="stylesheet" type="text/css" />
+ </f:facet>
+
+ <f:facet name="header" >
+ <ui:include src="layout/menu.xhtml">
+ <ui:param name="projectName" value="RichFaces Docs"/>
+ </ui:include>
+
+ </f:facet>
+
+ <f:facet name="sidebar">
+<ui:include src="layout/mainMenu.xhtml" />
+ </f:facet>
+ <p>body content</p>
+
+ <f:facet name="footer">
+ footer content
+ </f:facet>
+ </rich:page>
+
+</f:view>
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r13279 - trunk/test-applications/richfaces-docs/web/src/main/webapp/stylesheet.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-03-30 04:41:51 -0400 (Mon, 30 Mar 2009)
New Revision: 13279
Modified:
trunk/test-applications/richfaces-docs/web/src/main/webapp/stylesheet/theme.css
Log:
https://jira.jboss.org/jira/browse/RF-6419https://jira.jboss.org/jira/bro...
added new features
Modified: trunk/test-applications/richfaces-docs/web/src/main/webapp/stylesheet/theme.css
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/webapp/stylesheet/theme.css 2009-03-30 08:39:16 UTC (rev 13278)
+++ trunk/test-applications/richfaces-docs/web/src/main/webapp/stylesheet/theme.css 2009-03-30 08:41:51 UTC (rev 13279)
@@ -135,7 +135,7 @@
.dr-toolbar-int {padding: 2px 3px 2px 3px;}
-.menuToolBar .rich-toolbar-item {font-weight: 100; font-size: 10px;}
+
.dr-pnl-b .simpletext p {font-size: 12px;}
#mainMenu {text-align: left;}
@@ -144,4 +144,10 @@
.tableofattributes thead td {background: #F0F8FF; font-weight: 900; padding-left: 5px;}
.tableofattributes tbody td {padding-left: 5px; border-bottom: 1px solid #8fbde6 }
-.bodyClass {border: 1px solid black;}
\ No newline at end of file
+.bodyClass {border: 1px solid black;}
+
+.rich-page {margin: 0px; padding: 0px;}
+.rich-page-main{float:right;margin-left:-25em;}
+.rich-page-sidebar{float:left;width:23.076923em;*width:22.500563em;}
+.rich-page-body{margin-left:24.076923em;*marginleft:23.475563em;}
+.rich-page-body{float:none;width:auto;}
15 years, 1 month
JBoss Rich Faces SVN: r13278 - trunk/test-applications/richfaces-docs/web/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-03-30 04:39:16 -0400 (Mon, 30 Mar 2009)
New Revision: 13278
Modified:
trunk/test-applications/richfaces-docs/web/src/main/webapp/layout.xhtml
trunk/test-applications/richfaces-docs/web/src/main/webapp/page.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-6419https://jira.jboss.org/jira/bro...
added new features
Modified: trunk/test-applications/richfaces-docs/web/src/main/webapp/layout.xhtml
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/webapp/layout.xhtml 2009-03-30 08:38:11 UTC (rev 13277)
+++ trunk/test-applications/richfaces-docs/web/src/main/webapp/layout.xhtml 2009-03-30 08:39:16 UTC (rev 13278)
@@ -17,71 +17,31 @@
<rich:panel>
- <f:facet name="header">Layout Components: rich:page, rich:layout, rich:layoutPanel </f:facet>
+ <f:facet name="header">Layout Components: rich:layout and rich:layoutPanel </f:facet>
+
-<h3>Case 1: rich:page + rich:layout + rich:layoutPanel</h3>
-
-<rich:page sidebarPosition="left" style="border: 1px solid black" sidebarWidth="300" theme="#{layout.theme}" pageTitle="Rich:page">
- <f:facet name="header">
- header
- </f:facet>
- <f:facet name="sidebar">
-menu stuff
- </f:facet>
- <rich:layout >
-
- <rich:layoutPanel position="left" width="33*">
- <rich:layoutPanel position="left" width="33*">
- <p> inner left part of the body</p>
-
-
- </rich:layoutPanel>
-
-
-
- <rich:layoutPanel position="center" width="33*">
- <p>inner left part of the body</p>
- </rich:layoutPanel>
-
-
- </rich:layoutPanel>
-
-
-
- <rich:layoutPanel position="center" width="33*">
- <p> left part of the body</p>
- </rich:layoutPanel>
-
-
-
- </rich:layout>
- <f:facet name="footer">
- footer
- </f:facet>
- </rich:page>
-
-
- <h3>Case 2: rich:page + rich:layout + rich:layoutPanel</h3>
-
-
+ <rich:layout>
+ <rich:layoutPanel position="right">
+ <p>right</p>
+ <rich:layout>
- <rich:layout style="border 1px solid black">
+ <rich:layoutPanel position="top">
+ <p>top</p>
+ </rich:layoutPanel>
+ <rich:layoutPanel position="center">
+ <p> center - bottom</p>
+ </rich:layoutPanel>
+ </rich:layout>
+ </rich:layoutPanel>
+
+ <rich:layoutPanel position="center">
+ <p> center-left</p>
+ </rich:layoutPanel>
+ </rich:layout>
- <rich:layoutPanel position="left" >
- <p> left part of the body</p>
- </rich:layoutPanel>
- <rich:layoutPanel position="center" >
- <p> right part of the body</p>
- </rich:layoutPanel>
- <rich:layoutPanel position="right" >
- <p> right part of the body</p>
- </rich:layoutPanel>
-
-
- </rich:layout>
-
-
-
+
+
+
<table class="tableofattributes" cellpadding="0" cellspacing="0">
<thead>
@@ -102,15 +62,7 @@
Theme
</td>
<td>
- <h:form>
- <h:selectOneMenu value="#{layout.theme}" onchange="submit()">
- <f:selectItem itemLabel="Default" itemValue="" />
- <f:selectItem itemLabel="simple" itemValue="simple" />
- <f:selectItem itemLabel="csszend" itemValue="csszend" />
-
-
- </h:selectOneMenu>
- </h:form>
+
</td>
</tr>
Modified: trunk/test-applications/richfaces-docs/web/src/main/webapp/page.xhtml
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/webapp/page.xhtml 2009-03-30 08:38:11 UTC (rev 13277)
+++ trunk/test-applications/richfaces-docs/web/src/main/webapp/page.xhtml 2009-03-30 08:39:16 UTC (rev 13278)
@@ -17,19 +17,55 @@
<rich:panel>
+ <p>A page with the rich:page component can be found <a href="richPage.xhtml" style="display:inline">here</a>.</p>
<f:facet name="header">Layout Components: rich:page, rich:layout, rich:layoutPanel </f:facet>
-<h3>Case 1: Simple variant</h3>
+<h3>Listing 1: pageTitle, markupType and pageHeader facet</h3>
-<rich:page width="600px">
-<p>some content</p>
+<rich:page markupType="#{page.markupType}" pageTitle="#{page.pageTitle}" contentType="text/html; charset=UTF-8" >
+ <f:facet name="pageHeader" title="advisory" >
+ <meta content="The rich:page component" name="keywords" />
+ <link rel="shortcut icon" href="/images/favicon.ico"/>
+ <link href="/css/style.css" rel="stylesheet" type="text/css" />
+ <script type="text/javascript" src="/js/menu.js"></script>
+ </f:facet>
+ <!-- page content -->
+ <p> page content </p>
</rich:page>
+
+
-<h3>Case 2: with facets</h3>
+<h3>Listing 2: facets "header", "sidebar" and "footer"</h3>
-<rich:page sidebarPosition="right" sidebarWidth="300" bodyClass="bodyClass">
+<rich:page sidebarPosition="right" sidebarWidth="300">
<f:facet name="header" >
+ header content
+
+ </f:facet>
+
+ <f:facet name="sidebar">
+side bar content
+ </f:facet>
+ <p>body content</p>
+
+ <f:facet name="footer">
+ footer content
+ </f:facet>
+ </rich:page>
+
+
+<h3>Listing 3: with classes attributes</h3>
+
+
+
+ <rich:page sidebarPosition="right" sidebarWidth="300"
+bodyClass="myBodyClass"
+footerClass="myFooterClass"
+headerClass="myHeaderClass"
+sidebarClass="mySidebarClass"
+>
+ <f:facet name="header" >
header content
</f:facet>
@@ -43,11 +79,36 @@
footer content
</f:facet>
</rich:page>
+
+
+
+ <h3>Listing 4: t</h3>
+
+
+
+ <rich:page sidebarPosition="right" sidebarWidth="300"
+theme="#{page.theme}"
+>
+ <f:facet name="header" >
+ header content
+
+ </f:facet>
+
+ <f:facet name="sidebar">
+side bar content
+ </f:facet>
+ <p>body content</p>
+
+ <f:facet name="footer">
+ footer content
+ </f:facet>
+ </rich:page>
-
-
-<table class="tableofattributes" cellpadding="0" cellspacing="0">
+
+
+
+<table class="tableofattributes" cellpadding="0" cellspacing="0" >
<thead>
@@ -67,7 +128,7 @@
</td>
<td>
<h:form>
- <h:selectOneMenu value="#{layout.theme}" onchange="submit()">
+ <h:selectOneMenu value="#{page.theme}" onchange="submit()">
<f:selectItem itemLabel="Default" itemValue="" />
<f:selectItem itemLabel="simple" itemValue="simple" />
<f:selectItem itemLabel="csszend" itemValue="csszend" />
@@ -79,6 +140,36 @@
</tr>
+ <tr>
+ <td>
+ markupType
+ </td>
+ <td>
+ <h:form>
+ <h:selectOneMenu value="#{page.markupType}" onchange="submit()">
+ <f:selectItem itemLabel="html" itemValue="html" />
+ <f:selectItem itemLabel="xhtml" itemValue="xhtml" />
+ <f:selectItem itemLabel="html-transitional" itemValue="html-transitional" />
+ <f:selectItem itemLabel="html-3.2" itemValue="html-3.2" />
+
+ </h:selectOneMenu>
+ </h:form>
+ </td>
+ </tr>
+
+
+ <tr>
+ <td>
+ page title
+ </td>
+ <td>
+ <h:form>
+ <h:inputText value="#{page.pageTitle}" onchange="submit()"/>
+ </h:form>
+ </td>
+ </tr>
+
+
</tbody>
15 years, 1 month
JBoss Rich Faces SVN: r13277 - trunk/test-applications/richfaces-docs/web/src/main/java/org/docs.
by richfaces-svn-commits@lists.jboss.org
Author: msorokin
Date: 2009-03-30 04:38:11 -0400 (Mon, 30 Mar 2009)
New Revision: 13277
Added:
trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Page.java
Modified:
trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Layout.java
Log:
Modified: trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Layout.java
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Layout.java 2009-03-29 15:06:38 UTC (rev 13276)
+++ trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Layout.java 2009-03-30 08:38:11 UTC (rev 13277)
@@ -10,17 +10,7 @@
public class Layout {
-String theme;
-public String getTheme() {
- return theme;
-}
-
-public void setTheme(String theme) {
- this.theme = theme;
-}
-
-
Added: trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Page.java
===================================================================
--- trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Page.java (rev 0)
+++ trunk/test-applications/richfaces-docs/web/src/main/java/org/docs/Page.java 2009-03-30 08:38:11 UTC (rev 13277)
@@ -0,0 +1,47 @@
+/**
+ *
+ */
+package org.docs;
+
+/**
+ * @author Michael Sorokin
+ *
+ */
+public class Page {
+
+ private String markupType;
+ private String theme;
+private String pageTitle;
+
+
+
+
+ public String getPageTitle() {
+ return pageTitle;
+}
+
+public void setPageTitle(String pageTitle) {
+ this.pageTitle = pageTitle;
+}
+
+ public String getTheme() {
+ return theme;
+ }
+
+ public void setTheme(String theme) {
+ this.theme = theme;
+ }
+
+
+
+ public String getMarkupType() {
+ return markupType;
+ }
+
+ public void setMarkupType(String markupType) {
+ this.markupType = markupType;
+ }
+
+
+
+}
15 years, 1 month
JBoss Rich Faces SVN: r13276 - trunk/ui/dataTable/src/test/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-03-29 11:06:38 -0400 (Sun, 29 Mar 2009)
New Revision: 13276
Modified:
trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java
Log:
Test for https://jira.jboss.org/jira/browse/RF-6555
Modified: trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java
===================================================================
--- trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java 2009-03-28 16:22:49 UTC (rev 13275)
+++ trunk/ui/dataTable/src/test/java/org/richfaces/renderkit/DataTableRenderingTest.java 2009-03-29 15:06:38 UTC (rev 13276)
@@ -25,6 +25,7 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.el.ELContext;
import javax.el.ValueExpression;
@@ -183,8 +184,10 @@
*/
public void testRenderDataTable() throws Exception {
// setUp
- dataTable.getAttributes().put("columnsWidth", "400px,200px");
-
+ final Map<String, Object> attributes = dataTable.getAttributes();
+ attributes.put("columnsWidth", "400px,200px");
+ attributes.put("onRowMouseOver", "onRowMouseOver");
+
UIColumn column3 = (UIColumn) application.createComponent("org.richfaces.Column");
column3.setId("local_column3");
dataTable.getChildren().add(column3);
@@ -228,11 +231,17 @@
assertNotNull(tr);
classAttr = tr.getAttributeValue("class");
assertTrue(classAttr.contains("dr-table-firstrow rich-table-firstrow"));
+ classAttr = tr.getAttributeValue("onmouseover");
+ assertTrue(classAttr.contains("onRowMouseOver"));
for (int i = 1; i < trs.size(); i++) {
tr = (HtmlElement) trs.get(i);
assertNotNull(tr);
+
+ classAttr = tr.getAttributeValue("onmouseover");
+ assertTrue("Row i = " + i + " must have onmouseover attribute",
+ classAttr.contains("onRowMouseOver"));
+
classAttr = tr.getAttributeValue("class");
-
assertFalse("Row i = " + i + " have 'dr-table-firstrow' style",
classAttr.contains("dr-table-firstrow"));
assertFalse("Row i = " + i + " have 'rich-table-firstrow' style",
15 years, 1 month
JBoss Rich Faces SVN: r13275 - in trunk/ui/editor: src/main and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-03-28 12:22:49 -0400 (Sat, 28 Mar 2009)
New Revision: 13275
Added:
trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamSAXParser.java
trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamTransformer.java
trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/Tag.java
trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/TagFactory.java
Removed:
trunk/ui/editor/src/main/antlr/
Modified:
trunk/ui/editor/pom.xml
trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/DefaultSeamTextConverter.java
trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
Log:
sax parser for transformation html to seam text
https://jira.jboss.org/jira/browse/RF-5825
Modified: trunk/ui/editor/pom.xml
===================================================================
--- trunk/ui/editor/pom.xml 2009-03-28 00:31:19 UTC (rev 13274)
+++ trunk/ui/editor/pom.xml 2009-03-28 16:22:49 UTC (rev 13275)
@@ -39,24 +39,6 @@
</library>
</configuration>
</plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>antlr-maven-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <grammars>html-seamtext.g</grammars>
- </configuration>
- </plugin>
-
-
</plugins>
</build>
<profiles>
Modified: trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/DefaultSeamTextConverter.java
===================================================================
--- trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/DefaultSeamTextConverter.java 2009-03-28 00:31:19 UTC (rev 13274)
+++ trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/DefaultSeamTextConverter.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -38,8 +38,6 @@
import org.jboss.seam.text.SeamTextLexer;
import org.jboss.seam.text.SeamTextParser;
-import org.richfaces.antlr.HtmlSeamTextLexer;
-import org.richfaces.antlr.HtmlSeamTextParser;
/**
* Seam Text Converter class. Provides converting html to seam text and vice versa.
@@ -61,14 +59,12 @@
}
try {
- Reader r = new StringReader(value);
- HtmlSeamTextLexer lexer = new HtmlSeamTextLexer(r);
- HtmlSeamTextParser parser = new HtmlSeamTextParser(lexer);
- parser.startRule();
- return parser.toString();
+ return HtmlToSeamSAXParser.convertHtmlToSeamText(value);
} catch (Exception e) {
- FacesMessage message = new FacesMessage("An error occurred during conversion html to seam text",e.getMessage());
+ FacesMessage message = new FacesMessage(
+ "An error occurred during conversion html to seam text", e.getMessage());
+
throw new ConverterException(message,e);
}
Added: trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamSAXParser.java
===================================================================
--- trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamSAXParser.java (rev 0)
+++ trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamSAXParser.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -0,0 +1,227 @@
+package org.richfaces.convert.seamtext;
+
+import antlr.SemanticException;
+import antlr.Token;
+import com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser;
+import com.sun.org.apache.xerces.internal.parsers.SAXParser;
+import org.jboss.seam.text.SeamTextParser;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+
+/**
+ * @user: akolonitsky
+ * Date: Mar 24, 2009
+ */
+public class HtmlToSeamSAXParser extends DefaultHandler {
+ private static final TagFactory TAG_FACTORY = new TagFactory();
+
+ public static final String ROOT_TAG_NAME = "root";
+ public static final Tag ROOT_TAG = TAG_FACTORY.getInstance(ROOT_TAG_NAME);
+
+ private SeamTextParser.Sanitizer sanitizer = new SeamTextParser.DefaultSanitizer();
+ private HtmlToSeamTransformer transformer;
+
+ private Stack<Tag> tagStack;
+
+ public HtmlToSeamSAXParser() {
+ tagStack = new Stack<Tag>();
+
+ transformer = new HtmlToSeamTransformer();
+ transformer.setHtmlElementStack(tagStack);
+ }
+
+ public static String convertHtmlToSeamText(final String html) throws IOException, SAXException {
+ final HtmlToSeamSAXParser t = new HtmlToSeamSAXParser();
+ final AbstractSAXParser p = new SAXParser();
+ p.setContentHandler(t);
+ try {
+ p.setFeature("http://xml.org/sax/features/namespaces", false);
+ p.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+ } catch (SAXException e) {
+ e.printStackTrace(); // TODO
+ }
+ final StringBuilder str = new StringBuilder(html.length() + 2*ROOT_TAG_NAME.length() + 5);
+ str.append('<').append(ROOT_TAG_NAME).append('>').append(html).append("</").append(ROOT_TAG_NAME).append('>');
+
+ p.parse(new InputSource(new StringReader(str.toString())));
+
+ return t.getTransformer().toString();
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) {
+ if (!tagStack.isEmpty()){
+ tagStack.peek().setNotEmpty();
+ }
+
+ if (ROOT_TAG_NAME.equalsIgnoreCase(qName)) {
+ tagStack.push(ROOT_TAG);
+ } else if (hasInvalidParentTag()) {
+ if (!isValidTag(qName)) {
+ tagStack.push(TAG_FACTORY.getInstance(qName, processAttr(qName, attributes)));
+ }
+
+ } else {
+ final Tag tag = TAG_FACTORY.getInstance(qName, processAttr(qName, attributes)); // process attr invoked when it is invalid tag? is is can be optimized
+ if (isValidTag(tag)) {
+ transformer.openTag(tag);
+ } else {
+ setFirstInvalidTag(tag);
+ }
+
+ tagStack.push(tag); // 'push' must be after transformer.openTag(tag);
+ }
+ }
+
+ private Map<String, String> processAttr(final String tag, Attributes attributes) {
+ final Map<String, String> map = new HashMap<String, String>(attributes.getLength());
+ for (int i = 0; i < attributes.getLength(); i++) {
+ if (isValidAttr(tag, attributes.getQName(i))) {
+ map.put(attributes.getQName(i), attributes.getValue(i));
+ }
+ }
+
+ return map;
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) {
+ final Tag tag;
+
+ if (ROOT_TAG_NAME.equalsIgnoreCase(qName)) {
+ tag = tagStack.pop();
+ if (!ROOT_TAG_NAME.equalsIgnoreCase(tag.getName())) {
+ throw new IllegalStateException("Last tag must be '"+ ROOT_TAG_NAME +"', you have " + qName);
+ }
+ } else if (hasInvalidParentTag()) {
+ if (!isValidTag(qName)) {
+ tag = tagStack.pop();
+ if (tag == getFirstInvalidTag()) { // it is must be same tag(object)
+ cleanInvalidTag();
+ }
+ }
+
+ } else {
+ tag = tagStack.pop();
+
+ if (isValidTag(tag.getName())) {
+ transformer.closeTagWithBody(tag);
+ } else {
+ throw new IllegalStateException("Sometning wrong! You can't have invalid tag at here!");
+ }
+ }
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length) {
+ while (start < length) {
+ switch (ch[start]) {
+ case ' ': case '\t':
+ transformer.space(ch, start, length);
+ break;
+
+ case '\r': case '\n':
+ transformer.newline(ch, start, length);
+ break;
+
+ default:
+ throw new IllegalStateException("Unknow char : '" + ch[start] + '\'');
+ }
+ start++;
+ }
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) {
+ if (!tagStack.isEmpty()){
+ tagStack.peek().setNotEmpty();
+ }
+
+ transformer.text(ch, start, length);
+ }
+
+ /*
+ * Vlidation by sanitizer
+ * */
+ private static final class FakeToken extends Token {
+ private String text;
+
+ private FakeToken(final int t, final String txt) {
+ super(t, txt);
+ }
+
+ @Override
+ public String getText() {
+ return text;
+ }
+
+ @Override
+ public void setText(final String t) {
+ this.text = t;
+ }
+ }
+
+ private boolean isValidAttr(String tag, String name) {
+ try {
+ sanitizer.validateHtmlAttribute(new FakeToken(0, tag), new FakeToken(0, name));
+ } catch (SemanticException e) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isValidTag(String tagName) {
+ try {
+ sanitizer.validateHtmlElement(new FakeToken(0, tagName));
+ } catch (SemanticException e) {
+ return false;
+ }
+ return true;
+ }
+
+ private boolean isValidTag(Tag tag) {
+ return isValidTag(tag.getName());
+ }
+
+ /*
+ * Handling invalid tags by sanitizer
+ * */
+ private Tag firstInvalidTag = null;
+
+ private boolean hasInvalidParentTag() {
+ return firstInvalidTag != null;
+ }
+
+ private void cleanInvalidTag() {
+ this.firstInvalidTag = null;
+ }
+
+ private void setFirstInvalidTag(Tag firstInvalidTag) {
+ this.firstInvalidTag = firstInvalidTag;
+ }
+
+ private Tag getFirstInvalidTag() {
+ return this.firstInvalidTag;
+ }
+
+ /*
+ * Getters and Setters
+ * */
+
+ public HtmlToSeamTransformer getTransformer() {
+ return transformer;
+ }
+
+ public void setTransformer(HtmlToSeamTransformer transformer) {
+ this.transformer = transformer;
+ }
+}
Added: trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamTransformer.java
===================================================================
--- trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamTransformer.java (rev 0)
+++ trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/HtmlToSeamTransformer.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -0,0 +1,449 @@
+package org.richfaces.convert.seamtext;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Stack;
+
+/**
+ * @user: akolonitsky
+ * Date: Mar 24, 2009
+ */
+public class HtmlToSeamTransformer {
+
+ private static final String HTML_A = "a";
+ private static final String HTML_H1 = "h1";
+ private static final String HTML_H2 = "h2";
+ private static final String HTML_H3 = "h3";
+ private static final String HTML_H4 = "h4";
+ private static final String HTML_P = "p";
+ private static final String HTML_UL = "ul";
+ private static final String HTML_OL = "ol";
+ private static final String HTML_LI = "li";
+ private static final String HTML_PRE = "pre";
+ private static final String HTML_TT = "tt";
+ private static final String HTML_DEL = "del";
+ private static final String HTML_SUP = "sup";
+ private static final String HTML_Q = "q";
+ private static final String HTML_I = "i";
+ private static final String HTML_U = "u";
+ private static final String HTML_BLOCKQOUTE = "blockqoute";
+
+ private static final String SEAM_MONOSPACE = "|";
+ private static final String SEAM_TWIDDLE = "~";
+ private static final String SEAM_HASH = "#";
+ private static final String SEAM_HAT = "^";
+ private static final String SEAM_PLUS = "+";
+ private static final String SEAM_STAR = "*";
+ private static final String SEAM_UNDERSCORE = "_";
+ private static final String SEAM_EQ = "=";
+ private static final String SEAM_BACKTICK = "`";
+ private static final String SEAM_DOUBLEQUOTE = "\"";
+ private static final String SEAM_LINK_START = "[";
+ private static final String SEAM_LINK_END = "]";
+
+ private static final String SEAM_GT = ">";
+ private static final String SEAM_LT = "<";
+ private static final String SEAM_AMP = "&";
+
+ private static final String BLANK_LINE = "\n\n";
+
+ public boolean preformatted = false;
+
+ private static final Collection<String> SEAM_TEXT_SYMBOLS = new HashSet<String>(Arrays.asList(
+ SEAM_MONOSPACE,
+ SEAM_TWIDDLE,
+ SEAM_HASH,
+ SEAM_HAT,
+ SEAM_PLUS,
+ SEAM_STAR,
+ SEAM_UNDERSCORE,
+ SEAM_EQ,
+ SEAM_BACKTICK,
+ SEAM_DOUBLEQUOTE,
+ SEAM_LINK_START,
+ SEAM_LINK_END,
+ SEAM_LT,
+ SEAM_GT,
+ SEAM_AMP,
+
+ BLANK_LINE
+ ));
+
+
+ private static final Collection<String> SIMPLE_HTML_SEAM_TEXT_ELEMENTS = new HashSet<String>(Arrays.asList(
+ HTML_DEL,
+ HTML_SUP,
+ HTML_PRE,
+ HTML_Q,
+ HTML_I,
+ HTML_TT,
+ HTML_U));
+
+ private static final Collection<String> FORMATTED_HTML_SEAM_TEXT_ELEMENTS = new HashSet<String>(Arrays.asList(
+ HTML_H1,
+ HTML_H2,
+ HTML_H3,
+ HTML_H4,
+ HTML_P,
+ HTML_UL,
+ HTML_OL,
+ HTML_LI,
+ HTML_A,
+ HTML_BLOCKQOUTE));
+
+ private static final Collection<String> HTML_SEAM_TEXT_ELEMENTS =
+ new HashSet<String>(SIMPLE_HTML_SEAM_TEXT_ELEMENTS.size() + FORMATTED_HTML_SEAM_TEXT_ELEMENTS.size());
+ static {
+ HTML_SEAM_TEXT_ELEMENTS.addAll(SIMPLE_HTML_SEAM_TEXT_ELEMENTS);
+ HTML_SEAM_TEXT_ELEMENTS.addAll(FORMATTED_HTML_SEAM_TEXT_ELEMENTS);
+ }
+
+ private Stack<Tag> htmlElementStack = new Stack<Tag>();
+
+ public Stack<Tag> getHtmlElementStack() {
+ return htmlElementStack;
+ }
+
+ public void setHtmlElementStack(Stack<Tag> htmlElementStack) {
+ this.htmlElementStack = htmlElementStack;
+ }
+
+ private StringBuilder mainBuilder = new StringBuilder();
+
+ private boolean isHeaderProcessed = false;
+
+ private boolean isFirstChars = false;
+
+ private StringBuilder builder = mainBuilder;
+
+ public StringBuilder newLinesCollector;
+
+ @Override
+ public String toString() {
+ return builder.toString();
+ }
+
+ private void append(String ... strings) {
+ for (String str : strings) {
+ builder.append(str);
+ }
+ }
+
+ public boolean isLink(Tag tag) {
+ return HTML_A.equalsIgnoreCase(tag.getName());
+ }
+
+ public boolean isHeader(Tag tag) {
+ final String name = tag.getName().toLowerCase();
+ return HTML_H1.equals(name) || HTML_H2.equals(name) || HTML_H3.equals(name) || HTML_H4.equals(name);
+ }
+
+ public boolean isParagraph(Tag tag) {
+ return HTML_P.equalsIgnoreCase(tag.getName());
+ }
+
+ public boolean isList(Tag token) {
+ final String name = token.getName().toLowerCase();
+ return HTML_UL.equals(name) || HTML_OL.equals(name);
+ }
+
+ public boolean isListItem(Tag token) {
+ final String name = token.getName().toLowerCase();
+ return HTML_LI.equals(name);
+ }
+
+ public boolean isPreFormattedElement(Tag tag) {
+ final String name = tag.getName().toLowerCase();
+ return HTML_PRE.equals(name) || HTML_TT.equals(name);
+ }
+
+ public String createSeamTextList() {
+ final String seamText;
+
+ final Tag parent = htmlElementStack.peek();
+ final String parentName = parent.getName().toLowerCase();
+ if (parentName.equals(HTML_UL)) {
+ seamText = SEAM_EQ;
+ } else if (parentName.equals(HTML_OL)) {
+ seamText = SEAM_HASH;
+ } else {
+ throw new IllegalStateException("<li> must follow <ol> or <ul> not <" + parent.getName() + '>');
+ }
+
+ return seamText;
+ }
+
+ public boolean isPlainHtmlRequired(Tag name) {
+
+ if (!isSeamTextElement(name)) {
+ return true;
+ }
+
+ if (isSimpleSeamTextElement(name)) {
+ return false;
+ }
+
+ if (!HTML_A.equals(name.getName().toLowerCase())
+ && !HTML_P.equals(name.getName().toLowerCase())) {
+
+ for (Tag token : htmlElementStack) {
+ if (isHeader(token) || isListItem(token)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ public String getSimpleSeamText(Tag tag) {
+
+ final String name = tag.getName().toLowerCase();
+ final StringBuilder seamText = new StringBuilder();
+
+ if (HTML_TT.equals(name)) {
+ seamText.append(SEAM_MONOSPACE);
+ } else if (HTML_DEL.equals(name)) {
+ seamText.append(SEAM_TWIDDLE);
+ } else if (HTML_I.equals(name)) {
+ seamText.append(SEAM_STAR);
+ } else if (HTML_SUP.equals(name)) {
+ seamText.append(SEAM_HAT);
+ } else if (HTML_U.equals(name)) {
+ seamText.append(SEAM_UNDERSCORE);
+ } else if (HTML_PRE.equals(name)) {
+ seamText.append(SEAM_BACKTICK);
+ } else if (HTML_Q.equals(name)) {
+ seamText.append(SEAM_DOUBLEQUOTE);
+ }
+ return seamText.toString();
+
+ }
+
+
+ public String escapeSeamText(String tokenName, boolean preformatted) {
+ final StringBuilder result = new StringBuilder();
+
+ if (preformatted) {
+ if ("<".equals(tokenName)) {
+ result.append('<');
+ } else if ("&".equals(tokenName)) {
+ result.append('&');
+ } else if (">".equals(tokenName)) {
+ result.append('>');
+ } else if (""".equals(tokenName)) {
+ result.append('"');
+ } else if (" ".equals(tokenName)) {
+ result.append(' ');
+ } else if (SEAM_TEXT_SYMBOLS.contains(tokenName)) {
+ result.append(tokenName);
+ }
+
+ } else {
+
+ if ("<".equals(tokenName)) {
+ result.append("\\<");
+ } else if ("&".equals(tokenName)) {
+ result.append("\\&");
+ } else if (">".equals(tokenName)) {
+ result.append("\\>");
+ } else if (""".equals(tokenName)) {
+ result.append('\"');
+ } else if (" ".equals(tokenName)) {
+ result.append(' ');
+ } else if ("\\".equals(tokenName)) {
+ result.append("\\\\");
+ } else if (SEAM_TEXT_SYMBOLS.contains(tokenName)) {
+ result.append('\\').append(tokenName);
+ }
+ }
+
+ return result.toString();
+ }
+
+
+ public boolean isSeamTextElement(Tag element) {
+ return HTML_SEAM_TEXT_ELEMENTS.contains(element.getName().toLowerCase());
+ }
+
+ public boolean isSimpleSeamTextElement(Tag element) {
+ return SIMPLE_HTML_SEAM_TEXT_ELEMENTS.contains(element.getName().toLowerCase());
+ }
+
+ public boolean isFormattedHtmlSeamTextElement(Tag element) {
+ return FORMATTED_HTML_SEAM_TEXT_ELEMENTS.contains(element.getName().toLowerCase());
+ }
+
+ public void text(char[] text, int start, int length) {
+ if (isFirstChars) {
+// append(htmlElementStack.peek().printStartSuffix());
+
+ while (text[start] == '\n' && length > 0) {
+ start++;
+ length--;
+ }
+ isFirstChars = false;
+ }
+
+
+ while (length > 0) {
+ processChar(text, start, 1);
+
+ setHeaderProcessed();
+
+ start ++;
+ length --;
+ }
+ }
+
+ private void setHeaderProcessed() {
+ final Tag token = htmlElementStack.peek();
+ if (!isParagraph(token) && isHeaderProcessed) {
+ isHeaderProcessed = false;
+ }
+ }
+
+ private void processChar(final char[] text, final int start, final int localLength) {
+ switch (text[start]) {
+ case '*': case '|': case '^' : case '+':
+ case '=': case '#': case '\\': case '~':
+ case '[': case ']': case '`' :
+ case '<': case '>': case '&':
+ seamCharacters(text, start, localLength);
+ break;
+
+ case '\n':
+ final Tag token = htmlElementStack.peek();
+ if (!(isParagraph(token)
+ || isHeaderProcessed
+ || HtmlToSeamSAXParser.ROOT_TAG_NAME.equals(token.getName())
+ || isList(token))) {
+ out(text, start, localLength);
+ }
+
+ break;
+ default:
+ out(text, start, localLength);
+ break;
+ }
+ }
+
+ public void seamCharacters(char[] text, int start, int length) {
+ append(escapeSeamText(new String(text, start, length), preformatted));
+ }
+
+ public void plain(char[] text, int start, int length) {
+ out(text, start, length);
+
+ setHeaderProcessed();
+ }
+
+ public void out(char[] text, int start, int length) {
+ append(new String(text, start, length));
+ }
+
+ public void space(char[] text, int start, int length) {
+ if (!htmlElementStack.isEmpty()) {
+ final Tag token = htmlElementStack.peek();
+ if (isPlainHtmlRequired(token)) {
+ out(text, start, length);
+ }
+ }
+ }
+
+ public void newline(char[] text, int start, int length) {
+ if (preformatted && newLinesCollector != null){
+ newLinesCollector.append(new String(text, start, length));
+ }
+ }
+
+ public void openTag(Tag tag) {
+
+ if (isPreFormattedElement(tag)) {
+ preformatted = true;
+ }
+
+ if (isPlainHtmlRequired(tag)) {
+ outValueCollector();
+ append(tag.printPlainStart());
+ } else {
+
+ if (isFormattedHtmlSeamTextElement(tag)) {
+ if (isLink(tag)) {
+ append(tag.printStart());
+ } else if (isList(tag)) {
+ } else if (isListItem(tag)) {
+ append(createSeamTextList());
+ } else if (isHeader(tag)) {
+ append(tag.printStart());
+ } else if (isParagraph(tag) && !isHeaderProcessed) {
+ }
+ } else if (isSimpleSeamTextElement(tag)) {
+
+ outValueCollector();
+ append(getSimpleSeamText(tag));
+ } else {
+ throw new IllegalStateException("Unknow situation. ");
+ }
+ }
+
+ isFirstChars = true;
+ }
+
+ private void outValueCollector() {
+ if (newLinesCollector != null) {
+ append(newLinesCollector.toString());
+ newLinesCollector = null;
+ }
+ }
+
+ public void closeTagWithBody(Tag tag) {
+ if (!tag.getName().equals(tag.getName())) {
+ throw new IllegalStateException("Can not convert to the Seam Text: </" + tag.getName() + "> expected");
+ }
+
+ String value = "";
+ if (newLinesCollector != null) {
+ value = newLinesCollector.toString();
+ }
+
+ if (isPlainHtmlRequired(tag)) {
+ append(value);
+ append(tag.printPlainEnd());
+ } else {
+ if (isFormattedHtmlSeamTextElement(tag)) {
+ if (isLink(tag)) {
+ append(tag.printEnd());
+ } else if (isParagraph(tag)) {
+ append(value);
+ append(tag.printEnd());
+
+ isHeaderProcessed = false;
+ } else {
+ append(value);
+ }
+
+ if (isList(tag) || isListItem(tag)) {
+ append("\n");
+ } else if (isHeader(tag)) {
+ append(tag.printEnd());
+ isHeaderProcessed = true;
+ }
+
+ } else if (isSimpleSeamTextElement(tag)) {
+ append(value.trim());
+ append(getSimpleSeamText(tag));
+ } else {
+ throw new IllegalStateException("Unknow situation. ");
+ }
+ }
+
+
+ newLinesCollector = null;
+ if (isPreFormattedElement(tag)) {
+ preformatted = false;
+ }
+ }
+}
+
Added: trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/Tag.java
===================================================================
--- trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/Tag.java (rev 0)
+++ trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/Tag.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -0,0 +1,106 @@
+package org.richfaces.convert.seamtext;
+
+import java.util.Map;
+
+/**
+ * @user: akolonitsky
+ * Date: Mar 24, 2009
+ */
+public class Tag {
+ private String name;
+ private Map<String, String> attributes;
+
+ private boolean isEmpty = true;
+
+ public Tag() {
+ }
+
+ public Tag(String name) {
+ setName(name);
+ }
+
+ public Tag(String name, Map<String, String> attributes) {
+ setName(name);
+ setAttributes(attributes);
+ }
+
+ public String printPlainStart(){
+ final StringBuilder builder = new StringBuilder();
+ builder.append('<').append(getName());
+
+ if (!attributes.isEmpty()) {
+ builder.append(' ').append(printAttributes());
+ }
+ builder.append('>');
+
+ return builder.toString();
+ }
+
+ public String printStartSuffix(){
+ return ">";
+ }
+
+ public String printStart(){
+ return printPlainStart();
+ }
+
+ private String printAttributes() {
+ if (attributes == null) {
+ return "";
+ }
+
+ final StringBuilder builder = new StringBuilder();
+ for (Map.Entry<String, String> pair : attributes.entrySet()) {
+ builder.append(pair.getKey()).append("=\"").append(pair.getValue()).append("\" ");
+ }
+ return builder.substring(0, builder.length() - 1);
+ }
+
+ public String printPlainEnd(){
+ if (isEmpty) {
+// return "/>";
+ }
+
+ final StringBuilder builder = new StringBuilder(getName().length() + 3);
+ builder.append("</").append(getName()).append('>');
+
+ return builder.toString();
+ }
+
+ public void setEmpty() {
+ isEmpty = true;
+ }
+
+ public void setNotEmpty() {
+ isEmpty = false;
+ }
+
+ public String printEnd(){
+ return printPlainEnd();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAttribute(String attr) {
+ return attributes.get(attr);
+ }
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Map<String, String> attributes) {
+ this.attributes = attributes;
+ }
+
+ @Override
+ public String toString() {
+ return printStart();
+ }
+}
Added: trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/TagFactory.java
===================================================================
--- trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/TagFactory.java (rev 0)
+++ trunk/ui/editor/src/main/java/org/richfaces/convert/seamtext/TagFactory.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -0,0 +1,89 @@
+package org.richfaces.convert.seamtext;
+
+import java.util.*;
+
+/**
+ * @user: akolonitsky
+ * Date: Mar 25, 2009
+ */
+
+public class TagFactory {
+ /**
+ * Collection of special Seam Tags
+ * */
+ private static final Collection<Tag> TAGS = Arrays.asList(
+ getNewTagDefinition("h1", "+ ", "\n"),
+ getNewTagDefinition("h2", "++ ", "\n"),
+ getNewTagDefinition("h3", "+++ ", "\n"),
+ getNewTagDefinition("h4", "++++ ", "\n"),
+ getNewTagDefinition("p", "", "\n\n"),
+ getNewTagDefinition("i", "*", "*"),
+ new Tag("a") {
+ @Override
+ public String printStart() {
+ return "[";
+ }
+
+ @Override
+ public String printEnd() {
+ String s = getAttribute("href");
+ if (s == null) {
+ s = "/";
+ }
+ return "=>"+ s + ']';
+ }
+
+ @Override
+ public String printStartSuffix() {
+ return "";
+ }
+ }
+ );
+
+ private static final Map<String, Tag> TAGS_MAP = new HashMap<String, Tag>(TAGS.size());
+ static {
+ for (Tag tag : TAGS) {
+ TAGS_MAP.put(tag.getName(), tag);
+ }
+ }
+
+// private static Tag getNewTagDefinition(final String tagName, final String startTag) {
+// return getNewTagDefinition(tagName, startTag, "");
+// }
+
+ /**
+ * Create subclass for Tag class with overrided printStart, printEnd methods
+ * */
+ private static Tag getNewTagDefinition(final String tagName, final String startTag, final String endTag) {
+ return new Tag(tagName) {
+ @Override
+ public String printStart() {
+ return startTag;
+ }
+
+ @Override
+ public String printEnd() {
+ return endTag;
+ }
+
+ @Override
+ public String printStartSuffix() {
+ return "";
+ }
+ };
+ }
+
+ public Tag getInstance(String tagName) {
+ return getInstance(tagName, null);
+ }
+
+ public Tag getInstance(String tagName, Map<String, String> attr) {
+ Tag tag = TAGS_MAP.get(tagName);
+ if (tag == null) {
+ tag = new Tag(tagName);
+ }
+ tag.setAttributes(attr);
+
+ return tag;
+ }
+}
Modified: trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java
===================================================================
--- trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2009-03-28 00:31:19 UTC (rev 13274)
+++ trunk/ui/editor/src/test/java/org/richfaces/seamparser/HtmlSeamParserTest.java 2009-03-28 16:22:49 UTC (rev 13275)
@@ -1,303 +1,767 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
package org.richfaces.seamparser;
-import java.io.StringReader;
-
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
import junit.framework.TestCase;
-
import org.jboss.seam.text.SeamTextLexer;
import org.jboss.seam.text.SeamTextParser;
-import org.richfaces.antlr.HtmlSeamTextLexer;
-import org.richfaces.antlr.HtmlSeamTextParser;
+import org.richfaces.convert.seamtext.HtmlToSeamSAXParser;
+import java.io.StringReader;
+
/**
- * HtmlSeamParser Junit Test
- * @author Denis Morozov
- *
+ * @user: akolonitsky
+ * Date: Mar 25, 2009
*/
public class HtmlSeamParserTest extends TestCase {
- private final static String SEAM_TEXT_EXPRESSION_1 = "It's easy to make *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_.";
+ private final static String SEAM_TEXT_EXPRESSION_1 = "It's easy to make *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_.";
- private final static String SEAM_TEXT_EXPRESSION_2 = "+ This is a big heading\n"
- + "You /must/ have some text following a heading!\n\n"
- + "++ This is a smaller heading\n"
- + "This is the first paragraph. We can split it across multiple"
- + "lines, but we must end it with a blank line.\n\n"
- + "This is the second paragraph.";
+ private final static String SEAM_TEXT_EXPRESSION_2 = "+ This is a big heading\n"
+ + "You /must/ have some text following a heading!\n\n"
+ + "++ This is a smaller heading\n"
+ + "This is the first paragraph. We can split it across multiple"
+ + "lines, but we must end it with a blank line.\n\n"
+ + "This is the second paragraph.";
- private final static String SEAM_TEXT_EXPRESSION_3 = "An ordered list:\n\n"
- + "# first item\n" + "# second item\n"
- + "# and even the /third/ item\n\n" + "An unordered list:\n\n"
- + "= an item\n" + "= another item";
+ private final static String SEAM_TEXT_EXPRESSION_3 = "An ordered list:\n\n"
+ + "# first item\n" + "# second item\n"
+ + "# and even the /third/ item\n\n" + "An unordered list:\n\n"
+ + "= an item\n" + "= another item";
- private final static String SEAM_TEXT_EXPRESSION_4 = "The other guy said: "+ "\"Nyeah nyeah-nee\"";
-
- private final static String SEAM_TEXT_EXPRESSION_5 = "You can write down equations like 2\\*3\\+4-7\\=3 and HTML tagslike \\<body\\> using the escape character: \\\\. foo(a)tut.by, 100$ cash 100%";
+ private final static String SEAM_TEXT_EXPRESSION_4 = "The other guy said: " + "\"Nyeah nyeah-nee\"";
- private final static String SEAM_TEXT_EXPRESSION_6 = "My code doesn't work:"
- + "`for (int i=0; i<100; i--)\n"
- + "{\n"
- + "doSomething(){ String str = \"& >" \"; }; doSomething();\n"
- + "doSomething() " +
- "}`" + " Any ideas?";
-
- private final static String SEAM_TEXT_EXPRESSION_7 = "+ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
-
- private final static String SEAM_TEXT_EXPRESSION_8 = "++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
-
- private final static String SEAM_TEXT_EXPRESSION_9 = "+++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
-
- private final static String SEAM_TEXT_EXPRESSION_10 = "++++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
-
- private final static String SEAM_TEXT_EXPRESSION_11 = "+ test value<div>test5</div><h1>test1<div>test2</div>test4</h1>\ntest";
+ private final static String SEAM_TEXT_EXPRESSION_5 =
+ "You can write down equations like 2\\*3\\+4-7\\=3 and HTML tagslike \\<body\\> using the escape character: \\\\. foo(a)tut.by, 100$ cash 100%";
- private final static String SEAM_TEXT_EXPRESSION_12 = "[test link=>http://test.com]";
-
- private final static String SEAM_TEXT_EXPRESSION_13 = "[=>http://test.com]";
-
- private final static String SEAM_TEXT_EXPRESSION_14 = "This is a |<tag attribute=\"value\"/>| example.";
-
- private final static String SEAM_TEXT_EXPRESSION_15 = "= <div class=\"testClass1 testClass2\"></div><h1> test value </h1>";
-
- private final static String SEAM_TEXT_EXPRESSION_16 = "# <div class=\"testClass1 testClass2\"></div><h1> test value </h1>";
+ private final static String SEAM_TEXT_EXPRESSION_6 = "My code doesn't work:"
+ + "`for (int i=0; i<100; i--)\n"
+ + "{\n"
+ + "doSomething(){ String str = \"& >" \"; }; doSomething();\n"
+ + "doSomething() " +
+ "}`" + " Any ideas?";
- private final static String SEAM_TEXT_EXPRESSION_17 = "paragraph\n\n+ header\ntext after header\n\nanother paragraph";
+ private final static String SEAM_TEXT_EXPRESSION_7 = "+ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
- private final static String SEAM_TEXT_EXPRESSION_18 = "paragraph\n\n++ header\ntext after header\n\nanother paragraph";
-
- private final static String SEAM_TEXT_EXPRESSION_19 = "paragraph\n\n+++ header\ntext after header\n\nanother paragraph";
-
- private final static String SEAM_TEXT_EXPRESSION_20 = "paragraph\n\n++++ header\ntext after header\n\nanother paragraph";
-
- private final static String SEAM_TEXT_EXPRESSION_21 = "paragraph\n\n= item1\n= item2\n= item3\n\nanother paragraph";
-
- private final static String SEAM_TEXT_EXPRESSION_22 = "paragraph\n\n# item1\n# item2\n# item3\n\nanother paragraph";
-
- private final static String SEAM_TEXT_EXPRESSION_23 = "+ header text *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
-
- private final static String SEAM_TEXT_EXPRESSION_24 = "++ header text *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
+ private final static String SEAM_TEXT_EXPRESSION_8 = "++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
- private final static String SEAM_TEXT_EXPRESSION_25 = "+++ header text *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
+ private final static String SEAM_TEXT_EXPRESSION_9 = "+++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
- private final static String SEAM_TEXT_EXPRESSION_26 = "++++ header text *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
+ private final static String SEAM_TEXT_EXPRESSION_10 = "++++ test value<h1>test1<h2>test2</h2>test4</h1>\ntest";
-
- private final static String SEAM_TEXT_EXPRESSION_27 = "= item1 *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n= item2 *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
-
- private final static String SEAM_TEXT_EXPRESSION_28 = "# item1 *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_\n# item2 *emphasis*, |monospace|, "
- + "~deleted text~, super^scripts^ or_underlines_";
-
- private final static String SEAM_TEXT_EXPRESSION_29 = "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
-
- private final static String SEAM_TEXT_EXPRESSION_30 = "<div/>";
+ private final static String SEAM_TEXT_EXPRESSION_11 = "+ test value<div>test5</div><h1>test1<div>test2</div>test4</h1>\ntest";
-
-
- public HtmlSeamParserTest(String name) {
- super(name);
- }
- public void testSeamTextConverting1() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_1);
- }
+ private final static String SEAM_TEXT_EXPRESSION_12 = "[test link=>http://test.com]";
- public void testStandartSeamTextConverting2() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_2);
- }
+ private final static String SEAM_TEXT_EXPRESSION_13 = "[=>http://test.com]";
- public void testStandartSeamTextConverting3() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_3);
- }
-
- public void testStandartSeamTextConverting4() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_4);
- }
+ private final static String SEAM_TEXT_EXPRESSION_14 = "This is a |<tag attribute=\"value\"/>| example.";
- public void testStandartSeamTextConverting5() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_5);
- }
+ private final static String SEAM_TEXT_EXPRESSION_15 = "= <div class=\"testClass1 testClass2\"></div><h1> test value </h1>";
- public void testStandartSeamTextConverting6() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_6);
- }
-
- public void testStandartSeamTextConverting7() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_7);
- }
-
- public void testStandartSeamTextConverting8() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_8);
- }
-
- public void testStandartSeamTextConverting9() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_9);
- }
-
- public void testStandartSeamTextConverting10() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_10);
- }
-
- public void testStandartSeamTextConverting11() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_11);
- }
-
- public void testStandartSeamTextConverting12() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_12);
- }
-
- public void testStandartSeamTextConverting13() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_13);
- }
+ private final static String SEAM_TEXT_EXPRESSION_16 = "# <div class=\"testClass1 testClass2\"></div><h1> test value </h1>";
- public void testStandartSeamTextConverting14() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_14);
- }
-
- public void testStandartSeamTextConverting15() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_15);
- }
-
- public void testStandartSeamTextConverting16() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_16);
- }
+ private final static String SEAM_TEXT_EXPRESSION_17 = "paragraph\n\n+ header\ntext after header\n\nanother paragraph";
- public void testStandartSeamTextConverting17() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_17);
- }
+ private final static String SEAM_TEXT_EXPRESSION_18 = "paragraph\n\n++ header\ntext after header\n\nanother paragraph";
-
- public void testStandartSeamTextConverting18() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_18);
- }
+ private final static String SEAM_TEXT_EXPRESSION_19 = "paragraph\n\n+++ header\ntext after header\n\nanother paragraph";
- public void testStandartSeamTextConverting19() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_19);
- }
+ private final static String SEAM_TEXT_EXPRESSION_20 = "paragraph\n\n++++ header\ntext after header\n\nanother paragraph";
- public void testStandartSeamTextConverting20() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_20);
- }
+ private final static String SEAM_TEXT_EXPRESSION_21 = "paragraph\n\n= item1\n= item2\n= item3\n\nanother paragraph";
- public void testStandartSeamTextConverting21() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_21);
- }
-
- public void testStandartSeamTextConverting22() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_22);
- }
-
- public void testStandartSeamTextConverting23() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_23);
- }
-
- public void testStandartSeamTextConverting24() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_24);
- }
+ private final static String SEAM_TEXT_EXPRESSION_22 = "paragraph\n\n# item1\n# item2\n# item3\n\nanother paragraph";
- public void testStandartSeamTextConverting25() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_25);
- }
-
- public void testStandartSeamTextConverting26() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_26);
- }
+ private final static String SEAM_TEXT_EXPRESSION_23 = "+ header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
- public void testStandartSeamTextConverting27() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_27);
- }
-
- public void testStandartSeamTextConverting28() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_28);
- }
-
- public void testStandartSeamTextConverting29() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_29);
- }
-
- public void testStandartSeamTextConverting30() throws Exception {
- assertSeamConverting(SEAM_TEXT_EXPRESSION_30);
- }
+ private final static String SEAM_TEXT_EXPRESSION_24 = "++ header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
- public void testRF5717() throws Exception {
- assertHtml2SeamConverting("<p>a&b</p>", "a&b");
- }
-
+ private final static String SEAM_TEXT_EXPRESSION_25 = "+++ header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+ private final static String SEAM_TEXT_EXPRESSION_26 = "++++ header text *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n text after header *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
-
-
+ private final static String SEAM_TEXT_EXPRESSION_27 = "= item1 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n= item2 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
+ private final static String SEAM_TEXT_EXPRESSION_28 = "# item1 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_\n# item2 *emphasis*, |monospace|, "
+ + "~deleted text~, super^scripts^ or_underlines_";
- /**
- * Method to assert converting from Seam Text to html and back
- * @param htmlText
- * @throws Exception
- */
- private void assertHtml2SeamConverting(String htmlText, String resultContain)
- throws Exception {
-
- HtmlSeamTextParser htmlParser = new HtmlSeamTextParser(
- new HtmlSeamTextLexer(new StringReader(htmlText)));
- htmlParser.startRule();
- String seamText = htmlParser.toString();
+ private final static String SEAM_TEXT_EXPRESSION_29 = "A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9";
- SeamTextParser seamParser = new SeamTextParser(
- new SeamTextLexer(new StringReader(seamText)));
- seamParser.startRule();
- String html = seamParser.toString();
+// private final static String SEAM_TEXT_EXPRESSION_30 = "<div/>";
+
+
+ public HtmlSeamParserTest(String name) {
+ super(name);
+ }
+
+ public void testSeamTextConverting1() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_1);
+ }
+
+ public void testStandartSeamTextConverting2() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_2);
+ }
+
+ public void testStandartSeamTextConverting3() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_3);
+ }
+
+ public void testStandartSeamTextConverting4() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_4);
+ }
+
+ public void testStandartSeamTextConverting5() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_5);
+ }
+
+ public void testStandartSeamTextConverting6() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_6);
+ }
+
+ public void testStandartSeamTextConverting7() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_7);
+ }
+
+ public void testStandartSeamTextConverting8() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_8);
+ }
+
+ public void testStandartSeamTextConverting9() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_9);
+ }
+
+ public void testStandartSeamTextConverting10() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_10);
+ }
+
+ public void testStandartSeamTextConverting11() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_11);
+ }
+
+ public void testStandartSeamTextConverting12() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_12);
+ }
+
+ public void testStandartSeamTextConverting13() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_13);
+ }
+
+ public void testStandartSeamTextConverting14() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_14);
+ }
+
+ public void testStandartSeamTextConverting15() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_15);
+ }
+
+ public void testStandartSeamTextConverting16() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_16);
+ }
+
+ public void testStandartSeamTextConverting17() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_17);
+ }
+
+
+ public void testStandartSeamTextConverting18() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_18);
+ }
+
+ public void testStandartSeamTextConverting19() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_19);
+ }
+
+ public void testStandartSeamTextConverting20() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_20);
+ }
+
+ public void testStandartSeamTextConverting21() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_21);
+ }
+
+ public void testStandartSeamTextConverting22() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_22);
+ }
+
+ public void testStandartSeamTextConverting23() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_23);
+ }
+
+ public void testStandartSeamTextConverting24() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_24);
+ }
+
+ public void testStandartSeamTextConverting25() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_25);
+ }
+
+ public void testStandartSeamTextConverting26() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_26);
+ }
+
+ public void testStandartSeamTextConverting27() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_27);
+ }
+
+ public void testStandartSeamTextConverting28() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_28);
+ }
+
+ public void testStandartSeamTextConverting29() throws Exception {
+ assertSeamConverting(SEAM_TEXT_EXPRESSION_29);
+ }
+
+// public void testStandartSeamTextConverting30() throws Exception {
+// assertSeamConverting(SEAM_TEXT_EXPRESSION_30);
+// }
+
+ public void testRF5717() throws Exception {
+ assertHtml2SeamConverting("<p>a<b a&b</p>");
+ }
+
+ public void testRF5717_() throws Exception {
+ assertHtml2SeamConverting("<p><b>aaaaaaaaa <u><i class=\"seamTextEmphasis\">sssssssss</i> dddddddddddddddd</u></b></p>");
+ }
+
+// public void testRF5717__() throws Exception {
+// assertHtml2SeamConverting("<P><STRONG>aaaaaaaaad <U><B>ddddddddddddd</B> sssssssssssss</U></STRONG></P>", "");
+// }
+
+ public void testRF5798_() throws Exception {
+ assertHtml2SeamConverting("<!-- Hello Cfif -->");
+ }
+
+ public void noTestRF5798__() throws Exception {
+ final String str = "<p><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"/><meta content=\"Word.Document\" name=\"ProgId\"/><meta content=\"Microsoft Word 12\" name=\"Generator\"/><meta content=\"Microsoft Word 12\" name=\"Originator\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_filelist.xml\" rel=\"File-List\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_themedata.thmx\" rel=\"themeData\"/><link href=\"file:///E:\\TEMP~1\\msohtmlclip1\\01\\clip_colorschememapping.xml\" rel=\"colorSchemeMapping\"/>" +
+ "<!--[if gte mso 9]><xml>\n" +
+ " <w:WordDocument>\n" +
+ " <w:View>Normal</w:View>\n" +
+ " <w:Zoom>0</w:Zoom>\n" +
+ " <w:TrackMoves/>\n" +
+ " <w:TrackFormatting/>\n" +
+ " <w:PunctuationKerning/>\n" +
+ " <w:ValidateAgainstSchemas/>\n" +
+ " <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>\n" +
+ " <w:IgnoreMixedContent>false</w:IgnoreMixedContent>\n" +
+ " <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>\n" +
+ " <w:DoNotPromoteQF/>\n" +
+ " <w:LidThemeOther>EN-US</w:LidThemeOther>\n" +
+ " <w:LidThemeAsian>X-NONE</w:LidThemeAsian>\n" +
+ " <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>\n" +
+ " <w:Compatibility>\n" +
+ " <w:BreakWrappedTables/>\n" +
+ " <w:SnapToGridInCell/>\n" +
+ " <w:WrapTextWithPunct/>\n" +
+ " <w:UseAsianBreakRules/>\n" +
+ " <w:DontGrowAutofit/>\n" +
+ " <w:SplitPgBreakAndParaMark/>\n" +
+ " <w:DontVertAlignCellWithSp/>\n" +
+ " <w:DontBreakConstrainedForcedTables/>\n" +
+ " <w:DontVertAlignInTxbx/>\n" +
+ " <w:Word11KerningPairs/>\n" +
+ " <w:CachedColBalance/>\n" +
+ " </w:Compatibility>\n" +
+ " <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>\n" +
+ " <m:mathPr>\n" +
+ " <m:mathFont m:val=\"Cambria Math\"/>\n" +
+ " <m:brkBin m:val=\"before\"/>\n" +
+ " <m:brkBinSub m:val=\"-\"/>\n" +
+ " <m:smallFrac m:val=\"off\"/>\n" +
+ " <m:dispDef/>\n" +
+ " <m:lMargin m:val=\"0\"/>\n" +
+ " <m:rMargin m:val=\"0\"/>\n" +
+ " <m:defJc m:val=\"centerGroup\"/>\n" +
+ " <m:wrapIndent m:val=\"1440\"/>\n" +
+ " <m:intLim m:val=\"subSup\"/>\n" +
+ " <m:naryLim m:val=\"undOvr\"/>\n" +
+ " </m:mathPr></w:WordDocument>\n" +
+ "</xml><![endif]-->" +
+ "<!--[if gte mso 9]><xml>\n" +
+ " <w:LatentStyles DefLockedState=\"false\" DefUnhideWhenUsed=\"true\"\n" +
+ " DefSemiHidden=\"true\" DefQFormat=\"false\" DefPriority=\"99\"\n" +
+ " LatentStyleCount=\"267\">\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Normal\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"heading 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 7\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 8\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"9\" QFormat=\"true\" Name=\"heading 9\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 7\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 8\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"toc 9\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"35\" QFormat=\"true\" Name=\"caption\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"10\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Title\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"1\" Name=\"Default Paragraph Font\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"11\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Subtitle\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"22\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Strong\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"20\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Emphasis\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"59\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Table Grid\"/>\n" +
+ " <w:LsdException Locked=\"false\" UnhideWhenUsed=\"false\" Name=\"Placeholder Text\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"1\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"No Spacing\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" UnhideWhenUsed=\"false\" Name=\"Revision\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"34\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"List Paragraph\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"29\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Quote\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"30\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Intense Quote\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 1\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 2\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 3\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 4\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 5\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"60\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Shading Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"61\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light List Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"62\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Light Grid Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"63\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 1 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"64\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Shading 2 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"65\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 1 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"66\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium List 2 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"67\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 1 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"68\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 2 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"69\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Medium Grid 3 Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"70\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Dark List Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"71\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Shading Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"72\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful List Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"73\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" Name=\"Colorful Grid Accent 6\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"19\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Subtle Emphasis\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"21\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Intense Emphasis\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"31\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Subtle Reference\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"32\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Intense Reference\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"33\" SemiHidden=\"false\"\n" +
+ " UnhideWhenUsed=\"false\" QFormat=\"true\" Name=\"Book Title\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"37\" Name=\"Bibliography\"/>\n" +
+ " <w:LsdException Locked=\"false\" Priority=\"39\" QFormat=\"true\" Name=\"TOC Heading\"/>\n" +
+ " </w:LatentStyles>\n" +
+ "</xml><![endif]" +
+ "-->" +
+ "<style>\n" +
+ "<!--\n" +
+ " /* Font Definitions */\n" +
+ " @font-face\n" +
+ "\t{font-family:\"Cambria Math\";\n" +
+ "\tpanose-1:2 4 5 3 5 4 6 3 2 4;\n" +
+ "\tmso-font-charset:204;\n" +
+ "\tmso-generic-font-family:roman;\n" +
+ "\tmso-font-pitch:variable;\n" +
+ "\tmso-font-signature:-1610611985 1107304683 0 0 159 0;}\n" +
+ "@font-face\n" +
+ "\t{font-family:Calibri;\n" +
+ "\tpanose-1:2 15 5 2 2 2 4 3 2 4;\n" +
+ "\tmso-font-charset:204;\n" +
+ "\tmso-generic-font-family:swiss;\n" +
+ "\tmso-font-pitch:variable;\n" +
+ "\tmso-font-signature:-1610611985 1073750139 0 0 159 0;}\n" +
+ " /* Style Definitions */\n" +
+ " p.MsoNormal, li.MsoNormal, div.MsoNormal\n" +
+ "\t{mso-style-unhide:no;\n" +
+ "\tmso-style-qformat:yes;\n" +
+ "\tmso-style-parent:\"\";\n" +
+ "\tmargin-top:0in;\n" +
+ "\tmargin-right:0in;\n" +
+ "\tmargin-bottom:10.0pt;\n" +
+ "\tmargin-left:0in;\n" +
+ "\tline-height:115%;\n" +
+ "\tmso-pagination:widow-orphan;\n" +
+ "\tfont-size:11.0pt;\n" +
+ "\tfont-family:\"Calibri\",\"sans-serif\";\n" +
+ "\tmso-ascii-font-family:Calibri;\n" +
+ "\tmso-ascii-theme-font:minor-latin;\n" +
+ "\tmso-fareast-font-family:Calibri;\n" +
+ "\tmso-fareast-theme-font:minor-latin;\n" +
+ "\tmso-hansi-font-family:Calibri;\n" +
+ "\tmso-hansi-theme-font:minor-latin;\n" +
+ "\tmso-bidi-font-family:\"Times New Roman\";\n" +
+ "\tmso-bidi-theme-font:minor-bidi;}\n" +
+ "a:link, span.MsoHyperlink\n" +
+ "\t{mso-style-noshow:yes;\n" +
+ "\tmso-style-priority:99;\n" +
+ "\tcolor:blue;\n" +
+ "\ttext-decoration:underline;\n" +
+ "\ttext-underline:single;}\n" +
+ "a:visited, span.MsoHyperlinkFollowed\n" +
+ "\t{mso-style-noshow:yes;\n" +
+ "\tmso-style-priority:99;\n" +
+ "\tcolor:purple;\n" +
+ "\tmso-themecolor:followedhyperlink;\n" +
+ "\ttext-decoration:underline;\n" +
+ "\ttext-underline:single;}\n" +
+ "p\n" +
+ "\t{mso-style-noshow:yes;\n" +
+ "\tmso-style-priority:99;\n" +
+ "\tmso-margin-top-alt:auto;\n" +
+ "\tmargin-right:0in;\n" +
+ "\tmargin-bottom:5.75pt;\n" +
+ "\tmargin-left:0in;\n" +
+ "\tmso-pagination:widow-orphan;\n" +
+ "\tfont-size:12.0pt;\n" +
+ "\tfont-family:\"Times New Roman\",\"serif\";\n" +
+ "\tmso-fareast-font-family:\"Times New Roman\";}\n" +
+ ".MsoChpDefault\n" +
+ "\t{mso-style-type:export-only;\n" +
+ "\tmso-default-props:yes;\n" +
+ "\tmso-ascii-font-family:Calibri;\n" +
+ "\tmso-ascii-theme-font:minor-latin;\n" +
+ "\tmso-fareast-font-family:Calibri;\n" +
+ "\tmso-fareast-theme-font:minor-latin;\n" +
+ "\tmso-hansi-font-family:Calibri;\n" +
+ "\tmso-hansi-theme-font:minor-latin;\n" +
+ "\tmso-bidi-font-family:\"Times New Roman\";\n" +
+ "\tmso-bidi-theme-font:minor-bidi;}\n" +
+ ".MsoPapDefault\n" +
+ "\t{mso-style-type:export-only;\n" +
+ "\tmargin-bottom:10.0pt;\n" +
+ "\tline-height:115%;}\n" +
+ "@page Section1\n" +
+ "\t{size:595.3pt 841.9pt;\n" +
+ "\tmargin:56.7pt 42.5pt 56.7pt 85.05pt;\n" +
+ "\tmso-header-margin:.5in;\n" +
+ "\tmso-footer-margin:.5in;\n" +
+ "\tmso-paper-source:0;}\n" +
+ "div.Section1\n" +
+ "\t{page:Section1;}\n" +
+ "-->\n" +
+ "</style>" +
+ "<!--[if gte mso 10]>\n" +
+ "<style>\n" +
+ " /* Style Definitions */\n" +
+ " table.MsoNormalTable\n" +
+ "\t{mso-style-name:\"?z?�N�N�???�N? N�?�?�?�??N�?�\";\n" +
+ "\tmso-tstyle-rowband-size:0;\n" +
+ "\tmso-tstyle-colband-size:0;\n" +
+ "\tmso-style-noshow:yes;\n" +
+ "\tmso-style-priority:99;\n" +
+ "\tmso-style-qformat:yes;\n" +
+ "\tmso-style-parent:\"\";\n" +
+ "\tmso-padding-alt:0in 5.4pt 0in 5.4pt;\n" +
+ "\tmso-para-margin-top:0in;\n" +
+ "\tmso-para-margin-right:0in;\n" +
+ "\tmso-para-margin-bottom:10.0pt;\n" +
+ "\tmso-para-margin-left:0in;\n" +
+ "\tline-height:115%;\n" +
+ "\tmso-pagination:widow-orphan;\n" +
+ "\tfont-size:11.0pt;\n" +
+ "\tfont-family:\"Calibri\",\"sans-serif\";\n" +
+ "\tmso-ascii-font-family:Calibri;\n" +
+ "\tmso-ascii-theme-font:minor-latin;\n" +
+ "\tmso-fareast-font-family:\"Times New Roman\";\n" +
+ "\tmso-fareast-theme-font:minor-fareast;\n" +
+ "\tmso-hansi-font-family:Calibri;\n" +
+ "\tmso-hansi-theme-font:minor-latin;}\n" +
+ "</style>\n" +
+ "<![endif]" +
+ "-->\n" +
+ "\n" +
+ "<p align=\"center\" style=\"margin-bottom: 0.0001pt; text-align: center;\"><a name=\"OLE_LINK2\"/><a name=\"OLE_LINK1\"><span style=\"\"><b><span style='font-size: 20pt; font-family: \"Courier New\"; color: black;'>We where\n" +
+ "unsuccessful in reproducting this bug in our testing</span></b></span></a></p>\n" +
+ "\n" +
+ "<p align=\"center\" style=\"margin-bottom: 0.0001pt; text-align: center;\"><span style=\"\"><span style=\"\"><b><span style='font-size: 20pt; font-family: \"Courier New\"; color: black;'>environment.</span></b></span></span></p>\n" +
+ "\n" +
+ "<p style=\"margin-bottom: 0.0001pt;\"><span style=\"\"><span style=\"\"><o:p>A�</o:p></span></span></p>\n" +
+ "\n" +
+ "<p style=\"margin-bottom: 0.0001pt;\"><span style=\"\"><span style=\"\"><s><span style='font-size: 13pt; font-family: \"Courier New\"; color: black;'>Could you provide us with a example URL\n" +
+ "where this is happening?</span></s></span></span></p>\n" +
+ "\n" +
+ "<p style=\"margin-bottom: 0.0001pt;\"><span style=\"\"><span style=\"\"><span style='font-size: 13pt; font-family: \"Courier New\"; color: black;'>Do you have any odd browser\n" +
+ "extensions/plugins installed?</span></span></span></p>\n" +
+ "\n" +
+ "<p style=\"margin-bottom: 0.0001pt;\"><span style=\"\"><span style=\"\"><span style='font-size: 13pt; font-family: \"Courier New\"; color: black;'>Does it happen on our site aswell </span></span></span><a href=\"http://tinymce.moxiecode.com/\"><span style=\"\"><span style=\"\"><span style='font-size: 13pt; font-family: \"Courier New\";'>http://tinymce.moxiecode.com</span></span></span></a><span style=\"\"><span style=\"\"><span style='font-size: 13pt; font-family: \"Courier New\"; color: black;'>?</span></span></span></p>\n" +
+ "\n" +
+ "<p style=\"margin-bottom: 0.0001pt;\"><span style=\"\"><span style=\"\"><o:p>A�</o:p></span></span></p>\n" +
+ "\n" +
+ "<span style=\"\"/><span style=\"\"/>\n" +
+ "\n" +
+ "<p class=\"MsoNormal\"><o:p>A�</o:p></p>\n" +
+ "\n" +
+ "</p>";
+ assertHtml2SeamConverting(str);
+ }
+
+ public void testRF5798() throws Exception {
+ assertHtml2SeamConverting(
+ "<p style=\"margin-bottom: 0in; line-height: 100%;\" >" +
+ " <meta http-equiv=\"CONTENT-TYPE\" content=\"text/html;\" charset=\"utf-8\" />" +
+ " <title></title>" +
+ " <meta name=\"GENERATOR\" content=\"OpenOffice.org 3.0 (Win32)\" />" +
+ " <style type=\"text/css\"><!--" +
+ " <!" +
+ " @page { margin: 0.79in }" +
+ " P { margin-bottom: 0.08in }" +
+ " >" +
+ " --></style>" +
+ "</p>" +
+ "<p style=\"margin-bottom: 0in; line-height: 100%;\" " +
+ " align=\"center\" " +
+ " lang=\"en-US\">" +
+ " <font color=\"#000000\">" +
+ " <font color=\"#000001\">" +
+ " <font color=\"#000002\" style=\"font-size: 20pt;\" size=\"5\">" +
+ " <b>We where unsuccessful in reproducting this bug in our testing</b>" +
+ " </font>" +
+ " </font>" +
+ " </font>" +
+ "</p>" +
+ "<p style=\"margin-bottom: 0in; line-height: 100%;\" " +
+ " align=\"center\" " +
+ " lang=\"en-US\">" +
+ " <font color=\"#000000\">" +
+ " <font>" +
+ " <font style=\"font-size: 20pt;\" size=\"5\">" +
+ " <b>environment.</b>" +
+ " </font>" +
+ " </font>" +
+ " </font>" +
+ "</p>");
+// assertSeamConverting("<b>aaa _*bbb*ccc_ ddd</b>");
+ }
+
+ private String assertHtml2SeamConverting(String htmlText)
+ throws Exception {
+
+ final String seamText = convertHtmlToSeamText(htmlText);
+ System.out.println("seamText = \n" + seamText);
- assertTrue(html.contains(resultContain));
- }
+ final SeamTextParser seamParser = new SeamTextParser(
+ new SeamTextLexer(new StringReader(seamText)));
+ seamParser.startRule();
- /**
- * Method to assert converting from Seam Text to html and back
- * @param seamTextExpression
- * @throws Exception
- */
- private void assertSeamConverting(String seamTextExpression)
- throws Exception {
-
- SeamTextParser seamParser = new SeamTextParser(new SeamTextLexer(new StringReader(seamTextExpression)));
- seamParser.startRule();
- String html = seamParser.toString();
-
- HtmlSeamTextParser htmlParser = new HtmlSeamTextParser(new HtmlSeamTextLexer(new StringReader(html)));
- htmlParser.startRule();
- String seamtext = htmlParser.toString();
-
- assertEquals(seamTextExpression,seamtext.trim());
- }
-}
+ return seamParser.toString();
+ }
+
+ private void assertSeamConverting(String seamTextExpression) throws TokenStreamException, RecognitionException {
+
+ final SeamTextParser seamParser = new SeamTextParser(new SeamTextLexer(new StringReader(seamTextExpression)));
+ seamParser.startRule();
+ final String html = seamParser.toString();
+ System.out.println("html = " + html);
+
+ final String seamtext = convertHtmlToSeamText(html);
+
+ assertEquals(seamTextExpression,seamtext.trim());
+ }
+
+ private String convertHtmlToSeamText(final String html) {
+ try {
+ return HtmlToSeamSAXParser.convertHtmlToSeamText(html);
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertTrue(false);
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
15 years, 1 month
JBoss Rich Faces SVN: r13274 - in branches/jsf2.0/framework/jsf-test/src: main/java/org/richfaces/test/staging and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-03-27 20:31:19 -0400 (Fri, 27 Mar 2009)
New Revision: 13274
Modified:
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
Log:
minor improvements.
Modified: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-03-27 19:41:21 UTC (rev 13273)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/AbstractFacesTest.java 2009-03-28 00:31:19 UTC (rev 13274)
@@ -6,12 +6,14 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.EventListener;
import java.util.Locale;
import java.util.Properties;
import java.util.logging.LogManager;
+import javax.faces.FacesException;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
@@ -255,8 +257,24 @@
* @throws Exception
*/
protected void setupFacesRequest() throws Exception {
+ String url = "http://localhost/test.jsf";
+ setupFacesRequest(url);
+ UIViewRoot viewRoot = setupView();
+ if (null != viewRoot) {
+ facesContext.setViewRoot(viewRoot);
+ }
+ }
+
+ /**
+ * <p class="changed_added_2_0"></p>
+ * @param url
+ * @throws MalformedURLException
+ * @throws FacesException
+ */
+ protected void setupFacesRequest(String url) throws MalformedURLException,
+ FacesException {
connection = facesServer.getConnection(new URL(
- "http://localhost/test.jsf"));
+ url));
setupConnection();
connection.start();
FacesContextFactory facesContextFactory = (FacesContextFactory) FactoryFinder
@@ -264,10 +282,6 @@
facesContext = facesContextFactory.getFacesContext(facesServer
.getContext(), connection.getRequest(), connection
.getResponse(), lifecycle);
- UIViewRoot viewRoot = setupView();
- if (null != viewRoot) {
- facesContext.setViewRoot(viewRoot);
- }
}
/**
Modified: branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-27 19:41:21 UTC (rev 13273)
+++ branches/jsf2.0/framework/jsf-test/src/main/java/org/richfaces/test/staging/StagingServletContext.java 2009-03-28 00:31:19 UTC (rev 13274)
@@ -178,6 +178,10 @@
public Set getResourcePaths(String path) {
HashSet result=null;
ServerResource resource = getServerResource(path);
+ if(null == resource && !path.endsWith("/")){
+ path+="/";
+ resource = getServerResource(path);
+ }
if(null != resource){
Set<String> paths = resource.getPaths();
if(null != paths && paths.size()>0){
Modified: branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java
===================================================================
--- branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2009-03-27 19:41:21 UTC (rev 13273)
+++ branches/jsf2.0/framework/jsf-test/src/test/java/org/richfaces/test/FacesServerTest.java 2009-03-28 00:31:19 UTC (rev 13274)
@@ -5,6 +5,7 @@
import static org.junit.Assert.*;
+import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
@@ -24,6 +25,7 @@
import org.junit.Test;
import org.w3c.dom.Element;
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
@@ -69,8 +71,7 @@
*/
@Test
public void testHelloFacelets() throws Exception {
- WebClient webClient = new LocalWebClient(facesServer);
- HtmlPage page = webClient.getPage("http://localhost/hello.jsf");
+ HtmlPage page = getPage("/hello.jsf");
System.out.println(page.asXml());
Element submitElement = page.getElementById("helloForm:submit");
HtmlForm htmlForm = page.getFormByName("helloForm");
@@ -92,4 +93,17 @@
assertEquals("foo", span.getTextContent().trim());
}
+ /**
+ * <p class="changed_added_2_0"></p>
+ * @param url TODO
+ * @return
+ * @throws IOException
+ * @throws MalformedURLException
+ */
+ protected HtmlPage getPage(String url) throws Exception {
+ WebClient webClient = new LocalWebClient(facesServer);
+ HtmlPage page = webClient.getPage("http://localhost"+url);
+ return page;
+ }
+
}
15 years, 1 month
JBoss Rich Faces SVN: r13273 - in trunk/ui/datascroller/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-27 15:41:21 -0400 (Fri, 27 Mar 2009)
New Revision: 13273
Modified:
trunk/ui/datascroller/src/main/config/component/datascroller.xml
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
Log:
https://jira.jboss.org/jira/browse/RF-6637
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2009-03-27 18:46:19 UTC (rev 13272)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2009-03-27 19:41:21 UTC (rev 13273)
@@ -321,6 +321,12 @@
<description>HTML: script expression; a page is changed</description>
</property>
+ <property>
+ <name>showShortLastPage</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+
<property hidden="true" existintag="false" exist="false" >
<name>firstRow</name>
<classname>int</classname>
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
--- trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2009-03-27 18:46:19 UTC (rev 13272)
+++ trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2009-03-27 19:41:21 UTC (rev 13273)
@@ -206,6 +206,10 @@
public abstract void setInactiveStyleClass(String inactiveStyleClass);
public abstract void setInactiveStyle(String inactiveStyle);
+
+ public abstract boolean isShowShortLastPage();
+ public abstract void setShowShortLastPage(boolean showShortLastPage);
+
/**
* Finds the dataTable which id is mapped to the "for" property
*
@@ -325,7 +329,10 @@
public int getPageCount(UIData data) {
int rowCount = getRowCount(data);
int rows = getRows(data);
-
+ return getPageCount(data, rowCount, rows);
+ }
+
+ public int getPageCount(UIData data, int rowCount, int rows) {
int pageCount;
if (rows > 0) {
pageCount = rows <= 0 ? 1 : rowCount / rows;
@@ -438,7 +445,10 @@
public void setupFirstRowValue() {
UIData dataTable = getDataTable();
if (isRendered()) {
- Integer pageCount = getPageCount(dataTable);
+ int rowCount = getRowCount(dataTable);
+ int rows = getRows(dataTable);
+
+ Integer pageCount = getPageCount(dataTable, rowCount, rows);
int page = getPage();
int newPage = -1;
@@ -461,7 +471,18 @@
}
if (isRendered(dataTable)) {
- dataTable.setFirst((page - 1) * getRows(dataTable));
+ int first;
+
+ if (page != pageCount || isShowShortLastPage()) {
+ first = (page - 1) * rows;
+ } else {
+ first = rowCount - rows;
+ if (first < 0) {
+ first = 0;
+ }
+ }
+
+ dataTable.setFirst(first);
}
}
}
15 years, 1 month
JBoss Rich Faces SVN: r13272 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-03-27 14:46:19 -0400 (Fri, 27 Mar 2009)
New Revision: 13272
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java
Log:
RF-6249
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java 2009-03-27 17:45:38 UTC (rev 13271)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/SuggestionBoxTest.java 2009-03-27 18:46:19 UTC (rev 13272)
@@ -231,6 +231,36 @@
assertClassAttributeContains("//table[@id='" + spId + "']/tbody/tr[2]", "selected-class", "selectedClass attribute was not output to client");
}
+ @Test
+ public void testTokensAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Check tokens attribute allows to recall suggestion several times for different words");
+ writeStatus("In this case three tokens are given: ,[]");
+
+ String inputId = tester.getClientId("suggestion");
+ type(inputId, "Bel");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ AssertValueEquals(inputId, "Belarus");
+
+ type(inputId, "Belarus,Arm");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ AssertValueEquals(inputId, "Belarus,Armenia");
+
+ type(inputId, "Belarus[Rus");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ AssertValueEquals(inputId, "Belarus[Russia");
+
+ writeStatus("@ is not supported token");
+ type(inputId, "Belarus@Kaz");
+ waitForAjaxCompletion();
+ selenium.keyDown(inputId, "\\13");//enter
+ AssertValueEquals(inputId, "Belarus@Kaz");
+ }
+
@Override
public void sendAjax() {
type(getAutoTester(this).getClientId("suggestion"), "Bel");
15 years, 1 month