Author: justi9
Date: 2007-10-15 09:09:45 -0400 (Mon, 15 Oct 2007)
New Revision: 1065
Modified:
mgmt/cumin/python/cumin/cluster.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/server.py
mgmt/cumin/python/cumin/virtualhost.py
mgmt/cumin/python/wooly/widgets.py
mgmt/cumin/python/wooly/widgets.strings
Log:
Adds support in ModeSet for child widgets that are not modes. Uses
this feature to flatten the widget tree for CuminPage.
Modified: mgmt/cumin/python/cumin/cluster.py
===================================================================
--- mgmt/cumin/python/cumin/cluster.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/cluster.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -48,13 +48,13 @@
self.add_parameter(self.param)
self.view = ClusterView(app, "view")
- self.add_child(self.view)
+ self.add_mode(self.view)
self.server = ServerFrame(app, "server")
- self.add_child(self.server)
+ self.add_mode(self.server)
self.vhost = VirtualHostFrame(app, "vhost")
- self.add_child(self.vhost)
+ self.add_mode(self.vhost)
def get_object(self, session, object):
return self.param.get(session)
@@ -83,11 +83,11 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(self.ServerTab(app, "servers"))
- self.tabs.add_child(self.VirtualHostTab(app, "vhosts"))
- self.tabs.add_child(self.ConfigTab(app, "config"))
- self.tabs.add_child(self.StatsTab(app, "stats"))
- self.tabs.add_child(self.LogTab(app, "log"))
+ self.tabs.add_tab(self.ServerTab(app, "servers"))
+ self.tabs.add_tab(self.VirtualHostTab(app, "vhosts"))
+ self.tabs.add_tab(self.ConfigTab(app, "config"))
+ self.tabs.add_tab(self.StatsTab(app, "stats"))
+ self.tabs.add_tab(self.LogTab(app, "log"))
def render_title(self, session, cluster):
return "Cluster '%s'" % cluster.name
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/exchange.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -63,7 +63,7 @@
self.add_parameter(self.param)
self.view = ExchangeView(app, "view")
- self.add_child(self.view)
+ self.add_mode(self.view)
def get_object(self, session, object):
return self.param.get(session)
@@ -84,8 +84,8 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(ExchangeBindingSet(app, "bindings"))
- self.tabs.add_child(self.ExchangeLog(app, "log"))
+ self.tabs.add_tab(ExchangeBindingSet(app, "bindings"))
+ self.tabs.add_tab(self.ExchangeLog(app, "log"))
class ExchangeLog(Widget):
def render_title(self, session, exchange):
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/page.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -9,7 +9,7 @@
strings = StringCatalog(__file__)
-class CuminPage(Page):
+class CuminPage(Page, ModeSet):
def __init__(self, app, name):
super(CuminPage, self).__init__(app, name)
@@ -24,23 +24,20 @@
self.frame_tmpl = Template(self, "frame_html")
- self.modes = ModeSet(app, "mode")
- self.add_child(self.modes)
-
self.view = MainView(app, "view")
- self.modes.add_child(self.view)
+ self.add_mode(self.view)
self.server = ServerFrame(app, "server")
- self.modes.add_child(self.server)
+ self.add_mode(self.server)
self.cluster = ClusterFrame(app, "cluster")
- self.modes.add_child(self.cluster)
+ self.add_mode(self.cluster)
self.group_add = ServerGroupAdd(app, "group_add")
- self.modes.add_child(self.group_add)
+ self.add_mode(self.group_add)
self.group_edit = ServerGroupEdit(app, "group_edit")
- self.modes.add_child(self.group_edit)
+ self.add_mode(self.group_edit)
def save_session(self, session):
if self.app.debug:
@@ -61,7 +58,7 @@
def show_view(self, session):
self.set_current_frame(session, self)
- return self.modes.show_mode(session, self.view)
+ return self.show_mode(session, self.view)
def show_server(self, session, server):
cluster = server.get_cluster()
@@ -70,22 +67,22 @@
frame = self.show_cluster(session, cluster)
frame = frame.show_server(session, server)
else:
- frame = self.modes.show_mode(session, self.server)
+ frame = self.show_mode(session, self.server)
frame.set_server(session, server)
return self.page().set_current_frame(session, frame)
def show_server_group_add(self, session):
- frame = self.modes.show_mode(session, self.group_add)
+ frame = self.show_mode(session, self.group_add)
return self.page().set_current_frame(session, frame)
def show_server_group_edit(self, session, group):
- frame = self.modes.show_mode(session, self.group_edit)
+ frame = self.show_mode(session, self.group_edit)
frame.set_server_group(session, group)
return self.page().set_current_frame(session, frame)
def show_cluster(self, session, cluster):
- frame = self.modes.show_mode(session, self.cluster)
+ frame = self.show_mode(session, self.cluster)
frame.set_cluster(session, cluster)
return self.page().set_current_frame(session, frame)
@@ -149,8 +146,8 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(self.ServerTab(app, "servers"))
- self.tabs.add_child(self.ClusterTab(app, "clusters"))
+ self.tabs.add_tab(self.ServerTab(app, "servers"))
+ self.tabs.add_tab(self.ClusterTab(app, "clusters"))
def render_title(self, session, model):
return "Red Hat Messaging"
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -66,7 +66,7 @@
self.add_parameter(self.param)
self.view = QueueView(app, "view")
- self.add_child(self.view)
+ self.add_mode(self.view)
def get_object(self, session, object):
return self.param.get(session)
@@ -114,8 +114,8 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(QueueBindingSet(app, "bindings"))
- self.tabs.add_child(self.QueueLog(app, "log"))
+ self.tabs.add_tab(QueueBindingSet(app, "bindings"))
+ self.tabs.add_tab(self.QueueLog(app, "log"))
class QueueLog(Widget):
def render_title(self, session, queue):
Modified: mgmt/cumin/python/cumin/server.py
===================================================================
--- mgmt/cumin/python/cumin/server.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/server.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -46,10 +46,10 @@
self.add_parameter(self.param)
self.view = ServerView(app, "view")
- self.add_child(self.view)
+ self.add_mode(self.view)
self.vhost = VirtualHostFrame(app, "vhost")
- self.add_child(self.vhost)
+ self.add_mode(self.vhost)
def get_object(self, session, object):
return self.param.get(session)
@@ -92,10 +92,10 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(self.VirtualHostTab(app, "vhosts"))
- self.tabs.add_child(self.ConfigTab(app, "config"))
- self.tabs.add_child(self.StatsTab(app, "stats"))
- self.tabs.add_child(self.LogTab(app, "log"))
+ self.tabs.add_tab(self.VirtualHostTab(app, "vhosts"))
+ self.tabs.add_tab(self.ConfigTab(app, "config"))
+ self.tabs.add_tab(self.StatsTab(app, "stats"))
+ self.tabs.add_tab(self.LogTab(app, "log"))
def render_title(self, session, server):
return "Server '%s'" % server.name
Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/cumin/virtualhost.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -36,13 +36,13 @@
self.add_parameter(self.param)
self.queue = QueueFrame(app, "queue")
- self.add_child(self.queue)
+ self.add_mode(self.queue)
self.exchange = ExchangeFrame(app, "exchange")
- self.add_child(self.exchange)
+ self.add_mode(self.exchange)
self.view = VirtualHostView(app, "view")
- self.add_child(self.view)
+ self.add_mode(self.view)
def get_object(self, session, object):
return self.param.get(session)
@@ -71,10 +71,10 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_child(QueueSet(app, "queues"))
- self.tabs.add_child(ExchangeSet(app, "exchanges"))
- self.tabs.add_child(self.ConfigTab(app, "config"))
- self.tabs.add_child(self.LogTab(app, "log"))
+ self.tabs.add_tab(QueueSet(app, "queues"))
+ self.tabs.add_tab(ExchangeSet(app, "exchanges"))
+ self.tabs.add_tab(self.ConfigTab(app, "config"))
+ self.tabs.add_tab(self.LogTab(app, "log"))
def render_title(self, session, vhost):
return "Functional Host '%s'" % vhost.name
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/wooly/widgets.py 2007-10-15 13:09:45 UTC (rev 1065)
@@ -8,10 +8,14 @@
def __init__(self, app, name):
super(ModeSet, self).__init__(app, name)
+ self.modes = list()
+
self.mode = Parameter(app, "mode")
self.add_parameter(self.mode)
- def add_child(self, mode):
+ def add_mode(self, mode):
+ self.modes.append(mode)
+
super(ModeSet, self).add_child(mode)
if not self.mode.default:
@@ -34,7 +38,7 @@
if mode:
mode.process(session, object)
- def do_render(self, session, object):
+ def render_mode(self, session, object):
mode = self.get_selected_mode(session)
if mode:
@@ -49,18 +53,14 @@
self.object = Attribute(app, "object")
self.add_attribute(self.object)
- def do_render(self, session, object):
- writer = Writer()
+ def add_tab(self, tab):
+ self.add_mode(tab)
- self.template.render(session, object, writer)
-
- return writer.to_string()
-
def render_tabs(self, session, object):
self.object.set(session, object)
writer = Writer()
- for mode in self.children:
+ for mode in self.modes:
self.tab_tmpl.render(session, mode, writer)
return writer.to_string()
@@ -77,12 +77,6 @@
def render_tab_content(self, session, mode):
return mode.render_title(session, self.object.get(session))
- def render_mode(self, session, object):
- mode = self.get_selected_mode(session)
-
- if mode:
- return mode.render(session, object)
-
class Link(Widget):
def update_session(self, session, object):
pass
Modified: mgmt/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/cumin/python/wooly/widgets.strings 2007-10-14 20:31:09 UTC (rev 1064)
+++ mgmt/cumin/python/wooly/widgets.strings 2007-10-15 13:09:45 UTC (rev 1065)
@@ -1,3 +1,6 @@
+[ModeSet.html]
+{mode}
+
[TabSet.css]
ul.TabSet.tabs {
padding: 0;