author | tz |
Sat, 07 Feb 1998 15:02:17 +0100 | |
changeset 615 | 47f5ba2850d1 |
parent 608 | 8610ea5b501d |
child 616 | 9d9bccf8304c |
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' |
|
608 | 98 |
#'layout:' #(#LayoutFrame 221 0 676 0 822 0 1025 0) |
425 | 99 |
#'label:' 'Resource Browser' |
100 |
#'min:' #(#Point 400 300) |
|
101 |
#'max:' #(#Point 1152 864) |
|
608 | 102 |
#'bounds:' #(#Rectangle 221 676 823 1026) |
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 |
) |
|
608 | 204 |
|
205 |
"Modified: / 6.2.1998 / 03:45:21 / cg" |
|
425 | 206 |
! ! |
207 |
||
208 |
!ResourceSelectionBrowser methodsFor:'accessing - views'! |
|
209 |
||
467 | 210 |
classNameInputField |
211 |
||
212 |
^builder componentAt: #classNameInputField |
|
213 |
! |
|
214 |
||
425 | 215 |
listOfClassesView |
216 |
||
217 |
^builder componentAt: #listOfClassesView |
|
218 |
! ! |
|
219 |
||
220 |
!ResourceSelectionBrowser methodsFor:'aspects'! |
|
221 |
||
222 |
listOfClasses |
|
223 |
||
224 |
|holder| |
|
225 |
(holder := builder bindingAt:#listOfClasses) isNil ifTrue:[ |
|
226 |
builder aspectAt:#listOfClasses put: |
|
227 |
(holder := |
|
471 | 228 |
(TreeItem name: (resourceSuperclass ? #Object)) |
425 | 229 |
children: (OrderedCollection with: |
471 | 230 |
(TreeItem newAsTreeFromSmalltalkClass: (Smalltalk at:(resourceSuperclass ? #Object))))) |
425 | 231 |
]. |
232 |
^ holder |
|
233 |
||
234 |
||
235 |
! |
|
236 |
||
237 |
listOfResources |
|
238 |
||
239 |
|holder| |
|
240 |
(holder := builder bindingAt:#listOfResources) isNil ifTrue:[ |
|
241 |
builder aspectAt:#listOfResources put:(holder := List new). |
|
242 |
]. |
|
243 |
^ holder |
|
244 |
! |
|
245 |
||
246 |
selectionOfClass |
|
247 |
||
248 |
|holder| |
|
249 |
(holder := builder bindingAt:#selectionOfClass) isNil ifTrue:[ |
|
250 |
builder aspectAt:#selectionOfClass put:(holder := ValueHolder new). |
|
251 |
]. |
|
252 |
^ holder |
|
253 |
! |
|
254 |
||
255 |
selectionOfResource |
|
256 |
||
257 |
|holder| |
|
258 |
(holder := builder bindingAt:#selectionOfResource) isNil ifTrue:[ |
|
259 |
builder aspectAt:#selectionOfResource put:(holder := '' asValue). |
|
260 |
]. |
|
261 |
^ holder |
|
262 |
! |
|
263 |
||
467 | 264 |
valueOfClassName |
265 |
||
266 |
|holder| |
|
267 |
(holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[ |
|
268 |
builder aspectAt:#valueOfClassName put:(holder := '' asValue). |
|
269 |
]. |
|
270 |
^ holder |
|
271 |
! |
|
272 |
||
425 | 273 |
valueOfSelector |
274 |
||
275 |
|holder| |
|
276 |
(holder := builder bindingAt:#valueOfSelector) isNil ifTrue:[ |
|
277 |
builder aspectAt:#valueOfSelector put:(holder := '' asValue). |
|
278 |
]. |
|
279 |
^ holder |
|
280 |
! ! |
|
281 |
||
282 |
!ResourceSelectionBrowser methodsFor:'callbacks'! |
|
283 |
||
284 |
classSelected: anIndex |
|
285 |
||
286 |
self selectionOfClass value isNil ifTrue: [^nil]. |
|
287 |
self withWaitCursorDo: |
|
288 |
[ |
|
289 |
|clsName| |
|
517 | 290 |
resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes]. |
425 | 291 |
clsName := self listOfClassesView list at: anIndex. |
477 | 292 |
self valueOfClassName value: clsName. |
425 | 293 |
self class lastSelection: clsName. |
294 |
self listOfResources contents: |
|
523 | 295 |
((((Smalltalk at: clsName) |
425 | 296 |
class methodDictionary |
297 |
asOrderedCollection select: |
|
523 | 298 |
[:m| m resources notNil and: [resourceTypes includes: m resourceType]])) |
299 |
collect: [:m| Row new method: m]). |
|
425 | 300 |
] |
301 |
! |
|
302 |
||
303 |
resourceDoubleClicked |
|
304 |
||
305 |
resourceMethod := self selectionOfResource value. |
|
306 |
accept value: true. |
|
307 |
self close |
|
308 |
! |
|
309 |
||
310 |
resourceSelected |
|
311 |
||
312 |
resourceMethod := self selectionOfResource value. |
|
313 |
self valueOfSelector value: self selectionOfResource value selector |
|
314 |
! ! |
|
315 |
||
316 |
!ResourceSelectionBrowser methodsFor:'initialization'! |
|
317 |
||
318 |
postBuildWith:aBuilder |
|
319 |
||
467 | 320 |
|classSelection classSelectionBlock| |
563 | 321 |
allClasses := Object withAllSubclasses. |
517 | 322 |
classSelection := resourceClass ? self class lastSelection ? #Object. |
477 | 323 |
classSelectionBlock := |
324 |
[:clsPattern| |
|
325 |
|foundClass classes| |
|
326 |
((foundClass := Smalltalk at: clsPattern asSymbol) isNil or: |
|
327 |
[foundClass name ~= clsPattern]) |
|
328 |
ifTrue: |
|
329 |
[ |
|
330 |
classes := allClasses select: [:cls| cls name size >= clsPattern size]. |
|
331 |
1 to: clsPattern size do: |
|
332 |
[:i| |
|
333 |
classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)]. |
|
334 |
]. |
|
335 |
foundClass := classes at: 1 ifAbsent: [nil] |
|
336 |
]. |
|
337 |
foundClass notNil |
|
338 |
ifTrue: |
|
339 |
[ |
|
340 |
self listOfClassesView selectFromListOfNames: (foundClass |
|
341 |
withAllSuperclasses reverse collect: [:cls| cls name asString]) |
|
342 |
]. |
|
343 |
self valueOfClassName value: clsPattern |
|
344 |
]. |
|
467 | 345 |
classSelectionBlock value: classSelection. |
346 |
self valueOfClassName value: classSelection. |
|
523 | 347 |
self selectionOfResource value: (self listOfResources detect: [:m| m selector == resourceMethod] ifNone: nil). |
467 | 348 |
self classNameInputField entryCompletionBlock: |
349 |
[:value| |
|
350 |
|what| |
|
351 |
what := Smalltalk classnameCompletion: value withoutSpaces. |
|
352 |
self classNameInputField contents:what first. |
|
477 | 353 |
(what at:2) size ~~ 1 ifTrue:[Display beep]. |
467 | 354 |
classSelectionBlock value: self classNameInputField contents |
355 |
]. |
|
425 | 356 |
^super postBuildWith:aBuilder |
357 |
||
358 |
! ! |
|
359 |
||
360 |
!ResourceSelectionBrowser methodsFor:'instance creation'! |
|
361 |
||
362 |
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes |
|
363 |
||
364 |
|cls sel| |
|
517 | 365 |
resourceMethod := aSelector. |
425 | 366 |
resourceTypes := aResourceTypes. |
367 |
resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol]. |
|
368 |
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
|
369 |
self valueOfSelector value:(aSelector ? ''). |
425 | 370 |
|
463 | 371 |
self open. |
372 |
||
481
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
373 |
(self selectionOfClass value notNil |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
374 |
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
|
375 |
and:[accept value]] |
e2e1ea013229
Take care of nil selectors in #openOnSuperClass:andClass:andSelector:
Stefan Vogel <sv@exept.de>
parents:
477
diff
changeset
|
376 |
) ifTrue:[ |
463 | 377 |
^cls name, ' ', self valueOfSelector value |
425 | 378 |
]. |
379 |
^nil |
|
380 |
! ! |
|
381 |
||
382 |
!ResourceSelectionBrowser methodsFor:'startup / release'! |
|
383 |
||
384 |
closeCancel |
|
385 |
||
386 |
resourceMethod := nil. |
|
387 |
super closeCancel |
|
388 |
||
389 |
||
390 |
||
391 |
! ! |
|
392 |
||
523 | 393 |
!ResourceSelectionBrowser::Row methodsFor:'accessing'! |
394 |
||
395 |
iconOn:aGC |
|
396 |
||
397 |
icon isNil ifTrue: [icon := method iconOn: aGC]. |
|
398 |
^icon |
|
399 |
! |
|
400 |
||
401 |
method: aMethod |
|
402 |
||
403 |
method := aMethod |
|
404 |
! |
|
405 |
||
406 |
resourceType |
|
407 |
||
408 |
resourceType isNil ifTrue: [resourceType := method resourceType]. |
|
409 |
^resourceType |
|
410 |
! |
|
411 |
||
412 |
selector |
|
413 |
||
414 |
selector isNil ifTrue: [selector := method who methodSelector]. |
|
415 |
^selector |
|
416 |
! ! |
|
417 |
||
425 | 418 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
419 |
||
420 |
version |
|
421 |
^ '$Header$' |
|
422 |
! ! |