Package: groovy.swing.impl

## [Groovy] Class ClosureCellEditor

- groovy.swing.impl.ClosureCellEditor

- All Implemented Interfaces and Traits:
    TableCellEditor, TreeCellEditor

      class ClosureCellEditor
      extends AbstractCellEditor
      implements TableCellEditor, TreeCellEditor

  Cell editor implementation backed by builder closures for tables and trees.

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `Map<String, Closure>` | `callbacks` Optional callback closures invoked by invokeMethod(String, Object).
    `List` | `children` Child components made available to editor closures.
    `int` | `column` Table column currently being edited, or `-1` for tree editing.
    `boolean` | `defaultEditor` Indicates whether the default Swing editor should be used as the backing child component.
    `Closure` | `editorValue` Closure used to extract the current editor value.
    `boolean` | `expanded` Whether the edited tree node is expanded.
    `boolean` | `leaf` Whether the edited tree node is a leaf.
    `Closure` | `prepareEditor` Closure used to create or customize the editor component.
    `int` | `row` Row currently being edited.
    `boolean` | `selected` Whether the edited row is selected.
    `JTable` | `table` Table currently being edited, or `null` for tree editing.
    `JTree` | `tree` Tree currently being edited, or `null` for table editing.
    `Object` | `value` Value currently being edited.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ClosureCellEditor(Closure c, Map<String, Closure> callbacks)` Creates a closure-backed cell editor.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Object` | `getCellEditorValue()` Returns the value supplied by the configured editor value closure.
    `` | `Component` | `getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)` Prepares the editor context for table editing and returns the editor component.
    `` | `Component` | `getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)` Prepares the editor context for tree editing and returns the editor component.
    `` | `Object` | `invokeMethod(String name, Object args)` Dispatches method invocations to registered callbacks before falling back to the normal meta-class lookup.
    `` | `void` | `setEditorValue(Closure editorValue)` Sets the closure used to extract the editor value.
    `` | `void` | `setPrepareEditor(Closure prepareEditor)` Sets the closure used to prepare the editor component.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractCellEditor` | `addCellEditorListener, cancelCellEditing, equals, getCellEditorListeners, getCellEditorValue, getClass, hashCode, isCellEditable, notify, notifyAll, removeCellEditorListener, shouldSelectCell, stopCellEditing, toString, wait, wait, wait`

- - ### Property Detail

    - #### Map<String, Closure> callbacks

      Optional callback closures invoked by invokeMethod(String, Object).

    - #### List children

      Child components made available to editor closures.

    - #### int column

      Table column currently being edited, or `-1` for tree editing.

    - #### boolean defaultEditor

      Indicates whether the default Swing editor should be used as the backing child component.

    - #### Closure editorValue

      Closure used to extract the current editor value.

    - #### boolean expanded

      Whether the edited tree node is expanded.

    - #### boolean leaf

      Whether the edited tree node is a leaf.

    - #### Closure prepareEditor

      Closure used to create or customize the editor component.

    - #### int row

      Row currently being edited.

    - #### boolean selected

      Whether the edited row is selected.

    - #### JTable table

      Table currently being edited, or `null` for tree editing.

    - #### JTree tree

      Tree currently being edited, or `null` for table editing.

    - #### Object value

      Value currently being edited.

  - ### Constructor Detail

    - #### ClosureCellEditor(Closure c, Map<String, Closure> callbacks)

      Creates a closure-backed cell editor.

      Parameters:
        `c` - closure used to produce the editor value
        `callbacks` - optional method callback overrides

  - ### Method Detail

    - #### @Override
      Object getCellEditorValue()

      Returns the value supplied by the configured editor value closure.

      Returns:
        the edited value

    - #### @Override
      Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)

      Prepares the editor context for table editing and returns the editor component.

      Parameters:
        `table` - the table requesting the editor
        `value` - the cell value being edited
        `isSelected` - whether the row is selected
        `row` - the view row index
        `column` - the view column index
      Returns:
        the component used to edit the table cell

    - #### Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)

      Prepares the editor context for tree editing and returns the editor component.

      Parameters:
        `tree` - the tree requesting the editor
        `value` - the node value being edited
        `isSelected` - whether the node is selected
        `expanded` - whether the node is expanded
        `leaf` - whether the node is a leaf
        `row` - the visible row index
      Returns:
        the component used to edit the tree node

    - #### @Override
      Object invokeMethod(String name, Object args)

      Dispatches method invocations to registered callbacks before falling back to the normal meta-class lookup.

      Parameters:
        `name` - the invoked method name
        `args` - the invocation arguments
      Returns:
        the callback result or the invoked method result

    - #### void setEditorValue(Closure editorValue)

      Sets the closure used to extract the editor value.

      The closure delegates to this editor with Closure.DELEGATE_FIRST resolution.

      Parameters:
        `editorValue` - the value-producing closure

    - #### void setPrepareEditor(Closure prepareEditor)

      Sets the closure used to prepare the editor component.

      The closure delegates to this editor with Closure.DELEGATE_FIRST resolution.

      Parameters:
        `prepareEditor` - the preparation closure