author | Claus Gittinger <cg@exept.de> |
Tue, 17 Nov 2009 12:23:39 +0100 | |
changeset 9264 | 171e3ab3697d |
parent 9261 | 5d817a638b5d |
child 9265 | ae127bb9c614 |
permissions | -rw-r--r-- |
5141 | 1 |
" |
2 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
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 |
" |
|
3712 | 12 |
"{ Package: 'stx:libtool' }" |
13 |
||
14 |
Object subclass:#CodeGeneratorTool |
|
8572 | 15 |
instanceVariableNames:'compositeChangeCollector compositeChangeNesting userPreferences |
16 |
generateComments' |
|
8258 | 17 |
classVariableNames:'GenerateCommentsForGetters GenerateCommentsForSetters |
18 |
CopyrightTemplate' |
|
3712 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-Browsers' |
|
21 |
! |
|
22 |
||
3719 | 23 |
!CodeGeneratorTool class methodsFor:'documentation'! |
24 |
||
5141 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2002 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
3719 | 39 |
documentation |
40 |
" |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
41 |
This utility class contains various code generation facilites; |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
42 |
these were extracted from the old and newBrowser. |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
43 |
There is probably more to come... |
3719 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittiner |
|
47 |
" |
|
48 |
! ! |
|
3712 | 49 |
|
8572 | 50 |
!CodeGeneratorTool class methodsFor:'instance creation'! |
51 |
||
52 |
new |
|
53 |
^ self basicNew initialize. |
|
54 |
! ! |
|
55 |
||
3712 | 56 |
!CodeGeneratorTool class methodsFor:'code generation'! |
57 |
||
58 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
59 |
"create accessors in aClass" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
60 |
|
5758 | 61 |
^ self new |
6313 | 62 |
createAccessMethodsFor:aCollectionOfVarNames |
63 |
in:aClass |
|
64 |
withChange:withChange |
|
65 |
asValueHolder:asValueHolder |
|
66 |
readersOnly:readersOnly |
|
67 |
writersOnly:writersOnly |
|
4444
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
68 |
! |
6b077945517c
generate instvar accessors with lazy-init
Claus Gittinger <cg@exept.de>
parents:
4351
diff
changeset
|
69 |
|
3712 | 70 |
createApplicationCodeFor:aClass |
71 |
"create an empty application framework" |
|
72 |
||
5758 | 73 |
^ self new createApplicationCodeFor:aClass |
3712 | 74 |
! |
75 |
||
3804 | 76 |
createClassResponsibleProtocolFor:aClass |
77 |
"create stubs for the required protocol" |
|
78 |
||
5758 | 79 |
^ self new createClassResponsibleProtocolFor:aClass |
3804 | 80 |
! |
81 |
||
5124 | 82 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
83 |
"create a #isXXX test methods (I'm tired of typing)" |
4351 | 84 |
|
5758 | 85 |
^ self new createClassTypeTestMethodsIn:aClass forClasses:subClasses |
4351 | 86 |
! |
87 |
||
3712 | 88 |
createDocumentationMethodsFor:aClass |
89 |
"create empty documentation methods" |
|
90 |
||
5758 | 91 |
^ self new createDocumentationMethodsFor:aClass |
3712 | 92 |
! |
93 |
||
6313 | 94 |
createEnumTypeCodeFor:aClass |
95 |
^ self new createEnumTypeCodeFor:aClass |
|
96 |
! |
|
97 |
||
9125
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
98 |
createInitializationMethodIn:aClass |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
99 |
"create a #initialize methods (I'm tired of typing)" |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
100 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
101 |
^ self new createInitializationMethodIn:aClass |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
102 |
! |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
103 |
|
6718 | 104 |
createInitializedInstanceCreationMethodsIn:aClass |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
105 |
"create a #new and #initialize methods (I'm tired of typing)" |
3712 | 106 |
|
6718 | 107 |
^ self new createInitializedInstanceCreationMethodsIn:aClass |
108 |
! |
|
109 |
||
110 |
createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
111 |
"create a #selector instance creation method (I'm tired of typing)" |
|
112 |
||
113 |
^ self new createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
3712 | 114 |
! |
115 |
||
8344
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
116 |
createRedefinedInstanceCreationMethodsIn:aClass |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
117 |
"create a redefined #new method" |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
118 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
119 |
^ self new createRedefinedInstanceCreationMethodsIn:aClass |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
120 |
! |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
121 |
|
9081 | 122 |
createStartupCodeFor:aClass forStartOf:anApplicationClassOrNil |
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
123 |
"create standAloneStartup code" |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
124 |
|
9081 | 125 |
^ self new createStartupCodeFor:aClass forStartOf:anApplicationClassOrNil |
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
126 |
! |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
127 |
|
3712 | 128 |
createTestCaseSampleCodeFor:aClass |
4590 | 129 |
"create an (almost) empty testCase class" |
3712 | 130 |
|
5758 | 131 |
^ self new createTestCaseSampleCodeFor:aClass |
3712 | 132 |
! |
133 |
||
134 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
135 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
3712 | 136 |
|
5758 | 137 |
^ self new createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
3712 | 138 |
! |
139 |
||
6050 | 140 |
createWebApplicationCodeFor:aClass |
141 |
"create an empty webApplication framework" |
|
142 |
||
143 |
^ self new createWebApplicationCodeFor:aClass |
|
144 |
! |
|
145 |
||
7973 | 146 |
createWebServiceCodeFor:aClass |
147 |
"create an empty webService framework" |
|
148 |
||
149 |
^ self new createWebServiceCodeFor:aClass |
|
150 |
! |
|
151 |
||
8572 | 152 |
createWidgetCodeFor:aClass |
153 |
"create usually required widget code (redraw, model update, event handling)" |
|
154 |
||
155 |
^ self new createWidgetCodeFor:aClass |
|
156 |
! |
|
157 |
||
3712 | 158 |
initialMenuSpecMethodSourceForApplications |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
159 |
"return a menuSpec with typical stuff in it" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
160 |
|
3712 | 161 |
^ |
162 |
'mainMenu |
|
163 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
164 |
||
165 |
"Do not manually edit this!! If it is corrupted, |
|
166 |
the MenuEditor may not be able to read the specification." |
|
167 |
||
168 |
" |
|
169 |
MenuEditor new openOnClass:%1 andSelector:#mainMenu |
|
170 |
" |
|
171 |
||
172 |
<resource: #menu> |
|
173 |
||
174 |
^ #(#Menu |
|
175 |
#( |
|
176 |
#(#MenuItem |
|
177 |
#label: ''File'' |
|
178 |
#translateLabel: true |
|
179 |
#submenu: |
|
180 |
#(#Menu |
|
181 |
#( |
|
182 |
#(#MenuItem |
|
183 |
#label: ''New'' |
|
184 |
#translateLabel: true |
|
185 |
#value: #menuNew |
|
186 |
) |
|
187 |
#(#MenuItem |
|
188 |
#label: ''-'' |
|
189 |
) |
|
190 |
#(#MenuItem |
|
191 |
#label: ''Open...'' |
|
192 |
#translateLabel: true |
|
193 |
#value: #menuOpen |
|
194 |
) |
|
195 |
#(#MenuItem |
|
196 |
#label: ''-'' |
|
197 |
) |
|
198 |
#(#MenuItem |
|
199 |
#label: ''Save'' |
|
200 |
#translateLabel: true |
|
201 |
#value: #menuSave |
|
202 |
) |
|
203 |
#(#MenuItem |
|
204 |
#label: ''Save As...'' |
|
205 |
#translateLabel: true |
|
206 |
#value: #menuSaveAs |
|
207 |
) |
|
208 |
#(#MenuItem |
|
209 |
#label: ''-'' |
|
210 |
) |
|
211 |
#(#MenuItem |
|
212 |
#label: ''Exit'' |
|
213 |
#translateLabel: true |
|
214 |
#value: #closeRequest |
|
215 |
) |
|
216 |
) nil |
|
217 |
nil |
|
218 |
) |
|
219 |
) |
|
220 |
#(#MenuItem |
|
221 |
#label: ''Help'' |
|
222 |
#translateLabel: true |
|
223 |
#startGroup: #right |
|
224 |
#submenu: |
|
225 |
#(#Menu |
|
226 |
#( |
|
227 |
#(#MenuItem |
|
228 |
#label: ''Documentation'' |
|
229 |
#translateLabel: true |
|
230 |
#value: #openDocumentation |
|
231 |
) |
|
232 |
#(#MenuItem |
|
233 |
#label: ''-'' |
|
234 |
) |
|
235 |
#(#MenuItem |
|
6643 | 236 |
#label: ''About this Application...'' |
3712 | 237 |
#translateLabel: true |
238 |
#value: #openAboutThisApplication |
|
239 |
) |
|
240 |
) nil |
|
241 |
nil |
|
242 |
) |
|
243 |
) |
|
244 |
) nil |
|
245 |
nil |
|
246 |
) |
|
247 |
'. |
|
248 |
! |
|
249 |
||
7973 | 250 |
initialPageMenuSpec |
251 |
"return a menuSpec with typical stuff in it" |
|
252 |
||
253 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
254 |
||
255 |
"Do not manually edit this!! If it is corrupted, |
|
256 |
the MenuEditor may not be able to read the specification." |
|
257 |
||
258 |
" |
|
259 |
MenuEditor new openOnClass:%1 andSelector:#mainMenu |
|
260 |
" |
|
261 |
||
262 |
<resource: #menu> |
|
263 |
||
264 |
^ #(#Menu |
|
265 |
#( |
|
266 |
#(#MenuItem |
|
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
267 |
#label: 'File' |
7973 | 268 |
#translateLabel: true |
269 |
#submenu: |
|
270 |
#(#Menu |
|
271 |
#( |
|
272 |
#(#MenuItem |
|
273 |
#label: 'New' |
|
274 |
#translateLabel: true |
|
275 |
#value: #menuNew |
|
276 |
) |
|
277 |
#(#MenuItem |
|
278 |
#label: '-' |
|
279 |
) |
|
280 |
#(#MenuItem |
|
281 |
#label: 'Open...' |
|
282 |
#translateLabel: true |
|
283 |
#value: #menuOpen |
|
284 |
) |
|
285 |
#(#MenuItem |
|
286 |
#label: '-' |
|
287 |
) |
|
288 |
#(#MenuItem |
|
289 |
#label: 'Save' |
|
290 |
#translateLabel: true |
|
291 |
#value: #menuSave |
|
292 |
) |
|
293 |
#(#MenuItem |
|
294 |
#label: 'Save As...' |
|
295 |
#translateLabel: true |
|
296 |
#value: #menuSaveAs |
|
297 |
) |
|
298 |
#(#MenuItem |
|
299 |
#label: '-' |
|
300 |
) |
|
301 |
#(#MenuItem |
|
302 |
#label: 'Exit' |
|
303 |
#translateLabel: true |
|
304 |
#value: #closeRequest |
|
305 |
) |
|
306 |
) nil |
|
307 |
nil |
|
308 |
) |
|
309 |
) |
|
310 |
#(#MenuItem |
|
311 |
#label: 'Help' |
|
312 |
#translateLabel: true |
|
313 |
#startGroup: #right |
|
314 |
#submenu: |
|
315 |
#(#Menu |
|
316 |
#( |
|
317 |
#(#MenuItem |
|
318 |
#label: 'Documentation' |
|
319 |
#translateLabel: true |
|
320 |
#value: #openDocumentation |
|
321 |
) |
|
322 |
#(#MenuItem |
|
323 |
#label: '-' |
|
324 |
) |
|
325 |
#(#MenuItem |
|
326 |
#label: 'About this Application...' |
|
327 |
#translateLabel: true |
|
328 |
#value: #openAboutThisApplication |
|
329 |
) |
|
330 |
) nil |
|
331 |
nil |
|
332 |
) |
|
333 |
) |
|
334 |
) nil |
|
335 |
nil |
|
336 |
) |
|
337 |
! |
|
338 |
||
339 |
initialPageMenuSpecMethodSourceForWebApplications |
|
340 |
"return a menuSpec with typical stuff in it" |
|
341 |
||
342 |
^ |
|
343 |
'mainMenu |
|
344 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
345 |
||
346 |
"Do not manually edit this!! If it is corrupted, |
|
347 |
the MenuEditor may not be able to read the specification." |
|
348 |
||
349 |
" |
|
350 |
MenuEditor new openOnClass:%1 andSelector:#mainMenu |
|
351 |
" |
|
352 |
||
353 |
<resource: #menu> |
|
354 |
||
355 |
^ ',(self initialPageMenuSpec decodeAsLiteralArray literalArrayEncoding storeString),' |
|
356 |
'. |
|
357 |
||
358 |
" |
|
359 |
self initialPageMenuSpecMethodSourceForWebApplications |
|
360 |
" |
|
361 |
! |
|
362 |
||
363 |
initialPageSpecMethodSourceForWebApplications |
|
364 |
"return an empty pageSpec" |
|
365 |
||
366 |
^ |
|
367 |
'pageSpec |
|
368 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
369 |
||
370 |
"Do not manually edit this!! If it is corrupted, |
|
371 |
the UIPainter may not be able to read the specification." |
|
372 |
||
373 |
" |
|
374 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
375 |
" |
|
376 |
||
377 |
<resource: #canvas> |
|
378 |
||
379 |
^ #(#FullSpec |
|
380 |
#window: |
|
381 |
#(#WindowSpec |
|
382 |
#name: ''%1'' |
|
383 |
#layout: #(#LayoutFrame 204 0 162 0 503 0 461 0) |
|
384 |
#label: ''%1'' |
|
385 |
#min: #(#Point 10 10) |
|
386 |
#max: #(#Point 1024 768) |
|
387 |
#bounds: #(#Rectangle 204 162 504 462) |
|
388 |
#menu: #pageMenu |
|
389 |
#usePreferredExtent: false |
|
390 |
) |
|
391 |
#component: |
|
392 |
#(#SpecCollection |
|
393 |
#collection: #() |
|
394 |
) |
|
395 |
) |
|
396 |
'. |
|
397 |
! |
|
398 |
||
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
399 |
initialToolbarMenuSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
400 |
"This resource specification was automatically generated |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
401 |
by the MenuEditor of ST/X." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
402 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
403 |
"Do not manually edit this!! If it is corrupted, |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
404 |
the MenuEditor may not be able to read the specification." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
405 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
406 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
407 |
MenuEditor new openOnClass:CodeGeneratorTool andSelector:#initialToolbarMenuSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
408 |
(Menu new fromLiteralArrayEncoding:(CodeGeneratorTool initialToolbarMenuSpec)) startUp |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
409 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
410 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
411 |
<resource: #menu> |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
412 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
413 |
^ |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
414 |
#(Menu |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
415 |
( |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
416 |
(MenuItem |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
417 |
label: 'Reload' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
418 |
itemValue: menuReload |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
419 |
translateLabel: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
420 |
labelImage: (ResourceRetriever ToolbarIconLibrary reload24x24Icon) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
421 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
422 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
423 |
nil |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
424 |
nil |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
425 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
426 |
! |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
427 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
428 |
initialToolbarMenuSpecMethodSource |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
429 |
"return a menuSpec with typical stuff in it" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
430 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
431 |
^ |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
432 |
'toolbarMenu |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
433 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
434 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
435 |
"Do not manually edit this!! If it is corrupted, |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
436 |
the MenuEditor may not be able to read the specification." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
437 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
438 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
439 |
MenuEditor new openOnClass:%1 andSelector:#toolbarMenu |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
440 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
441 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
442 |
<resource: #menu> |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
443 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
444 |
^ ',(self initialToolbarMenuSpec decodeAsLiteralArray literalArrayEncoding storeString),' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
445 |
'. |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
446 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
447 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
448 |
self initialToolbarMenuSpecMethodSource |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
449 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
450 |
! |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
451 |
|
9054 | 452 |
initialWindowSpecForApplications |
453 |
"This resource specification was automatically generated |
|
454 |
by the UIPainter of ST/X." |
|
455 |
||
456 |
"Do not manually edit this!! If it is corrupted, |
|
457 |
the UIPainter may not be able to read the specification." |
|
458 |
||
459 |
" |
|
460 |
UIPainter new openOnClass:CodeGeneratorTool andSelector:#initialWindowSpecForApplications |
|
461 |
" |
|
462 |
||
463 |
<resource: #canvas> |
|
464 |
||
465 |
^ |
|
466 |
#(FullSpec |
|
467 |
name: initialWindowSpecForApplications |
|
468 |
window: |
|
469 |
(WindowSpec |
|
470 |
label: '%1' |
|
471 |
name: '%1' |
|
472 |
min: (Point 10 10) |
|
473 |
max: (Point 1024 768) |
|
474 |
bounds: (Rectangle 0 0 300 300) |
|
475 |
menu: mainMenu |
|
476 |
) |
|
477 |
component: |
|
478 |
(SpecCollection |
|
479 |
collection: ( |
|
480 |
(LabelSpec |
|
481 |
label: 'Hello World' |
|
482 |
name: 'Label1' |
|
483 |
layout: (LayoutFrame 0 0.0 60 0 0 1.0 219 0) |
|
484 |
translateLabel: true |
|
485 |
) |
|
486 |
) |
|
487 |
||
488 |
) |
|
489 |
) |
|
490 |
! |
|
491 |
||
492 |
initialWindowSpecForDialogs |
|
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
493 |
"This resource specification was automatically generated |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
494 |
by the UIPainter of ST/X." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
495 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
496 |
"Do not manually edit this!! If it is corrupted, |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
497 |
the UIPainter may not be able to read the specification." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
498 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
499 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
500 |
UIPainter new openOnClass:CodeGeneratorTool andSelector:#initialWindowSpecForDialogs |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
501 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
502 |
|
9054 | 503 |
<resource: #canvas> |
504 |
||
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
505 |
^ |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
506 |
#(FullSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
507 |
name: initialWindowSpecForDialogs |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
508 |
window: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
509 |
(WindowSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
510 |
label: '%1' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
511 |
name: '%1' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
512 |
min: (Point 10 10) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
513 |
max: (Point 1024 768) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
514 |
bounds: (Rectangle 0 0 300 300) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
515 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
516 |
component: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
517 |
(SpecCollection |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
518 |
collection: ( |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
519 |
(HorizontalPanelViewSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
520 |
name: 'buttonPanel' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
521 |
layout: (LayoutFrame 0 0.0 -40 1 0 1.0 0 1.0) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
522 |
horizontalLayout: spreadSpaceMax |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
523 |
verticalLayout: center |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
524 |
horizontalSpace: 3 |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
525 |
verticalSpace: 3 |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
526 |
reverseOrderIfOKAtLeft: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
527 |
component: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
528 |
(SpecCollection |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
529 |
collection: ( |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
530 |
(ActionButtonSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
531 |
label: 'Cancel' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
532 |
name: 'cancelButton' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
533 |
translateLabel: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
534 |
tabable: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
535 |
model: cancel |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
536 |
extent: (Point 125 22) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
537 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
538 |
(ActionButtonSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
539 |
label: 'OK' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
540 |
name: 'okButton' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
541 |
translateLabel: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
542 |
tabable: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
543 |
model: accept |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
544 |
isDefault: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
545 |
extent: (Point 125 22) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
546 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
547 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
548 |
|
9054 | 549 |
) |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
550 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
551 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
552 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
553 |
) |
9054 | 554 |
) |
555 |
! |
|
556 |
||
3712 | 557 |
initialWindowSpecMethodSourceForApplications |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
558 |
"return an empty windowSpec with an initial menubar in it" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
559 |
|
3712 | 560 |
^ |
561 |
'windowSpec |
|
562 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
563 |
||
564 |
"Do not manually edit this!! If it is corrupted, |
|
565 |
the UIPainter may not be able to read the specification." |
|
566 |
||
567 |
" |
|
568 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
569 |
" |
|
570 |
||
571 |
<resource: #canvas> |
|
572 |
||
9054 | 573 |
^ ', |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
574 |
self initialWindowSpecForApplications2 decodeAsLiteralArray prettyPrintString |
9054 | 575 |
. |
576 |
||
577 |
" |
|
578 |
self initialWindowSpecMethodSourceForApplications |
|
579 |
" |
|
3712 | 580 |
! |
581 |
||
582 |
initialWindowSpecMethodSourceForDialogs |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
583 |
"return an empty windowSpec for dialogs" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
584 |
|
3712 | 585 |
^ |
586 |
'windowSpec |
|
587 |
"This resource specification was automatically generated by the CodeGeneratorTool." |
|
588 |
||
589 |
"Do not manually edit this!! If it is corrupted, |
|
590 |
the UIPainter may not be able to read the specification." |
|
591 |
||
592 |
" |
|
593 |
UIPainter new openOnClass:%1 andSelector:#windowSpec |
|
594 |
" |
|
595 |
||
596 |
<resource: #canvas> |
|
597 |
||
9054 | 598 |
^ ', |
599 |
self initialWindowSpecForDialogs decodeAsLiteralArray prettyPrintString |
|
3712 | 600 |
! ! |
601 |
||
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
602 |
!CodeGeneratorTool class methodsFor:'code generation-basic'! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
603 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
604 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
605 |
"workhorse for creating access methods for instvars." |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
606 |
|
5758 | 607 |
^ self new |
608 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
609 |
! ! |
|
610 |
||
611 |
!CodeGeneratorTool class methodsFor:'code generation-individual methods'! |
|
612 |
||
613 |
createAcceptVisitorMethod:selector in:aClass |
|
614 |
"create an acceptVisitor: method |
|
615 |
(I'm tired of typing)" |
|
616 |
||
617 |
^ self new createAcceptVisitorMethod:selector in:aClass |
|
618 |
! |
|
619 |
||
620 |
createAcceptVisitorMethodIn:aClass |
|
621 |
"create an acceptVisitor: method |
|
622 |
(I'm tired of typing)" |
|
623 |
||
624 |
^ self new createAcceptVisitorMethodIn:aClass |
|
625 |
! |
|
626 |
||
627 |
createCopyrightMethodFor:aClass |
|
628 |
"add copyright method containing your/your companies |
|
629 |
copyright template but only if not already present. |
|
630 |
this is only added, if specified in the |
|
631 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
632 |
||
633 |
^ self new createCopyrightMethodFor:aClass |
|
634 |
! |
|
635 |
||
636 |
createDocumentationMethodFor:aClass |
|
637 |
"add documentation method containing doc template |
|
638 |
but only if not already present." |
|
639 |
||
640 |
^ self new createDocumentationMethodFor:aClass |
|
641 |
! |
|
642 |
||
643 |
createExamplesMethodFor:aClass |
|
644 |
"add examples method containing examples template |
|
645 |
but only if not already present." |
|
646 |
||
647 |
^ self new createExamplesMethodFor:aClass |
|
648 |
! |
|
649 |
||
650 |
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
651 |
^ self new createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
|
652 |
! |
|
653 |
||
654 |
createInitialHistoryMethodFor:aClass |
|
655 |
"add history method containing created-entry |
|
656 |
but only if not already present." |
|
657 |
||
658 |
^ self new createInitialHistoryMethodFor:aClass |
|
659 |
! |
|
660 |
||
661 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
662 |
"add an inst-creation method" |
|
663 |
||
664 |
^ self new createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
|
665 |
! |
|
666 |
||
667 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
668 |
"create a multi-setter method for instvars." |
|
669 |
||
670 |
^ self new createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
|
671 |
! |
|
672 |
||
673 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
674 |
"add a subclassResponsibility method; |
|
675 |
but only if not already present." |
|
676 |
||
677 |
^ self new createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
|
678 |
! |
|
679 |
||
680 |
createUpdateMethodIn:aClass |
|
681 |
"create an update:with:from:-method |
|
682 |
(I'm tired of typing)" |
|
683 |
||
684 |
^ self new createUpdateMethodIn:aClass |
|
685 |
! |
|
686 |
||
687 |
createVersionMethodFor:aClass |
|
688 |
"add version method containing RCS template |
|
689 |
but only if not already present and its not a private class." |
|
690 |
||
691 |
^ self new createVersionMethodFor:aClass |
|
692 |
! ! |
|
693 |
||
7973 | 694 |
!CodeGeneratorTool class methodsFor:'code generation-menus'! |
695 |
||
696 |
createActionMethodFor:aSelector in:aClass category:aCategory redefine:redefine |
|
697 |
|alreadyInSuperclass method code| |
|
698 |
||
699 |
(aClass includesSelector:aSelector) ifTrue:[ |
|
700 |
^ nil |
|
701 |
]. |
|
702 |
||
703 |
alreadyInSuperclass := aClass superclass canUnderstand:aSelector. |
|
704 |
(alreadyInSuperclass and:[redefine not]) ifTrue:[ |
|
705 |
^ nil |
|
706 |
]. |
|
707 |
||
708 |
method := self methodNameTemplateFor:aSelector. |
|
709 |
||
710 |
code := '%1 |
|
711 |
"automatically generated by UIEditor ..." |
|
712 |
||
713 |
"*** the code below performs no action" |
|
714 |
"*** (except for some feedback on the Transcript)" |
|
715 |
"*** Please change as required and accept in the browser." |
|
716 |
"*** (and replace this comment by something more useful ;-)" |
|
717 |
||
718 |
"action to be added ..." |
|
719 |
||
720 |
Transcript showCR:self class name, '': action for #%2 ...''. |
|
721 |
' bindWith:method with:aSelector. |
|
722 |
||
723 |
alreadyInSuperclass ifTrue:[ |
|
724 |
code := code, (('\ super %1\' bindWith:method) withCRs). |
|
725 |
]. |
|
726 |
self compile:code forClass:aClass inCategory:(aCategory ? 'actions'). |
|
727 |
^ code |
|
728 |
! |
|
729 |
||
730 |
createAspectMethodFor:aSelector in:aClass category:aCategory redefine:redefine |
|
731 |
|alreadyInSuperclass method code text| |
|
732 |
||
733 |
(aClass includesSelector:aSelector) ifTrue:[ |
|
734 |
^ nil |
|
735 |
]. |
|
736 |
||
737 |
alreadyInSuperclass := aClass superclass canUnderstand:aSelector. |
|
738 |
(alreadyInSuperclass and:[redefine not]) ifTrue:[ |
|
739 |
^ nil |
|
740 |
]. |
|
741 |
||
742 |
method := self methodNameTemplateFor:aSelector. |
|
743 |
||
744 |
code := '%1 |
|
745 |
"automatically generated by UIEditor ..." |
|
746 |
||
747 |
"*** the code below creates a default model when invoked" |
|
748 |
"*** (which may not be the one you wanted)" |
|
749 |
"*** Please change as required and accept in the browser." |
|
750 |
"*** (and replace this comment by something more useful ;-)" |
|
751 |
||
752 |
"aspect to be added ..." |
|
753 |
||
754 |
Transcript showCR:self class name, '': aspect for #%2 ...''. |
|
755 |
||
756 |
' bindWith:method with:aSelector. |
|
757 |
||
758 |
alreadyInSuperclass ifTrue:[ |
|
759 |
text := ' ^ super %1\' bindWith:method. |
|
760 |
] ifFalse:[ |
|
761 |
text := ' ^ builder valueAspectFor:#''%1'' initialValue:true\' bindWith:aSelector. |
|
762 |
]. |
|
763 |
code := code, (text withCRs). |
|
764 |
self compile:code forClass:aClass inCategory:(aCategory ? 'actions'). |
|
765 |
^ code |
|
766 |
! ! |
|
767 |
||
5758 | 768 |
!CodeGeneratorTool class methodsFor:'compilation'! |
769 |
||
770 |
compile:theCode forClass:aClass inCategory:cat |
|
771 |
"install some code for a class. |
|
772 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
773 |
||
774 |
^ self new compile:theCode forClass:aClass inCategory:cat |
|
775 |
! ! |
|
776 |
||
8258 | 777 |
!CodeGeneratorTool class methodsFor:'defaults'! |
778 |
||
779 |
copyrightTemplate |
|
780 |
"return the contents of COPYRIGHT_TEMPLATE_FILE resources |
|
781 |
or a standard template" |
|
782 |
||
783 |
|fn| |
|
784 |
||
785 |
CopyrightTemplate notNil ifTrue:[^ CopyrightTemplate]. |
|
786 |
||
787 |
fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil. |
|
788 |
fn notNil ifTrue:[ |
|
789 |
fn := fn asFilename. |
|
790 |
fn exists ifTrue:[ |
|
8488 | 791 |
^ fn contentsAsString. |
8258 | 792 |
]. |
793 |
]. |
|
794 |
^ ' COPYRIGHT (c) %1 by >>yourCompany<< |
|
795 |
All Rights Reserved |
|
796 |
||
797 |
This software is furnished under a license and may be used |
|
798 |
only in accordance with the terms of that license and with the |
|
799 |
inclusion of the above copyright notice. This software may not |
|
800 |
be provided or otherwise made available to, or used by, any |
|
801 |
other person. No title to or ownership of the software is |
|
802 |
hereby transferred. |
|
803 |
'. |
|
804 |
! |
|
805 |
||
806 |
copyrightTemplate:aString |
|
8488 | 807 |
"set the COPYRIGHT_TEMPLATE_FILE" |
808 |
||
8258 | 809 |
CopyrightTemplate := aString. |
810 |
! ! |
|
811 |
||
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
812 |
!CodeGeneratorTool class methodsFor:'interface specs'! |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
813 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
814 |
initialWindowSpecForApplications2 |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
815 |
"This resource specification was automatically generated |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
816 |
by the UIPainter of ST/X." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
817 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
818 |
"Do not manually edit this!! If it is corrupted, |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
819 |
the UIPainter may not be able to read the specification." |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
820 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
821 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
822 |
UIPainter new openOnClass:CodeGeneratorTool andSelector:#initialWindowSpecForApplications2 |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
823 |
" |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
824 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
825 |
<resource: #canvas> |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
826 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
827 |
^ |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
828 |
#(FullSpec |
9100
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
829 |
name: initialWindowSpecForApplications2 |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
830 |
window: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
831 |
(WindowSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
832 |
label: '%1' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
833 |
name: '%1' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
834 |
min: (Point 10 10) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
835 |
max: (Point 1024 768) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
836 |
bounds: (Rectangle 0 0 300 300) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
837 |
menu: mainMenu |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
838 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
839 |
component: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
840 |
(SpecCollection |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
841 |
collection: ( |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
842 |
(MenuPanelSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
843 |
name: 'ToolBar1' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
844 |
layout: (LayoutFrame 0 0.0 0 0 0 1.0 36 0) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
845 |
menu: toolbarMenu |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
846 |
textDefault: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
847 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
848 |
(ViewSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
849 |
name: 'Box1' |
9100
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
850 |
layout: (LayoutFrame 1 0 36 0 0 1 -26 1) |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
851 |
level: 1 |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
852 |
component: |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
853 |
(SpecCollection |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
854 |
collection: ( |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
855 |
(LabelSpec |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
856 |
label: 'Hello World' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
857 |
name: 'Contents' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
858 |
layout: (LayoutFrame 0 0 0 0 0 1 0 1) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
859 |
translateLabel: true |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
860 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
861 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
862 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
863 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
864 |
) |
9100
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
865 |
(ViewSpec |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
866 |
name: 'Box2' |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
867 |
layout: (LayoutFrame 0 0 -26 1 0 1 0 1) |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
868 |
level: 1 |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
869 |
component: |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
870 |
(SpecCollection |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
871 |
collection: ( |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
872 |
(LabelSpec |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
873 |
label: 'InfoLabel' |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
874 |
name: 'Label2' |
9261
5d817a638b5d
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9236
diff
changeset
|
875 |
layout: (LayoutFrame 0 0 -26 1 -1 1 0 1) |
9100
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
876 |
level: -1 |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
877 |
translateLabel: true |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
878 |
labelChannel: infoLabelHolder |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
879 |
adjust: left |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
880 |
) |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
881 |
) |
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
882 |
|
885eaa429d6f
changed: #initialWindowSpecForApplications2
Claus Gittinger <cg@exept.de>
parents:
9099
diff
changeset
|
883 |
) |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
884 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
885 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
886 |
|
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
887 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
888 |
) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
889 |
! ! |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
890 |
|
5758 | 891 |
!CodeGeneratorTool class methodsFor:'private'! |
892 |
||
893 |
canUseRefactoringSupport |
|
894 |
"check if refactory browser stuff is avaliable" |
|
895 |
||
896 |
^ RefactoryChangeManager notNil |
|
897 |
and:[RefactoryChangeManager isLoaded |
|
898 |
and:[UserPreferences current useRefactoringSupport]] |
|
7973 | 899 |
! |
900 |
||
901 |
methodNameTemplateFor:aSelector |
|
902 |
|numArgs method| |
|
903 |
||
904 |
numArgs := aSelector numArgs. |
|
905 |
numArgs == 1 ifTrue:[ |
|
906 |
method := aSelector, 'anArgument'. |
|
907 |
] ifFalse:[ |
|
908 |
numArgs == 0 ifTrue:[ |
|
909 |
method := aSelector |
|
910 |
] ifFalse:[ |
|
911 |
method := ''. |
|
912 |
aSelector keywords keysAndValuesDo:[:i :key| |
|
913 |
method := method, key, 'arg', i printString, ' '. |
|
914 |
]. |
|
915 |
] |
|
916 |
]. |
|
917 |
^ method |
|
5758 | 918 |
! ! |
919 |
||
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
920 |
!CodeGeneratorTool class methodsFor:'utilities'! |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
921 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
922 |
missingRequiredProtocolFor:aClass |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
923 |
"return the missing required protocol; |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
924 |
that is the set of selectors which send #subclassResponsibility in a superclass and |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
925 |
have no implementation in aClass or in any class between aClass and that superclass" |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
926 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
927 |
|requiredSelectors implementedSelectors| |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
928 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
929 |
requiredSelectors := IdentitySet new. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
930 |
implementedSelectors := IdentitySet withAll:(aClass methodDictionary keys). |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
931 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
932 |
aClass allSuperclassesDo:[:eachSuperClass | |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
933 |
eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod | |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
934 |
((eachMethod sends:#subclassResponsibility) or:[eachMethod sends:#subclassResponsibility:]) ifTrue:[ |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
935 |
(implementedSelectors includes:eachSelector) ifFalse:[ |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
936 |
requiredSelectors add:eachSelector. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
937 |
] |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
938 |
] ifFalse:[ |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
939 |
(requiredSelectors includes:eachSelector) ifFalse:[ |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
940 |
implementedSelectors add:eachSelector. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
941 |
]. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
942 |
]. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
943 |
] |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
944 |
]. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
945 |
^ requiredSelectors |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
946 |
! ! |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
947 |
|
5759 | 948 |
!CodeGeneratorTool methodsFor:'buld changes'! |
949 |
||
5763 | 950 |
addChange:aChange |
951 |
compositeChangeCollector addChange:aChange |
|
952 |
! |
|
953 |
||
5759 | 954 |
executeCollectedChangesNamed:name |
955 |
compositeChangeCollector notNil ifTrue:[ |
|
956 |
compositeChangeNesting := compositeChangeNesting - 1. |
|
957 |
compositeChangeNesting == 0 ifTrue:[ |
|
958 |
compositeChangeCollector name:name. |
|
959 |
compositeChangeCollector changesSize == 0 ifTrue:[ |
|
960 |
self information:'Nothing generated.'. |
|
961 |
] ifFalse:[ |
|
7037 | 962 |
RefactoryChangeManager performChange:compositeChangeCollector. |
5759 | 963 |
]. |
964 |
compositeChangeCollector := nil. |
|
965 |
] |
|
966 |
] |
|
967 |
! |
|
968 |
||
969 |
startCollectChanges |
|
970 |
(self canUseRefactoringSupport) ifTrue:[ |
|
971 |
compositeChangeCollector isNil ifTrue:[ |
|
972 |
compositeChangeCollector := CompositeRefactoryChange new. |
|
973 |
compositeChangeNesting := 0. |
|
974 |
]. |
|
975 |
compositeChangeNesting := compositeChangeNesting + 1. |
|
976 |
] |
|
977 |
! ! |
|
978 |
||
5758 | 979 |
!CodeGeneratorTool methodsFor:'code generation'! |
980 |
||
981 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly |
|
982 |
"create accessors in aClass" |
|
983 |
||
984 |
self |
|
985 |
createAccessMethodsFor:aCollectionOfVarNames |
|
986 |
in:aClass |
|
987 |
withChange:withChange |
|
988 |
asValueHolder:asValueHolder |
|
989 |
readersOnly:readersOnly |
|
990 |
writersOnly:writersOnly |
|
991 |
lazyInitialization:false |
|
992 |
! |
|
993 |
||
994 |
createApplicationCodeFor:aClass |
|
995 |
"create an empty application framework" |
|
996 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
997 |
|nonMetaClass metaClass className txt isDialog |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
998 |
categoryForMenuActionsMethods compileTemplateAction| |
5758 | 999 |
|
1000 |
self startCollectChanges. |
|
1001 |
||
8572 | 1002 |
categoryForMenuActionsMethods := userPreferences categoryForMenuActionsMethods. |
5758 | 1003 |
|
1004 |
nonMetaClass := aClass theNonMetaclass. |
|
1005 |
metaClass := aClass theMetaclass. |
|
1006 |
className := nonMetaClass name. |
|
1007 |
||
1008 |
isDialog := (nonMetaClass isSubclassOf:SimpleDialog). |
|
1009 |
||
1010 |
"/ add a windowSpec method for an empty applicationWindow, |
|
1011 |
"/ with a menuPanel. |
|
1012 |
||
1013 |
(metaClass includesSelector:#windowSpec) ifFalse:[ |
|
1014 |
isDialog ifTrue:[ |
|
1015 |
txt := self class initialWindowSpecMethodSourceForDialogs. |
|
1016 |
] ifFalse:[ |
|
1017 |
txt := self class initialWindowSpecMethodSourceForApplications. |
|
1018 |
]. |
|
1019 |
self |
|
1020 |
compile:(txt bindWith:className) |
|
1021 |
forClass:metaClass |
|
1022 |
inCategory:'interface specs'. |
|
1023 |
]. |
|
1024 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1025 |
compileTemplateAction := |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1026 |
[:selector :category | |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1027 |
(nonMetaClass includesSelector:selector) ifFalse:[ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1028 |
|codeTemplateSelector| |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1029 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1030 |
codeTemplateSelector := ('codeFor_',(selector upTo:$:)) asSymbol. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1031 |
txt := self perform:codeTemplateSelector. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1032 |
self |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1033 |
compile:txt |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1034 |
forClass:nonMetaClass |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1035 |
inCategory:(category = '*' ifTrue:categoryForMenuActionsMethods ifFalse:category). |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1036 |
] |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1037 |
]. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1038 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1039 |
#( |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1040 |
#'postBuildWith:' 'initialization & release' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1041 |
#'postOpenWith:' 'initialization & release' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1042 |
) pairWiseDo:compileTemplateAction. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1043 |
|
5758 | 1044 |
isDialog ifFalse:[ |
1045 |
"/ add a topMenu method |
|
1046 |
||
1047 |
(metaClass includesSelector:#mainMenu) ifFalse:[ |
|
1048 |
txt := self class initialMenuSpecMethodSourceForApplications. |
|
1049 |
self |
|
1050 |
compile:(txt bindWith:className) |
|
1051 |
forClass:metaClass |
|
1052 |
inCategory:'menu specs'. |
|
1053 |
]. |
|
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1054 |
(metaClass includesSelector:#toolbarMenu) ifFalse:[ |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1055 |
txt := self class initialToolbarMenuSpecMethodSource. |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1056 |
self |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1057 |
compile:(txt bindWith:className) |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1058 |
forClass:metaClass |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1059 |
inCategory:'menu specs'. |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1060 |
]. |
5758 | 1061 |
|
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1062 |
#( |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1063 |
#'hasUnsavedChanges' 'private queries' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1064 |
#'closeRequest' 'initialization & release' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1065 |
#'closeDownViews' 'initialization & release' |
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
1066 |
#'menuReload' '*' |
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1067 |
#'menuSaveAs' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1068 |
#'menuNew' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1069 |
#'menuOpen' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1070 |
#'menuSave' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1071 |
#'doSaveAs' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1072 |
#'openDocumentation' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1073 |
#'openAboutThisApplication' '*' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1074 |
) pairWiseDo:compileTemplateAction. |
5758 | 1075 |
]. |
1076 |
||
1077 |
isDialog ifTrue:[ |
|
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1078 |
#( |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1079 |
#'closeAccept' 'user actions' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1080 |
) pairWiseDo:compileTemplateAction. |
5758 | 1081 |
]. |
1082 |
||
6050 | 1083 |
self executeCollectedChangesNamed:('Add Application Code for ' , className). |
5758 | 1084 |
|
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
1085 |
"Modified: / 27-10-2006 / 10:21:58 / cg" |
5758 | 1086 |
! |
1087 |
||
8987 | 1088 |
createClassInitializeMethodIn:aClass |
1089 |
"create a #initialize method on the class side (I'm tired of typing)" |
|
1090 |
||
1091 |
|nonMetaClass metaClass className code initializer bindings| |
|
1092 |
||
1093 |
nonMetaClass := aClass theNonMetaclass. |
|
1094 |
metaClass := aClass theMetaclass. |
|
1095 |
className := nonMetaClass name. |
|
1096 |
||
1097 |
self startCollectChanges. |
|
1098 |
||
1099 |
(metaClass includesSelector:#'initialize') ifFalse:[ |
|
1100 |
'initialize |
|
1101 |
"Invoked at system start or when the class is dynamically loaded." |
|
1102 |
||
1103 |
"/ please change as required (and remove this comment) |
|
1104 |
'. |
|
1105 |
bindings := Dictionary new. |
|
1106 |
bindings at:'INIT_CLASSINSTVARS' put:( |
|
1107 |
String streamContents:[:s | |
|
1108 |
metaClass instVarNames do:[:eachClassInstVar | |
|
1109 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
1110 |
s nextPutLine:(' "/ %1 := %2.' bindWith:eachClassInstVar with:initializer). |
|
1111 |
] |
|
1112 |
]). |
|
1113 |
||
1114 |
bindings at:'INIT_CLASSVARS' put:( |
|
1115 |
String streamContents:[:s | |
|
1116 |
nonMetaClass classVarNames do:[:eachClassVar | |
|
1117 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
1118 |
s nextPutLine:(' "/ %1 := %2.' bindWith:eachClassVar with:initializer). |
|
1119 |
] |
|
1120 |
]). |
|
1121 |
||
1122 |
code := (self codeFor_classInitialize) expandPlaceholdersWith:bindings. |
|
1123 |
||
1124 |
self |
|
1125 |
compile:code |
|
1126 |
forClass:metaClass |
|
1127 |
inCategory:'initialization'. |
|
1128 |
]. |
|
1129 |
||
1130 |
self executeCollectedChangesNamed:('Add Class Initializer to ' , className). |
|
1131 |
! |
|
1132 |
||
5758 | 1133 |
createClassResponsibleProtocolFor:aClass |
1134 |
"create stubs for the required protocol" |
|
1135 |
||
6050 | 1136 |
|nonMetaClass metaClass className| |
1137 |
||
1138 |
nonMetaClass := aClass theNonMetaclass. |
|
1139 |
metaClass := aClass theMetaclass. |
|
1140 |
className := nonMetaClass name. |
|
1141 |
||
5758 | 1142 |
self startCollectChanges. |
1143 |
||
6050 | 1144 |
self privCreateClassResponsibleProtocolFor:nonMetaClass. |
1145 |
self privCreateClassResponsibleProtocolFor:metaClass. |
|
5758 | 1146 |
|
6050 | 1147 |
self executeCollectedChangesNamed:('Add Required Protocol to ' , className). |
5758 | 1148 |
! |
1149 |
||
1150 |
createClassTypeTestMethodsIn:aClass forClasses:subClasses |
|
1151 |
"create a #isXXX test methods (I'm tired of typing)" |
|
1152 |
||
1153 |
| code| |
|
1154 |
||
1155 |
self startCollectChanges. |
|
1156 |
||
1157 |
subClasses do:[:eachSubClass | |
|
1158 |
|nm selector| |
|
1159 |
||
1160 |
nm := eachSubClass nameWithoutPrefix. |
|
1161 |
selector := 'is' , nm. |
|
1162 |
(aClass includesSelector:selector) ifFalse:[ |
|
1163 |
code := (selector , '\ ^ false') withCRs. |
|
1164 |
self |
|
1165 |
compile:code |
|
1166 |
forClass:aClass |
|
1167 |
inCategory:'testing'. |
|
1168 |
]. |
|
1169 |
(eachSubClass includesSelector:selector) ifFalse:[ |
|
1170 |
code := (selector , '\ ^ true') withCRs. |
|
1171 |
self |
|
1172 |
compile:code |
|
1173 |
forClass:eachSubClass |
|
1174 |
inCategory:'testing'. |
|
1175 |
]. |
|
1176 |
]. |
|
1177 |
||
5759 | 1178 |
self executeCollectedChangesNamed:'Add ClassType Tests' |
5758 | 1179 |
! |
1180 |
||
1181 |
createDocumentationMethodsFor:aClass |
|
1182 |
"create empty documentation methods" |
|
1183 |
||
6050 | 1184 |
|nonMetaClass metaClass className| |
5758 | 1185 |
|
6050 | 1186 |
nonMetaClass := aClass theNonMetaclass. |
1187 |
metaClass := aClass theMetaclass. |
|
1188 |
className := nonMetaClass name. |
|
5758 | 1189 |
|
1190 |
self startCollectChanges. |
|
1191 |
||
8890 | 1192 |
"/ self createVersionMethodFor:metaClass. |
6050 | 1193 |
self createCopyrightMethodFor:metaClass. |
1194 |
self createDocumentationMethodFor:metaClass. |
|
8572 | 1195 |
self createExamplesMethodFor:metaClass. |
1196 |
"/ self createInitialHistoryMethodFor:metaClass. |
|
5758 | 1197 |
|
6050 | 1198 |
self executeCollectedChangesNamed:('Add Documentation to ' , className). |
5758 | 1199 |
! |
1200 |
||
6313 | 1201 |
createEnumTypeCodeFor:aClass |
1202 |
|nonMetaClass metaClass className enumValues code initCode runValue maxValue| |
|
1203 |
||
1204 |
self startCollectChanges. |
|
1205 |
||
1206 |
nonMetaClass := aClass theNonMetaclass. |
|
1207 |
metaClass := aClass theMetaclass. |
|
1208 |
className := nonMetaClass name. |
|
1209 |
||
1210 |
enumValues := nonMetaClass classVarNames. |
|
1211 |
enumValues do:[:eachVariableName | |
|
1212 |
self |
|
1213 |
createAccessMethodsFor:(Array with:eachVariableName) |
|
1214 |
in:metaClass |
|
1215 |
withChange:false |
|
1216 |
asValueHolder:false |
|
1217 |
readersOnly:true |
|
1218 |
writersOnly:false |
|
1219 |
]. |
|
1220 |
||
8572 | 1221 |
maxValue := enumValues |
1222 |
inject:0 |
|
1223 |
into:[:maxSoFar :eachVariableName | |
|
1224 |
|oldVal val| |
|
1225 |
oldVal := nonMetaClass classVarAt:eachVariableName. |
|
1226 |
oldVal notNil ifTrue:[ val := oldVal numericValue ]. |
|
1227 |
(val ? maxSoFar) max:maxSoFar |
|
1228 |
]. |
|
6313 | 1229 |
|
1230 |
initCode := WriteStream on: String new. |
|
1231 |
initCode nextPutLine:'initialize'. |
|
1232 |
runValue := maxValue + 1. |
|
1233 |
enumValues keysAndValuesDo:[:idx :eachVariableName | |
|
1234 |
|oldValue thisValue| |
|
1235 |
||
1236 |
oldValue := nonMetaClass classVarAt:eachVariableName. |
|
1237 |
oldValue notNil ifTrue:[ |
|
1238 |
thisValue := oldValue numericValue. |
|
1239 |
] ifFalse:[ |
|
1240 |
thisValue := runValue. |
|
1241 |
runValue := runValue + 1. |
|
1242 |
]. |
|
1243 |
initCode |
|
1244 |
nextPutAll:' '; |
|
1245 |
nextPutAll:eachVariableName; |
|
1246 |
nextPutAll:' := self basicNew'. |
|
1247 |
(aClass canUnderstand:#'setNumericValue:') ifTrue:[ |
|
1248 |
initCode nextPutAll:' setNumericValue: ',thisValue printString. |
|
1249 |
]. |
|
1250 |
(aClass canUnderstand:#'setCssClassString:') ifTrue:[ |
|
1251 |
initCode nextPutAll:('; setCssClassString: ''' , nonMetaClass nameWithoutPrefix asLowercaseFirst , eachVariableName , ''''). |
|
1252 |
]. |
|
1253 |
(aClass canUnderstand:#'setName:') ifTrue:[ |
|
1254 |
initCode nextPutAll:('; setName: ''' , eachVariableName asLowercaseFirst , ''''). |
|
1255 |
]. |
|
1256 |
initCode nextPutLine:'.'. |
|
1257 |
]. |
|
1258 |
initCode cr. |
|
1259 |
initCode nextPutLine:' "'. |
|
1260 |
initCode nextPutLine:' ',className, ' initialize'. |
|
1261 |
initCode nextPutLine:' "'. |
|
1262 |
||
1263 |
self |
|
1264 |
compile:(initCode contents) |
|
1265 |
forClass:metaClass |
|
1266 |
inCategory:'class initialization'. |
|
1267 |
||
1268 |
||
1269 |
code := 'allStateNames\ ^ #( ' , |
|
6341 | 1270 |
((enumValues collect:[:each | '#''',each asLowercaseFirst,'''']) asStringWith:' ') , ')', |
6313 | 1271 |
'\\ "\' , |
1272 |
' ',className, ' allStateNames\' , |
|
1273 |
' "\'. |
|
1274 |
self |
|
1275 |
compile:code withCRs |
|
1276 |
forClass:metaClass |
|
1277 |
inCategory:'queries'. |
|
1278 |
||
1279 |
self executeCollectedChangesNamed:('Generate EnumType Code for ' , className). |
|
1280 |
||
1281 |
aClass initialize. |
|
1282 |
||
1283 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
1284 |
! |
|
1285 |
||
8572 | 1286 |
createExamplesMethodForViewClass:aClass |
1287 |
"create an examples method" |
|
1288 |
||
1289 |
|nonMetaClass metaClass className code| |
|
1290 |
||
1291 |
nonMetaClass := aClass theNonMetaclass. |
|
1292 |
metaClass := aClass theMetaclass. |
|
1293 |
className := nonMetaClass name. |
|
1294 |
||
1295 |
self startCollectChanges. |
|
1296 |
||
1297 |
(metaClass includesSelector:#examples) ifFalse:[ |
|
1298 |
code := |
|
1299 |
'examples |
|
1300 |
" |
|
1301 |
Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator |
|
1302 |
to create nicely formatted and clickable executable examples in the generated html-doc. |
|
1303 |
(see the browsers class-documentation menu items for more) |
|
1304 |
||
1305 |
trying the widget as standAlone view: |
|
1306 |
[exBegin] |
|
1307 |
%1 new open |
|
1308 |
[exEnd] |
|
1309 |
||
1310 |
embedded in another view: |
|
1311 |
[exBegin] |
|
1312 |
|top v| |
|
1313 |
||
1314 |
top := StandardSystemView new. |
|
1315 |
top extent:300@300. |
|
1316 |
v := %1 new. |
|
1317 |
v origin:10@10 corner:150@150. |
|
1318 |
top add:v. |
|
1319 |
top open |
|
1320 |
[exEnd] |
|
1321 |
" |
|
1322 |
' bindWith:className. |
|
1323 |
||
1324 |
self |
|
1325 |
compile:code |
|
1326 |
forClass:metaClass |
|
1327 |
inCategory:'documentation'. |
|
1328 |
]. |
|
1329 |
||
1330 |
self executeCollectedChangesNamed:('Add Example to ' , className). |
|
1331 |
! |
|
1332 |
||
9125
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1333 |
createInitializationMethodIn:aClass |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1334 |
"create a #initialize methods (I'm tired of typing)" |
5758 | 1335 |
|
6050 | 1336 |
|nonMetaClass metaClass className code initializer m| |
1337 |
||
1338 |
nonMetaClass := aClass theNonMetaclass. |
|
1339 |
metaClass := aClass theMetaclass. |
|
1340 |
className := nonMetaClass name. |
|
5758 | 1341 |
|
1342 |
self startCollectChanges. |
|
1343 |
||
6050 | 1344 |
(nonMetaClass includesSelector:#'initialize') ifFalse:[ |
5758 | 1345 |
code := |
1346 |
'initialize |
|
1347 |
"Invoked when a new instance is created." |
|
1348 |
||
1349 |
"/ please change as required (and remove this comment) |
|
1350 |
'. |
|
1351 |
||
6718 | 1352 |
nonMetaClass instVarNames do:[:eachInstVar | |
1353 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
1354 |
code := code , (' "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr). |
|
1355 |
]. |
|
5758 | 1356 |
|
6718 | 1357 |
m := nonMetaClass responseTo:#initialize. |
1358 |
(m notNil and:[m messagesSent size == 0]) ifTrue:[ |
|
1359 |
"/ inherits an empty initialize. |
|
5758 | 1360 |
|
6718 | 1361 |
code := code , ' |
5758 | 1362 |
"/ super initialize. -- commented since inherited method does nothing |
1363 |
'. |
|
6718 | 1364 |
] ifFalse:[ |
1365 |
code := code , ' |
|
1366 |
super initialize. |
|
1367 |
'. |
|
5758 | 1368 |
]. |
1369 |
||
1370 |
self |
|
1371 |
compile:code |
|
6050 | 1372 |
forClass:nonMetaClass |
5758 | 1373 |
inCategory:'initialization'. |
1374 |
]. |
|
1375 |
||
9125
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1376 |
self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className). |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1377 |
! |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1378 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1379 |
createInitializedInstanceCreationMethodsIn:aClass |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1380 |
"create a #new and #initialize methods (I'm tired of typing)" |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1381 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1382 |
|nonMetaClass metaClass className code m| |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1383 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1384 |
nonMetaClass := aClass theNonMetaclass. |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1385 |
metaClass := aClass theMetaclass. |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1386 |
className := nonMetaClass name. |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1387 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1388 |
self startCollectChanges. |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1389 |
|
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1390 |
self createInitializationMethodIn:aClass. |
aaacd37a90b0
added: #createInitializationMethodIn:
Claus Gittinger <cg@exept.de>
parents:
9100
diff
changeset
|
1391 |
|
6050 | 1392 |
(metaClass includesSelector:#'new') ifFalse:[ |
1393 |
m := metaClass responseTo:#new. |
|
6718 | 1394 |
(m isNil |
1395 |
or:[ (m sends:#initialize) not |
|
9215
d3e59ce5867d
comment/format in: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
9209
diff
changeset
|
1396 |
or:[ |
6718 | 1397 |
(Dialog |
1398 |
confirmWithCancel:'The inherited #new method already seems to invoke #initialize. Redefine ?' |
|
1399 |
onCancel:[^ self]) ]]) ifTrue:[ |
|
1400 |
code := |
|
5758 | 1401 |
'new |
9209
3bcef7a559eb
changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
9125
diff
changeset
|
1402 |
"return an initialized instance" |
3bcef7a559eb
changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
9125
diff
changeset
|
1403 |
|
5758 | 1404 |
^ self basicNew initialize. |
1405 |
'. |
|
6718 | 1406 |
self |
1407 |
compile:code |
|
1408 |
forClass:metaClass |
|
1409 |
inCategory:'instance creation'. |
|
1410 |
]. |
|
1411 |
]. |
|
1412 |
||
1413 |
self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className). |
|
1414 |
||
1415 |
"Created: / 11.10.2001 / 22:18:55 / cg" |
|
1416 |
! |
|
1417 |
||
1418 |
createParametrizedInstanceCreationMethodsNamed:selector in:aClass |
|
1419 |
"create a #selector instance creation method (I'm tired of typing)" |
|
1420 |
||
1421 |
|nonMetaClass metaClass className code initializer m dfn| |
|
1422 |
||
1423 |
dfn := Method methodDefinitionTemplateForSelector:selector. |
|
1424 |
||
1425 |
nonMetaClass := aClass theNonMetaclass. |
|
1426 |
metaClass := aClass theMetaclass. |
|
1427 |
className := nonMetaClass name. |
|
1428 |
||
1429 |
self startCollectChanges. |
|
1430 |
||
1431 |
(nonMetaClass includesSelector:selector asSymbol) ifFalse:[ |
|
1432 |
code := |
|
1433 |
'initialize',dfn asUppercaseFirst,' |
|
1434 |
"Invoked when a new instance is created for arg." |
|
1435 |
||
1436 |
"/ please change as required (and remove these comments) |
|
1437 |
"/ do something with arg here (instVar-foo := arg) |
|
1438 |
'. |
|
1439 |
nonMetaClass instVarNames do:[:eachInstVar | |
|
1440 |
initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ... |
|
1441 |
code := code , (' "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr). |
|
1442 |
]. |
|
1443 |
||
1444 |
m := nonMetaClass responseTo:#initialize. |
|
1445 |
(m notNil and:[ m messagesSent size == 0 ]) ifTrue:[ |
|
1446 |
"/ inherits an empty initialize. |
|
1447 |
||
1448 |
code := code , ' |
|
1449 |
"/ super initialize. -- commented since inherited method does nothing |
|
1450 |
'. |
|
1451 |
] ifFalse:[ |
|
1452 |
code := code , ' |
|
1453 |
super initialize. |
|
1454 |
'. |
|
1455 |
]. |
|
1456 |
||
5758 | 1457 |
self |
1458 |
compile:code |
|
6718 | 1459 |
forClass:nonMetaClass |
1460 |
inCategory:'initialization'. |
|
5758 | 1461 |
]. |
1462 |
||
6718 | 1463 |
(metaClass includesSelector:selector) ifFalse:[ |
1464 |
m := metaClass responseTo:selector. |
|
1465 |
(m isNil |
|
1466 |
or:[ (Dialog confirmWithCancel:'The ',selector,'- method is already inherited. Redefine ?' onCancel:[^ self]) ]) |
|
1467 |
ifTrue:[ |
|
1468 |
code := |
|
1469 |
dfn,' |
|
1470 |
"Create & return a new instance for arg." |
|
5758 | 1471 |
|
6718 | 1472 |
^ self basicNew initialize',dfn asUppercaseFirst,' |
1473 |
'. |
|
1474 |
self |
|
1475 |
compile:code |
|
1476 |
forClass:metaClass |
|
1477 |
inCategory:'instance creation'. |
|
1478 |
]. |
|
1479 |
]. |
|
1480 |
||
1481 |
self executeCollectedChangesNamed:('Add Parametrized Instance Creation to ' , className). |
|
5758 | 1482 |
! |
1483 |
||
7470 | 1484 |
createPoolInitializationCodeFor:aClass |
1485 |
|nonMetaClass metaClass className poolVars code initCode runValue maxValue| |
|
1486 |
||
1487 |
self startCollectChanges. |
|
1488 |
||
1489 |
nonMetaClass := aClass theNonMetaclass. |
|
1490 |
metaClass := aClass theMetaclass. |
|
1491 |
className := nonMetaClass name. |
|
1492 |
||
1493 |
poolVars := nonMetaClass classVarNames. |
|
1494 |
||
1495 |
initCode := WriteStream on: String new. |
|
1496 |
initCode nextPutLine:'initialize'. |
|
1497 |
||
1498 |
poolVars do:[:eachVariableName | |
|
1499 |
|oldValue thisValue| |
|
1500 |
||
1501 |
oldValue := nonMetaClass classVarAt:eachVariableName. |
|
1502 |
oldValue notNil ifTrue:[ |
|
1503 |
thisValue := oldValue. |
|
1504 |
] ifFalse:[ |
|
1505 |
thisValue := nil. |
|
1506 |
]. |
|
1507 |
initCode |
|
1508 |
nextPutAll:' '; |
|
1509 |
nextPutAll:eachVariableName; |
|
1510 |
nextPutAll:' := '; |
|
1511 |
nextPutAll:thisValue storeString; |
|
1512 |
nextPutLine:'.'. |
|
1513 |
]. |
|
1514 |
initCode cr. |
|
1515 |
initCode nextPutLine:' "'. |
|
1516 |
initCode nextPutLine:' ',className, ' initialize'. |
|
1517 |
initCode nextPutLine:' "'. |
|
1518 |
||
1519 |
self |
|
1520 |
compile:(initCode contents) |
|
1521 |
forClass:metaClass |
|
1522 |
inCategory:'class initialization'. |
|
1523 |
||
1524 |
self executeCollectedChangesNamed:('Generate Pool Initialization Code for ' , className). |
|
1525 |
||
1526 |
aClass initialize. |
|
1527 |
||
1528 |
"Created: / 25-10-2006 / 09:28:40 / cg" |
|
1529 |
! |
|
1530 |
||
8344
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1531 |
createRedefinedInstanceCreationMethodsIn:aClass |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1532 |
"create a redefined #new methods" |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1533 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1534 |
|nonMetaClass metaClass className code| |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1535 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1536 |
nonMetaClass := aClass theNonMetaclass. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1537 |
metaClass := aClass theMetaclass. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1538 |
className := nonMetaClass name. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1539 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1540 |
self startCollectChanges. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1541 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1542 |
(metaClass includesSelector:#'new') ifFalse:[ |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1543 |
code := |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1544 |
'new |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1545 |
^ super new. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1546 |
'. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1547 |
self |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1548 |
compile:code |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1549 |
forClass:metaClass |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1550 |
inCategory:'redefined instance creation'. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1551 |
]. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1552 |
(metaClass includesSelector:#'new:') ifFalse:[ |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1553 |
code := |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1554 |
'new:n |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1555 |
^ super new:n. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1556 |
'. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1557 |
self |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1558 |
compile:code |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1559 |
forClass:metaClass |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1560 |
inCategory:'redefined instance creation'. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1561 |
]. |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1562 |
|
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1563 |
self executeCollectedChangesNamed:('Redefined Instance Creation to ' , className). |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1564 |
! |
efda36a55d02
changed #createRedefinedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents:
8258
diff
changeset
|
1565 |
|
5953 | 1566 |
createStandardPrintOnMethodIn:aClass |
1567 |
"create a #printOn: method (I'm tired of typing)" |
|
1568 |
||
6050 | 1569 |
|code nonMetaClass| |
1570 |
||
1571 |
nonMetaClass := aClass theNonMetaclass. |
|
5953 | 1572 |
|
1573 |
self startCollectChanges. |
|
1574 |
||
6050 | 1575 |
(nonMetaClass includesSelector:#'printOn:') ifFalse:[ |
5953 | 1576 |
code := |
1577 |
'printOn:aStream |
|
1578 |
"append a printed representation if the receiver to the argument, aStream" |
|
1579 |
||
1580 |
super printOn:aStream. |
|
1581 |
'. |
|
6050 | 1582 |
nonMetaClass instVarNames do:[:eachInstVarName | |
5953 | 1583 |
code := code , ' '. |
1584 |
code := code , 'aStream nextPutAll:'''. |
|
1585 |
code := code , eachInstVarName. |
|
1586 |
code := code , ': ''.' , Character cr. |
|
1587 |
code := code , ' '. |
|
1588 |
code := code , eachInstVarName. |
|
1589 |
code := code , ' printOn:aStream.' , Character cr. |
|
1590 |
||
1591 |
]. |
|
1592 |
||
1593 |
self |
|
1594 |
compile:code |
|
6050 | 1595 |
forClass:nonMetaClass |
5953 | 1596 |
inCategory:'printing & storing'. |
1597 |
]. |
|
1598 |
||
1599 |
||
6050 | 1600 |
self executeCollectedChangesNamed:('Add #printOn: to ' , nonMetaClass name). |
5953 | 1601 |
|
1602 |
"Created: / 11.10.2001 / 22:18:55 / cg" |
|
1603 |
! |
|
1604 |
||
9081 | 1605 |
createStartupCodeFor:aClass forStartOf:anApplicationClassOrNil |
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1606 |
"create startup code (main)" |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1607 |
|
9081 | 1608 |
|nonMetaClass metaClass className source |
1609 |
hasAplicationClass anApplicationClassNameOrStartupClassName| |
|
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1610 |
|
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1611 |
self startCollectChanges. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1612 |
|
9081 | 1613 |
hasAplicationClass := anApplicationClassOrNil notNil. |
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1614 |
nonMetaClass := aClass theNonMetaclass. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1615 |
metaClass := aClass theMetaclass. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1616 |
className := nonMetaClass name. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1617 |
|
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1618 |
(metaClass includesSelector:#main:) ifFalse:[ |
9081 | 1619 |
|
1620 |
source := String streamContents:[:stream | |
|
1621 |
stream nextPutAll: |
|
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1622 |
'main:argv |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1623 |
self verboseInfo:''starting %1''. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1624 |
|
9081 | 1625 |
'. |
1626 |
hasAplicationClass ifTrue: [ |
|
1627 |
stream nextPutAll: |
|
1628 |
' %1 open. |
|
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1629 |
'. |
9081 | 1630 |
]. |
1631 |
]. |
|
1632 |
||
1633 |
anApplicationClassNameOrStartupClassName := hasAplicationClass |
|
1634 |
ifTrue: [anApplicationClassOrNil name] |
|
1635 |
ifFalse: [className.]. |
|
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1636 |
self |
9081 | 1637 |
compile:(source bindWith:anApplicationClassNameOrStartupClassName) |
9049
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1638 |
forClass:metaClass |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1639 |
inCategory:'startup'. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1640 |
]. |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1641 |
self executeCollectedChangesNamed:('Add Startup Code to ' , className). |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1642 |
! |
9a2003a4fef3
added: #createStartupCodeFor:forStartOf:
Claus Gittinger <cg@exept.de>
parents:
9044
diff
changeset
|
1643 |
|
5758 | 1644 |
createTestCaseSampleCodeFor:aClass |
1645 |
"create an (almost) empty testCase class" |
|
1646 |
||
1647 |
|nonMetaClass metaClass| |
|
1648 |
||
1649 |
nonMetaClass := aClass theNonMetaclass. |
|
1650 |
metaClass := aClass theMetaclass. |
|
1651 |
"/ className := nonMetaClass name. |
|
1652 |
||
1653 |
( nonMetaClass includesSelector:#test1 ) ifFalse:[ |
|
1654 |
self |
|
1655 |
compile: |
|
1656 |
'test1 |
|
1657 |
"This is a demonstration testCase - it is meant to be removed eventually. |
|
1658 |
This testCase will PASS. |
|
1659 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1660 |
- please add more methods like this..." |
|
1661 |
||
1662 |
|o| |
|
1663 |
||
1664 |
o := Array new:2. |
|
1665 |
self assert: ( o size == 2 ). |
|
1666 |
self should: [ o at:0 ] raise:Error. |
|
1667 |
self shouldnt: [ o at:1 ] raise:Error. |
|
1668 |
||
1669 |
" |
|
1670 |
self run:#test1 |
|
1671 |
self new test1 |
|
1672 |
" |
|
1673 |
' |
|
1674 |
forClass:nonMetaClass |
|
1675 |
inCategory:'tests'. |
|
1676 |
]. |
|
1677 |
||
1678 |
( nonMetaClass includesSelector:#test2 ) ifFalse:[ |
|
1679 |
self |
|
1680 |
compile: |
|
1681 |
'test2 |
|
1682 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
1683 |
This testCase WILL FAIL. |
|
1684 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1685 |
- please add more methods like this..." |
|
1686 |
||
1687 |
|o| |
|
1688 |
||
1689 |
o := Array new:2. |
|
1690 |
self assert: ( o size == 3 ). |
|
1691 |
||
1692 |
" |
|
1693 |
self run:#test2 |
|
1694 |
self new test2 |
|
1695 |
" |
|
1696 |
' |
|
1697 |
forClass:nonMetaClass |
|
1698 |
inCategory:'tests'. |
|
1699 |
]. |
|
1700 |
||
1701 |
( nonMetaClass includesSelector:#test3 ) ifFalse:[ |
|
1702 |
self |
|
1703 |
compile: |
|
1704 |
'test3 |
|
1705 |
"This is a demonstration testCase - it is meant to be removed eventually.. |
|
1706 |
This testCase WILL generate an ERROR. |
|
1707 |
Double click on the TestCase class or open a TestRunner to see me checking... |
|
1708 |
- please add more methods like this..." |
|
1709 |
||
1710 |
|o| |
|
1711 |
||
1712 |
o := Array new:2. |
|
1713 |
self assert: ( o foo ). |
|
1714 |
||
1715 |
" |
|
1716 |
self run:#test3 |
|
1717 |
self new test3 |
|
1718 |
" |
|
1719 |
' |
|
1720 |
forClass:nonMetaClass |
|
1721 |
inCategory:'tests'. |
|
1722 |
]. |
|
1723 |
||
1724 |
( nonMetaClass includesSelector:#setUp ) ifFalse:[ |
|
1725 |
self |
|
1726 |
compile: |
|
1727 |
'setUp |
|
1728 |
"common setup - invoked before testing." |
|
1729 |
||
1730 |
super setUp |
|
1731 |
' |
|
1732 |
forClass:nonMetaClass |
|
1733 |
inCategory:'initialize / release'. |
|
1734 |
]. |
|
1735 |
||
1736 |
( nonMetaClass includesSelector:#tearDown ) ifFalse:[ |
|
1737 |
self |
|
1738 |
compile: |
|
1739 |
'tearDown |
|
1740 |
"common cleanup - invoked after testing." |
|
1741 |
||
1742 |
super tearDown |
|
1743 |
' |
|
1744 |
forClass:nonMetaClass |
|
1745 |
inCategory:'initialize / release'. |
|
1746 |
] |
|
1747 |
! |
|
1748 |
||
1749 |
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass |
|
1750 |
"create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)" |
|
1751 |
||
1752 |
|sel| |
|
1753 |
||
6921 | 1754 |
self assert:( visitedClass isMeta not ). |
1755 |
self assert:( visitorClass isMeta not ). |
|
5758 | 1756 |
|
1757 |
self startCollectChanges. |
|
1758 |
||
1759 |
sel := ('visit' , visitedClass nameWithoutPrefix , ':'). |
|
1760 |
self createAcceptVisitorMethod:sel in:visitedClass. |
|
1761 |
||
1762 |
(visitorClass includesSelector:sel) ifFalse:[ |
|
1763 |
self |
|
1764 |
compile: |
|
1765 |
(('%1anObject |
|
1766 |
"dispatched back from the visited %2-object (visitor pattern)" |
|
1767 |
||
1768 |
"fall back to general object-case - please change as required" |
|
1769 |
||
1770 |
^ self visitObject:anObject |
|
1771 |
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst) |
|
1772 |
forClass:visitorClass |
|
1773 |
inCategory:'visiting'. |
|
1774 |
]. |
|
1775 |
||
1776 |
(visitorClass includesSelector:#'visitObject:') ifFalse:[ |
|
1777 |
self |
|
1778 |
compile: |
|
1779 |
('visitObject:anObject |
|
1780 |
"dispatched back from the visited objects (visitor pattern)" |
|
1781 |
||
1782 |
"general fallBack - please change as required" |
|
1783 |
||
1784 |
self halt:''not yet implemented'' |
|
1785 |
') |
|
1786 |
forClass:visitorClass |
|
1787 |
inCategory:'visiting'. |
|
1788 |
]. |
|
1789 |
||
1790 |
(visitorClass includesSelector:#'visit:') ifFalse:[ |
|
1791 |
self |
|
1792 |
compile: |
|
1793 |
('visit:anObject |
|
1794 |
"visit anObject (visitor pattern). |
|
1795 |
The object should call back one of my visitXXXX methods." |
|
1796 |
||
1797 |
^ anObject acceptVisitor:self |
|
1798 |
') |
|
1799 |
forClass:visitorClass |
|
1800 |
inCategory:'visiting'. |
|
1801 |
]. |
|
1802 |
||
1803 |
self executeCollectedChangesNamed:('Add Visitor Pattern'). |
|
6050 | 1804 |
! |
1805 |
||
1806 |
createWebApplicationCodeFor:aClass |
|
1807 |
"create an empty webApplication framework" |
|
1808 |
||
1809 |
|nonMetaClass metaClass className txt| |
|
1810 |
||
1811 |
self startCollectChanges. |
|
1812 |
||
1813 |
nonMetaClass := aClass theNonMetaclass. |
|
1814 |
metaClass := aClass theMetaclass. |
|
1815 |
className := nonMetaClass name. |
|
1816 |
||
7973 | 1817 |
(metaClass includesSelector:#pageSpec) ifFalse:[ |
1818 |
txt := self class initialPageSpecMethodSourceForWebApplications. |
|
1819 |
self |
|
1820 |
compile:(txt bindWith:className) |
|
1821 |
forClass:metaClass |
|
1822 |
inCategory:'page specs'. |
|
1823 |
]. |
|
1824 |
||
1825 |
self executeCollectedChangesNamed:('Add WebApplication Code for ' , className). |
|
1826 |
||
1827 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
1828 |
! |
|
1829 |
||
1830 |
createWebServiceCodeFor:aClass |
|
1831 |
"create an empty webService framework" |
|
1832 |
||
1833 |
|nonMetaClass metaClass className txt| |
|
1834 |
||
1835 |
self startCollectChanges. |
|
1836 |
||
1837 |
nonMetaClass := aClass theNonMetaclass. |
|
1838 |
metaClass := aClass theMetaclass. |
|
1839 |
className := nonMetaClass name. |
|
1840 |
||
6050 | 1841 |
(nonMetaClass includesSelector:#process:) ifFalse:[ |
1842 |
txt := |
|
1843 |
'process:aRequest |
|
7973 | 1844 |
"This is the web services main processing method. |
6050 | 1845 |
It will be invoked for every incoming webBrowser-request. |
1846 |
The argument, aRequest contains the parameters (url, fields, parameters etc.)." |
|
1847 |
||
1848 |
|response| |
|
1849 |
||
1850 |
response := aRequest response. |
|
1851 |
response nextPutLine:''<HTML>''. |
|
1852 |
response nextPutLine:'' <HEAD>''. |
|
1853 |
response nextPutLine:'' <TITLE>Hello</TITLE>''. |
|
1854 |
response nextPutLine:'' </HEAD>''. |
|
1855 |
response nextPutLine:'' <BODY>''. |
|
1856 |
response nextPutLine:'' <H1>Hello World !!</H1>''. |
|
1857 |
response nextPutLine:'' </BODY>''. |
|
1858 |
response nextPutLine:''</HTML>''. |
|
1859 |
'. |
|
1860 |
self |
|
1861 |
compile:txt |
|
1862 |
forClass:nonMetaClass |
|
1863 |
inCategory:'response generation'. |
|
1864 |
]. |
|
1865 |
||
1866 |
(metaClass includesSelector:#linkName) ifFalse:[ |
|
1867 |
txt := |
|
1868 |
'linkName |
|
1869 |
"return the default linkName path (with slash)." |
|
1870 |
||
1871 |
^ ''/NewService'' |
|
1872 |
'. |
|
1873 |
self |
|
1874 |
compile:txt |
|
1875 |
forClass:metaClass |
|
1876 |
inCategory:'defaults'. |
|
1877 |
]. |
|
1878 |
||
1879 |
(metaClass includesSelector:#settingsApplicationClass) ifFalse:[ |
|
1880 |
txt := |
|
1881 |
'settingsApplicationClass |
|
1882 |
"a SettingsApplication class - or nil (used in the settings dialog if non-nil)." |
|
1883 |
||
1884 |
^ nil |
|
1885 |
'. |
|
1886 |
self |
|
1887 |
compile:txt |
|
1888 |
forClass:metaClass |
|
1889 |
inCategory:'defaults'. |
|
1890 |
]. |
|
1891 |
||
1892 |
||
7973 | 1893 |
self executeCollectedChangesNamed:('Add WebService Code for ' , className). |
6050 | 1894 |
|
1895 |
"Modified: / 1.2.1998 / 16:10:03 / cg" |
|
8572 | 1896 |
! |
1897 |
||
1898 |
createWidgetCodeFor:aClass |
|
1899 |
"create usually required widget code (redraw, model update, event handling)" |
|
1900 |
||
1901 |
|nonMetaClass metaClass className compileTemplateAction| |
|
1902 |
||
1903 |
self startCollectChanges. |
|
1904 |
||
1905 |
nonMetaClass := aClass theNonMetaclass. |
|
1906 |
metaClass := aClass theMetaclass. |
|
1907 |
className := nonMetaClass name. |
|
1908 |
||
1909 |
compileTemplateAction := |
|
1910 |
[:selector :templateSelector :category | |
|
1911 |
(nonMetaClass includesSelector:selector) ifFalse:[ |
|
1912 |
|txt| |
|
1913 |
||
1914 |
txt := self perform:templateSelector. |
|
1915 |
self |
|
1916 |
compile:txt |
|
1917 |
forClass:nonMetaClass |
|
1918 |
inCategory:category. |
|
1919 |
] |
|
1920 |
]. |
|
1921 |
||
1922 |
#( |
|
1923 |
#'initialize' #code_forWidget_initialize 'initialization & release' |
|
1924 |
#'update:with:from:' #code_forWidget_update 'change & update' |
|
1925 |
#'redrawX:y:width:height:' #code_forWidget_redraw 'drawing' |
|
1926 |
#'buttonPress:x:y:' #code_forWidget_buttonPress 'event handling' |
|
1927 |
#'keyPress:x:y:' #code_forWidget_keyPress 'event handling' |
|
1928 |
#'sizeChanged:' #code_forWidget_sizeChanged 'event handling' |
|
1929 |
) inGroupsOf:3 do:compileTemplateAction. |
|
1930 |
||
1931 |
self executeCollectedChangesNamed:('Add Widget Code for ' , className). |
|
5758 | 1932 |
! ! |
1933 |
||
1934 |
!CodeGeneratorTool methodsFor:'code generation-basic'! |
|
1935 |
||
1936 |
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization |
|
1937 |
"workhorse for creating access methods for instvars." |
|
1938 |
||
8572 | 1939 |
|classesClassVars generateCommentsForSetters generateCommentsForGetters| |
5758 | 1940 |
|
1941 |
self startCollectChanges. |
|
1942 |
||
8572 | 1943 |
generateCommentsForSetters := userPreferences generateCommentsForSetters. |
1944 |
generateCommentsForGetters := userPreferences generateCommentsForGetters. |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1945 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1946 |
classesClassVars := aClass theNonMetaclass allClassVarNames. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1947 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1948 |
aCollectionOfVarNames do:[:name | |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
1949 |
|source varType methodName defaultMethodName argName| |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1950 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1951 |
varType := (classesClassVars includes:name) |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1952 |
ifTrue:['static'] |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1953 |
ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1954 |
(aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1955 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1956 |
methodName := name. |
6643 | 1957 |
name isUppercaseFirst ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1958 |
methodName := methodName asLowercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1959 |
]. |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
1960 |
argName := 'something'. |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1961 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1962 |
"/ the GETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1963 |
writersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1964 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1965 |
defaultMethodName := 'default' , name asUppercaseFirst. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1966 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1967 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1968 |
"check, if method is not already present" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1969 |
(aClass includesSelector:(methodName asSymbol)) ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1970 |
asValueHolder ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1971 |
source := methodName , '\'. |
5758 | 1972 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1973 |
source := source , ' "return/create the ''%2'' value holder (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1974 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1975 |
source := source , ' %2 isNil ifTrue:[\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1976 |
lazyInitialization ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1977 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1978 |
, ' %2 := self class %3 asValue.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1979 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1980 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1981 |
, ' %2 := ValueHolder new.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1982 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1983 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1984 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1985 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1986 |
, ' %2 addDependent:self.\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1987 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1988 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1989 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1990 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1991 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1992 |
source := methodName , '\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1993 |
lazyInitialization ifTrue:[ |
5758 | 1994 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1995 |
source := source , ' "return the %1 instance variable ''%2'' with lazy instance creation (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1996 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1997 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1998 |
, ' %2 isNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
1999 |
, ' %2 := self class %3.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2000 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2001 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2002 |
] ifFalse:[ |
5758 | 2003 |
generateCommentsForGetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2004 |
source := source , ' "return the %1 instance variable ''%2'' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2005 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2006 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2007 |
, ' ^ %2'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2008 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2009 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2010 |
source := (source bindWith:varType with:name with:defaultMethodName) withCRs. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2011 |
self compile:source forClass:aClass inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']). |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2012 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2013 |
Transcript showCR:'method ''', methodName , ''' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2014 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2015 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2016 |
"/ default for lazy on class side |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2017 |
lazyInitialization ifTrue:[ |
9232
e16232d1a1dc
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
9215
diff
changeset
|
2018 |
(aClass theMetaclass includesSelector:(defaultMethodName asSymbol)) ifFalse:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2019 |
source := defaultMethodName , '\'. |
5758 | 2020 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2021 |
source := source , ' "default value for the ''%2'' instance variable (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2022 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2023 |
source := source |
6839
c25218305e50
Send #shouldImplement instead of #halt:.
Stefan Vogel <sv@exept.de>
parents:
6791
diff
changeset
|
2024 |
, ' self shouldImplement.\' |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2025 |
, ' ^ nil.'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2026 |
source := (source bindWith:varType with:name) withCRs. |
9232
e16232d1a1dc
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
9215
diff
changeset
|
2027 |
self compile:source forClass:aClass theMetaclass inCategory:'defaults'. |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2028 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2029 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2030 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2031 |
|
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2032 |
"/ the SETTER |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2033 |
readersOnly ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2034 |
(aClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[ |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2035 |
((methodName size > 2) and:[ (methodName startsWith:'is') and:[ (methodName at:3) isUppercase ]]) |
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2036 |
ifTrue:[ |
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2037 |
argName := 'aBoolean' |
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2038 |
]. |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2039 |
asValueHolder ifTrue:[ |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2040 |
source := methodName , ':%3\'. "/ argName |
5758 | 2041 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2042 |
source := source , ' "set the ''%2'' value holder' , ' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2043 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2044 |
withChange ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2045 |
source := source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2046 |
, ' |oldValue newValue|\\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2047 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2048 |
, ' oldValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2049 |
, ' %2 removeDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2050 |
, ' ].\' |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2051 |
, ' %2 := %3.\' "/ argName |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2052 |
, ' %2 notNil ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2053 |
, ' %2 addDependent:self.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2054 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2055 |
, ' newValue := %2 value.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2056 |
, ' oldValue ~~ newValue ifTrue:[\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2057 |
, ' self update:#value with:newValue from:%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2058 |
, ' ].\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2059 |
] ifFalse:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2060 |
source := source |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2061 |
, ' %2 := %3.'. "/ argName |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2062 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2063 |
] ifFalse:[ |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2064 |
source := methodName , ':%3\'. "/ argName |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2065 |
withChange ifTrue:[ |
5758 | 2066 |
generateComments ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2067 |
source := source , ' "set the value of the %1 variable ''%2'''. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2068 |
source := source , ' and send a change notification (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2069 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2070 |
source := source |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2071 |
, ' (%2 ~~ %3) ifTrue:[\' |
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2072 |
, ' %2 := %3.\' "/ argName |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2073 |
, ' self changed:#%2.\' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2074 |
, ' ].\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2075 |
] ifFalse:[ |
5758 | 2076 |
generateCommentsForSetters ifTrue:[ |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2077 |
source := source , ' "set the value of the %1 variable ''%2'''. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2078 |
source := source , ' (automatically generated)"\\'. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2079 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2080 |
source := source |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2081 |
, ' %2 := %3.'. "/ argName |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2082 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2083 |
]. |
8773
a722c4bb21a7
changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents:
8574
diff
changeset
|
2084 |
source := (source bindWith:varType with:name with:argName) withCRs. |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2085 |
self |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2086 |
compile:source |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2087 |
forClass:aClass |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2088 |
inCategory:(asValueHolder ifTrue:['aspects'] ifFalse:['accessing']). |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2089 |
] ifTrue:[ |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2090 |
Transcript showCR:'method ''', methodName , ':'' already present' |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2091 |
]. |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2092 |
]. |
5758 | 2093 |
]. |
2094 |
||
2095 |
self executeCollectedChangesNamed:('Add Accessors'). |
|
5763 | 2096 |
! |
2097 |
||
7615 | 2098 |
createCollectionAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange |
8572 | 2099 |
|classesClassVars| |
7615 | 2100 |
|
2101 |
self startCollectChanges. |
|
2102 |
||
2103 |
classesClassVars := aClass theNonMetaclass allClassVarNames. |
|
2104 |
||
2105 |
aCollectionOfVarNames do:[:name | |
|
2106 |
|source varType methodNameBase methodName defaultMethodName| |
|
2107 |
||
2108 |
varType := (classesClassVars includes:name) |
|
2109 |
ifTrue:['static'] |
|
2110 |
ifFalse:[ |
|
2111 |
(aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])]. |
|
2112 |
||
2113 |
methodNameBase := name asUppercaseFirst. |
|
2114 |
(methodNameBase endsWith:'s') ifTrue:[ |
|
2115 |
methodNameBase := methodNameBase copyWithoutLast:1. |
|
2116 |
]. |
|
2117 |
methodName := 'add' , methodNameBase, ':'. |
|
2118 |
||
2119 |
"check, if method is not already present" |
|
2120 |
(aClass includesSelector:(methodName asSymbol)) ifFalse:[ |
|
2121 |
source := methodName , 'a%1\'. |
|
2122 |
generateComments ifTrue:[ |
|
2123 |
source := source , ' "add a ',methodNameBase,'"\\'. |
|
2124 |
]. |
|
2125 |
source := source , ' %2 isNil ifTrue:[\'. |
|
2126 |
source := source |
|
2127 |
, ' %2 := OrderedCollection new.\'. |
|
2128 |
source := source |
|
2129 |
, ' ].\' |
|
2130 |
, ' %2 add: a%1'. |
|
2131 |
source := (source bindWith:methodNameBase with:name) withCRs. |
|
2132 |
self compile:source forClass:aClass inCategory:'accessing'. |
|
2133 |
] ifTrue:[ |
|
2134 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
2135 |
]. |
|
2136 |
||
2137 |
methodName := 'remove' , methodNameBase, ':'. |
|
2138 |
||
2139 |
"check, if method is not already present" |
|
2140 |
(aClass includesSelector:(methodName asSymbol)) ifFalse:[ |
|
2141 |
source := methodName , 'a%1\'. |
|
2142 |
generateComments ifTrue:[ |
|
2143 |
source := source , ' "remove a ',methodNameBase,'"\\'. |
|
2144 |
]. |
|
2145 |
source := source |
|
2146 |
, ' %2 remove: a%1'. |
|
2147 |
source := (source bindWith:methodNameBase with:name) withCRs. |
|
2148 |
self compile:source forClass:aClass inCategory:'accessing'. |
|
2149 |
] ifTrue:[ |
|
2150 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
2151 |
]. |
|
2152 |
]. |
|
2153 |
||
2154 |
self |
|
2155 |
createAccessMethodsFor:aCollectionOfVarNames |
|
2156 |
in:aClass |
|
2157 |
withChange:withChange |
|
2158 |
asValueHolder:false |
|
2159 |
readersOnly:true |
|
2160 |
writersOnly:false |
|
2161 |
lazyInitialization:false. |
|
2162 |
||
2163 |
self executeCollectedChangesNamed:('Add Collection Access'). |
|
2164 |
||
2165 |
"Created: / 04-02-2007 / 15:52:31 / cg" |
|
2166 |
! |
|
2167 |
||
5763 | 2168 |
createValueHoldersFor:aCollectionOfVarNames in:aClass lazyInitialization:lazyInitialization |
2169 |
"workhorse for creating access methods for instvars." |
|
2170 |
||
8572 | 2171 |
|nonMetaClass metaClass classesClassVars generateCommentsForSetters generateCommentsForGetters| |
6050 | 2172 |
|
2173 |
nonMetaClass := aClass theNonMetaclass. |
|
2174 |
metaClass := aClass theMetaclass. |
|
5763 | 2175 |
|
2176 |
self startCollectChanges. |
|
2177 |
||
8572 | 2178 |
generateCommentsForSetters := userPreferences generateCommentsForSetters. |
2179 |
generateCommentsForGetters := userPreferences generateCommentsForGetters. |
|
5763 | 2180 |
|
6050 | 2181 |
classesClassVars := nonMetaClass allClassVarNames. |
5763 | 2182 |
|
2183 |
aCollectionOfVarNames do:[:name | |
|
2184 |
|source varType methodName holderMethodName defaultMethodName| |
|
2185 |
||
2186 |
holderMethodName := name. |
|
6643 | 2187 |
name isUppercaseFirst ifTrue:[ |
5763 | 2188 |
holderMethodName := holderMethodName asLowercaseFirst. |
2189 |
]. |
|
2190 |
(holderMethodName endsWith:'Holder') ifTrue:[ |
|
2191 |
methodName := holderMethodName copyWithoutLast:6. |
|
2192 |
] ifFalse:[ |
|
2193 |
methodName := holderMethodName. |
|
2194 |
holderMethodName := methodName , 'Holder'. |
|
2195 |
]. |
|
2196 |
||
2197 |
methodName notNil ifTrue:[ |
|
6050 | 2198 |
(metaClass includesSelector:(methodName asSymbol)) ifFalse:[ |
5763 | 2199 |
source := '%1\'. |
2200 |
generateComments ifTrue:[ |
|
2201 |
source := source , ' "return the value in ''%2''"\\'. |
|
2202 |
]. |
|
2203 |
source := source , ' ^ self %2 value'. |
|
2204 |
source := (source bindWith:methodName with:holderMethodName) withCRs. |
|
6050 | 2205 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 2206 |
] ifTrue:[ |
2207 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
2208 |
]. |
|
2209 |
||
6050 | 2210 |
(metaClass includesSelector:((methodName , ':') asSymbol)) ifFalse:[ |
5763 | 2211 |
source := '%1: newValue\'. |
2212 |
generateComments ifTrue:[ |
|
2213 |
source := source , ' "set the value in ''%2''"\\'. |
|
2214 |
]. |
|
2215 |
source := source , ' self %2 value: newValue'. |
|
2216 |
source := (source bindWith:methodName with:holderMethodName) withCRs. |
|
6050 | 2217 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 2218 |
] ifTrue:[ |
2219 |
Transcript showCR:'method ''', methodName , ':'' already present' |
|
2220 |
]. |
|
2221 |
]. |
|
6050 | 2222 |
(metaClass includesSelector:(holderMethodName asSymbol)) ifFalse:[ |
5763 | 2223 |
source := '%1\'. |
2224 |
generateComments ifTrue:[ |
|
2225 |
source := source , ' "return/create the valueHolder ''%1''"\\'. |
|
2226 |
]. |
|
2227 |
source := source , ' %1 isNil ifTrue:[\'. |
|
2228 |
source := source , ' %1 := ValueHolder with:nil "defaultValue here".\'. |
|
2229 |
source := source , ' ].\'. |
|
2230 |
source := source , ' ^ %1\'. |
|
2231 |
source := (source bindWith:holderMethodName) withCRs. |
|
6050 | 2232 |
self compile:source forClass:nonMetaClass inCategory:('accessing'). |
5763 | 2233 |
] ifTrue:[ |
2234 |
Transcript showCR:'method ''', methodName , ''' already present' |
|
2235 |
]. |
|
2236 |
]. |
|
2237 |
||
2238 |
self executeCollectedChangesNamed:('Add ValueHolder'). |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2239 |
! ! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
2240 |
|
5758 | 2241 |
!CodeGeneratorTool methodsFor:'code generation-individual methods'! |
3712 | 2242 |
|
2243 |
createAcceptVisitorMethod:selector in:aClass |
|
2244 |
"create an acceptVisitor: method |
|
2245 |
(I'm tired of typing)" |
|
2246 |
||
6921 | 2247 |
self assert:( aClass isMeta not ). |
3712 | 2248 |
|
2249 |
(aClass includesSelector:#'acceptVisitor:') ifFalse:[ |
|
2250 |
self |
|
2251 |
compile: |
|
2252 |
(('acceptVisitor:aVisitor |
|
2253 |
"Double dispatch back to the visitor, passing my type encoded in |
|
2254 |
the selector (visitor pattern)" |
|
2255 |
||
2256 |
"stub code automatically generated - please change if required" |
|
2257 |
||
2258 |
^ aVisitor %1self |
|
2259 |
') bindWith:selector) |
|
2260 |
forClass:aClass |
|
2261 |
inCategory:'visiting'. |
|
2262 |
] |
|
2263 |
! |
|
2264 |
||
2265 |
createAcceptVisitorMethodIn:aClass |
|
2266 |
"create an acceptVisitor: method |
|
2267 |
(I'm tired of typing)" |
|
2268 |
||
2269 |
self |
|
2270 |
createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix , ':') asSymbol |
|
2271 |
in:aClass |
|
2272 |
! |
|
2273 |
||
2274 |
createCopyrightMethodFor:aClass |
|
2275 |
"add copyright method containing your/your companies |
|
2276 |
copyright template but only if not already present. |
|
2277 |
this is only added, if specified in the |
|
2278 |
COPYRIGHT_TEMPLATE_FILE resources." |
|
2279 |
||
8258 | 2280 |
|fn copyRightText| |
3712 | 2281 |
|
2282 |
(aClass includesSelector:#copyright) ifFalse:[ |
|
2283 |
fn := SystemBrowser classResources at:#'COPYRIGHT_TEMPLATE_FILE' default:nil. |
|
2284 |
fn notNil ifTrue:[ |
|
2285 |
fn := fn asFilename. |
|
2286 |
fn exists ifTrue:[ |
|
8488 | 2287 |
copyRightText := fn contentsAsString. |
8258 | 2288 |
self createCopyrightMethodFor:copyRightText for:aClass |
3712 | 2289 |
] |
2290 |
]. |
|
8258 | 2291 |
]. |
2292 |
! |
|
2293 |
||
2294 |
createCopyrightMethodFor:copyRightText for:aClass |
|
2295 |
"add copyright method containing text, |
|
2296 |
but only if not already present." |
|
2297 |
||
2298 |
|txt| |
|
2299 |
||
2300 |
(aClass includesSelector:#copyright) ifFalse:[ |
|
2301 |
copyRightText notNil ifTrue:[ |
|
2302 |
txt := copyRightText bindWith:(Date today year). |
|
3712 | 2303 |
self compile: |
2304 |
'copyright |
|
2305 |
" |
|
2306 |
' , txt , ' |
|
2307 |
" |
|
2308 |
' forClass:aClass |
|
2309 |
inCategory:'documentation'. |
|
2310 |
] |
|
2311 |
]. |
|
2312 |
! |
|
2313 |
||
2314 |
createDocumentationMethodFor:aClass |
|
2315 |
"add documentation method containing doc template |
|
2316 |
but only if not already present." |
|
2317 |
||
6050 | 2318 |
|metaClass nonMetaClass userName loginName hostName emailAddress code existingComment| |
2319 |
||
2320 |
metaClass := aClass theMetaclass. |
|
2321 |
nonMetaClass := aClass theNonMetaclass. |
|
3712 | 2322 |
|
6050 | 2323 |
(metaClass includesSelector:#documentation) ifFalse:[ |
2324 |
existingComment := nonMetaClass comment. |
|
2325 |
existingComment isEmptyOrNil ifTrue:[ |
|
2326 |
(nonMetaClass isSubclassOf:HTTPService) ifTrue:[ |
|
6159 | 2327 |
existingComment := ' [start Server with:] |
7545
df2fc5dbee78
changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents:
7480
diff
changeset
|
2328 |
HTTPServer startServerOnPort:8080 |
6159 | 2329 |
|
2330 |
[start with:] |
|
6050 | 2331 |
(self new) |
7545
df2fc5dbee78
changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents:
7480
diff
changeset
|
2332 |
registerServiceOn:(HTTPServer runningServerOnPort:8080)'. |
6050 | 2333 |
]. |
2334 |
]. |
|
2335 |
||
3712 | 2336 |
userName := OperatingSystem getFullUserName. |
2337 |
loginName := OperatingSystem getLoginName. |
|
2338 |
hostName := OperatingSystem getHostName. |
|
2339 |
emailAddress := loginName , '@' , hostName. |
|
2340 |
||
5756 | 2341 |
"/ ugly; should ask the class for that |
6350 | 2342 |
metaClass isJavaScriptMetaclass ifTrue:[ |
5756 | 2343 |
code := |
2344 |
'function documentation() { |
|
2345 |
/* |
|
6050 | 2346 |
' , (existingComment ? ' documentation to be added.') , ' |
5756 | 2347 |
|
2348 |
[author:] |
|
2349 |
' , userName |
|
2350 |
, ' (' , emailAddress , ')' , ' |
|
2351 |
||
2352 |
[instance variables:] |
|
2353 |
||
2354 |
[class variables:] |
|
2355 |
||
2356 |
[see also:] |
|
2357 |
||
2358 |
*/ |
|
2359 |
} |
|
2360 |
' |
|
2361 |
] ifFalse:[ |
|
2362 |
code:= |
|
3712 | 2363 |
'documentation |
2364 |
" |
|
6050 | 2365 |
' , (existingComment ? ' documentation to be added.') , ' |
3712 | 2366 |
|
2367 |
[author:] |
|
2368 |
' , userName |
|
2369 |
, ' (' , emailAddress , ')' , ' |
|
2370 |
||
2371 |
[instance variables:] |
|
2372 |
||
2373 |
[class variables:] |
|
2374 |
||
2375 |
[see also:] |
|
2376 |
||
2377 |
" |
|
5756 | 2378 |
' |
2379 |
]. |
|
2380 |
||
2381 |
self |
|
2382 |
compile:code |
|
6050 | 2383 |
forClass:metaClass |
5756 | 2384 |
inCategory:'documentation'. |
3712 | 2385 |
]. |
7545
df2fc5dbee78
changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents:
7480
diff
changeset
|
2386 |
|
df2fc5dbee78
changed #createDocumentationMethodFor:
Claus Gittinger <cg@exept.de>
parents:
7480
diff
changeset
|
2387 |
"Modified: / 24-11-2006 / 15:54:27 / cg" |
3712 | 2388 |
! |
2389 |
||
2390 |
createExamplesMethodFor:aClass |
|
2391 |
"add examples method containing examples template |
|
2392 |
but only if not already present." |
|
2393 |
||
6050 | 2394 |
|nonMetaclass fragment| |
2395 |
||
2396 |
nonMetaclass := aClass theNonMetaclass. |
|
8572 | 2397 |
|
2398 |
(nonMetaclass isSubclassOf:View) ifTrue:[ |
|
2399 |
self createExamplesMethodForViewClass:aClass. |
|
2400 |
^ self |
|
2401 |
]. |
|
2402 |
||
6050 | 2403 |
(nonMetaclass isSubclassOf:ApplicationModel) ifFalse:[ |
2404 |
^ self |
|
2405 |
]. |
|
3712 | 2406 |
|
2407 |
(aClass includesSelector:#examples) ifFalse:[ |
|
6050 | 2408 |
(nonMetaclass isSubclassOf:ApplicationModel) ifTrue:[ |
3712 | 2409 |
fragment := ' Starting the application: |
2410 |
[exBegin] |
|
6050 | 2411 |
' , nonMetaclass name , ' open |
3712 | 2412 |
|
2413 |
[exEnd] |
|
2414 |
' |
|
2415 |
] ifFalse:[ |
|
2416 |
fragment := '' |
|
2417 |
]. |
|
2418 |
||
2419 |
self |
|
2420 |
compile: |
|
2421 |
'examples |
|
2422 |
" |
|
2423 |
' , fragment , ' |
|
2424 |
more examples to be added: |
|
2425 |
[exBegin] |
|
2426 |
... add code fragment for |
|
2427 |
... executable example here ... |
|
2428 |
[exEnd] |
|
2429 |
" |
|
2430 |
' |
|
2431 |
forClass:aClass |
|
2432 |
inCategory:'documentation'. |
|
2433 |
]. |
|
2434 |
! |
|
2435 |
||
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2436 |
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2437 |
|imageStoreStream mthd imageKey category| |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2438 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2439 |
anImage storeOn: (imageStoreStream := WriteStream on: ''). |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2440 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2441 |
"/ if that method already exists, do not overwrite the category |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2442 |
category := 'image specs'. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2443 |
(mthd := aClass compiledMethodAt:sel) notNil ifTrue:[ |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2444 |
category := mthd category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2445 |
]. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2446 |
|
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2447 |
imageKey := (aClass name, ' ', sel) asSymbol. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2448 |
Icon constantNamed: imageKey put:nil. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2449 |
aClass |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2450 |
compile: ((sel, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2451 |
'\', comment, |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2452 |
'\\' , |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2453 |
' "\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2454 |
' self ' , sel , ' inspect\', |
3823 | 2455 |
' ImageEditor openOnClass:self andSelector:#', sel, '\', |
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2456 |
' Icon flushCachedIcons', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2457 |
'\ "', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2458 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2459 |
' <resource: #image>', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2460 |
'\\', |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2461 |
' ^Icon\') withCRs, |
7967
2560906ca552
use string-key in constantNamed:-icon caching
Claus Gittinger <cg@exept.de>
parents:
7615
diff
changeset
|
2462 |
' constantNamed:''', imageKey, '''\' withCRs, |
3822
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2463 |
' ifAbsentPut:[', imageStoreStream contents, ']') |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2464 |
classified: category. |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2465 |
! |
4e9f2f69875f
code generation for icons moved from ImageEditor
Claus Gittinger <cg@exept.de>
parents:
3804
diff
changeset
|
2466 |
|
3712 | 2467 |
createInitialHistoryMethodFor:aClass |
2468 |
"add history method containing created-entry |
|
2469 |
but only if not already present." |
|
2470 |
||
5758 | 2471 |
|code| |
2472 |
||
3712 | 2473 |
(aClass includesSelector:#history) ifFalse:[ |
2474 |
HistoryManager notNil ifTrue:[ |
|
5758 | 2475 |
code := HistoryManager codeForInitialHistoryMethodIn:aClass. |
2476 |
self |
|
2477 |
compile:code |
|
2478 |
forClass:aClass |
|
2479 |
inCategory:'documentation'. |
|
3712 | 2480 |
]. |
2481 |
]. |
|
2482 |
! |
|
2483 |
||
4512 | 2484 |
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass |
2485 |
"add an inst-creation method" |
|
2486 |
||
9236
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2487 |
|template instMthd argNames| |
4512 | 2488 |
|
2489 |
(aMetaClass includesSelector:selector) ifFalse:[ |
|
9236
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2490 |
instMthd := aMetaClass theNonMetaclass compiledMethodAt:selector. |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2491 |
(instMthd notNil |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2492 |
and:[ (argNames := instMthd methodArgNames) notEmptyOrNil ]) |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2493 |
ifTrue:[ |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2494 |
template := Parser methodSpecificationForSelector:selector argNames:argNames. |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2495 |
] ifFalse:[ |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2496 |
template := Parser methodSpecificationForSelector:selector. |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2497 |
]. |
3559b8aad270
changed: #createInstanceCreationMethodWithSetupFor:category:in:
Claus Gittinger <cg@exept.de>
parents:
9232
diff
changeset
|
2498 |
|
4512 | 2499 |
self |
2500 |
compile: |
|
2501 |
template , ' |
|
2502 |
^ self new ' , template , ' |
|
2503 |
' |
|
2504 |
forClass:aMetaClass |
|
2505 |
inCategory:category. |
|
2506 |
]. |
|
2507 |
! |
|
2508 |
||
3712 | 2509 |
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass |
2510 |
"create a multi-setter method for instvars." |
|
2511 |
||
2512 |
|source| |
|
2513 |
||
2514 |
source := ''. |
|
2515 |
aCollectionOfVarNames do:[:eachVar | |
|
2516 |
source := source , (eachVar , ':' , eachVar , 'Arg '). |
|
2517 |
]. |
|
2518 |
source := source , Character cr. |
|
8572 | 2519 |
(userPreferences generateCommentsForSetters) ifTrue:[ |
6993 | 2520 |
source := source , (' "set instance variables"' , Character cr , Character cr). |
6992 | 2521 |
]. |
3712 | 2522 |
aCollectionOfVarNames do:[:eachVar | |
2523 |
source := source , (' ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr). |
|
2524 |
]. |
|
2525 |
self compile:source forClass:aClass inCategory:'accessing'. |
|
2526 |
! |
|
2527 |
||
3800
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2528 |
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2529 |
"add a subclassResponsibility method; |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2530 |
but only if not already present." |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2531 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2532 |
(aClass includesSelector:aSelector) ifFalse:[ |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2533 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2534 |
self compile: |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2535 |
(Method methodDefinitionTemplateForSelector:aSelector) , |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2536 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2537 |
"raise an error: must be redefined in concrete subclass(es)" |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2538 |
|
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2539 |
^ self subclassResponsibility |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2540 |
' |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2541 |
forClass:aClass |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2542 |
inCategory:cat. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2543 |
]. |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2544 |
! |
a5c75c369855
added generateSubclassResponsibility
Claus Gittinger <cg@exept.de>
parents:
3719
diff
changeset
|
2545 |
|
3712 | 2546 |
createUpdateMethodIn:aClass |
2547 |
"create an update:with:from:-method |
|
2548 |
(I'm tired of typing)" |
|
2549 |
||
8572 | 2550 |
|code| |
2551 |
||
3712 | 2552 |
(aClass includesSelector:#'update:with:from:') ifFalse:[ |
8572 | 2553 |
generateComments ifFalse:[ |
2554 |
code := |
|
2555 |
'update:something with:aParameter from:changedObject |
|
2556 |
super update:something with:aParameter from:changedObject |
|
2557 |
' |
|
2558 |
] ifTrue:[ |
|
2559 |
code := |
|
3712 | 2560 |
'update:something with:aParameter from:changedObject |
2561 |
"Invoked when an object that I depend upon sends a change notification." |
|
2562 |
||
2563 |
"stub code automatically generated - please change as required" |
|
2564 |
||
2565 |
"/ changedObject == someOfMyValueHolders ifTrue:[ |
|
4926 | 2566 |
"/ self doSomethingApropriate. |
2567 |
"/ ^ self. |
|
3712 | 2568 |
"/ ]. |
2569 |
super update:something with:aParameter from:changedObject |
|
2570 |
' |
|
8572 | 2571 |
]. |
2572 |
||
2573 |
self |
|
2574 |
compile:code |
|
3712 | 2575 |
forClass:aClass |
2576 |
inCategory:'change & update'. |
|
2577 |
] |
|
2578 |
! |
|
2579 |
||
2580 |
createVersionMethodFor:aClass |
|
8890 | 2581 |
<resource: #obsolete> |
3712 | 2582 |
"add version method containing RCS template |
2583 |
but only if not already present and its not a private class." |
|
2584 |
||
5756 | 2585 |
|code| |
2586 |
||
8890 | 2587 |
self obsoleteMethodWarning. |
2588 |
||
3712 | 2589 |
aClass isPrivate ifFalse:[ |
2590 |
(aClass includesSelector:#version) ifFalse:[ |
|
5756 | 2591 |
"/ ugly; should ask the class for that |
2592 |
aClass isJavaScriptClass ifTrue:[ |
|
2593 |
code:= ('function version() {\ return ("$' , 'Header$");\}') withCRs |
|
2594 |
] ifFalse:[ |
|
2595 |
code:= ('version\ ^ ''$' , 'Header$''') withCRs |
|
2596 |
]. |
|
2597 |
self |
|
2598 |
compile:code |
|
2599 |
forClass:aClass |
|
2600 |
inCategory:'documentation'. |
|
3712 | 2601 |
] |
2602 |
]. |
|
2603 |
! ! |
|
2604 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2605 |
!CodeGeneratorTool methodsFor:'code templates'! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2606 |
|
8987 | 2607 |
codeFor_classInitialize |
2608 |
generateComments ifFalse:[ |
|
2609 |
^ |
|
2610 |
'initialize |
|
2611 |
%(INIT_CLASSINSTVARS) |
|
2612 |
%(INIT_CLASSVARS) |
|
2613 |
'. |
|
2614 |
]. |
|
2615 |
||
2616 |
^ |
|
2617 |
'initialize |
|
2618 |
"Invoked at system start or when the class is dynamically loaded." |
|
2619 |
||
2620 |
"/ please change as required (and remove this comment) |
|
2621 |
%(INIT_CLASSINSTVARS) |
|
2622 |
%(INIT_CLASSVARS) |
|
2623 |
'. |
|
2624 |
! |
|
2625 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2626 |
codeFor_closeAccept |
8572 | 2627 |
generateComments ifFalse:[ |
2628 |
^ |
|
2629 |
'closeAccept |
|
2630 |
^ super closeAccept |
|
2631 |
'. |
|
2632 |
]. |
|
2633 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2634 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2635 |
'closeAccept |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2636 |
"This is a hook method generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2637 |
It will be invoked when your dialog-window is closed with OK." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2638 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2639 |
"/ add any actions as required here ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2640 |
Transcript showCR:''dialog accepted''. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2641 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2642 |
"/ do not remove the one below (otherwise, the dialog will not close itself)... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2643 |
^ super closeAccept |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2644 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2645 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2646 |
"Created: / 27-10-2006 / 10:03:31 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2647 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2648 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2649 |
codeFor_closeDownViews |
8572 | 2650 |
generateComments ifFalse:[ |
2651 |
^ |
|
2652 |
'closeDownViews |
|
2653 |
^ super closeDownViews |
|
2654 |
'. |
|
2655 |
]. |
|
2656 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2657 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2658 |
'closeDownViews |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2659 |
"This is a hook method generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2660 |
It will be invoked when your app/dialog-window is really closed. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2661 |
See also #closeDownViews, which is invoked before and may suppress the close |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2662 |
or ask the user for confirmation." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2663 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2664 |
"/ change the code below as required ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2665 |
"/ This should cleanup any leftover resources |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2666 |
"/ (for example, temporary files) |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2667 |
"/ super closeRequest will initiate the closeDown |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2668 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2669 |
"/ add your code here |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2670 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2671 |
"/ do not remove the one below ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2672 |
^ super closeDownViews |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2673 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2674 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2675 |
"Created: / 27-10-2006 / 10:01:32 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2676 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2677 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2678 |
codeFor_closeRequest |
8572 | 2679 |
generateComments ifFalse:[ |
2680 |
^ |
|
2681 |
'closeRequest |
|
2682 |
self hasUnsavedChanges ifTrue:[ |
|
2683 |
(self confirm:(resources string:''Close without saving ?'')) ifFalse:[ |
|
2684 |
^ self |
|
2685 |
] |
|
2686 |
]. |
|
2687 |
^ super closeRequest |
|
2688 |
'. |
|
2689 |
]. |
|
2690 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2691 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2692 |
'closeRequest |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2693 |
"This is a hook method generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2694 |
It will be invoked when your app/dialog-window is about to be |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2695 |
closed (this method has a chance to suppress the close). |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2696 |
See also #closeDownViews, which is invoked when the close is really done." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2697 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2698 |
"/ change the code below as required ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2699 |
"/ Closing can be suppressed, by simply returning. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2700 |
"/ The ''super closeRequest'' at the end will initiate the real closeDown |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2701 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2702 |
self hasUnsavedChanges ifTrue:[ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2703 |
(self confirm:(resources string:''Close without saving ?'')) ifFalse:[ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2704 |
^ self |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2705 |
] |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2706 |
]. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2707 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2708 |
^ super closeRequest |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2709 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2710 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2711 |
"Created: / 27-10-2006 / 10:01:06 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2712 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2713 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2714 |
codeFor_doSaveAs |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2715 |
^ self codeFor_emptyMenuActionCodeFor:#doSaveAs menuItem:'save/saveAs' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2716 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2717 |
"Created: / 27-10-2006 / 10:22:06 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2718 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2719 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2720 |
codeFor_emptyMenuActionCodeFor:selector menuItem:item |
8572 | 2721 |
generateComments ifFalse:[ |
2722 |
^ |
|
2723 |
selector,' |
|
2724 |
self warn:''no action for ''''',item,''''' defined.''. |
|
2725 |
'. |
|
2726 |
]. |
|
2727 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2728 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2729 |
selector,' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2730 |
"This method was generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2731 |
It will be invoked when the menu-item ''',item,''' is selected." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2732 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2733 |
"/ change below and add any actions as required here ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2734 |
self warn:''no action for ''''',item,''''' defined.''. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2735 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2736 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2737 |
"Created: / 27-10-2006 / 10:16:43 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2738 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2739 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2740 |
codeFor_hasUnsavedChanges |
8572 | 2741 |
generateComments ifFalse:[ |
2742 |
^ |
|
2743 |
'hasUnsavedChanges |
|
2744 |
^ false. |
|
2745 |
'. |
|
2746 |
]. |
|
2747 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2748 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2749 |
'hasUnsavedChanges |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2750 |
"Return true, if any unsaved changes are present |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2751 |
(i.e. the contents needs to be saved or else will be lost)" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2752 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2753 |
"/ add real code as required (or remove the halt and always return false)... |
9053
9e09bbdb81a3
changed: #codeFor_hasUnsavedChanges
Claus Gittinger <cg@exept.de>
parents:
9049
diff
changeset
|
2754 |
"/ self halt:''check this code''. |
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2755 |
^ false. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2756 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2757 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2758 |
"Created: / 27-10-2006 / 10:00:36 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2759 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2760 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2761 |
codeFor_menuNew |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2762 |
^ self codeFor_emptyMenuActionCodeFor:#menuNew menuItem:'new' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2763 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2764 |
"Created: / 27-10-2006 / 10:17:08 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2765 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2766 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2767 |
codeFor_menuOpen |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2768 |
^ self codeFor_emptyMenuActionCodeFor:#menuOpen menuItem:'open' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2769 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2770 |
"Created: / 27-10-2006 / 10:17:18 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2771 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2772 |
|
9099
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
2773 |
codeFor_menuReload |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
2774 |
^ self codeFor_emptyMenuActionCodeFor:#menuReload menuItem:'reload' |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
2775 |
! |
2729600bb93c
include toolbar for new apps
Claus Gittinger <cg@exept.de>
parents:
9081
diff
changeset
|
2776 |
|
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2777 |
codeFor_menuSave |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2778 |
^ self codeFor_emptyMenuActionCodeFor:#menuSave menuItem:'save' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2779 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2780 |
"Created: / 27-10-2006 / 10:17:25 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2781 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2782 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2783 |
codeFor_menuSaveAs |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2784 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2785 |
'menuSaveAs |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2786 |
"This method was generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2787 |
It will be invoked when the menu-item ''saveAs'' is selected." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2788 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2789 |
"/ change below as required... (see examples in Dialog class for more options) |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2790 |
Dialog |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2791 |
requestSaveFileName:(resources string:''Save'') |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2792 |
default:''foo.txt'' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2793 |
fromDirectory:nil |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2794 |
action:[:fileName | self doSaveAs:fileName] |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2795 |
appendAction:nil. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2796 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2797 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2798 |
"Created: / 27-10-2006 / 10:01:57 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2799 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2800 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2801 |
codeFor_openAboutThisApplication |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2802 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2803 |
'openAboutThisApplication |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2804 |
"This method was generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2805 |
It will be invoked when the menu-item ''help-about'' is selected." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2806 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2807 |
"/ could open a customized aboutBox here ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2808 |
super openAboutThisApplication |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2809 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2810 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2811 |
"Created: / 27-10-2006 / 10:03:13 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2812 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2813 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2814 |
codeFor_openDocumentation |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2815 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2816 |
'openDocumentation |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2817 |
"This method was generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2818 |
It will be invoked when the menu-item ''help-documentation'' is selected." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2819 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2820 |
"/ change below as required ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2821 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2822 |
"/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ): |
9264
171e3ab3697d
changed: #codeFor_openDocumentation
Claus Gittinger <cg@exept.de>
parents:
9261
diff
changeset
|
2823 |
self openDocumentationFile:''TOP.html''. |
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2824 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2825 |
"/ add application-specific help files under the ''doc/online/<language>/help/appName'' |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2826 |
"/ directory, and open a viewer with: |
9264
171e3ab3697d
changed: #codeFor_openDocumentation
Claus Gittinger <cg@exept.de>
parents:
9261
diff
changeset
|
2827 |
"/ self openDocumentationFile:''help/<MyApplication>/TOP.html''. |
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2828 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2829 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2830 |
"Created: / 27-10-2006 / 10:02:55 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2831 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2832 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2833 |
codeFor_postBuildWith |
8572 | 2834 |
generateComments ifFalse:[ |
2835 |
^ |
|
2836 |
'postBuildWith:aBuilder |
|
2837 |
^ super postBuildWith:aBuilder |
|
2838 |
'. |
|
2839 |
]. |
|
2840 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2841 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2842 |
'postBuildWith:aBuilder |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2843 |
"This is a hook method generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2844 |
It will be invoked during the initialization of your app/dialog, |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2845 |
after all of the visual components have been built, |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2846 |
but BEFORE the top window is made visible. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2847 |
Add any app-specific actions here (reading files, setting up values etc.) |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2848 |
See also #postOpenWith:, which is invoked after opening." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2849 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2850 |
"/ add any code here ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2851 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2852 |
^ super postBuildWith:aBuilder |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2853 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2854 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2855 |
"Created: / 27-10-2006 / 09:59:33 / cg" |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2856 |
! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2857 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2858 |
codeFor_postOpenWith |
8572 | 2859 |
generateComments ifFalse:[ |
2860 |
^ |
|
2861 |
'postOpenWith:aBuilder |
|
2862 |
^ super postOpenWith:aBuilder |
|
2863 |
'. |
|
2864 |
]. |
|
2865 |
||
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2866 |
^ |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2867 |
'postOpenWith:aBuilder |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2868 |
"This is a hook method generated by the Browser. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2869 |
It will be invoked right after the applications window has been opened. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2870 |
Add any app-specific actions here (starting background processes etc.). |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2871 |
See also #postBuildWith:, which is invoked before opening." |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2872 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2873 |
"/ add any code here ... |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2874 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2875 |
^ super postOpenWith:aBuilder |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2876 |
'. |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2877 |
|
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
2878 |
"Created: / 27-10-2006 / 09:59:56 / cg" |
8572 | 2879 |
! |
2880 |
||
2881 |
code_forWidget_buttonPress |
|
2882 |
generateComments ifFalse:[ |
|
2883 |
^ |
|
2884 |
'buttonPress:button x:x y:y |
|
8574 | 2885 |
Transcript show:''button: ''; showCR:button. |
8572 | 2886 |
super buttonPress:button x:x y:y |
2887 |
' |
|
2888 |
]. |
|
2889 |
||
2890 |
^ |
|
2891 |
'buttonPress:button x:x y:y |
|
2892 |
"called when a mouse-button is pressed. button is the button-nr (1 for left-button). |
|
2893 |
x/y are the mouse position at the time of the click. |
|
2894 |
There are also corresponding buttonRelease and buttonMotion methods which could be |
|
2895 |
redefined...." |
|
2896 |
||
8574 | 2897 |
Transcript show:''button: ''; showCR:button. |
8572 | 2898 |
"/ super-code handles middleButtonMenu, if it was assigned (with middleButtonmenu:) |
2899 |
super buttonPress:button x:x y:y |
|
2900 |
' |
|
2901 |
! |
|
2902 |
||
2903 |
code_forWidget_initialize |
|
2904 |
^ |
|
2905 |
'initialize |
|
2906 |
super initialize "/ to initialize inherited state |
|
2907 |
||
2908 |
"/ add code to initialize private variables, |
|
2909 |
"/ and sub-components as required. |
|
2910 |
' |
|
2911 |
! |
|
2912 |
||
2913 |
code_forWidget_keyPress |
|
2914 |
generateComments ifFalse:[ |
|
2915 |
^ |
|
2916 |
'keyPress:key x:x y:y |
|
2917 |
"/ key == #Copy ifTrue:[ |
|
2918 |
"/ ]. |
|
2919 |
"/ key == #Cut ifTrue:[ |
|
2920 |
"/ ]. |
|
8574 | 2921 |
Transcript show:''key: ''; showCR:key. |
8572 | 2922 |
super keyPress:key x:x y:y |
2923 |
' |
|
2924 |
]. |
|
2925 |
^ |
|
2926 |
'keyPress:key x:x y:y |
|
2927 |
"called when a keyboard-key was pressed. key is either a character (for ordinary keys) |
|
2928 |
or a symbol, such as #Copy, #Cut or #Paste. |
|
2929 |
x/y are the mouse position at the time of the key-press. |
|
2930 |
There is also a corresponding keyRelease method which could be redefined...." |
|
2931 |
||
8574 | 2932 |
Transcript show:''key: ''; showCR:key. |
8572 | 2933 |
super keyPress:key x:x y:y |
2934 |
' |
|
2935 |
! |
|
2936 |
||
2937 |
code_forWidget_redraw |
|
8573 | 2938 |
|sel comment code| |
2939 |
||
2940 |
sel := 'redrawX:x y:y width:w height:h'. |
|
8572 | 2941 |
generateComments ifFalse:[ |
8573 | 2942 |
comment := ''. |
2943 |
] ifTrue:[ |
|
2944 |
comment := ' |
|
8572 | 2945 |
"called to redraw a part of the widgets area. x/y define the origin, w/h the size of |
2946 |
that area. The clipping region has already been set by the caller, so even if the code |
|
2947 |
below draws outside the redraw-area, it will not affect what is on the screen. |
|
2948 |
Therefore, the example below can fill the rectangle in the redraw area, but still draw |
|
2949 |
the cross in the outside regions." |
|
2950 |
||
8573 | 2951 |
'. |
2952 |
]. |
|
2953 |
||
2954 |
code := ' |
|
8572 | 2955 |
self paint:Color red. |
8573 | 2956 |
self fillRectangleX:x y:y width:w height:h. |
8572 | 2957 |
|
2958 |
self paint:Color yellow. |
|
8573 | 2959 |
self displayLineFrom:0@0 to:(width@height). |
2960 |
self displayLineFrom:width@0 to:(0@height). |
|
2961 |
'. |
|
2962 |
||
2963 |
^ sel,comment,code |
|
8572 | 2964 |
! |
2965 |
||
2966 |
code_forWidget_sizeChanged |
|
2967 |
generateComments ifFalse:[ |
|
2968 |
^ |
|
2969 |
'sizeChanged:how |
|
2970 |
self invalidate. |
|
2971 |
super sizeChanged:how. |
|
2972 |
' |
|
2973 |
]. |
|
2974 |
||
2975 |
^ |
|
2976 |
'sizeChanged:how |
|
2977 |
"Invoked whenever the size of the view changes. |
|
2978 |
Here, we force a full redraw, which might not be needed all the time" |
|
2979 |
||
2980 |
self invalidate. |
|
2981 |
super sizeChanged:how. |
|
2982 |
' |
|
2983 |
! |
|
2984 |
||
2985 |
code_forWidget_update |
|
2986 |
generateComments ifFalse:[ |
|
2987 |
^ |
|
2988 |
'update:something with:aParameter from:changedObject |
|
2989 |
changedObject == model ifTrue:[ |
|
2990 |
self invalidate. |
|
2991 |
^ self |
|
2992 |
]. |
|
2993 |
super update:something with:aParameter from:changedObject |
|
2994 |
' |
|
2995 |
]. |
|
2996 |
||
2997 |
^ |
|
2998 |
'update:something with:aParameter from:changedObject |
|
2999 |
"Invoked when an object that I depend upon sends a change notification." |
|
3000 |
||
3001 |
"stub code automatically generated - please change as required" |
|
3002 |
||
3003 |
changedObject == model ifTrue:[ |
|
3004 |
self invalidate. |
|
3005 |
^ self |
|
3006 |
]. |
|
3007 |
super update:something with:aParameter from:changedObject |
|
3008 |
' |
|
7480
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
3009 |
! ! |
33930379ab27
code cleanup; more application code generation
Claus Gittinger <cg@exept.de>
parents:
7470
diff
changeset
|
3010 |
|
6938 | 3011 |
!CodeGeneratorTool methodsFor:'compilation'! |
3012 |
||
3013 |
compile:theCode forClass:aClass inCategory:cat |
|
3014 |
"install some code for a class. |
|
3015 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
3016 |
||
7037 | 3017 |
self |
3018 |
compile:theCode forClass:aClass inCategory:cat |
|
3019 |
skipIfSame:true |
|
3020 |
! |
|
6938 | 3021 |
|
7037 | 3022 |
compile:theCode forClass:aClass inCategory:cat skipIfSame:skipIfSame |
3023 |
"install some code for a class. |
|
3024 |
If refactory browser stuff is avaliable the refactory tools are used to support undo" |
|
3025 |
||
3026 |
|change compiler selector oldMthd isSame| |
|
6938 | 3027 |
|
7037 | 3028 |
isSame := false. |
3029 |
skipIfSame ifTrue:[ |
|
3030 |
compiler := aClass compilerClass new. |
|
3031 |
compiler parseMethod:theCode in:aClass ignoreErrors:true ignoreWarnings:true. |
|
3032 |
||
3033 |
selector := compiler selector. |
|
3034 |
selector notNil ifTrue:[ |
|
3035 |
oldMthd := aClass compiledMethodAt:selector. |
|
3036 |
isSame := (oldMthd notNil and:[oldMthd source = theCode]). |
|
3037 |
isSame ifTrue:[ ^ self ]. |
|
6938 | 3038 |
]. |
3039 |
]. |
|
3040 |
||
3041 |
self canUseRefactoringSupport ifFalse:[ |
|
3042 |
"/ compile immediately |
|
3043 |
aClass compile:theCode classified:cat. |
|
3044 |
^ self. |
|
3045 |
]. |
|
3046 |
||
3047 |
change := InteractiveAddMethodChange compile:(theCode asString) in:aClass classified:cat. |
|
3048 |
||
3049 |
"/ if collecting, add to changes (to be executed as one change at the end, |
|
3050 |
"/ in order to have only one change in the undo-list (instead of many) |
|
3051 |
compositeChangeCollector notNil ifTrue:[ |
|
3052 |
compositeChangeCollector addChange:change |
|
3053 |
] ifFalse:[ |
|
7037 | 3054 |
RefactoryChangeManager performChange:change. |
6938 | 3055 |
] |
3056 |
||
3057 |
"Modified: / 21-08-2006 / 18:39:06 / cg" |
|
3058 |
! ! |
|
3712 | 3059 |
|
8572 | 3060 |
!CodeGeneratorTool methodsFor:'initialization'! |
3061 |
||
3062 |
initialize |
|
3063 |
userPreferences := UserPreferences current. |
|
3064 |
generateComments := userPreferences generateComments. |
|
3065 |
! ! |
|
3066 |
||
5758 | 3067 |
!CodeGeneratorTool methodsFor:'private'! |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3068 |
|
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
3069 |
canUseRefactoringSupport |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
3070 |
"check if refactory browser stuff is avaliable" |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
3071 |
|
5758 | 3072 |
^ self class canUseRefactoringSupport |
5013
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
3073 |
! |
0f2c39fc6e8c
comments; allow for comments to be suppressed
Claus Gittinger <cg@exept.de>
parents:
4926
diff
changeset
|
3074 |
|
9027
f2edc1bca4de
added: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9025
diff
changeset
|
3075 |
codeFor_shouldImplementFor:selector inClass:aClass |
9044
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3076 |
"used in the 'generate required protocol' to generate a shouldImplement-sending |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3077 |
method for each subclassClassresponsibility method above aClass." |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3078 |
|
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3079 |
|mthd comment implClass methodBodyStream searcher errorMessageString| |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3080 |
|
9028
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3081 |
(aClass notNil |
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3082 |
and:[ aClass superclass notNil ]) ifTrue:[ |
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3083 |
implClass := aClass superclass whichClassImplements:selector. |
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3084 |
]. |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3085 |
implClass isNil ifTrue:[ |
9028
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3086 |
^ ((Method methodDefinitionTemplateForSelector:selector),'\ ^ self shouldImplement\') withCRs |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3087 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3088 |
|
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3089 |
mthd := implClass compiledMethodAt:selector. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3090 |
|
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3091 |
methodBodyStream := '' writeStream. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3092 |
methodBodyStream |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3093 |
nextPutAll:mthd methodDefinitionTemplate; cr; |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3094 |
nextPutAll:' "'. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3095 |
|
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3096 |
"/ include the comment of the subclassResponsibility-sending method |
9044
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3097 |
|
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3098 |
comment := mthd methodComment. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3099 |
comment isEmptyOrNil ifTrue:[ |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3100 |
methodBodyStream |
9028
56eb45cb11f3
changed: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9027
diff
changeset
|
3101 |
nextPutAll:('superclass <1s> says that I am responsible to implement this method' |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3102 |
expandMacrosWith:implClass name) |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3103 |
] ifFalse:[ |
9044
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3104 |
comment |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3105 |
asStringCollection do:[:eachLine| |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3106 |
methodBodyStream nextPutAll:eachLine. |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3107 |
] separatedBy:[ |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3108 |
methodBodyStream cr; nextPutAll:' '. |
5da7b7815f56
comment/format in: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9028
diff
changeset
|
3109 |
]. |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3110 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3111 |
methodBodyStream |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3112 |
nextPut:$"; cr; cr. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3113 |
|
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3114 |
"/ include the argument of the subclassResponsibility:-sending method |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3115 |
self canUseRefactoringSupport ifTrue:[ |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3116 |
(mthd sends:#subclassResponsibility:) ifTrue:[ |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3117 |
searcher := ParseTreeSearcher new. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3118 |
searcher |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3119 |
matches: 'self subclassResponsibility: `''.*''' |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3120 |
do:[:node :answer | |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3121 |
errorMessageString := node arguments first value. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3122 |
true. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3123 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3124 |
searcher executeTree: (mthd parseTree) initialAnswer: false. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3125 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3126 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3127 |
errorMessageString notEmptyOrNil ifTrue:[ |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3128 |
methodBodyStream |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3129 |
nextPutAll:' ^ self shouldImplement:'; |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3130 |
nextPutLine:(errorMessageString storeString) |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3131 |
] ifFalse:[ |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3132 |
methodBodyStream |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3133 |
nextPutLine:' ^ self shouldImplement'. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3134 |
]. |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3135 |
|
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3136 |
^ methodBodyStream contents |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3137 |
! |
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3138 |
|
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3139 |
privCreateClassResponsibleProtocolFor:aClass |
6791
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
3140 |
"create stubs for the required protocol. |
6559c9ebb561
Keep method argument names when generating required methods
Stefan Vogel <sv@exept.de>
parents:
6718
diff
changeset
|
3141 |
aClass may be a a MetaClass or a non-MetaClass" |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3142 |
|
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3143 |
|requiredProtocol| |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3144 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3145 |
requiredProtocol := self class missingRequiredProtocolFor:aClass. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3146 |
requiredProtocol do:[:eachSelector | |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3147 |
|code implClass| |
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3148 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3149 |
implClass := aClass whichClassImplements:eachSelector. |
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3150 |
implClass == Object ifFalse:[ |
9027
f2edc1bca4de
added: #codeFor_shouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9025
diff
changeset
|
3151 |
code := self codeFor_shouldImplementFor:eachSelector inClass:aClass. |
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3152 |
|
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3153 |
self |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3154 |
compile:code |
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3155 |
forClass:aClass |
9025
124489bab860
added: #codeForShouldImplementFor:inClass:
Claus Gittinger <cg@exept.de>
parents:
9022
diff
changeset
|
3156 |
inCategory:(implClass compiledMethodAt:eachSelector) category. |
9022
676088a17690
added: #missingRequiredProtocolFor:
Claus Gittinger <cg@exept.de>
parents:
8987
diff
changeset
|
3157 |
] |
4108
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3158 |
]. |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3159 |
! ! |
19af32811dfd
Generate minimal protocol classes for metaclass.
Stefan Vogel <sv@exept.de>
parents:
3823
diff
changeset
|
3160 |
|
3712 | 3161 |
!CodeGeneratorTool class methodsFor:'documentation'! |
3162 |
||
3163 |
version |
|
9264
171e3ab3697d
changed: #codeFor_openDocumentation
Claus Gittinger <cg@exept.de>
parents:
9261
diff
changeset
|
3164 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.82 2009-11-17 11:23:39 cg Exp $' |
8890 | 3165 |
! |
3166 |
||
3167 |
version_CVS |
|
9264
171e3ab3697d
changed: #codeFor_openDocumentation
Claus Gittinger <cg@exept.de>
parents:
9261
diff
changeset
|
3168 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTool.st,v 1.82 2009-11-17 11:23:39 cg Exp $' |
3712 | 3169 |
! ! |