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 TypeMethodDescriptionvoid
Adds search update listeners.boolean
Gets a value indicating whether the searching can be executed.boolean
Checks if the beginning of tree was reached by searcher.boolean
Checks if the end of tree was reached by searcher.void
dispose()
Returns comparison session related to node.Gets current filter data.void
init()
Initializes searcher with allMdObjectComparisonNode
nodes from project's sessions given in constructor.boolean
Checks if engine is initialized.void
notifyComparisonTreeSearchUpdateListener
(int eventMask) Notifies listeners subscribed to specific tree search update events.void
pastRepositionSearchTo
(ComparisonNode node, IComparisonSession session) Performs reposition in sense of "having past thenode
but not the one which follows it", i.e. searching next gives the node (if exists) followingnode
and searching back givesnode
.void
Performs searching from the begining, notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTED
event.void
Performs searching from the begining and notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTED
event.void
refreshInputForRoot
(IComparisonSession comparisonSession) Updates input for searching corresponding to related session.void
Removes search update listener if registered.void
repositionSearchTo
(ComparisonNode node, IComparisonSession session) This one performs reposition in sense of "having past the node precedingnode
but not thenode
itself", i.e. searching next givesnode
and searching back gives the node preceding tonode
.void
Resets search borders and resets search progress to left border.search
(boolean backwardDirection) Searches forward or backward.void
setFilterData
(FilterData filterData) Sets new filter data.void
setSearchBorders
(ComparisonNode from, ComparisonNode to, IComparisonSession session) Narrows search borders of given collection to nodes contained betweenfrom
andto
inclusively.
-
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 allMdObjectComparisonNode
nodes 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_RESTARTED
event. -
performSearchFromTheEnd
public void performSearchFromTheEnd()Performs searching from the begining and notifies aboutIComparisonTreeSearchUpdateListener.SEARCH_RESTARTED
event. -
canSearch
public boolean canSearch()Gets a value indicating whether the searching can be executed.- Returns:
true
if the filter was set from non-empty data, otherwisefalse
-
canSearchNext
public boolean canSearchNext()Checks if the end of tree was reached by searcher.- Returns:
true
if the end of tree is not yet reached,false
otherwise
-
canSearchBack
public boolean canSearchBack()Checks if the beginning of tree was reached by searcher.- Returns:
true
if the beginning of tree is not yet reached,false
otherwise
-
search
Searches forward or backward.- Parameters:
backwardDirection
- the backward search direction flag- Returns:
- search result, may be
null
if nothing found
-
pastRepositionSearchTo
Performs reposition in sense of "having past thenode
but not the one which follows it", i.e. searching next gives the node (if exists) followingnode
and 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 benull
session
- session related with node, cannot benull
-
repositionSearchTo
This one performs reposition in sense of "having past the node precedingnode
but not thenode
itself", i.e. searching next givesnode
and searching back gives the node preceding tonode
.- Parameters:
node
- the node to which to reposition, does nothing ifnull
session
- 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
null
if given node unrelated with none of engine
-
isInitialized
public boolean isInitialized()Checks if engine is initialized.- Returns:
true
if initialized,false
otherwise
-
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. NotifiesIComparisonTreeSearchUpdateListener
listeners aboutSEARCH_RESTARTED
andSEARCH_INPUT_CHANGED
events.- Parameters:
comparisonSession
- session related to project where changes happened, cannot benull
-
setSearchBorders
Narrows search borders of given collection to nodes contained betweenfrom
andto
inclusively. Position of current node is moved right beforefrom
argument. Nodes must be present in the collection search is performed in. When empty interval in project is needed,from
andto
parameters must benull
, butsession
still must be specified.- Parameters:
from
- the starting border to narrow search to, can benull
to
- the end border to narrow search to, can benull
session
- 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:
dispose
in interfaceorg.eclipse.emf.edit.provider.IDisposable
-