Class BaseEditorSearchIndex<T extends Searchable>
- java.lang.Object
-
- org.kie.workbench.common.widgets.client.search.common.BaseEditorSearchIndex<T>
-
- All Implemented Interfaces:
EditorSearchIndex<T>
public abstract class BaseEditorSearchIndex<T extends Searchable> extends Object implements EditorSearchIndex<T>
-
-
Constructor Summary
Constructors Constructor Description BaseEditorSearchIndex()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete 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.protected abstract List<T>getSearchableElements()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.voidsetCurrentAssetHashcodeSupplier(Supplier<Integer> currentAssetHashcodeSupplier)voidsetNoResultsFoundCallback(org.uberfire.mvp.Command callback)Sets the callback that will be triggered when no result is found.voidsetSearchClosedCallback(org.uberfire.mvp.Command searchClosedCallback)voidsetSearchPerformedCallback(org.uberfire.mvp.Command searchPerformedCallback)Sets the callback that will be triggered when search is performed.
-
-
-
Method Detail
-
setSearchPerformedCallback
public void setSearchPerformedCallback(org.uberfire.mvp.Command searchPerformedCallback)
Description copied from interface:EditorSearchIndexSets the callback that will be triggered when search is performed.- Specified by:
setSearchPerformedCallbackin interfaceEditorSearchIndex<T extends Searchable>- Parameters:
searchPerformedCallback- the callback that will be triggered
-
getSubIndexes
public List<HasSearchableElements<T>> getSubIndexes()
Description copied from interface:EditorSearchIndexReturns the list of sub-indexes.- Specified by:
getSubIndexesin interfaceEditorSearchIndex<T extends Searchable>- Returns:
- the list of
HasSearchableElements.
-
registerSubIndex
public void registerSubIndex(HasSearchableElements<T> hasSearchableElements)
Description copied from interface:EditorSearchIndexRegisters a new sub-index intoEditorSearchIndex.- Specified by:
registerSubIndexin interfaceEditorSearchIndex<T extends Searchable>- Parameters:
hasSearchableElements- represents a new index.
-
search
public void search(String term)
Description copied from interface:EditorSearchIndexSearches for anySearchablethat satisfies the parameter, and triggers theonFoundcallback for the first result.- Specified by:
searchin interfaceEditorSearchIndex<T extends Searchable>- Parameters:
term- the string that will trigger the search
-
getCurrentResultNumber
public int getCurrentResultNumber()
Description copied from interface:EditorSearchIndexReturns the number of the current result.- Specified by:
getCurrentResultNumberin interfaceEditorSearchIndex<T extends Searchable>- Returns:
- a int value representing the number of current result.
-
getTotalOfResultsNumber
public int getTotalOfResultsNumber()
Description copied from interface:EditorSearchIndexReturns the number of results.- Specified by:
getTotalOfResultsNumberin interfaceEditorSearchIndex<T extends Searchable>- Returns:
- a int value representing the number of results.
-
close
public void close()
Description copied from interface:EditorSearchIndexResets the index state. It affects theisDirty, thenextResult, thepreviousResult, thegetCurrentResultNumber, and thegetTotalOfResultsNumbermethod.- Specified by:
closein interfaceEditorSearchIndex<T extends Searchable>
-
setNoResultsFoundCallback
public void setNoResultsFoundCallback(org.uberfire.mvp.Command callback)
Description copied from interface:EditorSearchIndexSets the callback that will be triggered when no result is found.- Specified by:
setNoResultsFoundCallbackin interfaceEditorSearchIndex<T extends Searchable>- Parameters:
callback- the callback that will be triggered
-
setClearCurrentResultsCallback
public void setClearCurrentResultsCallback(org.uberfire.mvp.Command callback)
Description copied from interface:EditorSearchIndexSets the callback that will be triggered when the current search results needs to be cleared.- Specified by:
setClearCurrentResultsCallbackin interfaceEditorSearchIndex<T extends Searchable>- Parameters:
callback- the callback that will be triggered
-
setSearchClosedCallback
public void setSearchClosedCallback(org.uberfire.mvp.Command searchClosedCallback)
- Specified by:
setSearchClosedCallbackin interfaceEditorSearchIndex<T extends Searchable>
-
isDirty
public boolean isDirty()
Description copied from interface:EditorSearchIndexCheck if the index is dirty.- Specified by:
isDirtyin interfaceEditorSearchIndex<T extends Searchable>- Returns:
- true if the index is dirty.
-
nextResult
public void nextResult()
Description copied from interface:EditorSearchIndexTriggers theonFoundcallback for the next result.- Specified by:
nextResultin interfaceEditorSearchIndex<T extends Searchable>
-
previousResult
public void previousResult()
Description copied from interface:EditorSearchIndexTriggers theonFoundcallback for the previous result.- Specified by:
previousResultin interfaceEditorSearchIndex<T extends Searchable>
-
getCurrentAssetHashcode
public Integer getCurrentAssetHashcode()
Description copied from interface:EditorSearchIndexThis method is used by theisDirtylogic.- Specified by:
getCurrentAssetHashcodein interfaceEditorSearchIndex<T extends Searchable>- Returns:
- the asset hashcode.
-
setCurrentAssetHashcodeSupplier
public void setCurrentAssetHashcodeSupplier(Supplier<Integer> currentAssetHashcodeSupplier)
-
getCurrentResult
public Optional<T> getCurrentResult()
Description copied from interface:EditorSearchIndexReturns the current result.- Specified by:
getCurrentResultin interfaceEditorSearchIndex<T extends Searchable>- Returns:
- The current result.
-
-