author | Claus Gittinger <cg@exept.de> |
Tue, 14 Mar 2006 13:52:13 +0100 | |
changeset 6685 | 85ebaa49b35b |
parent 6667 | a4f01d4860bc |
child 6691 | 06bc56dc7252 |
permissions | -rw-r--r-- |
5591 | 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 |
||
5592 | 13 |
"{ Package: 'stx:libtool' }" |
5591 | 14 |
|
15 |
"{ NameSpace: Tools }" |
|
16 |
||
17 |
DialogBox subclass:#SearchDialog |
|
18 |
instanceVariableNames:'openHow classes methods selectedClasses selectedCategories |
|
19 |
selectedMethods currentClass currentNamespace |
|
20 |
currentClassCategory browser whereRadioGroup verticalPanel |
|
21 |
searchAreas caseHolder matchHolder isMethodHolder codeField |
|
22 |
selectorHolder defaultOpenHow withTextEntry allowFind allowBuffer |
|
6685 | 23 |
allowBrowser isSelector searchClassProtocolHolder |
24 |
searchInstanceProtocolHolder selectorOrCode' |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
25 |
classVariableNames:'LastCodeSearched LastCodeSearchWasMethod LastGlobalSearched |
6381
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
26 |
LastSearchWasMatch LastSearchWasIgnoringCase LastStringSearchArea |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
27 |
LastCodeSearchArea' |
5591 | 28 |
poolDictionaries:'' |
29 |
category:'Interface-Browsers-New' |
|
30 |
! |
|
31 |
||
32 |
!SearchDialog class methodsFor:'documentation'! |
|
33 |
||
34 |
copyright |
|
35 |
" |
|
36 |
COPYRIGHT (c) 2000 by eXept Software AG |
|
37 |
All Rights Reserved |
|
38 |
||
39 |
This software is furnished under a license and may be used |
|
40 |
only in accordance with the terms of that license and with the |
|
41 |
inclusion of the above copyright notice. This software may not |
|
42 |
be provided or otherwise made available to, or used by, any |
|
43 |
other person. No title to or ownership of the software is |
|
44 |
hereby transferred. |
|
45 |
" |
|
46 |
! ! |
|
47 |
||
6381
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
48 |
!SearchDialog class methodsFor:'queries'! |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
49 |
|
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
50 |
lastCodeSearchArea |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
51 |
^ LastCodeSearchArea |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
52 |
! |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
53 |
|
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
54 |
lastStringSearchArea |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
55 |
^ LastStringSearchArea |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
56 |
! ! |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
57 |
|
6685 | 58 |
!SearchDialog methodsFor:'accessing-entered values'! |
59 |
||
60 |
classesToSearch |
|
61 |
^ classes. |
|
62 |
! |
|
63 |
||
64 |
codeToSearch |
|
65 |
^ selectorOrCode. |
|
66 |
! |
|
67 |
||
68 |
matchMethods |
|
69 |
^ isMethodHolder value ? false. |
|
70 |
! |
|
71 |
||
72 |
methodsToSearch |
|
73 |
^ methods. |
|
74 |
! |
|
75 |
||
76 |
openHow |
|
77 |
^ openHow. |
|
78 |
! |
|
79 |
||
80 |
searchIgnoringCase |
|
81 |
^ caseHolder value ? false. |
|
82 |
! |
|
83 |
||
84 |
searchWithMatch |
|
85 |
^ matchHolder value ? false. |
|
86 |
! |
|
87 |
||
88 |
selectorToSearch |
|
89 |
^ selectorOrCode. |
|
90 |
! ! |
|
91 |
||
5591 | 92 |
!SearchDialog methodsFor:'private'! |
93 |
||
6685 | 94 |
searchClassProtocolHolder |
95 |
searchClassProtocolHolder isNil ifTrue:[ |
|
96 |
searchClassProtocolHolder := true asValue |
|
97 |
]. |
|
98 |
^ searchClassProtocolHolder |
|
99 |
! |
|
100 |
||
101 |
searchInstanceProtocolHolder |
|
102 |
searchInstanceProtocolHolder isNil ifTrue:[ |
|
103 |
searchInstanceProtocolHolder := true asValue |
|
104 |
]. |
|
105 |
^ searchInstanceProtocolHolder |
|
106 |
! |
|
107 |
||
5591 | 108 |
showHelpOnCodePatterns |
109 |
HTMLDocumentView openFullOnHelpFile:'Browser/RBSearchPatterns.html' |
|
110 |
! ! |
|
111 |
||
112 |
!SearchDialog methodsFor:'public'! |
|
113 |
||
6242 | 114 |
addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch |
115 |
isSelector == #code ifTrue:[ |
|
116 |
self addTextEntryFieldForCode. |
|
117 |
] ifFalse:[ |
|
118 |
self addInputFieldForSelectorOrNameOrString. |
|
119 |
withCaseIgnore ifTrue:[ |
|
6685 | 120 |
self |
121 |
addCheckBox:(resources string:'Ignore case') |
|
6465
b490429fbd16
default search is no longer case-sensitive
Claus Gittinger <cg@exept.de>
parents:
6443
diff
changeset
|
122 |
on:(caseHolder := (LastSearchWasIgnoringCase ? true) asValue). |
6242 | 123 |
]. |
124 |
withMatch ifTrue:[ |
|
6685 | 125 |
self |
126 |
addCheckBox:(resources string:'Match') |
|
6242 | 127 |
on:(matchHolder := (LastSearchWasMatch ? true) asValue). |
128 |
"/ (isSelector and:[ sel notNil. ]) ifTrue:[ |
|
129 |
"/ sel includesMatchCharacters ifTrue:[ |
|
130 |
"/ matchHolder value:false. |
|
131 |
"/ ]. |
|
132 |
"/ ]. |
|
133 |
]. |
|
134 |
] |
|
135 |
! |
|
136 |
||
5591 | 137 |
askThenDo:aBlock |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
138 |
|where code sel matchHolderValue caseHolderValue| |
5591 | 139 |
|
140 |
self open. |
|
141 |
self accepted ifFalse:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
142 |
^ self. |
5591 | 143 |
]. |
144 |
||
145 |
openHow isNil ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
146 |
openHow := defaultOpenHow. |
5591 | 147 |
]. |
148 |
where := whereRadioGroup value. |
|
149 |
withTextEntry ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
150 |
isSelector == #code ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
151 |
code := codeField contentsAsString. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
152 |
LastCodeSearched := code. |
6381
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
153 |
LastCodeSearchArea := where. |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
154 |
] ifFalse:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
155 |
sel := selectorHolder value. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
156 |
sel isEmpty ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
157 |
browser warn:(isSelector |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
158 |
ifTrue:[ 'No selector entered for search'. ] |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
159 |
ifFalse:[ 'Nothing entered for search'. ]). |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
160 |
^ self. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
161 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
162 |
sel := sel string. |
6667 | 163 |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
164 |
browser rememberSearchPattern:sel. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
165 |
isSelector == #globalName ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
166 |
LastGlobalSearched := sel. |
6381
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
167 |
] ifFalse:[ |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
168 |
isSelector == #string ifTrue:[ |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
169 |
LastStringSearchArea := where. |
6667 | 170 |
] ifFalse:[ |
171 |
(sel startsWith:$#) ifTrue:[ |
|
172 |
(sel startsWith:'#''') ifTrue:[ |
|
173 |
sel := sel copyFrom:3. |
|
174 |
(sel endsWith:$') ifTrue:[ |
|
175 |
sel := sel copyWithoutLast:1. |
|
176 |
]. |
|
177 |
] ifFalse:[ |
|
178 |
sel := sel copyFrom:2. |
|
179 |
]. |
|
180 |
]. |
|
6381
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
181 |
] |
f8696b036204
remember last search areas for string and code search
Claus Gittinger <cg@exept.de>
parents:
6379
diff
changeset
|
182 |
] |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
183 |
]. |
5591 | 184 |
]. |
185 |
where isNil ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
186 |
browser warn:'No class(es) for search'. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
187 |
^ self. |
5591 | 188 |
]. |
189 |
||
190 |
self getClassesAndMethodsFor:where. |
|
191 |
(#(#classesWithPrivateClasses #classHierarchiesWithPrivateClasses #ownersWithPrivateClasses #ownersHierarchiesWithPrivateClasses) |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
192 |
includes:where) |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
193 |
ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
194 |
|toSearch| |
5591 | 195 |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
196 |
toSearch := IdentitySet withAll:classes. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
197 |
classes := IdentitySet withAll:toSearch. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
198 |
[ toSearch notEmpty. ] whileTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
199 |
|cls| |
5591 | 200 |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
201 |
cls := toSearch removeFirst. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
202 |
classes addAll:cls allPrivateClasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
203 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
204 |
]. |
5591 | 205 |
|
206 |
classes size == 0 ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
207 |
classes := nil. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
208 |
methods size == 0 ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
209 |
browser warn:'No class(es) given for search.'. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
210 |
^ self. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
211 |
]. |
5591 | 212 |
] ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
213 |
classes := classes asOrderedCollection. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
214 |
methods size ~~ 0 ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
215 |
browser warn:'oops'. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
216 |
methods := nil. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
217 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
218 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
219 |
|
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
220 |
matchHolderValue := matchHolder value. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
221 |
matchHolderValue notNil ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
222 |
LastSearchWasMatch := matchHolderValue |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
223 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
224 |
caseHolderValue := caseHolder value. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
225 |
caseHolderValue notNil ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
226 |
LastSearchWasIgnoringCase := caseHolderValue |
5591 | 227 |
]. |
228 |
||
6685 | 229 |
selectorOrCode := sel ? code. |
230 |
||
231 |
aBlock numArgs == 7 ifTrue:[ |
|
232 |
"/ old style |
|
233 |
aBlock |
|
234 |
value:classes |
|
235 |
value:(sel ? code) |
|
236 |
value:(caseHolderValue ? false) |
|
237 |
value:openHow |
|
238 |
value:(matchHolderValue ? false) |
|
239 |
value:methods |
|
240 |
value:(isMethodHolder value ? false). |
|
241 |
] ifFalse:[ |
|
242 |
aBlock value. |
|
243 |
] |
|
5591 | 244 |
! |
245 |
||
6242 | 246 |
setupToAskForMethodSearchTitle:title forBrowser:brwsrArg isSelector:isSelectorArg searchArea:whereDefault withCaseIgnore:withCaseIgnore withMatch:withMatch withMethodList:withMethodList allowFind:allowFindArg allowBuffer:allowBufferArg allowBrowser:allowBrowserArg withTextEntry:withTextEntryArg |
6685 | 247 |
|where ns methodNameSpaces hPanel leftVerticalPanel rightVerticalPanel| |
5591 | 248 |
|
249 |
allowFind := allowFindArg. |
|
250 |
allowBuffer := allowBufferArg. |
|
251 |
allowBrowser := allowBrowserArg. |
|
252 |
isSelector := isSelectorArg. |
|
253 |
withTextEntry := withTextEntryArg. |
|
254 |
browser := brwsrArg. |
|
255 |
resources := browser resources. |
|
256 |
||
6351 | 257 |
(self addTextLabel:(resources stringWithCRs:title)) adjust:#left. |
6685 | 258 |
|
5591 | 259 |
selectedClasses := browser selectedClasses value. |
260 |
selectedCategories := browser selectedCategoriesValue. |
|
261 |
selectedMethods := browser selectedMethods value. |
|
262 |
currentClass := browser theSingleSelectedClass. |
|
263 |
currentClassCategory := browser theSingleSelectedCategory. |
|
6242 | 264 |
currentClass isNil ifTrue:[ |
265 |
browser hasMethodSelected ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
266 |
currentClass := selectedMethods first mclass. |
6685 | 267 |
selectedClasses := (selectedMethods collect:[:each | each mclass ]) asIdentitySet. |
6242 | 268 |
selectedClasses := selectedClasses select:[:each | each notNil ]. |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
269 |
]. |
5591 | 270 |
]. |
6242 | 271 |
currentClass notNil ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
272 |
currentClass := currentClass theNonMetaclass. |
5591 | 273 |
]. |
6242 | 274 |
withTextEntry ifTrue:[ |
275 |
self addTextEntryWithCaseIgnore:withCaseIgnore withMatch:withMatch. |
|
5591 | 276 |
]. |
277 |
searchAreas := OrderedCollection new. |
|
6685 | 278 |
|
5591 | 279 |
self addHorizontalLine. |
280 |
self addVerticalSpace. |
|
6685 | 281 |
|
282 |
hPanel := HorizontalPanelView "SimpleView" new. |
|
283 |
hPanel verticalLayout:#top. |
|
284 |
hPanel horizontalLayout:#left. |
|
285 |
||
286 |
leftVerticalPanel := verticalPanel := VerticalPanelView new. |
|
287 |
leftVerticalPanel verticalLayout:#topSpace. |
|
288 |
leftVerticalPanel horizontalLayout:#fitSpace. |
|
289 |
leftVerticalPanel viewBackground:Color red. |
|
290 |
||
5591 | 291 |
(self addTextLabel:(resources string:'Search in:')) adjust:#left. |
292 |
whereRadioGroup := RadioButtonGroup new. |
|
6242 | 293 |
(selectedCategories size > 0 or:[ selectedClasses size > 0 ]) ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
294 |
self addCheckBoxForEverywhere. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
295 |
"/ classMethodListView notNil ifTrue:[ |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
296 |
"/ b := CheckBox label:(resources string:'Shown Methods'). |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
297 |
"/ panel add:b. whereChannel add:b value:#currentMethodList. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
298 |
"/ areas add:#currentMethodList. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
299 |
"/ self makeTabable:b. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
300 |
"/ ]. |
6242 | 301 |
browser isMethodListBrowser ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
302 |
methodNameSpaces := (browser selectedMethods value ? #()) |
6242 | 303 |
collect:[:eachMethod | eachMethod mclass topNameSpace ]. |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
304 |
]. |
6242 | 305 |
methodNameSpaces size == 1 ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
306 |
currentNamespace := methodNameSpaces first. |
6242 | 307 |
] ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
308 |
currentNamespace := browser currentNamespace. |
6379 | 309 |
selectedClasses size == 0 ifTrue:[ |
310 |
|classesInAllSelectedCategories nameSpacesOfAllClassesInAllSelectedCategories| |
|
311 |
classesInAllSelectedCategories := Smalltalk allClasses select:[:cls | selectedCategories includes:cls category]. |
|
312 |
nameSpacesOfAllClassesInAllSelectedCategories := classesInAllSelectedCategories collect:[:eachClass | eachClass topNameSpace]. |
|
313 |
nameSpacesOfAllClassesInAllSelectedCategories size == 1 ifTrue:[ |
|
314 |
currentNamespace := nameSpacesOfAllClassesInAllSelectedCategories first. |
|
315 |
]. |
|
316 |
]. |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
317 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
318 |
(currentNamespace notNil |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
319 |
and:[ currentNamespace ~= (browser nameListEntryForALL) ]) |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
320 |
ifTrue:[ self addCheckBoxForCurrentNamespace ] |
6242 | 321 |
ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
322 |
(currentClass notNil |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
323 |
and:[ (ns := currentClass nameSpace) notNil and:[ ns ~~ Smalltalk ] ]) |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
324 |
ifTrue:[ self addCheckBoxForClassesNamespace:ns ]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
325 |
]. |
6242 | 326 |
selectedCategories size > 0 ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
327 |
self addCheckBoxForSelectedClassCategory. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
328 |
]. |
6242 | 329 |
(selectedClasses size > 0 or:[ selectedMethods size > 0 ]) ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
330 |
self addCheckBoxForSelectedClass. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
331 |
self addCheckBoxForSelectedClassAndSuperclasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
332 |
self addCheckBoxForSelectedClassAndSubclasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
333 |
self addCheckBoxForSelectedClassAndPrivateClasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
334 |
self addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
335 |
self addCheckBoxForOwnerAndItsPrivateClasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
336 |
self addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
337 |
]. |
6242 | 338 |
] ifFalse:[ |
339 |
browser currentNamespace ~~ Smalltalk ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
340 |
self addCheckBoxForEverywhere. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
341 |
currentNamespace := browser currentNamespace. |
6242 | 342 |
currentNamespace ~= (browser nameListEntryForALL) ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
343 |
self addCheckBoxForCurrentNamespace. |
6242 | 344 |
] ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
345 |
(currentClass notNil |
6685 | 346 |
and:[ (ns := currentClass nameSpace) notNil |
347 |
and:[ ns ~~ Smalltalk ] ]) |
|
348 |
ifTrue:[ |
|
349 |
self addCheckBoxForClassesNamespace:ns |
|
350 |
]. |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
351 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
352 |
]. |
5591 | 353 |
]. |
6242 | 354 |
(withMethodList and:[ browser isMethodListBrowser ]) ifTrue:[ |
355 |
searchAreas size == 0 ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
356 |
self addCheckBoxForEverywhere. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
357 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
358 |
self addCheckBoxForMethodList. |
6242 | 359 |
browser selectedMethods value size > 1 ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
360 |
self addCheckBoxForSelectedMethods. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
361 |
]. |
5591 | 362 |
]. |
6242 | 363 |
searchAreas size == 0 ifTrue:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
364 |
whereRadioGroup := #everywhere asValue. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
365 |
self addDummyCheckBoxForEverywhere. |
6242 | 366 |
] ifFalse:[ |
367 |
whereDefault notNil ifTrue:[ |
|
368 |
(searchAreas includes:whereDefault) ifTrue:[ |
|
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
369 |
where := whereDefault asSymbol. |
6242 | 370 |
] ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
371 |
where := searchAreas first. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
372 |
]. |
6242 | 373 |
] ifFalse:[ |
5886
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
374 |
where := #everywhere. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
375 |
]. |
a212a4614597
remember last match- and last case-flag setting as default
Claus Gittinger <cg@exept.de>
parents:
5592
diff
changeset
|
376 |
whereRadioGroup value:where. |
5591 | 377 |
]. |
6685 | 378 |
|
379 |
hPanel add:leftVerticalPanel. |
|
380 |
||
381 |
rightVerticalPanel := verticalPanel := VerticalPanelView new. |
|
382 |
rightVerticalPanel verticalLayout:#topSpace. |
|
383 |
rightVerticalPanel horizontalLayout:#fitSpace. |
|
384 |
rightVerticalPanel viewBackground:Color green. |
|
385 |
||
386 |
false ifTrue:[ |
|
387 |
self addCheckBoxForClassMethodSearch. |
|
388 |
self addCheckBoxForInstanceMethodSearch. |
|
389 |
]. |
|
390 |
||
391 |
"/ rightVerticalPanel origin:0.75@0.0 corner:1.0@1.0. |
|
392 |
hPanel |
|
393 |
preferredExtent:(leftVerticalPanel preferredExtent y + rightVerticalPanel preferredExtent y) |
|
394 |
@ |
|
395 |
(leftVerticalPanel preferredExtent y max:rightVerticalPanel preferredExtent y). |
|
396 |
hPanel add:rightVerticalPanel. |
|
397 |
self addComponent:hPanel indent:0. |
|
398 |
||
5591 | 399 |
"/ panel has its own idea of indenting |
400 |
self addVerticalSpace. |
|
401 |
self addHorizontalLine. |
|
402 |
self addButtons. |
|
6685 | 403 |
|
5591 | 404 |
self label:(resources string:'Search'). |
405 |
! ! |
|
406 |
||
407 |
!SearchDialog methodsFor:'setup'! |
|
408 |
||
409 |
addCheckBox:b forSearchArea:area |
|
410 |
verticalPanel add:b. |
|
411 |
whereRadioGroup add:b value:area. |
|
412 |
searchAreas add:area. |
|
413 |
self makeTabable:b. |
|
414 |
! |
|
415 |
||
6685 | 416 |
addCheckBoxForClassMethodSearch |
417 |
|b| |
|
418 |
||
419 |
b := CheckBox label:(resources string:'Class Protocol'). |
|
420 |
b model:(self searchClassProtocolHolder). |
|
421 |
verticalPanel add:b. |
|
422 |
^ b. |
|
423 |
! |
|
424 |
||
5591 | 425 |
addCheckBoxForClassesNamespace:ns |
426 |
|b| |
|
427 |
||
428 |
b := CheckBox |
|
429 |
label:(resources string:'Classes nameSpace (''%1'')' with:ns name). |
|
430 |
self addCheckBox:b forSearchArea:#currentClassesNameSpace. |
|
431 |
^ b. |
|
432 |
! |
|
433 |
||
434 |
addCheckBoxForCurrentNamespace |
|
435 |
|b| |
|
436 |
||
437 |
b := CheckBox label:(resources string:'Current nameSpace (''%1'')' |
|
438 |
with:currentNamespace name). |
|
439 |
self addCheckBox:b forSearchArea:#currentNameSpace. |
|
440 |
^ b. |
|
441 |
! |
|
442 |
||
443 |
addCheckBoxForEverywhere |
|
444 |
|b| |
|
445 |
||
446 |
b := CheckBox label:(resources string:'Everywhere'). |
|
447 |
self addCheckBox:b forSearchArea:#everywhere. |
|
448 |
^ b. |
|
449 |
! |
|
450 |
||
6685 | 451 |
addCheckBoxForInstanceMethodSearch |
452 |
|b| |
|
453 |
||
454 |
b := CheckBox label:(resources string:'Instance Protocol'). |
|
455 |
b model:(self searchInstanceProtocolHolder). |
|
456 |
verticalPanel add:b. |
|
457 |
^ b. |
|
458 |
! |
|
459 |
||
5591 | 460 |
addCheckBoxForMethodList |
461 |
|b| |
|
462 |
||
463 |
b := CheckBox label:(resources string:'Methodlist'). |
|
464 |
self addCheckBox:b forSearchArea:#listOfMethods. |
|
465 |
^ b. |
|
466 |
! |
|
467 |
||
468 |
addCheckBoxForOwnerAndItsPrivateClasses |
|
469 |
|b lbl| |
|
470 |
||
471 |
(currentClass notNil and:[ currentClass isPrivate. ]) ifTrue:[ |
|
472 |
lbl := resources string:'Owner (%1) & all its private classes' |
|
473 |
with:currentClass owningClass name. |
|
474 |
] ifFalse:[ |
|
475 |
lbl := resources string:'Owners & all their private classes'. |
|
476 |
]. |
|
477 |
b := CheckBox label:lbl. |
|
478 |
self addCheckBox:b forSearchArea:#ownersWithPrivateClasses. |
|
479 |
(selectedClasses contains:[ :cls | cls isPrivate. ]) ifFalse:[ |
|
480 |
b disable. |
|
481 |
]. |
|
482 |
^ b. |
|
483 |
! |
|
484 |
||
485 |
addCheckBoxForOwnerAndItsSubclassesAndItsPrivateClasses |
|
486 |
|b lbl| |
|
487 |
||
488 |
(currentClass notNil and:[ currentClass isPrivate. ]) ifTrue:[ |
|
489 |
lbl := resources |
|
490 |
string:'Owner (%1) & its subclasses & all its private classes' |
|
491 |
with:currentClass owningClass name. |
|
492 |
] ifFalse:[ |
|
493 |
lbl := resources |
|
494 |
string:'Owners & their subclasses & all their private classes'. |
|
495 |
]. |
|
496 |
b := CheckBox label:lbl. |
|
497 |
self addCheckBox:b forSearchArea:#ownersHierarchiesWithPrivateClasses. |
|
498 |
(selectedClasses contains:[ :cls | cls isPrivate. ]) ifFalse:[ |
|
499 |
b disable. |
|
500 |
]. |
|
501 |
^ b. |
|
502 |
! |
|
503 |
||
504 |
addCheckBoxForSelectedClass |
|
505 |
|b lbl| |
|
506 |
||
507 |
(browser isMethodListBrowser or:[ currentClass isNil. ]) ifTrue:[ |
|
508 |
selectedClasses size == 1 ifTrue:[ |
|
509 |
lbl := resources string:'Selected class (''%1'')' |
|
510 |
with:selectedClasses first theNonMetaclass name. |
|
511 |
] ifFalse:[ |
|
512 |
lbl := resources string:'Selected classes (%1)' with:selectedClasses size. |
|
513 |
]. |
|
514 |
] ifFalse:[ |
|
515 |
lbl := resources string:'Class (''%1'')' with:currentClass name. |
|
516 |
]. |
|
517 |
b := CheckBox label:lbl. |
|
518 |
self addCheckBox:b forSearchArea:#classes. |
|
519 |
^ b. |
|
520 |
! |
|
521 |
||
522 |
addCheckBoxForSelectedClassAndPrivateClasses |
|
523 |
|b lbl| |
|
524 |
||
525 |
(browser isMethodListBrowser or:[ currentClass isNil. ]) ifTrue:[ |
|
526 |
lbl := 'Selected classes & all private classes'. |
|
527 |
] ifFalse:[ |
|
528 |
lbl := 'Class & private classes'. |
|
529 |
]. |
|
530 |
b := CheckBox label:(resources string:lbl). |
|
531 |
self addCheckBox:b forSearchArea:#classesWithPrivateClasses. |
|
532 |
(selectedClasses |
|
533 |
contains:[ :cls | cls theNonMetaclass privateClasses size > 0. ]) |
|
534 |
ifFalse:[ b disable. ]. |
|
535 |
^ b. |
|
536 |
! |
|
537 |
||
538 |
addCheckBoxForSelectedClassAndSubclasses |
|
539 |
|b lbl| |
|
540 |
||
541 |
(browser isMethodListBrowser or:[ currentClass isNil. ]) ifTrue:[ |
|
542 |
lbl := 'Selected classes & all subclasses'. |
|
543 |
] ifFalse:[ |
|
544 |
lbl := 'Class & subclasses'. |
|
545 |
]. |
|
546 |
b := CheckBox label:(resources string:lbl). |
|
547 |
self addCheckBox:b forSearchArea:#classHierarchies. |
|
548 |
(selectedClasses |
|
549 |
contains:[ :cls | cls theNonMetaclass subclasses size > 0. ]) |
|
550 |
ifFalse:[ b disable. ]. |
|
551 |
^ b. |
|
552 |
! |
|
553 |
||
554 |
addCheckBoxForSelectedClassAndSubclassesAndPrivateClasses |
|
555 |
|b lbl| |
|
556 |
||
557 |
(browser isMethodListBrowser or:[ currentClass isNil. ]) ifTrue:[ |
|
558 |
lbl := 'Selected classes & all subclasses & all private classes'. |
|
559 |
] ifFalse:[ |
|
560 |
lbl := 'Class & subclasses & all private classes'. |
|
561 |
]. |
|
562 |
b := CheckBox label:(resources string:lbl). |
|
563 |
self addCheckBox:b forSearchArea:#classHierarchiesWithPrivateClasses. |
|
564 |
(selectedClasses |
|
565 |
contains:[ :cls | cls theNonMetaclass privateClasses size > 0. ]) |
|
566 |
ifFalse:[ b disable. ]. |
|
567 |
^ b. |
|
568 |
! |
|
569 |
||
570 |
addCheckBoxForSelectedClassAndSuperclasses |
|
571 |
|b lbl| |
|
572 |
||
573 |
(browser isMethodListBrowser or:[ currentClass isNil. ]) ifTrue:[ |
|
574 |
lbl := 'Selected classes & all superclasses'. |
|
575 |
] ifFalse:[ |
|
576 |
lbl := 'Class & superclasses'. |
|
577 |
]. |
|
578 |
b := CheckBox label:(resources string:lbl). |
|
579 |
self addCheckBox:b forSearchArea:#classesAndSuperclasses. |
|
580 |
(selectedClasses |
|
581 |
contains:[ :cls | cls theNonMetaclass superclass notNil. ]) |
|
582 |
ifFalse:[ b disable. ]. |
|
583 |
^ b. |
|
584 |
! |
|
585 |
||
586 |
addCheckBoxForSelectedClassCategory |
|
587 |
|b lbl| |
|
588 |
||
589 |
currentClassCategory notNil ifTrue:[ |
|
590 |
lbl := resources string:'Class category (''%1'')' |
|
591 |
with:currentClassCategory. |
|
592 |
] ifFalse:[ |
|
593 |
lbl := resources string:'Selected classes categories (%1)' |
|
594 |
with:selectedCategories size. |
|
595 |
]. |
|
596 |
b := CheckBox label:lbl. |
|
597 |
self addCheckBox:b forSearchArea:#classCategories. |
|
598 |
^ b. |
|
599 |
! |
|
600 |
||
601 |
addCheckBoxForSelectedMethods |
|
602 |
|b| |
|
603 |
||
604 |
b := CheckBox label:(resources string:'Selected methods (%1)' |
|
605 |
with:browser selectedMethods value size). |
|
606 |
self addCheckBox:b forSearchArea:#listOfSelectedMethods. |
|
607 |
^ b. |
|
608 |
! |
|
609 |
||
610 |
addDummyCheckBoxForEverywhere |
|
611 |
|b| |
|
612 |
||
613 |
b := CheckBox label:(resources string:'Everywhere'). |
|
614 |
b turnOn. |
|
615 |
b disable. |
|
6685 | 616 |
|
5591 | 617 |
verticalPanel add:b. |
618 |
! |
|
619 |
||
620 |
addInputFieldForSelectorOrNameOrString |
|
621 |
|sel inputField lastSearchPatterns| |
|
622 |
||
623 |
isSelector == true ifTrue:[ |
|
5592 | 624 |
sel := browser selectorToSearchFor. |
5591 | 625 |
] ifFalse:[ |
5592 | 626 |
isSelector == #globalName ifTrue:[ |
627 |
sel := browser globalNameToSearchFor ? LastGlobalSearched. |
|
628 |
] ifFalse:[ |
|
629 |
sel := browser stringToSearchFor. |
|
630 |
]. |
|
5591 | 631 |
]. |
632 |
sel size == 0 ifTrue:[ |
|
5592 | 633 |
"/ use last searchString |
634 |
lastSearchPatterns := browser lastSearchPatterns. |
|
635 |
lastSearchPatterns size > 0 ifTrue:[ |
|
636 |
sel := lastSearchPatterns first. |
|
637 |
]. |
|
5591 | 638 |
]. |
639 |
selectorHolder := sel asValue. |
|
640 |
||
641 |
inputField := self addComboBoxOn:selectorHolder tabable:true. |
|
642 |
inputField list:lastSearchPatterns . |
|
643 |
inputField selectAll. |
|
644 |
inputField |
|
5592 | 645 |
entryCompletionBlock:[ :contents | |
646 |
|s what| |
|
5591 | 647 |
|
5592 | 648 |
s := contents withoutSpaces. |
649 |
self topView |
|
650 |
withWaitCursorDo:[ |
|
651 |
isSelector == #globalName ifFalse:[ |
|
652 |
what := Smalltalk selectorCompletion:s. |
|
653 |
] ifTrue:[ |
|
654 |
what := Smalltalk globalNameCompletion:s. |
|
655 |
]. |
|
656 |
inputField contents:what first. |
|
657 |
(what at:2) size ~~ 1 ifTrue:[ |
|
658 |
browser window beep. |
|
659 |
]. |
|
660 |
]. |
|
661 |
]. |
|
5591 | 662 |
! |
663 |
||
664 |
addTextEntryFieldForCode |
|
6608 | 665 |
|initial box panel infoLabel helpButton errMessageField checkCodeAction| |
5591 | 666 |
|
667 |
box := View new. |
|
6443 | 668 |
box extent:(600 @ 200). |
5591 | 669 |
|
6608 | 670 |
panel := VariableHorizontalPanel in:box. |
671 |
panel origin:0.0@0.0 corner:(1.0@1.0). |
|
5591 | 672 |
|
6608 | 673 |
codeField := CodeView in:panel. |
674 |
"/ codeField origin:0.0@0.0 corner:(0.75@1.0). |
|
675 |
||
676 |
infoLabel := Label in:panel. |
|
677 |
"/ infoLabel origin:0.75@0.0 corner:(1.0@1.0). |
|
5591 | 678 |
infoLabel font:(codeField font). |
6608 | 679 |
infoLabel adjust:#left. |
5591 | 680 |
infoLabel label:'MetaPatterns: |
681 |
||
682 |
' , '`' allBold , ' = meta |
|
683 |
||
684 |
' , '@' allBold , ' = list/any |
|
685 |
' , '.' allBold , ' = statement |
|
686 |
' , '`' allBold , ' = recurse |
|
687 |
||
688 |
' , '`#n' allBold , ' any lit |
|
689 |
' , '`v' allBold , ' any var |
|
690 |
' , '`@e' allBold , ' any expr |
|
691 |
'. |
|
692 |
||
6608 | 693 |
panel relativeCorners:#(0.6 1.0). |
694 |
||
695 |
helpButton := Button label:(resources string:'Pattern Help') in:infoLabel. |
|
696 |
helpButton layout:((AlignmentOrigin fractionalFromPoint:0.5@1.0) |
|
6443 | 697 |
leftOffset:2 |
6608 | 698 |
topOffset:helpButton preferredExtent y negated; |
699 |
leftAlignmentFraction:0.5 topAlignmentFraction:0). |
|
5591 | 700 |
helpButton topInset:0.75@1.0. |
701 |
helpButton action:[self showHelpOnCodePatterns]. |
|
702 |
||
6608 | 703 |
|
5591 | 704 |
self addComponent:box tabable:true. |
705 |
errMessageField := (self addTextLabel:'') adjust:#left. |
|
706 |
errMessageField level:-1. |
|
707 |
self addCheckBox:(resources string:'Method') on:self isMethodHolder. |
|
708 |
||
709 |
checkCodeAction := [ self checkCodeIn:codeField notifying:errMessageField. ]. |
|
710 |
||
711 |
codeField modifiedChannel onChangeEvaluate:checkCodeAction. |
|
712 |
||
713 |
initial := browser selectionInCodeView. |
|
714 |
initial isEmptyOrNil ifTrue:[ |
|
6443 | 715 |
initial := LastCodeSearched ? '' |
5591 | 716 |
]. |
717 |
codeField contents:initial. |
|
718 |
checkCodeAction value. |
|
719 |
! |
|
720 |
||
721 |
checkCodeIn:codeField notifying:errMessageField |
|
722 |
|codeString tree errAction| |
|
723 |
||
724 |
codeString := codeField contents asString string. |
|
725 |
errAction := [:str :pos | |
|
6608 | 726 |
|line col badLine| |
5591 | 727 |
|
6608 | 728 |
line := codeField lineOfCharacterPosition:pos. |
729 |
col := (codeField colOfCharacterPosition:pos) max:1. |
|
5591 | 730 |
|
6608 | 731 |
badLine := (codeField listAt:line) ? '' |
5591 | 732 |
. col <= badLine size size ifTrue:[ |
6608 | 733 |
codeField |
734 |
listAt:line |
|
735 |
put:(badLine asText |
|
736 |
emphasisAt:col |
|
737 |
put:(UserPreferences current unknownIdentifierEmphasis)). |
|
738 |
"/ codeField selectFromCharacterPosition:pos to:pos. |
|
739 |
]. |
|
740 |
errMessageField label:('line: ',line printString,' ',str). |
|
741 |
errMessageField backgroundColor:Color red. |
|
742 |
codeField requestFocus. |
|
743 |
nil. |
|
744 |
]. |
|
5591 | 745 |
|
746 |
isMethodHolder value ifTrue:[ |
|
6608 | 747 |
tree := RBParser parseRewriteMethod:codeString onError: errAction. |
5591 | 748 |
] ifFalse:[ |
6608 | 749 |
tree := RBParser parseRewriteExpression:codeString onError: errAction. |
5591 | 750 |
]. |
6608 | 751 |
tree notNil ifTrue:[ |
752 |
errMessageField backgroundColor:View defaultViewBackgroundColor. |
|
753 |
errMessageField label:nil |
|
754 |
]. |
|
5591 | 755 |
codeField modifiedChannel setValue:false. |
756 |
! |
|
757 |
||
758 |
getClassesAndMethodsFor:where |
|
759 |
where == #everywhere ifTrue:[ |
|
760 |
classes := Smalltalk allClasses. |
|
761 |
^ self. |
|
762 |
]. |
|
763 |
where == #currentNameSpace ifTrue:[ |
|
764 |
classes := currentNamespace allClassesWithAllPrivateClasses. |
|
765 |
^ self. |
|
766 |
]. |
|
767 |
where == #currentClassesNameSpace ifTrue:[ |
|
768 |
currentClass isPrivate ifTrue:[ |
|
769 |
classes := currentClass topOwningClass nameSpace |
|
770 |
allClassesWithAllPrivateClasses. |
|
771 |
] ifFalse:[ |
|
772 |
classes := currentClass nameSpace allClassesWithAllPrivateClasses. |
|
773 |
]. |
|
774 |
^ self. |
|
775 |
]. |
|
776 |
where == #classCategories ifTrue:[ |
|
777 |
classes := Smalltalk allClasses |
|
778 |
select:[ :cls | selectedCategories includes:cls category. ]. |
|
779 |
classes := classes collect:[ :each | each theNonMetaclass. ]. |
|
780 |
^ self. |
|
781 |
]. |
|
782 |
(where == #classes or:[ where == #classesWithPrivateClasses. ]) ifTrue:[ |
|
783 |
classes := selectedClasses collect:[ :each | each theNonMetaclass. ]. |
|
784 |
^ self. |
|
785 |
]. |
|
786 |
(where == #classHierarchies |
|
787 |
or:[ where == #classHierarchiesWithPrivateClasses. ]) |
|
788 |
ifTrue:[ |
|
789 |
classes := IdentitySet new. |
|
790 |
selectedClasses do:[ :cls | |
|
791 |
classes addAll:cls theNonMetaclass withAllSubclasses. |
|
792 |
]. |
|
793 |
^ self. |
|
794 |
]. |
|
795 |
where == #ownersWithPrivateClasses ifTrue:[ |
|
796 |
classes := IdentitySet new. |
|
797 |
selectedClasses do:[ :cls | |
|
798 |
|c| |
|
799 |
||
800 |
c := cls theNonMetaclass. |
|
801 |
classes add:(c owningClass ? c). |
|
802 |
]. |
|
803 |
^ self. |
|
804 |
]. |
|
805 |
where == #ownersHierarchiesWithPrivateClasses ifTrue:[ |
|
806 |
classes := IdentitySet new. |
|
807 |
selectedClasses do:[ :cls | |
|
808 |
|c| |
|
809 |
||
810 |
c := cls theNonMetaclass. |
|
811 |
classes addAll:(c owningClass ? c) withAllSubclasses. |
|
812 |
]. |
|
813 |
^ self. |
|
814 |
]. |
|
815 |
(where == #classesAndSuperclasses) ifTrue:[ |
|
816 |
classes := IdentitySet new. |
|
817 |
selectedClasses do:[ :cls | |
|
818 |
classes addAll:cls theNonMetaclass withAllSuperclasses. |
|
819 |
]. |
|
820 |
^ self. |
|
821 |
]. |
|
822 |
(where == #listOfMethods) ifTrue:[ |
|
823 |
classes := nil. |
|
824 |
methods := browser methodListApp methodList value. |
|
825 |
^ self. |
|
826 |
]. |
|
827 |
(where == #listOfSelectedMethods) ifTrue:[ |
|
828 |
classes := nil. |
|
829 |
methods := browser selectedMethods value. |
|
830 |
^ self. |
|
831 |
]. |
|
832 |
! |
|
833 |
||
834 |
isMethodHolder |
|
835 |
isMethodHolder isNil ifTrue:[isMethodHolder := (LastCodeSearchWasMethod ? false) asValue]. |
|
836 |
^ isMethodHolder |
|
837 |
! ! |
|
838 |
||
839 |
!SearchDialog methodsFor:'setup-buttons'! |
|
840 |
||
841 |
addBrowseButton |
|
842 |
|b| |
|
843 |
||
844 |
b := Button label:(resources string:'Browse'). |
|
845 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[ |
|
846 |
self addButton:b before:nil. |
|
847 |
] ifFalse:[ |
|
848 |
self addButton:b after:nil. |
|
849 |
]. |
|
850 |
b |
|
851 |
action:[ |
|
852 |
openHow := #newBrowser. |
|
853 |
self doAccept. |
|
854 |
self okPressed. |
|
855 |
]. |
|
856 |
^ b. |
|
857 |
! |
|
858 |
||
859 |
addBufferButton |
|
860 |
|b| |
|
861 |
||
862 |
b := Button label:(resources string:'Add Buffer'). |
|
863 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[ |
|
864 |
self addButton:b before:nil. |
|
865 |
] ifFalse:[ |
|
866 |
self addButton:b after:nil. |
|
867 |
]. |
|
868 |
b |
|
869 |
action:[ |
|
870 |
openHow := #newBuffer. |
|
871 |
self doAccept. |
|
872 |
self okPressed. |
|
873 |
]. |
|
874 |
^ b. |
|
875 |
! |
|
876 |
||
877 |
addButtons |
|
6685 | 878 |
"add find/newBrowser/newBuffer buttons" |
879 |
||
5591 | 880 |
|prevButton| |
881 |
||
882 |
allowFind ifTrue:[ |
|
6685 | 883 |
defaultOpenHow := #showHere. |
884 |
prevButton := self addFindButton. |
|
5591 | 885 |
]. |
886 |
allowBrowser ifTrue:[ |
|
6685 | 887 |
defaultOpenHow := #newBrowser. |
888 |
prevButton := self addBrowseButton. |
|
5591 | 889 |
]. |
890 |
allowBuffer ifTrue:[ |
|
6685 | 891 |
defaultOpenHow := #newBuffer. |
892 |
prevButton := self addBufferButton. |
|
5591 | 893 |
]. |
894 |
prevButton notNil ifTrue:[ |
|
6685 | 895 |
prevButton isReturnButton:true. |
5591 | 896 |
]. |
897 |
self addAbortButton. |
|
898 |
! |
|
899 |
||
900 |
addFindButton |
|
901 |
|b| |
|
902 |
||
903 |
b := Button label:(resources string:'Find'). |
|
904 |
(DialogBox defaultOKButtonAtLeft) ifTrue:[ |
|
905 |
self addButton:b before:nil. |
|
906 |
] ifFalse:[ |
|
907 |
self addButton:b after:nil. |
|
908 |
]. |
|
909 |
b |
|
910 |
action:[ |
|
911 |
openHow := #showHere. |
|
912 |
self doAccept. |
|
913 |
self okPressed. |
|
914 |
]. |
|
915 |
^ b. |
|
916 |
! ! |
|
917 |
||
918 |
!SearchDialog class methodsFor:'documentation'! |
|
919 |
||
920 |
version |
|
6685 | 921 |
^ '$Header: /cvs/stx/stx/libtool/Tools_SearchDialog.st,v 1.12 2006-03-14 12:52:13 cg Exp $' |
5591 | 922 |
! ! |