author | Claus Gittinger <cg@exept.de> |
Sat, 07 Feb 1998 22:55:40 +0100 | |
changeset 628 | 8992bc061c11 |
parent 623 | c8a99cea56f7 |
child 632 | 930b778d5e28 |
permissions | -rw-r--r-- |
425 | 1 |
" |
504 | 2 |
COPYRIGHT (c) 1997 by eXept Software AG |
425 | 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 |
||
13 |
||
14 |
SelectionBrowser subclass:#ResourceSelectionBrowser |
|
477 | 15 |
instanceVariableNames:'resourceMethod resourceClass resourceSuperclass resourceTypes |
16 |
allClasses' |
|
425 | 17 |
classVariableNames:'' |
18 |
poolDictionaries:'' |
|
619 | 19 |
category:'Interface-Dialogs' |
425 | 20 |
! |
21 |
||
523 | 22 |
Object subclass:#Row |
23 |
instanceVariableNames:'method icon resourceType selector' |
|
24 |
classVariableNames:'' |
|
25 |
poolDictionaries:'' |
|
26 |
privateIn:ResourceSelectionBrowser |
|
27 |
! |
|
28 |
||
425 | 29 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
30 |
||
31 |
copyright |
|
32 |
" |
|
504 | 33 |
COPYRIGHT (c) 1997 by eXept Software AG |
425 | 34 |
All Rights Reserved |
35 |
||
36 |
This software is furnished under a license and may be used |
|
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
||
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
504 | 48 |
[start with:] |
49 |
ResourceSelectionBrowser open |
|
50 |
||
51 |
[author:] |
|
52 |
Thomas Zwick |
|
425 | 53 |
" |
54 |
! ! |
|
55 |
||
56 |
!ResourceSelectionBrowser class methodsFor:'instance creation'! |
|
57 |
||
58 |
request: aTitle onSuperclass: aSuperclass andClass: aClass andSelector: aSelector withResourceTypes: aResourceTypes |
|
59 |
||
60 |
"self |
|
61 |
request: 'Select A Resource Selector' |
|
62 |
onSuperclass: #ApplicationModel |
|
63 |
andClass: #ToolApplicationModel |
|
64 |
andSelector: #saveIcon |
|
517 | 65 |
withResourceTypes: #(image) |
425 | 66 |
" |
67 |
||
68 |
^self new |
|
69 |
title: aTitle; |
|
70 |
openOnSuperclass: aSuperclass |
|
71 |
andClass: aClass |
|
72 |
andSelector: aSelector |
|
73 |
withResourceTypes: aResourceTypes |
|
74 |
! ! |
|
75 |
||
76 |
!ResourceSelectionBrowser class methodsFor:'interface specs'! |
|
77 |
||
78 |
windowSpec |
|
79 |
"this window spec was automatically generated by the ST/X UIPainter" |
|
80 |
||
81 |
"do not manually edit this - the painter/builder may not be able to |
|
82 |
handle the specification if its corrupted." |
|
83 |
||
84 |
" |
|
85 |
UIPainter new openOnClass:ResourceSelectionBrowser andSelector:#windowSpec |
|
86 |
ResourceSelectionBrowser new openInterface:#windowSpec |
|
87 |
" |
|
88 |
"ResourceSelectionBrowser open" |
|
89 |
||
90 |
<resource: #canvas> |
|
91 |
||
92 |
^ |
|
468 | 93 |
|
425 | 94 |
#(#FullSpec |
95 |
#'window:' |
|
96 |
#(#WindowSpec |
|
97 |
#'name:' 'Resource Browser' |
|
616 | 98 |
#'layout:' #(#LayoutFrame 252 0 290 0 851 0 639 0) |
425 | 99 |
#'label:' 'Resource Browser' |
100 |
#'min:' #(#Point 400 300) |
|
101 |
#'max:' #(#Point 1152 864) |
|
616 | 102 |
#'bounds:' #(#Rectangle 252 290 852 640) |
425 | 103 |
#'usePreferredExtent:' false |
104 |
) |
|
105 |
#'component:' |
|
106 |
#(#SpecCollection |
|
107 |
#'collection:' |
|
108 |
#( |
|
109 |
#(#VariableHorizontalPanelSpec |
|
110 |
#'name:' 'variableHorizontalPanel' |
|
111 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -40 1.0) |
|
112 |
#'component:' |
|
113 |
#(#SpecCollection |
|
114 |
#'collection:' |
|
115 |
#( |
|
116 |
#(#ViewSpec |
|
117 |
#'name:' 'view1' |
|
118 |
#'component:' |
|
119 |
#(#SpecCollection |
|
120 |
#'collection:' |
|
121 |
#( |
|
122 |
#(#SelectionInTreeViewSpec |
|
123 |
#'name:' 'listOfClassesView' |
|
467 | 124 |
#'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -22 1.0) |
425 | 125 |
#'model:' #selectionOfClass |
126 |
#'hasHorizontalScrollBar:' true |
|
127 |
#'hasVerticalScrollBar:' true |
|
128 |
#'miniScrollerHorizontal:' true |
|
129 |
#'showRoot:' false |
|
468 | 130 |
#'showDirectoryIndicatorForRoot:' false |
131 |
#'showDirectoryIndicator:' true |
|
425 | 132 |
#'valueChangeSelector:' #'classSelected:' |
133 |
#'hierarchicalList:' #listOfClasses |
|
134 |
) |
|
467 | 135 |
#(#InputFieldSpec |
136 |
#'name:' 'classNameInputField' |
|
608 | 137 |
#'layout:' #(#LayoutFrame 2 0.0 -22 1 -1 1.0 0 1) |
467 | 138 |
#'model:' #valueOfClassName |
139 |
) |
|
425 | 140 |
) |
141 |
) |
|
142 |
) |
|
143 |
#(#ViewSpec |
|
144 |
#'name:' 'view2' |
|
145 |
#'component:' |
|
146 |
#(#SpecCollection |
|
147 |
#'collection:' |
|
148 |
#( |
|
149 |
#(#DataSetSpec |
|
150 |
#'name:' 'resourcesDataSetView' |
|
608 | 151 |
#'layout:' #(#LayoutFrame 2 0.0 0 0.0 -2 1.0 -22 1.0) |
425 | 152 |
#'model:' #selectionOfResource |
153 |
#'hasHorizontalScrollBar:' true |
|
154 |
#'hasVerticalScrollBar:' true |
|
155 |
#'miniScrollerHorizontal:' true |
|
523 | 156 |
#'rowClassName:' 'ResourceSelectionBrowser::Row' |
425 | 157 |
#'dataList:' #listOfResources |
158 |
#'useIndex:' false |
|
477 | 159 |
#'has3Dsepartors:' true |
425 | 160 |
#'doubleClickSelector:' #resourceDoubleClicked |
161 |
#'valueChangeSelector:' #resourceSelected |
|
162 |
#'verticalSpacing:' 1 |
|
163 |
#'columns:' |
|
164 |
#( |
|
165 |
#(#DataSetColumnSpec |
|
166 |
#'width:' 20 |
|
523 | 167 |
#'height:' 20 |
425 | 168 |
#'printSelector:' #'iconOn:' |
169 |
#'canSelect:' false |
|
170 |
) |
|
171 |
#(#DataSetColumnSpec |
|
172 |
#'label:' 'Selector' |
|
173 |
#'model:' #selector |
|
174 |
#'canSelect:' false |
|
175 |
) |
|
176 |
#(#DataSetColumnSpec |
|
177 |
#'label:' 'Resource' |
|
178 |
#'model:' #resourceType |
|
179 |
#'canSelect:' false |
|
180 |
) |
|
181 |
) |
|
182 |
) |
|
183 |
#(#InputFieldSpec |
|
184 |
#'name:' 'selectorInputField' |
|
608 | 185 |
#'layout:' #(#LayoutFrame 2 0.0 -22 1 -2 1.0 0 1) |
425 | 186 |
#'model:' #valueOfSelector |
187 |
) |
|
188 |
) |
|
189 |
) |
|
190 |
) |
|
191 |
) |
|
192 |
) |
|
193 |
#'handles:' #(#Any 0.5 1.0) |
|
194 |
) |
|
436 | 195 |
#(#UISubSpecification |
196 |
#'name:' 'SubSpecification' |
|
197 |
#'layout:' #(#LayoutFrame 2 0.0 -32 1 -2 1.0 -8 1.0) |
|
198 |
#'majorKey:' #ToolApplicationModel |
|
199 |
#'minorKey:' #windowSpecForCommitWithoutChannels |
|
425 | 200 |
) |
201 |
) |
|
202 |
) |
|
203 |
) |
|
204 |
! ! |
|
205 |
||
206 |
!ResourceSelectionBrowser methodsFor:'accessing - views'! |
|
207 |
||
467 | 208 |
classNameInputField |
209 |
||
210 |
^builder componentAt: #classNameInputField |
|
211 |
! |
|
212 |
||
425 | 213 |
listOfClassesView |
214 |
||
215 |
^builder componentAt: #listOfClassesView |
|
216 |
! ! |
|
217 |
||
218 |
!ResourceSelectionBrowser methodsFor:'aspects'! |
|
219 |
||
220 |
listOfClasses |
|
221 |
||
222 |
|holder| |
|
223 |
(holder := builder bindingAt:#listOfClasses) isNil ifTrue:[ |
|
224 |
builder aspectAt:#listOfClasses put: |
|
225 |
(holder := |
|
471 | 226 |
(TreeItem name: (resourceSuperclass ? #Object)) |
425 | 227 |
children: (OrderedCollection with: |
471 | 228 |
(TreeItem newAsTreeFromSmalltalkClass: (Smalltalk at:(resourceSuperclass ? #Object))))) |
425 | 229 |
]. |
230 |
^ holder |
|
231 |
||
232 |
||
233 |
! |
|
234 |
||
235 |
listOfResources |
|
236 |
||
237 |
|holder| |
|
238 |
(holder := builder bindingAt:#listOfResources) isNil ifTrue:[ |
|
239 |
builder aspectAt:#listOfResources put:(holder := List new). |
|
240 |
]. |
|
241 |
^ holder |
|
242 |
! |
|
243 |
||
244 |
selectionOfClass |
|
245 |
||
246 |
|holder| |
|
247 |
(holder := builder bindingAt:#selectionOfClass) isNil ifTrue:[ |
|
248 |
builder aspectAt:#selectionOfClass put:(holder := ValueHolder new). |
|
249 |
]. |
|
250 |
^ holder |
|
251 |
! |
|
252 |
||
253 |
selectionOfResource |
|
254 |
||
255 |
|holder| |
|
256 |
(holder := builder bindingAt:#selectionOfResource) isNil ifTrue:[ |
|
257 |
builder aspectAt:#selectionOfResource put:(holder := '' asValue). |
|
258 |
]. |
|
259 |
^ holder |
|
260 |
! |
|
261 |
||
467 | 262 |
valueOfClassName |
263 |
||
264 |
|holder| |
|
265 |
(holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[ |
|
266 |
builder aspectAt:#valueOfClassName put:(holder := '' asValue). |
|
267 |
]. |
|
268 |
^ holder |
|
269 |
! |
|
270 |
||
425 | 271 |
valueOfSelector |
272 |
||
273 |
|holder| |
|
274 |
(holder := builder bindingAt:#valueOfSelector) isNil ifTrue:[ |
|
275 |
builder aspectAt:#valueOfSelector put:(holder := '' asValue). |
|
276 |
]. |
|
277 |
^ holder |
|
278 |
! ! |
|
279 |
||
280 |
!ResourceSelectionBrowser methodsFor:'callbacks'! |
|
281 |
||
282 |
classSelected: anIndex |
|
283 |
||
284 |
self selectionOfClass value isNil ifTrue: [^nil]. |
|
285 |
self withWaitCursorDo: |
|
286 |
[ |
|
287 |
|clsName| |
|
517 | 288 |
resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes]. |
425 | 289 |
clsName := self listOfClassesView list at: anIndex. |
477 | 290 |
self valueOfClassName value: clsName. |
425 | 291 |
self class lastSelection: clsName. |
292 |
self listOfResources contents: |
|
523 | 293 |
((((Smalltalk at: clsName) |
425 | 294 |
class methodDictionary |
295 |
asOrderedCollection select: |
|
523 | 296 |
[:m| m resources notNil and: [resourceTypes includes: m resourceType]])) |
297 |
collect: [:m| Row new method: m]). |
|
425 | 298 |
] |
299 |
! |
|
300 |
||
301 |
resourceDoubleClicked |
|
302 |
||
303 |
resourceMethod := self selectionOfResource value. |
|
304 |
accept value: true. |
|
305 |
self close |
|
306 |
! |
|
307 |
||
308 |
resourceSelected |
|
309 |
||
310 |
resourceMethod := self selectionOfResource value. |
|
311 |
self valueOfSelector value: self selectionOfResource value selector |
|
312 |
! ! |
|
313 |
||
314 |
!ResourceSelectionBrowser methodsFor:'instance creation'! |
|
315 |
||
316 |
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes |
|
317 |
||
318 |
|cls sel| |
|
517 | 319 |
resourceMethod := aSelector. |
425 | 320 |
resourceTypes := aResourceTypes. |
321 |
resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol]. |
|
322 |
resourceClass := aClassOrSymbol isClass ifTrue: [aClassOrSymbol name] ifFalse: [aClassOrSymbol]. |
|
481
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
323 |
self valueOfSelector value:(aSelector ? ''). |
425 | 324 |
|
463 | 325 |
self open. |
326 |
||
481
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
327 |
(self selectionOfClass value notNil |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
328 |
and:[(cls := Smalltalk at: self selectionOfClass value name) isClass |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
329 |
and:[accept value]] |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
330 |
) ifTrue:[ |
463 | 331 |
^cls name, ' ', self valueOfSelector value |
425 | 332 |
]. |
333 |
^nil |
|
334 |
! ! |
|
335 |
||
336 |
!ResourceSelectionBrowser methodsFor:'startup / release'! |
|
337 |
||
338 |
closeCancel |
|
339 |
||
340 |
resourceMethod := nil. |
|
341 |
super closeCancel |
|
342 |
||
343 |
||
344 |
||
623 | 345 |
! |
346 |
||
347 |
postBuildWith:aBuilder |
|
348 |
||
349 |
|classSelection classSelectionBlock| |
|
350 |
allClasses := Object withAllSubclasses. |
|
351 |
classSelection := resourceClass ? self class lastSelection ? #Object. |
|
352 |
classSelectionBlock := |
|
353 |
[:clsPattern| |
|
354 |
|foundClass classes| |
|
355 |
((foundClass := Smalltalk at: clsPattern printString asSymbol) isClass not or: |
|
356 |
[foundClass name ~= clsPattern]) |
|
357 |
ifTrue: |
|
358 |
[ |
|
359 |
classes := allClasses select: [:cls| cls name size >= clsPattern size]. |
|
360 |
1 to: clsPattern size do: |
|
361 |
[:i| |
|
362 |
classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)]. |
|
363 |
]. |
|
364 |
foundClass := classes at: 1 ifAbsent: [nil] |
|
365 |
]. |
|
366 |
foundClass notNil |
|
367 |
ifTrue: |
|
368 |
[ |
|
369 |
self listOfClassesView |
|
370 |
selectFromListOfNames: (foundClass |
|
371 |
withAllSuperclasses reverse collect: [:cls| cls name asString]); |
|
372 |
selectedNodeExpand: true |
|
373 |
]. |
|
374 |
self valueOfClassName value: clsPattern |
|
375 |
]. |
|
376 |
classSelectionBlock value: classSelection. |
|
377 |
self valueOfClassName value: classSelection. |
|
378 |
self selectionOfResource value: (self listOfResources detect: [:m| m selector == resourceMethod] ifNone: nil). |
|
379 |
self classNameInputField entryCompletionBlock: |
|
380 |
[:value| |
|
381 |
|what| |
|
382 |
what := Smalltalk classnameCompletion: value withoutSpaces. |
|
383 |
self classNameInputField contents:what first. |
|
384 |
(what at:2) size ~~ 1 ifTrue:[Display beep]. |
|
385 |
classSelectionBlock value: self classNameInputField contents |
|
386 |
]. |
|
387 |
||
388 |
self listOfClassesView selectedNodeExpand: true. |
|
389 |
||
390 |
^super postBuildWith:aBuilder |
|
391 |
||
425 | 392 |
! ! |
393 |
||
523 | 394 |
!ResourceSelectionBrowser::Row methodsFor:'accessing'! |
395 |
||
396 |
iconOn:aGC |
|
397 |
||
398 |
icon isNil ifTrue: [icon := method iconOn: aGC]. |
|
399 |
^icon |
|
400 |
! |
|
401 |
||
402 |
method: aMethod |
|
403 |
||
404 |
method := aMethod |
|
405 |
! |
|
406 |
||
407 |
resourceType |
|
408 |
||
409 |
resourceType isNil ifTrue: [resourceType := method resourceType]. |
|
410 |
^resourceType |
|
411 |
! |
|
412 |
||
413 |
selector |
|
414 |
||
415 |
selector isNil ifTrue: [selector := method who methodSelector]. |
|
416 |
^selector |
|
417 |
! ! |
|
418 |
||
425 | 419 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
420 |
||
421 |
version |
|
422 |
^ '$Header$' |
|
423 |
! ! |