Package ptolemy.actor.gui
Class PortConfigurerDialog.ValidatingJTextFieldCellEditor
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- javax.swing.DefaultCellEditor
-
- ptolemy.actor.gui.PortConfigurerDialog.ValidatingJTextFieldCellEditor
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
,javax.swing.tree.TreeCellEditor
- Enclosing class:
- PortConfigurerDialog
public class PortConfigurerDialog.ValidatingJTextFieldCellEditor extends javax.swing.DefaultCellEditor
A validating JTextField table cell editor for use with JTable. To determine if a selection is valid, this class uses the CellValidator class.Based on IntegerEditor from http://download.oracle.com/javase/tutorial/uiswing/examples/components/TableFTFEditDemoProject/src/components/IntegerEditor.java
- Since:
- Ptolemy II 5.1
- Version:
- $Id$
- Author:
- Christopher Brooks, Sun Microsystems
- See Also:
- Serialized Form
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Red (eal)
-
-
Constructor Summary
Constructors Constructor Description ValidatingJTextFieldCellEditor()
Construct a validating JTextField JTable Cell editor.ValidatingJTextFieldCellEditor(javax.swing.JFormattedTextField jFormattedTextField)
Construct a validating JTextField JTable Cell editor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getCellEditorValue()
Get the cell editor value.java.awt.Component
getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
void
setValidator(ptolemy.actor.gui.PortConfigurerDialog.CellValidator validator)
Set the validator.boolean
stopCellEditing()
Check the selection and determine whether we should stop editing.protected boolean
userSaysRevert(java.lang.String selectedItem)
Return true if the user wants to revert to the original value.-
Methods inherited from class javax.swing.DefaultCellEditor
cancelCellEditing, getClickCountToStart, getComponent, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCell
-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
-
-
-
-
Constructor Detail
-
ValidatingJTextFieldCellEditor
public ValidatingJTextFieldCellEditor()
Construct a validating JTextField JTable Cell editor.
-
ValidatingJTextFieldCellEditor
public ValidatingJTextFieldCellEditor(javax.swing.JFormattedTextField jFormattedTextField)
Construct a validating JTextField JTable Cell editor.- Parameters:
jFormattedTextField
- The JTextField that provides choices.
-
-
Method Detail
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
- Specified by:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
- Overrides:
getTableCellEditorComponent
in classjavax.swing.DefaultCellEditor
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
Get the cell editor value.- Specified by:
getCellEditorValue
in interfacejavax.swing.CellEditor
- Overrides:
getCellEditorValue
in classjavax.swing.DefaultCellEditor
- Returns:
- The string value of the selected item in the combobox.
-
setValidator
public void setValidator(ptolemy.actor.gui.PortConfigurerDialog.CellValidator validator)
Set the validator.- Parameters:
validator
- The validator.
-
stopCellEditing
public boolean stopCellEditing()
Check the selection and determine whether we should stop editing. If the selection is invalid, ask the user if they want to revert. If the selection is valid, then call stopCellEditing in the super class- Specified by:
stopCellEditing
in interfacejavax.swing.CellEditor
- Overrides:
stopCellEditing
in classjavax.swing.DefaultCellEditor
- Returns:
- False if the selection is invalid. Otherwise, return whatever super.stopCellEditing() returns.
-
userSaysRevert
protected boolean userSaysRevert(java.lang.String selectedItem)
Return true if the user wants to revert to the original value. A dialog box pops up that tells the user that their selection is invalid.- Parameters:
selectedItem
- The selected item.- Returns:
- True if the user elects to revert to the last good value. Otherwise, returns false, indicating that the user wants to continue editing.
-
-