Xj3D 2.0 VRML/X3D Code API

org.web3d.x3d.dom.swing
Class DOMTreeCellEditor

java.lang.Object
  extended by org.web3d.x3d.dom.swing.DOMTreeCellEditor
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener, javax.swing.CellEditor, javax.swing.tree.TreeCellEditor

public class DOMTreeCellEditor
extends java.lang.Object
implements javax.swing.tree.TreeCellEditor, java.awt.event.KeyListener

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 relvant 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
DOMTreeCellEditor()
          Create an instance of the tree cell editor.
 
Method Summary
 void addCellEditorListener(javax.swing.event.CellEditorListener l)
          Add a cell editor listener.
 void cancelCellEditing()
          Request the cell editor to cancel the current editing action.
 java.lang.Object getCellEditorValue()
          Get the value of the last edited cell component.
 java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree, java.lang.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 isCellEditable(java.util.EventObject evt)
          Check to see if a cell is editable.
 void keyPressed(java.awt.event.KeyEvent evt)
          Process a key pressed event.
 void keyReleased(java.awt.event.KeyEvent evt)
          Process a key released event.
 void keyTyped(java.awt.event.KeyEvent evt)
          Process a key event on the textfield.
 void removeCellEditorListener(javax.swing.event.CellEditorListener l)
          Remove a cell editor listener.
 boolean shouldSelectCell(java.util.EventObject evt)
          Query to check if the cell should be selected when it is going to be edited.
 boolean stopCellEditing()
          Instruction to stop editing this cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOMTreeCellEditor

public DOMTreeCellEditor()
Create an instance of the tree cell editor.

Method Detail

getTreeCellEditorComponent

public java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree,
                                                     java.lang.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 interface javax.swing.tree.TreeCellEditor
Parameters:
tree - The source tree this node comes from
value - The DOMTreeNode to be rendered
selected - True if the node is selected
expanded - True if expanded
leaf - True if this is a leaf node
row - 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 interface javax.swing.CellEditor

getCellEditorValue

public java.lang.Object getCellEditorValue()
Get the value of the last edited cell component. Returns a string representation of the value.

Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
A string representing the value

isCellEditable

public boolean isCellEditable(java.util.EventObject evt)
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 interface javax.swing.CellEditor
Parameters:
evt - The mouse event that caused this method to be called

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject evt)
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 interface javax.swing.CellEditor
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 interface javax.swing.CellEditor
Returns:
true

addCellEditorListener

public void addCellEditorListener(javax.swing.event.CellEditorListener l)
Add a cell editor listener. A listener instance can only be registered once.

Specified by:
addCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - The listener to add.

removeCellEditorListener

public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
Remove a cell editor listener. If the listener is not registered this does nothing.

Specified by:
removeCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - The listener to remove

keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
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 interface java.awt.event.KeyListener
Parameters:
evt - The event to be processed.

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Process a key pressed event.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Process a key released event.

Specified by:
keyReleased in interface java.awt.event.KeyListener

Xj3D 2.0 VRML/X3D Code API

Copyright © 2001 - 2006 Web3D Consortium