<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Kaptain on ... stuff &#187; Model-view-controller</title>
	<atom:link href="http://www.kellyrob99.com/blog/tag/model-view-controller/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kellyrob99.com/blog</link>
	<description>Tales of development, life and the folly that goes along with both</description>
	<lastBuildDate>Sun, 04 Dec 2011 21:51:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>SwingSet on Griffon</title>
		<link>http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=swingset-on-griffon</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 03:57:47 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[cobertura]]></category>
		<category><![CDATA[fest]]></category>
		<category><![CDATA[Griffon]]></category>
		<category><![CDATA[Groovy]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Model-view-controller]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SwingSet]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=103</guid>
		<description><![CDATA[So as&#160; as learning experience, I&#8217;ve decided to try cutting the&#160; SwingSet demo application over to Groovy and Griffon. To make it a little more interesting, I&#8217;m going to base it off of the SwingX version. The SwingX widgets have been a pleasure to work with in the past, and with the swingX plugin, it [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/03/15/fun-day-playing-with-new-stuff/' rel='bookmark' title='Fun day playing with new Stuff'>Fun day playing with new Stuff</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/27/vijug-griffongroovy-presentation/' rel='bookmark' title='VIJUG Griffon/Groovy Presentation'>VIJUG Griffon/Groovy Presentation</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>So as&nbsp; as learning experience, I&#8217;ve decided to try cutting the&nbsp; <a href="https://swingset3.dev.java.net/">SwingSet demo application</a> over to Groovy and <a class="zem_slink" href="http://groovy.codehaus.org/Griffon" title="Griffon (framework)" rel="homepage">Griffon</a>. To make it a little more interesting, I&#8217;m going to base it off of the <a href="http://swinglabs.org/demos.jsp">SwingX version</a>.</p>
<p>The SwingX widgets have been a pleasure to work with in the past, and with the <a href="http://griffon.codehaus.org/SwingxBuilder+Plugin">swingX plugin</a>, it takes not a single line of extra code in order to use them.&nbsp; The underlying <a href="http://groovy.codehaus.org/SwingXBuilder">SwingXBuilder</a> provides factories which override the standard <a href="http://groovy.codehaus.org/Swing+Builder">SwingBuilder</a> syntax to replace the standard widget set with the SwingX equivalents. Simply add the prefix &#8216;jx&#8217; to the standard SwingBuilder node calls and you&#8217;re in business.</p>
<p>Along the way I&#8217;m going to incorporate the <a href="http://griffon.codehaus.org/Fest+Plugin">fest</a> and <a href="http://griffon.codehaus.org/CodeCoverage+Plugin">cobertura</a> plugins to test out the UI. I&#8217;ve never used fest before but it seems that the only real requirement is to remember to give your components a uniquely identifiable id. There are additional ways of looking up components with fest, for sure, but unique ids should cover this application&#8217;s needs quite nicely. Using both together is a simple exercise on the command line.</p>
<pre class="brush: groovy; title: ; notranslate">griffon run-fest -cobertura</pre>
<p>Under the hood, Griffon uses <a href="http://testng.org/doc/index.html">TestNG</a>, so the test class can also take advantage of some nice familiar annotations to assist configuration. Code coverage and testing results are provided by default in an html format, which anyone who likes their test coverage will be infinitely familiar with.&nbsp; All in all, the experience of setup and execution of the testing framework is pretty painless.</p>
<p>The SwingSet demo is actually laid out pretty nicely for testing in the first place. There&#8217; s a top level MainWindow class, which accepts a DemoPanel parameter. The full demo launches with a SwingXDemo subclass of DemoPanel that aggregates other subclasses of the same into a tabbed pane. Tests are free to call the MainWindow class with any of the individual panels as a parameter, so testing them on their own using fest looks like it would be a cinch.&nbsp; In Griffon terms this roughly translates to a root MVC group that composes another MVC group that is specified by id. Easier to show than to explain, with an example of a call that would go in the controller:</p>
<pre class="brush: groovy; title: ; notranslate">
createMVCGroup(mvcGroupIDParam, uid,   [... param map ...] )
</pre>
<p>The first thing created in the SwingSet UI is the menu, so that&#8217;s what I created first as well. In the view class:</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
 actions {
    action(id: &quot;quitAction&quot;,
            name: model.QUIT_NAME,
            mnemonic: &quot;Q&quot;,
            accelerator: shortcut(&quot;Q&quot;),
            closure: controller.quit)
  }

  menuBar {
    menu(model.MENU_NAME) {
      menuItem(name: model.QUIT_NAME, action:quitAction)
    }
  }
</pre>
<p>The component names are defined in the model class so that they can easily be extracted later for testing purposes.<br />
Including the fest plugin with Griffon adds a target which is used to create a new test, which will prompt you for a test name.</p>
<pre class="brush: groovy; title: ; notranslate">create-fest-test</pre>
<p>The new test class is created with all of the necessary code to let fest launch the base application frame. This first test is very simple, just making sure that our single menu item is present in the GUI.</p>
<pre class="brush: groovy; smart-tabs: true; title: ; notranslate">
  @Test
  void testQuitMenuItemPresent()
  {
    Assert.assertNotNull( window.menuItem(GriffonSwingSet3Model.QUIT_NAME) )
  }
</pre>
<p>That&#8217;s really all it takes to launch a new application using the test harness and verify UI component state. Man, can I think of a couple of times in the past where that might have come in handy <img src='http://www.kellyrob99.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Next, step is cutting over the first SwingSet DemoPanel, a demonstration of JXBusyLabel &#8211; 635 lines of the usual Swing inner classes and boilerplate GridBagLayout constraints code. Really looking forward to seeing how it looks in Groovy.</p>
<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/16488263-27eb-48d8-a2e7-387ff800c515/" title="Zemified by Zemanta"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=16488263-27eb-48d8-a2e7-387ff800c515" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
<!-- AdSense Now! V1.95 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="float:right;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-6955914197200080";
/* 728x90, created 8/3/09 */
google_ad_slot = "4051815125";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/03/15/fun-day-playing-with-new-stuff/' rel='bookmark' title='Fun day playing with new Stuff'>Fun day playing with new Stuff</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/08/27/vijug-griffongroovy-presentation/' rel='bookmark' title='VIJUG Griffon/Groovy Presentation'>VIJUG Griffon/Groovy Presentation</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The first two chapters of Griffon In Action</title>
		<link>http://www.kellyrob99.com/blog/2009/04/01/the-first-two-chapters-of-griffon-in-action/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-first-two-chapters-of-griffon-in-action</link>
		<comments>http://www.kellyrob99.com/blog/2009/04/01/the-first-two-chapters-of-griffon-in-action/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 06:32:52 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Model-view-controller]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SwingWorker]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=84</guid>
		<description><![CDATA[Documentation up until now has been sparse to be sure, but judging by the first two chapters of the MEAP for Griffon in Action, this book is going to be worth every penny. I&#8217;ve experimented a bit with Griffon a bit lately, but still being somewhat of a Groovy noob, I don&#8217;t think that the [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/08/27/vijug-griffongroovy-presentation/' rel='bookmark' title='VIJUG Griffon/Groovy Presentation'>VIJUG Griffon/Groovy Presentation</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Documentation up until now has been sparse to be sure, but judging by the first two chapters of the <a href="http://www.manning.com/about/meap.html">MEAP</a> for <a href="http://www.manning.com/almiray/">Griffon in Action</a>, this book is going to be worth every penny.</p>
<p>I&#8217;ve experimented a bit with <a class="zem_slink" title="Griffon (framework)" rel="homepage" href="http://groovy.codehaus.org/Griffon">Griffon</a> a bit lately, but still being somewhat of a <a href="http://groovy.codehaus.org/">Groovy</a> noob, I don&#8217;t think that the full impact hit me until I started reading the book. Maybe part of the problem is not that it&#8217;s hard to understand, but that it&#8217;s hard to believe that it&#8217;s so easy.</p>
<p>A very clearly defined way of separating the classic <a class="zem_slink" title="Model-view-controller" rel="wikipedia" href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a>. Injection of views, models, controllers &#8211; all available by convention not by annotation, xml configuration or even having to a refer to a component by name. The transparent access to a variety of builder actions through plugins makes a large toolset available with little or no cost. Clear architectural boundaries exist that guide you to where your code should be developed. The Griffon framework, created with gracious acknowledgement to its forerunner <a class="zem_slink" title="Grails (framework)" rel="homepage" href="http://grails.org">Grails</a> strives to do one thing above all &#8211; make Swing easy.</p>
<p>The power and versatility of Swing has always been obvious to me. The &#8216;magic sauce&#8217; that makes large scale Java Swing applications behave in any sane way has been a little more hazy. The advent of SwingWorker and other enhancements to the Swing toolset and the availability of better documentation have certainly made the landscape a lot more tolerable, but at the end of the day, it&#8217;s still hard to even find good examples of large Swing apps to use as a guideline(well at least it has been for me.) On the other side of the spectrum, I&#8217;m not sure there IS such a thing as a small Swing app. The amount of boilerplate code required is cumbersame, to say the least, and between anonymous inner classes for actions/listeners and correct handling of business logic and the <a class="zem_slink" title="Event dispatching thread" rel="wikipedia" href="http://en.wikipedia.org/wiki/Event_dispatching_thread">EDT</a> by the time you&#8217;ve finished doing anything moderately significant you&#8217;re already a couple 1000 lines in.</p>
<p>Griffon takes all that and hides it behind a curtain. Expanding on the already powerful SwingBuilder capabilities, it provides a quick and easy way to develop complex Swing applications. Utilizing @Binding to provide easy view/model interaction and baking the Observer pattern right into the framework make it beyond simple to deal with <a class="zem_slink" title="Graphical user interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Graphical_user_interface">GUI</a> events. And the pattern for dealing with EDT issues couldn&#8217;t be much more straightforward.</p>
<pre class="brush: groovy; title: ; notranslate">

doOutside {
.... do whatever you need to do off of the EDT
doLater { ... come back to the EDT when you're done to update widgets }
}
</pre>
<p>I&#8217;m pretty sure that&#8217;s an easy enough pattern that I will never again forget the cost of doing&#8230; well pretty much anything that takes +1 second while blocking the EDT.</p>
<p>Personally, I&#8217;ve run into a couple of unexpected results when trying to utilize the webstart version of the application, but other than that everything has worked exactly as advertised. And at the end of the day I&#8217;m willing to chalk that up to my misuse of the system. I&#8217;ll tell you for sure when I get to that chapter of the book. Which will probably be about 2 days after the authors publish it.</p>
<p> <img src='http://www.kellyrob99.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So far my impression of the pre-release chapters of the book are pretty good &#8211; well written, clear and above all &#8211; the code samples work. Kudos to the authors <a href="http://www.jroller.com/aalmiray/">Andres Almiray</a>,<a href="http://shemnon.com/speling/"> Danno Ferrin</a> and <a href="http://blogs.sun.com/geertjan/">Geertjan Wielenga</a>.&nbsp; Look forward to the rest of the book boys, and to writing some new Swing apps with Griffon!</p>
<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/07d75949-b8da-4090-a057-6c9c6b02b056/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=07d75949-b8da-4090-a057-6c9c6b02b056" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
<p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2009/08/27/vijug-griffongroovy-presentation/' rel='bookmark' title='VIJUG Griffon/Groovy Presentation'>VIJUG Griffon/Groovy Presentation</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/08/griffon-swingx-fest-testing/' rel='bookmark' title='Griffon SwingX Fest testing'>Griffon SwingX Fest testing</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/04/01/the-first-two-chapters-of-griffon-in-action/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fun day playing with new Stuff</title>
		<link>http://www.kellyrob99.com/blog/2009/03/15/fun-day-playing-with-new-stuff/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fun-day-playing-with-new-stuff</link>
		<comments>http://www.kellyrob99.com/blog/2009/03/15/fun-day-playing-with-new-stuff/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 19:56:46 +0000</pubDate>
		<dc:creator>TheKaptain</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Griffon]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Model-view-controller]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://www.kellyrob99.com/blog/?p=50</guid>
		<description><![CDATA[Today was a pretty great day, I must say. I got a chance to work with the brand new Griffon framework and must say &#8211; the combination of clear MVC architecture, Grails style convention over configuration and already powerful plugin selection make it pretty sexy. The early support for cobertura code coverage and fest GUI [...]
Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2010/02/11/a-one-day-griffon-applicationpresentation/' rel='bookmark' title='A One Day Griffon Application/Presentation'>A One Day Griffon Application/Presentation</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/03/07/playing-with-the-new-grails/' rel='bookmark' title='Playing with the new Grails :)'>Playing with the new Grails :)</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Today was a pretty great day, I must say.</p>
<p>I got a chance to work with the brand new <a class="zem_slink" title="Griffon (framework)" rel="homepage" href="http://groovy.codehaus.org/Griffon">Griffon</a> framework and must say &#8211; the combination of clear <a class="zem_slink" title="Model-view-controller" rel="wikipedia" href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a> architecture, <a class="zem_slink" title="Grails (framework)" rel="homepage" href="http://grails.org">Grails</a> style convention over configuration and already powerful plugin selection make it pretty sexy.</p>
<p>The early support for cobertura <a class="zem_slink" title="Code coverage" rel="wikipedia" href="http://en.wikipedia.org/wiki/Code_coverage">code coverage</a> and fest <a class="zem_slink" title="GUI software testing" rel="wikipedia" href="http://en.wikipedia.org/wiki/GUI_software_testing">GUI testing</a> are both appealing to any developer that appreciates the need for testing your application.  I&#8217;m still undecided on the Grails-like adoption of storing project information in a &#8220;.griffon&#8221; folder in the user directory and completely outside of the actual project directory structure. With luck, future versions will allow for incorporating maven to handle dependency management and get me past my FUD on that one, something that the latest Grails supports. I haven&#8217;t yet tried that new feature out in Grails out so I&#8217;m not entirely sure how well it works, but the docs say that there is a provided archetype and that all of the familiar Grails targets are <a href="http://www.grails.org/Maven+Integration">mirrored in the maven goals</a>.</p>
<p>Being able to add additional Groovy style builders as plugins is about as transparent as it gets &#8211; install the plugin and you can immediately incorporate that builder anywhere in the application.  The only builder component set that I have had a chance to work with previously is <a href="https://swingx.dev.java.net/">SwingX</a>, but anyone who&#8217;s had the opportunity to use a JXTable in place of the vanilla JTable can immediately see the advantage! And the JDirectoryChooser from <a href="http://www.l2fprod.com/">l2fprod</a> is a powerful alternative to the <a class="zem_slink" title="Swing (Java)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Swing_%28Java%29">Swing</a> built-in JFileChooser.</p>
<p>The crown jewel so far however seems to be  the <a href="http://griffon.codehaus.org/Wizard+Plugin">wizard plugin</a>. This addresses what is  a very common scenario in any process related application:</p>
<ul>
<li> collect User input in a series of steps</li>
<li>validate the input at each step</li>
<li>allow the User  to go back and review or change any inputs</li>
<li>apply all of the input to an underlying business process</li>
<li>provide feedback as to the result</li>
</ul>
<p>The <a href="https://wizard.dev.java.net/">wizard framework</a> worked pretty much as advertised right out of the box and, although the project seems to have stalled (couldn&#8217;t seem to  find any updates since mid-2008) , when integrated so well with Griffon it seems a very good candidate for building lightweight applications &#8211; installers in particular jump to mind.</p>
<p>Any way you look at it &#8211; for a project as newly arrived as Griffon, it&#8217;s already promising to be a very powerful enabler. Thanks to <a href="http://www.jroller.com/aalmiray/">Andres Almiray</a> and everyone else involved in the project. I look forward to using Griffon more in the future.</p>
<div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/a8105dd0-7c00-4551-8e80-5731041a87c6/"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=a8105dd0-7c00-4551-8e80-5731041a87c6" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p>Related posts:<ol>
<li><a href='http://www.kellyrob99.com/blog/2010/02/11/a-one-day-griffon-applicationpresentation/' rel='bookmark' title='A One Day Griffon Application/Presentation'>A One Day Griffon Application/Presentation</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/03/07/playing-with-the-new-grails/' rel='bookmark' title='Playing with the new Grails :)'>Playing with the new Grails :)</a></li>
<li><a href='http://www.kellyrob99.com/blog/2009/04/03/swingset-on-griffon/' rel='bookmark' title='SwingSet on Griffon'>SwingSet on Griffon</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.kellyrob99.com/blog/2009/03/15/fun-day-playing-with-new-stuff/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

