myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r432577 - in /myfaces/tobago/trunk/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/
Date Fri, 18 Aug 2006 13:29:41 GMT
Author: weber
Date: Fri Aug 18 06:29:41 2006
New Revision: 432577

URL: http://svn.apache.org/viewvc?rev=432577&view=rev
Log:
better client-side js-logging panel

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java?rev=432577&r1=432576&r2=432577&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
(original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PageRenderer.java
Fri Aug 18 06:29:41 2006
@@ -48,6 +48,7 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.faces.context.ExternalContext;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.StringWriter;
@@ -83,6 +84,18 @@
   private static final String FRAMESET =
       "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\""
           + " \"http://www.w3.org/TR/html4/frameset.dtd\">";
+    private static final String CLIENT_DEBUG_SEVERITY = "clientDebugSeverity";
+
+
+    public void decode(FacesContext facesContext, UIComponent component) {
+        super.decode(facesContext, component);
+        String name = component.getClientId(facesContext) + SUBCOMPONENT_SEP + "clientSeverity";
+        ExternalContext externalContext = facesContext.getExternalContext();
+        String severity = (String) externalContext.getRequestParameterMap().get(name);
+        if (severity != null) {
+          externalContext.getRequestMap().put(CLIENT_DEBUG_SEVERITY, severity);
+        }
+    }
 
 // ----------------------------------------------------------------- interfaces
 
@@ -214,11 +227,24 @@
     scriptFiles.remove("script/tobago.js");
     scriptFiles.remove("script/theme-config.js");
 
+    int clientLogSeverity = 2;
     boolean hideClientLogging = true;
     final boolean debugMode =
         ClientProperties.getInstance(facesContext.getViewRoot()).isDebugMode();
 //        true; hideClientLogging = false;
     if (debugMode) {
+      String severity = (String) facesContext.getExternalContext().getRequestMap().get(CLIENT_DEBUG_SEVERITY);
+      LOG.info("get " + CLIENT_DEBUG_SEVERITY + " = " + severity);
+      if (severity != null) {
+        try {
+            int index = severity.indexOf(';');
+            if (index == -1) {
+              index = severity.length();
+            }
+            clientLogSeverity = Integer.parseInt(severity.substring(0, index));
+        } catch (NumberFormatException e) {/* ignore; use default*/ }
+        hideClientLogging = !severity.contains("show");
+      }
       scriptFiles.add("script/effects.js");
       scriptFiles.add("script/dragdrop.js");
       scriptFiles.add("script/logging.js");
@@ -306,6 +332,15 @@
         clientId + SUBCOMPONENT_SEP + "form-action");
     writer.writeAttribute("value", defaultActionId, null);
     writer.endElement("input");
+
+    if (debugMode) {
+      writer.startElement("input");
+      writer.writeAttribute("value", clientLogSeverity, null);
+      writer.writeAttribute("id", clientId + SUBCOMPONENT_SEP + "clientSeverity", null);
+      writer.writeAttribute("name", clientId + SUBCOMPONENT_SEP + "clientSeverity", null);
+      writer.writeAttribute("type", "hidden", null);
+      writer.endElement("input");
+    }
 
 // TODO: this is needed for the "BACK-BUTTON-PROBLEM"
 // but may no longer needed

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js?rev=432577&r1=432576&r2=432577&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js
(original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/logging.js
Fri Aug 18 06:29:41 2006
@@ -20,10 +20,12 @@
   IdBase: "TbgLog",
   messages: new Array(),
   appenders: new Array(),
+  SEVERITY_ID_POSTFIX: "clientSeverity",
   DEBUG: 1,
   INFO:  2,
   WARN:  3,
   ERROR: 4,
+  NONE: 100,
 
   show: function() {
     for (var i = 0 ; i < this.appenders.length; i++) {
@@ -108,11 +110,11 @@
        } else {
          LOG.debug("AjaxComponentId = " + name + " Unknown object");
        }
-    }  
+    }
   }
 });
 
-LOG.bindOnWindow();
+//LOG.bindOnWindow();
 
 
 LOG.LogArea = Class.create();
@@ -154,24 +156,53 @@
     tmpElement.innerHTML = "LoggingArea";
     this.dragHandleTop.appendChild(tmpElement);
 
-    this.clearButton = document.createElement("BUTTON");
-    this.clearButton.style.marginLeft = "20px";
-    this.clearButton.style.height = "20px";
-    this.clearButton.innerHTML = "Clear";
+    this.severitySelector = document.createElement("SELECT");
+    var option = document.createElement("OPTION");
+    option.value = LOG.DEBUG;
+    option.innerHTML = "Debug";
+    this.severitySelector.appendChild(option);
+    option = document.createElement("OPTION");
+    option.value = LOG.INFO;
+    option.innerHTML = "Info";
+    this.severitySelector.appendChild(option);
+    option = document.createElement("OPTION");
+    option.value = LOG.WARN;
+    option.innerHTML = "Warn";
+    this.severitySelector.appendChild(option);
+    option = document.createElement("OPTION");
+    option.value = LOG.ERROR;
+    option.innerHTML = "Error";
+    this.severitySelector.appendChild(option);
+    option = document.createElement("OPTION");
+    option.value = LOG.NONE;
+    option.innerHTML = "None";
+    this.severitySelector.appendChild(option);
+    var sev = Tobago.element(Tobago.page.id + Tobago.SUB_COMPONENT_SEP + LOG.SEVERITY_ID_POSTFIX);
+    if (sev) {
+      this.severitySelector.value = sev.value;
+    } else {
+      this.severitySelector.value = LOG.INFO;
+    }
+    this.severitySelector.style.position = "absolute";
+    this.severitySelector.style.right = "66px";
+    this.dragHandleTop.appendChild(this.severitySelector);
+
+    this.clearButton = this.createButtonElement();
+    this.clearButton.style.right = "44px";
+    this.clearButton.innerHTML = "C";
+    this.clearButton.title = "Clear log area";
     this.dragHandleTop.appendChild(this.clearButton);
 
-    this.oldButton = document.createElement("BUTTON");
-    this.oldButton.style.marginLeft = "20px";
-    this.oldButton.style.height = "20px";
-//    this.hideButton.style.float = "right";
-    this.oldButton.innerHTML = "Get old";
+    this.oldButton = this.createButtonElement();
+    this.oldButton.style.right = "22px";
+    this.oldButton.innerHTML = "O";
+    this.oldButton.title = "Get all Messages";
     this.dragHandleTop.appendChild(this.oldButton);
 
-    this.hideButton = document.createElement("BUTTON");
-    this.hideButton.style.marginLeft = "20px";
-    this.hideButton.style.height = "20px";
-//    this.hideButton.style.float = "right";
-    this.hideButton.innerHTML = "Hide";
+    this.hideButton = this.createButtonElement();
+    this.hideButton.style.right = "0px";
+    this.hideButton.innerHTML = "X";
+    this.hideButton.title = "Hide log area";
     this.dragHandleTop.appendChild(this.hideButton);
 
     this.dragHandleLeft = document.createElement("DIV");
@@ -225,6 +256,7 @@
 
     this.eventMouseDown = this.initDrag.bindAsEventListener(this);
 
+    this.eventChangeSeverity = this.changeSeverity.bindAsEventListener(this);
     this.eventClear     = this.clearList.bindAsEventListener(this);
     this.eventOld      = this.getOld.bindAsEventListener(this);
     this.eventHide      = this.hide.bindAsEventListener(this);
@@ -236,6 +268,9 @@
     Event.observe(this.dragHandleBottom, "mousedown", this.eventMouseDown);
     Event.observe(this.dragHandleLeft, "mousedown", this.eventMouseDown);
 
+    Event.observe(this.severitySelector, "change", this.eventChangeSeverity);
+    Event.observe(this.severitySelector, "click", this.eventStopEvent);
+    Event.observe(this.severitySelector, "mousedown", this.eventStopEvent);
     Event.observe(this.clearButton, "click", this.eventClear);
     Event.observe(this.clearButton, "mousedown", this.eventStopEvent);
     Event.observe(this.oldButton, "click", this.eventOld);
@@ -249,7 +284,10 @@
     this.body.tbgLogArea = this;
 
     if (this.options.hide) {
-      this.element.style.display = 'none';
+//      this.element.style.display = 'none';
+      this.hide();
+    } else {
+      this.setupHidden();  
     }
     this.body.appendChild(this.element);
     LOG.addAppender(this);
@@ -257,10 +295,14 @@
 
   show: function() {
     this.element.style.display = '';
+    this.hide = "show";
+    this.setupHidden();
   },
 
   hide: function() {
     this.element.style.display = 'none';
+    this.hide = "hide";
+    this.setupHidden();
   },
 
   setUpLogDiv: function(element, top, right, width, height, border, background) {
@@ -281,6 +323,29 @@
     if (cursor != null) element.style.cursor = cursor;
   },
 
+  createButtonElement: function() {
+    var button = document.createElement("BUTTON");
+    button.style.width = "20px";
+    button.style.height = "20px";
+    button.style.position = "absolute";
+    button.style.top = "0px";
+    button.style.paddingLeft = "0px";
+    button.style.paddingRight = "0px";
+    return button;
+  },
+
+  changeSeverity: function() {
+    this.setupHidden();
+  },
+
+  setupHidden: function() {
+    var hidden = Tobago.element(Tobago.page.id + Tobago.SUB_COMPONENT_SEP + "clientSeverity");
+    if (hidden) {
+      hidden.value = this.severitySelector.value + ";" + this.hide;
+    }
+  },
+
+
   clearList: function() {
     this.logList.innerHTML = "";
   },
@@ -320,7 +385,13 @@
   },
 
   logFor: function(severity) {
-    return (severity >= this.options.severity);
+    //this.append(severity + ":::" + typeof severity);
+    if (this.severitySelector.value) {
+    //    this.append("::::::" + this.severitySelector.value + "--" + typeof this.severitySelector.value
+    //                + "--" + typeof (this.severitySelector.value - 0));
+        return (severity >= (this.severitySelector.value - 0));
+    }
+    return (severity >= (this.options.severity -0));
   }
 });
 



Mime
View raw message