Friday, May 21, 2010

Griffon ShutdownHandler sample

Here is a simple ShutdownHandler (available since 0.3.1) sample. For simplicity, I just made the main controller implement the new ShutdownHandler interface. All it does is to print a message during shutdown, but we can imagine that it could do much more clever things. The most interesting method is canShutdown. In this sample, it always returns true, so the application will normally shutdown. Depending on some conditions, we could make it return false, to prevent the application to shutdown.

import griffon.core.*

class GriffonsampleController implements ShutdownHandler {
 def model
 def view

 void mvcGroupInit(Map args) {
  app.addShutdownHandler(this)
  }
 
 boolean canShutdown(GriffonApplication app) {
  return true;
 }
 void onShutdown(GriffonApplication app) {
  println "Shutting down..."
 }
}

GRIFFON-176

According to one of the author of Griffon, the problem I encountered on Griffon with spaces in directories (GRIFFON-176) seems to be related to GRIFFON-156. The good news is that the bug level has been raised to critical. I hope this is going to be fixed as soon as possible. Until then, I'll use Griffon with the command line on Ubuntu only.

Thursday, May 20, 2010

Griffon run-app error at Windows prompt

I've been using Griffon on Windows with IntelliJ, and on Ubuntu with Eclipse. In order to check the changes of Griffon 0.3.1, I tried to use it on Windows command line for the first time. "griffon create-app" ended successfully, but "griffon run-app" didn't.


D:\temp\java\griffonsample>griffon run-app
Welcome to Griffon 0.3.1 - http://griffon.codehaus.org/
Licensed under Apache Standard License 2.0
Griffon home is set to: D:\jar\griffon-0.3.1

Base Directory: D:\temp\java\griffonsample
Running script D:\jar\griffon-0.3.1\scripts\RunApp.groovy
Environment set to development
Warning, target causing name overwriting of name default
java.lang.NoClassDefFoundError: and
Caused by: java.lang.ClassNotFoundException: and
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: and. Program will exit.


I guess it's because of my home directory being in C:\Documents and Settings\. I found a similar bug related to using space in directories, GRIFFON-156. But it's not quite the same problem, because I don't think it's related to the java.library.path variable. I think I'll report the problem.

UPDATE : I have posted the problem. It is reported as GRIFFON-176.

Wednesday, May 19, 2010

Griffon 0.3.1 is out

Griffon 0.3.1 is out. Shutdown handlers were added, to allow to do something during the shutdown process, or to allow to abort it. Another new feature is the ability to know the running mode of the application : STANDALONE, WEBSTART or APPLET. Apart from that, the good news is that the downloadable package now contains the Griffon Guide.

Sunday, May 9, 2010

Ubuntu 10.04 breaking old habits

I updated Ubuntu to the latest 10.04 and the first thing I noticed is that the minimize/maximize/close window buttons were moved from the upper right corner, to the upper left corner. At first, I thought this was not a big deal. But after a few hours, it happens to be really annoying. How can I suddenly break a more than 10 years old habit ? No matter what, I keep looking for these buttons in the upper right corner. I definitely had to put them back to where they belong. How do we do that ?
  1. Open the gconf-editor (Alt+F2 and type gconf-editor)
  2. Search for the apps/metacity/general/button_layout key
  3. Double click it and change it to menu:maximize,minimize,close
  4. Click Ok, and the buttons should be back to the upper right
Another change in the default layout is that the maximize button comes before the minimize button. I didn't even notice it, so I'm fine with the current order.