[rhmessaging-commits] rhmessaging commits: r2724 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Sat Nov 1 13:28:21 EDT 2008


Author: eallen
Date: 2008-11-01 13:28:21 -0400 (Sat, 01 Nov 2008)
New Revision: 2724

Modified:
   mgmt/trunk/cumin/python/cumin/job.py
   mgmt/trunk/cumin/python/cumin/model.py
   mgmt/trunk/cumin/python/cumin/stat.py
   mgmt/trunk/cumin/python/cumin/stat.strings
Log:
Using ItemSet for grid widget legend

Modified: mgmt/trunk/cumin/python/cumin/job.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/job.py	2008-11-01 16:47:39 UTC (rev 2723)
+++ mgmt/trunk/cumin/python/cumin/job.py	2008-11-01 17:28:21 UTC (rev 2724)
@@ -1291,7 +1291,4 @@
 
     @classmethod
     def get_zipped_colors(cls):
-        colors = dict()
-        for stat in cls.stat_strings:
-            colors[stat] = cls.stat_colors[cls.stat_strings.index(stat)]
-        return colors
\ No newline at end of file
+        return zip(cls.stat_strings, cls.stat_colors)

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2008-11-01 16:47:39 UTC (rev 2723)
+++ mgmt/trunk/cumin/python/cumin/model.py	2008-11-01 17:28:21 UTC (rev 2724)
@@ -593,12 +593,14 @@
         return object.nodeName
 
     class VisSlots(CuminAction):
-        load_colors = {"Idle": "clear", 
-                       "Busy": "green", 
-                       "Suspended": "red", 
-                       "Vacating": "red",
-                       "Killing": "blue",
-                       "Benchmarking": "yellow" }
+        # list of status/colors in the order we want them displayed
+        # in the legend
+        load_colors = [("Idle", "clear"), 
+                       ("Busy", "green"),
+                       ("Suspended", "red"),
+                       ("Vacating", "red"),
+                       ("Killing", "blue"),
+                       ("Benchmarking", "yellow")]
 
         def __init__(self, cls, name):
             super(CuminSystem.VisSlots, self).__init__(cls, name)
@@ -633,9 +635,10 @@
 
         def get_color(self, slot):
             activity = slot["activity"]
-            if activity in self.load_colors:
-                return self.load_colors[activity]
-            return "black"
+            for status, color in self.load_colors:
+                if status == activity:
+                    return color
+            return "black"  
 
         def get_colors(self):
             return self.load_colors
@@ -1871,7 +1874,7 @@
             status = self.get_status(job)
             color = JobStatusInfo.get_status_color(status) 
             if "Idle" == JobStatusInfo.get_status_string(status):
-                color = "clear"   
+                color = "clear" # instead of green  
             return color
 
         def get_colors(self):

Modified: mgmt/trunk/cumin/python/cumin/stat.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.py	2008-11-01 16:47:39 UTC (rev 2723)
+++ mgmt/trunk/cumin/python/cumin/stat.py	2008-11-01 17:28:21 UTC (rev 2724)
@@ -145,13 +145,15 @@
         super(StatUtilizationGrid, self).__init__(app, name)
 
         self.stats_tmpl = Template(self, "cell_html")
-        self.legend_tmpl = Template(self, "legend_html")
         
         self.sticky = self.Sticky(app, "sticky_info")
         self.add_child(self.sticky)
+
+        legend = self.Legend(app, "grid_legend")
+        self.add_child(legend)
         
-        self.ajax = self.Updater(app, "grid_updater")
-        self.add_child(self.ajax)
+        ajax = self.Updater(app, "grid_updater")
+        self.add_child(ajax)
 
     def get_args(self, session):
         """ must return a sequence """
@@ -174,21 +176,6 @@
     def render_override_style(self, session, objects):
         pass
     
-    def render_legends(self, session, objects):
-        colors = self.get_colors(session)
-        writer = Writer()
-        
-        sorted_keys = sorted(colors.keys())
-        for key in sorted_keys:
-            self.legend_tmpl.render(writer, session, colors, key)
-        return writer.to_string()
-        
-    def render_legend_color(self, session, colors, key):
-        return colors[key]
-    
-    def render_legend_text(self, session, colors, key):
-        return key
-    
     def render_cell_width(self, session, count, object):
         sq = sqrt(count)
         isq = int(sq)
@@ -212,6 +199,9 @@
     def render_cell_id(self, session, count, object):
         return 1
     
+    def get_colors(self, session):
+        return ["clear"]
+        
     def render_sticky_rows(self, session, count, object):
         return self.sticky.render_items(session, object)
     
@@ -233,6 +223,16 @@
     def get_sticky_info(self, session):
         return [("Name", "Display Title")]
     
+    class Legend(ItemSet):
+        def do_get_items(self, session, *args):
+            return self.parent.get_colors(session)
+
+        def render_legend_text(self, session, color):
+            return color[0]
+        
+        def render_legend_color(self, session, color):
+            return color[1]
+    
     class Sticky(ItemSet):
         def do_get_items(self, session, *args):
             info = self.parent.get_sticky_info(session)

Modified: mgmt/trunk/cumin/python/cumin/stat.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/stat.strings	2008-11-01 16:47:39 UTC (rev 2723)
+++ mgmt/trunk/cumin/python/cumin/stat.strings	2008-11-01 17:28:21 UTC (rev 2724)
@@ -330,7 +330,7 @@
 	</div>
 </div>
 <div id="cell_legend">
-	{legends}
+	{grid_legend}
 </div>
 {grid_updater}
 
@@ -353,10 +353,8 @@
 	<td class="sticky_values" nowrap="nowrap"><span id="cell_{sticky_name}_{sticky_object_id}"></span></td>
 </tr>
 
-[StatUtilizationGrid.legend_html]
+[Legend.item_html]
 <div class="legend">
 	<button class="btn {legend_color}" style="background-image: none; width:1em; height:1em;" ></button> {legend_text}
 </div>
-
- 
  
\ No newline at end of file




More information about the rhmessaging-commits mailing list