author | tz |
Sat, 18 Apr 1998 16:53:48 +0200 | |
changeset 782 | 62f2cd2978d5 |
parent 773 | de5c99bd3078 |
child 786 | 17a84830f0ee |
permissions | -rw-r--r-- |
425 | 1 |
" |
771 | 2 |
COPYRIGHT (c) 1997-1998 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 |
771 | 16 |
allClasses classSelectionBlock readResourcesProcess |
17 |
mayReadResources' |
|
425 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
619 | 20 |
category:'Interface-Dialogs' |
425 | 21 |
! |
22 |
||
771 | 23 |
Object subclass:#ResourceMethod |
523 | 24 |
instanceVariableNames:'method icon resourceType selector' |
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:ResourceSelectionBrowser |
|
28 |
! |
|
29 |
||
425 | 30 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
771 | 34 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
425 | 35 |
All Rights Reserved |
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
||
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
746 | 49 |
The ResourceSelectionBrowser allows you to browse in class hierarchies |
771 | 50 |
and to select resource methods for loading or to saving resource |
51 |
specifications (#canvas, #menu, etc.). |
|
52 |
||
53 |
[instance variables:] |
|
54 |
resourceMethod <Symbol> selector of the resource spec |
|
55 |
resourceClass <Symbol> class of the resource spec |
|
56 |
resourceSuperclass <Symbol> root class of the tree list |
|
57 |
resourceTypes <Array> allowed resource types |
|
58 |
allClasses <Array> list of the subclasses of resourceSuperclass |
|
59 |
classSelectionBlock <Block> by evaluating this block the class selection is done |
|
60 |
readResourcesProcess <Process> process of reading the resource methods |
|
61 |
mayReadResources <Boolean> flag whether may read the resource methods |
|
746 | 62 |
|
504 | 63 |
[start with:] |
771 | 64 |
ResourceSelectionBrowser open |
504 | 65 |
|
66 |
[author:] |
|
771 | 67 |
Thomas Zwick, eXept Software AG |
425 | 68 |
" |
69 |
! ! |
|
70 |
||
71 |
!ResourceSelectionBrowser class methodsFor:'instance creation'! |
|
72 |
||
649 | 73 |
request: aTitle onSuperclass: aSuperclass andClass: aClass andSelector: aSelector withResourceTypes: resourceTypes |
771 | 74 |
"opens a ResourceSelectionBrowser |
75 |
with aTitle |
|
76 |
on aSuperclassOrSymbol, |
|
77 |
and aClassOrSymbol, |
|
78 |
and aSelector, |
|
79 |
with allowed aResourceTypes" |
|
649 | 80 |
" |
81 |
ResourceSelectionBrowser |
|
771 | 82 |
request: 'Select a Resource Selector' |
83 |
onSuperclass: #ApplicationModel |
|
84 |
andClass: #ToolApplicationModel |
|
85 |
andSelector: #saveIcon |
|
86 |
withResourceTypes: #(image) |
|
425 | 87 |
" |
88 |
||
89 |
^self new |
|
771 | 90 |
title: aTitle; |
91 |
openOnSuperclass: aSuperclass |
|
92 |
andClass: aClass |
|
93 |
andSelector: aSelector |
|
94 |
withResourceTypes: resourceTypes |
|
425 | 95 |
! ! |
96 |
||
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
97 |
!ResourceSelectionBrowser class methodsFor:'callbacks - default'! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
98 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
99 |
treeViewChildren |
771 | 100 |
"returns the children for the contents (class) of aTreeItem as a block" |
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
101 |
|
680 | 102 |
^[:aTreeItem| |
771 | 103 |
|classes| |
104 |
classes := OrderedCollection new. |
|
105 |
classes addAll: ((aTreeItem contents subclasses reject: [:cls| cls isPrivate]) asSortedCollection: [:i1 :i2| i1 name < i2 name]). |
|
106 |
classes addAll: (aTreeItem contents privateClasses asSortedCollection: [:i1 :i2| i1 name < i2 name]). |
|
107 |
classes |
|
718 | 108 |
] |
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
109 |
! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
110 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
111 |
treeViewContents |
771 | 112 |
"returns the default contents of the root of the class tree list" |
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
113 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
114 |
^Smalltalk at: #Object |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
115 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
116 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
117 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
118 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
119 |
! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
120 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
121 |
treeViewIcon |
771 | 122 |
"returns the icon for aTreeItem as a block" |
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
123 |
|
718 | 124 |
^[:aTreeItem| |
771 | 125 |
|icon| |
126 |
icon := self iconClass. |
|
127 |
aTreeItem contents isPrivate |
|
128 |
ifTrue: |
|
129 |
[ |
|
130 |
icon := self iconPrivateClass |
|
131 |
]. |
|
132 |
icon |
|
133 |
] |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
134 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
135 |
! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
136 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
137 |
treeViewLabel |
771 | 138 |
"returns the label for aTreeItem as a block" |
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
139 |
|
718 | 140 |
^[:aTreeItem| |
771 | 141 |
|label superCls| |
142 |
label := aTreeItem contents name. |
|
143 |
(aTreeItem contents isPrivate and: [aTreeItem parent contents ~~ (superCls := aTreeItem contents superclass)]) |
|
144 |
ifTrue: [label := label, ' (', superCls name, ')']. |
|
145 |
label |
|
718 | 146 |
] |
147 |
||
148 |
||
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
149 |
! ! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
150 |
|
730 | 151 |
!ResourceSelectionBrowser class methodsFor:'image specs'! |
152 |
||
153 |
iconClass |
|
746 | 154 |
"This resource specification was automatically generated |
155 |
by the ImageEditor of ST/X." |
|
156 |
||
157 |
"Do not manually edit this!! If it is corrupted, |
|
158 |
the ImageEditor may not be able to read the specification." |
|
159 |
||
730 | 160 |
" |
746 | 161 |
ImageEditor openOnClass:self andSelector:#iconClass |
730 | 162 |
" |
163 |
||
164 |
<resource: #image> |
|
165 |
||
166 |
^Icon |
|
771 | 167 |
constantNamed:#'ResourceSelectionBrowser iconClass' |
168 |
ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@UUUUU!!Q****(@F**** @Z****@A****(@F**** @Z****@A****(LF**** TZ****@A****(@F**** @Z****@B@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]! |
|
730 | 169 |
|
170 |
iconPrivateClass |
|
746 | 171 |
"This resource specification was automatically generated |
172 |
by the ImageEditor of ST/X." |
|
173 |
||
174 |
"Do not manually edit this!! If it is corrupted, |
|
175 |
the ImageEditor may not be able to read the specification." |
|
176 |
||
730 | 177 |
" |
746 | 178 |
ImageEditor openOnClass:self andSelector:#iconPrivateClass |
730 | 179 |
" |
180 |
||
181 |
<resource: #image> |
|
182 |
||
183 |
^Icon |
|
771 | 184 |
constantNamed:#'ResourceSelectionBrowser iconPrivateClass' |
185 |
ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@PUUUUU A****(@F*??* @Z+??*@A*/*>(OF*>+: @Z+??*@A*/?:(DF*>** @Z+:**@A*/**(@F*>** @Z****C2@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]! ! |
|
730 | 186 |
|
425 | 187 |
!ResourceSelectionBrowser class methodsFor:'interface specs'! |
188 |
||
189 |
windowSpec |
|
746 | 190 |
"This resource specification was automatically generated |
191 |
by the UIPainter of ST/X." |
|
425 | 192 |
|
746 | 193 |
"Do not manually edit this!! If it is corrupted, |
194 |
the UIPainter may not be able to read the specification." |
|
425 | 195 |
|
196 |
" |
|
197 |
UIPainter new openOnClass:ResourceSelectionBrowser andSelector:#windowSpec |
|
198 |
ResourceSelectionBrowser new openInterface:#windowSpec |
|
746 | 199 |
ResourceSelectionBrowser open |
425 | 200 |
" |
201 |
||
202 |
<resource: #canvas> |
|
203 |
||
204 |
^ |
|
468 | 205 |
|
425 | 206 |
#(#FullSpec |
773 | 207 |
#window: |
208 |
#(#WindowSpec |
|
209 |
#name: 'Resource Selection Browser' |
|
210 |
#layout: #(#LayoutFrame 76 0 236 0 675 0 585 0) |
|
211 |
#label: 'Resource Selection Browser' |
|
212 |
#min: #(#Point 400 300) |
|
213 |
#max: #(#Point 1152 864) |
|
214 |
#bounds: #(#Rectangle 76 236 676 586) |
|
215 |
#usePreferredExtent: false |
|
216 |
) |
|
217 |
#component: |
|
218 |
#(#SpecCollection |
|
219 |
#collection: |
|
220 |
#( |
|
221 |
#(#VariableHorizontalPanelSpec |
|
222 |
#name: 'VariableHorizontalPanel' |
|
223 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
224 |
#component: |
|
225 |
#(#SpecCollection |
|
226 |
#collection: |
|
227 |
#( |
|
228 |
#(#ViewSpec |
|
229 |
#name: 'Box1' |
|
230 |
#component: |
|
231 |
#(#SpecCollection |
|
232 |
#collection: |
|
233 |
#( |
|
234 |
#(#LabelSpec |
|
235 |
#name: 'ClassHierarchyLabel' |
|
236 |
#layout: #(#LayoutFrame 0 0.0 2 0 0 1.0 23 0) |
|
237 |
#label: ' Class Hierarchy:' |
|
238 |
#level: 1 |
|
239 |
#adjust: #left |
|
240 |
) |
|
241 |
#(#SelectionInTreeViewSpec |
|
242 |
#name: 'listOfClassesView' |
|
243 |
#layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -60 1.0) |
|
244 |
#tabable: true |
|
245 |
#model: #selectionOfClass |
|
246 |
#hasHorizontalScrollBar: true |
|
247 |
#hasVerticalScrollBar: true |
|
248 |
#miniScrollerHorizontal: true |
|
249 |
#showDirectoryIndicatorForRoot: false |
|
250 |
#showDirectoryIndicator: true |
|
251 |
#valueChangeSelector: #classSelected |
|
252 |
#hierarchicalList: #rootOfClasses |
|
253 |
#validateDoubleClickSelector: #validateDoubleClick: |
|
254 |
#contentsSelector: #treeViewContents |
|
255 |
#labelSelector: #treeViewLabel |
|
256 |
#childrenSelector: #treeViewChildren |
|
257 |
#iconSelector: #treeViewIcon |
|
258 |
) |
|
259 |
#(#InputFieldSpec |
|
260 |
#name: 'classNameInputField' |
|
261 |
#layout: #(#LayoutFrame 2 0.0 -58 1 -1 1.0 -36 1) |
|
262 |
#tabable: true |
|
263 |
#model: #valueOfClassName |
|
264 |
) |
|
265 |
#(#HorizontalPanelViewSpec |
|
266 |
#name: 'HorizontalPanelView' |
|
267 |
#layout: #(#LayoutFrame 0 0.0 -28 1 0 1.0 -4 1) |
|
268 |
#component: |
|
269 |
#(#SpecCollection |
|
270 |
#collection: |
|
271 |
#( |
|
272 |
#(#LabelSpec |
|
273 |
#name: 'CreateLabel' |
|
274 |
#label: 'Create: ' |
|
275 |
#adjust: #right |
|
276 |
#extent: #(#Point 72 24) |
|
277 |
) |
|
278 |
#(#ActionButtonSpec |
|
279 |
#name: 'CreateClassButton' |
|
280 |
#activeHelpKey: #dss |
|
281 |
#label: 'Class' |
|
282 |
#model: #createClass: |
|
283 |
#actionValue: 'class' |
|
284 |
#extent: #(#Point 72 24) |
|
285 |
) |
|
286 |
#(#ActionButtonSpec |
|
287 |
#name: 'CreateSubclassButton' |
|
288 |
#activeHelpKey: #dss |
|
289 |
#label: 'Subclass' |
|
290 |
#model: #createClass: |
|
291 |
#actionValue: 'subclass' |
|
292 |
#extent: #(#Point 72 24) |
|
293 |
) |
|
294 |
#(#ActionButtonSpec |
|
295 |
#name: 'CreatePrivateClassButton' |
|
296 |
#activeHelpKey: #dss |
|
297 |
#label: 'Private' |
|
298 |
#model: #createClass: |
|
299 |
#actionValue: 'private' |
|
300 |
#extent: #(#Point 73 24) |
|
301 |
) |
|
302 |
) |
|
303 |
) |
|
304 |
#horizontalLayout: #fit |
|
305 |
#verticalLayout: #fit |
|
306 |
) |
|
307 |
) |
|
308 |
) |
|
309 |
) |
|
310 |
#(#ViewSpec |
|
311 |
#name: 'Box2' |
|
312 |
#component: |
|
313 |
#(#SpecCollection |
|
314 |
#collection: |
|
315 |
#( |
|
316 |
#(#DataSetSpec |
|
317 |
#name: 'resourcesDataSetView' |
|
318 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -60 1.0) |
|
319 |
#model: #selectionOfResourceMethod |
|
320 |
#hasHorizontalScrollBar: true |
|
321 |
#hasVerticalScrollBar: true |
|
322 |
#miniScrollerHorizontal: true |
|
323 |
#rowClassName: 'ResourceSelectionBrowser::Row' |
|
324 |
#dataList: #listOfResourceMethods |
|
325 |
#useIndex: false |
|
326 |
#has3Dsepartors: true |
|
327 |
#doubleClickSelector: #resourceDoubleClicked |
|
328 |
#columnHolder: #resourceMethodColumns |
|
329 |
#valueChangeSelector: #resourceSelected |
|
330 |
#verticalSpacing: 1 |
|
331 |
) |
|
332 |
#(#InputFieldSpec |
|
333 |
#name: 'selectorInputField' |
|
334 |
#layout: #(#LayoutFrame 2 0.0 -58 1 -2 1.0 -36 1) |
|
335 |
#tabable: true |
|
336 |
#model: #valueOfResourceSelector |
|
337 |
) |
|
338 |
#(#HorizontalPanelViewSpec |
|
339 |
#name: 'HorizontalPanel1' |
|
340 |
#layout: #(#LayoutFrame 2 0.0 -28 1 -2 1.0 -4 1.0) |
|
341 |
#component: |
|
342 |
#(#SpecCollection |
|
343 |
#collection: |
|
344 |
#( |
|
345 |
#(#ActionButtonSpec |
|
346 |
#name: 'HelpButton' |
|
347 |
#activeHelpKey: #dss |
|
348 |
#label: 'Help' |
|
349 |
#model: #openHTMLDocument: |
|
350 |
#initiallyDisabled: true |
|
351 |
#enableChannel: #helpEnabled |
|
352 |
#actionValue: 'tools/uipainter/ResourceSelectionBrowser.html' |
|
353 |
#extent: #(#Point 96 24) |
|
354 |
) |
|
355 |
#(#ActionButtonSpec |
|
356 |
#name: 'cancelButton' |
|
357 |
#activeHelpKey: #commitCancel |
|
358 |
#label: 'Cancel' |
|
359 |
#tabable: true |
|
360 |
#model: #cancel |
|
361 |
#extent: #(#Point 96 24) |
|
362 |
) |
|
363 |
#(#ActionButtonSpec |
|
364 |
#name: 'okButton' |
|
365 |
#activeHelpKey: #commitOK |
|
366 |
#label: 'OK' |
|
367 |
#tabable: true |
|
368 |
#model: #accept |
|
369 |
#isDefault: true |
|
370 |
#extent: #(#Point 96 24) |
|
371 |
) |
|
372 |
) |
|
373 |
) |
|
374 |
#horizontalLayout: #fit |
|
375 |
#verticalLayout: #fit |
|
376 |
) |
|
377 |
) |
|
378 |
) |
|
379 |
) |
|
380 |
) |
|
381 |
) |
|
382 |
#handles: #(#Any 0.5 1.0) |
|
383 |
) |
|
384 |
) |
|
385 |
) |
|
425 | 386 |
) |
387 |
! ! |
|
388 |
||
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
389 |
!ResourceSelectionBrowser class methodsFor:'list specs'! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
390 |
|
771 | 391 |
resourceMethodColumns |
392 |
"returns the columns for the table of the resource methods" |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
393 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
394 |
^ #(#(#DataSetColumnSpec |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
395 |
#width: 20 |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
396 |
#height: 20 |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
397 |
#printSelector: #iconOn: |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
398 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
399 |
) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
400 |
#(#DataSetColumnSpec |
649 | 401 |
#label: ' Selector' |
402 |
#'labelAlignment:' #left |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
403 |
#model: #selector |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
404 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
405 |
) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
406 |
(#DataSetColumnSpec |
649 | 407 |
#label: ' Resource Type' |
408 |
#'labelAlignment:' #left |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
409 |
#model: #resourceType |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
410 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
411 |
)) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
412 |
! ! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
413 |
|
425 | 414 |
!ResourceSelectionBrowser methodsFor:'aspects'! |
415 |
||
773 | 416 |
helpEnabled |
417 |
"returns whether there is a documentation file" |
|
418 |
||
419 |
^true |
|
420 |
! |
|
421 |
||
771 | 422 |
listOfResourceMethods |
423 |
"returns the value holder for the list of the resource methods" |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
424 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
425 |
|holder| |
771 | 426 |
(holder := builder bindingAt:#listOfResourceMethods) isNil ifTrue:[ |
427 |
builder aspectAt:#listOfResourceMethods put:(holder := List new). |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
428 |
]. |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
429 |
^ holder |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
430 |
! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
431 |
|
771 | 432 |
resourceMethodColumns |
433 |
"returns the columns for the table of the resource methods as value holder" |
|
425 | 434 |
|
435 |
|holder| |
|
771 | 436 |
(holder := builder bindingAt:#resourceMethodColumns) isNil ifTrue:[ |
437 |
builder aspectAt:#resourceMethodColumns put:(holder := List new). |
|
438 |
holder addAll: (self class resourceMethodColumns collect: [:i| i decodeAsLiteralArray]). |
|
439 |
]. |
|
440 |
^ holder |
|
441 |
! |
|
442 |
||
443 |
rootOfClasses |
|
444 |
"returns the value holder for the root of the class tree list" |
|
445 |
||
446 |
|holder| |
|
447 |
(holder := builder bindingAt:#rootOfClasses) isNil ifTrue:[ |
|
448 |
builder aspectAt:#rootOfClasses put: (holder := SelectionInTree new root: TreeItem new) |
|
425 | 449 |
]. |
450 |
^ holder |
|
451 |
||
452 |
||
453 |
! |
|
454 |
||
771 | 455 |
selectionOfClass |
456 |
"returns the value holder for the selected class of the class tree list" |
|
425 | 457 |
|
458 |
|holder| |
|
771 | 459 |
(holder := builder bindingAt:#selectionOfClass) isNil ifTrue:[ |
460 |
builder aspectAt:#selectionOfClass put:(holder := ValueHolder new). |
|
425 | 461 |
]. |
462 |
^ holder |
|
463 |
! |
|
464 |
||
771 | 465 |
selectionOfResourceMethod |
466 |
"returns the value holder for the selected resource method of the resource method list" |
|
425 | 467 |
|
468 |
|holder| |
|
771 | 469 |
(holder := builder bindingAt:#selectionOfResourceMethod) isNil ifTrue:[ |
470 |
builder aspectAt:#selectionOfResourceMethod put:(holder := '' asValue). |
|
425 | 471 |
]. |
472 |
^ holder |
|
473 |
! |
|
474 |
||
467 | 475 |
valueOfClassName |
771 | 476 |
"returns the value holder for the name of the class" |
467 | 477 |
|
478 |
|holder| |
|
479 |
(holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[ |
|
771 | 480 |
builder aspectAt:#valueOfClassName put:(holder := '' asValue). |
467 | 481 |
]. |
482 |
^ holder |
|
483 |
! |
|
484 |
||
771 | 485 |
valueOfResourceSelector |
486 |
"returns the value holder for the name of the selector" |
|
425 | 487 |
|
488 |
|holder| |
|
771 | 489 |
(holder := builder bindingAt:#valueOfResourceSelector) isNil ifTrue:[ |
490 |
builder aspectAt:#valueOfResourceSelector put:(holder := '' asValue). |
|
425 | 491 |
]. |
492 |
^ holder |
|
493 |
! ! |
|
494 |
||
771 | 495 |
!ResourceSelectionBrowser methodsFor:'callbacks - class list'! |
632 | 496 |
|
497 |
treeViewContents |
|
771 | 498 |
"returns the contents of the root of the class tree list" |
632 | 499 |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
500 |
^(Smalltalk at: resourceSuperclass) ? self class treeViewContents |
632 | 501 |
|
502 |
||
771 | 503 |
! |
504 |
||
505 |
validateDoubleClick: aTreeItem |
|
506 |
"returns whether a class may be selected" |
|
507 |
||
508 |
^aTreeItem contents ~~ self treeViewContents |
|
509 |
||
510 |
||
511 |
||
632 | 512 |
! ! |
513 |
||
514 |
!ResourceSelectionBrowser methodsFor:'callbacks - user'! |
|
425 | 515 |
|
771 | 516 |
classSelected |
517 |
"after a class selection, read the allowed resource methods of the selected class" |
|
730 | 518 |
|
771 | 519 |
(mayReadResources not or: [self selectionOfClass value isNil]) ifTrue: [^nil]. |
425 | 520 |
self withWaitCursorDo: |
521 |
[ |
|
522 |
|clsName| |
|
517 | 523 |
resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes]. |
771 | 524 |
clsName := self selectionOfClass value name. |
477 | 525 |
self valueOfClassName value: clsName. |
425 | 526 |
self class lastSelection: clsName. |
771 | 527 |
self listOfResourceMethods contents: |
523 | 528 |
((((Smalltalk at: clsName) |
425 | 529 |
class methodDictionary |
530 |
asOrderedCollection select: |
|
523 | 531 |
[:m| m resources notNil and: [resourceTypes includes: m resourceType]])) |
771 | 532 |
collect: [:m| (ResourceMethod new method: m)]). |
425 | 533 |
] |
534 |
! |
|
535 |
||
680 | 536 |
createClass: what |
771 | 537 |
"creates a class, a subclass, or a private class of the selected class" |
680 | 538 |
|
539 |
|clsCandidat cls| |
|
771 | 540 |
|
680 | 541 |
clsCandidat := self valueOfClassName value asSymbol. |
542 |
||
543 |
(Smalltalk at: clsCandidat) notNil |
|
771 | 544 |
ifTrue: [^self warn: 'Cannot create class ', clsCandidat asBoldText, |
545 |
'!!\Key with that name in dictionary ' withCRs, 'Smalltalk' asBoldText, ' detected.']. |
|
680 | 546 |
|
547 |
cls := self selectionOfClass value contents. |
|
548 |
what = 'class' ifTrue: [cls := cls superclass]. |
|
549 |
||
550 |
cls isNil ifTrue: [^self warn: 'May not create class with superclass ', 'nil' asBoldText, '!!']. |
|
551 |
||
552 |
what = 'private' |
|
693 | 553 |
ifFalse: |
554 |
[ |
|
771 | 555 |
cls subclass: clsCandidat |
556 |
instanceVariableNames:'' |
|
557 |
classVariableNames:'' |
|
558 |
poolDictionaries:'' |
|
559 |
category: cls category |
|
693 | 560 |
] |
680 | 561 |
ifTrue: |
562 |
[ |
|
771 | 563 |
|superClsCandidate| |
564 |
superClsCandidate := (Dialog |
|
565 |
request: 'Enter name of superclass of private class.' |
|
566 |
initialAnswer: 'Object') asSymbol. |
|
567 |
(Smalltalk at: superClsCandidate) isNil ifTrue: [^self warn: 'Class ', superClsCandidate asBoldText, ' does not exist!!']. |
|
680 | 568 |
|
771 | 569 |
((superClsCandidate := Smalltalk at: superClsCandidate) isClass and: [superClsCandidate isPrivate not]) |
570 |
ifFalse: [^self warn: 'May not create private class with superclass ', superClsCandidate asBoldText, '!!']. |
|
571 |
superClsCandidate subclass: clsCandidat |
|
572 |
instanceVariableNames:'' |
|
573 |
classVariableNames:'' |
|
574 |
poolDictionaries:'' |
|
575 |
privateIn: cls |
|
680 | 576 |
]. |
577 |
||
578 |
allClasses := Object withAllSubclasses. |
|
579 |
||
580 |
what = 'class' |
|
771 | 581 |
ifTrue: [self selectionOfClass value parent changed: #children] |
582 |
ifFalse: [self selectionOfClass value changed: #children]. |
|
680 | 583 |
|
693 | 584 |
classSelectionBlock value: self valueOfClassName value |
680 | 585 |
! |
586 |
||
425 | 587 |
resourceDoubleClicked |
771 | 588 |
"after a double click on resource method, accept it and close" |
425 | 589 |
|
590 |
accept value: true. |
|
771 | 591 |
|
425 | 592 |
self close |
593 |
! |
|
594 |
||
595 |
resourceSelected |
|
771 | 596 |
"after a click on a resource method, set its selector into the field" |
425 | 597 |
|
771 | 598 |
self selectionOfResourceMethod value notNil |
599 |
ifTrue: [self valueOfResourceSelector value: self selectionOfResourceMethod value selector] |
|
425 | 600 |
! ! |
601 |
||
602 |
!ResourceSelectionBrowser methodsFor:'instance creation'! |
|
603 |
||
604 |
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes |
|
771 | 605 |
"opens a ResourceSelectionBrowser on |
606 |
aSuperclassOrSymbol, |
|
607 |
and aClassOrSymbol, |
|
608 |
and aSelector, |
|
609 |
with allowed aResourceTypes" |
|
425 | 610 |
|
733 | 611 |
|clsName| |
771 | 612 |
|
517 | 613 |
resourceMethod := aSelector. |
425 | 614 |
resourceTypes := aResourceTypes. |
615 |
resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol]. |
|
689 | 616 |
resourceClass := aClassOrSymbol isClass |
771 | 617 |
ifTrue: [aClassOrSymbol name] |
618 |
ifFalse: [(Smalltalk at: aClassOrSymbol) notNil |
|
619 |
ifTrue: [aClassOrSymbol] |
|
620 |
ifFalse: [nil]]. |
|
621 |
self valueOfResourceSelector value:(aSelector ? ''). |
|
425 | 622 |
|
463 | 623 |
self open. |
624 |
||
733 | 625 |
(clsName := self selectionOfClass value) isNil ifTrue: [^nil]. |
626 |
clsName := (clsName name upTo: $ ) asSymbol. |
|
693 | 627 |
|
733 | 628 |
((Smalltalk at: clsName) isClass and: [accept value]) |
632 | 629 |
ifTrue: |
693 | 630 |
[ |
771 | 631 |
^clsName, ' ', self valueOfResourceSelector value |
425 | 632 |
]. |
633 |
^nil |
|
634 |
! ! |
|
635 |
||
636 |
!ResourceSelectionBrowser methodsFor:'startup / release'! |
|
637 |
||
638 |
closeCancel |
|
771 | 639 |
"after a cancel, terminate readResourcesProcess" |
425 | 640 |
|
771 | 641 |
readResourcesProcess notNil ifTrue: [readResourcesProcess terminate]. |
642 |
||
425 | 643 |
super closeCancel |
644 |
||
645 |
||
646 |
||
623 | 647 |
! |
648 |
||
649 |
postBuildWith:aBuilder |
|
771 | 650 |
"after building and before opening, |
651 |
create a class selection block, an entry completion block for the class name field, |
|
652 |
and select the class and the resource selector" |
|
623 | 653 |
|
771 | 654 |
|classSelection classNameInputField| |
655 |
||
656 |
allClasses := self treeViewContents withAllSubclasses reject: [:cls| cls isPrivate]. |
|
689 | 657 |
classSelection := resourceClass. |
658 |
(Smalltalk at: classSelection) isNil |
|
659 |
ifTrue: [classSelection := self class lastSelection]. |
|
660 |
(Smalltalk at: classSelection) isNil |
|
771 | 661 |
ifTrue: [classSelection := self treeViewContents]. |
623 | 662 |
classSelectionBlock := |
663 |
[:clsPattern| |
|
664 |
|foundClass classes| |
|
665 |
((foundClass := Smalltalk at: clsPattern printString asSymbol) isClass not or: |
|
666 |
[foundClass name ~= clsPattern]) |
|
667 |
ifTrue: |
|
668 |
[ |
|
669 |
classes := allClasses select: [:cls| cls name size >= clsPattern size]. |
|
670 |
1 to: clsPattern size do: |
|
671 |
[:i| |
|
672 |
classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)]. |
|
673 |
]. |
|
674 |
foundClass := classes at: 1 ifAbsent: [nil] |
|
771 | 675 |
]. |
623 | 676 |
foundClass notNil |
677 |
ifTrue: |
|
771 | 678 |
[ |
679 |
|superClasses nonSuperclasses item| |
|
680 |
superClasses := foundClass withAllSuperclasses reverse. |
|
681 |
(nonSuperclasses := self treeViewContents allSuperclasses) notNil |
|
682 |
ifTrue: [superClasses := superClasses reject: [:cls| nonSuperclasses includes: cls]]. |
|
683 |
item := self rootOfClasses detectItem:[:child :arg| child contents == arg] arguments:superClasses. |
|
684 |
item notNil ifTrue:[self selectionOfClass value:item] |
|
623 | 685 |
]. |
686 |
self valueOfClassName value: clsPattern |
|
687 |
]. |
|
635 | 688 |
self valueOfClassName value: classSelection. |
771 | 689 |
|
690 |
(classNameInputField := builder componentAt: #classNameInputField) entryCompletionBlock: |
|
623 | 691 |
[:value| |
692 |
|what| |
|
693 |
what := Smalltalk classnameCompletion: value withoutSpaces. |
|
771 | 694 |
classNameInputField contents:what first. |
623 | 695 |
(what at:2) size ~~ 1 ifTrue:[Display beep]. |
771 | 696 |
classSelectionBlock value: classNameInputField contents |
623 | 697 |
]. |
771 | 698 |
|
699 |
mayReadResources := false. |
|
700 |
classSelectionBlock value: classSelection. |
|
623 | 701 |
|
771 | 702 |
readResourcesProcess := |
680 | 703 |
[ |
771 | 704 |
mayReadResources := true. |
705 |
self classSelected. |
|
706 |
self selectionOfResourceMethod value: (self listOfResourceMethods detect: [:m| m selector == resourceMethod] ifNone: nil). |
|
707 |
readResourcesProcess := nil. |
|
708 |
] forkAt: 4. |
|
623 | 709 |
|
710 |
^super postBuildWith:aBuilder |
|
711 |
||
425 | 712 |
! ! |
713 |
||
771 | 714 |
!ResourceSelectionBrowser::ResourceMethod methodsFor:'accessing'! |
523 | 715 |
|
716 |
iconOn:aGC |
|
771 | 717 |
"registers and returns an icon indicating the resource type" |
523 | 718 |
|
730 | 719 |
self resourceType isNil ifTrue: [^nil]. |
720 |
icon isNil |
|
721 |
ifTrue: |
|
722 |
[ |
|
771 | 723 |
|cls sel image imageKey| |
724 |
((self resourceType = #image) or: [resourceType = #fileImage]) |
|
725 |
ifTrue: |
|
726 |
[ |
|
727 |
cls := method who methodClass soleInstance. |
|
728 |
sel := method who methodSelector. |
|
729 |
] |
|
730 |
ifFalse: |
|
731 |
[ |
|
732 |
cls := BrowserView. |
|
733 |
sel := (resourceType, 'Icon') asSymbol. |
|
734 |
]. |
|
735 |
imageKey := (cls name, sel) asSymbol. |
|
736 |
(icon := aGC registeredImageAt: imageKey) isNil |
|
737 |
ifTrue: |
|
738 |
[ |
|
739 |
image := cls perform: sel. |
|
740 |
image extent y > 18 |
|
741 |
ifTrue: |
|
742 |
[ |
|
743 |
image := image magnifiedBy: 18/image extent y |
|
744 |
]. |
|
745 |
aGC registerImage: image key: imageKey. |
|
746 |
icon := aGC registeredImageAt: imageKey. |
|
747 |
]. |
|
730 | 748 |
]. |
523 | 749 |
^icon |
750 |
! |
|
751 |
||
752 |
method: aMethod |
|
771 | 753 |
"sets aMethod" |
523 | 754 |
|
755 |
method := aMethod |
|
756 |
! |
|
757 |
||
758 |
resourceType |
|
771 | 759 |
"returns resourceType" |
523 | 760 |
|
761 |
resourceType isNil ifTrue: [resourceType := method resourceType]. |
|
762 |
^resourceType |
|
763 |
! |
|
764 |
||
765 |
selector |
|
771 | 766 |
"returns selector" |
523 | 767 |
|
768 |
selector isNil ifTrue: [selector := method who methodSelector]. |
|
769 |
^selector |
|
770 |
! ! |
|
771 |
||
425 | 772 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
773 |
||
774 |
version |
|
775 |
^ '$Header$' |
|
776 |
! ! |