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 Details

    • ComparisonTreeSearchEngine

      public ComparisonTreeSearchEngine(List<IComparisonSession> comparisonSessions)
      Creates instance of search engine for given sessions. Before using this instance, init() must be called.
      Parameters:
      comparisonSessions - sessions to initialize searching for, cannot be null
  • Method Details

    • init

      public void init()
      Initializes searcher with all MdObjectComparisonNode nodes from project's sessions given in constructor.
      Parameters:
      projectSessions - sessions related to projects to search in, cannot be null
    • getFilterData

      public FilterData getFilterData()
      Gets current filter data.
      Returns:
      current filter data, never null
    • setFilterData

      public void setFilterData(FilterData filterData)
      Sets new filter data. The search will be repositioned to the begining if the filter data was changed, notifies SearchRestartedListener.
      Parameters:
      filterData - the new filter data, cannot be null
    • performSearchFromTheBegining

      public void performSearchFromTheBegining()
      Performs searching from the begining, notifies about IComparisonTreeSearchUpdateListener.SEARCH_RESTARTED event.
    • performSearchFromTheEnd

      public void performSearchFromTheEnd()
      Performs searching from the begining and notifies about IComparisonTreeSearchUpdateListener.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, otherwise false
    • 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

      public SearchResult search(boolean backwardDirection)
      Searches forward or backward.
      Parameters:
      backwardDirection - the backward search direction flag
      Returns:
      search result, may be null if nothing found
    • pastRepositionSearchTo

      public void pastRepositionSearchTo(ComparisonNode node, IComparisonSession session)
      Performs reposition in sense of "having past the node but not the one which follows it", i.e. searching next gives the node (if exists) following node and searching back gives node. 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 be null
      session - session related with node, cannot be null
    • repositionSearchTo

      public void repositionSearchTo(ComparisonNode node, IComparisonSession session)
      This one performs reposition in sense of "having past the node preceding node but not the node itself", i.e. searching next gives node and searching back gives the node preceding to node.
      Parameters:
      node - the node to which to reposition, does nothing if null
      session - session related with node, cannot be null
    • getComparisonSessionFor

      public IComparisonSession getComparisonSessionFor(ComparisonNode node)
      Returns comparison session related to node.
      Parameters:
      node - to find comparison session for, cannot be null
      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

      public void addComparisonTreeSearchUpdateListener(IComparisonTreeSearchUpdateListener listener)
      Adds search update listeners. If not registered already.
      Parameters:
      listener - listener to add, cannot be null
    • removeComparisonTreeSearchUpdateListener

      public void removeComparisonTreeSearchUpdateListener(IComparisonTreeSearchUpdateListener listener)
      Removes search update listener if registered.
      Parameters:
      listener - listener to remove, cannot be null
    • notifyComparisonTreeSearchUpdateListener

      public void notifyComparisonTreeSearchUpdateListener(int eventMask)
      Notifies listeners subscribed to specific tree search update events.
      Parameters:
      eventMask - mask of comparison tree search update events. See IComparisonTreeSearchUpdateListener
    • refreshInputForRoot

      public void refreshInputForRoot(IComparisonSession comparisonSession)
      Updates input for searching corresponding to related session. Should be used when tree structure changes and some nodes are added/removed. Notifies IComparisonTreeSearchUpdateListener listeners about SEARCH_RESTARTED and SEARCH_INPUT_CHANGED events.
      Parameters:
      comparisonSession - session related to project where changes happened, cannot be null
    • setSearchBorders

      public void setSearchBorders(ComparisonNode from, ComparisonNode to, IComparisonSession session)
      Narrows search borders of given collection to nodes contained between from and to inclusively. Position of current node is moved right before from argument. Nodes must be present in the collection search is performed in. When empty interval in project is needed, from and to parameters must be null, but session still must be specified.
      Parameters:
      from - the starting border to narrow search to, can be null
      to - the end border to narrow search to, can be null
      session - session related with node, cannot be null
    • resetBorders

      public void resetBorders()
      Resets search borders and resets search progress to left border.
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.eclipse.emf.edit.provider.IDisposable