(Quick Reference)

5.6.7 Default Imports - Reference Documentation

Authors: Andres Almiray

Version: 1.2.0

5.6.7 Default Imports

Since Griffon 0.9.1 default imports per artifacts are supported. All Groovy based artifacts will resolve classes from the griffon.core and griffon.util packages automatically, there is no longer a need to define imports on those classes unless you require an static import or define an alias. An example of this feature would be as follows.

class MyController {
    void mvcGroupInit(Map args) {
        println Metadata.current.'app.name'
    }
}

The Metadata class is defined in package griffon.util. There are additional imports per artifact type, here's the list of default definitions

  • Model
    • groovy.beans -> @Bindable, @Vetoable
    • java.beans -> useful for all PropertyChange* classes
  • View (when using Swing)
    • java.awt
    • java.awt.event
    • javax.swing
    • javax.swing.event
    • javax.swing.table
    • javax.swing.text
    • javax.swing.tree

The list of imports per artifacts can be tweaked or changed completely at will. You only need to specify a file named META-INF/griffon-default-imports.properties with the following format

<artifact_type> = <comma_separated_package_list>

These are the contents of the default file

views = javax.swing., javax.swing.event., javax.swing.table., javax.swing.text., javax.swing.tree., java.awt., java.awt.event.
models = groovy.beans., java.beans.

Imports are cumulative, this means you a package can't be removed from the default list provided by Griffon.