Class ComparisonTreeSearchEngine
java.lang.Object
com._1c.g5.v8.dt.md.compare.search.ComparisonTreeSearchEngine
- All Implemented Interfaces:
org.eclipse.emf.edit.provider.IDisposable
public class ComparisonTreeSearchEngine
extends Object
implements org.eclipse.emf.edit.provider.IDisposable
Represents an engine to search the nodes in comparison tree.
-
Constructor Summary
ConstructorsConstructorDescriptionComparisonTreeSearchEngine(List<IComparisonSession> comparisonSessions) Creates instance of search engine for given sessions. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds search update listeners.booleanGets a value indicating whether the searching can be executed.booleanChecks if the beginning of tree was reached by searcher.booleanChecks if the end of tree was reached by searcher.voiddispose()Returns comparison session related to node.Gets current filter data.voidinit()Initializes searcher with allMdObjectComparisonNodenodes from project's sessions given in constructor.booleanChecks if engine is initialized.voidnotifyComparisonTreeSearchUpdateListener(int eventMask) Notifies listeners subscribed to specific tree search update events.voidpastRepositionSearchTo(ComparisonNode node, IComparisonSession session) Performs reposition in sense of "having past thenodebut not the one which follows it", i.e. searching next gives the node (if exists) followingnodeand searching back givesnode.voidPerforms searching from the begining, notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTEDevent.voidPerforms searching from the begining and notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTEDevent.voidrefreshInputForRoot(IComparisonSession comparisonSession) Updates input for searching corresponding to related session.voidRemoves search update listener if registered.voidrepositionSearchTo(ComparisonNode node, IComparisonSession session) This one performs reposition in sense of "having past the node precedingnodebut not thenodeitself", i.e. searching next givesnodeand searching back gives the node preceding tonode.voidResets search borders and resets search progress to left border.search(boolean backwardDirection) Searches forward or backward.voidsetFilterData(FilterData filterData) Sets new filter data.voidsetSearchBorders(ComparisonNode from, ComparisonNode to, IComparisonSession session) Narrows search borders of given collection to nodes contained betweenfromandtoinclusively.
-
Constructor Details
-
ComparisonTreeSearchEngine
Creates instance of search engine for given sessions. Before using this instance,init()must be called.- Parameters:
comparisonSessions- sessions to initialize searching for, cannot benull
-
-
Method Details
-
init
public void init()Initializes searcher with allMdObjectComparisonNodenodes from project's sessions given in constructor.- Parameters:
projectSessions- sessions related to projects to search in, cannot benull
-
getFilterData
Gets current filter data.- Returns:
- current filter data, never
null
-
setFilterData
Sets new filter data. The search will be repositioned to the begining if the filter data was changed, notifiesSearchRestartedListener.- Parameters:
filterData- the new filter data, cannot benull
-
performSearchFromTheBegining
public void performSearchFromTheBegining()Performs searching from the begining, notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTEDevent. -
performSearchFromTheEnd
public void performSearchFromTheEnd()Performs searching from the begining and notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTEDevent. -
canSearch
public boolean canSearch()Gets a value indicating whether the searching can be executed.- Returns:
trueif the filter was set from non-empty data, otherwisefalse
-
canSearchNext
public boolean canSearchNext()Checks if the end of tree was reached by searcher.- Returns:
trueif the end of tree is not yet reached,falseotherwise
-
canSearchBack
public boolean canSearchBack()Checks if the beginning of tree was reached by searcher.- Returns:
trueif the beginning of tree is not yet reached,falseotherwise
-
search
Searches forward or backward.- Parameters:
backwardDirection- the backward search direction flag- Returns:
- search result, may be
nullif nothing found
-
pastRepositionSearchTo
Performs reposition in sense of "having past thenodebut not the one which follows it", i.e. searching next gives the node (if exists) followingnodeand searching back givesnode. Useful when search is performed across a subset of a bigger set of nodes and setting cursor "between" two nodes is needed.- Parameters:
node- the node to which to reposition to, cannot benullsession- session related with node, cannot benull
-
repositionSearchTo
This one performs reposition in sense of "having past the node precedingnodebut not thenodeitself", i.e. searching next givesnodeand searching back gives the node preceding tonode.- Parameters:
node- the node to which to reposition, does nothing ifnullsession- session related with node, cannot benull
-
getComparisonSessionFor
Returns comparison session related to node.- Parameters:
node- to find comparison session for, cannot benull- Returns:
- related comparison session, may be
nullif given node unrelated with none of engine
-
isInitialized
public boolean isInitialized()Checks if engine is initialized.- Returns:
trueif initialized,falseotherwise
-
addComparisonTreeSearchUpdateListener
Adds search update listeners. If not registered already.- Parameters:
listener- listener to add, cannot benull
-
removeComparisonTreeSearchUpdateListener
Removes search update listener if registered.- Parameters:
listener- listener to remove, cannot benull
-
notifyComparisonTreeSearchUpdateListener
public void notifyComparisonTreeSearchUpdateListener(int eventMask) Notifies listeners subscribed to specific tree search update events.- Parameters:
eventMask- mask of comparison tree search update events. SeeIComparisonTreeSearchUpdateListener
-
refreshInputForRoot
Updates input for searching corresponding to related session. Should be used when tree structure changes and some nodes are added/removed. NotifiesIComparisonTreeSearchUpdateListenerlisteners aboutSEARCH_RESTARTEDandSEARCH_INPUT_CHANGEDevents.- Parameters:
comparisonSession- session related to project where changes happened, cannot benull
-
setSearchBorders
Narrows search borders of given collection to nodes contained betweenfromandtoinclusively. Position of current node is moved right beforefromargument. Nodes must be present in the collection search is performed in. When empty interval in project is needed,fromandtoparameters must benull, butsessionstill must be specified.- Parameters:
from- the starting border to narrow search to, can benullto- the end border to narrow search to, can benullsession- session related with node, cannot benull
-
resetBorders
public void resetBorders()Resets search borders and resets search progress to left border. -
dispose
public void dispose()- Specified by:
disposein interfaceorg.eclipse.emf.edit.provider.IDisposable
-