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 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.
        model - the model to initialize with
    • Method Detail

      • setActualModel

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

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

        protected void initialize()
        Initializes indices etc.
      • isInitialized

        protected boolean isInitialized()
        whether the model is initialized.
        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
        visibleIndex - the displayed index to retrieve the original index for
        the original index
      • isVisible

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

        public int getVisibleIndex​(int actualIndex)
        Returns the visible index for an actual index in the model.
        actualIndex - the actual index to get the visible index for
        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
        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
        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
        params - the search parameters
        index - the index of the element of the underlying model
        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
        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
        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
        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
        index - the requested index
        the value at index