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