Class 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)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor

        javax.swing.DefaultCellEditor.EditorDelegate
    • Field Summary

      • Fields inherited from class javax.swing.DefaultCellEditor

        clickCountToStart, delegate, editorComponent
      • Fields inherited from class javax.swing.AbstractCellEditor

        changeEvent, listenerList
    • 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
      • 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

      • 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 interface javax.swing.table.TableCellEditor
        Overrides:
        getTableCellEditorComponent in class javax.swing.DefaultCellEditor
      • getCellEditorValue

        public java.lang.Object getCellEditorValue()
        Get the cell editor value.
        Specified by:
        getCellEditorValue in interface javax.swing.CellEditor
        Overrides:
        getCellEditorValue in class javax.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 interface javax.swing.CellEditor
        Overrides:
        stopCellEditing in class javax.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.