[rhmessaging-commits] rhmessaging commits: r3185 - mgmt/trunk/wooly/python/wooly.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Mar 20 11:01:50 EDT 2009


Author: justi9
Date: 2009-03-20 11:01:50 -0400 (Fri, 20 Mar 2009)
New Revision: 3185

Added:
   mgmt/trunk/wooly/python/wooly/demo.strings
Modified:
   mgmt/trunk/wooly/python/wooly/demo.py
Log:
Explain links and toggles; add a brief intro

Modified: mgmt/trunk/wooly/python/wooly/demo.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/demo.py	2009-03-20 14:31:17 UTC (rev 3184)
+++ mgmt/trunk/wooly/python/wooly/demo.py	2009-03-20 15:01:50 UTC (rev 3185)
@@ -70,8 +70,8 @@
     def __init__(self, app, name):
         super(DemoPage, self).__init__(app, name)
 
-        main = MainView(app, "main")
-        self.add_child(main)
+        self.main_view = MainView(app, "main")
+        self.add_child(self.main_view)
 
 class MainView(Widget):
     def __init__(self, app, name):
@@ -80,8 +80,45 @@
         tabs = TabbedModeSet(app, "tabs")
         self.add_child(tabs)
 
-        tabs.add_tab(ToggleDemo(app, "toggle"))
+        self.intro_tab = Introduction(app, "intro")
+        tabs.add_tab(self.intro_tab)
 
-class ToggleDemo(Widget):
+        self.link_tab = LinkDemo(app, "link")
+        tabs.add_tab(self.link_tab)
+
+class Introduction(Widget):
     def render_title(self, session):
-        return "Toggles"
+        return "Introduction"
+
+class LinkDemo(Widget):
+    def __init__(self, app, name):
+        super(LinkDemo, self).__init__(app, name)
+
+        self.visit_intro_link = self.VisitIntroLink(app, "visit_intro_link")
+        self.add_child(self.visit_intro_link)
+
+        self.secret_toggle = self.SecretToggle(app, "secret_toggle")
+        self.add_child(self.secret_toggle)
+
+    def render_title(self, session):
+        return "Links"
+
+    def render_secret(self, session):
+        if self.secret_toggle.get(session):
+            return "Above all things, I love persimmons."
+
+    class VisitIntroLink(Link):
+        def render_href(self, session):
+            branch = session.branch()
+            self.app.main_page.main_view.intro_tab.show(branch)
+            return branch.marshal()
+
+        def render_content(self, session):
+            return "See the Egress!"
+
+    class SecretToggle(Toggle):
+        def render_content(self, session):
+            if self.get(session):
+                return "Hide that secret"
+            else:
+                return "Show me a secret"

Added: mgmt/trunk/wooly/python/wooly/demo.strings
===================================================================
--- mgmt/trunk/wooly/python/wooly/demo.strings	                        (rev 0)
+++ mgmt/trunk/wooly/python/wooly/demo.strings	2009-03-20 15:01:50 UTC (rev 3185)
@@ -0,0 +1,64 @@
+[DemoPage.css]
+.initial {
+  margin-top: 0;
+}
+
+div.instance {
+  background-color: #f0f0f0;
+  border: 1px dotted #e7e7e7;
+  padding: 1em 1.2em;
+}
+
+[MainView.html]
+<h1>Wooly Demo</h1>
+
+{tabs}
+
+[Introduction.html]
+<p class="initial">Hello.  This is a little application to explain the
+features of the <strong>Wooly</strong> web user-interface toolkit.</p>
+
+<p>The code for this demo is available in the <tt>wooly.demo</tt>
+module.</p>
+
+[LinkDemo.css]
+div.secret {
+  display: inline;
+  float: right;
+  width: 66%;
+}
+
+[LinkDemo.html]
+<h2 class="initial">Basic Links</h2>
+
+<p>A <tt>Link</tt> renders an HTML link with a URL to an alternate
+page state.  In Wooly, this is how transitions from one view or state
+to another are accomplished.</p>
+
+<p>A <tt>Link</tt> is really just a thin wrapper around the more
+fundamental ability in Wooly to take an existing <tt>Session</tt>
+object, with all its current state, and change just one part of it in
+order to produce a new, different URL and view.</p>
+
+<div class="instance">
+  <h3 class="initial">A link that changes the view to the intro tab</h3>
+
+  <p>{visit_intro_link}</p>
+</div>
+
+<h2>Toggles</h2>
+
+<p>A <tt>Toggle</tt> is a <tt>Link</tt> that remembers whether it is
+toggled or not.  It's often useful to use that state to trigger other
+behaviors.</p>
+
+<p>Internally, <tt>Toggle</tt> holds a <tt>BooleanParameter</tt>
+called "toggled".  Each time the <tt>Toggle</tt> is rendered, it
+generates a URL for its other possible state, toggled if it's
+currently untoggled and vice versa.</p>
+
+<div class="instance">
+  <h3 class="initial">A single toggle with a conditionally rendered message</h3>
+
+  <p><div class="secret">{secret}</div> {secret_toggle}</p>
+</div>




More information about the rhmessaging-commits mailing list