Tools_SearchDialog.st
changeset 6242 53a88bc35aa5
parent 5886 a212a4614597
child 6351 1db1881129a3
equal deleted inserted replaced
6241:9cc17d183247 6242:53a88bc35aa5
    48 showHelpOnCodePatterns
    48 showHelpOnCodePatterns
    49     HTMLDocumentView openFullOnHelpFile:'Browser/RBSearchPatterns.html'
    49     HTMLDocumentView openFullOnHelpFile:'Browser/RBSearchPatterns.html'
    50 ! !
    50 ! !
    51 
    51 
    52 !SearchDialog methodsFor:'public'!
    52 !SearchDialog methodsFor:'public'!
       
    53 
       
    54 addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch 
       
    55     isSelector == #code ifTrue:[
       
    56         self addTextEntryFieldForCode.
       
    57     ] ifFalse:[
       
    58         self addInputFieldForSelectorOrNameOrString.
       
    59         withCaseIgnore ifTrue:[
       
    60             self addCheckBox:(resources string:'Ignore case')
       
    61                 on:(caseHolder := (LastSearchWasIgnoringCase ? false) asValue).
       
    62         ].
       
    63         withMatch ifTrue:[
       
    64             self addCheckBox:(resources string:'Match')
       
    65                 on:(matchHolder := (LastSearchWasMatch ? true) asValue).
       
    66 "/                (isSelector and:[ sel notNil. ]) ifTrue:[ 
       
    67 "/                    sel includesMatchCharacters ifTrue:[ 
       
    68 "/                        matchHolder value:false.
       
    69 "/                    ].
       
    70 "/                ].
       
    71         ].
       
    72     ]
       
    73 !
    53 
    74 
    54 askThenDo:aBlock 
    75 askThenDo:aBlock 
    55     |where code sel matchHolderValue caseHolderValue|
    76     |where code sel matchHolderValue caseHolderValue|
    56 
    77 
    57     self open.
    78     self open.
   135         value:(matchHolderValue ? false)
   156         value:(matchHolderValue ? false)
   136         value:methods
   157         value:methods
   137         value:(isMethodHolder value ? false).
   158         value:(isMethodHolder value ? false).
   138 !
   159 !
   139 
   160 
   140 setupToAskForMethodSearchTitle:title forBrowser:brwsrArg isSelector:isSelectorArg searchArea:whereDefault withCaseIgnore:withCaseIgnore withMatch:withMatch 
   161 setupToAskForMethodSearchTitle:title forBrowser:brwsrArg isSelector:isSelectorArg searchArea:whereDefault withCaseIgnore:withCaseIgnore withMatch:withMatch withMethodList:withMethodList allowFind:allowFindArg allowBuffer:allowBufferArg allowBrowser:allowBrowserArg withTextEntry:withTextEntryArg 
   141     withMethodList:withMethodList allowFind:allowFindArg allowBuffer:allowBufferArg allowBrowser:allowBrowserArg withTextEntry:withTextEntryArg 
   162     |where ns methodNameSpaces|
   142     | where ns methodNameSpaces|
       
   143 
   163 
   144     allowFind := allowFindArg.
   164     allowFind := allowFindArg.
   145     allowBuffer := allowBufferArg.
   165     allowBuffer := allowBufferArg.
   146     allowBrowser := allowBrowserArg.
   166     allowBrowser := allowBrowserArg.
   147     isSelector := isSelectorArg.
   167     isSelector := isSelectorArg.
   148     withTextEntry := withTextEntryArg.
   168     withTextEntry := withTextEntryArg.
   149     browser := brwsrArg.
   169     browser := brwsrArg.
   150     resources := browser resources.
   170     resources := browser resources.
   151 
   171 
   152     (self addTextLabel:(resources string:title) withCRs) adjust:#left.
   172     (self addTextLabel:(resources string:title) withCRs) adjust:#left.
   153 
       
   154     selectedClasses := browser selectedClasses value.
   173     selectedClasses := browser selectedClasses value.
   155     selectedCategories := browser selectedCategoriesValue.
   174     selectedCategories := browser selectedCategoriesValue.
   156     selectedMethods := browser selectedMethods value.
   175     selectedMethods := browser selectedMethods value.
   157     currentClass := browser theSingleSelectedClass.
   176     currentClass := browser theSingleSelectedClass.
   158     currentClassCategory := browser theSingleSelectedCategory.
   177     currentClassCategory := browser theSingleSelectedCategory.
   159     currentClass isNil ifTrue:[ 
   178     currentClass isNil ifTrue:[
   160         browser hasMethodSelected ifTrue:[ 
   179         browser hasMethodSelected ifTrue:[
   161             currentClass := selectedMethods first mclass.
   180             currentClass := selectedMethods first mclass.
   162             selectedClasses := (selectedMethods collect:[ :each | each mclass ]) 
   181             selectedClasses := (selectedMethods collect:[:each | each mclass ]) 
   163                         asIdentitySet.
   182                         asIdentitySet.
   164             selectedClasses := selectedClasses select:[ :each | each notNil ].
   183             selectedClasses := selectedClasses select:[:each | each notNil ].
   165         ].
   184         ].
   166     ].
   185     ].
   167     currentClass notNil ifTrue:[ 
   186     currentClass notNil ifTrue:[
   168         currentClass := currentClass theNonMetaclass.
   187         currentClass := currentClass theNonMetaclass.
   169     ].
   188     ].
   170 
   189     withTextEntry ifTrue:[
   171     withTextEntry ifTrue:[ 
   190         self addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch.
   172         isSelector == #code ifTrue:[
       
   173             self addTextEntryFieldForCode.
       
   174         ] ifFalse:[
       
   175             self addInputFieldForSelectorOrNameOrString.
       
   176 
       
   177             withCaseIgnore ifTrue:[ 
       
   178                 self addCheckBox:(resources string:'Ignore case')
       
   179                     on:(caseHolder := (LastSearchWasIgnoringCase ? false) asValue).
       
   180             ].
       
   181             withMatch ifTrue:[ 
       
   182                 self addCheckBox:(resources string:'Match')
       
   183                     on:(matchHolder := (LastSearchWasMatch ? true) asValue).
       
   184 
       
   185 "/                (isSelector and:[ sel notNil. ]) ifTrue:[ 
       
   186 "/                    sel includesMatchCharacters ifTrue:[ 
       
   187 "/                        matchHolder value:false.
       
   188 "/                    ].
       
   189 "/                ].
       
   190             ].
       
   191         ].
       
   192     ].
   191     ].
   193     searchAreas := OrderedCollection new.
   192     searchAreas := OrderedCollection new.
   194     verticalPanel := VerticalPanelView new.
   193     verticalPanel := VerticalPanelView new.
   195     verticalPanel horizontalLayout:#fitSpace.
   194     verticalPanel horizontalLayout:#fitSpace.
   196     self addHorizontalLine.
   195     self addHorizontalLine.
   197     self addVerticalSpace.
   196     self addVerticalSpace.
   198     (self addTextLabel:(resources string:'Search in:')) adjust:#left.
   197     (self addTextLabel:(resources string:'Search in:')) adjust:#left.
   199     whereRadioGroup := RadioButtonGroup new.
   198     whereRadioGroup := RadioButtonGroup new.
   200     (selectedCategories size > 0 or:[ selectedClasses size > 0 ]) ifTrue:[ 
   199     (selectedCategories size > 0 or:[ selectedClasses size > 0 ]) ifTrue:[
   201         self addCheckBoxForEverywhere.
   200         self addCheckBoxForEverywhere.
   202         
       
   203         "/        classMethodListView notNil ifTrue:[
   201         "/        classMethodListView notNil ifTrue:[
   204         "/            b := CheckBox label:(resources string:'Shown Methods').
   202         "/            b := CheckBox label:(resources string:'Shown Methods').
   205         "/            panel add:b. whereChannel add:b value:#currentMethodList.
   203         "/            panel add:b. whereChannel add:b value:#currentMethodList.
   206         "/            areas add:#currentMethodList.
   204         "/            areas add:#currentMethodList.
   207         "/            self makeTabable:b.
   205         "/            self makeTabable:b.
   208         "/        ].
   206         "/        ].
   209         browser isMethodListBrowser ifTrue:[ 
   207         browser isMethodListBrowser ifTrue:[
   210             methodNameSpaces := (browser selectedMethods value ? #()) 
   208             methodNameSpaces := (browser selectedMethods value ? #()) 
   211                         collect:[ :eachMethod | eachMethod mclass topNameSpace ].
   209                         collect:[:eachMethod | eachMethod mclass topNameSpace ].
   212         ].
   210         ].
   213         methodNameSpaces size == 1 ifTrue:[ 
   211         methodNameSpaces size == 1 ifTrue:[
   214             currentNamespace := methodNameSpaces first.
   212             currentNamespace := methodNameSpaces first.
   215         ] ifFalse:[ 
   213         ] ifFalse:[
   216             currentNamespace := browser currentNamespace.
   214             currentNamespace := browser currentNamespace.
   217         ].
   215         ].
   218         (currentNamespace notNil 
   216         (currentNamespace notNil 
   219             and:[ currentNamespace ~= (browser nameListEntryForALL) ]) 
   217             and:[ currentNamespace ~= (browser nameListEntryForALL) ]) 
   220                 ifTrue:[ self addCheckBoxForCurrentNamespace ]
   218                 ifTrue:[ self addCheckBoxForCurrentNamespace ]
   221                 ifFalse:[ 
   219                 ifFalse:[
   222                     (currentClass notNil 
   220                     (currentClass notNil 
   223                         and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ]) 
   221                         and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ]) 
   224                             ifTrue:[ self addCheckBoxForClassesNamespace:ns ].
   222                             ifTrue:[ self addCheckBoxForClassesNamespace:ns ].
   225                 ].
   223                 ].
   226         selectedCategories size > 0 ifTrue:[ 
   224         selectedCategories size > 0 ifTrue:[
   227             self addCheckBoxForSelectedClassCategory.
   225             self addCheckBoxForSelectedClassCategory.
   228         ].
   226         ].
   229         (selectedClasses size > 0 or:[ selectedMethods size > 0 ]) ifTrue:[ 
   227         (selectedClasses size > 0 or:[ selectedMethods size > 0 ]) ifTrue:[
   230             self addCheckBoxForSelectedClass.
   228             self addCheckBoxForSelectedClass.
   231             self addCheckBoxForSelectedClassAndSuperclasses.
   229             self addCheckBoxForSelectedClassAndSuperclasses.
   232             self addCheckBoxForSelectedClassAndSubclasses.
   230             self addCheckBoxForSelectedClassAndSubclasses.
   233             self addCheckBoxForSelectedClassAndPrivateClasses.
   231             self addCheckBoxForSelectedClassAndPrivateClasses.
   234             self addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses.
   232             self addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses.
   235             self addCheckBoxForOwnerAndItsPrivateClasses.
   233             self addCheckBoxForOwnerAndItsPrivateClasses.
   236             self addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses.
   234             self addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses.
   237         ].
   235         ].
   238     ] ifFalse:[ 
   236     ] ifFalse:[
   239         browser currentNamespace ~~ Smalltalk ifTrue:[ 
   237         browser currentNamespace ~~ Smalltalk ifTrue:[
   240             self addCheckBoxForEverywhere.
   238             self addCheckBoxForEverywhere.
   241             currentNamespace := browser currentNamespace.
   239             currentNamespace := browser currentNamespace.
   242             currentNamespace ~= (browser nameListEntryForALL) ifTrue:[ 
   240             currentNamespace ~= (browser nameListEntryForALL) ifTrue:[
   243                 self addCheckBoxForCurrentNamespace.
   241                 self addCheckBoxForCurrentNamespace.
   244             ] ifFalse:[ 
   242             ] ifFalse:[
   245                 (currentClass notNil 
   243                 (currentClass notNil 
   246                     and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ]) 
   244                     and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ]) 
   247                         ifTrue:[ self addCheckBoxForClassesNamespace:ns ].
   245                         ifTrue:[ self addCheckBoxForClassesNamespace:ns ].
   248             ].
   246             ].
   249         ].
   247         ].
   250     ].
   248     ].
   251     (withMethodList and:[ browser isMethodListBrowser ]) ifTrue:[ 
   249     (withMethodList and:[ browser isMethodListBrowser ]) ifTrue:[
   252         searchAreas size == 0 ifTrue:[ 
   250         searchAreas size == 0 ifTrue:[
   253             self addCheckBoxForEverywhere.
   251             self addCheckBoxForEverywhere.
   254         ].
   252         ].
   255         self addCheckBoxForMethodList.
   253         self addCheckBoxForMethodList.
   256         browser selectedMethods value size > 1 ifTrue:[ 
   254         browser selectedMethods value size > 1 ifTrue:[
   257             self addCheckBoxForSelectedMethods.
   255             self addCheckBoxForSelectedMethods.
   258         ].
   256         ].
   259     ].
   257     ].
   260     searchAreas size == 0 ifTrue:[ 
   258     searchAreas size == 0 ifTrue:[
   261         whereRadioGroup := #everywhere asValue.
   259         whereRadioGroup := #everywhere asValue.
   262         self addDummyCheckBoxForEverywhere.
   260         self addDummyCheckBoxForEverywhere.
   263     ] ifFalse:[ 
   261     ] ifFalse:[
   264         whereDefault notNil ifTrue:[ 
   262         whereDefault notNil ifTrue:[
   265             (searchAreas includes:whereDefault) ifTrue:[ 
   263             (searchAreas includes:whereDefault) ifTrue:[
   266                 where := whereDefault asSymbol.
   264                 where := whereDefault asSymbol.
   267             ] ifFalse:[ 
   265             ] ifFalse:[
   268                 where := searchAreas first.
   266                 where := searchAreas first.
   269             ].
   267             ].
   270         ] ifFalse:[ 
   268         ] ifFalse:[
   271             where := #everywhere.
   269             where := #everywhere.
   272         ].
   270         ].
   273         whereRadioGroup value:where.
   271         whereRadioGroup value:where.
   274     ].
   272     ].
   275     self addComponent:verticalPanel indent:0.
   273     self addComponent:verticalPanel indent:0.
   276     
   274     
   277     "/ panel has its own idea of indenting
   275     "/ panel has its own idea of indenting
   278     self addVerticalSpace.
   276     self addVerticalSpace.
   279     self addHorizontalLine.
   277     self addHorizontalLine.
   280 
       
   281     self addButtons.
   278     self addButtons.
   282     self label:(resources string:'Search').
   279     self label:(resources string:'Search').
   283 ! !
   280 ! !
   284 
   281 
   285 !SearchDialog methodsFor:'setup'!
   282 !SearchDialog methodsFor:'setup'!
   761 ! !
   758 ! !
   762 
   759 
   763 !SearchDialog class methodsFor:'documentation'!
   760 !SearchDialog class methodsFor:'documentation'!
   764 
   761 
   765 version
   762 version
   766     ^ '$Header: /cvs/stx/stx/libtool/Tools_SearchDialog.st,v 1.3 2004-05-27 14:29:32 cg Exp $'
   763     ^ '$Header: /cvs/stx/stx/libtool/Tools_SearchDialog.st,v 1.4 2005-04-08 09:32:20 cg Exp $'
   767 ! !
   764 ! !