JBoss Rich Faces SVN: r11020 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-11-04 11:38:02 -0500 (Tue, 04 Nov 2008)
New Revision: 11020
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
Log:
RF-4837
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/orderingList/orderingListTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-04 16:22:04 UTC (rev 11019)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/OrderingListTest.java 2008-11-04 16:38:02 UTC (rev 11020)
@@ -59,8 +59,22 @@
private String selectionText;
private String activeItemText;
+
+ private String messagesId;
/**
+ * 'required' and 'requiredMessage' attributes work
+ */
+ @Test
+ public void testRequired(Template template) {
+ renderPage(template);
+ initFields();
+ Assert.assertTrue(selenium.getText(messagesId).length() == 0);
+ clickAjaxCommandAndWait(getParentId() + "testRequired:submit");
+ Assert.assertFalse(selenium.getText(messagesId).length() == 0);
+ }
+
+ /**
* Check "caption" facet
*/
@Test
@@ -187,7 +201,8 @@
}
private void initFields() {
- orderingListId = getParentId() + "_form:orderingList";
+ String formId = getParentId() + "_form:";
+ orderingListId = formId + "orderingList";
firstButton = orderingListId + "first";
firstButtonDisabled = orderingListId + "disfirst";
@@ -204,11 +219,12 @@
firstRow = orderingListId + ":0";
thirdRow = orderingListId + ":2";
- actionResultText = getParentId() + "_form:actionResult";
- selectionText = getParentId() + "_form:selection";
- activeItemText = getParentId() + "_form:activeItem";
+ actionResultText = formId + "actionResult";
+ selectionText = formId + "selection";
+ activeItemText = formId + "activeItem";
ajax = firstRow + ":_ajax";
server = orderingListId + ":1:_server";
+ messagesId = formId + "messages";
}
public String getTestUrl() {
16 years, 1 month
JBoss Rich Faces SVN: r11019 - trunk/test-applications/automator/src/main/java/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2008-11-04 11:22:04 -0500 (Tue, 04 Nov 2008)
New Revision: 11019
Modified:
trunk/test-applications/automator/src/main/java/parser/TLDParser.java
Log:
+getAllHandlers()
Modified: trunk/test-applications/automator/src/main/java/parser/TLDParser.java
===================================================================
--- trunk/test-applications/automator/src/main/java/parser/TLDParser.java 2008-11-04 16:12:17 UTC (rev 11018)
+++ trunk/test-applications/automator/src/main/java/parser/TLDParser.java 2008-11-04 16:22:04 UTC (rev 11019)
@@ -121,4 +121,32 @@
}
return richfacesUI;
}
+
+ public ArrayList<String> getAllHandlers() {
+ tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
+ InputStream input = null;
+ ArrayList<String> handlers = new ArrayList<String>();
+
+ try {
+ input = richfacesUI.getInputStream(tld);
+ InputStreamReader isr = new InputStreamReader(input);
+ BufferedReader reader = new BufferedReader(isr);
+ String line, temp;
+ int start, end;
+ while ((line = reader.readLine()) != null) {
+ if ((start = line.indexOf("<name>")) != -1) {
+ end = line.indexOf("</name>");
+ temp = line.substring(start + 6, end).trim();
+ if (temp.startsWith("on") && !handlers.contains(temp)) {
+ handlers.add(temp);
+ }
+ }
+ }
+ return handlers;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}
16 years, 1 month
JBoss Rich Faces SVN: r11018 - in trunk/test-applications: automator and 18 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: adubovsky
Date: 2008-11-04 11:12:17 -0500 (Tue, 04 Nov 2008)
New Revision: 11018
Added:
trunk/test-applications/automator/
trunk/test-applications/automator/pom.xml
trunk/test-applications/automator/src/
trunk/test-applications/automator/src/main/
trunk/test-applications/automator/src/main/java/
trunk/test-applications/automator/src/main/java/comboBox/
trunk/test-applications/automator/src/main/java/comboBox/ComboBoxGeneral.java
trunk/test-applications/automator/src/main/java/general/
trunk/test-applications/automator/src/main/java/general/DrawGrids.java
trunk/test-applications/automator/src/main/java/general/General.java
trunk/test-applications/automator/src/main/java/parser/
trunk/test-applications/automator/src/main/java/parser/Attribute.java
trunk/test-applications/automator/src/main/java/parser/AttributesList.java
trunk/test-applications/automator/src/main/java/parser/Status.java
trunk/test-applications/automator/src/main/java/parser/TLDParser.java
trunk/test-applications/automator/src/main/java/phaseTracker/
trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTracker.java
trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTrackerComponent.java
trunk/test-applications/automator/src/main/resources/
trunk/test-applications/automator/src/main/webapp/
trunk/test-applications/automator/src/main/webapp/META-INF/
trunk/test-applications/automator/src/main/webapp/META-INF/MANIFEST.MF
trunk/test-applications/automator/src/main/webapp/WEB-INF/
trunk/test-applications/automator/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/components/
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/components/ComboBox.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/General.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/ShowResults.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Attribute.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/AttributesList.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Status.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/TLDParser.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTracker.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTrackerComponent.class
trunk/test-applications/automator/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/automator/src/main/webapp/WEB-INF/lib/
trunk/test-applications/automator/src/main/webapp/WEB-INF/web.xml
trunk/test-applications/automator/src/main/webapp/component/
trunk/test-applications/automator/src/main/webapp/component/comboBox.jsp
trunk/test-applications/automator/src/main/webapp/icons/
trunk/test-applications/automator/src/main/webapp/icons/logo.png
trunk/test-applications/automator/src/main/webapp/index.jsp
trunk/test-applications/automator/src/main/webapp/main/
trunk/test-applications/automator/src/main/webapp/main/componentsList.jsp
trunk/test-applications/automator/src/main/webapp/main/main.jsp
Log:
automator app was added
Added: trunk/test-applications/automator/pom.xml
===================================================================
--- trunk/test-applications/automator/pom.xml (rev 0)
+++ trunk/test-applications/automator/pom.xml 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>test-applications</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.3.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.test-applications</groupId>
+ <artifactId>automator</artifactId>
+ <packaging>war</packaging>
+ <name>RichFaces Test Application (AUTOMATOR)</name>
+ <build>
+ <finalName>automator</finalName>
+ </build>
+<dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.tomahawk</groupId>
+ <artifactId>tomahawk</artifactId>
+ <version>1.1.6</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+</dependencies>
+</project>
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/java/comboBox/ComboBoxGeneral.java
===================================================================
--- trunk/test-applications/automator/src/main/java/comboBox/ComboBoxGeneral.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/comboBox/ComboBoxGeneral.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,209 @@
+package comboBox;
+
+import general.DrawGrids;
+
+import java.util.ArrayList;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlPanelGrid;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
+import javax.faces.validator.ValidatorException;
+import org.richfaces.component.html.HtmlComboBox;
+import parser.Attribute;
+import parser.AttributesList;
+import parser.Status;
+import parser.TLDParser;
+import phaseTracker.PhaseTracker;
+
+public class ComboBoxGeneral {
+
+ private ArrayList<SelectItem> selectItems;
+ private HtmlComboBox comboBox;
+ private HtmlPanelGrid panelGrid;
+
+ // list of attributes
+ private boolean immediate;
+ private boolean required;
+ private String align;
+ private String validatorMessage;
+
+ private String statusValidator = "FAILED";
+ private String phaseValidator = "UNDEFINED";
+ private String validatorMessageTest = "";
+
+ private TLDParser tldParser = new TLDParser("comboBox");
+ private AttributesList attrs = tldParser.getAllAttributes();
+ private ArrayList<Attribute> generalAttrs = attrs.getCommonAttributes();
+
+ public ComboBoxGeneral() {
+ immediate = false;
+ required = true;
+ align = "right";
+ validatorMessage = "validator test message!";
+
+ selectItems = new ArrayList<SelectItem>();
+ for (int i = 0; i < 10; i++) {
+ selectItems.add(new SelectItem("selectItem " + i));
+ }
+ }
+
+ public void testGeneralAttributes(ActionEvent e) {
+ this.validatorCheck();
+ this.alignCheck();
+ this.validatorMessageCheck();
+ this.bindingCheck();
+
+ DrawGrids.showResultGrid(panelGrid, generalAttrs);
+ }
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+ statusValidator = "PASSED";
+ phaseValidator = PhaseTracker.currentPhase.toString();
+
+ String selectedItem = null;
+ if (value != null)
+ selectedItem = value.toString();
+ if (selectedItem.equals("Gosha"))
+ throw new ValidatorException(new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, "Validation error",
+ "Incorrect input"));
+ }
+
+ private void validatorCheck() {
+ int index = generalAttrs.indexOf(new Attribute("validator"));
+ if (index == -1) {
+ generalAttrs
+ .add(new Attribute(
+ "validator",
+ "void validator(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)",
+ "", Status.IMPLEMENTED));
+ } else {
+ Attribute attr = generalAttrs.get(index);
+ if (statusValidator.equals("PASSED")) {
+ if ((phaseValidator.equals("PROCESS_VALIDATIONS 3"))
+ && (!immediate)
+ || (phaseValidator.equals("APPLY_REQUEST_VALUES 2"))
+ && (immediate)) {
+ attr.setStatus(Status.PASSED);
+ } else {
+ attr.setStatus(Status.FAILED);
+ attr
+ .setDescription("Validator was triggered on incorrect phase");
+ }
+ } else {
+ attr.setStatus(Status.FAILED);
+ attr.setDescription("Validator was not triggered");
+ }
+ }
+ }
+
+ private void alignCheck() {
+ int index = generalAttrs.indexOf(new Attribute("align"));
+ if (index == -1) {
+ generalAttrs
+ .add(new Attribute("align", "", "", Status.IMPLEMENTED));
+ } else {
+ Attribute attr = generalAttrs.get(index);
+
+ attr.setStatus(Status.PASSED);
+ }
+ }
+
+ private void bindingCheck() {
+ int index = generalAttrs.indexOf(new Attribute("binding"));
+ if (index == -1) {
+ generalAttrs.add(new Attribute("binding", "", "",
+ Status.IMPLEMENTED));
+ } else {
+ Attribute attr = generalAttrs.get(index);
+ if (comboBox != null) {
+ attr.setStatus(Status.PASSED);
+ } else {
+ attr.setStatus(Status.FAILED);
+ }
+ }
+ }
+
+ private void validatorMessageCheck() {
+ int index = generalAttrs.indexOf(new Attribute("validatorMessage"));
+ if (index == -1) {
+ generalAttrs.add(new Attribute("validatorMessage", "", "",
+ Status.IMPLEMENTED));
+ } else {
+ Attribute attr = generalAttrs.get(index);
+
+ if (validatorMessageTest.indexOf(validatorMessage) != -1) {
+ attr.setStatus(Status.PASSED);
+ } else {
+ attr.setStatus(Status.FAILED);
+ }
+ }
+ }
+
+ public HtmlComboBox getComboBox() {
+ return comboBox;
+ }
+
+ public void setComboBox(HtmlComboBox comboBox) {
+ this.comboBox = comboBox;
+ }
+
+ public ArrayList<SelectItem> getSelectItems() {
+ return selectItems;
+ }
+
+ public HtmlPanelGrid getPanelGrid() {
+ return panelGrid;
+ }
+
+ public void setPanelGrid(HtmlPanelGrid panelGrid) {
+ this.panelGrid = panelGrid;
+ }
+
+ public boolean isImmediate() {
+ return immediate;
+ }
+
+ public void setImmediate(boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ public void setSelectItems(ArrayList<SelectItem> selectItems) {
+ this.selectItems = selectItems;
+ }
+
+ public String getAlign() {
+ return align;
+ }
+
+ public void setAlign(String align) {
+ this.align = align;
+ }
+
+ public String getValidatorMessage() {
+ return validatorMessage;
+ }
+
+ public void setValidatorMessage(String validatorMessage) {
+ this.validatorMessage = validatorMessage;
+ }
+
+ public String getValidatorMessageTest() {
+ return validatorMessageTest;
+ }
+
+ public void setValidatorMessageTest(String validatorMessageTest) {
+ this.validatorMessageTest = validatorMessageTest;
+ }
+}
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/java/general/DrawGrids.java
===================================================================
--- trunk/test-applications/automator/src/main/java/general/DrawGrids.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/general/DrawGrids.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,52 @@
+package general;
+
+import java.util.ArrayList;
+
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.component.html.HtmlPanelGrid;
+
+import parser.Attribute;
+
+public class DrawGrids {
+
+ public static void showResultGrid(HtmlPanelGrid panelGrid, ArrayList<Attribute> attrs) {
+ panelGrid.getChildren().clear();
+
+ HtmlOutputText attrNameHeader = new HtmlOutputText();
+ attrNameHeader.setValue("Attribute");
+ attrNameHeader.setStyle("font-weight: bold; font-size: large");
+
+ HtmlOutputText attrStatusHeader = new HtmlOutputText();
+ attrStatusHeader.setValue("Status");
+ attrStatusHeader.setStyle("font-weight: bold; font-size: large");
+
+ panelGrid.getChildren().add(attrNameHeader);
+ panelGrid.getChildren().add(attrStatusHeader);
+
+ for (Attribute a : attrs) {
+ HtmlOutputText attrName = new HtmlOutputText();
+ attrName.setValue(a.getName());
+ HtmlOutputText attrStatus = new HtmlOutputText();
+ attrStatus.setValue(a.getStatus());
+
+ switch (a.getStatus()) {
+ case FAILED:
+ attrStatus.setStyle("color: red");
+ break;
+ case PASSED:
+ attrStatus.setStyle("color: green");
+ break;
+ case NOT_READY:
+ attrStatus.setStyle("color: grey");
+ break;
+ }
+
+ panelGrid.getChildren().add(attrName);
+ panelGrid.getChildren().add(attrStatus);
+ }
+ }
+
+ public static void showEventGrid(HtmlPanelGrid panelGrid, ArrayList<String> events) {
+
+ }
+}
Added: trunk/test-applications/automator/src/main/java/general/General.java
===================================================================
--- trunk/test-applications/automator/src/main/java/general/General.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/general/General.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,18 @@
+package general;
+
+public class General {
+
+ private String componentPage;
+
+ public General() {
+ componentPage = "/main/componentsList.jsp";
+ }
+
+ public String getComponentPage() {
+ return componentPage;
+ }
+
+ public void setComponentPage(String componentPage) {
+ this.componentPage = componentPage;
+ }
+}
Added: trunk/test-applications/automator/src/main/java/parser/Attribute.java
===================================================================
--- trunk/test-applications/automator/src/main/java/parser/Attribute.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/parser/Attribute.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,69 @@
+package parser;
+
+public class Attribute {
+ private String name;
+ private String type;
+ private String description;
+ private Status status;
+
+ public Attribute(){
+ this.description = "";
+ }
+
+ public Attribute(String name){
+ this.name = name;
+ this.description = "";
+ }
+
+ public Attribute(String name, String type, String desc, Status status){
+ this.name = name;
+ this.type = type;
+ this.description = desc;
+ this.status = status;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+
+ @Override
+ public String toString(){
+ return "[" + "Name: " + name + "\r\n" + "Description: " + description + "\r\n" +
+ "Type: " + type + "\r\n" + "Status: " + status + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ Attribute attr = (Attribute) obj;
+
+ return (attr.getName().equals(this.name));
+ }
+}
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/java/parser/AttributesList.java
===================================================================
--- trunk/test-applications/automator/src/main/java/parser/AttributesList.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/parser/AttributesList.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,78 @@
+package parser;
+
+import java.util.ArrayList;
+
+public class AttributesList extends ArrayList<Attribute> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3245089852351607636L;
+
+ public AttributesList(){
+ super();
+ }
+
+ public ArrayList<String> getNamesArray(){
+ ArrayList<String> result = new ArrayList<String>();
+ for(Attribute attr:this){
+ result.add(attr.getName());
+ }
+ return result;
+ }
+
+ public ArrayList<String> getDescriptionArray(){
+ ArrayList<String> result = new ArrayList<String>();
+ for(Attribute attr:this){
+ result.add(attr.getDescription());
+ }
+ return result;
+ }
+
+ public ArrayList<String> getTypeArray(){
+ ArrayList<String> result = new ArrayList<String>();
+ for(Attribute attr:this){
+ result.add(attr.getType());
+ }
+ return result;
+ }
+
+ public ArrayList<Status> getStatusArray(){
+ ArrayList<Status> result = new ArrayList<Status>();
+ for(Attribute attr:this){
+ result.add(attr.getStatus());
+ }
+ return result;
+ }
+
+ public ArrayList<Attribute> getHandlers(){
+ ArrayList<Attribute> result = new ArrayList<Attribute>();
+ for(Attribute attr:this){
+ if (attr.getName().startsWith("on")) {
+ result.add(attr);
+ }
+ }
+ return result;
+ }
+
+ public ArrayList<Attribute> getStyles(){
+ ArrayList<Attribute> result = new ArrayList<Attribute>();
+ for(Attribute attr:this){
+ if (attr.getName().indexOf("tyle") != -1 || attr.getName().indexOf("lass") != -1) {
+ result.add(attr);
+ }
+ }
+ return result;
+ }
+
+ public ArrayList<Attribute> getCommonAttributes(){
+ ArrayList<Attribute> result = new ArrayList<Attribute>();
+ for(Attribute attr:this){
+ if(!(attr.getName().startsWith("on") || (attr.getName().indexOf("tyle") != -1) || (attr.getName().indexOf("lass") != -1))){
+ result.add(attr);
+ }
+ }
+ return result;
+ }
+
+}
Added: trunk/test-applications/automator/src/main/java/parser/Status.java
===================================================================
--- trunk/test-applications/automator/src/main/java/parser/Status.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/parser/Status.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,3 @@
+package parser;
+
+public enum Status {NOT_READY, IMPLEMENTED, FAILED, PASSED}
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/java/parser/TLDParser.java
===================================================================
--- trunk/test-applications/automator/src/main/java/parser/TLDParser.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/parser/TLDParser.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,124 @@
+package parser;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+public class TLDParser {
+
+ protected String component;
+ protected JarEntry tld;
+ protected JarFile richfacesUI;
+ protected AttributesList allAttributes;
+
+ public TLDParser(String str) {
+ this.component = str;
+ allAttributes = new AttributesList();
+ }
+
+ public AttributesList getAllAttributes() {
+ allAttributes.clear();
+ tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
+ InputStream input = null;
+ try {
+ input = richfacesUI.getInputStream(tld);
+
+ InputStreamReader isr = new InputStreamReader(input);
+ BufferedReader reader = new BufferedReader(isr);
+ String line, attr;
+ Attribute attribute = new Attribute();
+ int position, end;
+ boolean insideTag = true;
+ StringBuilder sb = new StringBuilder("");
+ while (((line = reader.readLine()) != null) && insideTag) {
+ if ((position = line.indexOf("<name>")) != -1) {
+ end = line.indexOf("</name>");
+ attr = line.substring(position + 6, end).trim();
+ if (attr.equalsIgnoreCase(component)) {
+ while (!(line = reader.readLine()).contains("</tag>")) {
+ if (line.contains("<attribute>")) {
+ do {
+ // find attribute name
+ if ((position = line.indexOf("<name>")) != -1) {
+ end = line.indexOf("</name>");
+ attribute.setName(line.substring(
+ position + 6, end).trim());
+ }
+ // find attribute description
+ if ((position = line.indexOf("<description>")) != -1) {
+
+ if((end = line.indexOf("</description>")) != -1){
+ attribute.setDescription(line.substring(position + 13, line.length()-14));
+ }else{
+ sb.append(line.substring(position + 13, line.length()).trim().replaceAll("\t", ""));
+ line = reader.readLine();
+ while ((end = line.indexOf("</description>")) == -1) {
+ sb.append(line.substring(0, line.length()).replaceAll("\t", ""));
+ line = reader.readLine();
+ }
+ sb.append(line.substring(0, line.length() - 14).trim().replaceAll("\t", ""));
+
+ attribute.setDescription(sb.toString());
+ sb.delete(0, sb.length());
+ }
+ }
+ // find attribute type
+ if ((position = line.indexOf("<type>")) != -1) {
+ end = line.indexOf("</type>");
+ attribute.setType(line.substring(position + 6, end).trim());
+ }
+ // find attribute method-signature
+ if ((position = line.indexOf("<method-signature>")) != -1) {
+ end = line.indexOf("</method-signature>");
+ attribute.setType(line.substring(position + 18, end).trim());
+ }
+ } while (!((line = reader.readLine())
+ .contains("</attribute>")));
+ // define attribute status
+ attribute.setStatus(Status.NOT_READY);
+ allAttributes.add(attribute);
+ attribute = new Attribute();
+ }
+ }
+ insideTag = false;
+ }
+ }
+ }
+ reader.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return allAttributes;
+ }
+
+ public String getExtPath() {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String resource = "META-INF/richfaces.tld";
+ return loader.getResource(resource).toString();
+ }
+
+ public String getComponent() {
+ return component;
+ }
+
+ public void setComponent(String component) {
+ this.component = component;
+ }
+
+ public JarFile getRichfacesUI() {
+ String temp = null;
+ int position;
+ try {
+ if ((position = getExtPath().indexOf('!')) != -1) {
+ temp = getExtPath().substring("jar:file:\\".length(), position);
+ }
+ richfacesUI = new JarFile(temp);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return richfacesUI;
+ }
+}
Added: trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTracker.java
===================================================================
--- trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTracker.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTracker.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,43 @@
+package phaseTracker;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * @author AYanul
+ *
+ */
+public class PhaseTracker implements PhaseListener {
+ /** The Constant serialVersionUID. */
+ private static final long serialVersionUID = 6533052212003582848L;
+
+ /** The Current JSF phase of the application. */
+ public static PhaseId currentPhase = PhaseId.ANY_PHASE;
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public void afterPhase(PhaseEvent arg0) {
+ System.out.println("PhaseTracker.afterPhase()" + arg0.getPhaseId());
+ if (arg0.getPhaseId().toString().equals("RENDER_RESPONSE 6"))
+ System.out.println("********** end lifecycle *************");
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public void beforePhase(PhaseEvent arg0) {
+ if (arg0.getPhaseId().toString().equals("RESTORE_VIEW 1"))
+ System.out.println("********** begin lifecycle *************");
+ currentPhase = arg0.getPhaseId();
+ System.out.println("PhaseTracker.beforePhase()" + arg0.getPhaseId());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.ANY_PHASE;
+ }
+}
Added: trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTrackerComponent.java
===================================================================
--- trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTrackerComponent.java (rev 0)
+++ trunk/test-applications/automator/src/main/java/phaseTracker/PhaseTrackerComponent.java 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,46 @@
+/**
+ *
+ */
+package phaseTracker;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Map;
+
+import javax.faces.component.UIPanel;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+/**
+ * @author user
+ *
+ */
+public class PhaseTrackerComponent extends UIPanel{
+
+ @Override
+ public void encodeAll(FacesContext context) throws IOException {
+ ResponseWriter responseWriter = context.getResponseWriter();
+ StringWriter stringWriter = new StringWriter();
+ ResponseWriter clonedWriter = responseWriter.cloneWithWriter(stringWriter);
+ context.setResponseWriter(clonedWriter);
+
+ super.encodeAll(context);
+ clonedWriter.flush();
+ context.setResponseWriter(responseWriter);
+
+ String string = stringWriter.toString();
+ responseWriter.write(string);
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+ requestMap.put("pttc", string);
+ }
+
+ @Override
+ public String getRendererType() {
+ return null;
+ }
+
+
+}
Added: trunk/test-applications/automator/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/test-applications/automator/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/META-INF/MANIFEST.MF 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
===================================================================
--- trunk/test-applications/automator/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS model-entity="JSFProcess"/>
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/components/ComboBox.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/components/ComboBox.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/General.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/General.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/ShowResults.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/general/ShowResults.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Attribute.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Attribute.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/AttributesList.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/AttributesList.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Status.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/Status.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/TLDParser.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/parser/TLDParser.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTracker.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTracker.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTrackerComponent.class
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/WEB-INF/classes/phaseTracker/PhaseTrackerComponent.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/test-applications/automator/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/WEB-INF/faces-config.xml 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+ <managed-bean>
+ <managed-bean-name>general</managed-bean-name>
+ <managed-bean-class>general.General</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>comboBoxGeneral</managed-bean-name>
+ <managed-bean-class>comboBox.ComboBoxGeneral</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <lifecycle>
+ <phase-listener>phaseTracker.PhaseTracker</phase-listener>
+ </lifecycle>
+</faces-config>
Added: trunk/test-applications/automator/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/automator/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/WEB-INF/web.xml 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>automator</display-name>
+ <context-param>
+ <param-name>org.richfaces.SKIN</param-name>
+ <param-value>classic</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.richfaces.LoadScriptStrategy</param-name>
+ <param-value>ALL</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>
+ <param-value>RESOURCE_URI_PREFIX</param-value>
+ </context-param>
+ <context-param>
+ <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <filter>
+ <display-name>RichFaces Filter</display-name>
+ <filter-name>richfaces</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>richfaces</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: trunk/test-applications/automator/src/main/webapp/component/comboBox.jsp
===================================================================
--- trunk/test-applications/automator/src/main/webapp/component/comboBox.jsp (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/component/comboBox.jsp 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,42 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
+<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
+
+<f:subview id="comboBoxSubview">
+ <div>The <rich:comboBox> is a component, that provides
+ editable combo box element on a page.</div>
+ <rich:spacer height="30"></rich:spacer>
+
+ <script type="text/javascript">
+ function showValue() {
+ var myMessage = document.getElementById('mainForm:comboBoxSubview:mess');
+ if(myMessage != null) {
+ myMessageText = myMessage.textContent;
+ document.getElementById('mainForm:comboBoxSubview:hiddenInput').value = myMessageText;
+ }
+ return true;
+ }
+ </script>
+
+ <h:panelGrid id="comboBoxGrid" columns="1" >
+ <h:messages id="mess" style="color: red" />
+ <rich:comboBox id="comboBox" binding="#{comboBoxGeneral.comboBox}"
+ align="#{comboBoxGeneral.align}" validator="#{comboBoxGeneral.validate}"
+ required="#{comboBoxGeneral.required}"
+ validatorMessage="#{comboBoxGeneral.validatorMessage}">
+ <f:selectItems value="#{comboBoxGeneral.selectItems}" />
+ <f:selectItem itemValue="Gosha" itemLabel="Gosha" />
+ </rich:comboBox>
+ <h:inputHidden id="hiddenInput" value="#{comboBoxGeneral.validatorMessageTest}" />
+ </h:panelGrid>
+ <rich:spacer height="30"></rich:spacer>
+
+ <a4j:commandButton value="testGeneralAttrs"
+ actionListener="#{comboBoxGeneral.testGeneralAttributes}"
+ reRender="generalResult, comboBoxGrid"></a4j:commandButton>
+
+ <h:panelGrid id="generalResult" binding="#{comboBoxGeneral.panelGrid}"
+ columns="2">
+ </h:panelGrid>
+</f:subview>
Added: trunk/test-applications/automator/src/main/webapp/icons/logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/automator/src/main/webapp/icons/logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/test-applications/automator/src/main/webapp/index.jsp
===================================================================
--- trunk/test-applications/automator/src/main/webapp/index.jsp (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/index.jsp 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head></head>
+ <body>
+ <jsp:forward page="/main/main.jsf" />
+ </body>
+</html>
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/webapp/main/componentsList.jsp
===================================================================
--- trunk/test-applications/automator/src/main/webapp/main/componentsList.jsp (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/main/componentsList.jsp 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,13 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
+<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
+
+<f:subview id="componentsListSubview">
+ <h:panelGrid columns="1">
+ <a4j:commandLink reRender="componentPage" value="Combo Box">
+ <a4j:actionparam value="/component/comboBox.jsp"
+ assignTo="#{general.componentPage}" />
+ </a4j:commandLink>
+ </h:panelGrid>
+</f:subview>
\ No newline at end of file
Added: trunk/test-applications/automator/src/main/webapp/main/main.jsp
===================================================================
--- trunk/test-applications/automator/src/main/webapp/main/main.jsp (rev 0)
+++ trunk/test-applications/automator/src/main/webapp/main/main.jsp 2008-11-04 16:12:17 UTC (rev 11018)
@@ -0,0 +1,36 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
+<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
+
+<f:view>
+ <html>
+ <head>
+ <title>Automator</title>
+ </head>
+ <body>
+ <h:form id="mainForm">
+ <div align="center"><h:panelGrid columns="2">
+ <h:graphicImage value="/icons/logo.png" />
+ <h:panelGroup>
+ <span style="color: orange; font-size: 50; font-family: cursive">Automator</span>
+ </h:panelGroup>
+ </h:panelGrid></div>
+ <div align="right"><h:panelGrid id="mainMenu" columns="3"
+ border="1">
+ <a4j:status id="a4jStatus" startText="WORK!" startStyle="color: red;"
+ stopText="a4j:status" />
+ <a4j:commandButton reRender="componentPage" value="reRender" />
+ <a4j:commandLink reRender="componentPage" value="Return" immediate="true">
+ <a4j:actionparam value="/main/componentsList.jsp"
+ assignTo="#{general.componentPage}" />
+ </a4j:commandLink>
+ </h:panelGrid></div>
+ <rich:spacer height="20"></rich:spacer>
+ <h:panelGrid id="componentPage" columns="1">
+ <jsp:include page="${general.componentPage}" />
+ </h:panelGrid>
+ </h:form>
+ </body>
+ </html>
+</f:view>
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11017 - trunk/test-applications/auto-jsp.
by richfaces-svn-commits@lists.jboss.org
Author: adubovsky
Date: 2008-11-04 11:09:28 -0500 (Tue, 04 Nov 2008)
New Revision: 11017
Removed:
trunk/test-applications/auto-jsp/.classpath
trunk/test-applications/auto-jsp/.project
Log:
Deleted: trunk/test-applications/auto-jsp/.classpath
===================================================================
--- trunk/test-applications/auto-jsp/.classpath 2008-11-04 16:06:42 UTC (rev 11016)
+++ trunk/test-applications/auto-jsp/.classpath 2008-11-04 16:09:28 UTC (rev 11017)
@@ -1,39 +0,0 @@
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar" sourcepath="M2_REPO/javax/el/el-api/1.0/el-api-1.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/nekohtml/nekohtml/0.9.5/nekohtml-0.9.5.jar" sourcepath="M2_REPO/nekohtml/nekohtml/0.9.5/nekohtml-0.9.5-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-core/3.3.0.CR1/hibernate-core-3.3.0.CR1.jar" sourcepath="M2_REPO/org/hibernate/hibernate-core/3.3.0.CR1/hibernate-core-3.3.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/oro/oro/2.0.8/oro-2.0.8.jar" sourcepath="M2_REPO/oro/oro/2.0.8/oro-2.0.8-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.0/commons-fileupload-1.0.jar" sourcepath="M2_REPO/commons-fileupload/commons-fileupload/1.0/commons-fileupload-1.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/3.1.0.CR1/hibernate-validator-3.1.0.CR1.jar" sourcepath="M2_REPO/org/hibernate/hibernate-validator/3.1.0.CR1/hibernate-validator-3.1.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar" sourcepath="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.4.2/slf4j-api-1.4.2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.1/commons-lang-2.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/com/uwyn/jhighlight/1.0/jhighlight-1.0.jar" sourcepath="M2_REPO/com/uwyn/jhighlight/1.0/jhighlight-1.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.3/commons-codec-1.3-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar" sourcepath="M2_REPO/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/richfaces/framework/richfaces-impl/3.3.0-SNAPSHOT/richfaces-impl-3.3.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/richfaces/framework/richfaces-impl/3.3.0-SNAPSHOT/richfaces-impl-3.3.0-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/myfaces/core/myfaces-impl/1.2.4/myfaces-impl-1.2.4.jar" sourcepath="M2_REPO/org/apache/myfaces/core/myfaces-impl/1.2.4/myfaces-impl-1.2.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.CR1/hibernate-commons-annotations-3.1.0.CR1.jar" sourcepath="M2_REPO/org/hibernate/hibernate-commons-annotations/3.1.0.CR1/hibernate-commons-annotations-3.1.0.CR1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-discovery/commons-discovery/0.4/commons-discovery-0.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/myfaces/core/myfaces-api/1.2.4/myfaces-api-1.2.4.jar" sourcepath="M2_REPO/org/apache/myfaces/core/myfaces-api/1.2.4/myfaces-api-1.2.4-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/richfaces/ui/richfaces-ui/3.3.0-SNAPSHOT/richfaces-ui-3.3.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/richfaces/ui/richfaces-ui/3.3.0-SNAPSHOT/richfaces-ui-3.3.0-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/myfaces/tomahawk/tomahawk/1.1.6/tomahawk-1.1.6.jar" sourcepath="M2_REPO/org/apache/myfaces/tomahawk/tomahawk/1.1.6/tomahawk-1.1.6-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-simple/1.4.2/slf4j-simple-1.4.2.jar" sourcepath="M2_REPO/org/slf4j/slf4j-simple/1.4.2/slf4j-simple-1.4.2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/richfaces/framework/richfaces-api/3.3.0-SNAPSHOT/richfaces-api-3.3.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/richfaces/framework/richfaces-api/3.3.0-SNAPSHOT/richfaces-api-3.3.0-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14.jar" sourcepath="M2_REPO/com/sun/facelets/jsf-facelets/1.1.14/jsf-facelets-1.1.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/servlet/jstl/1.0/jstl-1.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8.jar" sourcepath="M2_REPO/commons-digester/commons-digester/1.8/commons-digester-1.8-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0.jar" sourcepath="M2_REPO/commons-el/commons-el/1.0/commons-el-1.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1.jar" sourcepath="M2_REPO/commons-validator/commons-validator/1.3.1/commons-validator-1.3.1-sources.jar"/>
-</classpath>
\ No newline at end of file
Deleted: trunk/test-applications/auto-jsp/.project
===================================================================
--- trunk/test-applications/auto-jsp/.project 2008-11-04 16:06:42 UTC (rev 11016)
+++ trunk/test-applications/auto-jsp/.project 2008-11-04 16:09:28 UTC (rev 11017)
@@ -1,22 +0,0 @@
-<projectDescription>
- <name>auto-jsp</name>
- <comment/>
- <projects/>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
- <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
- </natures>
-</projectDescription>
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11016 - trunk/cdk/generator/src/main/resources/META-INF/schema/entities.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2008-11-04 11:06:42 -0500 (Tue, 04 Nov 2008)
New Revision: 11016
Modified:
trunk/cdk/generator/src/main/resources/META-INF/schema/entities/html_input_attributes.ent
Log:
RF-4610: inputNumberSlider: there is incorrect description of maxlength attribute
Modified: trunk/cdk/generator/src/main/resources/META-INF/schema/entities/html_input_attributes.ent
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/schema/entities/html_input_attributes.ent 2008-11-04 16:02:04 UTC (rev 11015)
+++ trunk/cdk/generator/src/main/resources/META-INF/schema/entities/html_input_attributes.ent 2008-11-04 16:06:42 UTC (rev 11016)
@@ -13,7 +13,10 @@
<property>
<name>maxlength</name>
<classname>int</classname>
- <description>When the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters you may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number</description>
+ <description>Specifies the maximum number of digits that could be entered into the input field.
+ The maximum number is unlimited by default.
+ If entered value exceeds the value specified in "maxValue" attribute than the slider takes a maximum value position.
+ </description>
</property>
</properties>
16 years, 1 month
JBoss Rich Faces SVN: r11015 - trunk/test-applications/auto-jsp/src/main/java/util/parser.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2008-11-04 11:02:04 -0500 (Tue, 04 Nov 2008)
New Revision: 11015
Modified:
trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java
Log:
getAllHandlers()
Modified: trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java
===================================================================
--- trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java 2008-11-04 16:01:39 UTC (rev 11014)
+++ trunk/test-applications/auto-jsp/src/main/java/util/parser/TLDParser.java 2008-11-04 16:02:04 UTC (rev 11015)
@@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.ArrayList;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -12,7 +13,7 @@
protected String component;
protected JarEntry tld;
protected JarFile richfacesUI;
- protected AttributesList allAttributes;
+ protected AttributesList allAttributes;
public TLDParser(String str) {
this.component = str;
@@ -48,32 +49,52 @@
position + 6, end).trim());
}
// find attribute description
- if ((position = line.indexOf("<description>")) != -1) {
-
- if((end = line.indexOf("</description>")) != -1){
- attribute.setDescription(line.substring(position + 13, line.length()-14));
- }else{
- sb.append(line.substring(position + 13, line.length()).trim().replaceAll("\t", ""));
+ if ((position = line
+ .indexOf("<description>")) != -1) {
+
+ if ((end = line
+ .indexOf("</description>")) != -1) {
+ attribute
+ .setDescription(line
+ .substring(
+ position + 13,
+ line
+ .length() - 14));
+ } else {
+ sb.append(line.substring(
+ position + 13,
+ line.length()).trim()
+ .replaceAll("\t", ""));
line = reader.readLine();
- while ((end = line.indexOf("</description>")) == -1) {
- sb.append(line.substring(0, line.length()).replaceAll("\t", ""));
+ while ((end = line
+ .indexOf("</description>")) == -1) {
+ sb.append(line.substring(0,
+ line.length())
+ .replaceAll("\t", ""));
line = reader.readLine();
}
- sb.append(line.substring(0, line.length() - 14).trim().replaceAll("\t", ""));
-
- attribute.setDescription(sb.toString());
+ sb.append(line.substring(0,
+ line.length() - 14).trim()
+ .replaceAll("\t", ""));
+
+ attribute.setDescription(sb
+ .toString());
sb.delete(0, sb.length());
- }
- }
+ }
+ }
// find attribute type
if ((position = line.indexOf("<type>")) != -1) {
end = line.indexOf("</type>");
- attribute.setType(line.substring(position + 6, end).trim());
+ attribute.setType(line.substring(
+ position + 6, end).trim());
}
// find attribute method-signature
- if ((position = line.indexOf("<method-signature>")) != -1) {
- end = line.indexOf("</method-signature>");
- attribute.setType(line.substring(position + 18, end).trim());
+ if ((position = line
+ .indexOf("<method-signature>")) != -1) {
+ end = line
+ .indexOf("</method-signature>");
+ attribute.setType(line.substring(
+ position + 18, end).trim());
}
} while (!((line = reader.readLine())
.contains("</attribute>")));
@@ -120,5 +141,33 @@
e.printStackTrace();
}
return richfacesUI;
- }
+ }
+
+ public ArrayList<String> getAllHandlers() {
+ tld = getRichfacesUI().getJarEntry("META-INF/richfaces.tld");
+ InputStream input = null;
+ ArrayList<String> handlers = new ArrayList<String>();
+
+ try {
+ input = richfacesUI.getInputStream(tld);
+ InputStreamReader isr = new InputStreamReader(input);
+ BufferedReader reader = new BufferedReader(isr);
+ String line, temp;
+ int start, end;
+ while ((line = reader.readLine()) != null) {
+ if ((start = line.indexOf("<name>")) != -1) {
+ end = line.indexOf("</name>");
+ temp = line.substring(start + 6, end).trim();
+ if (temp.startsWith("on") && !handlers.contains(temp)) {
+ handlers.add(temp);
+ }
+ }
+ }
+ return handlers;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
}
16 years, 1 month
JBoss Rich Faces SVN: r11014 - trunk/test-applications/auto-jsp/src/main/java/util/componentInfo.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2008-11-04 11:01:39 -0500 (Tue, 04 Nov 2008)
New Revision: 11014
Modified:
trunk/test-applications/auto-jsp/src/main/java/util/componentInfo/ComponentInfo.java
Log:
handlers example
Modified: trunk/test-applications/auto-jsp/src/main/java/util/componentInfo/ComponentInfo.java
===================================================================
--- trunk/test-applications/auto-jsp/src/main/java/util/componentInfo/ComponentInfo.java 2008-11-04 15:36:26 UTC (rev 11013)
+++ trunk/test-applications/auto-jsp/src/main/java/util/componentInfo/ComponentInfo.java 2008-11-04 16:01:39 UTC (rev 11014)
@@ -95,9 +95,10 @@
}
System.out.println("----------HANDLERS----------");
- for(Attribute attr:allAttributes.getHandlers()){
- System.out.println(attr.getName());
+ for(String attr:parser.getAllHandlers()){
+ System.out.println(attr);
}
+ System.out.println("total size: " + parser.getAllHandlers().size());
AccessibleObject.setAccessible(fields, true);
for (Field field : fields) {
16 years, 1 month
JBoss Rich Faces SVN: r11013 - trunk/sandbox/ui/editor.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-04 10:36:26 -0500 (Tue, 04 Nov 2008)
New Revision: 11013
Modified:
trunk/sandbox/ui/editor/pom.xml
Log:
Modified: trunk/sandbox/ui/editor/pom.xml
===================================================================
--- trunk/sandbox/ui/editor/pom.xml 2008-11-04 15:08:16 UTC (rev 11012)
+++ trunk/sandbox/ui/editor/pom.xml 2008-11-04 15:36:26 UTC (rev 11013)
@@ -45,6 +45,7 @@
<artifactId>antlr-maven-plugin</artifactId>
<executions>
<execution>
+ <phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
16 years, 1 month
JBoss Rich Faces SVN: r11012 - trunk/sandbox/ui/editor/src/main/antlr.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-04 10:08:16 -0500 (Tue, 04 Nov 2008)
New Revision: 11012
Modified:
trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
Log:
remove sanitizer interface and default sanitizer implementation from grammar file use import instead ...
Modified: trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
===================================================================
--- trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g 2008-11-04 11:34:08 UTC (rev 11011)
+++ trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g 2008-11-04 15:08:16 UTC (rev 11012)
@@ -3,6 +3,11 @@
package org.richfaces.antlr;
}
+{
+ import org.jboss.seam.text.SeamTextParser.DefaultSanitizer;
+ import org.jboss.seam.text.SeamTextParser.Sanitizer;
+}
+
class HtmlSeamTextParser extends Parser;
options
@@ -12,321 +17,32 @@
}
{
- public class HtmlRecognitionException extends RecognitionException {
- Token openingElement;
- RecognitionException wrappedException;
-
- public HtmlRecognitionException(Token openingElement, RecognitionException wrappedException) {
- this.openingElement = openingElement;
- this.wrappedException = wrappedException;
- }
-
- public Token getOpeningElement() {
- return openingElement;
- }
-
- public String getMessage() {
- return wrappedException.getMessage();
- }
-
- public Throwable getCause() {
- return wrappedException;
- }
- }
-
- public interface Sanitizer {
+
+ public class HtmlRecognitionException extends RecognitionException {
+ Token openingElement;
+ RecognitionException wrappedException;
- public void validateLinkTagURI(Token element, String uri) throws SemanticException;
- public void validateHtmlElement(Token element) throws SemanticException;
- public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException;
- public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException;
- public void escapeSeamTextToken(Token element);
- public String getInvalidURIMessage(String uri);
- public String getInvalidElementMessage(String elementName);
- public String getInvalidAttributeMessage(String elementName, String attributeName);
- public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value);
+ public HtmlRecognitionException(Token openingElement, RecognitionException wrappedException) {
+ this.openingElement = openingElement;
+ this.wrappedException = wrappedException;
+ }
- }
-
- public static class DefaultSanitizer implements HtmlSeamTextParser.Sanitizer {
-
- protected java.util.Set<String> attributesWhoseValueIsAURI = new java.util.HashSet(java.util.Arrays.asList(
- "action", "cite", "href", "longdesc", "src", "xlink:href", "xml:base"
- ));
-
-
- protected java.util.Set<String> uriSchemes = new java.util.HashSet(java.util.Arrays.asList(
- "afs", "aim", "callto", "ed2k", "feed", "ftp", "gopher", "http", "https",
- "irc", "mailto", "news", "nntp", "rsync", "rtsp", "sftp", "ssh", "tag",
- "tel", "telnet", "urn", "webcal", "wtai", "xmpp"
- ));
-
- protected java.util.Set<String> acceptableElements = new java.util.HashSet(java.util.Arrays.asList(
- "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote",
- "br", "button", "caption", "center", "cite", "code", "col", "colgroup", "dd",
- "del", "dfn", "dir", "div", "dl", "dt", "em", "fieldset", "font", "form",
- "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "input", "ins", "kbd",
- "label", "legend", "li", "map", "menu", "ol", "optgroup", "option", "p",
- "pre", "q", "s", "samp", "select", "small", "span", "strike", "strong",
- "sub", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead",
- "tr", "tt", "u", "ul", "var", "wbr"
- ));
+ public Token getOpeningElement() {
+ return openingElement;
+ }
- protected java.util.Set<String> mathmlElements = new java.util.HashSet(java.util.Arrays.asList(
- "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo",
- "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "mspace",
- "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext",
- "mtr", "munder", "munderover", "none"
- ));
+ public String getMessage() {
+ return wrappedException.getMessage();
+ }
- protected java.util.Set<String> svgElements = new java.util.HashSet(java.util.Arrays.asList(
- "a", "animate", "animateColor", "animateMotion", "animateTransform",
- "circle", "defs", "desc", "ellipse", "font-face", "font-face-name",
- "font-face-src", "g", "glyph", "hkern", "image", "line", "linearGradient",
- "marker", "metadata", "missing-glyph", "mpath", "path", "polygon",
- "polyline", "radialGradient", "rect", "set", "stop", "svg", "switch", "text",
- "title", "tspan", "use"
- ));
-
- protected java.util.Set<String> acceptableAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "abbr", "accept", "accept-charset", "accesskey", "action", "align", "alt",
- "axis", "border", "cellpadding", "cellspacing", "char", "charoff", "charset",
- "checked", "cite", "class", "clear", "color", "cols", "colspan", "compact",
- "coords", "datetime", "dir", "disabled", "enctype", "for", "frame",
- "headers", "height", "href", "hreflang", "hspace", "id", "ismap", "label",
- "lang", "longdesc", "maxlength", "media", "method", "multiple", "name",
- "nohref", "noshade", "nowrap", "prompt", "readonly", "rel", "rev", "rows",
- "rowspan", "rules", "scope", "selected", "shape", "size", "span", "src",
- "start", "style", "summary", "tabindex", "target", "title", "type", "usemap",
- "valign", "value", "vspace", "width", "xml:lang"
- ));
-
- protected java.util.Set<String> mathmlAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "actiontype", "align", "columnalign", "columnalign", "columnalign",
- "columnlines", "columnspacing", "columnspan", "depth", "display",
- "displaystyle", "equalcolumns", "equalrows", "fence", "fontstyle",
- "fontweight", "frame", "height", "linethickness", "lspace", "mathbackground",
- "mathcolor", "mathvariant", "mathvariant", "maxsize", "minsize", "other",
- "rowalign", "rowalign", "rowalign", "rowlines", "rowspacing", "rowspan",
- "rspace", "scriptlevel", "selection", "separator", "stretchy", "width",
- "width", "xlink:href", "xlink:show", "xlink:type", "xmlns", "xmlns:xlink"
- ));
-
-
- protected java.util.Set<String> svgAttributes = new java.util.HashSet(java.util.Arrays.asList(
- "accent-height", "accumulate", "additive", "alphabetic", "arabic-form",
- "ascent", "attributeName", "attributeType", "baseProfile", "bbox", "begin",
- "by", "calcMode", "cap-height", "class", "color", "color-rendering",
- "content", "cx", "cy", "d", "descent", "display", "dur", "dx", "dy", "end",
- "fill", "fill-rule", "font-family", "font-size", "font-stretch",
- "font-style", "font-variant", "font-weight", "from", "fx", "fy", "g1", "g2",
- "glyph-name", "gradientUnits", "hanging", "height", "horiz-adv-x",
- "horiz-origin-x", "id", "ideographic", "k", "keyPoints", "keySplines",
- "keyTimes", "lang", "marker-end", "marker-mid", "marker-start",
- "markerHeight", "markerUnits", "markerWidth", "mathematical", "max", "min",
- "name", "offset", "opacity", "orient", "origin", "overline-position",
- "overline-thickness", "panose-1", "path", "pathLength", "points",
- "preserveAspectRatio", "r", "refX", "refY", "repeatCount", "repeatDur",
- "requiredExtensions", "requiredFeatures", "restart", "rotate", "rx", "ry",
- "slope", "stemh", "stemv", "stop-color", "stop-opacity",
- "strikethrough-position", "strikethrough-thickness", "stroke",
- "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
- "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage",
- "target", "text-anchor", "to", "transform", "type", "u1", "u2",
- "underline-position", "underline-thickness", "unicode", "unicode-range",
- "units-per-em", "values", "version", "viewBox", "visibility", "width",
- "widths", "x", "x-height", "x1", "x2", "xlink:actuate", "xlink:arcrole",
- "xlink:href", "xlink:role", "xlink:show", "xlink:title", "xlink:type",
- "xml:base", "xml:lang", "xml:space", "xmlns", "xmlns:xlink", "y", "y1", "y2",
- "zoomAndPan"
- ));
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_VALUE = java.util.regex.Pattern.compile(
- "^(#[0-9a-f]{3,6}|rgb\\(\\d{1,3}%?,\\d{1,3}%?,?\\d{1,3}%?\\)?|-?\\d{0,2}\\.?\\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\\))?)$"
- );
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_STRING1 = java.util.regex.Pattern.compile(
- "^([-:,;#%.\\sa-zA-Z0-9!]|\\w-\\w|'[\\s\\w]+'|\"[\\s\\w]+\"|\\([\\d,\\s]+\\))*$"
- );
-
- public final java.util.regex.Pattern REGEX_VALID_CSS_STRING2 = java.util.regex.Pattern.compile(
- "^(\\s*[-\\w]+\\s*:\\s*[^:;]*(;|$))*$"
- );
-
-
- protected java.util.Set<String> styleProperties = new java.util.HashSet(java.util.Arrays.asList(
- "azimuth",
- "background", "background-attachment", "background-color", "background-image",
- "background-position", "background-repeat",
- "border", "border-bottom", "border-bottom-color", "border-bottom-style",
- "border-bottom-width", "border-collapse", "border-color", "border-left",
- "border-left-color", "border-left-style", "border-left-width", "border-right",
- "border-right-color", "border-right-style", "border-right-width", "border-spacing",
- "border-style", "border-top", "border-top-color", "border-top-style",
- "border-top-width", "border-width",
- "clear", "color",
- "cursor", "direction", "display", "elevation", "float", "font",
- "font-family", "font-size", "font-style", "font-variant", "font-weight",
- "height", "letter-spacing", "line-height",
- "margin", "margin-bottom", "margin-left", "margin-right", "margin-top",
- "max-height", "max-width", "min-height", "min-width",
- "overflow",
- "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
- "pause", "pause-after", "pause-before", "pitch",
- "pitch-range", "richness", "speak", "speak-header", "speak-numeral",
- "speak-punctuation", "speech-rate", "stress", "text-align",
- "text-decoration", "text-indent", "unicode-bidi", "vertical-align",
- "voice-family", "volume", "white-space", "width"
- ));
-
-
- protected java.util.Set<String> stylePropertiesValues = new java.util.HashSet(java.util.Arrays.asList(
- "aqua", "auto", "baseline", "black", "block", "blue", "bold", "both", "bottom", "brown",
- "center", "collapse", "dashed", "dotted", "fuchsia", "gray", "green",
- "inherit", "italic", "left", "length", "lime", "maroon", "medium", "middle", "navy", "none", "normal",
- "nowrap", "olive", "percentage", "pointer", "purple", "red", "right", "silver", "solid", "sub", "super",
- "teal", "text-bottom", "text-top", "top", "transparent", "underline", "white", "yellow"
- ));
-
- protected java.util.Set<String> svgStyleProperties = new java.util.HashSet(java.util.Arrays.asList(
- "fill", "fill-opacity", "fill-rule", "stroke", "stroke-linecap",
- "stroke-linejoin", "stroke-opacity", "stroke-width"
- ));
-
-
- public void validateLinkTagURI(Token element, String uri) throws SemanticException {
- if (!validateURI(uri)) {
- throw createSemanticException("Invalid URI", element);
- }
- }
-
- public void validateHtmlElement(Token element) throws SemanticException {
- String elementName = element.getText().toLowerCase();
- if (!acceptableElements.contains(elementName) &&
- !svgElements.contains(elementName) &&
- !mathmlElements.contains(elementName)) {
- throw createSemanticException(getInvalidElementMessage(elementName), element);
- }
- }
-
- public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException {
- String elementName = element.getText().toLowerCase();
- String attributeName = attribute.getText().toLowerCase();
- if (!acceptableAttributes.contains(attributeName) &&
- !svgAttributes.contains(attributeName) &&
- !mathmlAttributes.contains(attributeName)) {
- throw createSemanticException(getInvalidAttributeMessage(elementName, attributeName), element);
- }
-
- }
-
- public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException{
-
- if (attributeValue == null || attributeValue.length() == 0) return;
-
- String elementName = element.getText().toLowerCase();
- String attributeName = attribute.getText().toLowerCase();
-
- // Check element with attribute that has URI value (href, src, etc.)
- if (attributesWhoseValueIsAURI.contains(attributeName) && !validateURI(attributeValue)) {
- throw createSemanticException(getInvalidURIMessage(attributeValue), element);
- }
-
- // Check attribute value of style (CSS filtering)
- if (attributeName.equals("style")) {
- if (!REGEX_VALID_CSS_STRING1.matcher(attributeValue).matches() ||
- !REGEX_VALID_CSS_STRING2.matcher(attributeValue).matches()) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
-
- String[] cssProperties = attributeValue.split(";");
- for (String cssProperty : cssProperties) {
- if (!cssProperty.contains(":")) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
- String[] property = cssProperty.split(":");
- String propertyName = property[0].trim();
- String propertyValue = property.length == 2 ? property[1].trim() : null;
-
- // CSS property name
- if (!styleProperties.contains(propertyName) &&
- !svgStyleProperties.contains(propertyName)) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
-
- // CSS property value
- if (propertyValue != null && !stylePropertiesValues.contains(propertyValue)) {
- // Not in list, now check the regex
- if (!REGEX_VALID_CSS_VALUE.matcher(propertyValue).matches()) {
- throw createSemanticException(
- getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
- element
- );
- }
- }
- }
- }
-
-
- }
-
- public String getInvalidURIMessage(String uri){
- return "invalid URI";
- }
-
- public String getInvalidElementMessage(String elementName){
- return "invalid element '" + elementName + "'";
- }
-
- public String getInvalidAttributeMessage(String elementName, String attributeName){
- return "invalid attribute '" + attributeName + "' for element '" + elementName + "'";
- }
-
- public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value){
- return "invalid value of attribute '" + attributeName + "' for element '" + elementName + "'";
- }
-
- public void escapeSeamTextToken(Token element) {
- }
-
- protected boolean validateURI(String uri) {
-
- // Relative URI starts with a slash
- if (uri.startsWith("/")) return true;
-
- java.net.URI parsedURI;
- try {
- parsedURI = new java.net.URI(uri);
- } catch (java.net.URISyntaxException ex) {
- return false;
- }
-
- if (!uriSchemes.contains(parsedURI.getScheme())) {
- return false;
- }
- return true;
+ public Throwable getCause() {
+ return wrappedException;
}
-
- public SemanticException createSemanticException(String message, Token element) {
- return new SemanticException(
- message,
- element.getFilename(), element.getLine(), element.getColumn()
- );
- }
-
- }
+ }
+
+
-
private final String SEAMTEXT_MONOSPACE = "|";
private final String SEAMTEXT_TWIDDLE = "~";
16 years, 1 month
JBoss Rich Faces SVN: r11011 - in trunk/sandbox/ui/editor/src/main: antlr and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-11-04 06:34:08 -0500 (Tue, 04 Nov 2008)
New Revision: 11011
Added:
trunk/sandbox/ui/editor/src/main/antlr/
trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
Log:
Added: trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g
===================================================================
--- trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g (rev 0)
+++ trunk/sandbox/ui/editor/src/main/antlr/html-seamtext.g 2008-11-04 11:34:08 UTC (rev 11011)
@@ -0,0 +1,1070 @@
+header
+{
+ package org.richfaces.antlr;
+}
+
+class HtmlSeamTextParser extends Parser;
+
+options
+{
+ k=4;
+ defaultErrorHandler=false;
+}
+
+{
+ public class HtmlRecognitionException extends RecognitionException {
+ Token openingElement;
+ RecognitionException wrappedException;
+
+ public HtmlRecognitionException(Token openingElement, RecognitionException wrappedException) {
+ this.openingElement = openingElement;
+ this.wrappedException = wrappedException;
+ }
+
+ public Token getOpeningElement() {
+ return openingElement;
+ }
+
+ public String getMessage() {
+ return wrappedException.getMessage();
+ }
+
+ public Throwable getCause() {
+ return wrappedException;
+ }
+ }
+
+
+ public interface Sanitizer {
+
+ public void validateLinkTagURI(Token element, String uri) throws SemanticException;
+ public void validateHtmlElement(Token element) throws SemanticException;
+ public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException;
+ public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException;
+ public void escapeSeamTextToken(Token element);
+ public String getInvalidURIMessage(String uri);
+ public String getInvalidElementMessage(String elementName);
+ public String getInvalidAttributeMessage(String elementName, String attributeName);
+ public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value);
+
+ }
+
+ public static class DefaultSanitizer implements HtmlSeamTextParser.Sanitizer {
+
+ protected java.util.Set<String> attributesWhoseValueIsAURI = new java.util.HashSet(java.util.Arrays.asList(
+ "action", "cite", "href", "longdesc", "src", "xlink:href", "xml:base"
+ ));
+
+
+ protected java.util.Set<String> uriSchemes = new java.util.HashSet(java.util.Arrays.asList(
+ "afs", "aim", "callto", "ed2k", "feed", "ftp", "gopher", "http", "https",
+ "irc", "mailto", "news", "nntp", "rsync", "rtsp", "sftp", "ssh", "tag",
+ "tel", "telnet", "urn", "webcal", "wtai", "xmpp"
+ ));
+
+ protected java.util.Set<String> acceptableElements = new java.util.HashSet(java.util.Arrays.asList(
+ "a", "abbr", "acronym", "address", "area", "b", "bdo", "big", "blockquote",
+ "br", "button", "caption", "center", "cite", "code", "col", "colgroup", "dd",
+ "del", "dfn", "dir", "div", "dl", "dt", "em", "fieldset", "font", "form",
+ "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "input", "ins", "kbd",
+ "label", "legend", "li", "map", "menu", "ol", "optgroup", "option", "p",
+ "pre", "q", "s", "samp", "select", "small", "span", "strike", "strong",
+ "sub", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead",
+ "tr", "tt", "u", "ul", "var", "wbr"
+ ));
+
+ protected java.util.Set<String> mathmlElements = new java.util.HashSet(java.util.Arrays.asList(
+ "maction", "math", "merror", "mfrac", "mi", "mmultiscripts", "mn", "mo",
+ "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "mspace",
+ "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext",
+ "mtr", "munder", "munderover", "none"
+ ));
+
+ protected java.util.Set<String> svgElements = new java.util.HashSet(java.util.Arrays.asList(
+ "a", "animate", "animateColor", "animateMotion", "animateTransform",
+ "circle", "defs", "desc", "ellipse", "font-face", "font-face-name",
+ "font-face-src", "g", "glyph", "hkern", "image", "line", "linearGradient",
+ "marker", "metadata", "missing-glyph", "mpath", "path", "polygon",
+ "polyline", "radialGradient", "rect", "set", "stop", "svg", "switch", "text",
+ "title", "tspan", "use"
+ ));
+
+ protected java.util.Set<String> acceptableAttributes = new java.util.HashSet(java.util.Arrays.asList(
+ "abbr", "accept", "accept-charset", "accesskey", "action", "align", "alt",
+ "axis", "border", "cellpadding", "cellspacing", "char", "charoff", "charset",
+ "checked", "cite", "class", "clear", "color", "cols", "colspan", "compact",
+ "coords", "datetime", "dir", "disabled", "enctype", "for", "frame",
+ "headers", "height", "href", "hreflang", "hspace", "id", "ismap", "label",
+ "lang", "longdesc", "maxlength", "media", "method", "multiple", "name",
+ "nohref", "noshade", "nowrap", "prompt", "readonly", "rel", "rev", "rows",
+ "rowspan", "rules", "scope", "selected", "shape", "size", "span", "src",
+ "start", "style", "summary", "tabindex", "target", "title", "type", "usemap",
+ "valign", "value", "vspace", "width", "xml:lang"
+ ));
+
+ protected java.util.Set<String> mathmlAttributes = new java.util.HashSet(java.util.Arrays.asList(
+ "actiontype", "align", "columnalign", "columnalign", "columnalign",
+ "columnlines", "columnspacing", "columnspan", "depth", "display",
+ "displaystyle", "equalcolumns", "equalrows", "fence", "fontstyle",
+ "fontweight", "frame", "height", "linethickness", "lspace", "mathbackground",
+ "mathcolor", "mathvariant", "mathvariant", "maxsize", "minsize", "other",
+ "rowalign", "rowalign", "rowalign", "rowlines", "rowspacing", "rowspan",
+ "rspace", "scriptlevel", "selection", "separator", "stretchy", "width",
+ "width", "xlink:href", "xlink:show", "xlink:type", "xmlns", "xmlns:xlink"
+ ));
+
+
+ protected java.util.Set<String> svgAttributes = new java.util.HashSet(java.util.Arrays.asList(
+ "accent-height", "accumulate", "additive", "alphabetic", "arabic-form",
+ "ascent", "attributeName", "attributeType", "baseProfile", "bbox", "begin",
+ "by", "calcMode", "cap-height", "class", "color", "color-rendering",
+ "content", "cx", "cy", "d", "descent", "display", "dur", "dx", "dy", "end",
+ "fill", "fill-rule", "font-family", "font-size", "font-stretch",
+ "font-style", "font-variant", "font-weight", "from", "fx", "fy", "g1", "g2",
+ "glyph-name", "gradientUnits", "hanging", "height", "horiz-adv-x",
+ "horiz-origin-x", "id", "ideographic", "k", "keyPoints", "keySplines",
+ "keyTimes", "lang", "marker-end", "marker-mid", "marker-start",
+ "markerHeight", "markerUnits", "markerWidth", "mathematical", "max", "min",
+ "name", "offset", "opacity", "orient", "origin", "overline-position",
+ "overline-thickness", "panose-1", "path", "pathLength", "points",
+ "preserveAspectRatio", "r", "refX", "refY", "repeatCount", "repeatDur",
+ "requiredExtensions", "requiredFeatures", "restart", "rotate", "rx", "ry",
+ "slope", "stemh", "stemv", "stop-color", "stop-opacity",
+ "strikethrough-position", "strikethrough-thickness", "stroke",
+ "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
+ "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage",
+ "target", "text-anchor", "to", "transform", "type", "u1", "u2",
+ "underline-position", "underline-thickness", "unicode", "unicode-range",
+ "units-per-em", "values", "version", "viewBox", "visibility", "width",
+ "widths", "x", "x-height", "x1", "x2", "xlink:actuate", "xlink:arcrole",
+ "xlink:href", "xlink:role", "xlink:show", "xlink:title", "xlink:type",
+ "xml:base", "xml:lang", "xml:space", "xmlns", "xmlns:xlink", "y", "y1", "y2",
+ "zoomAndPan"
+ ));
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_VALUE = java.util.regex.Pattern.compile(
+ "^(#[0-9a-f]{3,6}|rgb\\(\\d{1,3}%?,\\d{1,3}%?,?\\d{1,3}%?\\)?|-?\\d{0,2}\\.?\\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\\))?)$"
+ );
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_STRING1 = java.util.regex.Pattern.compile(
+ "^([-:,;#%.\\sa-zA-Z0-9!]|\\w-\\w|'[\\s\\w]+'|\"[\\s\\w]+\"|\\([\\d,\\s]+\\))*$"
+ );
+
+ public final java.util.regex.Pattern REGEX_VALID_CSS_STRING2 = java.util.regex.Pattern.compile(
+ "^(\\s*[-\\w]+\\s*:\\s*[^:;]*(;|$))*$"
+ );
+
+
+ protected java.util.Set<String> styleProperties = new java.util.HashSet(java.util.Arrays.asList(
+ "azimuth",
+ "background", "background-attachment", "background-color", "background-image",
+ "background-position", "background-repeat",
+ "border", "border-bottom", "border-bottom-color", "border-bottom-style",
+ "border-bottom-width", "border-collapse", "border-color", "border-left",
+ "border-left-color", "border-left-style", "border-left-width", "border-right",
+ "border-right-color", "border-right-style", "border-right-width", "border-spacing",
+ "border-style", "border-top", "border-top-color", "border-top-style",
+ "border-top-width", "border-width",
+ "clear", "color",
+ "cursor", "direction", "display", "elevation", "float", "font",
+ "font-family", "font-size", "font-style", "font-variant", "font-weight",
+ "height", "letter-spacing", "line-height",
+ "margin", "margin-bottom", "margin-left", "margin-right", "margin-top",
+ "max-height", "max-width", "min-height", "min-width",
+ "overflow",
+ "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
+ "pause", "pause-after", "pause-before", "pitch",
+ "pitch-range", "richness", "speak", "speak-header", "speak-numeral",
+ "speak-punctuation", "speech-rate", "stress", "text-align",
+ "text-decoration", "text-indent", "unicode-bidi", "vertical-align",
+ "voice-family", "volume", "white-space", "width"
+ ));
+
+
+ protected java.util.Set<String> stylePropertiesValues = new java.util.HashSet(java.util.Arrays.asList(
+ "aqua", "auto", "baseline", "black", "block", "blue", "bold", "both", "bottom", "brown",
+ "center", "collapse", "dashed", "dotted", "fuchsia", "gray", "green",
+ "inherit", "italic", "left", "length", "lime", "maroon", "medium", "middle", "navy", "none", "normal",
+ "nowrap", "olive", "percentage", "pointer", "purple", "red", "right", "silver", "solid", "sub", "super",
+ "teal", "text-bottom", "text-top", "top", "transparent", "underline", "white", "yellow"
+ ));
+
+ protected java.util.Set<String> svgStyleProperties = new java.util.HashSet(java.util.Arrays.asList(
+ "fill", "fill-opacity", "fill-rule", "stroke", "stroke-linecap",
+ "stroke-linejoin", "stroke-opacity", "stroke-width"
+ ));
+
+
+ public void validateLinkTagURI(Token element, String uri) throws SemanticException {
+ if (!validateURI(uri)) {
+ throw createSemanticException("Invalid URI", element);
+ }
+ }
+
+ public void validateHtmlElement(Token element) throws SemanticException {
+ String elementName = element.getText().toLowerCase();
+ if (!acceptableElements.contains(elementName) &&
+ !svgElements.contains(elementName) &&
+ !mathmlElements.contains(elementName)) {
+ throw createSemanticException(getInvalidElementMessage(elementName), element);
+ }
+ }
+
+ public void validateHtmlAttribute(Token element, Token attribute) throws SemanticException {
+ String elementName = element.getText().toLowerCase();
+ String attributeName = attribute.getText().toLowerCase();
+ if (!acceptableAttributes.contains(attributeName) &&
+ !svgAttributes.contains(attributeName) &&
+ !mathmlAttributes.contains(attributeName)) {
+ throw createSemanticException(getInvalidAttributeMessage(elementName, attributeName), element);
+ }
+
+ }
+
+ public void validateHtmlAttributeValue(Token element, Token attribute, String attributeValue) throws SemanticException{
+
+ if (attributeValue == null || attributeValue.length() == 0) return;
+
+ String elementName = element.getText().toLowerCase();
+ String attributeName = attribute.getText().toLowerCase();
+
+ // Check element with attribute that has URI value (href, src, etc.)
+ if (attributesWhoseValueIsAURI.contains(attributeName) && !validateURI(attributeValue)) {
+ throw createSemanticException(getInvalidURIMessage(attributeValue), element);
+ }
+
+ // Check attribute value of style (CSS filtering)
+ if (attributeName.equals("style")) {
+ if (!REGEX_VALID_CSS_STRING1.matcher(attributeValue).matches() ||
+ !REGEX_VALID_CSS_STRING2.matcher(attributeValue).matches()) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
+ element
+ );
+ }
+
+ String[] cssProperties = attributeValue.split(";");
+ for (String cssProperty : cssProperties) {
+ if (!cssProperty.contains(":")) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
+ element
+ );
+ }
+ String[] property = cssProperty.split(":");
+ String propertyName = property[0].trim();
+ String propertyValue = property.length == 2 ? property[1].trim() : null;
+
+ // CSS property name
+ if (!styleProperties.contains(propertyName) &&
+ !svgStyleProperties.contains(propertyName)) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
+ element
+ );
+ }
+
+ // CSS property value
+ if (propertyValue != null && !stylePropertiesValues.contains(propertyValue)) {
+ // Not in list, now check the regex
+ if (!REGEX_VALID_CSS_VALUE.matcher(propertyValue).matches()) {
+ throw createSemanticException(
+ getInvalidAttributeValueMessage(elementName, attributeName, attributeValue),
+ element
+ );
+ }
+ }
+ }
+ }
+
+
+ }
+
+ public String getInvalidURIMessage(String uri){
+ return "invalid URI";
+ }
+
+ public String getInvalidElementMessage(String elementName){
+ return "invalid element '" + elementName + "'";
+ }
+
+ public String getInvalidAttributeMessage(String elementName, String attributeName){
+ return "invalid attribute '" + attributeName + "' for element '" + elementName + "'";
+ }
+
+ public String getInvalidAttributeValueMessage(String elementName, String attributeName, String value){
+ return "invalid value of attribute '" + attributeName + "' for element '" + elementName + "'";
+ }
+
+ public void escapeSeamTextToken(Token element) {
+ }
+
+ protected boolean validateURI(String uri) {
+
+ // Relative URI starts with a slash
+ if (uri.startsWith("/")) return true;
+
+ java.net.URI parsedURI;
+ try {
+ parsedURI = new java.net.URI(uri);
+ } catch (java.net.URISyntaxException ex) {
+ return false;
+ }
+
+ if (!uriSchemes.contains(parsedURI.getScheme())) {
+ return false;
+ }
+ return true;
+ }
+
+ public SemanticException createSemanticException(String message, Token element) {
+ return new SemanticException(
+ message,
+ element.getFilename(), element.getLine(), element.getColumn()
+ );
+ }
+
+ }
+
+
+ private final String SEAMTEXT_MONOSPACE = "|";
+
+ private final String SEAMTEXT_TWIDDLE = "~";
+
+ private final String SEAMTEXT_HASH = "#";
+
+ private final String SEAMTEXT_HAT = "^";
+
+ private final String SEAMTEXT_PLUS = "+";
+
+ private final String SEAMTEXT_STAR = "*";
+
+ private final String SEAMTEXT_UNDERSCORE = "_";
+
+ private final String SEAMTEXT_EQ = "=";
+
+ private final String SEAMTEXT_BACKTICK = "`";
+
+ private final String SEAMTEXT_PARAGRAPH = "\n\n";
+
+ private final String SEAM_DOUBLEQUOTE = "\"";
+
+ private final String SEAM_OPEN = "[";
+
+ private final String SEAM_CLOSE = "]";
+
+ private final String SEAM_GT = ">";
+
+
+ protected java.util.Set<String> seamTextSymbols = new java.util.HashSet(java.util.Arrays.asList(
+ SEAMTEXT_MONOSPACE, SEAMTEXT_TWIDDLE, SEAMTEXT_HASH, SEAMTEXT_HAT, SEAMTEXT_PLUS, SEAMTEXT_STAR,
+ SEAMTEXT_UNDERSCORE, SEAMTEXT_EQ, SEAMTEXT_BACKTICK, SEAMTEXT_PARAGRAPH, SEAM_DOUBLEQUOTE, SEAM_OPEN,
+ SEAM_CLOSE, SEAM_GT
+ ));
+
+ protected java.util.Set<String> htmlSeamTextElements = new java.util.HashSet(java.util.Arrays.asList(
+ "del", "sup", "pre","p", "q" ,"h1" ,"h2" ,"h3" ,"h4" ,"ul" ,"ol" ,"li" ,"i" ,"tt" ,"u" ,"a"));
+
+ private Sanitizer sanitizer = new DefaultSanitizer();
+
+ private java.util.Stack<Token> htmlElementStack = new java.util.Stack<Token>();
+
+ private StringBuilder mainBuilder = new StringBuilder();
+
+ private StringBuilder linkValueCollector = new StringBuilder();
+
+ private String linkHolder;
+
+ private StringBuilder builder = mainBuilder;
+
+
+ public void setSanitizer(Sanitizer sanitizer) {
+ this.sanitizer = sanitizer;
+ }
+
+ public String toString() {
+ return builder.toString();
+ }
+
+ private void beginCapture() {
+ builder = new StringBuilder();
+ }
+
+ private String endCapture() {
+ String result = builder.toString();
+ builder = mainBuilder;
+ return result;
+ }
+
+ private void append(String... strings) {
+ for (String string: strings) builder.append(string);
+ }
+
+
+ public boolean isLink(Token token) {
+ String name = token.getText().toLowerCase();
+ return "a".equals(name);
+ }
+
+ private String createSeamTextLink(String link, String value) {
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("[");
+
+ if (value != null) {
+ builder.append(value.trim());
+ }
+
+ builder.append("=>");
+ builder.append(link);
+ builder.append("]");
+
+ return builder.toString();
+
+ }
+
+ public boolean isHeader(Token token) {
+ String name = token.getText().toLowerCase();
+ return ("h1".equals(name) || "h2".equals(name) || "h3".equals(name) || "h4".equals(name));
+ }
+
+ public String createSeamTextHeader(Token token) throws SemanticException {
+
+ String name = token.getText();
+ StringBuilder seamHeader = new StringBuilder();
+
+ if("h1".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS);
+ } else if("h2".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ } else if("h3".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ } else if("h4".equals(name)) {
+ seamHeader.append("\n").append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS).append(SEAMTEXT_PLUS);
+ }
+
+ return seamHeader.toString();
+ }
+
+ public boolean isList(Token token){
+ String name = token.getText();
+ return ("ul".equals(name) || "ol".equals(name));
+ }
+
+ public boolean isListItem(Token token) {
+ String name = token.getText().toLowerCase();
+ return "li".equals(name);
+ }
+
+ public String createSeamTextList(Token token, java.util.Stack <Token> htmlElementStack) throws SemanticException {
+ String seamText = null;
+
+ Token parent = htmlElementStack.peek();
+ String parentName = parent.getText().toLowerCase();
+ if(parentName.equals("ul")) {
+ seamText = SEAMTEXT_HASH;
+ } else if (parentName.equals("ol")){
+ seamText = SEAMTEXT_EQ;
+ } else {
+ String message = "<li> must follow <ol> or <ul> not <" + parent.getText() + ">";
+ throw new SemanticException( message, parent.getFilename(), parent.getLine(), parent.getColumn());
+ }
+
+ return seamText != null ? seamText : "";
+ }
+
+ // validate lists and headers'
+ public void validateNestedMarkup(Token name, java.util.Stack <Token> htmlElementStack) throws SemanticException {
+ if(!htmlElementStack.isEmpty()) {
+ for(Token token : htmlElementStack) {
+
+ if(token.getText().equals("h1") || token.getText().equals("h2") || token.getText().equals("h3")
+ || token.getText().equals("h4") || token.getText().equals("ol") || token.getText().equals("ul")) {
+ String message = "<" + token.getText() + "> contains nested <" + name.getText() + "> token";
+ throw new SemanticException( message, name.getFilename(), name.getLine(), name.getColumn());
+ }
+ }
+ }
+
+ }
+
+ public void validateHeaderMarkup(Token token, java.util.Stack <Token> htmlElementStack) throws TokenStreamException, SemanticException{
+ int EOF = 1;
+ int ALPHANUMERICWORD = 4;
+ int i = 0;
+ int type;
+
+ boolean containText = false;
+
+ Token element = htmlElementStack.peek();
+ String header = element.getText();
+
+ if (header.equals("h1") || header.equals("h2") || header.equals("h3") || header.equals("h4")) {
+ do {
+ i++;
+ type = LT(i).getType();
+ if (type == ALPHANUMERICWORD) {
+ containText = true;
+ break;
+ }
+
+ } while ( type != EOF);
+
+ if (!containText) {
+ String message = "You must have some text following a heading";
+ throw new SemanticException( message, element.getFilename(), element.getLine(), element.getColumn());
+ }
+ }
+
+ }
+
+ public String createSimpleSeamText(Token token) throws SemanticException{
+
+ String name = token.getText().toLowerCase();
+ StringBuilder seamText = new StringBuilder();
+
+ if("tt".equals(name)) {
+ seamText.append(SEAMTEXT_MONOSPACE);
+ } else if("del".equals(name)) {
+ seamText.append(SEAMTEXT_TWIDDLE);
+ } else if("i".equals(name)) {
+ seamText.append(SEAMTEXT_STAR);
+ } else if("sup".equals(name)) {
+ seamText.append(SEAMTEXT_HAT);
+ } else if("u".equals(name)) {
+ seamText.append(SEAMTEXT_UNDERSCORE);
+ } else if("pre".equals(name)) {
+ seamText.append(SEAMTEXT_BACKTICK);
+ } else if("p".equals(name)) {
+ seamText.append(SEAMTEXT_PARAGRAPH);
+ } else if("q".equals(name)) {
+ seamText.append(SEAM_DOUBLEQUOTE);
+ } else if("blockquote".equals(name)) {
+ seamText.append(SEAM_DOUBLEQUOTE);
+ }
+
+ return seamText.toString();
+
+ }
+
+ public boolean isSeamTextElement(Token element){
+ String name = element.getText().toLowerCase();
+ return htmlSeamTextElements.contains(name);
+ }
+
+
+ public String escapeSeamText(Token token, java.util.Stack <Token> parentHtmlTokens) throws TokenStreamException {
+
+ StringBuilder result = new StringBuilder();
+ String tokenName = token.getText();
+
+ if(parentHtmlTokens != null && !parentHtmlTokens.isEmpty()){
+ Token parentToken = parentHtmlTokens.peek();
+ String parentTokenName = parentToken.getText().toLowerCase();
+
+ if ("tt".equals(parentTokenName) || "pre".equals(parentTokenName)) {
+
+ 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(seamTextSymbols.contains(tokenName)) {
+ result.append(tokenName);
+ }
+ }
+ }
+ result = result.length() != 0 ? result : result.append("\\").append(tokenName);
+ return result.toString();
+ }
+
+
+
+}
+
+
+startRule: (newline)* (text eof)?
+ ;
+
+text: ((seamCharacters|plain|html|htmlSpecialChars) (newline)*)+
+ ;
+
+word: an:ALPHANUMERICWORD { append( an.getText() ); } | uc:UNICODEWORD { append( uc.getText() ); }
+ ;
+
+htmlSpecialChars:
+ DOUBLEQUOTE { append("\""); }
+ | lt:ESCAPED_LT {append(escapeSeamText(lt, htmlElementStack));}
+ | gt:ESCAPED_GT {append(escapeSeamText(gt, htmlElementStack));}
+ | amp:ESCAPED_AMP {append(escapeSeamText(amp, htmlElementStack));}
+ | qout:ESCAPED_QOUT {append(escapeSeamText(qout, htmlElementStack));}
+
+ ;
+eof: EOF;
+
+punctuation: p:PUNCTUATION { append( p.getText() ); }
+ | sq:SINGLEQUOTE { append( sq.getText() ); }
+ | s:SLASH { append( s.getText() ); }
+ ;
+
+specialChars:
+ st:STAR {append( st.getText() ); }
+ | b:BAR { append( b.getText() ); }
+ | h:HAT { append( h.getText() ); }
+ | p:PLUS { append( p.getText() ); }
+ | eq:EQ { append( eq.getText() ); }
+ | hh:HASH { append( hh.getText() ); }
+ | e:ESCAPE { append( e.getText() ); }
+ | t:TWIDDLE { append( t.getText() ); }
+ | u:UNDERSCORE { append( u.getText() ); }
+ ;
+
+
+seamCharacters:
+ hat:HAT {append(escapeSeamText(hat, htmlElementStack));}
+ | hash:HASH {append(escapeSeamText(hash, htmlElementStack));}
+ | open:OPEN {append(escapeSeamText(open, htmlElementStack)) ;}
+ | close:CLOSE {append(escapeSeamText(close, htmlElementStack));}
+ | twiddle:TWIDDLE {append(escapeSeamText(twiddle, htmlElementStack));}
+ | bar:BAR {append(escapeSeamText(bar, htmlElementStack));}
+ | eq:EQ {append(escapeSeamText(eq, htmlElementStack));}
+ | plus:PLUS {append(escapeSeamText(plus, htmlElementStack));}
+ | backtick:BACKTICK {append(escapeSeamText(backtick, htmlElementStack));}
+ | st:STAR {append(escapeSeamText(st, htmlElementStack));}
+ | e:ESCAPE {append(escapeSeamText(e, htmlElementStack));}
+ | gt:GT {append(escapeSeamText(gt, htmlElementStack));}
+ ;
+
+space: s:SPACE {
+
+ if(!htmlElementStack.isEmpty()) {
+ String tokenName = htmlElementStack.peek().getText();
+ if(!("ul".equals(tokenName) || "ol".equals(tokenName))) {
+ append(s.getText());
+ }
+
+ } else {
+ append(s.getText());
+ }
+
+ }
+ ;
+
+newline: n:NEWLINE { append(n.getText());}
+
+
+ ;
+
+newlineOrEof: newline | EOF
+ ;
+
+html: openTag ( space | space attribute )* ( ( beforeBody body closeTagWithBody ) | closeTagWithNoBody)
+ ;
+
+plain: (word|punctuation|space)
+ ;
+
+body: (
+
+ {
+ Token token = htmlElementStack.peek();
+ boolean isLink = isLink(token);
+ linkValueCollector = new StringBuilder();
+ }
+ (
+
+ seamCharacters|
+
+
+ { if(isLink) {
+ beginCapture();
+ }
+
+ }
+ plain
+ {
+ if(isLink) {
+ String plain = endCapture();
+ linkValueCollector.append(plain);
+ }
+
+ }
+
+ |html
+ |htmlSpecialChars
+ {
+ if(isLink) {
+ String message = "unexpected token";
+ throw new SemanticException(message);
+ }
+ }
+ |newline: NEWLINE )*)
+ ;
+
+openTag:
+ LT name:ALPHANUMERICWORD
+ {
+
+
+ sanitizer.validateHtmlElement(name);
+
+ if (isSeamTextElement(name)) {
+ if (isList(name)) {
+ validateNestedMarkup(name, htmlElementStack);
+ } else if (isListItem(name)) {
+ append(createSeamTextList(name,htmlElementStack));
+ } else if (isHeader(name)) {
+ validateNestedMarkup(name, htmlElementStack);
+ append(createSeamTextHeader(name));
+ }
+
+ } else {
+ append("<");
+ append(name.getText());
+ }
+ htmlElementStack.push(name);
+
+ }
+ ;
+ exception
+ catch [RecognitionException ex] {
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+ }
+
+
+beforeBody: GT {
+ Token name = htmlElementStack.peek();
+ if(isSeamTextElement(name)){
+ append(createSimpleSeamText(name));
+ } else {
+ append(">");
+ }
+ }
+ ;
+ exception
+ catch [RecognitionException ex] {
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+ }
+
+closeTagWithBody:
+ LT SLASH name:ALPHANUMERICWORD GT
+ {
+ if(isSeamTextElement(name)){
+ if(isLink(name)){
+ append(createSeamTextLink(linkHolder,linkValueCollector.toString().trim()));
+ } else {
+ append(createSimpleSeamText(name));
+ }
+
+ if(isListItem(name) || isHeader(name)) {
+ append("\n");
+ validateHeaderMarkup(name,htmlElementStack);
+ }
+
+ } else {
+ append("</");
+ append(name.getText());
+ append(">");
+ }
+
+
+ htmlElementStack.pop();
+ }
+ ;
+
+closeTagWithNoBody:
+ SLASH GT
+ { append("/>");
+ htmlElementStack.pop();
+ }
+ ;
+
+attribute: att:ALPHANUMERICWORD (space)* EQ (space)*
+ DOUBLEQUOTE
+ {
+ Token token = htmlElementStack.peek();
+ sanitizer.validateHtmlAttribute(token, att);
+ boolean isSeamTextProcessed = isSeamTextElement(token);
+
+ if (!isSeamTextProcessed) {
+ append(att.getText());
+ append("=\"");
+ }
+ beginCapture();
+ }
+ attributeValue
+ {
+ String attValue = endCapture();
+ sanitizer.validateHtmlAttributeValue(token, att, attValue);
+
+ if (!isSeamTextProcessed) {
+ append(attValue);
+ } else if(isLink(token) && "href".equals(att.getText())) {
+
+ linkHolder = attValue;
+ }
+
+ }
+ DOUBLEQUOTE {
+ if(!isSeamTextProcessed) {
+ append("\"");
+ }
+ }
+ ;
+ exception
+ catch [RecognitionException ex] {
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+ }
+
+attributeValue: ( AMPERSAND { append("&"); } |
+ an:ALPHANUMERICWORD { append( an.getText() ); } |
+ p:PUNCTUATION { append( p.getText() ); } |
+ s:SLASH { append( s.getText() ); } |
+ space|specialChars )*
+ ;
+ exception
+ catch [RecognitionException ex] {
+ if (htmlElementStack.isEmpty()) throw ex;
+ Token tok = htmlElementStack.peek();
+ if (tok != null) {
+ throw new HtmlRecognitionException(tok, ex);
+ } else {
+ throw ex;
+ }
+ }
+
+class HtmlSeamTextLexer extends Lexer;
+
+options
+{
+ k=2;
+
+ // Allow any char but \uFFFF (16 bit -1)
+ charVocabulary='\u0000'..'\uFFFE';
+}
+
+
+// Unicode sets allowed:
+// '\u00a0'..'\u00ff' Latin 1 supplement (no control characters) http://www.unicode.org/charts/PDF/U0080.pdf
+// '\u0100'..'\u017f' Latin Extended A http://www.unicode.org/charts/PDF/U0100.pdf
+// '\u0180'..'\u024f' Latin Extended B http://www.unicode.org/charts/PDF/U0180.pdf
+// '\u0250'..'\ufaff' Various other languages, punctuation etc. (excluding "presentation forms")
+// '\uff00'..'\uffef' Halfwidth and Fullwidth forms (including CJK punctuation)
+
+ALPHANUMERICWORD
+ options {
+ paraphrase = "letters or digits";
+ }
+ : ('a'..'z'|'A'..'Z'|'0'..'9')+
+ ;
+
+UNICODEWORD
+ options {
+ paraphrase = "letters or digits";
+ }
+ : (
+ '\u00a0'..'\u00ff' |
+ '\u0100'..'\u017f' |
+ '\u0180'..'\u024f' |
+ '\u0250'..'\ufaff' |
+ '\uff00'..'\uffef'
+ )+
+ ;
+
+PUNCTUATION
+ options {
+ paraphrase = "a punctuation character";
+ }
+ : '-' | ';' | ':' | '(' | ')' | '{' | '}' | '?' | '!' | '@' | '%' | '.' | ',' | '$'
+ ;
+
+EQ
+ options {
+ paraphrase = "an equals '='";
+ }
+ : '='
+ ;
+
+PLUS
+ options {
+ paraphrase = "a plus '+'";
+ }
+ : '+'
+ ;
+
+UNDERSCORE
+ options {
+ paraphrase = "an underscore '_'";
+ }
+ : '_'
+ ;
+
+STAR
+ options {
+ paraphrase = "a star '*'";
+ }
+ : '*'
+ ;
+
+SLASH
+ options {
+ paraphrase = "a slash '/'";
+ }
+
+ : '/'
+ ;
+
+ESCAPE
+ options {
+ paraphrase = "the escaping blackslash '\'";
+ }
+ : '\\'
+ ;
+
+BAR
+ options {
+ paraphrase = "a bar or pipe '|'";
+ }
+ : '|'
+ ;
+
+BACKTICK
+ options {
+ paraphrase = "a backtick '`'";
+ }
+ : '`'
+ ;
+
+
+TWIDDLE
+ options {
+ paraphrase = "a tilde '~'";
+ }
+ : '~'
+ ;
+
+DOUBLEQUOTE
+ options {
+ paraphrase = "a doublequote \"";
+ }
+ : '"'
+ ;
+
+SINGLEQUOTE
+ options {
+ paraphrase = "a single quote '";
+ }
+ : '\''
+ ;
+
+OPEN
+ options {
+ paraphrase = "an opening square bracket '['";
+ }
+ : '['
+ ;
+
+CLOSE
+ options {
+ paraphrase = "a closing square bracket ']'";
+ }
+ : ']'
+ ;
+
+HASH
+ options {
+ paraphrase = "a hash '#'";
+ }
+ : '#'
+ ;
+
+HAT
+ options {
+ paraphrase = "a caret '^'";
+ }
+ : '^'
+ ;
+
+GT
+ options {
+ paraphrase = "a closing angle bracket '>'";
+ }
+ : '>'
+ ;
+
+LT
+ options {
+ paraphrase = "an opening angle bracket '<'";
+ }
+ : '<'
+ ;
+
+AMPERSAND
+ options {
+ paraphrase = "an ampersand '&'";
+ }
+ : '&'
+ ;
+
+SPACE
+ options {
+ paraphrase = "a space or tab";
+ }
+ : (' '|'\t')+
+ ;
+
+NEWLINE
+ options {
+ paraphrase = "a newline";
+ }
+ : "\r\n" | '\r' | '\n'
+ ;
+
+EOF
+ options {
+ paraphrase = "the end of the text";
+ }
+ : '\uFFFF'
+ ;
+
+ESCAPED_LT : "<"
+ ;
+
+ESCAPED_GT : ">"
+ ;
+
+ESCAPED_AMP : "&"
+ ;
+
+ESCAPED_QOUT : """
+ ;
+
+
+
+
+
+
+
+
+
16 years, 1 month