Interface EditorSearchIndex<T extends Searchable>
-
- Type Parameters:
T- represents the type ofSearchableelement.
- All Known Implementing Classes:
BaseEditorSearchIndex
public interface EditorSearchIndex<T extends Searchable>EditorSearchIndexholds the search logic. --- TheEditorSearchIndexcan have many sub-indexes that index different kinds of elements. Each sub-index, orHasSearchableElements, 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Resets the index state.IntegergetCurrentAssetHashcode()This method is used by theisDirtylogic.Optional<T>getCurrentResult()Returns the current result.intgetCurrentResultNumber()Returns the number of the current result.List<HasSearchableElements<T>>getSubIndexes()Returns the list of sub-indexes.intgetTotalOfResultsNumber()Returns the number of results.booleanisDirty()Check if the index is dirty.voidnextResult()Triggers theonFoundcallback for the next result.voidpreviousResult()Triggers theonFoundcallback for the previous result.voidregisterSubIndex(HasSearchableElements<T> hasSearchableElements)Registers a new sub-index intoEditorSearchIndex.voidsearch(String term)Searches for anySearchablethat satisfies the parameter, and triggers theonFoundcallback for the first result.voidsetClearCurrentResultsCallback(org.uberfire.mvp.Command callback)Sets the callback that will be triggered when the current search results needs to be cleared.voidsetNoResultsFoundCallback(org.uberfire.mvp.Command callback)Sets the callback that will be triggered when no result is found.voidsetSearchClosedCallback(org.uberfire.mvp.Command callback)voidsetSearchPerformedCallback(org.uberfire.mvp.Command callback)Sets the callback that will be triggered when search is performed.
-
-
-
Method Detail
-
getCurrentResult
Optional<T> getCurrentResult()
Returns the current result.- Returns:
- The current result.
-
getSubIndexes
List<HasSearchableElements<T>> getSubIndexes()
Returns the list of sub-indexes.- Returns:
- the list of
HasSearchableElements.
-
registerSubIndex
void registerSubIndex(HasSearchableElements<T> hasSearchableElements)
Registers a new sub-index intoEditorSearchIndex.- Parameters:
hasSearchableElements- represents a new index.
-
search
void search(String term)
Searches for anySearchablethat satisfies the parameter, and triggers theonFoundcallback 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 theisDirtylogic.- Returns:
- the asset hashcode.
-
isDirty
boolean isDirty()
Check if the index is dirty.- Returns:
- true if the index is dirty.
-
nextResult
void nextResult()
Triggers theonFoundcallback for the next result.
-
previousResult
void previousResult()
Triggers theonFoundcallback 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 theisDirty, thenextResult, thepreviousResult, thegetCurrentResultNumber, and thegetTotalOfResultsNumbermethod.
-
-