JIDE 3.5.15

com.jidesoft.grid
Class TreeComboBoxCellEditor

java.lang.Object
  extended by javax.swing.AbstractCellEditor
      extended by com.jidesoft.grid.AbstractJideCellEditor
          extended by com.jidesoft.grid.ContextSensitiveCellEditor
              extended by com.jidesoft.grid.ExComboBoxCellEditor
                  extended by com.jidesoft.grid.TreeComboBoxCellEditor
All Implemented Interfaces:
ConverterContextSupport, EditorContextSupport, EditorStyleSupport, JideCellEditor, ActionListener, Serializable, EventListener, CellEditor, PopupMenuListener, TableCellEditor

public class TreeComboBoxCellEditor
extends ExComboBoxCellEditor

This class is for any cell editor where one needs to choose value from a tree. It used TreeExComboBox as the editor.

To let the TreeComboBoxCellEditor work well with a custom class other than String.class, please first register an ObjectConverter for that class and register a TreeComboBoxCellEditor for the class with the following code. While constructing the tree nodes, please make sure ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject() is an instance of the custom class.

      CellEditorManager.registerEditor(ConnectItem.class, new CellEditorFactory() {
          public CellEditor create() {
              return new TreeComboBoxCellEditor(getDefaultTreeModel()) {
                  protected TreeExComboBox createTreeComboBox() {
                      TreeExComboBox treeComboBox = new TreeExComboBox() {
                          protected TreeChooserPanel createTreeChooserPanel(TreeModel model) {
                              TreeChooserPanel panel = super.createTreeChooserPanel(model);
                              panel.setSearchUserObjectToSelect(true);
                              return panel;
                          }
                      };
                      treeComboBox.setEditable(false);
                      treeComboBox.setType(YourCustomClass.class);
                      return treeComboBox;
                  }
              };
          }
      }, new EditorContext("Tree"));
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.jidesoft.grid.ExComboBoxCellEditor
_comboBox
 
Fields inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
DEFAULT_CELL_EDITOR_BORDER
 
Fields inherited from class com.jidesoft.grid.AbstractJideCellEditor
_clickCountToStart
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Constructor Summary
TreeComboBoxCellEditor(Hashtable<?,?> objects)
          Creates a new TreeComboBoxCellEditor.
TreeComboBoxCellEditor(Object[] objects)
          Creates a new TreeComboBoxCellEditor.
TreeComboBoxCellEditor(TreeModel model)
          Creates a new TreeComboBoxCellEditor.
TreeComboBoxCellEditor(TreeNode root)
          Creates a new TreeComboBoxCellEditor.
TreeComboBoxCellEditor(TreeNode root, boolean asksAllowsChildren)
          Creates a new TreeComboBoxCellEditor.
TreeComboBoxCellEditor(Vector<?> objects)
          Creates a new TreeComboBoxCellEditor.
 
Method Summary
 ExComboBox createExComboBox()
          Creates an ExComboBox or its subclass used by this cell editor.
protected  TreeExComboBox createTreeComboBox()
          Creates the tree combobox.
 Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
           
 boolean isCellEditable(EventObject anEvent)
           
 boolean stopCellEditing()
           
 
Methods inherited from class com.jidesoft.grid.ExComboBoxCellEditor
actionPerformed, createExComboBox, customizeExComboBox, getCellEditorValue, getComboBox, isEditorStyleSupported, popupMenuCanceled, popupMenuWillBecomeInvisible, popupMenuWillBecomeVisible, setCellEditorValue, setConverter, setType
 
Methods inherited from class com.jidesoft.grid.ContextSensitiveCellEditor
getConverter, getConverterContext, getEditorContext, getEditorStyle, getType, isUseConverterContext, setConverterContext, setEditorContext, setEditorStyle, setUseConverterContext
 
Methods inherited from class com.jidesoft.grid.AbstractJideCellEditor
addValidationListener, getClickCountToStart, getDefaultErrorBehavior, getValidationListeners, isAutoStopCellEditing, isPassEnterKeyToTable, removeValidationListener, setAutoStopCellEditing, setClickCountToStart, setDefaultErrorBehavior, setPassEnterKeyToTable, validate
 
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener, shouldSelectCell
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, removeCellEditorListener, shouldSelectCell
 

Constructor Detail

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(Object[] objects)
Creates a new TreeComboBoxCellEditor.

Parameters:
objects - the objects in the tree model

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(Vector<?> objects)
Creates a new TreeComboBoxCellEditor.

Parameters:
objects - the objects in the tree model

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(Hashtable<?,?> objects)
Creates a new TreeComboBoxCellEditor.

Parameters:
objects - the objects in the tree model

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(TreeNode root)
Creates a new TreeComboBoxCellEditor.

Parameters:
root - the tree root node

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(TreeNode root,
                              boolean asksAllowsChildren)
Creates a new TreeComboBoxCellEditor.

Parameters:
root - the tree root node
asksAllowsChildren - the flag indicating if allows children

TreeComboBoxCellEditor

public TreeComboBoxCellEditor(TreeModel model)
Creates a new TreeComboBoxCellEditor.

Parameters:
model - the tree model
Method Detail

isCellEditable

public boolean isCellEditable(EventObject anEvent)
Specified by:
isCellEditable in interface CellEditor
Overrides:
isCellEditable in class AbstractJideCellEditor

getTableCellEditorComponent

public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column)
Specified by:
getTableCellEditorComponent in interface TableCellEditor
Overrides:
getTableCellEditorComponent in class ExComboBoxCellEditor

stopCellEditing

public boolean stopCellEditing()
Specified by:
stopCellEditing in interface CellEditor
Overrides:
stopCellEditing in class ExComboBoxCellEditor

createExComboBox

public ExComboBox createExComboBox()
Description copied from class: ExComboBoxCellEditor
Creates an ExComboBox or its subclass used by this cell editor.

Specified by:
createExComboBox in class ExComboBoxCellEditor
Returns:
an ExComboBox.

createTreeComboBox

protected TreeExComboBox createTreeComboBox()
Creates the tree combobox.

Returns:
the tree combobox.

JIDE 3.5.15