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