MethodFinderWindow.st
changeset 2891 d4f1cd8626e6
parent 2890 3d8556368fe9
child 2892 a1349bc5e2fe
equal deleted inserted replaced
2890:3d8556368fe9 2891:d4f1cd8626e6
     3 ApplicationModel subclass:#MethodFinderWindow
     3 ApplicationModel subclass:#MethodFinderWindow
     4 	instanceVariableNames:'argumentsEditor messageAnswerEditor receiverEditor receiver
     4 	instanceVariableNames:'argumentsEditor messageAnswerEditor receiverEditor receiver
     5 		resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible
     5 		resultSelectors arg2BoxVisible arg1BoxVisible arg4BoxVisible
     6 		arg3BoxVisible argCountHolder argCountList argument1Editor
     6 		arg3BoxVisible argCountHolder argCountList argument1Editor
     7 		argument2Editor argument3Editor argument4Editor resultSelected
     7 		argument2Editor argument3Editor argument4Editor resultSelected
     8 		lookAtResultEditor codeHolder'
     8 		lookAtResultEditor codeHolder searchProcess'
     9 	classVariableNames:''
     9 	classVariableNames:''
    10 	poolDictionaries:''
    10 	poolDictionaries:''
    11 	category:'Interface-MethodFinder'
    11 	category:'Interface-MethodFinder'
    12 !
    12 !
    13 
    13 
   700 receiver:=tempReceiver            "search the string for the selector found. Stored as an ordered collection"
   700 receiver:=tempReceiver            "search the string for the selector found. Stored as an ordered collection"
   701 
   701 
   702     "Modified: / 26-09-2011 / 12:42:28 / cg"
   702     "Modified: / 26-09-2011 / 12:42:28 / cg"
   703 !
   703 !
   704 
   704 
       
   705 searchPatternChanged
       
   706     "/ self searchPatternMatches
       
   707     self searchPatternMatchesInBackground
       
   708 
       
   709     "Created: / 01-06-2012 / 13:18:16 / cg"
       
   710 !
       
   711 
   705 searchPatternMatches
   712 searchPatternMatches
   706     "Do a search based on the pattern match"
   713     "Do a search based on the pattern match"
   707 
   714 
   708     | pattern list selectors counts|
   715     | pattern list selectors counts|
   709 
   716 
   731     resultSelectors := selectors asOrderedCollection sort.
   738     resultSelectors := selectors asOrderedCollection sort.
   732 
   739 
   733     self resultHolder value: (resultSelectors collect:[:sel | sel,' --> ',(counts at:sel) value printString,' implementor(s)']).
   740     self resultHolder value: (resultSelectors collect:[:sel | sel,' --> ',(counts at:sel) value printString,' implementor(s)']).
   734 
   741 
   735     "Created: / 27-04-2012 / 14:46:35 / cg"
   742     "Created: / 27-04-2012 / 14:46:35 / cg"
       
   743 !
       
   744 
       
   745 searchPatternMatchesInBackground
       
   746     "Do a search based on the pattern match"
       
   747 
       
   748     | p pattern list|
       
   749 
       
   750     (p := searchProcess) notNil ifTrue:[
       
   751         searchProcess := nil.
       
   752         p terminate.
       
   753     ].
       
   754 
       
   755     searchProcess := 
       
   756         [
       
   757             pattern := self selectorPattern value.
       
   758 
       
   759             self withCursor:Cursor execute do:[
       
   760                 pattern includesMatchCharacters ifFalse:[   
       
   761                     pattern := '*',pattern,'*'
       
   762                 ].
       
   763                 list := SystemBrowser findImplementorsMatching:pattern in:Smalltalk allClasses ignoreCase:true.
       
   764             ].
       
   765             self enqueueDelayedAction:[ self updateListAfterPatternSearch: list ]
       
   766         ] fork.
       
   767 
       
   768     "Created: / 01-06-2012 / 13:16:54 / cg"
   736 !
   769 !
   737 
   770 
   738 selectedClassOfResultHolderChanged
   771 selectedClassOfResultHolderChanged
   739     |sel classAndSelector mthd|
   772     |sel classAndSelector mthd|
   740 
   773 
   773 
   806 
   774     self classOfResultHolder value: classList.
   807     self classOfResultHolder value: classList.
   775     self selectedClassOfResultHolder value:nil.
   808     self selectedClassOfResultHolder value:nil.
   776 
   809 
   777     "Modified: / 13.11.2001 / 12:07:31 / cg"
   810     "Modified: / 13.11.2001 / 12:07:31 / cg"
       
   811 !
       
   812 
       
   813 updateListAfterPatternSearch:list
       
   814     "Do a search based on the pattern match"
       
   815 
       
   816     | selectors counts|
       
   817 
       
   818     self resultHolder value: nil.                "reset the result list"
       
   819     self classOfResultHolder value: nil.         "reset the implementorOf list"
       
   820     self codeHolder value: nil.                  "reset the source"
       
   821 
       
   822     counts := IdentityDictionary new.
       
   823     selectors := IdentitySet new.
       
   824 
       
   825     list do:[:eachMethod |
       
   826         selectors add: eachMethod selector.
       
   827         (counts at:(eachMethod selector) ifAbsentPut:[0 asValue]) increment
       
   828     ].
       
   829 
       
   830     resultSelectors := selectors asOrderedCollection sort.
       
   831 
       
   832     self resultHolder value: (resultSelectors collect:[:sel | sel,' --> ',(counts at:sel) value printString,' implementor(s)']).
       
   833 
       
   834     "Created: / 01-06-2012 / 13:17:34 / cg"
   778 ! !
   835 ! !
   779 
   836 
   780 !MethodFinderWindow methodsFor:'aspects'!
   837 !MethodFinderWindow methodsFor:'aspects'!
   781 
   838 
   782 arg1BoxVisible
   839 arg1BoxVisible
   891 selectorPattern
   948 selectorPattern
   892     |holder|
   949     |holder|
   893     (holder := builder bindingAt:#selectorPattern) isNil ifTrue:[
   950     (holder := builder bindingAt:#selectorPattern) isNil ifTrue:[
   894         holder := ValueHolder new.
   951         holder := ValueHolder new.
   895         builder aspectAt:#selectorPattern put:holder.
   952         builder aspectAt:#selectorPattern put:holder.
   896         holder onChangeSend:#searchPatternMatches to:self.
   953         holder onChangeSend:#searchPatternChanged to:self.
   897     ].
   954     ].
   898     ^ holder
   955     ^ holder
   899 
   956 
   900     "Created: / 27-04-2012 / 14:44:01 / cg"
   957     "Created: / 27-04-2012 / 14:44:01 / cg"
   901 ! !
   958 ! !