[rhmessaging-commits] rhmessaging commits: r3112 - in mgmt/trunk: cumin/python/cumin and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Feb 10 07:29:37 EST 2009


Author: justi9
Date: 2009-02-10 07:29:37 -0500 (Tue, 10 Feb 2009)
New Revision: 3112

Modified:
   mgmt/trunk/basil/python/basil/model.py
   mgmt/trunk/basil/python/basil/page.py
   mgmt/trunk/basil/python/basil/page.strings
   mgmt/trunk/basil/python/basil/widgets.py
   mgmt/trunk/basil/python/basil/widgets.strings
   mgmt/trunk/cumin/python/cumin/charts.py
Log:
Add timestamps, refine styles

Modified: mgmt/trunk/basil/python/basil/model.py
===================================================================
--- mgmt/trunk/basil/python/basil/model.py	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/basil/python/basil/model.py	2009-02-10 12:29:37 UTC (rev 3112)
@@ -53,6 +53,9 @@
             self.model.lock.release()
 
     def newClass(self, kind, classKey):
+        if kind == 2:
+            return # XXX for now, drop events
+
         self.model.lock.acquire()
 
         try:

Modified: mgmt/trunk/basil/python/basil/page.py
===================================================================
--- mgmt/trunk/basil/python/basil/page.py	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/basil/python/basil/page.py	2009-02-10 12:29:37 UTC (rev 3112)
@@ -28,7 +28,7 @@
         objects = ObjectBrowser(app, "objects")
         self.tabs.add_tab(objects)
 
-class ObjectBrowser(Widget):
+class ObjectBrowser(PanningColumnSet):
     def __init__(self, app, name):
         super(ObjectBrowser, self).__init__(app, name)
 
@@ -86,11 +86,14 @@
         self.add_column(col)
 
     def do_get_items(self, session):
-        package = self.pkgid.get(session)
+        id = self.pkgid.get(session)
 
-        if package:
-            classes = self.app.model.classes_by_package[package].values()
-            return sorted(classes)
+        if id:
+            try:
+                classes = self.app.model.classes_by_package[id].values()
+                return sorted(classes)
+            except KeyError:
+                pass
 
     def render_title(self, session):
         return "Classes"
@@ -151,6 +154,34 @@
         self.stats = ObjectStatistics(app, "stats", self.objid)
         self.add_child(self.stats)
 
+    def render_name(self, session):
+        id = self.objid.get(session)
+
+        try:
+            return self.app.model.objects_by_id[id].getIndex()
+        except KeyError:
+            pass
+
+    def render_timestamp(self, session, index):
+        id = self.objid.get(session)
+
+        try:
+            utime = self.app.model.objects_by_id[id].getTimestamps()[index]
+            if utime != 0:
+                utime = utime / float(1000000000)
+                return datetime.fromtimestamp(utime)
+        except KeyError:
+            pass
+
+    def render_create_time(self, session):
+        return self.render_timestamp(session, 0)
+
+    def render_update_time(self, session):
+        return self.render_timestamp(session, 1)
+
+    def render_delete_time(self, session):
+        return self.render_timestamp(session, 2)
+
 class BaseObjectProperties(PropertySet):
     def __init__(self, app, name, objid):
         super(BaseObjectProperties, self).__init__(app, name)
@@ -178,5 +209,12 @@
         return object.getProperties()
 
 class ObjectStatistics(BaseObjectProperties):
+    def do_get_items(self, session):
+        id = self.objid.get(session)
+        stats = self.app.model.stats_by_id.get(id)
+
+        if stats:
+            return self.get_properties(stats[-1])
+
     def get_properties(self, object):
         return object.getStatistics()

Modified: mgmt/trunk/basil/python/basil/page.strings
===================================================================
--- mgmt/trunk/basil/python/basil/page.strings	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/basil/python/basil/page.strings	2009-02-10 12:29:37 UTC (rev 3112)
@@ -1,4 +1,14 @@
 [BasilPage.css]
+body {
+  font-size: 0.9em;
+  font-family: "DejaVu LGC Sans", "Bitstream Vera Sans", "Lucida Grande",
+               "Trebuchet MS", verdana, helvetica, arial, sans-serif;
+}
+
+h3 {
+  font-size: 0.9em;
+}
+
 a {
   text-decoration: none;
   color: blue;
@@ -22,34 +32,20 @@
   </body>
 </html>
 
-[ObjectBrowser.css]
-table.ObjectBrowser tr td {
-  vertical-align: top;
-}
-
-table.ObjectBrowser tr td.view {
-  width: 50%;
-}
-
-[ObjectBrowser.html]
-<table class="ObjectBrowser">
-  <tr>
-    <td>{packages}</td>
-    <td>{classes}</td>
-    <td>{objects}</td>
-    <td class="view">{view}</td>
-  </tr>
-</table>
-
 [ObjectView.html]
-{prev_link} {next_link}
-
 <h2>{name}</h2>
 
-<h3>Agent</h3>
+<table class="PropertySet">
+  <thead>
+    <tr><th><a>Name</a></th><th><a>Value</a></th></tr>
+  </thead>
+  <tbody>
+    <tr><td>Created</td><td>{create_time}</td></tr>
+    <tr><td>Updated</td><td>{update_time}</td></tr>
+    <tr><td>Deleted</td><td>{delete_time}</td></tr>
+  </tbody>
+</table>
 
-<h3>Timestamps</h3>
-
 <h3>Properties</h3>
 
 {props}

Modified: mgmt/trunk/basil/python/basil/widgets.py
===================================================================
--- mgmt/trunk/basil/python/basil/widgets.py	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/basil/python/basil/widgets.py	2009-02-10 12:29:37 UTC (rev 3112)
@@ -2,24 +2,25 @@
 from wooly import *
 from wooly.tables import *
 from wooly.resources import *
+from wooly.parameters import *
 
 strings = StringCatalog(__file__)
 
 class SelectableNameColumn(ItemTableColumn):
-    def __init__(self, app, name, param):
+    def __init__(self, app, name, id_param):
         super(SelectableNameColumn, self).__init__(app, name)
 
-        self.param = param
+        self.id_param = id_param
 
     def render_content(self, session, object):
         id = self.get_id(object)
         name = self.get_name(object)
 
-        selected = self.param.get(session) == id
+        selected = self.id_param.get(session) == id
         class_attr = selected and "class=\"selected\"" or ""
 
         branch = session.branch()
-        self.param.set(branch, id)
+        self.id_param.set(branch, id)
 
         return "<a %s href=\"%s\">%s</a>" % \
             (class_attr, branch.marshal(), name)
@@ -59,3 +60,38 @@
 
         def render_content(self, session, item):
             return escape(self.parent.get_item_value(item))
+
+class PanningColumnSet(Widget):
+    def __init__(self, app, name):
+        super(PanningColumnSet, self).__init__(app, name)
+
+        self.start = IntegerParameter(app, "start")
+        self.start.default = 0
+        self.add_parameter(self.start)
+
+        self.column_tmpl = Template(self, "column_html")
+
+    def render_back_href(self, session):
+        branch = session.branch()
+        self.start.set(branch, max((0, self.start.get(session) - 1)))
+        return branch.marshal()
+
+    def render_columns(self, session):
+        start = self.start.get(session)
+        writer = Writer()
+
+        for i, column in enumerate(self.children[start:]):
+            if i > 1:
+                break
+
+            if i == 1:
+                branch = session.branch()
+                self.start.set(branch, start + 1)
+                self.column_tmpl.render(writer, branch, column)
+            else:
+                self.column_tmpl.render(writer, session, column)
+
+        return writer.to_string()
+
+    def render_column(self, session, column):
+        return column.render(session)

Modified: mgmt/trunk/basil/python/basil/widgets.strings
===================================================================
--- mgmt/trunk/basil/python/basil/widgets.strings	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/basil/python/basil/widgets.strings	2009-02-10 12:29:37 UTC (rev 3112)
@@ -0,0 +1,45 @@
+[PropertySet.css]
+table.PropertySet {
+  width: 100%;
+  font-size: 0.9em;
+  text-align: left;
+  border-collapse; collapse;
+}
+
+table.PropertySet tbody td {
+  border-top: 1px dotted #ccc;
+}
+
+table.PropertySet thead a {
+  color: #666;
+  font-weight: normal;
+  font-style: italic;
+}
+
+[PropertySet.html]
+<table class="PropertySet">
+  <thead><tr>{headers}</tr></thead>
+  <tbody>{items}</tbody>
+</table>
+
+[PanningColumnSet.css]
+table.PanningColumnSet {
+  width: 100%;
+}
+
+table.PanningColumnSet tr td {
+  vertical-align: top;
+  width: 50%;
+}
+
+[PanningColumnSet.html]
+<table class="PanningColumnSet">
+  <tr>
+    <td><a href="{back_href}">&lt;&lt; Back</a></td>
+    <td></td>
+  </tr>
+  <tr>{columns}</tr>
+</table>
+
+[PanningColumnSet.column_html]
+<td>{column}</td>

Modified: mgmt/trunk/cumin/python/cumin/charts.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/charts.py	2009-02-09 22:49:51 UTC (rev 3111)
+++ mgmt/trunk/cumin/python/cumin/charts.py	2009-02-10 12:29:37 UTC (rev 3112)
@@ -26,13 +26,16 @@
         cr.set_source_rgba(color[0], color[1], color[2], 0.66)
 
         tnow = time()
+        value = None
 
         for dt, value in samples:
             if value is None:
-                log.debug("Unexpected null value") # XXX
                 continue
 
             t = secs(dt)
+
+            print "--", t
+
             # prevent line from drawing off right side of grid
             if tnow - t < 0:
                 t = tnow
@@ -41,6 +44,9 @@
             y = self.height - (value / float(self.y_max)) * self.height
             cr.line_to(x, y)
 
+        if value:
+            cr.line_to(self.width, value)
+
         cr.stroke()
 
     def plot_legend(self, titles, colors):




More information about the rhmessaging-commits mailing list