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