com.sas.swing.visuals.tableview
Class DefaultTableCellEditor

com.sas.swing.visuals.tableview.DefaultTableCellEditor
All Implemented Interfaces:
SupportsGenericErrorHandlerInterface, java.io.Serializable, javax.swing.CellEditor, javax.swing.table.TableCellEditor, javax.swing.tree.TreeCellEditor
Direct Known Subclasses:
BooleanEditor, NumberEditor

public class DefaultTableCellEditor
implements SupportsGenericErrorHandlerInterface

Default Table Cell Editor

See Also:
Serialized Form

Field Summary
static java.lang.String RB_KEY
           
 
Constructor Summary
DefaultTableCellEditor()
          Contructs a DefaultTableCellEditor with a JTextField as the editing component.
DefaultTableCellEditor(javax.swing.JCheckBox checkBox)
          Constructs a DefaultTableCellEditor object that uses a check box.
DefaultTableCellEditor(javax.swing.JComboBox comboBox)
          Constructs a DefaultTableCellEditor object that uses a combo box.
DefaultTableCellEditor(javax.swing.JTextField textField)
          Constructs a DefaultCellEditor object that uses a text field.
 
Method Summary
 java.lang.Object getCellEditorValue()
          Returns the value contained within the editor.
 GenericErrorHandlerInterface getGenericErrorHandler()
          Returns the error handler that the editor uses to handle various errors it catches when either it tries to construct the value to set on the model or validate the value.
 java.util.Locale getLocale()
          Returns the Locale that is used on the transform and outputTransform for the editor.
 com.sas.util.transforms.TransformInterface getOutputTransform()
          Returns the output transform used for converting the user enter string value to an Object that will be set on the model.
 java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
          Sets an initial value for the editor.
 com.sas.util.transforms.TransformInterface getTransform()
          Returns the TransformInterface that is used to convert the value from the model into text to be displayed in the editor.
 ValidationInterface getValidator()
          Returns the validationInterface the editor uses to validate the value before setting the value on the model.
 void setGenericErrorHandler(GenericErrorHandlerInterface errorHandler)
          Sets an error handler to be used on the editor, this errorhandler will be used to handle various errors the editor catches when trying to construct the value to set on the model or when it validates a value.
 void setLocale(java.util.Locale newLocale)
          Sets the locale to use on the transform and outputTransform for the editor.
 void setOutputTransform(com.sas.util.transforms.TransformInterface newTransform)
          Sets the new output transform to use for converting the user enter string value to a value (Class) that is to be set on the model.
 void setTransform(com.sas.util.transforms.TransformInterface newTransform)
          Sets the new transform to use for converting values from the model into displayable text in the editor.
 void setValidator(ValidationInterface newValidator)
          Sets an validator to be used on the editor, this validator will be used to validate whether a value is valid before the value is set on the model.
 boolean stopCellEditing()
          Tells the editor to stop editing and accept any partially edited value as the value of the editor.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values
Constructor Detail

DefaultTableCellEditor

public DefaultTableCellEditor()
Contructs a DefaultTableCellEditor with a JTextField as the editing component.


DefaultTableCellEditor

public DefaultTableCellEditor(javax.swing.JCheckBox checkBox)
Constructs a DefaultTableCellEditor object that uses a check box.

Parameters:
checkBox -

DefaultTableCellEditor

public DefaultTableCellEditor(javax.swing.JComboBox comboBox)
Constructs a DefaultTableCellEditor object that uses a combo box.

Parameters:
comboBox -

DefaultTableCellEditor

public DefaultTableCellEditor(javax.swing.JTextField textField)
Constructs a DefaultCellEditor object that uses a text field.

Parameters:
textField -
Method Detail

setLocale

public void setLocale(java.util.Locale newLocale)
Sets the locale to use on the transform and outputTransform for the editor. The locale will only be set on these transforms if the default transforms are being used, otherwise it is the users responsibility to make sure the transforms are handling the locale correctly.

Parameters:
newLocale - the locale to use
See Also:
getLocale()

getLocale

public java.util.Locale getLocale()
Returns the Locale that is used on the transform and outputTransform for the editor. The locale will only be used on these transforms if the default transforms are being used, otherwise it is the users responsibility to make sure the transforms are handling the locale correctly.

Returns:
the locale to use on the transforms for converting values into the correct locale
See Also:
setLocale(Locale)

setTransform

public void setTransform(com.sas.util.transforms.TransformInterface newTransform)
Sets the new transform to use for converting values from the model into displayable text in the editor. By default, the editor uses the com.sas.util.transforms.ObjectToStringTransform class as it has internationalization support as well as support for missing values.

Parameters:
newTransform - the new transform to use
See Also:
getTransform()

getTransform

public com.sas.util.transforms.TransformInterface getTransform()
Returns the TransformInterface that is used to convert the value from the model into text to be displayed in the editor. By default, the editor uses the com.sas.util.transforms.ObjectToStringTransform class.

Returns:
the transform to use for converting values into displayable text
See Also:
setTransform(TransformInterface)

setOutputTransform

public void setOutputTransform(com.sas.util.transforms.TransformInterface newTransform)
Sets the new output transform to use for converting the user enter string value to a value (Class) that is to be set on the model. By default, the output transform is null and the editor uses the BaseTransforms class to determine the transform to use. Users only need to set an output transform if the default transform returned from BaseTransforms.defaultInstance.lookupTransform(String.class, table.getColumnClass(column)) is not the transform they want to use or if null is returned from the lookup call.

Parameters:
newTransform - the new output transform to use for converting a string to the value set on the model
See Also:
getOutputTransform(), BaseTransforms

getOutputTransform

public com.sas.util.transforms.TransformInterface getOutputTransform()
Returns the output transform used for converting the user enter string value to an Object that will be set on the model. By default, the output transform is null and the editor uses the BaseTransforms class to determine the transform to use. Users only need to set an output transform if the default transform returned from BaseTransforms.defaultInstance.lookupTransform(String.class, table.getColumnClass(column)) is not the transform they want to use or if null is returned from the lookup call.

Returns:
the transform to use for converting user entered values into a object to be set on the model
See Also:
setOutputTransform(TransformInterface)

getGenericErrorHandler

public GenericErrorHandlerInterface getGenericErrorHandler()
Returns the error handler that the editor uses to handle various errors it catches when either it tries to construct the value to set on the model or validate the value. The error handler might display a JOptionPane or write the error to a log. By default, the error handler is null.

Specified by:
getGenericErrorHandler in interface SupportsGenericErrorHandlerInterface
Returns:
the error handler that is used to handle various errors in the editor
See Also:
setGenericErrorHandler(GenericErrorHandlerInterface)

setGenericErrorHandler

public void setGenericErrorHandler(GenericErrorHandlerInterface errorHandler)
Sets an error handler to be used on the editor, this errorhandler will be used to handle various errors the editor catches when trying to construct the value to set on the model or when it validates a value. The error handler set might display a JOptionPane with the error, write the error to a log, or handle the error by another means. The error handler can do whatever it chooses with the error. By default, the error handler is null.

Specified by:
setGenericErrorHandler in interface SupportsGenericErrorHandlerInterface
Parameters:
errorHandler - the new error handler interface to use to handle errors or null to remove the current error handler
See Also:
getGenericErrorHandler()

getValidator

public ValidationInterface getValidator()
Returns the validationInterface the editor uses to validate the value before setting the value on the model. By default, the validator is null.

Returns:
the validator that is used to validate whether a certain value is valid before setting on the model
See Also:
setValidator(ValidationInterface)

setValidator

public void setValidator(ValidationInterface newValidator)
Sets an validator to be used on the editor, this validator will be used to validate whether a value is valid before the value is set on the model. By default, the validator is null.

Parameters:
newValidator - the new validation interface to use to validate the values before setting the value on the model, or null to clear the validation interface
See Also:
getValidator()

stopCellEditing

public boolean stopCellEditing()
Tells 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; this is useful for editors that validate and can not accept invalid entries. If a ValidationInterface has been set on the editor, it will get a chance to validate whether the value is valid or not.

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

getTableCellEditorComponent

public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table,
                                                      java.lang.Object value,
                                                      boolean isSelected,
                                                      int row,
                                                      int column)
Sets an initial value for the editor. This will cause the editor to stopEditing and lose any partially edited value if the editor is editing when this method is called. Returns the component that should be added to the client's Component hierarchy. Once installed in the client's hierarchy this component will then be able to draw and receive user input.

Specified by:
getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
Overrides:
getTableCellEditorComponent in class javax.swing.DefaultCellEditor
Parameters:
table - the JTable that is asking the editor to edit; can be null
value - the value of the cell to be edited; it is up to the specific editor to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value
isSelected - true if the cell is to be rendered with highlighting
row - the row of the cell being edited
column - the column of the cell being edited
Returns:
the component for editing

getCellEditorValue

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

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



Copyright © 2009 SAS Institute Inc. All Rights Reserved.