author | tz |
Thu, 09 Apr 1998 21:12:59 +0200 | |
changeset 771 | 905c3b4ba565 |
parent 769 | bb413a70f479 |
child 773 | de5c99bd3078 |
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 |
771 | 207 |
#window: |
208 |
#(#WindowSpec |
|
209 |
#name: 'Resource Selection Browser' |
|
210 |
#layout: #(#LayoutFrame 221 0 252 0 820 0 601 0) |
|
211 |
#label: 'Resource Selection Browser' |
|
212 |
#min: #(#Point 400 300) |
|
213 |
#max: #(#Point 1152 864) |
|
214 |
#bounds: #(#Rectangle 221 252 821 602) |
|
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 -40 1.0) |
|
224 |
#component: |
|
225 |
#(#SpecCollection |
|
226 |
#collection: |
|
227 |
#( |
|
228 |
#(#ViewSpec |
|
229 |
#name: 'Box1' |
|
230 |
#component: |
|
231 |
#(#SpecCollection |
|
232 |
#collection: |
|
233 |
#( |
|
234 |
#(#SelectionInTreeViewSpec |
|
235 |
#name: 'listOfClassesView' |
|
236 |
#layout: #(#LayoutFrame 0 0.0 23 0.0 0 1.0 -22 1.0) |
|
237 |
#tabable: true |
|
238 |
#model: #selectionOfClass |
|
239 |
#hasHorizontalScrollBar: true |
|
240 |
#hasVerticalScrollBar: true |
|
241 |
#miniScrollerHorizontal: true |
|
242 |
#showDirectoryIndicatorForRoot: false |
|
243 |
#showDirectoryIndicator: true |
|
244 |
#valueChangeSelector: #classSelected |
|
245 |
#hierarchicalList: #rootOfClasses |
|
246 |
#validateDoubleClickSelector: #validateDoubleClick: |
|
247 |
#contentsSelector: #treeViewContents |
|
248 |
#labelSelector: #treeViewLabel |
|
249 |
#childrenSelector: #treeViewChildren |
|
250 |
#iconSelector: #treeViewIcon |
|
251 |
) |
|
252 |
#(#InputFieldSpec |
|
253 |
#name: 'classNameInputField' |
|
254 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -1 1.0 0 1) |
|
255 |
#tabable: true |
|
256 |
#model: #valueOfClassName |
|
257 |
) |
|
258 |
#(#LabelSpec |
|
259 |
#name: 'ClassHierarchyLabel' |
|
260 |
#layout: #(#LayoutFrame 0 0 2 0 297 0 23 0) |
|
261 |
#label: ' Class Hierarchy' |
|
262 |
#level: 1 |
|
263 |
#adjust: #left |
|
264 |
) |
|
265 |
) |
|
266 |
) |
|
267 |
) |
|
268 |
#(#ViewSpec |
|
269 |
#name: 'Box2' |
|
270 |
#component: |
|
271 |
#(#SpecCollection |
|
272 |
#collection: |
|
273 |
#( |
|
274 |
#(#DataSetSpec |
|
275 |
#name: 'resourcesDataSetView' |
|
276 |
#layout: #(#LayoutFrame 2 0.0 2 0.0 -2 1.0 -22 1.0) |
|
277 |
#model: #selectionOfResourceMethod |
|
278 |
#hasHorizontalScrollBar: true |
|
279 |
#hasVerticalScrollBar: true |
|
280 |
#miniScrollerHorizontal: true |
|
281 |
#rowClassName: 'ResourceSelectionBrowser::Row' |
|
282 |
#dataList: #listOfResourceMethods |
|
283 |
#useIndex: false |
|
284 |
#has3Dsepartors: true |
|
285 |
#doubleClickSelector: #resourceDoubleClicked |
|
286 |
#columnHolder: #resourceMethodColumns |
|
287 |
#valueChangeSelector: #resourceSelected |
|
288 |
#verticalSpacing: 1 |
|
289 |
) |
|
290 |
#(#InputFieldSpec |
|
291 |
#name: 'selectorInputField' |
|
292 |
#layout: #(#LayoutFrame 2 0.0 -22 1 -2 1.0 0 1) |
|
293 |
#tabable: true |
|
294 |
#model: #valueOfResourceSelector |
|
295 |
) |
|
296 |
) |
|
297 |
) |
|
298 |
) |
|
299 |
) |
|
300 |
) |
|
301 |
#handles: #(#Any 0.5 1.0) |
|
302 |
) |
|
303 |
#(#UISubSpecification |
|
304 |
#name: 'windowSpecForCommitWithoutChannels' |
|
305 |
#layout: #(#LayoutFrame 301 0.0 -32 1 -2 1.0 -8 1.0) |
|
306 |
#majorKey: #ToolApplicationModel |
|
307 |
#minorKey: #windowSpecForCommitWithoutChannels |
|
308 |
) |
|
309 |
#(#HorizontalPanelViewSpec |
|
310 |
#name: 'HorizontalPanelView' |
|
311 |
#layout: #(#LayoutFrame 3 0 76 0.691429 300 0 0 0.977143) |
|
312 |
#component: |
|
313 |
#(#SpecCollection |
|
314 |
#collection: |
|
315 |
#( |
|
316 |
#(#LabelSpec |
|
317 |
#name: 'Label2' |
|
318 |
#label: 'Create: ' |
|
319 |
#adjust: #right |
|
320 |
#extent: #(#Point 72 24) |
|
321 |
) |
|
322 |
#(#ActionButtonSpec |
|
323 |
#name: 'CreateClassButton' |
|
324 |
#activeHelpKey: #dss |
|
325 |
#label: 'Class' |
|
326 |
#model: #createClass: |
|
327 |
#actionValue: 'class' |
|
328 |
#extent: #(#Point 72 24) |
|
329 |
) |
|
330 |
#(#ActionButtonSpec |
|
331 |
#name: 'CreateSubclassButton' |
|
332 |
#activeHelpKey: #dss |
|
333 |
#label: 'Subclass' |
|
334 |
#model: #createClass: |
|
335 |
#actionValue: 'subclass' |
|
336 |
#extent: #(#Point 72 24) |
|
337 |
) |
|
338 |
#(#ActionButtonSpec |
|
339 |
#name: 'CreatePrivateClassButton' |
|
340 |
#activeHelpKey: #dss |
|
341 |
#label: 'Private' |
|
342 |
#model: #createClass: |
|
343 |
#actionValue: 'private' |
|
344 |
#extent: #(#Point 72 24) |
|
345 |
) |
|
346 |
) |
|
347 |
) |
|
348 |
#horizontalLayout: #fit |
|
349 |
#verticalLayout: #fit |
|
350 |
) |
|
351 |
) |
|
352 |
) |
|
425 | 353 |
) |
354 |
! ! |
|
355 |
||
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
356 |
!ResourceSelectionBrowser class methodsFor:'list specs'! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
357 |
|
771 | 358 |
resourceMethodColumns |
359 |
"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
|
360 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
361 |
^ #(#(#DataSetColumnSpec |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
362 |
#width: 20 |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
363 |
#height: 20 |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
364 |
#printSelector: #iconOn: |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
365 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
366 |
) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
367 |
#(#DataSetColumnSpec |
649 | 368 |
#label: ' Selector' |
369 |
#'labelAlignment:' #left |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
370 |
#model: #selector |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
371 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
372 |
) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
373 |
(#DataSetColumnSpec |
649 | 374 |
#label: ' Resource Type' |
375 |
#'labelAlignment:' #left |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
376 |
#model: #resourceType |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
377 |
#canSelect: false |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
378 |
)) |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
379 |
! ! |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
380 |
|
425 | 381 |
!ResourceSelectionBrowser methodsFor:'aspects'! |
382 |
||
771 | 383 |
listOfResourceMethods |
384 |
"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
|
385 |
|
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
386 |
|holder| |
771 | 387 |
(holder := builder bindingAt:#listOfResourceMethods) isNil ifTrue:[ |
388 |
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
|
389 |
]. |
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
390 |
^ holder |
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 |
|
771 | 393 |
resourceMethodColumns |
394 |
"returns the columns for the table of the resource methods as value holder" |
|
425 | 395 |
|
396 |
|holder| |
|
771 | 397 |
(holder := builder bindingAt:#resourceMethodColumns) isNil ifTrue:[ |
398 |
builder aspectAt:#resourceMethodColumns put:(holder := List new). |
|
399 |
holder addAll: (self class resourceMethodColumns collect: [:i| i decodeAsLiteralArray]). |
|
400 |
]. |
|
401 |
^ holder |
|
402 |
! |
|
403 |
||
404 |
rootOfClasses |
|
405 |
"returns the value holder for the root of the class tree list" |
|
406 |
||
407 |
|holder| |
|
408 |
(holder := builder bindingAt:#rootOfClasses) isNil ifTrue:[ |
|
409 |
builder aspectAt:#rootOfClasses put: (holder := SelectionInTree new root: TreeItem new) |
|
425 | 410 |
]. |
411 |
^ holder |
|
412 |
||
413 |
||
414 |
! |
|
415 |
||
771 | 416 |
selectionOfClass |
417 |
"returns the value holder for the selected class of the class tree list" |
|
425 | 418 |
|
419 |
|holder| |
|
771 | 420 |
(holder := builder bindingAt:#selectionOfClass) isNil ifTrue:[ |
421 |
builder aspectAt:#selectionOfClass put:(holder := ValueHolder new). |
|
425 | 422 |
]. |
423 |
^ holder |
|
424 |
! |
|
425 |
||
771 | 426 |
selectionOfResourceMethod |
427 |
"returns the value holder for the selected resource method of the resource method list" |
|
425 | 428 |
|
429 |
|holder| |
|
771 | 430 |
(holder := builder bindingAt:#selectionOfResourceMethod) isNil ifTrue:[ |
431 |
builder aspectAt:#selectionOfResourceMethod put:(holder := '' asValue). |
|
425 | 432 |
]. |
433 |
^ holder |
|
434 |
! |
|
435 |
||
467 | 436 |
valueOfClassName |
771 | 437 |
"returns the value holder for the name of the class" |
467 | 438 |
|
439 |
|holder| |
|
440 |
(holder := builder bindingAt:#valueOfClassName) isNil ifTrue:[ |
|
771 | 441 |
builder aspectAt:#valueOfClassName put:(holder := '' asValue). |
467 | 442 |
]. |
443 |
^ holder |
|
444 |
! |
|
445 |
||
771 | 446 |
valueOfResourceSelector |
447 |
"returns the value holder for the name of the selector" |
|
425 | 448 |
|
449 |
|holder| |
|
771 | 450 |
(holder := builder bindingAt:#valueOfResourceSelector) isNil ifTrue:[ |
451 |
builder aspectAt:#valueOfResourceSelector put:(holder := '' asValue). |
|
425 | 452 |
]. |
453 |
^ holder |
|
454 |
! ! |
|
455 |
||
771 | 456 |
!ResourceSelectionBrowser methodsFor:'callbacks - class list'! |
632 | 457 |
|
458 |
treeViewContents |
|
771 | 459 |
"returns the contents of the root of the class tree list" |
632 | 460 |
|
648
d0724edba450
some changes for the lib builder and for its new subclass
tz
parents:
641
diff
changeset
|
461 |
^(Smalltalk at: resourceSuperclass) ? self class treeViewContents |
632 | 462 |
|
463 |
||
771 | 464 |
! |
465 |
||
466 |
validateDoubleClick: aTreeItem |
|
467 |
"returns whether a class may be selected" |
|
468 |
||
469 |
^aTreeItem contents ~~ self treeViewContents |
|
470 |
||
471 |
||
472 |
||
632 | 473 |
! ! |
474 |
||
475 |
!ResourceSelectionBrowser methodsFor:'callbacks - user'! |
|
425 | 476 |
|
771 | 477 |
classSelected |
478 |
"after a class selection, read the allowed resource methods of the selected class" |
|
730 | 479 |
|
771 | 480 |
(mayReadResources not or: [self selectionOfClass value isNil]) ifTrue: [^nil]. |
425 | 481 |
self withWaitCursorDo: |
482 |
[ |
|
483 |
|clsName| |
|
517 | 484 |
resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes]. |
771 | 485 |
clsName := self selectionOfClass value name. |
477 | 486 |
self valueOfClassName value: clsName. |
425 | 487 |
self class lastSelection: clsName. |
771 | 488 |
self listOfResourceMethods contents: |
523 | 489 |
((((Smalltalk at: clsName) |
425 | 490 |
class methodDictionary |
491 |
asOrderedCollection select: |
|
523 | 492 |
[:m| m resources notNil and: [resourceTypes includes: m resourceType]])) |
771 | 493 |
collect: [:m| (ResourceMethod new method: m)]). |
425 | 494 |
] |
495 |
! |
|
496 |
||
680 | 497 |
createClass: what |
771 | 498 |
"creates a class, a subclass, or a private class of the selected class" |
680 | 499 |
|
500 |
|clsCandidat cls| |
|
771 | 501 |
|
680 | 502 |
clsCandidat := self valueOfClassName value asSymbol. |
503 |
||
504 |
(Smalltalk at: clsCandidat) notNil |
|
771 | 505 |
ifTrue: [^self warn: 'Cannot create class ', clsCandidat asBoldText, |
506 |
'!!\Key with that name in dictionary ' withCRs, 'Smalltalk' asBoldText, ' detected.']. |
|
680 | 507 |
|
508 |
cls := self selectionOfClass value contents. |
|
509 |
what = 'class' ifTrue: [cls := cls superclass]. |
|
510 |
||
511 |
cls isNil ifTrue: [^self warn: 'May not create class with superclass ', 'nil' asBoldText, '!!']. |
|
512 |
||
513 |
what = 'private' |
|
693 | 514 |
ifFalse: |
515 |
[ |
|
771 | 516 |
cls subclass: clsCandidat |
517 |
instanceVariableNames:'' |
|
518 |
classVariableNames:'' |
|
519 |
poolDictionaries:'' |
|
520 |
category: cls category |
|
693 | 521 |
] |
680 | 522 |
ifTrue: |
523 |
[ |
|
771 | 524 |
|superClsCandidate| |
525 |
superClsCandidate := (Dialog |
|
526 |
request: 'Enter name of superclass of private class.' |
|
527 |
initialAnswer: 'Object') asSymbol. |
|
528 |
(Smalltalk at: superClsCandidate) isNil ifTrue: [^self warn: 'Class ', superClsCandidate asBoldText, ' does not exist!!']. |
|
680 | 529 |
|
771 | 530 |
((superClsCandidate := Smalltalk at: superClsCandidate) isClass and: [superClsCandidate isPrivate not]) |
531 |
ifFalse: [^self warn: 'May not create private class with superclass ', superClsCandidate asBoldText, '!!']. |
|
532 |
superClsCandidate subclass: clsCandidat |
|
533 |
instanceVariableNames:'' |
|
534 |
classVariableNames:'' |
|
535 |
poolDictionaries:'' |
|
536 |
privateIn: cls |
|
680 | 537 |
]. |
538 |
||
539 |
allClasses := Object withAllSubclasses. |
|
540 |
||
541 |
what = 'class' |
|
771 | 542 |
ifTrue: [self selectionOfClass value parent changed: #children] |
543 |
ifFalse: [self selectionOfClass value changed: #children]. |
|
680 | 544 |
|
693 | 545 |
classSelectionBlock value: self valueOfClassName value |
680 | 546 |
! |
547 |
||
425 | 548 |
resourceDoubleClicked |
771 | 549 |
"after a double click on resource method, accept it and close" |
425 | 550 |
|
551 |
accept value: true. |
|
771 | 552 |
|
425 | 553 |
self close |
554 |
! |
|
555 |
||
556 |
resourceSelected |
|
771 | 557 |
"after a click on a resource method, set its selector into the field" |
425 | 558 |
|
771 | 559 |
self selectionOfResourceMethod value notNil |
560 |
ifTrue: [self valueOfResourceSelector value: self selectionOfResourceMethod value selector] |
|
425 | 561 |
! ! |
562 |
||
563 |
!ResourceSelectionBrowser methodsFor:'instance creation'! |
|
564 |
||
565 |
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withResourceTypes: aResourceTypes |
|
771 | 566 |
"opens a ResourceSelectionBrowser on |
567 |
aSuperclassOrSymbol, |
|
568 |
and aClassOrSymbol, |
|
569 |
and aSelector, |
|
570 |
with allowed aResourceTypes" |
|
425 | 571 |
|
733 | 572 |
|clsName| |
771 | 573 |
|
517 | 574 |
resourceMethod := aSelector. |
425 | 575 |
resourceTypes := aResourceTypes. |
576 |
resourceSuperclass := aSuperclassOrSymbol isClass ifTrue: [aSuperclassOrSymbol name] ifFalse: [aSuperclassOrSymbol]. |
|
689 | 577 |
resourceClass := aClassOrSymbol isClass |
771 | 578 |
ifTrue: [aClassOrSymbol name] |
579 |
ifFalse: [(Smalltalk at: aClassOrSymbol) notNil |
|
580 |
ifTrue: [aClassOrSymbol] |
|
581 |
ifFalse: [nil]]. |
|
582 |
self valueOfResourceSelector value:(aSelector ? ''). |
|
425 | 583 |
|
463 | 584 |
self open. |
585 |
||
733 | 586 |
(clsName := self selectionOfClass value) isNil ifTrue: [^nil]. |
587 |
clsName := (clsName name upTo: $ ) asSymbol. |
|
693 | 588 |
|
733 | 589 |
((Smalltalk at: clsName) isClass and: [accept value]) |
632 | 590 |
ifTrue: |
693 | 591 |
[ |
771 | 592 |
^clsName, ' ', self valueOfResourceSelector value |
425 | 593 |
]. |
594 |
^nil |
|
595 |
! ! |
|
596 |
||
597 |
!ResourceSelectionBrowser methodsFor:'startup / release'! |
|
598 |
||
599 |
closeCancel |
|
771 | 600 |
"after a cancel, terminate readResourcesProcess" |
425 | 601 |
|
771 | 602 |
readResourcesProcess notNil ifTrue: [readResourcesProcess terminate]. |
603 |
||
425 | 604 |
super closeCancel |
605 |
||
606 |
||
607 |
||
623 | 608 |
! |
609 |
||
610 |
postBuildWith:aBuilder |
|
771 | 611 |
"after building and before opening, |
612 |
create a class selection block, an entry completion block for the class name field, |
|
613 |
and select the class and the resource selector" |
|
623 | 614 |
|
771 | 615 |
|classSelection classNameInputField| |
616 |
||
617 |
allClasses := self treeViewContents withAllSubclasses reject: [:cls| cls isPrivate]. |
|
689 | 618 |
classSelection := resourceClass. |
619 |
(Smalltalk at: classSelection) isNil |
|
620 |
ifTrue: [classSelection := self class lastSelection]. |
|
621 |
(Smalltalk at: classSelection) isNil |
|
771 | 622 |
ifTrue: [classSelection := self treeViewContents]. |
623 | 623 |
classSelectionBlock := |
624 |
[:clsPattern| |
|
625 |
|foundClass classes| |
|
626 |
((foundClass := Smalltalk at: clsPattern printString asSymbol) isClass not or: |
|
627 |
[foundClass name ~= clsPattern]) |
|
628 |
ifTrue: |
|
629 |
[ |
|
630 |
classes := allClasses select: [:cls| cls name size >= clsPattern size]. |
|
631 |
1 to: clsPattern size do: |
|
632 |
[:i| |
|
633 |
classes := classes select: [:cls| (cls name at: i) == (clsPattern at: i)]. |
|
634 |
]. |
|
635 |
foundClass := classes at: 1 ifAbsent: [nil] |
|
771 | 636 |
]. |
623 | 637 |
foundClass notNil |
638 |
ifTrue: |
|
771 | 639 |
[ |
640 |
|superClasses nonSuperclasses item| |
|
641 |
superClasses := foundClass withAllSuperclasses reverse. |
|
642 |
(nonSuperclasses := self treeViewContents allSuperclasses) notNil |
|
643 |
ifTrue: [superClasses := superClasses reject: [:cls| nonSuperclasses includes: cls]]. |
|
644 |
item := self rootOfClasses detectItem:[:child :arg| child contents == arg] arguments:superClasses. |
|
645 |
item notNil ifTrue:[self selectionOfClass value:item] |
|
623 | 646 |
]. |
647 |
self valueOfClassName value: clsPattern |
|
648 |
]. |
|
635 | 649 |
self valueOfClassName value: classSelection. |
771 | 650 |
|
651 |
(classNameInputField := builder componentAt: #classNameInputField) entryCompletionBlock: |
|
623 | 652 |
[:value| |
653 |
|what| |
|
654 |
what := Smalltalk classnameCompletion: value withoutSpaces. |
|
771 | 655 |
classNameInputField contents:what first. |
623 | 656 |
(what at:2) size ~~ 1 ifTrue:[Display beep]. |
771 | 657 |
classSelectionBlock value: classNameInputField contents |
623 | 658 |
]. |
771 | 659 |
|
660 |
mayReadResources := false. |
|
661 |
classSelectionBlock value: classSelection. |
|
623 | 662 |
|
771 | 663 |
readResourcesProcess := |
680 | 664 |
[ |
771 | 665 |
mayReadResources := true. |
666 |
self classSelected. |
|
667 |
self selectionOfResourceMethod value: (self listOfResourceMethods detect: [:m| m selector == resourceMethod] ifNone: nil). |
|
668 |
readResourcesProcess := nil. |
|
669 |
] forkAt: 4. |
|
623 | 670 |
|
671 |
^super postBuildWith:aBuilder |
|
672 |
||
425 | 673 |
! ! |
674 |
||
771 | 675 |
!ResourceSelectionBrowser::ResourceMethod methodsFor:'accessing'! |
523 | 676 |
|
677 |
iconOn:aGC |
|
771 | 678 |
"registers and returns an icon indicating the resource type" |
523 | 679 |
|
730 | 680 |
self resourceType isNil ifTrue: [^nil]. |
681 |
icon isNil |
|
682 |
ifTrue: |
|
683 |
[ |
|
771 | 684 |
|cls sel image imageKey| |
685 |
((self resourceType = #image) or: [resourceType = #fileImage]) |
|
686 |
ifTrue: |
|
687 |
[ |
|
688 |
cls := method who methodClass soleInstance. |
|
689 |
sel := method who methodSelector. |
|
690 |
] |
|
691 |
ifFalse: |
|
692 |
[ |
|
693 |
cls := BrowserView. |
|
694 |
sel := (resourceType, 'Icon') asSymbol. |
|
695 |
]. |
|
696 |
imageKey := (cls name, sel) asSymbol. |
|
697 |
(icon := aGC registeredImageAt: imageKey) isNil |
|
698 |
ifTrue: |
|
699 |
[ |
|
700 |
image := cls perform: sel. |
|
701 |
image extent y > 18 |
|
702 |
ifTrue: |
|
703 |
[ |
|
704 |
image := image magnifiedBy: 18/image extent y |
|
705 |
]. |
|
706 |
aGC registerImage: image key: imageKey. |
|
707 |
icon := aGC registeredImageAt: imageKey. |
|
708 |
]. |
|
730 | 709 |
]. |
523 | 710 |
^icon |
711 |
! |
|
712 |
||
713 |
method: aMethod |
|
771 | 714 |
"sets aMethod" |
523 | 715 |
|
716 |
method := aMethod |
|
717 |
! |
|
718 |
||
719 |
resourceType |
|
771 | 720 |
"returns resourceType" |
523 | 721 |
|
722 |
resourceType isNil ifTrue: [resourceType := method resourceType]. |
|
723 |
^resourceType |
|
724 |
! |
|
725 |
||
726 |
selector |
|
771 | 727 |
"returns selector" |
523 | 728 |
|
729 |
selector isNil ifTrue: [selector := method who methodSelector]. |
|
730 |
^selector |
|
731 |
! ! |
|
732 |
||
425 | 733 |
!ResourceSelectionBrowser class methodsFor:'documentation'! |
734 |
||
735 |
version |
|
736 |
^ '$Header$' |
|
737 |
! ! |