Interface EditorSearchIndex<T extends Searchable>

  • Type Parameters:
    T - represents the type of Searchable element.
    All Known Implementing Classes:
    BaseEditorSearchIndex

    public interface EditorSearchIndex<T extends Searchable>
    EditorSearchIndex holds the search logic. --- The EditorSearchIndex can have many sub-indexes that index different kinds of elements. Each sub-index, or HasSearchableElements, is naive and will load its searchable elements for every call. Thus, implementations of this interface control lazy approaches, cached approaches, or even the use of a third party library. ---
    • Method Detail

      • getCurrentResult

        Optional<T> getCurrentResult()
        Returns the current result.
        Returns:
        The current result.
      • registerSubIndex

        void registerSubIndex​(HasSearchableElements<T> hasSearchableElements)
        Registers a new sub-index into EditorSearchIndex.
        Parameters:
        hasSearchableElements - represents a new index.
      • search

        void search​(String term)
        Searches for any Searchable that satisfies the parameter, and triggers the onFound callback for the first result.
        Parameters:
        term - the string that will trigger the search
      • setNoResultsFoundCallback

        void setNoResultsFoundCallback​(org.uberfire.mvp.Command callback)
        Sets the callback that will be triggered when no result is found.
        Parameters:
        callback - the callback that will be triggered
      • setSearchClosedCallback

        void setSearchClosedCallback​(org.uberfire.mvp.Command callback)
      • setSearchPerformedCallback

        void setSearchPerformedCallback​(org.uberfire.mvp.Command callback)
        Sets the callback that will be triggered when search is performed.
        Parameters:
        callback - the callback that will be triggered
      • setClearCurrentResultsCallback

        void setClearCurrentResultsCallback​(org.uberfire.mvp.Command callback)
        Sets the callback that will be triggered when the current search results needs to be cleared.
        Parameters:
        callback - the callback that will be triggered
      • getCurrentAssetHashcode

        Integer getCurrentAssetHashcode()
        This method is used by the isDirty logic.
        Returns:
        the asset hashcode.
      • isDirty

        boolean isDirty()
        Check if the index is dirty.
        Returns:
        true if the index is dirty.
      • nextResult

        void nextResult()
        Triggers the onFound callback for the next result.
      • previousResult

        void previousResult()
        Triggers the onFound callback for the previous result.
      • getCurrentResultNumber

        int getCurrentResultNumber()
        Returns the number of the current result.
        Returns:
        a int value representing the number of current result.
      • getTotalOfResultsNumber

        int getTotalOfResultsNumber()
        Returns the number of results.
        Returns:
        a int value representing the number of results.
      • close

        void close()
        Resets the index state. It affects the isDirty, the nextResult, the previousResult, the getCurrentResultNumber, and the getTotalOfResultsNumber method.