Skip to: Site menu | Main content

A Grails-like Rich Internet Framework

Glazedlists Plugin Print

Description

Provides integration with GlazedLists.

Installation

The current version of griffon-glazedlists-plugin is 0.4

To install just issue the following command

griffon install-plugin glazedlists

Usage

The following nodes will become available on a View script upon installing this plugin

Node Property Type Default Required Bindable Notes
defaultTableFormat

[DefaultTableFormat]
columnNames List    
  read Closure   closure used to read properties from an element
defaultAdvancedTableFormat

[DefaultAdvancedTableFormat]
columns List<Map>    
  columns.name String   column's name
  columns.class Class Object column's class
  columns.comparator Comparator {a, b -> a <=> b } column's comparator
  read Closure   closure used to read properties from an element
eventComboBoxModel

[EventComboBoxModel]
source EventList    
eventListModel

[EventListModel]
source EventList    
eventTableModel

[EventTableModel]
source EventList    
  format TableFormat    
eventTreeModel

[EventTreeModel]
source TreeList    
eventJXTableModel

[EventJXTableModel]
source EventList    
  format TableFormat    

The following methods become available as well

  • installTableComparatorChooser(Map args) - install a TableComparatorChooser on a target JTable
    Argument Type Default
    target JTable builder's current node
    source EventList  
    strategy Object AbstractTableComparatorChooser.SINGLE_COLUMN
  • installTTreeTableSupport(Map args) - install a TableComparatorChooser on a target JTable
    Argument Type Default
    target JTable builder's current node
    source TreeList  
    index int 1
  • installComboBoxAutoCompleteSupport(Map args) - install a TableComparatorChooser on a target JTable
    Argument Type Default
    target JComboBox builder's current node
    items EventList  
    textFilterator TextFilterator  
    format Format  

The following Model and View scripts shows a basic usage.

SampleModel.groovy
import ca.odell.glazedlists.EventList
import ca.odell.glazedlists.BasicEventList
import ca.odell.glazedlists.SortedList

class GModel {
    EventList persons = new SortedList( new BasicEventList(),
        {a, b -> a.name <=> b.name} as Comparator)

    GModel() {
        persons.addAll([
            [name: 'Adam',  lastName: 'Savage'],
            [name: 'Jamie', lastName: 'Hyneman'],
            [name: 'Kari',  lastName: 'Byron'],
            [name: 'Grant', lastName: 'Imahara'],
            [name: 'Tori',  lastName: 'Belleci'],
            [name: 'Buster',  lastName: ''],
        ])
    }
}
SampleView.groovy
import ca.odell.glazedlists.BasicEventList

application(title: 'GlazedLists',
  size:[300,300],
  locationByPlatform:true,
  iconImage: imageIcon('/griffon-icon-48x48.png').image,
  iconImages: [imageIcon('/griffon-icon-48x48.png').image,
               imageIcon('/griffon-icon-32x32.png').image,
               imageIcon('/griffon-icon-16x16.png').image]) {
    borderLayout()
    panel(constraints: NORTH) {
        gridLayout(cols: 1, rows: 2)
        comboBox {
            installComboBoxAutoCompleteSupport(items: new BasicEventList(model.persons*.name))
        }
        comboBox {
            installComboBoxAutoCompleteSupport(items: new BasicEventList(model.persons*.lastName))
        }
    }
    scrollPane(constraints: CENTER) {
        table(id: 'personsTable') {
            tableFormat = defaultTableFormat(columnNames: ['Name', 'LastName'])
            // tableFormat = defaultAdvancedTableFormat(columns: [[name:'Name'], [name: 'LastName']])
            eventTableModel(source: model.persons, format: tableFormat)
            installTableComparatorChooser(source: model.persons)
        }
    }
}

History

Version Date Notes
0.4 07-22-10 Release sync with Griffon 0.9
0.3 03-01-10 Upgraded to Griffon 0.3
0.2 12-26-09 fixed a bug in DefaultAdvancedTableFormat
0.1 12-16-09 first release