[richfaces-svn-commits] JBoss Rich Faces SVN: r18641 - in trunk/ui: core/api and 12 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sun Aug 15 15:29:48 EDT 2010


Author: nbelaevski
Date: 2010-08-15 15:29:47 -0400 (Sun, 15 Aug 2010)
New Revision: 18641

Added:
   trunk/ui/core/api/
   trunk/ui/core/api/pom.xml
   trunk/ui/core/api/src/
   trunk/ui/core/api/src/main/
   trunk/ui/core/api/src/main/java/
   trunk/ui/core/api/src/main/java/org/
   trunk/ui/core/api/src/main/java/org/richfaces/
   trunk/ui/core/api/src/main/java/org/richfaces/component/
   trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java
   trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/
   trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css
   trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
Removed:
   trunk/ui/core/ui/src/main/resources/META-INF/resources/richfaces.css
Modified:
   trunk/ui/core/pom.xml
   trunk/ui/core/ui/pom.xml
   trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
   trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
   trunk/ui/dist/richfaces-components-api/pom.xml
Log:
https://jira.jboss.org/browse/RF-7816

Added: trunk/ui/core/api/pom.xml
===================================================================
--- trunk/ui/core/api/pom.xml	                        (rev 0)
+++ trunk/ui/core/api/pom.xml	2010-08-15 19:29:47 UTC (rev 18641)
@@ -0,0 +1,45 @@
+<!--
+        JBoss, Home of Professional Open Source Copyright 2010, Red Hat, Inc.
+        and individual contributors by the @authors tag. See the copyright.txt
+        in the distribution for a full listing of individual contributors.
+        This is free software; you can redistribute it and/or modify it under
+        the terms of the GNU Lesser General Public License as published by the
+        Free Software Foundation; either version 2.1 of the License, or (at
+        your option) any later version. This software is distributed in the
+        hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+        the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+        PURPOSE. See the GNU Lesser General Public License for more details.
+        You should have received a copy of the GNU Lesser General Public
+        License along with this software; if not, write to the Free Software
+        Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+        USA, or see the FSF site: http://www.fsf.org.
+    -->
+
+<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>
+        <groupId>org.richfaces.ui</groupId>
+        <artifactId>richfaces-ui-parent</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.richfaces.ui.core</groupId>
+    <artifactId>richfaces-ui-core-api</artifactId>
+    <name>Richfaces UI Components: Core API</name>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <!-- runtime -->
+        <dependency>
+            <groupId>org.richfaces.core</groupId>
+            <artifactId>richfaces-core-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.richfaces.ui.common</groupId>
+            <artifactId>richfaces-ui-common-api</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

Added: trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java
===================================================================
--- trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java	                        (rev 0)
+++ trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java	2010-08-15 19:29:47 UTC (rev 18641)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+/**
+ * @author Nick Belaevski
+ * 
+ */
+public enum LogMode {
+
+    popup, inline, console
+    
+}

Modified: trunk/ui/core/pom.xml
===================================================================
--- trunk/ui/core/pom.xml	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/core/pom.xml	2010-08-15 19:29:47 UTC (rev 18641)
@@ -35,6 +35,7 @@
     <name>Richfaces UI Components: Core Aggregator</name>
 
     <modules>
+        <module>api</module>
         <module>ui</module>
     </modules>
 

Modified: trunk/ui/core/ui/pom.xml
===================================================================
--- trunk/ui/core/ui/pom.xml	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/core/ui/pom.xml	2010-08-15 19:29:47 UTC (rev 18641)
@@ -49,6 +49,10 @@
             <groupId>org.richfaces.ui.common</groupId>
             <artifactId>richfaces-ui-common-ui</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.richfaces.ui.core</groupId>
+            <artifactId>richfaces-ui-core-api</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java	2010-08-15 19:29:47 UTC (rev 18641)
@@ -38,8 +38,11 @@
  *
  */
 @ResourceDependencies(value = {
-        @ResourceDependency(name = "jquery.js") , @ResourceDependency(name = "richfaces.js") ,
-        @ResourceDependency(name = "richfaces-jsf-log.js"), @ResourceDependency(name = "richfaces.css")
+        @ResourceDependency(name = "jquery.js"), 
+        @ResourceDependency(name = "richfaces.js") ,
+        @ResourceDependency(name = "richfaces-base-component.js") ,
+        @ResourceDependency(library = "org.richfaces", name = "log.js"), 
+        @ResourceDependency(library = "org.richfaces", name = "log.css")
         })
 @JsfComponent(
         tag = @Tag(name = "log", type = TagType.Facelets),
@@ -59,6 +62,8 @@
 
     @Attribute(defaultValue = "")
     public abstract String getStyleClass();
+    
+    public abstract LogMode getMode();
 
 //  public abstract String getHotkey();
 //  public abstract void setHotkey(String newvalue);

Copied: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css (from rev 18609, trunk/ui/core/ui/src/main/resources/META-INF/resources/richfaces.css)
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css	                        (rev 0)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css	2010-08-15 19:29:47 UTC (rev 18641)
@@ -0,0 +1,10 @@
+.rich-log {
+	height: 300px;
+	overflow: auto;
+	width: 100%;
+}
+
+.rich-log-contents {
+	font-family: monospace;
+	font-size: 14px;
+}

Added: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js	                        (rev 0)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js	2010-08-15 19:29:47 UTC (rev 18641)
@@ -0,0 +1,265 @@
+(function(jquery, richfaces) {
+	var logLevels = ['debug', 'info', 'warn', 'error'];
+	var logLevelsPadded = {'debug': 'debug', 'info': 'info ', 'warn': 'warn ', 'error': 'error'};
+	var logLevelValues = {'debug': 1, 'info': 2, 'warn': 3, 'error': 4};
+	var logLevelColors = {'debug': 'darkblue', 'info': 'blue', 'warn': 'gold', 'error': 'red'};
+
+	var logClassMethods = {
+
+		__openPopup: function() {
+			if (!this.__popupWindow || this.__popupWindow.closed) {
+				this.__popupWindow = open("", "_richfaces_logWindow", "height=400, width=600, resizable = yes, status=no, " +
+				"scrollbars = yes, statusbar=no, toolbar=no, menubar=no, location=no");
+				
+				this.__popupWindow.document.write("<html><head></head><body><div id='richfaces.log'></div></body></html>");
+				this.__popupWindow.document.close();
+				this.__consoleElement = jquery("#richfaces\\.log", this.__popupWindow.document);
+				this.__initializeControls();
+			} else {
+				this.__popupWindow.focus();
+			}
+		},
+			
+		__hotkeyHandler: function(event) {
+			if (event.ctrlKey && event.shiftKey) {
+				if ((this.hotkey || 'l').toLowerCase() == String.fromCharCode(event.keyCode).toLowerCase()) {
+					this.__openPopup();
+				}
+			}
+		},
+			
+		__getTimeAsString: function() {
+			var date = new Date();
+
+			var timeString = this.__lzpad(date.getHours(), 2) + ':' + this.__lzpad(date.getMinutes(), 2) + ':' + 
+			this.__lzpad(date.getSeconds(), 2) + '.' + this.__lzpad(date.getMilliseconds(), 3);
+
+			return timeString;
+		},
+
+		__lzpad: function(s, length) {
+			s = s.toString();
+			var a = new Array();
+			for (var i = 0; i < length - s.length; i++) {
+				a.push('0');
+			}
+			a.push(s);
+			return a.join('');
+		},
+
+		__getMessagePrefix: function(level) {
+			return logLevelsPadded[level] + '[' + this.__getTimeAsString() + ']: ';
+		},
+
+		__setLevelFromSelect: function(event) {
+			this.setLevel(event.target.value);
+		},
+
+		__initializeControls : function() {
+			var console = this.__consoleElement;
+
+			var clearBtn = console.children("button.rich-log-element");
+			if (clearBtn.length == 0) {
+				clearBtn = jquery("<button type='button' class='rich-log-element'>Clear</button>").appendTo(console);
+			}
+
+			clearBtn.click(jquery.proxy(this.clear, this));
+
+			var levelSelect = console.children("select.rich-log-element");
+			if (levelSelect.length == 0) {
+				levelSelect = jquery("<select class='rich-log-element' name='richfaces.log' />").appendTo(console);
+			}
+
+			if (levelSelect.children().length == 0) {
+				for (var l = 0; l < logLevels.length; l++) {
+					jquery("<option value='" + logLevels[l]+ "'>" + logLevels[l] + "</option>").appendTo(levelSelect);
+				}
+			}
+
+			levelSelect.val(this.getLevel());
+			levelSelect.change(jquery.proxy(this.__setLevelFromSelect, this));
+
+			var consoleEntries = console.children(".rich-log-contents");
+			if (consoleEntries.length == 0) {
+				consoleEntries = jquery("<div class='rich-log-contents'></div>").appendTo(console);
+			}
+		},
+
+		__log: function(level, message) {
+			//TODO scroll to the added message
+			if (!this.__consoleElement) {
+				return;
+			}
+			
+			var console = this.__consoleElement;
+
+			if (logLevelValues[level] >= logLevelValues[this.getLevel()]) {
+				var newEntry = jquery(document.createElement("div")).appendTo(console.children(".rich-log-contents"));
+				jquery("<span style='color: " + logLevelColors[level] + "'></span>").appendTo(newEntry).text(this.__getMessagePrefix(level));
+
+				var entrySpan = jquery(document.createElement("span")).appendTo(newEntry);
+				if (typeof message != 'object' || !message.appendTo) {
+					entrySpan.text(message);
+				} else {
+					message.appendTo(entrySpan);
+				}
+			}
+		},
+
+		init: function(options) {
+			this.level = options.level;
+			this.hotkey = options.hotkey;
+			this.mode = options.mode;
+
+			if (this.mode == 'popup') {
+				this.__boundHotkeyHandler = jquery.proxy(this.__hotkeyHandler, this);
+				jquery(document).bind('keydown', this.__boundHotkeyHandler);
+			} else {
+				this.__consoleElement = jquery("#richfaces\\.log");
+				this.__initializeControls();
+			}
+		},
+
+		destroy: function() {
+			//TODO test this method
+			if (this.__popupWindow) {
+				this.__popupWindow.close();
+			}
+			this.__popupWindow = null;
+			
+			jquery(document).unbind('keydown', this.__boundHotkeyHandler);
+			this.__boundHotkeyHandler = null;
+
+			this.__consoleElement = null;
+			this.$super.destroy.call(this);
+		},
+
+		setLevel: function(level) {
+			this.level = level;
+			this.clear();
+		},
+
+		getLevel: function() {
+			return this.level || 'info';
+		},
+
+		clear: function() {
+			this.__consoleElement.children(".rich-log-contents").children().remove();
+		}
+	};
+
+	for (var i = 0; i < logLevels.length; i++) {
+		logClassMethods[logLevels[i]] = (function() {
+			var level = logLevels[i];
+			return function(message) {
+				this.__log(level, message);
+			}
+		}());
+	}
+	
+	richfaces.HtmlLog = richfaces.BaseComponent.extendClass(logClassMethods);
+}(jQuery, RichFaces));
+
+if (typeof jsf != 'undefined') {
+	(function(jQuery, richfaces, jsf) {
+
+		//JSF log adapter
+		var identifyElement = function(elt) {
+			var identifier = '<' + elt.tagName.toLowerCase();
+			var e = jQuery(elt);
+			if (e.attr('id')) {
+				identifier += (' id=' + e.attr('id'));
+			}
+			if (e.attr('class')) {
+				identifier += (' class=' + e.attr('class'));
+			}
+
+			identifier += ' ...>';
+
+			return identifier;
+		}
+
+		var formatPartialResponseElement = function(logElement, responseElement) {
+			var change = jQuery(responseElement);
+
+			logElement.append("Element <b>" + responseElement.nodeName + "</b>");
+			if (change.attr("id")) {
+				logElement.append(document.createTextNode(" for id=" + change.attr("id")));
+			}
+
+			jQuery(document.createElement("br")).appendTo(logElement);
+			jQuery("<span style='color:dimgray'></span>").appendTo(logElement).text(change.toXML());
+			jQuery(document.createElement("br")).appendTo(logElement);
+		}
+
+		var formatPartialResponse = function(partialResponse) {
+			var logElement = jQuery(document.createElement("span"));
+
+			partialResponse.children().each(function() {
+				var responseElement = jQuery(this);
+				if (responseElement.is('changes')) {
+					logElement.append("Listing content of response <b>changes</b> element:<br />");
+					responseElement.children().each(function() {
+						formatPartialResponseElement(logElement, this);
+					});
+				} else {
+					formatPartialResponseElement(logElement, this);
+				}
+			});
+
+			return logElement;
+		}
+
+		var jsfAjaxLogAdapter = function(data) {
+			try {
+				var log = richfaces.log;
+
+				var source = data.source;
+				var type = data.type;
+
+				var responseCode = data.responseCode;
+				var responseXML = data.responseXML;
+				var responseText = data.responseText;
+
+				if (type != 'error') {
+					log.info("Received '" + type + "' event from " + identifyElement(source));
+
+					if (type == 'beforedomupdate') {
+						var partialResponse;
+
+						if (responseXML) {
+							partialResponse = jQuery(responseXML).children("partial-response");
+						}
+
+						var responseTextEntry = jQuery("<span>Server returned responseText: </span><span style='color:dimgray'></span>").eq(1).text(responseText).end();
+
+						if (partialResponse && partialResponse.length) {
+							log.debug(responseTextEntry);
+							log.info(formatPartialResponse(partialResponse));
+						} else {
+							log.info(responseTextEntry);
+						}
+					}
+				} else {
+					var status = data.status;
+					log.error("Received '" + type + '@' + status + "' event from " + identifyElement(source));
+					log.error("[" + data.responseCode + "] " + data.errorName + ": " + data.errorMessage);
+				}
+			} catch (e) {
+				//ignore logging errors
+			}
+		};
+
+		var eventsListener = richfaces.createJSFEventsAdapter({
+			begin: jsfAjaxLogAdapter,
+			beforedomupdate: jsfAjaxLogAdapter,
+			success: jsfAjaxLogAdapter,
+			complete: jsfAjaxLogAdapter,
+			error: jsfAjaxLogAdapter
+		});
+
+		jsf.ajax.addOnEvent(eventsListener);
+		jsf.ajax.addOnError(eventsListener);
+		//
+	}(jQuery, RichFaces, jsf));
+};
\ No newline at end of file

Deleted: trunk/ui/core/ui/src/main/resources/META-INF/resources/richfaces.css
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/richfaces.css	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/richfaces.css	2010-08-15 19:29:47 UTC (rev 18641)
@@ -1,10 +0,0 @@
-.rich-log {
-	height: 300px;
-	overflow: auto;
-	width: 100%;
-}
-
-.rich-log-contents {
-	font-family: Consolas, Courier New, Courier;
-	font-size: 14px;
-}

Modified: trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml	2010-08-15 19:29:47 UTC (rev 18641)
@@ -12,25 +12,14 @@
 	</cc:interface>
 
 	<cc:implementation>
-		<!--
-			f:clientid var="clientId"/ > <cdk:choose> <cdk:when
-			test="#{component.isPopup()}"> <script id="#{clientId}"
-			type="text/javascript"> LOG.registerPopup(
-			'#{component.attributes["hotkey"]}',
-			'#{component.attributes["name"]}', #{component.attributes["width"]},
-			#{component.attributes["height"]},
-			LOG.#{component.attributes["level"]}); </script> </cdk:when>
-			<cdk:otherwise> <div id="richfaces.log"
-			style='width:#{component.attributes["width"]};height:#{component.attributes["height"]};overflow:auto;#{component.attributes["style"]}'
-			cdk:passThroughWithExclusions="value name id style">
-			<button>Clear</button><br /> <script type="text/javascript">
-			LOG.LEVEL = LOG.#{component.attributes["level"]}; </script> </div>
-			</cdk:otherwise> </cdk:choose
-		-->
 		<div id="richfaces.log" class="rich-log #{component.attributes['styleClass']}">
 			<script type="text/javascript">
-				RichFaces.log.setLevel("#{component.attributes['level']}");
-		</script>
+				RichFaces.log = new RichFaces.HtmlLog({
+                    level: "#{component.attributes['level']}",
+                    hotkey: "#{component.attributes['hotkey']}",
+                    mode: "#{component.attributes['mode']}"
+                });
+		    </script>
 		</div>
 	</cc:implementation>
 </cdk:root>

Modified: trunk/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- trunk/ui/dist/richfaces-components-api/pom.xml	2010-08-15 19:28:03 UTC (rev 18640)
+++ trunk/ui/dist/richfaces-components-api/pom.xml	2010-08-15 19:29:47 UTC (rev 18641)
@@ -45,6 +45,10 @@
             <artifactId>richfaces-ui-common-api</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.richfaces.ui.core</groupId>
+            <artifactId>richfaces-ui-core-api</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.richfaces.ui.iteration</groupId>
             <artifactId>richfaces-ui-iteration-api</artifactId>
         </dependency>
@@ -144,7 +148,7 @@
                                 <configuration>
                                     <classifier>sources</classifier>
 
-                                    <includeGroupIds>org.richfaces.ui.common, org.richfaces.ui.iteration, org.richfaces.ui.output</includeGroupIds>
+                                    <includeGroupIds>org.richfaces.ui.common, org.richfaces.ui.core, org.richfaces.ui.iteration, org.richfaces.ui.output</includeGroupIds>
                                     <useSubDirectoryPerArtifact>true</useSubDirectoryPerArtifact>
                                     <excludeTransitive>true</excludeTransitive>
                                 </configuration>



More information about the richfaces-svn-commits mailing list