Class JXList.ListAdapter

  • Enclosing class:
    JXList

    protected static class JXList.ListAdapter
    extends ComponentAdapter
    A component adapter targeted at a JXList.
    • Constructor Summary

      Constructors 
      Constructor Description
      ListAdapter​(JXList component)
      Constructs a ListAdapter for the specified target JXList.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getFilteredStringAt​(int row, int column)
      Returns the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.
      java.lang.Object getFilteredValueAt​(int row, int column)
      Returns the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.
      JXList getList()
      Typesafe accessor for the target component.
      int getRowCount()
      Returns the number of rows in the target's data model.
      java.lang.String getString()
      Returns the String representation of the value of the cell identified by this adapter.
      java.lang.String getStringAt​(int row, int column)
      Returns the String representation of the value of the cell identified by the row specified row and column in model coordinates.
      java.lang.Object getValue()
      Returns the value of the cell identified by this adapter.
      java.lang.Object getValueAt​(int row, int column)
      Returns the value of the target component's cell identified by the specified row and column in model coordinates.
      boolean hasFocus()
      Returns true if the cell identified by this adapter currently has focus.
      boolean isCellEditable​(int row, int column)
      Determines whether this cell is editable.
      boolean isEditable()
      Returns true if the cell identified by this adapter is editable, false otherwise.
      boolean isSelected()
      Returns true if the cell identified by this adapter is currently selected.
      void setValueAt​(java.lang.Object aValue, int row, int column)
      Sets the value of the target component's cell identified by the specified row and column in model coordinates.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ListAdapter

        public ListAdapter​(JXList component)
        Constructs a ListAdapter for the specified target JXList.
        Parameters:
        component - the target list.
    • Method Detail

      • getList

        public JXList getList()
        Typesafe accessor for the target component.
        Returns:
        the target component as a JXList
      • hasFocus

        public boolean hasFocus()
        Returns true if the cell identified by this adapter currently has focus. Otherwise, it returns false.
        Specified by:
        hasFocus in class ComponentAdapter
        Returns:
        true if the cell identified by this adapter currently has focus; Otherwise, return false
      • getRowCount

        public int getRowCount()
        Returns the number of rows in the target's data model.
        Overrides:
        getRowCount in class ComponentAdapter
        Returns:
        the number of rows in the target's data model.
      • getValue

        public java.lang.Object getValue()
        Returns the value of the cell identified by this adapter. That is, for the at position (adapter.row, adapter.column) in view coordinates.

        NOTE: this implementation assumes that view coordinates == model coordinates, that is simply calls getValueAt(this.row, this.column). It is up to subclasses to override appropriately is they support model/view coordinate transformation.

        Overridden to return value at implicit view coordinates.

        Overrides:
        getValue in class ComponentAdapter
        Returns:
        the value of the cell identified by this adapter
        See Also:
        ComponentAdapter.getValueAt(int, int), ComponentAdapter.getFilteredValueAt(int, int), ComponentAdapter.getValue(int)
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)
        Returns the value of the target component's cell identified by the specified row and column in model coordinates.
        Specified by:
        getValueAt in class ComponentAdapter
        Parameters:
        row - in model coordinates
        column - in model coordinates
        Returns:
        the value of the target component's cell identified by the specified row and column
      • getFilteredValueAt

        public java.lang.Object getFilteredValueAt​(int row,
                                                   int column)
        Returns the filtered value of the cell identified by the row in view coordinate and the column in model coordinates. Note: the asymetry of the coordinates is intentional - clients like Highlighters are interested in view values but might need to access non-visible columns for testing. While it is possible to access row coordinates different from the current (that is this.row) it is not safe to do so for row > this.row because the adapter doesn't allow to query the count of visible rows.
        Specified by:
        getFilteredValueAt in class ComponentAdapter
        Parameters:
        row - the row of the cell in view coordinates
        column - the column of the cell in model coordinates.
        Returns:
        the filtered value of the cell identified by the row in view coordinate and the column in model coordiantes
      • getFilteredStringAt

        public java.lang.String getFilteredStringAt​(int row,
                                                    int column)
        Returns the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.

        Note: the asymetry of the coordinates is intentional - clients like Highlighters are interested in view values but might need to access non-visible columns for testing. While it is possible to access row coordinates different from the current (that is this.row) it is not safe to do so for row > this.row because the adapter doesn't allow to query the count of visible rows.

        This implementation messages the StringValue.TO_STRING with the filteredValue, subclasses should re-implement and use the api appropriate for the target component type.

        PENDING JW: what about null cell values? StringValue has a contract to return a empty string then, would that be okay here as well?

        Overrides:
        getFilteredStringAt in class ComponentAdapter
        Parameters:
        row - the row of the cell in view coordinates
        column - the column of the cell in model coordinates.
        Returns:
        the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordiantes
      • getString

        public java.lang.String getString()
        Returns the String representation of the value of the cell identified by this adapter. That is, for the at position (adapter.row, adapter.column) in view coordinates.

        NOTE: this implementation assumes that view coordinates == model coordinates, that is simply calls getValueAt(this.row, this.column). It is up to subclasses to override appropriately is they support model/view coordinate transformation.

        This implementation messages the StringValue.TO_STRING with the getValue, subclasses should re-implement and use the api appropriate for the target component type.

        Overrides:
        getString in class ComponentAdapter
        Returns:
        the String representation of value of the cell identified by this adapter
        See Also:
        ComponentAdapter.getValueAt(int, int), ComponentAdapter.getFilteredValueAt(int, int), ComponentAdapter.getValue(int)
      • getStringAt

        public java.lang.String getStringAt​(int row,
                                            int column)
        Returns the String representation of the value of the cell identified by the row specified row and column in model coordinates.

        This implementation messages the StringValue.TO_STRING with the valueAt, subclasses should re-implement and use the api appropriate for the target component type.

        Overrides:
        getStringAt in class ComponentAdapter
        Parameters:
        row - in model coordinates
        column - in model coordinates
        Returns:
        the value of the target component's cell identified by the specified row and column
      • setValueAt

        public void setValueAt​(java.lang.Object aValue,
                               int row,
                               int column)
        Sets the value of the target component's cell identified by the specified row and column in model coordinates.
        Specified by:
        setValueAt in class ComponentAdapter
        Parameters:
        aValue - the value to set
        row - in model coordinates
        column - in model coordinates
      • isCellEditable

        public boolean isCellEditable​(int row,
                                      int column)
        Determines whether this cell is editable.
        Specified by:
        isCellEditable in class ComponentAdapter
        Parameters:
        row - the row to query in model coordinates
        column - the column to query in model coordinates
        Returns:
        true if the cell is editable, false otherwise
      • isEditable

        public boolean isEditable()
        Returns true if the cell identified by this adapter is editable, false otherwise.
        Specified by:
        isEditable in class ComponentAdapter
        Returns:
        true if the cell is editable, false otherwise
      • isSelected

        public boolean isSelected()
        Returns true if the cell identified by this adapter is currently selected. Otherwise, it returns false.
        Specified by:
        isSelected in class ComponentAdapter
        Returns:
        true if the cell identified by this adapter is currently selected; Otherwise, return false