// ĠCopyright Ġ 2 0 0 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . x debugger . impl . ui . tree Ċ Ċ import Ġcom . intellij . find . Find Manager Ċ import Ġcom . intellij . find . Find Model Ċ import Ġcom . intellij . find . Search Replace Component Ċ import Ġcom . intellij . find . Search Session Ċ import Ġcom . intellij . find . editor Header Actions . Next Occurrence Action Ċ import Ġcom . intellij . find . editor Header Actions . Prev Occurrence Action Ċ import Ġcom . intellij . find . editor Header Actions . Status Text Action Ċ import Ġcom . intellij . find . editor Header Actions . Toggle Match Case Ċ import Ġcom . intellij . openapi . action System . DataProvider Ċ import Ġcom . intellij . openapi . action System . ex . Default Custom Component Action Ċ import Ġcom . intellij . openapi . project . Project Ċ import Ġcom . intellij . openapi . util . text . StringUtil Ċ import Ġcom . intellij . openapi . wm . Ide Focus Manager Ċ import Ġcom . intellij . ui . JB Int Spinner Ċ import Ġcom . intellij . ui . components . JB Label Ċ import Ġcom . intellij . ui . components . panels . Horizontal Layout Ċ import Ġcom . intellij . ui . scale . J BU IS cale Ċ import Ġcom . intellij . util . ui . UI Util Ċ import Ġcom . intellij . x debugger . X Debugger Bundle Ċ import Ġjava . awt . Component Ċ import Ġjava . awt . event . KeyEvent Ċ import Ġjava . awt . event . Key Listener Ċ import Ġjava . util . function . Supplier Ċ import Ġjavax . swing . J Component Ċ import Ġjavax . swing . JPanel Ċ Ċ internal Ġclass ĠX Debugger Tree Search Session ( val Ġdebugger Tree Panel : ĠX Debugger Tree Panel , Ġval Ġproject : ĠProject ) ĊĠ Ġ: ĠSearch Session , ĊĠĠĠ ĠFind Model . Find Model Observer , ĊĠĠĠ ĠSearch Replace Component . Listener , ĠData Provider Ġ{ ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġconst Ġval ĠDEFAULT _ SEARCH _ DEPTH Ġ= Ġ 4 ĊĠ Ġ} ĊĊĠ Ġprivate Ġval Ġprevious Header Component : ĠComponent ? Ġ= Ġdebugger Tree Panel . header Component ĊĠ Ġprivate Ġval Ġspeed Search Ġ= Ġdebugger Tree Panel . tree . my Speed Search ĊĠ Ġprivate Ġval Ġdepth Choice Ġ= Ġcreate Depth Choice () ĊĠ Ġprivate Ġval Ġsearch Component Ġ= Ġcreate Search Component () ĊĠ Ġprivate Ġval Ġfind Model Ġ= Ġcreate Find Model () ĊĠ Ġprivate Ġvar Ġhas Matches : ĠBoolean Ġ= Ġfalse ĊĠ Ġprivate Ġvar Ġclose Listener Ġ= Ġobject Ġ: ĠKey Listener Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġkey Typed ( e : ĠKeyEvent ) Ġ= Ġprocess Event ( e ) ĊĠĠĠ Ġoverride Ġfun Ġkey Pressed ( e : ĠKeyEvent ) Ġ= Ġprocess Event ( e ) ĊĠĠĠ Ġoverride Ġfun Ġkey Released ( e : ĠKeyEvent ?) Ġ{} ĊĊĠĠĠ Ġprivate Ġfun Ġprocess Event ( e : ĠKeyEvent ) Ġ{ ĊĠĠĠĠĠ Ġif Ġ( e . keyCode Ġ== ĠKeyEvent . VK _ ESCAPE ) Ġ{ ĊĠĠĠĠĠĠĠ Ġclose () ĊĠĠĠĠĠĠĠ Ġe . consume () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġdebugger Tree Panel . header Component Ġ= Ġsearch Component ĊĠĠĠ Ġdebugger Tree Panel . tree . component . add Key Listener ( close Listener ) ĊĠĠĠ Ġspeed Search . search Session Started ( this ) ĊĠĠĠ ĠIde Focus Manager . getInstance ( project ). request Focus ( search Component . search Text Component , Ġfalse ) ĊĠ Ġ} ĊĊĠ Ġclass ĠX Debugger Tree Find Model Ġ: ĠFind Model () Ġ{ ĊĠĠĠ Ġvar Ġsearch Depth : ĠInt Ġ= ĠDEFAULT _ SEARCH _ DEPTH ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Find Model (): ĠX Debugger Tree Find Model Ġ{ ĊĠĠĠ Ġval Ġfind Model Ġ= ĠX Debugger Tree Find Model () ĊĠĠĠ Ġfind Model . copyFrom ( Find Manager . getInstance ( project ). find In File Model ) ĊĠĠĠ Ġfind Model . add Observer ( this ) ĊĠĠĠ Ġreturn Ġfind Model ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġget Find Model (): ĠX Debugger Tree Find Model Ġ{ ĊĠĠĠ Ġreturn Ġfind Model ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġfind Model Changed ( find Model : ĠFind Model ) Ġ{ ĊĠĠĠ Ġval Ġstring To Find Ġ= Ġfind Model . string To Find ĊĊĠĠĠ Ġhas Matches Ġ= Ġperform Search () ĊĠĠĠ Ġif Ġ( StringUtil . isNotEmpty ( string To Find ) Ġ&& Ġ! has Matches ) Ġ{ ĊĠĠĠĠĠ Ġsearch Component . set NotFound Background () ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ{ ĊĠĠĠĠĠ Ġsearch Component . set Regular Background () ĊĠĠĠ Ġ} ĊĠĠĠ Ġsearch Component . status Text Ġ= Ġ"" ĊĠĠĠ Ġsearch Component . update ( string To Find , Ġ"", Ġfalse , Ġfind Model . is Mult iline ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġget Component (): ĠSearch Replace Component Ġ{ ĊĠĠĠ Ġreturn Ġsearch Component ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġhas Matches (): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġhas Matches ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġsearch Forward () Ġ{ ĊĠĠĠ Ġspeed Search . next Occ uren ce ( find Model . string To Find ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġsearch Backward () Ġ{ ĊĠĠĠ Ġspeed Search . previous Occ uren ce ( find Model . string To Find ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġperform Search (): ĠBoolean Ġ{ ĊĠĠĠ Ġreturn Ġspeed Search . find Occ uren ce ( find Model . string To Find ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġsearch Field Document Changed () Ġ{ ĊĠĠĠ Ġval Ġtext To Find Ġ= Ġsearch Component . search Text Component . text ĊĠĠĠ Ġfind Model . string To Find Ġ= Ġtext To Find ĊĠĠĠ Ġfind Model . is Mult iline Ġ= Ġtext To Find . contains ("\ n ") ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġreplace Field Document Changed () Ġ{} ĊĊĠ Ġoverride Ġfun Ġmultiline StateChanged () Ġ{} ĊĊĠ Ġoverride Ġfun Ġclose () Ġ{ ĊĠĠĠ Ġdebugger Tree Panel . header Component Ġ= Ġprevious Header Component ĊĠĠĠ Ġdebugger Tree Panel . search Session Stopped () ĊĠĠĠ Ġdebugger Tree Panel . tree . component . remove Key Listener ( close Listener ) ĊĠĠĠ Ġspeed Search . search Session Stopped () ĊĠĠĠ ĠIde Focus Manager . getInstance ( project ). request Focus ( debugger Tree Panel . tree . component , Ġfalse ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠgetData ( data Id : ĠString ): ĠAny ? Ġ{ ĊĠĠĠ Ġreturn Ġif Ġ( Search Session . KEY .` is `( data Id )) Ġthis Ġelse Ġnull ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Depth Choice (): ĠJ Component Ġ{ ĊĠĠĠ Ġval Ġdepth Spinner Ġ= ĠJ B Int Spinner ( DEFAULT _ SEARCH _ DEPTH , Ġ 1 , Ġ 3 0 , Ġ 1 ) ĊĠĠĠ Ġdepth Spinner . add ChangeListener Ġ{ ĊĠĠĠĠĠ Ġfind Model . search Depth Ġ= Ġdepth Spinner . number ĊĠĠĠĠĠ Ġfind Model Changed ( find Model ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġval Ġlabel Ġ= ĠJ B Label ( X Debugger Bundle . message (" x debugger . variables . search . depth ")) ĊĠĠĠ Ġval Ġpanel Ġ= ĠJPanel ( Horizontal Layout ( J BU IS cale . scale ( UI Util . DEFAULT _ HG AP ))) ĊĠĠĠ Ġpanel . add ( label ) ĊĠĠĠ Ġpanel . add ( depth Spinner ) ĊĠĠĠ Ġreturn Ġpanel ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Search Component (): ĠSearch Replace Component Ġ{ ĊĠĠĠ Ġval Ġsearch Replace Component Ġ= ĠSearch Replace Component ĊĠĠĠĠĠ Ġ. build For ( project , Ġdebugger Tree Panel . tree . component ) ĊĠĠĠĠĠ Ġ. add Primary Search Actions ( Prev Occurrence Action (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠNext Occurrence Action ()) ĊĠĠĠĠĠ Ġ. add Extra Search Actions ( Toggle Match Case (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDefault Custom Component Action ( Supplier < J Component > Ġ{ Ġdepth Choice Ġ}), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStatus Text Action ()) ĊĠĠĠĠĠ Ġ. with Close Action Ġ{ Ġclose () Ġ} ĊĠĠĠĠĠ Ġ. with DataProvider ( this ) ĊĠĠĠĠĠ Ġ. build () ĊĊĠĠĠ Ġsearch Replace Component . addListener ( this ) ĊĠĠĠ Ġreturn Ġsearch Replace Component ĊĠ Ġ} Ċ Ċ }