author | Stefan Vogel <sv@exept.de> |
Thu, 05 Feb 1998 13:43:45 +0100 | |
changeset 587 | dd545d089d95 |
parent 563 | 81f54df8d333 |
child 596 | d7613f6ab331 |
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:'' |
|
19 |
category:'Interface-Advanced-Tools' |
|
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' |
|
523 | 98 |
#'layout:' #(#LayoutFrame 460 0 343 0 871 0 642 0) |
425 | 99 |
#'label:' 'Resource Browser' |
100 |
#'min:' #(#Point 400 300) |
|
101 |
#'max:' #(#Point 1152 864) |
|
523 | 102 |
#'bounds:' #(#Rectangle 460 343 872 643) |
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' |
|
472 | 137 |
#'layout:' #(#LayoutFrame 0 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' |
|
151 |
#'layout:' #(#LayoutFrame 2 0.0 0 0.0 2 1.0 -22 1.0) |
|
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' |
|
185 |
#'layout:' #(#LayoutFrame 2 0.0 -22 1 2 1.0 0 1) |
|
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:'initialization'! |
|
315 |
||
316 |
postBuildWith:aBuilder |
|
317 |
||
467 | 318 |
|classSelection classSelectionBlock| |
563 | 319 |
allClasses := Object withAllSubclasses. |
517 | 320 |
classSelection := resourceClass ? self class lastSelection ? #Object. |
477 | 321 |
classSelectionBlock := |
322 |
[:clsPattern| |
|
323 |
|foundClass classes| |
|
324 |
((foundClass := Smalltalk at: clsPattern asSymbol) isNil or: |
|
325 |
[foundClass name ~= clsPattern]) |
|
326 |
ifTrue: |
|
327 |
[ |
|
328 |
classes := allClasses select: [:cls| cls name size >= clsPattern size]. |
|
329 |
1 to: clsPattern size do: |
|
330 |
[:i| |
|
331 |
classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)]. |
|
332 |
]. |
|
333 |
foundClass := classes at: 1 ifAbsent: [nil] |
|
334 |
]. |
|
335 |
foundClass notNil |
|
336 |
ifTrue: |
|
337 |
[ |
|
338 |
self listOfClassesView selectFromListOfNames: (foundClass |
|
339 |
withAllSuperclasses reverse collect: [:cls| cls name asString]) |
|
340 |
]. |
|
341 |
self valueOfClassName value: clsPattern |
|
342 |
]. |
|
467 | 343 |
classSelectionBlock value: classSelection. |
344 |
self valueOfClassName value: classSelection. |
|
523 | 345 |
self selectionOfResource value: (self listOfResources detect: [:m| m selector == resourceMethod] ifNone: nil). |
467 | 346 |
self classNameInputField entryCompletionBlock: |
347 |
[:value| |
|
348 |
|what| |
|
349 |
what := Smalltalk classnameCompletion: value withoutSpaces. |
|
350 |
self classNameInputField contents:what first. |
|
477 | 351 |
(what at:2) size ~~ 1 ifTrue:[Display beep]. |
467 | 352 |
classSelectionBlock value: self classNameInputField contents |
353 |
]. |
|
425 | 354 |
^super postBuildWith:aBuilder |
355 |
||
356 |
! ! |
|
357 |
||
358 |
!ResourceSelectionBrowser methodsFor:'instance creation'! |
|
359 |
||
360 |
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes |
|
361 |
||
362 |
|cls sel| |
|
517 | 363 |
resourceMethod := aSelector. |
425 | 364 |
resourceTypes := aResourceTypes. |
365 |
resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol]. |
|
366 |
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
|
367 |
self valueOfSelector value:(aSelector ? ''). |
425 | 368 |
|
463 | 369 |
self open. |
370 |
||
481
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
371 |
(self selectionOfClass value notNil |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
372 |
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
|
373 |
and:[accept value]] |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
374 |
) ifTrue:[ |
463 | 375 |
^cls name, ' ', self valueOfSelector value |
425 | 376 |
]. |
377 |
^nil |
|
378 |
! ! |
|
379 |
||
380 |
!ResourceSelectionBrowser methodsFor:'startup / release'! |
|
381 |
||
382 |
closeCancel |
|
383 |
||
384 |
resourceMethod := nil. |
|
385 |
super closeCancel |
|
386 |
||
387 |
||
388 |
||
389 |
! ! |
|
390 |
||
523 | 391 |
!ResourceSelectionBrowser::Row methodsFor:'accessing'! |
392 |
||
393 |
iconOn:aGC |
|
394 |
||
395 |
icon isNil ifTrue: [icon := method iconOn: aGC]. |
|
396 |
^icon |
|
397 |
! |
|
398 |
||
399 |
method: aMethod |
|
400 |
||
401 |
method := aMethod |
|
402 |
! |
|
403 |
||
404 |
resourceType |
|
405 |
||
406 |
resourceType isNil ifTrue: [resourceType := method resourceType]. |
|
407 |
^resourceType |
|
408 |
! |
|
409 |
||
410 |
selector |
|
411 |
||
412 |
selector isNil ifTrue: [selector := method who methodSelector]. |
|
413 |
^selector |
|
414 |
! ! |
|
415 |
||
425 | 416 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
417 |
||
418 |
version |
|
419 |
^ '$Header$' |
|
420 |
! ! |