sos.reports
Class DefaultElementEditor

java.lang.Object
  |
  +--javax.swing.AbstractCellEditor
        |
        +--sos.reports.DefaultElementEditor
All Implemented Interfaces:
javax.swing.CellEditor, ElementEditor, java.io.Serializable

public class DefaultElementEditor
extends javax.swing.AbstractCellEditor
implements ElementEditor

An element editor that can adapt a JComboBox, JTextField, or a JCheckBox to be an editor.

Since:
1.0

Field Summary
 
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
 
Fields inherited from interface sos.reports.ElementEditor
POSITIONED
 
Constructor Summary
DefaultElementEditor(javax.swing.JCheckBox checkBox)
          Creates an instance of DefaultElementEditor that uses the specified checkbox as the editor component.
DefaultElementEditor(javax.swing.JComboBox comboBox)
          Creates an instance of DefaultElementEditor that uses the specified combobox as the editor component.
DefaultElementEditor(javax.swing.JTextField textField)
          Creates an instance of DefaultElementEditor that uses the specified text field as the editor component.
 
Method Summary
 void cancelCellEditing()
          Tells this editor to cancel editing and not accept any partially edited value.
 java.lang.Object getCellEditorValue()
          Returns the value contained in the editor.
 int getClickCountToStart()
          Returns the number of clicks needed to start editing.
 java.awt.Component getElementEditorComponent(JReportPane reportPane, Element element)
          Returns the component that should be added to the client's component hierarchy in order to edit the specified element in the specified report pane.
 java.awt.Component getMouseOverComponent(JReportPane reportPane, Element element)
          Returns a component (or null, if none) that provides a hint or shortcut to editing the specified element in the specified report pane.
 boolean isCellEditable(java.util.EventObject anEvent)
          Asks this editor if it can start editing using anEvent.
 boolean isMouseOverEnabled()
          Returns true if this editor shows mouse-over hints.
 void setClickCountToStart(int count)
          Specifies the number of clicks needed to start editing.
 void setMouseOverEnabled(boolean mouseOverEnabled)
          Sets whether or not this editor shows mouse-over hints.
 boolean shouldSelectCell(java.util.EventObject anEvent)
          Returns true if the editing cell should be selected, false otherwise.
 boolean stopCellEditing()
          Tells this editor to stop editing and accept any partially edited value as the value of the editor.
 
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 javax.swing.CellEditor
addCellEditorListener, removeCellEditorListener
 

Constructor Detail

DefaultElementEditor

public DefaultElementEditor(javax.swing.JComboBox comboBox)
Creates an instance of DefaultElementEditor that uses the specified combobox as the editor component.

Parameters:
comboBox - the editor component

DefaultElementEditor

public DefaultElementEditor(javax.swing.JTextField textField)
Creates an instance of DefaultElementEditor that uses the specified text field as the editor component.

Parameters:
textField - the editor component

DefaultElementEditor

public DefaultElementEditor(javax.swing.JCheckBox checkBox)
Creates an instance of DefaultElementEditor that uses the specified checkbox as the editor component.

Parameters:
checkBox - the editor component
Method Detail

cancelCellEditing

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

Specified by:
cancelCellEditing in interface javax.swing.CellEditor
Overrides:
cancelCellEditing in class javax.swing.AbstractCellEditor

getCellEditorValue

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

Specified by:
getCellEditorValue in interface javax.swing.CellEditor
Returns:
the value contained in the editor

getClickCountToStart

public int getClickCountToStart()
Returns the number of clicks needed to start editing.

Returns:
the number of clicks needed to start editing
See Also:
setClickCountToStart(int)

getMouseOverComponent

public java.awt.Component getMouseOverComponent(JReportPane reportPane,
                                                Element element)
Description copied from interface: ElementEditor
Returns a component (or null, if none) that provides a hint or shortcut to editing the specified element in the specified report pane. This component is installed in the report pane when the mouse is over the element.

Specified by:
getMouseOverComponent in interface ElementEditor
Parameters:
reportPane - report pane that is rendering element
element - the element for which the mouse-over component is requested
Returns:
a component that provides a mouse-over hint or shortcut for element

getElementEditorComponent

public java.awt.Component getElementEditorComponent(JReportPane reportPane,
                                                    Element element)
Description copied from interface: ElementEditor
Returns the component that should be added to the client's component hierarchy in order to edit the specified element in the specified report pane.

Specified by:
getElementEditorComponent in interface ElementEditor
Parameters:
reportPane - report pane that is rendering element
element - the element for which the editor component is requested
Returns:
the component for editing

isCellEditable

public boolean isCellEditable(java.util.EventObject anEvent)
Asks this editor if it can start editing using anEvent. anEvent is in the invoking component coordinate system. If editing can be started this method returns true.

Specified by:
isCellEditable in interface javax.swing.CellEditor
Overrides:
isCellEditable in class javax.swing.AbstractCellEditor
Parameters:
anEvent - the event the editor should use to consider whether to begin editing or not
Returns:
true if editing can be started

isMouseOverEnabled

public boolean isMouseOverEnabled()
Returns true if this editor shows mouse-over hints.

Returns:
whether or not mouse-over hints are enabled
See Also:
setMouseOverEnabled(boolean)

setMouseOverEnabled

public void setMouseOverEnabled(boolean mouseOverEnabled)
Sets whether or not this editor shows mouse-over hints.

Parameters:
mouseOverEnabled - true if this editor should show mouse-over hints
See Also:
isMouseOverEnabled()

setClickCountToStart

public void setClickCountToStart(int count)
Specifies the number of clicks needed to start editing.

Parameters:
count - the number of clicks needed to start editing
See Also:
getClickCountToStart()

shouldSelectCell

public boolean shouldSelectCell(java.util.EventObject anEvent)
Returns true if the editing cell should be selected, false otherwise. Typically, the return value is true, because in most cases the editing cell should be selected. However, it is useful to return false to keep the selection from changing for some types of edits. eg. In a report that contains a column of check boxes, the user might want to be able to change those checkboxes without altering the selection.

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

stopCellEditing

public boolean stopCellEditing()
Tells this editor to stop editing and accept any partially edited value as the value of the editor. This editor returns false if editing was not stopped; this is useful for editors that validate and cannot accept invalid entries.

Specified by:
stopCellEditing in interface javax.swing.CellEditor
Overrides:
stopCellEditing in class javax.swing.AbstractCellEditor
Returns:
true if editing was stopped; false otherwise


Copyright 2003, 2004 Side of Software (SOS). All rights reserved.