<?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>Andrew Pietsch&#039;s Weblog &#187; UIs and Swing</title>
	<atom:link href="http://pietschy.com/blog/category/uis-and-swing/feed/" rel="self" type="application/rss+xml" />
	<link>http://pietschy.com/blog</link>
	<description>Things and stuff</description>
	<lastBuildDate>Sun, 01 Aug 2010 07:43:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simplifying</title>
		<link>http://pietschy.com/blog/2008/10/simplifying/</link>
		<comments>http://pietschy.com/blog/2008/10/simplifying/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 00:03:57 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=26</guid>
		<description><![CDATA[I always find it healthy to come back and use code you wrote a while ago. There&#8217;s nothing like a bit of space to help see things in a new light. Often too you can be so focused on solving &#8230; <a href="http://pietschy.com/blog/2008/10/simplifying/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I always find it healthy to come back and use code you wrote a while ago.  There&#8217;s nothing like a bit of space to help see things in a new light.  Often too you can be so focused on solving one problem that you don&#8217;t get a chance to step back and see the bigger&nbsp;picture.</p>
<p>And so it was when using my binding framework the other day.  Don&#8217;t get me wrong, I really like it.  But the first pass gave me flexibililty I needed, but not the simplicity I needed for day to day regular use.  Who really wants to create presentation models using the&nbsp;following?</p>
<pre>// somewhere at startup
Pectin.registerMixin(ComponentMixin.instance());

// then when you need a presentation model
PresentationModel&lt;ComponentValueModel&gt; pm =
      new PresentationModel&lt;ComponentValueModel&gt;();

// and use the "firstName" value model..
pm.get("firstName").setEnabled(false);</pre>
<p>What&#8217;s a ComponentValueModel anyway and why do I need one?  As it turns out I almost always want one (since it gives my value models the common enabled, visible, and editable properties) so why do I have to specify it every time?  Then there&#8217;s validation, you almost always need that&nbsp;too.</p>
<p>So, short story long, I&#8217;ve layered the API.  The original classes have been moved to a lower level (i.e. GenericPresentationModel) and I&#8217;ve created new implementations that extend them and that come pre-configured with the default interfaces.   I&#8217;ve also installed the associated Mixins automatically so for everyday use it&#8217;s now&nbsp;just:</p>
<pre lang="java">// This is much better
PresentationModel pm = new PresentationModel();
pm.get("firstName").setEnabled(false);</pre>
<p>Much&nbsp;nicer.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/10/simplifying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Farewell Tapestry and Hello GWT</title>
		<link>http://pietschy.com/blog/2008/06/farewell-tapestry-and-hello-gwt/</link>
		<comments>http://pietschy.com/blog/2008/06/farewell-tapestry-and-hello-gwt/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 03:52:13 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=24</guid>
		<description><![CDATA[With the upcoming release of Tapestry 5 I&#8217;ve decided to take the plunge and try out GWT. I&#8217;ve long been a Tapestry fan (I can&#8217;t stand the goto development style of Struts), but this latest version has left me a &#8230; <a href="http://pietschy.com/blog/2008/06/farewell-tapestry-and-hello-gwt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With the upcoming release of Tapestry 5 I&#8217;ve decided to take the plunge and try out GWT.  I&#8217;ve long been a Tapestry fan (I can&#8217;t stand the goto development style of Struts), but this latest version has left me a little wanting.  In&nbsp;short:</p>
<ul>
<li>It&#8217;s changing dramatically&nbsp;again.</li>
<li> The framework now magically invokes methods if they follow particular&nbsp;conventions.</li>
<li> I hate method conventions.  Intellij IDEA is really good at telling me all kinds of useful things.  Method conventions bugger that up&nbsp;completely.</li>
<li> Tapestry documentation has always been lacking, this magnifies the previous gripe by a factor of&nbsp;100.</li>
</ul>
<p>Once I realised the depth of my grumpiness I decided to re-evaluate the webapp landscape.  Since I&#8217;m not interested in ruby/rails I decided to give GWT a&nbsp;whirl.</p>
<p>The GWT approach is different.  You don&#8217;t develop a web application with lots of pages etc, you write Javascript application which you then embed in a given web page (I.e. a bit like embedding an Applet in a page).  While it&#8217;s not a solution for generating websites, it&#8217;s great for developing web&nbsp;applications.</p>
<p>What&#8217;s more, you write your Javascript in Java.  Sweet.  I get everything  Java gives me (well a fair bit anyway) like packages, interfaces and type safe refactoring&nbsp;etc.</p>
<p>Some of the good points&nbsp;are:</p>
<ul>
<li>The documentation is great.  Well thought out and well&nbsp;written.</li>
<li>The shell environment is wonderful.  The best out of the box web development experience I&#8217;ve had&nbsp;yet.</li>
<li>The client aspects of the application are written using standard client techniques.  Observable models, reusable widgets, similar development&nbsp;approaches.</li>
<li>My server is&nbsp;stateless.</li>
</ul>
<p>Things that could be&nbsp;better:</p>
<ul>
<li>There&#8217;s no binding API.  Life without binding sucks.  There are apparently plans for one, but in the mean time it took me a week to migrate my Swing binding framework over to&nbsp;GWT.</li>
<li>It would be nice if there was an easier way to add servlet context listeners and context parameters to the shell&nbsp;environment.</li>
<li>Better documentation on writing compiler plugins would be&nbsp;nice.</li>
</ul>
<p>Other than that, the combination of GWT in the browser and simple servlets using Guice on the backend has been a&nbsp;delight.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/06/farewell-tapestry-and-hello-gwt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with Google Guice: Look and Feel</title>
		<link>http://pietschy.com/blog/2008/05/playing-with-google-guice-look-and-feel/</link>
		<comments>http://pietschy.com/blog/2008/05/playing-with-google-guice-look-and-feel/#comments</comments>
		<pubDate>Mon, 12 May 2008 01:00:50 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=23</guid>
		<description><![CDATA[In this example I&#8217;m showing how I use the LookAndFeelService in conjection with the EnvironmentService to configure the LAF defaults based on the runtime environment. The LookAndFeelModule allows me to configure various look and feel aspects based on the runtime&#160;environment. &#8230; <a href="http://pietschy.com/blog/2008/05/playing-with-google-guice-look-and-feel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this example I&#8217;m showing how I use the LookAndFeelService in conjection with the EnvironmentService to configure the LAF defaults based on the runtime environment.  The LookAndFeelModule allows me to configure various look and feel aspects based on the runtime&nbsp;environment.</p>
<p>The LookAndFeelModule is the starting point.  You configure it and it configures the LookAndFeelService&nbsp;appropriately.</p>
<pre>// create the module
LookAndFeelModule lafModule = new LookAndFeelModule();

// set the default look and feel.
lafModule.setDefaultLookAndFeel(UIManager.getSystemLookAndFeelClassName());

// now configure environment specific lafs
lafModule.registerLookAndFeel(MacOSX.class,
                              QuaquaLookAndFeel.class.getName());</pre>
<p>I also use a replacement for JOptionPane that supports application wide and document specific option panes as required by the Mac. This too needs to be configured based on the environment we&#8217;re running&nbsp;on.</p>
<pre>// Configure the MessagePaneProvider to use by default
lafModule.setDefaultMessagePaneProvider(new GenericMessagePaneProvider());

// now configure environment specific MessagePane providers
lafModule.registerMessagePaneProvider(MacOSX.class,
                                      new MacMessagePaneProvider());</pre>
<p>Then I simply pass the module to my application launcher.  The application retrieves the LookAndFeelService and invokes its configure&nbsp;method.</p>
<p>Launcher.launch(MyApplication.class, args,&nbsp;lafModule);</p>
<p>Of course instead of repeating this in every application I&#8217;ve created a default module implementation that&#8217;s preconfigured.  So all I need do&nbsp;is:</p>
<pre>Launcher.launch(MyApplication.class, args, new DefaultLookAndFeelModule());</pre>
<p>And everything just works.&nbsp;Nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/05/playing-with-google-guice-look-and-feel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with Google Guice: Splash Screens</title>
		<link>http://pietschy.com/blog/2008/05/playing-with-google-guice-splash-screens/</link>
		<comments>http://pietschy.com/blog/2008/05/playing-with-google-guice-splash-screens/#comments</comments>
		<pubDate>Wed, 07 May 2008 03:22:15 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=22</guid>
		<description><![CDATA[The previous entry showed the creation of a (very) simple single frame application. Splash screens are common, so lets add one. Since there&#8217;s no easy way to do it for all occasions, we&#8217;ll use a Guice module to provide it &#8230; <a href="http://pietschy.com/blog/2008/05/playing-with-google-guice-splash-screens/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The previous entry showed the creation of a (very) simple single frame application.  Splash screens are common, so lets add one.   Since there&#8217;s no easy way to do it for all occasions, we&#8217;ll use a Guice module to provide it for runtimes prior to Java&nbsp;6.</p>
<pre>public static void main(String[] args)
{
   URL splashImage = Main.class.getResource("/images/splash.png");

   // create the splash module for pre Java 6 runtimes.
   Module splashModule = Java5SplashScreenModule(splashImage);
   Launcher.launch(MyApplication.class, args, splashModule);
}</pre>
<p>And that&#8217;s it.  The framework will display the splash screen and all will work fine.  Of course if you&#8217;re running on Java 6 you&#8217;d used the Java 6 version (that uses the new SplashScreen functionality).  Of course if we don&#8217;t define the service in one of our modules, the framework uses the default&nbsp;`NullSplashScreenService`.</p>
<p>If MyApplicationFrame (or any other class for that matter) wanted to use the splash screen service, it just needs to inject it into it&#8217;s&nbsp;constructor.</p>
<pre>public class MyApplicationFrame extends JFrame
{
   @Inject
   public MyApplicationFrame(SplashScreenService splashService)
   {
      // do stuff....
      splashService.setImageURL(nextImageURL);
   }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/05/playing-with-google-guice-splash-screens/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with Google Guice</title>
		<link>http://pietschy.com/blog/2008/05/playing-with-google-guice/</link>
		<comments>http://pietschy.com/blog/2008/05/playing-with-google-guice/#comments</comments>
		<pubDate>Wed, 07 May 2008 02:26:40 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=21</guid>
		<description><![CDATA[It&#8217;s been a long time coming but I&#8217;ve finally started dabbling in dependency injection for my swing frameworks. It&#8217;s taken me a quite a while to get a feel for where and how it can/should be used. Given the complexity &#8230; <a href="http://pietschy.com/blog/2008/05/playing-with-google-guice/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time coming but I&#8217;ve finally started dabbling in dependency injection for my swing frameworks.  It&#8217;s taken me a quite a while to get a feel for where and how it can/should be used.   Given the complexity of even an average Swing application I&#8217;d been loathed to convert all my UI construction and wiring over to a container, but I&#8217;d also love to create a framework environment where I can install all my standard behaviours in one&nbsp;line.</p>
<p>I&#8217;d also been wanting to consolidate my various frameworks and utilities into a single application framework (along the lines of <a href="https://appframework.dev.java.net/">JSR-296</a>) but wanted to try out the dependency injection&nbsp;route.</p>
<p>Anyway, so far I&#8217;ve been very pleased with the results.  I&#8217;ve been able to create services for controlling the splash screen, determining the runtime environment and providing runtime environment services, configuring Look and Feel settings and so on. With Guice you can easily create default implementations of your services so you can have the basics going with zero&nbsp;configuration.</p>
<p>So the following useless example shows what&#8217;s necessary to get a frame up and create a file in the default application data&nbsp;directory.</p>
<pre>public class MyApplication
extends SingleFrameApplication
{
   public MyApplication()
   {
      super("MyApplication", MyApplicationFrame.class);
   }

   public void initialise(String[] args)
   {
      // The EnvironemntService ensures it's the correct location
      // based on the runtime platform.. i.e. `C:\AppData\MyApplication`
      // on windows and `~/Library/Application Support/MyApplication`
      // on the Mac.

      // AbstractApplication provides getters for standard services so
      // you don't have to magically discern their existence.
      EnvironmentService env = getEnvironmentServices();
      File logFile = env.getFileInAppDataDirectory("logs/my-app.log");

      // do stuff with the file...
      ....
   }
}</pre>
<p>Then the application can be simply started using the&nbsp;following.</p>
<pre>public static void main(String[] args)
{
   Launcher.launch(MyApplication.class, args);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/05/playing-with-google-guice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I generally avoid GUI Builders</title>
		<link>http://pietschy.com/blog/2008/02/why-i-generally-avoid-gui-builders/</link>
		<comments>http://pietschy.com/blog/2008/02/why-i-generally-avoid-gui-builders/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 23:55:41 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=12</guid>
		<description><![CDATA[How&#8217;s that for a non committal title&#160;(c: Most of my own thoughts have been better explained by others.  Beware the GUI Builder is an excellent article on Hacknot, and a response by Karsten Lentzsch to this post sums up the &#8230; <a href="http://pietschy.com/blog/2008/02/why-i-generally-avoid-gui-builders/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How&#8217;s that for a non committal title&nbsp;(c:</p>
<p>Most of my own thoughts have been better explained by others.  <a href="http://www.hacknot.info/hacknot/action/showEntry?eid=76">Beware the GUI Builder</a> is an excellent article on <a href="http://www.hacknot.info/">Hacknot</a>, and a response by Karsten Lentzsch to <a href="http://weblogs.java.net/blog/joshy/archive/2007/06/a_response_to_g.html">this post</a> sums up the design issues well (search for &#8220;Karsten Lentzsch&#8221; and you&#8217;ll find his&nbsp;comment).</p>
<p>The meta design issues described by Karsten are a major sticking point for me.  The implication is that if you use GUI builders and your UI design requires that the label/component gap be 4 DLUs, or that section titles should have 12 DLUs of top padding, then every developer must know every rule and ensure they implement it correctly on every form.  You will have&nbsp;problems.</p>
<p>Custom layout builders on the other hand don&#8217;t generally suffer the same fate.  They&#8217;re able to capture the design rules in one place (i.e. the DRY principle) and your developers can live blissfully unaware of the nitty gritty requirements or implementation&nbsp;issues.</p>
<p>For larger projects you can also specialise the builders and integrate them with other infrastructure such as a binding or command&nbsp;framework.</p>
<pre>//  a trivial example that doesn't really make sense.
SimpleFormBuilder b = new SimpleFormBuilder();
b.setFormTitle("My Cool Form");
b.addTextField("First _Name", firstNameValueModel);</pre>
<p>Of course the real problems with layout builders is that you have to design and write them,  and there will always be cases that break the rules.  You can minimize this pain however if you start with a decent builder and layer your architecture so developers can drop down to &#8220;manual&#8221; for the edge&nbsp;cases.</p>
<p>This then is the real issue for me: if you only have a few static screens, then a GUI builder is probably an acceptable option, but once your project grows you&#8217;re heading for&nbsp;trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2008/02/why-i-generally-avoid-gui-builders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing with ANTLR</title>
		<link>http://pietschy.com/blog/2007/09/playing-with-antlr/</link>
		<comments>http://pietschy.com/blog/2007/09/playing-with-antlr/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 08:03:32 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=16</guid>
		<description><![CDATA[One aspect that can be annoying when creating value models creating bindings for their enabled and visible states. The following shows a simple example where certain components are enabled and disabled based on the value of&#160;others. In this screen, the &#8230; <a href="http://pietschy.com/blog/2007/09/playing-with-antlr/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One aspect that can be annoying when creating value models creating bindings for their enabled and visible states.  The following shows a simple example where certain components are enabled and disabled based on the value of&nbsp;others.</p>
<p><img src="/blog/wp-content/uploads/2007/09/mr-schedule-options.png" alt="Mr Schedule Options" title="Mr Schedule Options" width="344" height="435" class="aligncenter size-full wp-image-77" /></p>
<p>In this screen, the &#8220;Use Proxy&#8221; is only enabled when &#8220;Automatically Check for Updates&#8221; is selected, and both the &#8220;Host&#8221; and &#8220;Port&#8221; fields are only enabled when both check boxes are&nbsp;selected.</p>
<p>To simplify this kind of operation I&#8217;ve been playing around with <a href="http://www.antlr.org/">ANTLR</a> grammars.  First off, if you&#8217;re like me and have never built a language parser before, just go ahead and <a href="http://www.pragmaticprogrammer.com/titles/tpantlr/index.html">buy the book</a>.  Building an abstract syntax tree would have been near impossible without&nbsp;it.</p>
<p>So far I&#8217;ve been able to get a basic language up and going.  The syntax is simple and lets you assign model properties from simple expressions involving other models, for&nbsp;example:</p>
<pre>useProxy.enabled = checkForUpdates.value</pre>
<p>This binds the enabled property of &#8220;useProxy&#8221; to the value of &#8220;checkForUpdates&#8221;.   I also let you omit the &#8220;.value&#8221; for simplicity, so then we&nbsp;get:</p>
<pre>useProxy.enabled = checkForUpdates</pre>
<p>So state of the all the components in the above image is controlled by the three &#8220;bind&#8221; lines of code in the&nbsp;PresentationModel.</p>
<pre>// install the value models...
installValueModel("checkForUpdates", ..);
installValueModel("useProxy", ..);
installValueModel("proxyHost", ..);
installValueModel("proxyPort", ..);

// and create the bindings
bind("useProxy.enabled = checkForUpdates");
bind("proxyHost.enabled = checkForUpdates &#038;& useProxy");
bind("proxyPort.enabled = checkForUpdates &#038;& useProxy");
</pre>
<p>Normally I don&#8217;t like putting code in strings, but in this case I think it&#8217;s worth it.  To limit any possible issues the library barfs during the call to bind if any of the models are missing or don&#8217;t define the required&nbsp;properties. </p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2007/09/playing-with-antlr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>And then there were Mixins</title>
		<link>http://pietschy.com/blog/2007/09/and-then-there-were-mixins/</link>
		<comments>http://pietschy.com/blog/2007/09/and-then-there-were-mixins/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 22:42:58 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=13</guid>
		<description><![CDATA[One of the key goals for my binding infrastructure has been to make it easy to extend the value models to suit your business requirements. The idea was let you define a custom value model properties and have the library &#8230; <a href="http://pietschy.com/blog/2007/09/and-then-there-were-mixins/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the key goals for my binding infrastructure has been to make it easy to extend the value models to suit your business requirements.  The idea was let you define a custom value model properties and have the library automatically manage them.  I had this working pretty well, but it was pretty painful to set up, and definitely not something I&#8217;d wish on&nbsp;others.</p>
<p>Enter Mixins.  Somewhere along the line it occurred to me that I could create Mixins that provide standard ValueModel extensions and their handlers out of the box.  The first test was to convert my ComponentValueModel interfaces that defines standard component properties such as enabled, editable and&nbsp;visible.  </p>
<pre>public interface ComponentValueModel extends ValueModel
{
    @DefaultValue(true)
    public boolean isEnabled();
    public void setEnabled(boolean enabled);

    @DefaultValue(true)
    public boolean isEditable();
    public void setEditable(boolean editable);

    @DefaultValue(true)
    public boolean isVisible();
    public void setVisible(boolean visible);
}
</pre>
<p>Using this mixin is now as simple&nbsp;as..</p>
<pre>// install the mixin that defines the ComponentValueModel
// interface and standard handlers.
Pectin.registerMixin(ComponentMixin.instance());

// create a presentation model that vends ComponentValueModels
pm = new BeanPresentationModel&lt;Person, ComponentValueModel&gt;(...);

// all the value models returned by the presentation model will
// implement the mixin interface.
ComponentValueModel cvm = pm.get("firstName");

// changes to the mixin properties will be automatically handled
// by the mixin
cvm.setEnabled(true);
cvm.setEditable(false);
cvm.setVisible(true);
</pre>
<p>From here the mixin is responsible for updating the state of components bound to ComponentValueModels.  The mixin uses styles that map particular model properties to particular components allowing you to control the way particular properties effect particular&nbsp;components. </p>
<p>So far I&#8217;m really pleased with the&nbsp;progress.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2007/09/and-then-there-were-mixins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Value Model thoughts…</title>
		<link>http://pietschy.com/blog/2007/08/more-value-model-thoughts/</link>
		<comments>http://pietschy.com/blog/2007/08/more-value-model-thoughts/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 07:30:32 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=17</guid>
		<description><![CDATA[In light of my previous post, I&#8217;ve long pondered how I could create a generic PresentationModel/ValueModel framework that can be customised on a per project&#160;basis. Must be able to extend the ValueModel interface with real meta data&#160;methods. Must be able &#8230; <a href="http://pietschy.com/blog/2007/08/more-value-model-thoughts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In light of my previous post, I&#8217;ve long pondered how I could create a generic PresentationModel/ValueModel framework that can be customised on a per project&nbsp;basis.</p>
<ol>
<li>Must be able to extend the ValueModel interface with real meta data&nbsp;methods.</li>
<li>Must be able to modify the behaviour of the component bindings to use use the custom ValueModel metadata defined&nbsp;above.</li>
<li>Must support buffering&nbsp;natively.</li>
<li>Must be easy to use out of the box and easy to&nbsp;customise.</li>
</ol>
<p>I&#8217;d had a couple of goes at this in the past but yesterday I had a bit of a moment where I believed it might be possible (either rightly or&nbsp;wrongly).  </p>
<p>Ignoring any doubts I tried a few ideas and to my surprise it progressed pretty well.  I think this was partly because I&#8217;d been spending more time away from the Mac where my brain could think in&nbsp;peace.</p>
<p>Anyway, I shall continue plugging away and see how it turns&nbsp;out.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2007/08/more-value-model-thoughts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Value Models</title>
		<link>http://pietschy.com/blog/2007/08/valuemodels/</link>
		<comments>http://pietschy.com/blog/2007/08/valuemodels/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 22:40:11 +0000</pubDate>
		<dc:creator>pietschy</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[UIs and Swing]]></category>

		<guid isPermaLink="false">http://pietschy.webfactional.com/blog/?p=8</guid>
		<description><![CDATA[I recently worked on a large scale Swing project where we made heavy use of value models in the UI. The requirements were complex as the interface designers were more interested in what was good rather than what was&#160;easy. In &#8230; <a href="http://pietschy.com/blog/2007/08/valuemodels/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently worked on a large scale Swing project where we made heavy use of value models in the UI.  The requirements were complex as the interface designers were more interested in what was good rather than what was&nbsp;easy.   </p>
<p>In our technology selection we examined various value model frameworks such as <a href="http://spring-rich-c.sourceforge.net/">Spring Rich Client</a>, <a href="https://binding.dev.java.net/">JGoodies Binding</a> and PGS Binding.  Of all the frameworks we examined, none provided a simple mechanism for adding meta data to our value&nbsp;models. </p>
<p>Some of our meta data included the following&nbsp;properties:</p>
<ol>
<li>Obfuscated - some fields need to be be obfuscated from view (such as credit card numbers) based on the users&nbsp;profile.</li>
<li>These fields also needed the ability to be un-obfuscated&nbsp;temporarily.</li>
<li>Editable - Some fields needed to be displayed, but were only editable if the user had the required privileges.  Non editable fields looked like labels and not like regular&nbsp;components.</li>
<li>Enabled - Fields that were editable could be either enabled or&nbsp;disabled. </li>
<li>Visible - Fields and forms needed to be shown and&nbsp;hidden. </li>
</ol>
<p>Even if we could find a framework that could model these aspects it would be unlikely that it would match the exact look and feel requirements of our designers.  So in the end, we decided to write our&nbsp;own.</p>
<p>Our approach was to use the ValueModel as both and Adapter and Decorator.  As an adapter the value model was responsible for transfering the value to and from the source.  As a decorator it provided additional information about the value that was relevant for the&nbsp;UI.  </p>
<p><img src="/blog/wp-content/uploads/2007/08/value-models.png" alt="Binding Overview" title="Binding Overview" width="500" height="196" class="aligncenter size-full wp-image-91" /></p>
<p>The key to the design was that  the infrastructure modeled our business requirements.  In the end developers had very little code to write to create a whole dollar, obfuscated `JFormattedTextField`, and none of it was difficult or&nbsp;Swing-ish. </p>
]]></content:encoded>
			<wfw:commentRss>http://pietschy.com/blog/2007/08/valuemodels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
