org.annotation.wordfreak.chooser
Class EntityTreeCellEditor

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.annotation.wordfreak.chooser.EntityTreeNode
                      extended byorg.annotation.wordfreak.chooser.EntityTreeCellEditor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, javax.swing.CellEditor, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable, javax.swing.tree.TreeCellEditor, javax.swing.event.TreeSelectionListener

public class EntityTreeCellEditor
extends EntityTreeNode
implements java.awt.event.MouseListener, java.awt.event.ActionListener, javax.swing.tree.TreeCellEditor, javax.swing.event.TreeSelectionListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  boolean canEdit
           
protected  javax.swing.event.ChangeEvent changeEvent
          the event to fire
protected  javax.swing.Icon collapsedIcon
          the icon for collapsed nodes
protected  java.awt.Color colSelBg
          the differnet colors
protected  java.awt.Color colSelFg
          the differnet colors
protected  javax.swing.tree.TreeCellEditor defaultEditor
          the default editor used, if the node isn't a MyCheckMutableTreeNode
protected  javax.swing.tree.DefaultTreeCellRenderer defaultRenderer
           
protected  java.lang.Object editingValue
          saves the actual editing value
protected  EntityTreeCellRenderer entityRenderer
           
protected  javax.swing.Icon expandedIcon
          the icon for expanded nodes
protected  boolean isCheckBox
          defines if a checkbox is used
protected  boolean isDefaultEditorUsed
          flag defines, if the default editor is used or this one
protected  javax.swing.tree.TreePath lastPath
          last path that was selected.
protected  int lastRow
          Row that was last passed into getTreeCellEditorComponent.
protected  javax.swing.Icon leafIcon
          the icon for leafs
protected  javax.swing.event.EventListenerList listenerList
          Event listeners
protected  javax.swing.border.Border normBorder
          the borders for focus
protected  int offset
          Used in editing.
protected  java.lang.Object oldRealValue
          saves the old user object to return
protected  javax.swing.border.Border selBorder
          the borders for focus
protected  javax.swing.Timer timer
          Used before starting the editing session.
protected  javax.swing.JTree tree
          JTree instance listening too.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
EntityTreeCellEditor(javax.swing.JTree tree)
          The constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Messaged when the timer fires, this will start the editing session.
 void addCellEditorListener(javax.swing.event.CellEditorListener l)
          Add a listener to the list that's notified when the editor starts, stops, or cancels editing.
 void cancelCellEditing()
          Tell the editor to cancel editing and not accept any partially edited value.
protected  boolean canEditImmediately(java.util.EventObject event)
          Returns true if event is null, or it is a MouseEvent with a click count > 2.
protected  void fireEditingCanceled()
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireEditingStopped()
          Notify all listeners that have registered interest for notification on this event type.
 java.lang.Object getCellEditorValue()
          Returns the value contained in the editor
 javax.swing.Icon getCollapsedIcon()
           
 javax.swing.Icon getExpandedIcon()
           
 javax.swing.Icon getLeafIcon()
           
 java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree, java.lang.Object value, boolean isSelected, boolean expanded, boolean leaf, int row)
          Configures the editor.
protected  boolean inHitRegion(int x, int y)
          Returns true if x is inside the text region of the renderer, not the icon part.
 boolean isCellEditable(java.util.EventObject anEvent)
          Ask the editor if it can start editing using anEvent.
 void mouseClicked(java.awt.event.MouseEvent me)
          From mouse listener, not used yet
 void mouseEntered(java.awt.event.MouseEvent me)
          From mouse listener, not used
 void mouseExited(java.awt.event.MouseEvent me)
          From mouse listener, not used
 void mousePressed(java.awt.event.MouseEvent me)
          From mouse listener, not used
 void mouseReleased(java.awt.event.MouseEvent me)
          From mouse listener, not used
 void removeCellEditorListener(javax.swing.event.CellEditorListener l)
          Remove a listener from the list that's notified
 void setCollapsedIcon(javax.swing.Icon icon)
          Method to set the collapsed icon (for next use) It is not updated by changed LnF
 void setExpandedIcon(javax.swing.Icon icon)
          Method to set the expanded icon (for next use) It is not updated by changed LnF
 void setLeafIcon(javax.swing.Icon icon)
          Method to set the leaf icon (for next use) It is not updated by changed LnF
protected  void setTree(javax.swing.JTree newTree)
          Sets the tree currently editing for.
 boolean shouldSelectCell(java.util.EventObject anEvent)
          The return value of shouldSelectCell() is a boolean indicating whether the editing cell should be selected or not.
protected  boolean shouldStartEditingTimer(java.util.EventObject event)
          Returns true if event is a MouseEvent and the click count is 1.
protected  void startEditingTimer()
          Starts the editing timer.
 boolean stopCellEditing()
          Tell the editor to stop editing and accept any partially edited value as the value of the editor.
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          Resets lastPath.
 
Methods inherited from class org.annotation.wordfreak.chooser.EntityTreeNode
add, add, addActionListener, getCodes, getDivider, getEntities, getID, getText, isActionClick, isSelected, main, remove, setDisplay, setDivider, setEntities, setForeground, setID, setSelected, updateText
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList
Event listeners


changeEvent

protected transient javax.swing.event.ChangeEvent changeEvent
the event to fire


timer

protected transient javax.swing.Timer timer
Used before starting the editing session.


canEdit

protected boolean canEdit

lastPath

protected transient javax.swing.tree.TreePath lastPath
last path that was selected.


offset

protected transient int offset
Used in editing. Indicates x position to place editingComponent.


lastRow

protected transient int lastRow
Row that was last passed into getTreeCellEditorComponent.


defaultEditor

protected javax.swing.tree.TreeCellEditor defaultEditor
the default editor used, if the node isn't a MyCheckMutableTreeNode


isDefaultEditorUsed

protected boolean isDefaultEditorUsed
flag defines, if the default editor is used or this one


tree

protected transient javax.swing.JTree tree
JTree instance listening too.


isCheckBox

protected boolean isCheckBox
defines if a checkbox is used


oldRealValue

protected java.lang.Object oldRealValue
saves the old user object to return


editingValue

protected java.lang.Object editingValue
saves the actual editing value


expandedIcon

protected javax.swing.Icon expandedIcon
the icon for expanded nodes


collapsedIcon

protected javax.swing.Icon collapsedIcon
the icon for collapsed nodes


leafIcon

protected javax.swing.Icon leafIcon
the icon for leafs


selBorder

protected javax.swing.border.Border selBorder
the borders for focus


normBorder

protected javax.swing.border.Border normBorder
the borders for focus


colSelFg

protected java.awt.Color colSelFg
the differnet colors


colSelBg

protected java.awt.Color colSelBg
the differnet colors


entityRenderer

protected EntityTreeCellRenderer entityRenderer

defaultRenderer

protected javax.swing.tree.DefaultTreeCellRenderer defaultRenderer
Constructor Detail

EntityTreeCellEditor

public EntityTreeCellEditor(javax.swing.JTree tree)
The constructor. Creates the default editor and initializes all values.

Parameters:
tree - is the tree listenening too
Method Detail

getTreeCellEditorComponent

public java.awt.Component getTreeCellEditorComponent(javax.swing.JTree tree,
                                                     java.lang.Object value,
                                                     boolean isSelected,
                                                     boolean expanded,
                                                     boolean leaf,
                                                     int row)
Configures the editor. Returns the editor component (the checkbox) within an container looking like the tree node itself

Specified by:
getTreeCellEditorComponent in interface javax.swing.tree.TreeCellEditor
Parameters:
tree - the JTree that is asking the editor to edit This parameter can be null.
value - the value of the cell to be edited.
isSelected - true is the cell is to be renderer with selection highlighting
expanded - true if the node is expanded
leaf - true if the node is a leaf node
row - the row index of the node being edited
Returns:
the component for editing

getCellEditorValue

public java.lang.Object getCellEditorValue()
Returns the value contained in the editor

Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
is that value

isCellEditable

public boolean isCellEditable(java.util.EventObject anEvent)
Ask the editor if it can start editing using anEvent.

Specified by:
isCellEditable in interface javax.swing.CellEditor
Parameters:
anEvent - the event the editor should use to consider whether to begin editing or not.
Returns:
true if editing can be started.
See Also:
shouldSelectCell(java.util.EventObject)

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject anEvent)
The return value of shouldSelectCell() is a boolean indicating whether the editing cell should be selected or not. The default is that this method returns true;

Specified by:
shouldSelectCell in interface javax.swing.CellEditor
Parameters:
anEvent - the event the editor should use to start editing.
Returns:
true if the editor would like the editing cell to be selected
See Also:
isCellEditable(java.util.EventObject)

stopCellEditing

public boolean stopCellEditing()
Tell the editor to stop editing and accept any partially edited value as the value of the editor. The editor returns false if editing was not stopped, useful for editors which validates and can not accept invalid entries.

Specified by:
stopCellEditing in interface javax.swing.CellEditor
Returns:
true if editing was stopped

cancelCellEditing

public void cancelCellEditing()
Tell the editor to cancel editing and not accept any partially edited value.

Specified by:
cancelCellEditing in interface javax.swing.CellEditor

addCellEditorListener

public void addCellEditorListener(javax.swing.event.CellEditorListener l)
Add a listener to the list that's notified when the editor starts, stops, or cancels editing.

Specified by:
addCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the CellEditorListener

removeCellEditorListener

public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
Remove a listener from the list that's notified

Specified by:
removeCellEditorListener in interface javax.swing.CellEditor
Parameters:
l - the CellEditorListener

fireEditingStopped

protected void fireEditingStopped()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

fireEditingCanceled

protected void fireEditingCanceled()
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)
Resets lastPath.

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener

startEditingTimer

protected void startEditingTimer()
Starts the editing timer.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Messaged when the timer fires, this will start the editing session.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

shouldStartEditingTimer

protected boolean shouldStartEditingTimer(java.util.EventObject event)
Returns true if event is a MouseEvent and the click count is 1.


inHitRegion

protected boolean inHitRegion(int x,
                              int y)
Returns true if x is inside the text region of the renderer, not the icon part.


canEditImmediately

protected boolean canEditImmediately(java.util.EventObject event)
Returns true if event is null, or it is a MouseEvent with a click count > 2.


setTree

protected void setTree(javax.swing.JTree newTree)
Sets the tree currently editing for. This is needed to add a selection listener.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
From mouse listener, not used yet

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
From mouse listener, not used

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
From mouse listener, not used

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
From mouse listener, not used

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
From mouse listener, not used

Specified by:
mouseExited in interface java.awt.event.MouseListener

getLeafIcon

public javax.swing.Icon getLeafIcon()
Returns:
is the used leaf icon

setLeafIcon

public void setLeafIcon(javax.swing.Icon icon)
Method to set the leaf icon (for next use) It is not updated by changed LnF

Parameters:
icon - is the new icon used for leaf

getExpandedIcon

public javax.swing.Icon getExpandedIcon()
Returns:
is the used icon for expanded nodes

setExpandedIcon

public void setExpandedIcon(javax.swing.Icon icon)
Method to set the expanded icon (for next use) It is not updated by changed LnF

Parameters:
icon - is the new icon used for expanded nodes

getCollapsedIcon

public javax.swing.Icon getCollapsedIcon()
Returns:
is the used icon for collapsed nodes

setCollapsedIcon

public void setCollapsedIcon(javax.swing.Icon icon)
Method to set the collapsed icon (for next use) It is not updated by changed LnF

Parameters:
icon - is the new icon used for collapsed nodes


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.