Author: julien(a)jboss.com
Date: 2008-07-07 18:56:19 -0400 (Mon, 07 Jul 2008)
New Revision: 11337
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/AgentContext.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/MetaWidget.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/DestroyObjectAction.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/RefreshAction.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/utils/Level.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css
Log:
improve logging it was starting to become a mess to follow
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/AgentContext.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/AgentContext.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/AgentContext.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -53,6 +53,9 @@
request.setAction(action);
//
+ log.info("About to perform action " + action);
+
+ //
agent.getProxy().process(request, new AsyncCallback()
{
public void onFailure(Throwable throwable)
@@ -74,12 +77,12 @@
//
if (stale != null)
{
- log.info("Going to refresh object " + staleObject);
+ log.debug("Going to refresh object " + staleObject);
stale.refresh(true);
}
else
{
- log.info("No stale object for " + staleObject);
+ log.debug("No stale object for " + staleObject);
}
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/PresentationClientAgent.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -28,6 +28,12 @@
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
@@ -128,44 +134,129 @@
proxy.ping(callback);
}
- private static class SimpleAppender extends FlowPanel implements Appender
+ private static class SimpleAppender extends VerticalPanel implements Appender,
ChangeListener, ClickListener
{
// width:auto; height:100px; overflow:hidden;
/** . */
- private Element container;
+ private static final Level[] levels = {Level.ERROR, Level.INFO, Level.DEBUG,
Level.TRACE};
+ /** . */
+ private FlowPanel content;
+
+ /** . */
+ private HorizontalPanel controls;
+
+ /** . */
+ private ListBox levelBox;
+
+ /** . */
+ private Button clearButton;
+
+ /** . */
+ private Element topContainer;
+
+ /** . */
+ private Element childrenContainer;
+
+ /** . */
private DateTimeFormat format;
+ /** . */
+ private Level currentLevel = Level.INFO;
+
private SimpleAppender()
{
- container = getElement();
+ controls = new HorizontalPanel();
+ clearButton = new Button("Clear");
+ levelBox = new ListBox();
+ content = new FlowPanel();
+ topContainer = content.getElement();
+ childrenContainer = DOM.createDiv();
format = DateTimeFormat.getFormat("HH:mm:ss:SSSS");
//
+ for (int i = 0;i < levels.length;i++)
+ {
+ levelBox.addItem(levels[i].getName());
+ }
+ levelBox.addChangeListener(this);
+ levelBox.setSelectedIndex(1); // INFO
+
+ //
+ clearButton.addClickListener(this);
+
+ //
+ controls.add(levelBox);
+ controls.add(clearButton);
+
+ //
+ DOM.appendChild(topContainer, childrenContainer);
+
+ //
+ add(controls);
+ add(content);
+
+ //
// DOM.setStyleAttribute(container, "width", "auto");
- DOM.setStyleAttribute(container, "height", "128px");
- DOM.setStyleAttribute(container, "overflow", "scroll");
+ DOM.setStyleAttribute(topContainer, "height", "128px");
+ DOM.setStyleAttribute(topContainer, "overflow", "scroll");
//
setStylePrimaryName("log");
}
+ public void onChange(Widget widget)
+ {
+ if (widget == levelBox)
+ {
+ currentLevel = levels[levelBox.getSelectedIndex()];
+ }
+ }
+
+ public void onClick(Widget widget)
+ {
+ if (widget == clearButton)
+ {
+ clear();
+ }
+ }
+
public void append(Level level, Date time, String category, String msg)
{
- Element div = DOM.createDiv();
+ if (currentLevel.implies(level))
+ {
+ Element div = DOM.createDiv();
- //
- DOM.setInnerHTML(div, level + " " + format.format(time) + "
" + category + " " + msg);
+ //
+ DOM.setInnerHTML(div, level + " " + format.format(time) + "
" + category + " " + msg);
- //
- DOM.appendChild(container, div);
+ //
+ DOM.appendChild(childrenContainer, div);
+ DOM.setElementProperty(div, "className", "log-" +
currentLevel.getName());
- // Autoscroll to bottom
- String height = DOM.getElementProperty(container, "scrollHeight");
- DOM.setElementProperty(container, "scrollTop", height);
+ //
+ autoscroll();
+ }
}
+
+ public void clear()
+ {
+ DOM.removeChild(topContainer, childrenContainer);
+ childrenContainer = DOM.createDiv();
+ DOM.appendChild(topContainer, childrenContainer);
+ autoscroll();
+ }
+
+ /**
+ * Autoscroll to bottom
+ */
+ private void autoscroll()
+ {
+ String height = DOM.getElementProperty(topContainer, "scrollHeight");
+ DOM.setElementProperty(topContainer, "scrollTop", height);
+ }
+
}
-
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxObject.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -114,13 +114,13 @@
//
if (stale || force)
{
- context.log.info("Starting refresh of object " + id);
+ context.log.debug("Starting refresh of object " + id);
//
doRefresh(force);
//
- context.log.info("Finished refresh of object " + id);
+ context.log.debug("Finished refresh of object " + id);
//
stale = false;
@@ -129,7 +129,7 @@
public final void refresh(boolean force)
{
- context.log.info("Requesting for" + (force ? " forced " :
" ") + "refresh of object " + id);
+ context.log.debug("Requesting for" + (force ? " forced " :
" ") + "refresh of object " + id);
//
refreshRecursive(force);
@@ -245,7 +245,7 @@
ModelUpdate update = updates[i];
//
- log.trace("Executing model update " + update);
+ log.debug("Executing model update " + update);
//
if (update instanceof AddObject)
@@ -324,7 +324,7 @@
parent.removeChild(child);
//
- log.info("Child " + removeChild.getChildId() + " removed
from parent " + removeChild.getParentId());
+ log.debug("Child " + removeChild.getChildId() + " removed
from parent " + removeChild.getParentId());
}
else if (update instanceof RemoveObject)
{
@@ -346,7 +346,7 @@
object.destroyWidget();
//
- log.info("Destroyed object " + removeObject.getObjectId());
+ log.debug("Destroyed object " + removeObject.getObjectId());
}
}
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/MetaWidget.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/MetaWidget.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/MetaWidget.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -87,7 +87,7 @@
{
public void run()
{
- log.info("Creating popup widget");
+ log.trace("Creating popup widget");
VerticalPanel popup = new VerticalPanel();
@@ -114,16 +114,16 @@
}
};
timer.schedule(4000);
- log.info("Scheduling");
+ log.trace("Scheduling");
}
else
{
- log.info("Will not schedule because it is already
scheduled");
+ log.trace("Will not schedule because it is already
scheduled");
}
}
else
{
- log.info("Will not schedule because the from element is
descendant");
+ log.trace("Will not schedule because the from element is
descendant");
}
break;
case Event.ONMOUSEOUT:
@@ -132,17 +132,17 @@
{
if (timer != null)
{
- log.info("Unscheduling");
+ log.trace("Unscheduling");
timer.cancel();
- log.info("Timer cancelled");
+ log.trace("Timer cancelled");
if (popup != null)
{
remove(popup);
- log.info("Removed popup");
+ log.trace("Removed popup");
}
timer = null;
popup = null;
- log.info("Unscheduled");
+ log.trace("Unscheduled");
}
}
break;
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/DestroyObjectAction.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/DestroyObjectAction.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/DestroyObjectAction.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -50,4 +50,9 @@
{
this.objectId = objectId;
}
+
+ public String toString()
+ {
+ return "DestroyObjectAction[objectId=" + objectId + "]";
+ }
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/RefreshAction.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/RefreshAction.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/RefreshAction.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -28,4 +28,8 @@
*/
public class RefreshAction extends AjaxAction
{
+ public String toString()
+ {
+ return "RefreshAction[]";
+ }
}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/utils/Level.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/utils/Level.java 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/utils/Level.java 2008-07-07
22:56:19 UTC (rev 11337)
@@ -30,29 +30,44 @@
{
/** . */
- public static final Level TRACE = new Level("TRACE");
+ public static final Level TRACE = new Level(3, "TRACE");
/** . */
- public static final Level DEBUG = new Level("DEBUG");
+ public static final Level DEBUG = new Level(2, "DEBUG");
/** . */
- public static final Level INFO = new Level("INFO");
+ public static final Level INFO = new Level(1, "INFO");
/** . */
- public static final Level ERROR = new Level("ERROR");
+ public static final Level ERROR = new Level(0, "ERROR");
/** . */
+ private final int index;
+
+ /** . */
private final String name;
/** . */
private final String toString;
- private Level(String name)
+ private Level(int index, String name)
{
+ this.index = index;
this.name = name;
this.toString = "[" + name + "]";
}
+ public boolean implies(Level other)
+ {
+ if (other == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ return index >= other.index;
+ }
+
public String getName()
{
return name;
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css 2008-07-07
22:14:53 UTC (rev 11336)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/public/style.css 2008-07-07
22:56:19 UTC (rev 11337)
@@ -5,6 +5,22 @@
font-weight:bold;
}
+.log-ERROR {
+ color:red;
+}
+
+.log-INFO {
+ color:black;
+}
+
+.log-DEBUG {
+ color:gray;
+}
+
+.log-TRACE {
+ color:lightgray;
+}
+
.pf-Pane {
border: 1px solid black;
padding: 1px;
@@ -35,4 +51,4 @@
.pf-Pane {
border: 1px solid black;
padding: 1px;
-}
\ No newline at end of file
+}