Class SearchableWrapperListModel

    • Field Detail

      • m_Model

        protected ListModel m_Model
        the actual list model.
      • m_SearchString

        protected String m_SearchString
        the string that was searched for.
      • m_RegExpSearch

        protected boolean m_RegExpSearch
        whether the search was a regular expression based one.
      • m_DisplayIndices

        protected gnu.trove.list.TIntList m_DisplayIndices
        the indices of the indices to display that match a search string.
      • m_DisplayIndicesSet

        protected gnu.trove.set.TIntSet m_DisplayIndicesSet
        the indices of the indices to display that match a search string.
      • m_ActualToDisplayIndex

        protected gnu.trove.map.TIntIntMap m_ActualToDisplayIndex
        the relation between actual and display index.
    • Constructor Detail

      • SearchableWrapperListModel

        public SearchableWrapperListModel()
        initializes with no model.
      • SearchableWrapperListModel

        public SearchableWrapperListModel​(ListModel model)
        initializes with the given model.
        Parameters:
        model - the model to initialize with
    • Method Detail

      • setActualModel

        public void setActualModel​(ListModel value)
        Sets the model to use.
        Parameters:
        value - the model to use
      • getActualModel

        public ListModel getActualModel()
        returns the underlying model, can be null.
        Returns:
        the current model
      • initialize

        protected void initialize()
        Initializes indices etc.
      • isInitialized

        protected boolean isInitialized()
        whether the model is initialized.
        Returns:
        true if the model is not null
      • getActualIndex

        public int getActualIndex​(int visibleIndex)
        Returns the actual underlying index the given visible one represents. Useful for retrieving "non-visual" data that is also stored in a ListModel.
        Specified by:
        getActualIndex in interface SearchableListModel
        Parameters:
        visibleIndex - the displayed index to retrieve the original index for
        Returns:
        the original index
      • isVisible

        public boolean isVisible​(int actualIndex)
        Checks whether the index from the actual underlying model is visible.
        Parameters:
        actualIndex - the actual index to check for visibility
        Returns:
        true if visible
      • getVisibleIndex

        public int getVisibleIndex​(int actualIndex)
        Returns the visible index for an actual index in the model.
        Parameters:
        actualIndex - the actual index to get the visible index for
        Returns:
        the index, -1 if failed to locate
      • getSize

        public int getSize()
        Returns the number of (visible) elements in the model.
        Specified by:
        getSize in interface ListModel
        Returns:
        the number of elements in the model
      • getActualSize

        public int getActualSize()
        Returns the actual element count in the model.
        Specified by:
        getActualSize in interface SearchableListModel
        Returns:
        the element count in the underlying data
      • isSearchMatch

        public boolean isSearchMatch​(SearchParameters params,
                                     int index)
        Tests whether the search matches the specified element index.

        Default implementation just checks against the strings that getElementAt(...) returns (using the toString() method of the returned objects). Derived classes should override this method in order to implement a proper/faster search functionality.
        Specified by:
        isSearchMatch in interface CustomSearchListModel
        Parameters:
        params - the search parameters
        index - the index of the element of the underlying model
        Returns:
        true if the search matches this element
      • search

        public void search​(String searchString,
                           boolean regexp)
        Performs a search for the given string. Limits the display of indices to ones containing the search string.
        Specified by:
        search in interface SearchableListModel
        Parameters:
        searchString - the string to search for
        regexp - whether to perform regular expression matching or just plain string comparison
      • getSeachString

        public String getSeachString()
        Returns the current search string.
        Specified by:
        getSeachString in interface SearchableListModel
        Returns:
        the search string, null if not filtered
      • isRegExpSearch

        public boolean isRegExpSearch()
        Returns whether the last search was a regular expression based one.
        Specified by:
        isRegExpSearch in interface SearchableListModel
        Returns:
        true if last search was a reg exp one
      • getElementAt

        public Object getElementAt​(int index)
        Returns the value at the specified index.
        Specified by:
        getElementAt in interface ListModel
        Parameters:
        index - the requested index
        Returns:
        the value at index