Tools__SearchDialog.st
branchjv
changeset 16459 85d703589d34
parent 16369 1090224cc0db
parent 16450 6cb2bfca401e
child 16570 dc5e958a20dc
--- a/Tools__SearchDialog.st	Thu May 05 06:48:38 2016 +0200
+++ b/Tools__SearchDialog.st	Fri May 06 06:55:08 2016 +0200
@@ -22,7 +22,8 @@
 		allowBuffer allowBrowser searchWhat searchClassProtocolHolder
 		searchInstanceProtocolHolder selectorOrCode selectionList
 		listHolder matchProcess inputField showMetaFilter
-		metaclassesOnlyHolder classesOnlyHolder initialText'
+		metaclassesOnlyHolder classesOnlyHolder initialText
+		withSearchStringInLiterals searchStringInLiteralsHolder'
 	classVariableNames:'LastCodeSearched LastCodeSearchWasMethod LastGlobalSearched
 		LastStringSearched LastSearchWasMatch LastSearchWasCaseSensitive
 		LastStringSearchArea LastCodeSearchArea AREA_LISTOFMETHODS
@@ -63,6 +64,99 @@
     "Created: / 19-11-2010 / 12:11:50 / cg"
 ! !
 
+!SearchDialog class methodsFor:'help'!
+
+helpSpec
+    ^ Dictionary new addPairsFrom:#(
+#listOfChangedClasses
+'Search only in changed classes'
+
+#listOfChangedMethods
+'Search only in changed methods'
+
+#currentClassesNameSpace
+'Search in the namespace(s) of the selected class(es)'
+
+#currentClassesPackage
+'Search in the package(s) of the selected class(es)'
+
+#currentNameSpace
+'Search in the current selected or selected classes namespace'
+
+#currentPackage
+'Search in the current selected or selected classes package'
+
+#currentClassesPackage
+'Search in the current selected classes package'
+
+#currentPackageAndSubPackages
+'Search in the current (selected) package and subpackages.\(disabled if there are no subpackages)'
+
+#everywhere
+'Search everywhere (all loaded classes)'
+
+#listOfMethods
+'Search only in the list of (shown) methods'
+
+#ownersWithPrivateClasses
+'Search in class and the owning and private classes.\(disabled if there are none)'
+
+#ownersHierarchiesWithPrivateClasses
+'Search in class, owners, private classes and all subclasses.\(disabled if there are none)'
+
+#classes
+'Search in selected class(es) only'
+
+#classesWithPrivateClasses
+'Search in selected class(es) and any private classes.\(disabled if there are no private classes)'
+
+#classHierarchies
+'Search in selected class(es) and down all subclasses.\(disabled if there are no subclasses)'
+
+#classHierarchiesWithPrivateClasses
+'Search in selected class(es), down all subclasses and all of their private classes.\(disabled if there are none)'
+
+#classesAndSuperclasses
+'Search in selected class(es) and up all super classes.\(disabled if there are none)'
+
+#classCategories
+'Search in selected class category(s)'
+
+#listOfSelectedMethodClasses
+'Search in class(es) of selected method(s)'
+
+#listOfSelectedMethodPackages
+'Search in package(es) of selected method(s)'
+
+#listOfSelectedMethods
+'Search in selected method(s)'
+
+#selectedPackages
+'Search in selected package(s)'
+
+#searchPatternField
+'The searched string or name. Does completion on TAB-key'
+
+#codeEntryField
+'Code fragment to match against in the search.\Press "pattern-help" to learn more about code searches'
+
+#nonMetaClassesOnly
+'Search only in instance methods (non-meta classes)'
+
+#metaClassesOnly
+'Search only in class methods (meta classes)'
+
+#searchStringInLiterals
+'Search string in literal constants; not in source code'
+
+#match
+'Perform a pattern match search, as oposed to an exact string search.\Pattern is a simple GLOB pattern (as in filenames)'
+
+#caseSensitive
+'Perform a case sensitive search (default is to ignore case differences)'
+)
+! !
+
 !SearchDialog class methodsFor:'queries'!
 
 lastCodeSearchArea
@@ -87,13 +181,25 @@
     initialText := aString.
 !
 
-showMetaFilter:something
-    showMetaFilter := something.
+showMetaFilter:aBoolean
+    "enable another checkbox, to allow searching in meta/non-meta"
+
+    showMetaFilter := aBoolean.
+!
+
+withSearchStringInLiterals:aBoolean
+    "enable another checkbox, to allow searching for a string
+     in the literals only"
+     
+    withSearchStringInLiterals := aBoolean.
 ! !
 
 !SearchDialog methodsFor:'accessing-entered values'!
 
 classesOnly
+    "the value of the corresponding check toggle;
+     if on, only search in non-metaclasses"
+
     ^ (classesOnlyHolder ? false) value
 
     "Created: / 20-08-2012 / 13:25:26 / cg"
@@ -112,6 +218,9 @@
 !
 
 metaclassesOnly
+    "the value of the corresponding check toggle;
+     if on, only search in metaclasses"
+
     ^ (metaclassesOnlyHolder ? false) value
 
     "Created: / 20-08-2012 / 13:17:12 / cg"
@@ -122,10 +231,16 @@
 !
 
 openHow
+    "the value of the corresponding button pressed to close the dialog;
+     a symbol describing what to do (newBrowser/newBuffer/find)"
+
     ^ openHow.
 !
 
 searchAreaSelected
+    "the value of the corresponding radio button;
+     a symbol describing where to search"
+
     ^ whereRadioGroup value.
 !
 
@@ -134,10 +249,24 @@
 !
 
 searchIsCaseSensitive
+    "the value of the corresponding check toggle;
+     if on, search is case sensitive; otherwise ignore case"
+
     ^ (caseHolder value ? false)
 !
 
+searchStringInLiterals
+    "the value of the corresponding check toggle;
+     if on, only literal strings should be searched;
+     otherwise, the sourcecode is searched"
+     
+    ^ searchStringInLiteralsHolder value ? false.
+!
+
 searchWithMatch
+    "the value of the corresponding check toggle;
+     if on, do a GLOB match; otherwise an exact search"
+
     ^ matchHolder value ? false.
 !
 
@@ -145,6 +274,21 @@
     ^ selectorOrCode.
 ! !
 
+!SearchDialog methodsFor:'help'!
+
+flyByHelpTextFor:aComponent
+    |symbolicHelpKey text|
+
+    (symbolicHelpKey := aComponent helpKey) notNil ifTrue:[
+    Transcript showCR:symbolicHelpKey.
+        text := self class helpSpec at:symbolicHelpKey ifAbsent:[ nil ].
+        text notNil ifTrue:[
+            ^ NewSystemBrowser classResources stringWithCRs:text.
+        ].    
+    ].
+    ^ nil
+! !
+
 !SearchDialog methodsFor:'obsolete'!
 
 addCheckBoxForClassMethodSearch
@@ -232,18 +376,20 @@
         (searchWhat ~~ #resource) ifTrue:[ 
             initialCaseSensitive := (LastSearchWasCaseSensitive ? false) 
         ].  
-        self 
+        (self 
             addCheckBox:(resources string:'Case Sensitive')
-            on:(caseHolder := initialCaseSensitive asValue).
+            on:(caseHolder := initialCaseSensitive asValue))
+            helpKey:#caseSensitive.
     ].
     withMatch ifTrue:[
         initialMatch := true.
         (searchWhat ~~ #resource) ifTrue:[ 
             initialMatch := (LastSearchWasMatch ? true) 
         ].
-        self 
+        (self 
             addCheckBox:(resources string:'Match')
-            on:(matchHolder := initialMatch asValue).
+            on:(matchHolder := initialMatch asValue))
+            helpKey:#match.
 "/                (isSelector and:[ sel notNil. ]) ifTrue:[ 
 "/                    sel includesMatchCharacters ifTrue:[ 
 "/                        matchHolder value:false.
@@ -379,6 +525,10 @@
     withMethodList:withMethodList allowFind:allowFindArg allowBuffer:allowBufferArg 
     allowBrowser:allowBrowserArg withTextEntry:withTextEntryArg 
 
+    "the real construction of the box is done here. 
+     Any additional parameters (metaOnly, searchLiterals etc. must have been done
+     already."
+    
     "searchWhat:
         one of:#selector 
      searchArea:
@@ -422,16 +572,16 @@
         self addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch.
     ].
 
-    searchAreas := OrderedCollection new.
-
-    self addHorizontalLine.
-    "/ self addVerticalSpace.
-
     (showMetaFilter ? false) ifTrue:[
         currentPanel := self.
         self addCheckBoxForMetaClassesOnly.
     ].
-
+    (withSearchStringInLiterals ? false) ifTrue:[    
+        currentPanel := self.
+        self addCheckBoxForSearchInLiteralsOnly
+    ].
+    
+    self addHorizontalLine.
 
     hPanel := HorizontalPanelView "SimpleView" new.
     hPanel verticalLayout:#top.
@@ -443,6 +593,7 @@
 
     (self addTextLabel:(resources string:'Search in:')) adjust:#left.
 
+    searchAreas := OrderedCollection new.
     whereRadioGroup := RadioButtonGroup new.
 
     self addCheckBoxForEverywhere.
@@ -636,16 +787,22 @@
 !SearchDialog methodsFor:'setup'!
 
 addCheckBox:b forSearchArea:area 
+    self addCheckBox:b forSearchArea:area helpKey:area
+!
+
+addCheckBox:b forSearchArea:area helpKey:symbolicHelpKey
     currentPanel add:b.
     whereRadioGroup add:b value:area.
     searchAreas add:area.
     self makeTabable:b.
+    symbolicHelpKey notNil ifTrue:[ b helpKey:symbolicHelpKey ].
 !
 
 addCheckBoxForChangedClassesList
     |b|
 
     b := RadioButton "CheckBox" label:(resources string:'Changed Classes').
+    
     self addCheckBox:b forSearchArea:#listOfChangedClasses.
     ChangeSet current changedClasses isEmpty ifTrue:[
         b disable
@@ -657,6 +814,7 @@
     |b|
 
     b := RadioButton "CheckBox" label:(resources string:'Changed Methods').
+
     self addCheckBox:b forSearchArea:#listOfChangedMethods.
     ChangeSet current changeSelectors isEmpty ifTrue:[
         b disable
@@ -739,12 +897,14 @@
     
     b := CheckBox label:(resources string:'Metaclasses Only') in:p.
     b model:(metaclassesOnlyHolder := false asValue).
+    b helpKey:#metaClassesOnly.
     metaclassesOnlyHolder onChangeEvaluate:[metaclassesOnlyHolder value ifTrue:[classesOnlyHolder value:false]].
     self makeTabable:b.
 
     b := CheckBox label:(resources string:'Classes Only') in:p.
     b left:0.5.
     b model:(classesOnlyHolder := false asValue).
+    b helpKey:#nonMetaClassesOnly.
     classesOnlyHolder onChangeEvaluate:[classesOnlyHolder value ifTrue:[metaclassesOnlyHolder value:false]].
     self makeTabable:b.
 
@@ -798,6 +958,20 @@
     ^ b.
 !
 
+addCheckBoxForSearchInLiteralsOnly
+    |p b|
+
+    p := View new.
+    
+    b := CheckBox label:(resources string:'Search Literals Only') in:p.
+    b model:(searchStringInLiteralsHolder := false asValue).
+    p helpKey:#searchStringInLiterals.
+    self makeTabable:b.
+
+    currentPanel add:p.
+    ^ nil.
+!
+
 addCheckBoxForSelectedClass
     |b lbl arg|
 
@@ -973,15 +1147,15 @@
 addCheckBoxForSelectedPackage
     |b lbl arg|
 
-    currentClassCategory notNil ifTrue:[ 
-        lbl := 'Class category ("%1")'.
-        arg := currentClassCategory.
+    currentPackage notNil ifTrue:[ 
+        lbl := 'Class package ("%1")'.
+        arg := currentPackage.
     ] ifFalse:[ 
-        lbl := 'Selected classes categories (%1)'.
-        arg := selectedCategories size.
+        lbl := 'Selected classes packages (%1)'.
+        arg := selectedPackages size.
     ].
     b := RadioButton "CheckBox" label:(resources string:lbl with:arg).
-    self addCheckBox:b forSearchArea:#classCategories.
+    self addCheckBox:b forSearchArea:#selectedPackages.
     ^ b.
 !
 
@@ -990,10 +1164,12 @@
 
     y := self yPosition.
     b1 := self addCheckBox:(resources string:'Instance Protocol') on:(self searchInstanceProtocolHolder).
+    b1 helpKey:#classesOnly.
     "/ b1 width:0.5.
 
     "/ self yPosition:y.
     b2 := self addCheckBox:(resources string:'Class Protocol') on:(self searchClassProtocolHolder).
+    b2 helpKey:#metaClassesOnly.
     "/ b2 left:0.5; width:0.5.
 
     "Created: / 06-12-2011 / 11:24:11 / cg"
@@ -1072,6 +1248,7 @@
     inputField selectAllInitially.
     inputField immediateAccept:true.
     inputField takeFocus.
+    inputField helpKey:#searchPatternField.
 
     searchWhat == #string ifFalse:[
         inputField 
@@ -1113,6 +1290,7 @@
 
     box := View new.
     box extent:(600 @ 200).
+    box helpKey:#codeEntryField.
 
     panel := VariableHorizontalPanel in:box.
     panel origin:0.0@0.0 corner:(1.0@1.0).