Griffon
  1. Griffon
  2. GRIFFON-253

WritableTableFormat and writable EventTreeModel support

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: plugins
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      3

      Description

      Features of the patch:

      • added installEventSelectionModel method to addon
      • added installJXTableSorting method to addon
      • fixed EventTreeModel support
      • added missing EventTreeModel.valueForPathChanged via embedded afterEdit-Closure
      • fixed and added WritableTableFormat
      • fixed bug in setColumnValue
      • added AdvancedTableFormat implementation to DefaultWritableTableFormat
      • adjusted format to be conform with AdvancedTableFormat

      Examples:

      WritableTableFormat:

          EventList persons = new SortedList(new BasicEventList(), {a, b -> a.name <=> b.name} as Comparator)
          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: ''],
          ])
      
          builder.edt {
            frame(id: 'test', title: 'Frame', size: [300, 300], show: true) {
              borderLayout()
              scrollPane {
                table(id: 'personsTable') {
                  tableFormat = defaultWritableTableFormat(columns: [
                          [name: 'Name',
                                  editable: { target, columns, index -> true },
                                  class: { columns, index -> String },
                                  comparator: { columns, index -> { a, b -> b <=> a } as Comparator }
                          ],
                          [name: 'LastName',
                                  editable: false,
                                  class: String,
                                  comparator: { a, b -> b <=> a } as Comparator
                          ]
                  ])
                  eventTableModel(source: persons, format: tableFormat)
                }
              }
            }
          }
      

      Writable EventTreeModel:

          EventList persons = new SortedList(new BasicEventList(), {a, b -> a.name <=> b.name} as Comparator)
          persons.addAll([
                  [group: 'Private', name: 'Adam Savage'],
                  [group: 'Private', name: 'Jamie Hyneman'],
                  [group: 'Private', name: 'Kari Byron'],
                  [group: 'Business', name: 'Grant Imahara'],
                  [group: 'Business', name: 'Tori Belleci'],
                  [group: 'Business', name: 'Buster'],
          ])
      
          def treeList = new TreeList(persons, [
                  allowsChildren: { element -> false },
                  getComparator: { depth -> { a, b -> a.bean[a.property] <=> b.bean[b.property] } as Comparator },
                  getPath: { List path, element ->
                    path << [bean: element, property: 'group']
                    path << [bean: element, property: 'name']
                  }
          ] as Format, new DefaultExternalExpansionModel())
      
          builder.edt {
            frame(id: 'test', title: 'Frame', size: [300, 300], show: true) {
              borderLayout()
              scrollPane() {
                def delRenderer = new DefaultTreeCellRenderer()
                def exampleTree = tree(id: 'exampleTree', rootVisible: false, editable: true, cellRenderer: [
                        getTreeCellRendererComponent: {tree, value, selected, expanded, leaf, row, focus ->
                          if (value instanceof TreeList.Node)
                            value = value.element.bean[value.element.property]
                          delRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focus)
                        }] as TreeCellRenderer) {
                  eventTreeModel(source: treeList) {
                    afterEdit { path, node, value ->
                      node.element.bean[node.element.property] = value
                    }
                  }
                }
                def delEditor = new MyEditor(exampleTree, delRenderer)
                exampleTree.setCellEditor(delEditor)
              }
            }
          }
      

        Activity

          People

          • Assignee:
            Andres Almiray
            Reporter:
            Alexander Klein
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: