Package org.web3d.x3d.dom.swing
Class DOMTreeCellEditor
java.lang.Object
org.web3d.x3d.dom.swing.DOMTreeCellEditor
- All Implemented Interfaces:
KeyListener
,EventListener
,CellEditor
,TreeCellEditor
An implementation of the TreeCellRenderer interface to provided a renderer
for DOM specific capabilities.
This cell renderer is very simple - it just displays a label with the text
name of the node type and any relevant information about it. It knows nothing
about X3D. If you want an X3D specific tree cell renderer, use the
DOMTreeCellRenderer
- Version:
- $Revision: 1.4 $
- Author:
- Justin Couch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a cell editor listener.void
Request the cell editor to cancel the current editing action.Get the value of the last edited cell component.getTreeCellEditorComponent
(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) Request the renderer that suits the given value type and for the given tree.boolean
Check to see if a cell is editable.void
keyPressed
(KeyEvent evt) Process a key pressed event.void
keyReleased
(KeyEvent evt) Process a key released event.void
Process a key event on the textfield.void
Remove a cell editor listener.boolean
Query to check if the cell should be selected when it is going to be edited.boolean
Instruction to stop editing this cell.
-
Constructor Details
-
DOMTreeCellEditor
public DOMTreeCellEditor()Create an instance of the tree cell editor.
-
-
Method Details
-
getTreeCellEditorComponent
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row) Request the renderer that suits the given value type and for the given tree.- Specified by:
getTreeCellEditorComponent
in interfaceTreeCellEditor
- Parameters:
tree
- The source tree this node comes fromvalue
- The DOMTreeNode to be renderedselected
- True if the node is selectedexpanded
- True if expandedleaf
- True if this is a leaf noderow
- The row this node is on
-
cancelCellEditing
public void cancelCellEditing()Request the cell editor to cancel the current editing action. This is ignored by this implementation.- Specified by:
cancelCellEditing
in interfaceCellEditor
-
getCellEditorValue
Get the value of the last edited cell component. Returns a string representation of the value.- Specified by:
getCellEditorValue
in interfaceCellEditor
- Returns:
- A string representing the value
-
isCellEditable
Check to see if a cell is editable. We have to go through some hoops here because we don't want all the cells to be editable. In particular, only those that match the ones in the getComponent method above.- Specified by:
isCellEditable
in interfaceCellEditor
- Parameters:
evt
- The mouse event that caused this method to be called
-
shouldSelectCell
Query to check if the cell should be selected when it is going to be edited. All cells can be selected- Specified by:
shouldSelectCell
in interfaceCellEditor
- Parameters:
evt
- The mouse event selecting the cell- Returns:
- true;
-
stopCellEditing
public boolean stopCellEditing()Instruction to stop editing this cell. Ignored by this implementation.- Specified by:
stopCellEditing
in interfaceCellEditor
- Returns:
- true
-
addCellEditorListener
Add a cell editor listener. A listener instance can only be registered once.- Specified by:
addCellEditorListener
in interfaceCellEditor
- Parameters:
l
- The listener to add.
-
removeCellEditorListener
Remove a cell editor listener. If the listener is not registered this does nothing.- Specified by:
removeCellEditorListener
in interfaceCellEditor
- Parameters:
l
- The listener to remove
-
keyTyped
Process a key event on the textfield. For this implementation we are looking for either VK_ENTER or VK_ESCAPE to finish or cancel the editing respectively.- Specified by:
keyTyped
in interfaceKeyListener
- Parameters:
evt
- The event to be processed.
-
keyPressed
Process a key pressed event.- Specified by:
keyPressed
in interfaceKeyListener
- Parameters:
evt
-
-
keyReleased
Process a key released event.- Specified by:
keyReleased
in interfaceKeyListener
- Parameters:
evt
-
-