[rhmessaging-commits] rhmessaging commits: r1490 - in mgmt: notes and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Dec 14 10:37:47 EST 2007


Author: justi9
Date: 2007-12-14 10:37:46 -0500 (Fri, 14 Dec 2007)
New Revision: 1490

Modified:
   mgmt/cumin/python/cumin/client.py
   mgmt/cumin/python/cumin/widgets.py
   mgmt/cumin/python/cumin/widgets.strings
   mgmt/notes/justin-todo.txt
Log:
Adds a new widget StateSwitch, for producing unit radio buttons of
various sorts.  Reimplements UnitSwitch using it.

Adds a frames-vs-bytes state switch to ClientSet.



Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py	2007-12-14 14:54:01 UTC (rev 1489)
+++ mgmt/cumin/python/cumin/client.py	2007-12-14 15:37:46 UTC (rev 1490)
@@ -13,14 +13,16 @@
     def __init__(self, app, name):
         super(ClientSet, self).__init__(app, name)
 
-        self.unit = UnitSwitch(app, "unit")
+        self.unit = StateSwitch(app, "unit")
+        self.unit.add_state("f", "Frames")
+        self.unit.add_state("b", "Bytes")
         self.add_child(self.unit)
 
     def get_title(self, session, vhost):
         return "Clients %s" % fmt_count(self.get_item_count(session, vhost))
 
     def render_unit_plural(self, session, vhost):
-        return self.unit.get(session) == "b" and "Bytes" or "Msgs."
+        return self.unit.get(session) == "b" and "Bytes" or "Frames"
 
     def get_item_count(self, session, vhost):
         return Client.select(Client.q.vhostID == vhost.id).count()

Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py	2007-12-14 14:54:01 UTC (rev 1489)
+++ mgmt/cumin/python/cumin/widgets.py	2007-12-14 15:37:46 UTC (rev 1490)
@@ -240,35 +240,47 @@
         
         return writer.to_string()
     
-class UnitSwitch(Widget):
+class StateSwitch(ItemSet):
     def __init__(self, app, name):
-        super(UnitSwitch, self).__init__(app, name)
+        super(StateSwitch, self).__init__(app, name)
 
         self.param = Parameter(app, "param")
-        self.param.set_default("m")
         self.add_parameter(self.param)
 
+        self.states = list()
+        self.titles = dict()
+
+    def add_state(self, state, title):
+        self.states.append(state)
+        self.titles[state] = title
+
+        if self.param.default is None:
+            self.param.set_default(state)
+
     def get(self, session):
         return self.param.get(session)
 
     def set(self, session, value):
         return self.param.set(session, value)
 
-    def render_messages_link(self, session, vhost):
+    def get_items(self, session, object):
+        return self.states
+
+    def render_item_link(self, session, state):
         branch = session.branch()
-        self.set(branch, "m")
+        self.set(branch, state)
 
-        class_ = self.get(session) == "m" and "selected"
+        title = self.titles[state]
+        class_ = self.get(session) == state and "selected"
 
-        return fmt_link(branch.marshal(), "Messages", class_)
+        return fmt_link(branch.marshal(), title, class_)
 
-    def render_bytes_link(self, session, vhost):
-        branch = session.branch()
-        self.set(branch, "b")
+class UnitSwitch(StateSwitch):
+    def __init__(self, app, name):
+        super(UnitSwitch, self).__init__(app, name)
 
-        class_ = self.get(session) == "b" and "selected"
-        
-        return fmt_link(branch.marshal(), "Bytes", class_)
+        self.add_state("m", "Messages")
+        self.add_state("b", "Bytes")
 
 class Paginator(ItemSet):
     def __init__(self, app, name):

Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings	2007-12-14 14:54:01 UTC (rev 1489)
+++ mgmt/cumin/python/cumin/widgets.strings	2007-12-14 15:37:46 UTC (rev 1490)
@@ -52,12 +52,14 @@
   <div>{actions_pending}</div>
 </div>
 
-[UnitSwitch.html]
+[StateSwitch.html]
 <ul class="radiotabs">
-  <li>{messages_link}</li>
-  <li>{bytes_link}</li>
+  {items}
 </ul>
 
+[StateSwitch.item_html]
+<li>{item_link}</li>
+
 [Paginator.css]
 div.Paginator {
   margin: 0 0 0.5em 0;

Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt	2007-12-14 14:54:01 UTC (rev 1489)
+++ mgmt/notes/justin-todo.txt	2007-12-14 15:37:46 UTC (rev 1490)
@@ -30,8 +30,6 @@
 
  * Remove auth id for now
 
- * Unit for clients should be frames vs. bytes
-
 Deferred
 
  * Add an edit form for broker registrations so you can change their




More information about the rhmessaging-commits mailing list