14111
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2000 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
DialogBox subclass:#SearchDialog
|
|
17 |
instanceVariableNames:'openHow classes methods selectedClasses selectedCategories
|
|
18 |
selectedMethods selectedPackages currentClass currentNamespace
|
|
19 |
currentClassCategory currentPackage browser whereRadioGroup
|
|
20 |
currentPanel searchAreas caseHolder matchHolder isMethodHolder
|
|
21 |
codeField selectorHolder defaultOpenHow withTextEntry allowFind
|
|
22 |
allowBuffer allowBrowser searchWhat searchClassProtocolHolder
|
|
23 |
searchInstanceProtocolHolder selectorOrCode selectionList
|
|
24 |
listHolder matchProcess inputField showMetaFilter
|
|
25 |
metaclassesOnlyHolder classesOnlyHolder'
|
|
26 |
classVariableNames:'LastCodeSearched LastCodeSearchWasMethod LastGlobalSearched
|
|
27 |
LastStringSearched LastSearchWasMatch LastSearchWasCaseSensitive
|
|
28 |
LastStringSearchArea LastCodeSearchArea AREA_LISTOFMETHODS
|
|
29 |
LastResourceSearched'
|
|
30 |
poolDictionaries:''
|
|
31 |
category:'Interface-Browsers-New'
|
|
32 |
!
|
|
33 |
|
|
34 |
!SearchDialog class methodsFor:'documentation'!
|
|
35 |
|
|
36 |
copyright
|
|
37 |
"
|
|
38 |
COPYRIGHT (c) 2000 by eXept Software AG
|
|
39 |
All Rights Reserved
|
|
40 |
|
|
41 |
This software is furnished under a license and may be used
|
|
42 |
only in accordance with the terms of that license and with the
|
|
43 |
inclusion of the above copyright notice. This software may not
|
|
44 |
be provided or otherwise made available to, or used by, any
|
|
45 |
other person. No title to or ownership of the software is
|
|
46 |
hereby transferred.
|
|
47 |
"
|
|
48 |
! !
|
|
49 |
|
|
50 |
!SearchDialog class methodsFor:'initialization'!
|
|
51 |
|
|
52 |
initialize
|
|
53 |
AREA_LISTOFMETHODS := #listOfMethods
|
|
54 |
|
|
55 |
"Created: / 19-11-2010 / 12:00:18 / cg"
|
|
56 |
! !
|
|
57 |
|
|
58 |
!SearchDialog class methodsFor:'constants'!
|
|
59 |
|
|
60 |
constantForListOfMethodsArea
|
|
61 |
^ AREA_LISTOFMETHODS
|
|
62 |
|
|
63 |
"Created: / 19-11-2010 / 12:11:50 / cg"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!SearchDialog class methodsFor:'queries'!
|
|
67 |
|
|
68 |
lastCodeSearchArea
|
|
69 |
^ LastCodeSearchArea
|
|
70 |
!
|
|
71 |
|
|
72 |
lastStringSearchArea
|
|
73 |
^ LastStringSearchArea
|
|
74 |
! !
|
|
75 |
|
|
76 |
!SearchDialog methodsFor:'accessing'!
|
|
77 |
|
|
78 |
currentPackage
|
|
79 |
^ currentPackage
|
|
80 |
!
|
|
81 |
|
|
82 |
showMetaFilter:something
|
|
83 |
showMetaFilter := something.
|
|
84 |
! !
|
|
85 |
|
|
86 |
!SearchDialog methodsFor:'accessing-entered values'!
|
|
87 |
|
|
88 |
classesOnly
|
|
89 |
^ (classesOnlyHolder ? false) value
|
|
90 |
|
|
91 |
"Created: / 20-08-2012 / 13:25:26 / cg"
|
|
92 |
!
|
|
93 |
|
|
94 |
classesToSearch
|
|
95 |
^ classes.
|
|
96 |
!
|
|
97 |
|
|
98 |
codeToSearch
|
|
99 |
^ selectorOrCode.
|
|
100 |
!
|
|
101 |
|
|
102 |
matchMethods
|
|
103 |
^ isMethodHolder value ? false.
|
|
104 |
!
|
|
105 |
|
|
106 |
metaclassesOnly
|
|
107 |
^ (metaclassesOnlyHolder ? false) value
|
|
108 |
|
|
109 |
"Created: / 20-08-2012 / 13:17:12 / cg"
|
|
110 |
!
|
|
111 |
|
|
112 |
methodsToSearch
|
|
113 |
^ methods.
|
|
114 |
!
|
|
115 |
|
|
116 |
openHow
|
|
117 |
^ openHow.
|
|
118 |
!
|
|
119 |
|
|
120 |
searchAreaSelected
|
|
121 |
^ whereRadioGroup value.
|
|
122 |
!
|
|
123 |
|
|
124 |
searchIgnoringCase
|
|
125 |
^ self searchIsCaseSensitive not
|
|
126 |
!
|
|
127 |
|
|
128 |
searchIsCaseSensitive
|
|
129 |
^ (caseHolder value ? false)
|
|
130 |
!
|
|
131 |
|
|
132 |
searchWithMatch
|
|
133 |
^ matchHolder value ? false.
|
|
134 |
!
|
|
135 |
|
|
136 |
selectorToSearch
|
|
137 |
^ selectorOrCode.
|
|
138 |
! !
|
|
139 |
|
|
140 |
!SearchDialog methodsFor:'obsolete'!
|
|
141 |
|
|
142 |
addCheckBoxForClassMethodSearch
|
|
143 |
|b|
|
|
144 |
|
|
145 |
b := CheckBox label:(resources string:'Class Protocol').
|
|
146 |
b model:(self searchClassProtocolHolder).
|
|
147 |
currentPanel add:b.
|
|
148 |
^ b.
|
|
149 |
!
|
|
150 |
|
|
151 |
addCheckBoxForInstanceMethodSearch
|
|
152 |
|b|
|
|
153 |
|
|
154 |
b := CheckBox label:(resources string:'Instance Protocol').
|
|
155 |
b model:(self searchInstanceProtocolHolder).
|
|
156 |
currentPanel add:b.
|
|
157 |
^ b.
|
|
158 |
! !
|
|
159 |
|
|
160 |
!SearchDialog methodsFor:'private'!
|
|
161 |
|
|
162 |
searchClassProtocolHolder
|
|
163 |
searchClassProtocolHolder isNil ifTrue:[
|
|
164 |
searchClassProtocolHolder := true asValue
|
|
165 |
].
|
|
166 |
^ searchClassProtocolHolder
|
|
167 |
!
|
|
168 |
|
|
169 |
searchInstanceProtocolHolder
|
|
170 |
searchInstanceProtocolHolder isNil ifTrue:[
|
|
171 |
searchInstanceProtocolHolder := true asValue
|
|
172 |
].
|
|
173 |
^ searchInstanceProtocolHolder
|
|
174 |
!
|
|
175 |
|
|
176 |
showHelpOnCodePatterns
|
|
177 |
HTMLDocumentView openFullOnHelpFile:'Browser/RBSearchPatterns.html'
|
|
178 |
!
|
|
179 |
|
|
180 |
updateListOfMatchingSelectorsFor:s
|
|
181 |
|p|
|
|
182 |
|
|
183 |
(p := matchProcess) notNil ifTrue:[
|
|
184 |
p terminate.
|
|
185 |
].
|
|
186 |
listHolder isNil ifTrue:[^ self].
|
|
187 |
|
|
188 |
matchProcess :=
|
|
189 |
[
|
|
190 |
|what matching|
|
|
191 |
|
|
192 |
[
|
|
193 |
searchWhat == #globalName ifFalse:[
|
|
194 |
what := DoWhatIMeanSupport selectorCompletion:s inEnvironment:Smalltalk match:(matchHolder value) ignoreCase:(caseHolder value not)
|
|
195 |
] ifTrue:[
|
|
196 |
what := DoWhatIMeanSupport globalNameCompletion:s inEnvironment:Smalltalk match:(matchHolder value).
|
|
197 |
].
|
|
198 |
"/ best := what first.
|
|
199 |
matching := what second.
|
|
200 |
self sensor pushAction:[ listHolder contents:matching ].
|
|
201 |
] ensure:[
|
|
202 |
matchProcess := nil.
|
|
203 |
].
|
|
204 |
] fork.
|
|
205 |
|
|
206 |
"Modified: / 26-10-2010 / 20:33:05 / cg"
|
|
207 |
! !
|
|
208 |
|
|
209 |
!SearchDialog methodsFor:'public'!
|
|
210 |
|
|
211 |
addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch
|
|
212 |
|initialMatch initialCaseSensitive|
|
|
213 |
|
|
214 |
matchHolder := caseHolder := nil.
|
|
215 |
|
|
216 |
searchWhat == #code ifTrue:[
|
|
217 |
self addTextEntryFieldForCode.
|
|
218 |
^ self.
|
|
219 |
].
|
|
220 |
|
|
221 |
self addInputFieldForSelectorOrNameOrString.
|
|
222 |
withCaseIgnore ifTrue:[
|
14112
|
223 |
initialCaseSensitive := false.
|
|
224 |
(searchWhat ~~ #resource) ifTrue:[
|
|
225 |
initialCaseSensitive := (LastSearchWasCaseSensitive ? false)
|
|
226 |
].
|
14111
|
227 |
self
|
|
228 |
addCheckBox:(resources string:'Case Sensitive')
|
|
229 |
on:(caseHolder := initialCaseSensitive asValue).
|
|
230 |
].
|
|
231 |
withMatch ifTrue:[
|
14112
|
232 |
initialMatch := true.
|
|
233 |
(searchWhat ~~ #resource) ifTrue:[
|
|
234 |
initialMatch := (LastSearchWasMatch ? true)
|
|
235 |
].
|
14111
|
236 |
self
|
|
237 |
addCheckBox:(resources string:'Match')
|
|
238 |
on:(matchHolder := initialMatch asValue).
|
|
239 |
"/ (isSelector and:[ sel notNil. ]) ifTrue:[
|
|
240 |
"/ sel includesMatchCharacters ifTrue:[
|
|
241 |
"/ matchHolder value:false.
|
|
242 |
"/ ].
|
|
243 |
"/ ].
|
|
244 |
]
|
|
245 |
|
|
246 |
"Modified (format): / 06-07-2011 / 11:56:31 / cg"
|
|
247 |
!
|
|
248 |
|
|
249 |
askThenDo:aBlock
|
|
250 |
|where code sel matchHolderValue caseHolderValue|
|
|
251 |
|
|
252 |
self beScreenDialog. "raise it above all windows"
|
|
253 |
self open.
|
|
254 |
self accepted ifFalse:[
|
|
255 |
^ self.
|
|
256 |
].
|
|
257 |
|
|
258 |
openHow isNil ifTrue:[
|
|
259 |
openHow := defaultOpenHow.
|
|
260 |
].
|
|
261 |
where := whereRadioGroup value.
|
|
262 |
withTextEntry ifTrue:[
|
|
263 |
searchWhat == #code ifTrue:[
|
|
264 |
code := codeField contentsAsString.
|
|
265 |
LastCodeSearched := code.
|
|
266 |
LastCodeSearchArea := where.
|
|
267 |
] ifFalse:[
|
|
268 |
(selectionList notNil and:[selectionList hasSelection]) ifTrue:[
|
|
269 |
sel := selectionList selectionValue.
|
|
270 |
] ifFalse:[
|
|
271 |
sel := selectorHolder value withoutSeparators.
|
|
272 |
].
|
|
273 |
sel isEmptyOrNil ifTrue:[
|
|
274 |
browser warn:((searchWhat == #selector)
|
|
275 |
ifTrue:[ 'No selector entered for search'. ]
|
|
276 |
ifFalse:[ 'Nothing entered for search'. ]).
|
|
277 |
^ self.
|
|
278 |
].
|
|
279 |
sel := sel string.
|
|
280 |
|
|
281 |
(browser ? SystemBrowser) rememberSearchPattern:sel.
|
|
282 |
searchWhat == #globalName ifTrue:[
|
|
283 |
LastGlobalSearched := sel.
|
|
284 |
] ifFalse:[
|
|
285 |
searchWhat == #string ifTrue:[
|
|
286 |
LastStringSearched := sel.
|
|
287 |
LastStringSearchArea := where.
|
|
288 |
] ifFalse:[
|
|
289 |
(sel startsWith:'#''') ifTrue:[
|
|
290 |
sel := sel copyFrom:3.
|
|
291 |
(sel endsWith:$') ifTrue:[
|
|
292 |
sel := sel copyButLast:1.
|
|
293 |
].
|
|
294 |
].
|
|
295 |
]
|
|
296 |
]
|
|
297 |
].
|
|
298 |
].
|
|
299 |
where isNil ifTrue:[
|
|
300 |
(browser ? Dialog) warn:'No class(es) for search'.
|
|
301 |
^ self.
|
|
302 |
].
|
|
303 |
self getClassesAndMethodsFor:where.
|
|
304 |
|
|
305 |
(#(#classesWithPrivateClasses #classHierarchiesWithPrivateClasses #ownersWithPrivateClasses #ownersHierarchiesWithPrivateClasses)
|
|
306 |
includes:where)
|
|
307 |
ifTrue:[
|
|
308 |
|toSearch|
|
|
309 |
|
|
310 |
toSearch := IdentitySet withAll:classes.
|
|
311 |
classes := IdentitySet withAll:toSearch.
|
|
312 |
[ toSearch notEmpty ] whileTrue:[
|
|
313 |
|cls|
|
|
314 |
|
|
315 |
cls := toSearch removeFirst.
|
|
316 |
classes addAll:cls allPrivateClasses.
|
|
317 |
].
|
|
318 |
].
|
|
319 |
|
|
320 |
classes size == 0 ifTrue:[
|
|
321 |
classes := nil.
|
|
322 |
methods size == 0 ifTrue:[
|
|
323 |
(browser ? Dialog) warn:'No class(es) given for search.'.
|
|
324 |
^ self.
|
|
325 |
].
|
|
326 |
] ifFalse:[
|
|
327 |
classes := classes asOrderedCollection.
|
|
328 |
methods size ~~ 0 ifTrue:[
|
|
329 |
(browser ? Dialog) warn:'oops'.
|
|
330 |
methods := nil.
|
|
331 |
].
|
|
332 |
].
|
|
333 |
|
|
334 |
matchHolderValue := matchHolder value.
|
|
335 |
matchHolderValue notNil ifTrue:[
|
|
336 |
LastSearchWasMatch := matchHolderValue
|
|
337 |
].
|
|
338 |
caseHolderValue := caseHolder value.
|
|
339 |
caseHolderValue notNil ifTrue:[
|
|
340 |
LastSearchWasCaseSensitive := caseHolderValue
|
|
341 |
].
|
|
342 |
|
|
343 |
selectorOrCode := sel ? code.
|
|
344 |
|
|
345 |
aBlock numArgs == 7 ifTrue:[
|
|
346 |
"/ old style
|
|
347 |
aBlock
|
|
348 |
value:classes
|
|
349 |
value:(sel ? code)
|
|
350 |
value:(self searchIgnoringCase)
|
|
351 |
value:openHow
|
|
352 |
value:(matchHolderValue ? false)
|
|
353 |
value:methods
|
|
354 |
value:(isMethodHolder value ? false).
|
|
355 |
] ifFalse:[
|
|
356 |
aBlock value.
|
|
357 |
]
|
|
358 |
|
|
359 |
"Modified: / 26-09-2012 / 11:50:45 / cg"
|
|
360 |
!
|
|
361 |
|
|
362 |
setupToAskForMethodSearchTitle:title forBrowser:brwsrArg searchWhat:searchWhatArg
|
|
363 |
searchArea:whereDefault withCaseIgnore:withCaseIgnore withMatch:withMatch
|
|
364 |
withMethodList:withMethodList allowFind:allowFindArg allowBuffer:allowBufferArg
|
|
365 |
allowBrowser:allowBrowserArg withTextEntry:withTextEntryArg
|
|
366 |
|
|
367 |
|where ns methodNameSpaces methodPackages hPanel leftVerticalPanel rightVerticalPanel|
|
|
368 |
|
|
369 |
allowFind := allowFindArg.
|
|
370 |
allowBuffer := allowBufferArg.
|
|
371 |
allowBrowser := allowBrowserArg.
|
|
372 |
searchWhat := searchWhatArg.
|
|
373 |
|
|
374 |
withTextEntry := withTextEntryArg.
|
|
375 |
|
|
376 |
(browser := brwsrArg) isNil ifTrue:[
|
|
377 |
resources := NewSystemBrowser classResources.
|
|
378 |
] ifFalse:[
|
|
379 |
resources := browser resources.
|
|
380 |
selectedClasses := browser selectedClasses value.
|
|
381 |
selectedCategories := browser selectedCategoriesValue.
|
|
382 |
selectedCategories := selectedCategories reject:[:cat | NavigatorModel isPseudoCategory:cat].
|
|
383 |
selectedMethods := browser selectedMethods value.
|
|
384 |
currentClass := browser theSingleSelectedClass.
|
|
385 |
currentClassCategory := browser theSingleSelectedCategory.
|
|
386 |
currentPackage := browser theSingleSelectedProject.
|
|
387 |
currentClass isNil ifTrue:[
|
|
388 |
browser hasMethodSelected ifTrue:[
|
|
389 |
currentClass := selectedMethods first mclass.
|
|
390 |
"/ selectedClasses := (selectedMethods collect:[:each | each mclass ]) asIdentitySet.
|
|
391 |
"/ selectedClasses := selectedClasses select:[:each | each notNil ].
|
|
392 |
].
|
|
393 |
].
|
|
394 |
].
|
|
395 |
|
|
396 |
(self addTextLabel:(resources stringWithCRs:title)) adjust:#left.
|
|
397 |
|
|
398 |
currentClass notNil ifTrue:[
|
|
399 |
currentClass := currentClass theNonMetaclass.
|
|
400 |
].
|
|
401 |
withTextEntry ifTrue:[
|
|
402 |
self addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch.
|
|
403 |
].
|
|
404 |
|
|
405 |
searchAreas := OrderedCollection new.
|
|
406 |
|
|
407 |
self addHorizontalLine.
|
|
408 |
"/ self addVerticalSpace.
|
|
409 |
|
|
410 |
(showMetaFilter ? false) ifTrue:[
|
|
411 |
currentPanel := self.
|
|
412 |
self addCheckBoxForMetaClassesOnly.
|
|
413 |
].
|
|
414 |
|
|
415 |
|
|
416 |
hPanel := HorizontalPanelView "SimpleView" new.
|
|
417 |
hPanel verticalLayout:#top.
|
|
418 |
hPanel horizontalLayout:#left.
|
|
419 |
|
|
420 |
leftVerticalPanel := currentPanel := VerticalPanelView new.
|
|
421 |
leftVerticalPanel verticalLayout:#topSpace.
|
|
422 |
leftVerticalPanel horizontalLayout:#fitSpace.
|
|
423 |
|
|
424 |
(self addTextLabel:(resources string:'Search in:')) adjust:#left.
|
|
425 |
|
|
426 |
whereRadioGroup := RadioButtonGroup new.
|
|
427 |
|
|
428 |
(selectedCategories size > 0 or:[ selectedClasses size > 0 ]) ifTrue:[
|
|
429 |
self addCheckBoxForEverywhere.
|
|
430 |
"/ classMethodListView notNil ifTrue:[
|
|
431 |
"/ b := CheckBox label:(resources string:'Shown Methods').
|
|
432 |
"/ panel add:b. whereChannel add:b value:#currentMethodList.
|
|
433 |
"/ areas add:#currentMethodList.
|
|
434 |
"/ self makeTabable:b.
|
|
435 |
"/ ].
|
|
436 |
browser isMethodListBrowser ifTrue:[
|
|
437 |
methods := browser selectedMethods value ? #().
|
|
438 |
methodNameSpaces := methods
|
|
439 |
select:[:eachMethod | eachMethod mclass notNil]
|
|
440 |
thenCollect:[:eachMethod | eachMethod mclass topNameSpace ].
|
|
441 |
methodPackages := methods
|
|
442 |
collect:[:eachMethod | eachMethod package ].
|
|
443 |
].
|
|
444 |
methodNameSpaces size == 1 ifTrue:[
|
|
445 |
currentNamespace := methodNameSpaces first.
|
|
446 |
] ifFalse:[
|
|
447 |
currentNamespace := browser currentNamespace.
|
|
448 |
selectedClasses size == 0 ifTrue:[
|
|
449 |
|classesInAllSelectedCategories nameSpacesOfAllClassesInAllSelectedCategories|
|
|
450 |
classesInAllSelectedCategories := Smalltalk allClasses select:[:cls | selectedCategories includes:cls category].
|
|
451 |
nameSpacesOfAllClassesInAllSelectedCategories := classesInAllSelectedCategories collect:[:eachClass | eachClass topNameSpace].
|
|
452 |
nameSpacesOfAllClassesInAllSelectedCategories size == 1 ifTrue:[
|
|
453 |
currentNamespace := nameSpacesOfAllClassesInAllSelectedCategories first.
|
|
454 |
].
|
|
455 |
].
|
|
456 |
].
|
|
457 |
|
|
458 |
(currentNamespace notNil
|
|
459 |
and:[ currentNamespace ~= (browser nameListEntryForALL) ])
|
|
460 |
ifTrue:[ self addCheckBoxForCurrentNamespace ]
|
|
461 |
ifFalse:[
|
|
462 |
(currentClass notNil
|
|
463 |
and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ])
|
|
464 |
ifTrue:[ self addCheckBoxForClassesNamespace:ns ].
|
|
465 |
].
|
|
466 |
|
|
467 |
methodPackages size == 1 ifTrue:[
|
|
468 |
currentPackage := methodPackages first.
|
|
469 |
] ifFalse:[
|
|
470 |
currentPackage := browser currentProject.
|
|
471 |
"/ selectedClasses size == 0 ifTrue:[
|
|
472 |
"/ |classesInAllSelectedCategories packagesOfAllClassesInAllSelectedCategories|
|
|
473 |
"/ classesInAllSelectedCategories := Smalltalk allClasses select:[:cls | selectedCategories includes:cls category].
|
|
474 |
"/ packagesOfAllClassesInAllSelectedCategories := classesInAllSelectedCategories collect:[:eachClass | eachClass package].
|
|
475 |
"/ packagesOfAllClassesInAllSelectedCategories size == 1 ifTrue:[
|
|
476 |
"/ currentPackage := packagesOfAllClassesInAllSelectedCategories first.
|
|
477 |
"/ ].
|
|
478 |
"/ ].
|
|
479 |
].
|
|
480 |
|
|
481 |
(currentPackage notNil
|
|
482 |
and:[ currentPackage ~= (browser nameListEntryForALL) ])
|
|
483 |
ifTrue:[ self addCheckBoxForCurrentPackage ]
|
|
484 |
ifFalse:[
|
|
485 |
(currentClass notNil) ifTrue:[
|
|
486 |
self addCheckBoxForClassesPackage:(currentClass package)
|
|
487 |
].
|
|
488 |
].
|
|
489 |
|
|
490 |
selectedCategories size > 0 ifTrue:[
|
|
491 |
self addCheckBoxForSelectedClassCategory.
|
|
492 |
].
|
|
493 |
(selectedClasses size > 0 or:[ selectedMethods size > 0 ]) ifTrue:[
|
|
494 |
self addCheckBoxForSelectedClass.
|
|
495 |
self addCheckBoxForSelectedClassAndSuperclasses.
|
|
496 |
self addCheckBoxForSelectedClassAndSubclasses.
|
|
497 |
self addCheckBoxForSelectedClassAndPrivateClasses.
|
|
498 |
self addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses.
|
|
499 |
self addCheckBoxForOwnerAndItsPrivateClasses.
|
|
500 |
self addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses.
|
|
501 |
].
|
|
502 |
] ifFalse:[
|
|
503 |
(browser notNil and:[browser currentNamespace ~~ Smalltalk]) ifTrue:[
|
|
504 |
self addCheckBoxForEverywhere.
|
|
505 |
currentNamespace := browser currentNamespace.
|
|
506 |
currentNamespace ~= (browser nameListEntryForALL) ifTrue:[
|
|
507 |
self addCheckBoxForCurrentNamespace.
|
|
508 |
] ifFalse:[
|
|
509 |
(currentClass notNil
|
|
510 |
and:[ (ns := currentClass nameSpace) notNil
|
|
511 |
and:[ ns ~~ Smalltalk ] ])
|
|
512 |
ifTrue:[
|
|
513 |
self addCheckBoxForClassesNamespace:ns
|
|
514 |
].
|
|
515 |
].
|
|
516 |
].
|
|
517 |
].
|
|
518 |
searchAreas size == 0 ifTrue:[
|
|
519 |
self addCheckBoxForEverywhere.
|
|
520 |
].
|
|
521 |
self addCheckBoxForChangedClassesList.
|
|
522 |
|
|
523 |
withMethodList ifTrue:[
|
|
524 |
browser isMethodListBrowser ifTrue:[
|
|
525 |
searchAreas size == 0 ifTrue:[
|
|
526 |
self addCheckBoxForEverywhere.
|
|
527 |
].
|
|
528 |
self addCheckBoxForMethodList.
|
|
529 |
self addCheckBoxForSelectedMethods.
|
|
530 |
self addCheckBoxForSelectedMethodClasses.
|
|
531 |
self addCheckBoxForSelectedMethodPackages.
|
|
532 |
] ifFalse:[
|
|
533 |
searchAreas size == 0 ifTrue:[
|
|
534 |
self addCheckBoxForEverywhere.
|
|
535 |
].
|
|
536 |
self addCheckBoxForChangedMethodList.
|
|
537 |
].
|
|
538 |
].
|
|
539 |
|
|
540 |
searchAreas size == 0 ifTrue:[
|
|
541 |
whereRadioGroup := #everywhere asValue.
|
|
542 |
self addDummyCheckBoxForEverywhere.
|
|
543 |
] ifFalse:[
|
|
544 |
whereDefault notNil ifTrue:[
|
|
545 |
(searchAreas includes:whereDefault) ifTrue:[
|
|
546 |
where := whereDefault asSymbol.
|
|
547 |
] ifFalse:[
|
|
548 |
where := searchAreas first.
|
|
549 |
].
|
|
550 |
] ifFalse:[
|
|
551 |
where := #everywhere.
|
|
552 |
].
|
|
553 |
whereRadioGroup value:where.
|
|
554 |
].
|
|
555 |
|
|
556 |
hPanel add:leftVerticalPanel.
|
|
557 |
|
|
558 |
false ifTrue:[
|
|
559 |
"/ noone liked the right panel...
|
|
560 |
rightVerticalPanel := currentPanel := VerticalPanelView new.
|
|
561 |
rightVerticalPanel verticalLayout:#topSpace.
|
|
562 |
rightVerticalPanel horizontalLayout:#fitSpace.
|
|
563 |
|
|
564 |
self addCheckBoxForClassMethodSearch.
|
|
565 |
self addCheckBoxForInstanceMethodSearch.
|
|
566 |
"/ rightVerticalPanel origin:0.75@0.0 corner:1.0@1.0.
|
|
567 |
hPanel
|
|
568 |
preferredExtent:(leftVerticalPanel preferredWidth + rightVerticalPanel preferredWidth)
|
|
569 |
@
|
|
570 |
(leftVerticalPanel preferredHeight max:rightVerticalPanel preferredHeight).
|
|
571 |
hPanel add:rightVerticalPanel.
|
|
572 |
] ifFalse:[
|
|
573 |
|
|
574 |
"/ rightVerticalPanel origin:0.75@0.0 corner:1.0@1.0.
|
|
575 |
hPanel
|
|
576 |
preferredExtent:(leftVerticalPanel preferredWidth) @ (leftVerticalPanel preferredHeight).
|
|
577 |
].
|
|
578 |
|
|
579 |
self addComponent:hPanel indent:0.
|
|
580 |
|
|
581 |
"/ panel has its own idea of indenting
|
|
582 |
"/ self addVerticalSpace.
|
|
583 |
searchWhat == #selector ifTrue:[
|
|
584 |
"/ not yet implemented
|
|
585 |
"/ self addHorizontalLine.
|
|
586 |
"/ self addCheckBoxesForClassAndMetaSearch.
|
|
587 |
|
|
588 |
selectionList := self addFilteredListOfMatchingSelectors.
|
|
589 |
self stickAtBottomWithVariableHeight:selectionList.
|
|
590 |
matchHolder notNil ifTrue:[
|
|
591 |
matchHolder onChangeEvaluate:[ self updateListOfMatchingSelectorsFor:inputField contents ]
|
|
592 |
].
|
|
593 |
inputField notNil ifTrue:[ self updateListOfMatchingSelectorsFor:inputField contents ].
|
|
594 |
] ifFalse:[
|
|
595 |
self addHorizontalLine.
|
|
596 |
].
|
|
597 |
self addButtons.
|
|
598 |
|
|
599 |
self label:(resources string:'Search').
|
|
600 |
|
|
601 |
"Modified: / 20-08-2012 / 13:25:03 / cg"
|
|
602 |
! !
|
|
603 |
|
|
604 |
!SearchDialog methodsFor:'setup'!
|
|
605 |
|
|
606 |
addCheckBox:b forSearchArea:area
|
|
607 |
currentPanel add:b.
|
|
608 |
whereRadioGroup add:b value:area.
|
|
609 |
searchAreas add:area.
|
|
610 |
self makeTabable:b.
|
|
611 |
!
|
|
612 |
|
|
613 |
addCheckBoxForChangedClassesList
|
|
614 |
|b|
|
|
615 |
|
|
616 |
b := CheckBox label:(resources string:'Changed Classes').
|
|
617 |
self addCheckBox:b forSearchArea:#listOfChangedClasses.
|
|
618 |
ChangeSet current changedClasses isEmpty ifTrue:[
|
|
619 |
b disable
|
|
620 |
].
|
|
621 |
^ b.
|
|
622 |
!
|
|
623 |
|
|
624 |
addCheckBoxForChangedMethodList
|
|
625 |
|b|
|
|
626 |
|
|
627 |
b := CheckBox label:(resources string:'Changed Methods').
|
|
628 |
self addCheckBox:b forSearchArea:#listOfChangedMethods.
|
|
629 |
ChangeSet current changeSelectors isEmpty ifTrue:[
|
|
630 |
b disable
|
|
631 |
].
|
|
632 |
^ b.
|
|
633 |
!
|
|
634 |
|
|
635 |
addCheckBoxForClassesNamespace:ns
|
|
636 |
|b|
|
|
637 |
|
|
638 |
b := CheckBox
|
|
639 |
label:(resources string:'Classes'' nameSpace ("%1")' with:ns name).
|
|
640 |
self addCheckBox:b forSearchArea:#currentClassesNameSpace.
|
|
641 |
^ b.
|
|
642 |
!
|
|
643 |
|
|
644 |
addCheckBoxForClassesPackage:pkg
|
|
645 |
|b|
|
|
646 |
|
|
647 |
b := CheckBox
|
|
648 |
label:(resources string:'Classes'' package ("%1")' with:pkg).
|
|
649 |
self addCheckBox:b forSearchArea:#currentClassesPackage.
|
|
650 |
^ b.
|
|
651 |
|
|
652 |
"Created: / 21-09-2006 / 17:39:55 / cg"
|
|
653 |
!
|
|
654 |
|
|
655 |
addCheckBoxForCurrentNamespace
|
|
656 |
|b|
|
|
657 |
|
|
658 |
b := CheckBox
|
|
659 |
label:(resources string:'Current nameSpace ("%1")' with:currentNamespace name).
|
|
660 |
self addCheckBox:b forSearchArea:#currentNameSpace.
|
|
661 |
^ b.
|
|
662 |
|
|
663 |
"Modified: / 10-10-2006 / 15:28:47 / cg"
|
|
664 |
!
|
|
665 |
|
|
666 |
addCheckBoxForCurrentPackage
|
|
667 |
|b|
|
|
668 |
|
|
669 |
b := CheckBox
|
|
670 |
label:(resources string:'Current package ("%1")' with:currentPackage).
|
|
671 |
self addCheckBox:b forSearchArea:#currentPackage.
|
|
672 |
^ b.
|
|
673 |
|
|
674 |
"Modified: / 10-10-2006 / 15:28:51 / cg"
|
|
675 |
!
|
|
676 |
|
|
677 |
addCheckBoxForCurrentPackage:pkg
|
|
678 |
|b|
|
|
679 |
|
|
680 |
b := CheckBox
|
|
681 |
label:(resources string:'Classes'' package ("%1")' with:pkg).
|
|
682 |
self addCheckBox:b forSearchArea:#currentClassesPackage.
|
|
683 |
^ b.
|
|
684 |
|
|
685 |
"Modified: / 10-10-2006 / 15:29:06 / cg"
|
|
686 |
!
|
|
687 |
|
|
688 |
addCheckBoxForEverywhere
|
|
689 |
|b|
|
|
690 |
|
|
691 |
b := CheckBox label:(resources string:'Everywhere').
|
|
692 |
self addCheckBox:b forSearchArea:#everywhere.
|
|
693 |
^ b.
|
|
694 |
!
|
|
695 |
|
|
696 |
addCheckBoxForMetaClassesOnly
|
|
697 |
|p b|
|
|
698 |
|
|
699 |
p := View new.
|
|
700 |
|
|
701 |
b := CheckBox label:(resources string:'Metaclasses Only') in:p.
|
|
702 |
b model:(metaclassesOnlyHolder := false asValue).
|
|
703 |
metaclassesOnlyHolder onChangeEvaluate:[metaclassesOnlyHolder value ifTrue:[classesOnlyHolder value:false]].
|
|
704 |
self makeTabable:b.
|
|
705 |
|
|
706 |
b := CheckBox label:(resources string:'Classes Only') in:p.
|
|
707 |
b left:0.5.
|
|
708 |
b model:(classesOnlyHolder := false asValue).
|
|
709 |
classesOnlyHolder onChangeEvaluate:[classesOnlyHolder value ifTrue:[metaclassesOnlyHolder value:false]].
|
|
710 |
self makeTabable:b.
|
|
711 |
|
|
712 |
currentPanel add:p.
|
|
713 |
^ nil.
|
|
714 |
|
|
715 |
"Created: / 20-08-2012 / 11:32:15 / cg"
|
|
716 |
!
|
|
717 |
|
|
718 |
addCheckBoxForMethodList
|
|
719 |
|b|
|
|
720 |
|
|
721 |
b := CheckBox label:(resources string:'Methodlist').
|
|
722 |
self addCheckBox:b forSearchArea:AREA_LISTOFMETHODS.
|
|
723 |
^ b.
|
|
724 |
|
|
725 |
"Modified: / 19-11-2010 / 12:00:52 / cg"
|
|
726 |
!
|
|
727 |
|
|
728 |
addCheckBoxForOwnerAndItsPrivateClasses
|
|
729 |
|b lbl arg|
|
|
730 |
|
|
731 |
(currentClass notNil and:[ currentClass isPrivate. ]) ifTrue:[
|
|
732 |
lbl := 'Owner (%1) & all its private classes'.
|
|
733 |
arg := currentClass owningClass name.
|
|
734 |
] ifFalse:[
|
|
735 |
lbl := 'Owners & all their private classes'.
|
|
736 |
].
|
|
737 |
b := CheckBox label:(resources string:lbl with:arg).
|
|
738 |
self addCheckBox:b forSearchArea:#ownersWithPrivateClasses.
|
|
739 |
(selectedClasses contains:[ :cls | cls isPrivate. ]) ifFalse:[
|
|
740 |
b disable.
|
|
741 |
].
|
|
742 |
^ b.
|
|
743 |
!
|
|
744 |
|
|
745 |
addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses
|
|
746 |
|b lbl arg|
|
|
747 |
|
|
748 |
(currentClass notNil and:[ currentClass isPrivate. ]) ifTrue:[
|
|
749 |
lbl := 'Owner (%1) & its subclasses & all its private classes'.
|
|
750 |
arg := currentClass owningClass name.
|
|
751 |
] ifFalse:[
|
|
752 |
lbl := 'Owners & their subclasses & all their private classes'.
|
|
753 |
].
|
|
754 |
b := CheckBox label:(resources string:lbl with:arg).
|
|
755 |
self addCheckBox:b forSearchArea:#ownersHierarchiesWithPrivateClasses.
|
|
756 |
(selectedClasses contains:[ :cls | cls isPrivate. ]) ifFalse:[
|
|
757 |
b disable.
|
|
758 |
].
|
|
759 |
^ b.
|
|
760 |
!
|
|
761 |
|
|
762 |
addCheckBoxForSelectedClass
|
|
763 |
|b lbl arg|
|
|
764 |
|
|
765 |
(browser isMethodListBrowser
|
|
766 |
or:[ currentClass isNil
|
|
767 |
or:[ selectedClasses size > 1] ]) ifTrue:[
|
|
768 |
selectedClasses size == 1 ifTrue:[
|
|
769 |
lbl := 'Selected class ("%1")'.
|
|
770 |
arg := selectedClasses first theNonMetaclass name.
|
|
771 |
] ifFalse:[
|
|
772 |
lbl := 'Selected classes (%1)'.
|
|
773 |
arg := selectedClasses size.
|
|
774 |
].
|
|
775 |
] ifFalse:[
|
|
776 |
lbl := 'Class ("%1")'.
|
|
777 |
arg := currentClass name.
|
|
778 |
].
|
|
779 |
b := CheckBox label:(resources string:lbl with:arg).
|
|
780 |
self addCheckBox:b forSearchArea:#classes.
|
|
781 |
^ b.
|
|
782 |
!
|
|
783 |
|
|
784 |
addCheckBoxForSelectedClassAndPrivateClasses
|
|
785 |
|b lbl|
|
|
786 |
|
|
787 |
(browser isMethodListBrowser
|
|
788 |
or:[ currentClass isNil
|
|
789 |
or:[ selectedClasses size > 1] ]) ifTrue:[
|
|
790 |
lbl := 'Selected classes & all private classes'.
|
|
791 |
] ifFalse:[
|
|
792 |
lbl := 'Class & private classes'.
|
|
793 |
].
|
|
794 |
b := CheckBox label:(resources string:lbl).
|
|
795 |
self addCheckBox:b forSearchArea:#classesWithPrivateClasses.
|
|
796 |
(selectedClasses
|
|
797 |
contains:[ :cls | cls theNonMetaclass privateClasses size > 0. ])
|
|
798 |
ifFalse:[ b disable. ].
|
|
799 |
^ b.
|
|
800 |
!
|
|
801 |
|
|
802 |
addCheckBoxForSelectedClassAndSubclasses
|
|
803 |
|b lbl|
|
|
804 |
|
|
805 |
(browser isMethodListBrowser
|
|
806 |
or:[ currentClass isNil
|
|
807 |
or:[ selectedClasses size > 1] ]) ifTrue:[
|
|
808 |
lbl := 'Selected classes & all subclasses'.
|
|
809 |
] ifFalse:[
|
|
810 |
lbl := 'Class & subclasses'.
|
|
811 |
].
|
|
812 |
b := CheckBox label:(resources string:lbl).
|
|
813 |
self addCheckBox:b forSearchArea:#classHierarchies.
|
|
814 |
(selectedClasses
|
|
815 |
contains:[ :cls | cls theNonMetaclass subclasses size > 0. ])
|
|
816 |
ifFalse:[ b disable. ].
|
|
817 |
^ b.
|
|
818 |
!
|
|
819 |
|
|
820 |
addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses
|
|
821 |
|b lbl|
|
|
822 |
|
|
823 |
(browser isMethodListBrowser
|
|
824 |
or:[ currentClass isNil
|
|
825 |
or:[ selectedClasses size > 1] ]) ifTrue:[
|
|
826 |
lbl := 'Selected classes & all subclasses & all private classes'.
|
|
827 |
] ifFalse:[
|
|
828 |
lbl := 'Class & subclasses & all private classes'.
|
|
829 |
].
|
|
830 |
b := CheckBox label:(resources string:lbl).
|
|
831 |
self addCheckBox:b forSearchArea:#classHierarchiesWithPrivateClasses.
|
|
832 |
(selectedClasses
|
|
833 |
contains:[ :cls | cls theNonMetaclass privateClasses size > 0. ])
|
|
834 |
ifFalse:[ b disable. ].
|
|
835 |
^ b.
|
|
836 |
!
|
|
837 |
|
|
838 |
addCheckBoxForSelectedClassAndSuperclasses
|
|
839 |
|b lbl|
|
|
840 |
|
|
841 |
(browser isMethodListBrowser
|
|
842 |
or:[ currentClass isNil
|
|
843 |
or:[ selectedClasses size > 1] ]) ifTrue:[
|
|
844 |
lbl := 'Selected classes & all superclasses'.
|
|
845 |
] ifFalse:[
|
|
846 |
lbl := 'Class & superclasses'.
|
|
847 |
].
|
|
848 |
b := CheckBox label:(resources string:lbl).
|
|
849 |
self addCheckBox:b forSearchArea:#classesAndSuperclasses.
|
|
850 |
(selectedClasses
|
|
851 |
contains:[ :cls | cls theNonMetaclass superclass notNil. ])
|
|
852 |
ifFalse:[ b disable. ].
|
|
853 |
^ b.
|
|
854 |
!
|
|
855 |
|
|
856 |
addCheckBoxForSelectedClassCategory
|
|
857 |
|b lbl arg|
|
|
858 |
|
|
859 |
currentClassCategory notNil ifTrue:[
|
|
860 |
lbl := 'Class category ("%1")'.
|
|
861 |
arg := currentClassCategory.
|
|
862 |
] ifFalse:[
|
|
863 |
lbl := 'Selected class categories (%1)'.
|
|
864 |
arg := selectedCategories size.
|
|
865 |
].
|
|
866 |
b := CheckBox label:(resources string:lbl with:arg).
|
|
867 |
self addCheckBox:b forSearchArea:#classCategories.
|
|
868 |
^ b.
|
|
869 |
!
|
|
870 |
|
|
871 |
addCheckBoxForSelectedMethodClasses
|
|
872 |
|b classes numClasses|
|
|
873 |
|
|
874 |
classes := ((browser selectedMethods value ? #())
|
|
875 |
select:[:m | m mclass notNil]
|
|
876 |
thenCollect:[:m | m mclass theNonMetaclass]) asSet.
|
|
877 |
numClasses := classes size.
|
|
878 |
numClasses == 0 ifTrue:[^ self]. "/ comment this to show, but disabled
|
|
879 |
|
|
880 |
numClasses == 1 ifTrue:[
|
|
881 |
b := CheckBox label:(resources string:'Selected method''s class ("%1")'
|
|
882 |
with:classes first name).
|
|
883 |
] ifFalse:[
|
|
884 |
b := CheckBox label:(resources string:'Selected methods'' classes (%1)'
|
|
885 |
with:numClasses).
|
|
886 |
numClasses == 0 ifTrue:[
|
|
887 |
b disable
|
|
888 |
].
|
|
889 |
].
|
|
890 |
self addCheckBox:b forSearchArea:#listOfSelectedMethodClasses.
|
|
891 |
^ b.
|
|
892 |
|
|
893 |
"Modified (comment): / 20-07-2012 / 11:40:44 / cg"
|
|
894 |
!
|
|
895 |
|
|
896 |
addCheckBoxForSelectedMethodPackages
|
|
897 |
|b packages numPackages|
|
|
898 |
|
|
899 |
packages := ((browser selectedMethods value ? #())
|
|
900 |
collect:[:m | m package] as:Set).
|
|
901 |
numPackages := packages size.
|
|
902 |
numPackages size == 0 ifTrue:[^ self]. "/ comment this to show, but disabled
|
|
903 |
|
|
904 |
numPackages == 1 ifTrue:[
|
|
905 |
b := CheckBox label:(resources string:'Selected method''s package ("%1")'
|
|
906 |
with:packages first).
|
|
907 |
] ifFalse:[
|
|
908 |
b := CheckBox label:(resources string:'Selected methods'' packages (%1)'
|
|
909 |
with:numPackages).
|
|
910 |
numPackages == 0 ifTrue:[
|
|
911 |
b disable
|
|
912 |
].
|
|
913 |
].
|
|
914 |
self addCheckBox:b forSearchArea:#listOfSelectedMethodPackages.
|
|
915 |
^ b.
|
|
916 |
|
|
917 |
"Created: / 29-02-2012 / 19:42:26 / cg"
|
|
918 |
!
|
|
919 |
|
|
920 |
addCheckBoxForSelectedMethods
|
|
921 |
|b numSelected|
|
|
922 |
|
|
923 |
numSelected := browser selectedMethods value size.
|
|
924 |
numSelected == 0 ifTrue:[^ self]. "/ comment this to show, but disabled
|
|
925 |
|
|
926 |
b := CheckBox label:(resources string:'Selected methods (%1)' with:numSelected).
|
|
927 |
self addCheckBox:b forSearchArea:#listOfSelectedMethods.
|
|
928 |
numSelected == 0 ifTrue:[b disable].
|
|
929 |
^ b.
|
|
930 |
|
|
931 |
"Modified (comment): / 20-07-2012 / 11:40:33 / cg"
|
|
932 |
!
|
|
933 |
|
|
934 |
addCheckBoxForSelectedPackage
|
|
935 |
|b lbl arg|
|
|
936 |
|
|
937 |
currentClassCategory notNil ifTrue:[
|
|
938 |
lbl := 'Class category ("%1")'.
|
|
939 |
arg := currentClassCategory.
|
|
940 |
] ifFalse:[
|
|
941 |
lbl := 'Selected classes categories (%1)'.
|
|
942 |
arg := selectedCategories size.
|
|
943 |
].
|
|
944 |
b := CheckBox label:(resources string:lbl with:arg).
|
|
945 |
self addCheckBox:b forSearchArea:#classCategories.
|
|
946 |
^ b.
|
|
947 |
!
|
|
948 |
|
|
949 |
addCheckBoxesForClassAndMetaSearch
|
|
950 |
|y b1 b2|
|
|
951 |
|
|
952 |
y := self yPosition.
|
|
953 |
b1 := self addCheckBox:(resources string:'Instance Protocol') on:(self searchInstanceProtocolHolder).
|
|
954 |
"/ b1 width:0.5.
|
|
955 |
|
|
956 |
"/ self yPosition:y.
|
|
957 |
b2 := self addCheckBox:(resources string:'Class Protocol') on:(self searchClassProtocolHolder).
|
|
958 |
"/ b2 left:0.5; width:0.5.
|
|
959 |
|
|
960 |
"Created: / 06-12-2011 / 11:24:11 / cg"
|
|
961 |
!
|
|
962 |
|
|
963 |
addDummyCheckBoxForEverywhere
|
|
964 |
|b|
|
|
965 |
|
|
966 |
b := CheckBox label:(resources string:'Everywhere').
|
|
967 |
b turnOn.
|
|
968 |
b disable.
|
|
969 |
|
|
970 |
currentPanel add:b.
|
|
971 |
!
|
|
972 |
|
|
973 |
addFilteredListOfMatchingSelectors
|
|
974 |
|l|
|
|
975 |
|
|
976 |
listHolder := List new.
|
|
977 |
|
|
978 |
l := HVScrollableView for:SelectionInListView.
|
|
979 |
l listHolder:listHolder.
|
|
980 |
self addComponent:l.
|
|
981 |
l doubleClickAction:[
|
|
982 |
selectorHolder value:(l selectionValue).
|
|
983 |
matchHolder value:false.
|
|
984 |
caseHolder value:false.
|
|
985 |
self doAccept.
|
|
986 |
self okPressed.
|
|
987 |
].
|
|
988 |
^ l.
|
|
989 |
!
|
|
990 |
|
|
991 |
addInputFieldForSelectorOrNameOrString
|
|
992 |
|sel lastSearchPatterns|
|
|
993 |
|
|
994 |
browser notNil ifTrue:[
|
|
995 |
searchWhat == #selector ifTrue:[
|
|
996 |
sel := browser selectorToSearchFor.
|
|
997 |
] ifFalse:[
|
|
998 |
searchWhat == #globalName ifTrue:[
|
|
999 |
sel := browser globalNameToSearchFor ? LastGlobalSearched.
|
|
1000 |
] ifFalse:[
|
|
1001 |
searchWhat == #string ifTrue:[
|
|
1002 |
sel := browser stringToSearchFor ? LastStringSearched.
|
|
1003 |
] ifFalse:[
|
|
1004 |
searchWhat == #resource ifTrue:[
|
|
1005 |
sel := browser stringToSearchFor ? LastResourceSearched.
|
|
1006 |
] ifFalse:[
|
|
1007 |
sel := browser selectorToSearchFor.
|
|
1008 |
]
|
|
1009 |
]
|
|
1010 |
].
|
|
1011 |
].
|
|
1012 |
].
|
|
1013 |
lastSearchPatterns := (browser ? SystemBrowser) lastSearchPatterns.
|
|
1014 |
|
|
1015 |
sel isEmptyOrNil ifTrue:[
|
|
1016 |
"/ use last searchString
|
|
1017 |
lastSearchPatterns size > 0 ifTrue:[
|
|
1018 |
sel := lastSearchPatterns first.
|
|
1019 |
].
|
|
1020 |
].
|
|
1021 |
selectorHolder := (sel ? '') withoutSeparators asValue.
|
|
1022 |
|
|
1023 |
inputField := self addComboBoxOn:selectorHolder tabable:true.
|
|
1024 |
inputField list:lastSearchPatterns.
|
|
1025 |
inputField selectAllInitially.
|
|
1026 |
inputField immediateAccept:true.
|
|
1027 |
inputField takeFocus.
|
|
1028 |
inputField
|
|
1029 |
entryCompletionBlock:[ :contents |
|
|
1030 |
|s what|
|
|
1031 |
|
|
1032 |
s := contents withoutSpaces.
|
|
1033 |
self topView
|
|
1034 |
withWaitCursorDo:[
|
|
1035 |
|best matching|
|
|
1036 |
|
|
1037 |
searchWhat == #resource ifTrue:[
|
|
1038 |
what := DoWhatIMeanSupport resourceCompletion:s inEnvironment:Smalltalk match:true ignoreCase:false.
|
|
1039 |
] ifFalse:[
|
|
1040 |
searchWhat == #globalName ifFalse:[
|
|
1041 |
what := DoWhatIMeanSupport selectorCompletion:s inEnvironment:Smalltalk.
|
|
1042 |
] ifTrue:[
|
|
1043 |
what := DoWhatIMeanSupport globalNameCompletion:s inEnvironment:Smalltalk match:true.
|
|
1044 |
].
|
|
1045 |
].
|
|
1046 |
best := what first.
|
|
1047 |
matching := what second.
|
|
1048 |
inputField contents:best.
|
|
1049 |
"/ listHolder contents:matching.
|
|
1050 |
matching size ~~ 1 ifTrue:[
|
|
1051 |
(browser ? self) window beep.
|
|
1052 |
].
|
|
1053 |
].
|
|
1054 |
].
|
|
1055 |
|
|
1056 |
selectorHolder onChangeEvaluate:[ self updateListOfMatchingSelectorsFor:inputField contents ].
|
|
1057 |
|
|
1058 |
"Modified: / 14-02-2012 / 14:13:52 / cg"
|
|
1059 |
!
|
|
1060 |
|
|
1061 |
addTextEntryFieldForCode
|
|
1062 |
|initial box panel patternInfoBox infoLabel helpButton errMessageField checkCodeAction
|
|
1063 |
metaBox b|
|
|
1064 |
|
|
1065 |
box := View new.
|
|
1066 |
box extent:(600 @ 200).
|
|
1067 |
|
|
1068 |
panel := VariableHorizontalPanel in:box.
|
|
1069 |
panel origin:0.0@0.0 corner:(1.0@1.0).
|
|
1070 |
|
|
1071 |
codeField := CodeView in:panel.
|
|
1072 |
codeField canTab:true.
|
|
1073 |
"/ codeField origin:0.0@0.0 corner:(0.75@1.0).
|
|
1074 |
|
|
1075 |
patternInfoBox := View in:panel.
|
|
1076 |
|
|
1077 |
infoLabel := Label in:patternInfoBox.
|
|
1078 |
infoLabel geometryLayout:(LayoutFrame bottomInset:30).
|
|
1079 |
|
|
1080 |
infoLabel font:(codeField font asSize:(codeField font size - 2)).
|
|
1081 |
infoLabel adjust:#left.
|
|
1082 |
infoLabel label:(self helpTextForMetaPatterns).
|
|
1083 |
|
|
1084 |
panel relativeCorners:#(0.6 1.0).
|
|
1085 |
panel showHandle:true.
|
|
1086 |
|
|
1087 |
helpButton := Button label:(resources string:'Pattern Help') in:patternInfoBox.
|
|
1088 |
helpButton layout:((AlignmentOrigin fractionalFromPoint:0.5@1.0)
|
|
1089 |
leftOffset:2
|
|
1090 |
topOffset:helpButton preferredHeight negated;
|
|
1091 |
leftAlignmentFraction:0.5 topAlignmentFraction:0).
|
|
1092 |
helpButton topInset:0.75@1.0.
|
|
1093 |
helpButton action:[self showHelpOnCodePatterns].
|
|
1094 |
|
|
1095 |
|
|
1096 |
self addComponent:box tabable:true.
|
|
1097 |
|
|
1098 |
metaBox := HorizontalPanelView new.
|
|
1099 |
metaBox horizontalLayout:#leftMax.
|
|
1100 |
b := Button label:'+Lit' action:[ codeField pasteOrReplace:'`#n' ] in:metaBox.
|
|
1101 |
b helpKey:#matchAnyLiteral.
|
|
1102 |
b := Button label:'+Var' action:[ codeField pasteOrReplace:'`v' ] in:metaBox.
|
|
1103 |
b helpKey:#matchAnyVariable.
|
|
1104 |
b := Button label:'+Expr' action:[ codeField pasteOrReplace:'`@e' ] in:metaBox.
|
|
1105 |
b helpKey:#matchAnyExpression.
|
|
1106 |
b := Button label:'+Msg' action:[ codeField pasteOrReplace:'`@m:' ] in:metaBox.
|
|
1107 |
b helpKey:#matchAnyMessage.
|
|
1108 |
b := Button label:'+Node' action:[ codeField pasteOrReplace:'`{:node | node isLiteral and:[node value isSymbol] }' ] in:metaBox.
|
|
1109 |
b helpKey:#matchAnyNode.
|
|
1110 |
b := Button label:'+Stats' action:[ codeField pasteOrReplace:'`.@stats' ] in:metaBox.
|
|
1111 |
b helpKey:#matchAnyStats.
|
|
1112 |
self addComponent:metaBox.
|
|
1113 |
|
|
1114 |
errMessageField := (self addTextLabel:'') adjust:#left.
|
|
1115 |
errMessageField level:-1.
|
|
1116 |
self addCheckBox:(resources string:'Method') on:self isMethodHolder.
|
|
1117 |
|
|
1118 |
checkCodeAction := [ self checkCodeIn:codeField notifying:errMessageField. ].
|
|
1119 |
|
|
1120 |
codeField modifiedChannel onChangeEvaluate:checkCodeAction.
|
|
1121 |
self isMethodHolder onChangeEvaluate:checkCodeAction.
|
|
1122 |
|
|
1123 |
initial := browser selectionInCodeView.
|
|
1124 |
initial isEmptyOrNil ifTrue:[
|
|
1125 |
initial := LastCodeSearched ? ''
|
|
1126 |
].
|
|
1127 |
codeField contents:initial.
|
|
1128 |
checkCodeAction value.
|
|
1129 |
|
|
1130 |
"Modified: / 23-07-2011 / 10:35:14 / cg"
|
|
1131 |
!
|
|
1132 |
|
|
1133 |
checkCodeIn:codeField notifying:errMessageField
|
|
1134 |
|codeString tree errAction|
|
|
1135 |
|
|
1136 |
codeString := codeField contents asString string.
|
|
1137 |
errAction := [:str :pos |
|
|
1138 |
|line col badLine|
|
|
1139 |
|
|
1140 |
line := codeField lineOfCharacterPosition:pos.
|
|
1141 |
col := (codeField colOfCharacterPosition:pos) max:1.
|
|
1142 |
|
|
1143 |
badLine := (codeField listAt:line) ? ''.
|
|
1144 |
col <= badLine size size ifTrue:[
|
|
1145 |
codeField
|
|
1146 |
listAt:line
|
|
1147 |
put:(badLine asText
|
|
1148 |
emphasisAt:col
|
|
1149 |
put:(UserPreferences current unknownIdentifierEmphasis)).
|
|
1150 |
"/ codeField selectFromCharacterPosition:pos to:pos.
|
|
1151 |
].
|
|
1152 |
errMessageField label:('line: ',line printString,' ',str).
|
|
1153 |
errMessageField backgroundColor:Color red.
|
|
1154 |
codeField requestFocus.
|
|
1155 |
nil.
|
|
1156 |
].
|
|
1157 |
|
|
1158 |
isMethodHolder value ifTrue:[
|
|
1159 |
tree := RBParser parseRewriteMethod:codeString onError: errAction.
|
|
1160 |
] ifFalse:[
|
|
1161 |
tree := RBParser parseRewriteExpression:codeString onError: errAction.
|
|
1162 |
].
|
|
1163 |
tree notNil ifTrue:[
|
|
1164 |
errMessageField backgroundColor:View defaultViewBackgroundColor.
|
|
1165 |
errMessageField label:nil
|
|
1166 |
].
|
|
1167 |
codeField modifiedChannel setValue:false.
|
|
1168 |
!
|
|
1169 |
|
|
1170 |
getClassesAndMethodsFor:where
|
|
1171 |
where == #everywhere ifTrue:[
|
|
1172 |
classes := Smalltalk allClasses.
|
|
1173 |
methods := nil.
|
|
1174 |
^ self.
|
|
1175 |
].
|
|
1176 |
where == #currentNameSpace ifTrue:[
|
|
1177 |
classes := currentNamespace allClassesWithAllPrivateClasses.
|
|
1178 |
methods := nil.
|
|
1179 |
^ self.
|
|
1180 |
].
|
|
1181 |
where == #currentClassesNameSpace ifTrue:[
|
|
1182 |
currentClass isPrivate ifTrue:[
|
|
1183 |
classes := currentClass topOwningClass nameSpace
|
|
1184 |
allClassesWithAllPrivateClasses.
|
|
1185 |
] ifFalse:[
|
|
1186 |
classes := currentClass nameSpace allClassesWithAllPrivateClasses.
|
|
1187 |
].
|
|
1188 |
methods := nil.
|
|
1189 |
^ self.
|
|
1190 |
].
|
|
1191 |
where == #currentPackage ifTrue:[
|
|
1192 |
classes := Smalltalk allClassesInPackage:currentPackage.
|
|
1193 |
methods := nil.
|
|
1194 |
^ self.
|
|
1195 |
].
|
|
1196 |
where == #currentClassesPackage ifTrue:[
|
|
1197 |
classes := Smalltalk allClassesInPackage:currentClass package.
|
|
1198 |
methods := nil.
|
|
1199 |
^ self.
|
|
1200 |
].
|
|
1201 |
where == #classCategories ifTrue:[
|
|
1202 |
classes := Smalltalk allClasses
|
|
1203 |
select:[ :cls | selectedCategories includes:cls category. ].
|
|
1204 |
classes := classes collect:[ :each | each theNonMetaclass. ].
|
|
1205 |
methods := nil.
|
|
1206 |
^ self.
|
|
1207 |
].
|
|
1208 |
(where == #classes or:[ where == #classesWithPrivateClasses. ]) ifTrue:[
|
|
1209 |
classes := selectedClasses collect:[ :each | each theNonMetaclass. ].
|
|
1210 |
methods := nil.
|
|
1211 |
^ self.
|
|
1212 |
].
|
|
1213 |
(where == #classHierarchies or:[ where == #classHierarchiesWithPrivateClasses. ])
|
|
1214 |
ifTrue:[
|
|
1215 |
classes := IdentitySet new.
|
|
1216 |
selectedClasses do:[ :cls |
|
|
1217 |
classes addAll:cls theNonMetaclass withAllSubclasses.
|
|
1218 |
].
|
|
1219 |
methods := nil.
|
|
1220 |
^ self.
|
|
1221 |
].
|
|
1222 |
where == #ownersWithPrivateClasses ifTrue:[
|
|
1223 |
classes := IdentitySet new.
|
|
1224 |
selectedClasses do:[ :cls |
|
|
1225 |
|c|
|
|
1226 |
|
|
1227 |
c := cls theNonMetaclass.
|
|
1228 |
classes add:(c owningClass ? c).
|
|
1229 |
].
|
|
1230 |
methods := nil.
|
|
1231 |
^ self.
|
|
1232 |
].
|
|
1233 |
where == #ownersHierarchiesWithPrivateClasses ifTrue:[
|
|
1234 |
classes := IdentitySet new.
|
|
1235 |
selectedClasses do:[ :cls |
|
|
1236 |
|c|
|
|
1237 |
|
|
1238 |
c := cls theNonMetaclass.
|
|
1239 |
classes addAll:(c owningClass ? c) withAllSubclasses.
|
|
1240 |
].
|
|
1241 |
methods := nil.
|
|
1242 |
^ self.
|
|
1243 |
].
|
|
1244 |
(where == #classesAndSuperclasses) ifTrue:[
|
|
1245 |
classes := IdentitySet new.
|
|
1246 |
selectedClasses do:[ :cls |
|
|
1247 |
classes addAll:cls theNonMetaclass withAllSuperclasses.
|
|
1248 |
].
|
|
1249 |
methods := nil.
|
|
1250 |
^ self.
|
|
1251 |
].
|
|
1252 |
(where == AREA_LISTOFMETHODS) ifTrue:[
|
|
1253 |
classes := nil.
|
|
1254 |
methods := browser methodListApp methodList value.
|
|
1255 |
^ self.
|
|
1256 |
].
|
|
1257 |
(where == #listOfSelectedMethods) ifTrue:[
|
|
1258 |
classes := nil.
|
|
1259 |
methods := browser selectedMethods value ? #().
|
|
1260 |
^ self.
|
|
1261 |
].
|
|
1262 |
(where == #listOfSelectedMethodClasses) ifTrue:[
|
|
1263 |
classes := ((browser selectedMethods value ? #()) collect:[:m | m mclass theNonMetaclass] as:Set) asOrderedCollection.
|
|
1264 |
methods := nil.
|
|
1265 |
^ self.
|
|
1266 |
].
|
|
1267 |
(where == #listOfSelectedMethodPackages) ifTrue:[
|
|
1268 |
classes := (((browser selectedMethods value ? #()) collect:[:m | m package] as:Set)
|
|
1269 |
collectAll:[:p | Smalltalk allClassesInPackage:p ]) asOrderedCollection.
|
|
1270 |
methods := nil.
|
|
1271 |
^ self.
|
|
1272 |
].
|
|
1273 |
(where == #listOfChangedClasses) ifTrue:[
|
|
1274 |
classes := ChangeSet current changedClasses.
|
|
1275 |
methods := nil.
|
|
1276 |
^ self.
|
|
1277 |
].
|
|
1278 |
(where == #listOfChangedMethods) ifTrue:[
|
|
1279 |
classes := nil.
|
|
1280 |
methods := Set new.
|
|
1281 |
ChangeSet current do:[:chg |
|
|
1282 |
|mthd|
|
|
1283 |
|
|
1284 |
chg notNil ifTrue:[
|
|
1285 |
chg isMethodChange ifTrue:[
|
|
1286 |
mthd := chg changeMethod.
|
|
1287 |
mthd notNil ifTrue:[
|
|
1288 |
methods add:mthd
|
|
1289 |
]
|
|
1290 |
]
|
|
1291 |
]
|
|
1292 |
].
|
|
1293 |
methods := methods asOrderedCollection.
|
|
1294 |
^ self.
|
|
1295 |
].
|
|
1296 |
|
|
1297 |
self todo:'unimplemented search'.
|
|
1298 |
|
|
1299 |
"Modified: / 05-10-2011 / 15:48:20 / az"
|
|
1300 |
"Modified: / 29-02-2012 / 19:47:42 / cg"
|
|
1301 |
!
|
|
1302 |
|
|
1303 |
helpTextForMetaPatterns
|
|
1304 |
^ 'MetaPatterns:
|
|
1305 |
' , '`' allBold , ' = meta
|
|
1306 |
' , '@' allBold , ' = list/any
|
|
1307 |
' , '.' allBold , ' = statement
|
|
1308 |
' , '`' allBold , ' = recurse
|
|
1309 |
|
|
1310 |
' , '`#n' allBold , ' any lit
|
|
1311 |
' , '`v' allBold , ' any var (`V => global)
|
|
1312 |
' , '`@e' allBold , ' any expr
|
|
1313 |
' , '`@m:' allBold , ' any message (`m => unary)
|
|
1314 |
' , '`{:n|...}' allBold , ' node pattern
|
|
1315 |
' , '`''a.*''' allBold , ' regex on string const
|
|
1316 |
'.
|
|
1317 |
|
|
1318 |
"Modified: / 08-08-2011 / 20:33:03 / cg"
|
|
1319 |
!
|
|
1320 |
|
|
1321 |
isMethodHolder
|
|
1322 |
isMethodHolder isNil ifTrue:[isMethodHolder := (LastCodeSearchWasMethod ? false) asValue].
|
|
1323 |
^ isMethodHolder
|
|
1324 |
! !
|
|
1325 |
|
|
1326 |
!SearchDialog methodsFor:'setup-buttons'!
|
|
1327 |
|
|
1328 |
addBrowseButton
|
|
1329 |
|b|
|
|
1330 |
|
|
1331 |
b := Button label:(resources string:'Browse').
|
|
1332 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[
|
|
1333 |
self addButton:b before:nil.
|
|
1334 |
] ifFalse:[
|
|
1335 |
self addButton:b after:nil.
|
|
1336 |
].
|
|
1337 |
b
|
|
1338 |
action:[
|
|
1339 |
openHow := #newBrowser.
|
|
1340 |
self doAccept.
|
|
1341 |
self okPressed.
|
|
1342 |
].
|
|
1343 |
^ b.
|
|
1344 |
!
|
|
1345 |
|
|
1346 |
addBufferButton
|
|
1347 |
|b|
|
|
1348 |
|
|
1349 |
b := Button label:(resources string:'Add Buffer').
|
|
1350 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[
|
|
1351 |
self addButton:b before:nil.
|
|
1352 |
] ifFalse:[
|
|
1353 |
self addButton:b after:nil.
|
|
1354 |
].
|
|
1355 |
b
|
|
1356 |
action:[
|
|
1357 |
openHow := #newBuffer.
|
|
1358 |
self doAccept.
|
|
1359 |
self okPressed.
|
|
1360 |
].
|
|
1361 |
^ b.
|
|
1362 |
!
|
|
1363 |
|
|
1364 |
addButtons
|
|
1365 |
"add find/newBrowser/newBuffer buttons"
|
|
1366 |
|
|
1367 |
|prevButton|
|
|
1368 |
|
|
1369 |
allowFind ifTrue:[
|
|
1370 |
defaultOpenHow := #showHere.
|
|
1371 |
prevButton := self addFindButton.
|
|
1372 |
].
|
|
1373 |
allowBrowser ifTrue:[
|
|
1374 |
defaultOpenHow := #newBrowser.
|
|
1375 |
prevButton := self addBrowseButton.
|
|
1376 |
].
|
|
1377 |
allowBuffer ifTrue:[
|
|
1378 |
defaultOpenHow := #newBuffer.
|
|
1379 |
prevButton := self addBufferButton.
|
|
1380 |
].
|
|
1381 |
prevButton notNil ifTrue:[
|
|
1382 |
prevButton isReturnButton:true.
|
|
1383 |
].
|
|
1384 |
self addAbortButton.
|
|
1385 |
!
|
|
1386 |
|
|
1387 |
addFindButton
|
|
1388 |
|b|
|
|
1389 |
|
|
1390 |
b := Button label:(resources string:'Find').
|
|
1391 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[
|
|
1392 |
self addButton:b before:nil.
|
|
1393 |
] ifFalse:[
|
|
1394 |
self addButton:b after:nil.
|
|
1395 |
].
|
|
1396 |
b
|
|
1397 |
action:[
|
|
1398 |
openHow := #showHere.
|
|
1399 |
self doAccept.
|
|
1400 |
self okPressed.
|
|
1401 |
].
|
|
1402 |
^ b.
|
|
1403 |
! !
|
|
1404 |
|
|
1405 |
!SearchDialog class methodsFor:'documentation'!
|
|
1406 |
|
14112
|
1407 |
version
|
|
1408 |
^ '$Header: /cvs/stx/stx/libtool/Tools__SearchDialog.st,v 1.80 2014-03-05 14:52:44 cg Exp $'
|
|
1409 |
!
|
|
1410 |
|
14111
|
1411 |
version_CVS
|
14112
|
1412 |
^ '$Header: /cvs/stx/stx/libtool/Tools__SearchDialog.st,v 1.80 2014-03-05 14:52:44 cg Exp $'
|
14111
|
1413 |
! !
|
|
1414 |
|
|
1415 |
|
|
1416 |
SearchDialog initialize!
|