Holger's Java API

## com.antelmann.util.table
Class AbstractDialogCellEditor<T>

    java.lang.Object
      javax.swing.AbstractCellEditor
          javax.swing.DefaultCellEditor
              com.antelmann.util.table.AbstractDialogCellEditor<T>

All Implemented Interfaces:
  ValueRetriever<T>, ValueSetter<T>, Serializable, CellEditor, TableCellEditor, TreeCellEditor

Direct Known Subclasses:
  ColorDialogCellEditor, DateDialogCellEditor, FormDialogCellEditor, TextDialogCellEditor

    public abstract class AbstractDialogCellEditor<T>

extends DefaultCellEditor
implements ValueRetriever<T>, ValueSetter<T>

provides an editor that always shows a dialog for editing the value. To extend this class, the interfaces `ValueRetriever` and `ValueSetter` must be implemented. The ValueRetriever is responsible to provide value after editing and the ValueSetter is responsible to set the current value for the dialog component from the table before editing starts. Note that any Exceptions that are thrown by the ValueSetter are simply wrapped as RuntimeExceptions and then thrown.

Since:
  21. August 2007, 23:14
Author:
  Holger Antelmann
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor
`DefaultCellEditor.EditorDelegate`

Field Summary
`protected int` `column` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected String` `columnName`
`protected JComponent` `dialogComponent`
`protected String` `dialogTitle`
`protected boolean` `expanded` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected boolean` `isSelected` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected boolean` `leaf` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected int` `row` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected JTable` `table` cached from the last call to the method that provides the component, so that it's available for the VaueSetter
`protected JTree` `tree` cached from the last call to the method that provides the component, so that it's available for the VaueSetter

Fields inherited from class javax.swing.DefaultCellEditor
`clickCountToStart, delegate, editorComponent`

Fields inherited from class javax.swing.AbstractCellEditor
`changeEvent, listenerList`

Constructor Summary
`AbstractDialogCellEditor(JComponent dialogComponent)`
`AbstractDialogCellEditor(JComponent dialogComponent, String dialogTitle)`
`AbstractDialogCellEditor(JComponent dialogComponent, String dialogTitle, boolean resizable)` initializes this instance with a component to be shown in the dialog and a title.

Method Summary
`Object` `getCellEditorValue()`
`protected JComponent` `getDialogComponent()` override this to create a component on each call based on the cached member variables instead of simply returning the component provided in the constructor
`protected Component` `getRelevantComponent(Object value)` called by the methods providing the components for JTable and JTree to share the functionality
`Component` `getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)` caches all parameters in member variables and then calls `getRelevantComponent(Object)`
`Component` `getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row)` caches all parameters in member variables and then calls `getRelevantComponent(Object)`
`boolean` `isCellEditable(EventObject ev)`
`boolean` `isResizable()`
`void` `setResizable(boolean resizable)`
`protected int` `showDialog(JComponent parent)` shows the dialog and returns the value from the method `JOptionPane.showConfirmDialog(Component, Object)`
`protected void` `valueChanged()`

Methods inherited from class javax.swing.DefaultCellEditor
`cancelCellEditing, getClickCountToStart, getComponent, setClickCountToStart, shouldSelectCell, stopCellEditing`

Methods inherited from class javax.swing.AbstractCellEditor
`addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.antelmann.util.ValueRetriever
`getRelevantValue`

Methods inherited from interface com.antelmann.util.ValueSetter
`setRelevantValue`

Methods inherited from interface javax.swing.CellEditor
`addCellEditorListener, removeCellEditorListener`

Field Detail

### dialogTitle

    protected String dialogTitle

### dialogComponent

    protected JComponent dialogComponent

### columnName

    protected String columnName

### tree

    protected JTree tree

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### table

    protected JTable table

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### column

    protected int column

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### row

    protected int row

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### isSelected

    protected boolean isSelected

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### expanded

    protected boolean expanded

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

### leaf

    protected boolean leaf

  cached from the last call to the method that provides the component, so that it's available for the VaueSetter

Constructor Detail

### AbstractDialogCellEditor

    public AbstractDialogCellEditor(JComponent dialogComponent)

See Also:
  `AbstractDialogCellEditor(JComponent, String, boolean)`

### AbstractDialogCellEditor

    public AbstractDialogCellEditor(JComponent dialogComponent,
                                    String dialogTitle)

See Also:
  `AbstractDialogCellEditor(JComponent, String, boolean)`

### AbstractDialogCellEditor

    public AbstractDialogCellEditor(JComponent dialogComponent,
                                    String dialogTitle,
                                    boolean resizable)

  initializes this instance with a component to be shown in the dialog and a title. An `AncestorListener` will be added to the dialogComponent to ensure that the component will receive the focus when the dialog is shown.

  Parameters:
    `dialogComponent` - the component to be shown in the dialog
    `dialogTitle` - if null, the column name is automatically used in when a JTable is used; for JTree, this value really should be set, however!
    `resizable` - if true, the dialog shown is resizable

Method Detail

### isResizable

    public boolean isResizable()

### setResizable

    public void setResizable(boolean resizable)

### getDialogComponent

    protected JComponent getDialogComponent()

  override this to create a component on each call based on the cached member variables instead of simply returning the component provided in the constructor

### showDialog

    protected int showDialog(JComponent parent)

  shows the dialog and returns the value from the method `JOptionPane.showConfirmDialog(Component, Object)`

  See Also:
    `JOptionPane.showConfirmDialog(Component, Object)`

### getCellEditorValue

    public Object getCellEditorValue()

  Specified by:
    `getCellEditorValue` in interface `CellEditor`
  Overrides:
    `getCellEditorValue` in class `DefaultCellEditor`

### isCellEditable

    public boolean isCellEditable(EventObject ev)

  Specified by:
    `isCellEditable` in interface `CellEditor`
  Overrides:
    `isCellEditable` in class `DefaultCellEditor`

### getRelevantComponent

    protected Component getRelevantComponent(Object value)

  called by the methods providing the components for JTable and JTree to share the functionality

### valueChanged

    protected void valueChanged()

### getTableCellEditorComponent

    public Component getTableCellEditorComponent(JTable table,
                                                 Object value,
                                                 boolean isSelected,
                                                 int row,
                                                 int column)

  caches all parameters in member variables and then calls `getRelevantComponent(Object)`

  Specified by:
    `getTableCellEditorComponent` in interface `TableCellEditor`
  Overrides:
    `getTableCellEditorComponent` in class `DefaultCellEditor`

### getTreeCellEditorComponent

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

  caches all parameters in member variables and then calls `getRelevantComponent(Object)`

  Specified by:
    `getTreeCellEditorComponent` in interface `TreeCellEditor`
  Overrides:
    `getTreeCellEditorComponent` in class `DefaultCellEditor`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads