author | Claus Gittinger <cg@exept.de> |
Tue, 11 May 2004 14:49:21 +0200 | |
changeset 1838 | 170a0f24260b |
parent 1834 | 2c640b5f7fa9 |
child 1869 | d7a4c2b7fddb |
permissions | -rw-r--r-- |
60 | 1 |
" |
156 | 2 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 3 |
All Rights Reserved |
60 | 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 |
|
742 | 7 |
inclusion of the above copyright notice. This software may not |
60 | 8 |
be provided or otherwise made available to, or used by, any |
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
1387 | 13 |
"{ Package: 'stx:libtool2' }" |
14 |
||
60 | 15 |
UIObjectView subclass:#UIPainterView |
278 | 16 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
1467
b46624bb6994
use white handles, if the views background color is dark.
Claus Gittinger <cg@exept.de>
parents:
1450
diff
changeset
|
17 |
categoryName handleColorBlack handleColorWhite handleMasterColor' |
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
18 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances' |
60 | 19 |
poolDictionaries:'' |
20 |
category:'Interface-UIPainter' |
|
21 |
! |
|
22 |
||
211 | 23 |
Object subclass:#ViewProperty |
24 |
instanceVariableNames:'view spec identifier' |
|
25 |
classVariableNames:'Identifier' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:UIPainterView |
|
28 |
! |
|
29 |
||
60 | 30 |
!UIPainterView class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
156 | 34 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 35 |
All Rights Reserved |
60 | 36 |
|
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
742 | 39 |
inclusion of the above copyright notice. This software may not |
60 | 40 |
be provided or otherwise made available to, or used by, any |
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
128 | 48 |
buildIn view used by the UIPainter; from this view, the layout of the |
49 |
new application derives from. |
|
50 |
||
51 |
[see also:] |
|
1834 | 52 |
UIBuilder |
53 |
UIObjectView |
|
156 | 54 |
|
55 |
[author:] |
|
1834 | 56 |
Claus Gittinger |
57 |
Claus Atzkern |
|
60 | 58 |
" |
59 |
! ! |
|
60 |
||
1225 | 61 |
!UIPainterView class methodsFor:'initialization'! |
62 |
||
63 |
initialize |
|
64 |
||
1494 | 65 |
AspectsAsInstances := true. "/ false. |
1225 | 66 |
RedefineAspectMethods := false. |
67 |
||
68 |
"Created: / 22.9.1999 / 12:32:31 / stefan" |
|
69 |
! ! |
|
70 |
||
698 | 71 |
!UIPainterView class methodsFor:'code generation mode'! |
72 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
73 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
74 |
"if on, aspects are held as instance variables; |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
75 |
if off (the default), they are kept in the bindings dictionary. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
76 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
77 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
78 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
79 |
"Created: / 29.7.1998 / 11:21:38 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
80 |
"Modified: / 29.7.1998 / 11:22:01 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
81 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
82 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
83 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
84 |
"if on, aspects are held as instance variables; |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
85 |
if off (the default), they are kept in the bindings dictionary. |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
86 |
" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
87 |
AspectsAsInstances := aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
88 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
89 |
"Created: / 29.7.1998 / 11:21:26 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
90 |
"Modified: / 29.7.1998 / 11:22:11 / cg" |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
91 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
92 |
|
742 | 93 |
redefineAspectMethods |
698 | 94 |
"redefine methods yes or no. If a method is defined in super class |
95 |
should the message be reinstalled ? |
|
96 |
" |
|
1225 | 97 |
^ RedefineAspectMethods |
698 | 98 |
|
1225 | 99 |
"Modified: / 22.9.1999 / 12:33:03 / stefan" |
698 | 100 |
! |
101 |
||
742 | 102 |
redefineAspectMethods:aBoolean |
698 | 103 |
"redefine methods yes or no. If a method is defined in super class |
104 |
should the message be reinstalled ? |
|
105 |
" |
|
742 | 106 |
RedefineAspectMethods := aBoolean |
698 | 107 |
|
108 |
||
109 |
! ! |
|
110 |
||
60 | 111 |
!UIPainterView class methodsFor:'defaults'! |
112 |
||
1834 | 113 |
defaultMenuMessage |
60 | 114 |
"This message is the default yo be sent to the menuHolder to get a menu |
115 |
" |
|
121 | 116 |
^ #showMiddleButtonMenu |
60 | 117 |
|
118 |
||
119 |
! ! |
|
120 |
||
121 |
!UIPainterView methodsFor:'accessing'! |
|
122 |
||
123 |
application |
|
124 |
^ nil |
|
125 |
||
126 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
127 |
! |
|
128 |
||
78 | 129 |
applicationName |
130 |
^ self className |
|
131 |
! |
|
132 |
||
133 |
applicationName:aName |
|
134 |
self className:aName |
|
135 |
! |
|
136 |
||
60 | 137 |
className |
138 |
^ className |
|
139 |
! |
|
140 |
||
78 | 141 |
className:aName |
142 |
className := aName |
|
60 | 143 |
! |
144 |
||
145 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
78 | 146 |
className := aClassName. |
60 | 147 |
superclassName := aSuperclassName. |
78 | 148 |
methodName := aSelector. |
60 | 149 |
|
150 |
! |
|
151 |
||
152 |
methodName |
|
153 |
^ methodName |
|
154 |
! |
|
155 |
||
78 | 156 |
methodName:aName |
157 |
methodName := aName |
|
60 | 158 |
! |
159 |
||
160 |
selectNames:aStringOrCollection |
|
1031 | 161 |
|prop coll s n newSel| |
162 |
||
163 |
(aStringOrCollection size == 0) ifTrue:[ |
|
1834 | 164 |
newSel := nil. |
1031 | 165 |
] ifFalse:[ |
1834 | 166 |
(s := aStringOrCollection) isString ifFalse:[ |
167 |
s size == 1 ifTrue:[ |
|
168 |
s := s first |
|
169 |
] ifFalse:[ |
|
170 |
coll := OrderedCollection new. |
|
171 |
||
172 |
s do:[:aName| |
|
173 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
174 |
coll add:(prop view) |
|
175 |
] |
|
176 |
]. |
|
177 |
(n := coll size) == 1 ifTrue:[ |
|
178 |
newSel := coll at:1 |
|
179 |
] ifFalse:[ |
|
180 |
n == 0 ifTrue:[ |
|
181 |
newSel := nil |
|
182 |
] ifFalse:[ |
|
183 |
newSel := coll |
|
184 |
] |
|
185 |
]. |
|
186 |
^ self select:newSel. |
|
187 |
] |
|
188 |
]. |
|
189 |
||
190 |
prop := self propertyOfName:s. |
|
191 |
prop isNil ifTrue:[ |
|
192 |
newSel := nil |
|
193 |
] ifFalse:[ |
|
194 |
newSel := prop view |
|
195 |
]. |
|
60 | 196 |
]. |
197 |
||
1031 | 198 |
^ self select:newSel |
60 | 199 |
! ! |
200 |
||
111 | 201 |
!UIPainterView methodsFor:'change & update'! |
202 |
||
223 | 203 |
layoutChanged |
1445 | 204 |
treeView notNil ifTrue:[ |
1834 | 205 |
treeView layoutChanged |
1445 | 206 |
] |
111 | 207 |
! ! |
208 |
||
60 | 209 |
!UIPainterView methodsFor:'copy & cut & paste'! |
210 |
||
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
211 |
commonContainerOf:someComponents |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
212 |
|container| |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
213 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
214 |
container := someComponents first container. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
215 |
[container notNil |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
216 |
and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]] |
1834 | 217 |
whileTrue:[ |
218 |
container := container container. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
219 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
220 |
^ container |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
221 |
! |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
222 |
|
60 | 223 |
copySelection |
224 |
"copy the selection into the cut&paste-buffer |
|
225 |
" |
|
698 | 226 |
|specs coll sel| |
227 |
||
228 |
sel := treeView selection. |
|
71 | 229 |
|
128 | 230 |
coll := self minSetOfSuperViews:(self selection). |
60 | 231 |
|
71 | 232 |
coll notNil ifTrue:[ |
776 | 233 |
"/ self select:nil. |
1834 | 234 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
235 |
self setSelection:specs. |
|
776 | 236 |
"/ treeView selection: sel |
60 | 237 |
]. |
78 | 238 |
|
239 |
||
60 | 240 |
! |
241 |
||
723 | 242 |
deleteSelection |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
243 |
"delete the selection buffered |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
244 |
" |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
245 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
246 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
247 |
|
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
248 |
deleteSelectionBuffered: buffered |
698 | 249 |
"cut the selection into the cut&paste-buffer |
62 | 250 |
and open a transaction |
60 | 251 |
" |
1574 | 252 |
|specs coll index oldSelection newSelection treeModel children size nd| |
71 | 253 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
254 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
255 |
|
128 | 256 |
coll := self minSetOfSuperViews:(self selection). |
60 | 257 |
|
78 | 258 |
coll notNil ifTrue:[ |
1834 | 259 |
treeView cvsEventsDisabledDo:[ |
260 |
treeModel := treeView model. |
|
261 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
262 |
||
263 |
oldSelection notNil ifTrue:[ |
|
264 |
children := oldSelection parent children. |
|
265 |
(size := children size) > 1 ifTrue:[ |
|
266 |
index := children identityIndexOf:oldSelection. |
|
267 |
size == index ifTrue:[ |
|
268 |
index := index - 1 |
|
269 |
]. |
|
270 |
newSelection := children at:index ifAbsent:1. |
|
271 |
] ifFalse:[ |
|
272 |
newSelection := oldSelection parent |
|
273 |
]. |
|
274 |
newSelection := treeModel indexOf:newSelection. |
|
275 |
] ifFalse:[ |
|
276 |
newSelection := 1 |
|
277 |
]. |
|
278 |
||
279 |
self hideSelection. |
|
280 |
selection := nil. |
|
281 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
282 |
||
283 |
self withinTransaction:#cut objects:coll do:[ |
|
284 |
coll reverseDo:[:aView| |
|
285 |
self createUndoRemove:aView. |
|
286 |
self remove:aView. |
|
287 |
] |
|
288 |
]. |
|
289 |
buffered ifTrue: [self setSelection:specs]. |
|
290 |
treeView selection:nil. |
|
291 |
treeView selection:(Array with: newSelection). |
|
292 |
(nd := treeView selectedNode) notNil ifTrue:[ |
|
293 |
self setSelection:nd contents view withRedraw:true. |
|
294 |
] |
|
295 |
] |
|
698 | 296 |
] |
297 |
! |
|
298 |
||
723 | 299 |
deleteTotalSelection |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
300 |
"delete the selection |
1834 | 301 |
" |
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
302 |
self deleteSelectionBuffered: false |
60 | 303 |
! |
304 |
||
1832 | 305 |
getSelectedViewsAndSpecs |
306 |
"return an array filed with selected views and corresponding specs. |
|
307 |
Nil if there is none. |
|
308 |
" |
|
309 |
|specs coll sel| |
|
310 |
||
311 |
sel := treeView selection. |
|
312 |
||
313 |
coll := self minSetOfSuperViews:(self selection). |
|
314 |
||
315 |
coll isNil ifTrue:[^ nil]. |
|
316 |
||
317 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
318 |
^ Array with: coll with: specs |
|
319 |
! |
|
320 |
||
60 | 321 |
pasteBuffer |
62 | 322 |
"add the objects in the paste-buffer to the object view |
60 | 323 |
" |
223 | 324 |
|sel| |
325 |
||
326 |
sel := self pasteSpecifications:(self getSelection) keepLayout:false. |
|
327 |
||
328 |
sel notNil ifTrue:[ |
|
1834 | 329 |
self select:sel. |
223 | 330 |
]. |
89 | 331 |
|
332 |
! |
|
333 |
||
392 | 334 |
pasteFromClipBoard:aString |
335 |
^ self |
|
336 |
||
337 |
||
338 |
! |
|
339 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
340 |
pasteKeepingPosition |
1834 | 341 |
"add the objects in the paste-buffer to the object view; |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
342 |
translate the layout as appropriate, to position the component |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
343 |
at the same absolute position (relative to topView) as before |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
344 |
" |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
345 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
346 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
347 |
sel := self |
1834 | 348 |
pasteSpecifications:(self getSelection) |
349 |
keepLayout:true |
|
350 |
keepPosition:true |
|
351 |
at:nil. |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
352 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
353 |
sel notNil ifTrue:[ |
1834 | 354 |
self select:sel. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
355 |
]. |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
356 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
357 |
|
89 | 358 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
223 | 359 |
"add the specs to the object view; returns list of pasted components |
89 | 360 |
" |
278 | 361 |
|
362 |
^ self |
|
1834 | 363 |
pasteSpecifications:aSpecificationOrList |
364 |
keepLayout:keepLayout |
|
365 |
at:nil |
|
278 | 366 |
|
367 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
368 |
! |
|
369 |
||
370 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
371 |
"add the specs to the object view; returns list of pasted components |
|
372 |
" |
|
1834 | 373 |
^ self |
374 |
pasteSpecifications:aSpecificationOrList |
|
375 |
keepLayout:keepLayout |
|
376 |
keepPosition:false |
|
377 |
at:aPointOrNil |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
378 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
379 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
380 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
381 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
382 |
"add the specs to the object view; returns list of pasted components |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
383 |
" |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
384 |
|paste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
385 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
386 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
387 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
388 |
containerToPasteInto := self singleSelection. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
389 |
containerToPasteInto isNil ifTrue:[ |
1834 | 390 |
self selection size > 0 ifTrue:[ |
391 |
containerToPasteInto := self commonContainerOf:self selection |
|
392 |
] ifFalse:[ |
|
393 |
containerToPasteInto := self |
|
394 |
]. |
|
395 |
self selection:containerToPasteInto. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
396 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
397 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
398 |
(self canPasteInto:containerToPasteInto) ifFalse:[ |
1834 | 399 |
containerToPasteInto notNil ifTrue:[ |
400 |
"/ search up parent list for something we can paste into |
|
401 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
|
402 |
containerToPasteInto := containerToPasteInto container. |
|
403 |
]. |
|
404 |
self selection:containerToPasteInto. |
|
405 |
]. |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
406 |
]. |
1752 | 407 |
containerToPasteInto isNil ifTrue:[ |
1834 | 408 |
containerToPasteInto := self |
1752 | 409 |
]. |
60 | 410 |
|
89 | 411 |
(self canPaste:aSpecificationOrList) ifFalse:[ |
1834 | 412 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
413 |
^ nil |
|
89 | 414 |
]. |
223 | 415 |
|
776 | 416 |
aSpecificationOrList isCollection ifTrue:[ |
1834 | 417 |
paste := aSpecificationOrList |
776 | 418 |
] ifFalse:[ |
1834 | 419 |
paste := Array with:aSpecificationOrList |
776 | 420 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
421 |
self setSelection:nil. |
776 | 422 |
|
423 |
newSel := OrderedCollection new. |
|
424 |
builder := UIBuilder new isEditing:true. |
|
425 |
||
426 |
className notNil ifTrue:[ |
|
1834 | 427 |
builder applicationClass:(self resolveName:className) |
776 | 428 |
]. |
429 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
430 |
(keepLayout not or:[keepPosition]) ifTrue:[ |
1834 | 431 |
pasteOffset := 0@0. |
432 |
||
433 |
keepPosition ifTrue:[ |
|
434 |
pasteOrigin := device translatePoint:0@0 |
|
435 |
fromView:self |
|
436 |
toView:containerToPasteInto. |
|
437 |
] ifFalse:[ |
|
438 |
aPointOrNil isNil ifTrue:[ |
|
439 |
pasteOrigin := self sensor mousePoint. |
|
440 |
pasteOrigin := device translatePoint:pasteOrigin |
|
441 |
fromView:nil |
|
442 |
toView:containerToPasteInto. |
|
443 |
] ifFalse:[ |
|
444 |
pasteOrigin := device translatePoint:aPointOrNil |
|
445 |
fromView:self |
|
446 |
toView:containerToPasteInto. |
|
447 |
] |
|
448 |
]. |
|
449 |
||
450 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent) |
|
776 | 451 |
]. |
60 | 452 |
|
776 | 453 |
paste do:[:aSpec| |
1834 | 454 |
|view newOrigin| |
455 |
||
456 |
view := self addSpec:aSpec builder:builder in:containerToPasteInto. |
|
457 |
||
458 |
keepPosition ifTrue:[ |
|
459 |
self moveObject:view to:(view origin + pasteOrigin). |
|
460 |
] ifFalse:[ |
|
461 |
keepLayout ifFalse:[ |
|
462 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
|
463 |
newOrigin := pasteOffset. |
|
464 |
] ifTrue:[ |
|
465 |
newOrigin := pasteOrigin + pasteOffset. |
|
466 |
]. |
|
467 |
self moveObject:view to:newOrigin. |
|
468 |
pasteOffset := pasteOffset + 4 |
|
469 |
]. |
|
470 |
]. |
|
471 |
view realize. |
|
472 |
newSel add:view. |
|
776 | 473 |
]. |
60 | 474 |
|
776 | 475 |
self withinTransaction:#paste objects:newSel do:[ |
1834 | 476 |
undoHistory addUndoSelector:#undoCreate: |
477 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]) |
|
776 | 478 |
]. |
60 | 479 |
|
776 | 480 |
self realizeAllSubViews. |
481 |
newSel do:[:v| v raise]. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
482 |
self elementChangedSize:containerToPasteInto. |
134 | 483 |
|
776 | 484 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 485 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
486 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
487 |
"Modified: / 10.10.2001 / 14:15:12 / cg" |
89 | 488 |
! |
489 |
||
490 |
pasteWithLayout |
|
491 |
"add the objects in the paste-buffer to the object view; don't change the |
|
492 |
layout |
|
493 |
" |
|
223 | 494 |
|sel| |
495 |
||
496 |
sel := self pasteSpecifications:(self getSelection) keepLayout:true. |
|
89 | 497 |
|
223 | 498 |
sel notNil ifTrue:[ |
1834 | 499 |
self select:sel. |
223 | 500 |
]. |
60 | 501 |
! ! |
502 |
||
503 |
!UIPainterView methodsFor:'drag & drop'! |
|
504 |
||
288 | 505 |
canDrop:something |
506 |
"returns true if something can be droped |
|
1834 | 507 |
" |
288 | 508 |
(something size == 1 and:[self enabled and:[self numberOfSelections <= 1]]) ifTrue:[ |
509 |
^ something first theObject isKindOf:UISpecification |
|
223 | 510 |
]. |
511 |
^ false |
|
512 |
! |
|
513 |
||
285 | 514 |
canPaste |
515 |
"returns true if something to be past exists and can be paste into |
|
516 |
the selection if exists |
|
517 |
" |
|
518 |
^ self canPaste:(self getSelection) |
|
519 |
! |
|
520 |
||
223 | 521 |
canPaste:something |
522 |
"returns true if something could be paste |
|
523 |
" |
|
524 |
|el size| |
|
525 |
||
526 |
((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[ |
|
1834 | 527 |
^ false |
223 | 528 |
]. |
529 |
something isCollection ifTrue:[something notEmpty ifTrue:[el := something first]] |
|
1834 | 530 |
ifFalse:[el := something]. |
223 | 531 |
|
532 |
(el isKindOf:UISpecification) ifFalse:[ |
|
1834 | 533 |
^ false |
223 | 534 |
]. |
535 |
||
536 |
size == 1 ifTrue:[ |
|
1834 | 537 |
^ self canPasteInto:(self singleSelection) |
223 | 538 |
]. |
539 |
^ true |
|
540 |
! |
|
541 |
||
542 |
canPasteInto:aView |
|
543 |
"can paste into a view |
|
544 |
" |
|
285 | 545 |
|prop| |
60 | 546 |
|
223 | 547 |
aView notNil ifTrue:[ |
1834 | 548 |
(prop := self propertyRespondsToView:aView) notNil ifTrue:[ |
549 |
^ prop spec class supportsSubComponents |
|
550 |
]. |
|
285 | 551 |
^ aView specClass supportsSubComponents. |
89 | 552 |
]. |
553 |
^ false |
|
96
73725336b4fe
dont paste into scrollable selectionInListViews ...
Claus Gittinger <cg@exept.de>
parents:
89
diff
changeset
|
554 |
|
60 | 555 |
! |
556 |
||
557 |
drop:anObjectOrCollection at:aPoint |
|
1833 | 558 |
|spec newSel oldSel dragOffset widg doit| |
559 |
||
560 |
doit := true. |
|
288 | 561 |
self selection notNil ifTrue:[ |
1834 | 562 |
oldSel := self singleSelection. |
563 |
||
564 |
"/ search selections hierarchy for a widget into which we can paste |
|
565 |
widg := oldSel. |
|
566 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
567 |
widg notNil ifTrue:[ |
|
568 |
widg := widg container |
|
569 |
]. |
|
570 |
]. |
|
571 |
||
572 |
oldSel := nil. |
|
573 |
self setSelection:widg withRedraw:true. |
|
231 | 574 |
]. |
89 | 575 |
spec := (anObjectOrCollection at:1) theObject. |
1833 | 576 |
doit ifTrue:[ |
1834 | 577 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
578 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
579 |
||
580 |
self select:(oldSel ? newSel) |
|
1833 | 581 |
]. |
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
582 |
|
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
583 |
"Modified: / 18.3.1999 / 18:29:43 / stefan" |
1520
eb77c52704c7
drop: paste in surrounding view if not possible to drop in selected.
Claus Gittinger <cg@exept.de>
parents:
1500
diff
changeset
|
584 |
"Modified: / 30.10.2001 / 14:02:35 / cg" |
60 | 585 |
! ! |
586 |
||
361 | 587 |
!UIPainterView methodsFor:'event handling'! |
588 |
||
589 |
keyPress:key x:x y:y view:aView |
|
376 | 590 |
"a delegated keyEvent from aView" |
591 |
||
361 | 592 |
self keyPress:key x:x y:y |
593 |
||
376 | 594 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 595 |
! |
596 |
||
597 |
keyRelease:key x:x y:y view:aView |
|
376 | 598 |
"a delegated keyEvent from aView" |
599 |
||
361 | 600 |
self keyRelease:key x:x y:y |
601 |
||
376 | 602 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 603 |
! |
604 |
||
605 |
sizeChanged:how |
|
606 |
||
1834 | 607 |
super sizeChanged:how. |
754 | 608 |
|
609 |
self layoutChanged |
|
361 | 610 |
! ! |
611 |
||
78 | 612 |
!UIPainterView methodsFor:'generating output'! |
613 |
||
352 | 614 |
aspectMethods |
615 |
"extract a list of aspect methods - for browsing" |
|
616 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
617 |
|cls methods| |
352 | 618 |
|
619 |
className isNil ifTrue:[ |
|
1834 | 620 |
self warn:'No class defined !!'. |
621 |
^ #() |
|
352 | 622 |
]. |
623 |
||
624 |
cls := self resolveName:className. |
|
625 |
methods := IdentitySet new. |
|
626 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
627 |
self aspectSelectorsAndTypesDo: |
1834 | 628 |
[:selector :typeSymbol | |
629 |
|skip| |
|
630 |
||
631 |
(cls includesSelector:selector) ifTrue:[ |
|
632 |
||
633 |
skip := false. |
|
634 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
635 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
636 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
637 |
]. |
|
638 |
]. |
|
639 |
skip ifFalse:[ |
|
640 |
methods add:(cls compiledMethodAt:selector) |
|
641 |
]. |
|
642 |
] |
|
643 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
644 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
645 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
646 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
647 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
648 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
649 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
650 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
651 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
652 |
"evaluate aBlock for every aspect methods selector; 2nd arg describes the aspects type" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
653 |
|
1726 | 654 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
655 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
656 |
className isNil ifTrue:[ |
1834 | 657 |
self warn:'No class defined !!'. |
658 |
^ self |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
659 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
660 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
661 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
662 |
|
352 | 663 |
treeView propertiesDo:[:aProp| |
1834 | 664 |
|selector| |
665 |
||
666 |
(selector := aProp model) notNil ifTrue:[ |
|
667 |
selector isArray ifFalse:[ |
|
668 |
aTwoArgBlock value:(selector asSymbol) value:#modelAspect |
|
669 |
]. |
|
670 |
]. |
|
671 |
||
672 |
(selector := aProp menu) notNil ifTrue:[ |
|
673 |
selector isArray ifFalse:[ |
|
674 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
|
675 |
]. |
|
676 |
]. |
|
677 |
||
678 |
(aProp spec aspectSelectors) do:[:aSel | |
|
679 |
aSel isArray ifFalse:[ |
|
680 |
aTwoArgBlock value:(aSel asSymbol) value:#channelAspect |
|
681 |
]. |
|
682 |
]. |
|
683 |
aProp spec actionSelectors do:[:aSel| |
|
684 |
aSel isArray ifFalse:[ |
|
685 |
aTwoArgBlock value:(aSel asSymbol) value:#actionSelector |
|
686 |
]. |
|
687 |
]. |
|
688 |
aProp spec valueSelectors do:[:aSel| |
|
689 |
aSel isArray ifFalse:[ |
|
690 |
aTwoArgBlock value:(aSel asSymbol) value:#valueSelector |
|
691 |
]. |
|
692 |
] |
|
352 | 693 |
]. |
694 |
||
695 |
protoSpec := treeView canvasSpec. |
|
696 |
||
697 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
1834 | 698 |
selector isArray ifFalse:[ |
699 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
|
700 |
]. |
|
352 | 701 |
]. |
702 |
! |
|
703 |
||
60 | 704 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
568 | 705 |
|selector args showIt code alreadyInSuperclass numArgs method| |
288 | 706 |
|
707 |
selector := aspect asSymbol. |
|
141 | 708 |
|
288 | 709 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
710 |
||
568 | 711 |
numArgs := selector numArgs. |
712 |
method := aspect. |
|
713 |
||
714 |
numArgs == 1 ifTrue:[ |
|
1834 | 715 |
args := 'anArgument'. |
716 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
717 |
] ifFalse:[ |
|
718 |
args := ''. |
|
719 |
showIt := ' ...''.\'. |
|
720 |
||
721 |
numArgs ~~ 0 ifTrue:[ |
|
722 |
method := ''. |
|
723 |
||
724 |
selector keywords keysAndValuesDo:[:i :key| |
|
725 |
method := method, key, 'arg', i printString, ' ' |
|
726 |
] |
|
727 |
] |
|
149 | 728 |
]. |
141 | 729 |
|
288 | 730 |
code := '!!' , targetClass name , ' methodsFor:''actions''!!\\' , |
1834 | 731 |
method , args , '\' , |
732 |
' "automatically generated by UIPainter ..."\\' , |
|
733 |
' "*** the code below performs no action"\' , |
|
734 |
' "*** (except for some feedback on the Transcript)"\' , |
|
735 |
' "*** Please change as required and accept in the browser."\' , |
|
736 |
'\' . |
|
288 | 737 |
|
738 |
alreadyInSuperclass ifTrue:[ |
|
1834 | 739 |
code := code , |
740 |
' "action for ' , aspect , ' is already provided in a superclass."\' , |
|
741 |
' "It may be redefined here ..."\\'. |
|
288 | 742 |
] ifFalse:[ |
1834 | 743 |
code := code , |
744 |
' "action to be added ..."\\'. |
|
288 | 745 |
]. |
746 |
||
747 |
code := code , |
|
1834 | 748 |
' Transcript showCR:self class name, '': '. |
288 | 749 |
alreadyInSuperclass ifTrue:[ |
1834 | 750 |
code := code , 'inherited '. |
288 | 751 |
]. |
752 |
code := code , 'action for ' , aspect , showIt. |
|
753 |
||
754 |
alreadyInSuperclass ifTrue:[ |
|
1834 | 755 |
code := code , |
756 |
' super ' , aspect , args , '.\'. |
|
288 | 757 |
]. |
758 |
||
759 |
code := code , |
|
1834 | 760 |
'!! !!\\'. |
288 | 761 |
^ code withCRs |
762 |
||
352 | 763 |
"Modified: / 25.10.1997 / 19:18:50 / cg" |
60 | 764 |
! |
765 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
766 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
767 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
768 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
769 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
770 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
771 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
772 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
773 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
774 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
775 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
776 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
777 |
Return a string ready to compile into the application class." |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
778 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
779 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
780 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
781 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
782 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
783 |
cls isNil ifTrue:[ |
1834 | 784 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
785 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
786 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
787 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
788 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
789 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
790 |
treeView propertiesDo:[:aProp| |
1834 | 791 |
|modelSelector| |
792 |
||
793 |
protoSpec := aProp spec. |
|
794 |
||
795 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
796 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
797 |
do:[:aSel| |
|
798 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
799 |
skip := false. |
|
800 |
||
801 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
802 |
skip := SimpleDialog includesSelector:aSel |
|
803 |
]. |
|
804 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
805 |
skip := true. |
|
806 |
]. |
|
807 |
||
808 |
skip ifFalse:[ |
|
809 |
"/ kludge .. |
|
810 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
811 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
812 |
ifTrue:[ |
|
813 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
814 |
] ifFalse:[ |
|
815 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
816 |
]. |
|
817 |
codePieces add:thisCode. |
|
818 |
definedMethodSelectors add:aSel. |
|
819 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
820 |
] ifTrue:[ |
|
821 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
822 |
]. |
|
823 |
]. |
|
824 |
]. |
|
825 |
]. |
|
826 |
||
827 |
"/ for each aspect, generate getter (if not yet implemented) |
|
828 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
829 |
do:[:aSel| |
|
830 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
831 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
832 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
833 |
codePieces add:thisCode. |
|
834 |
definedMethodSelectors add:aSel. |
|
835 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
836 |
] |
|
837 |
] |
|
838 |
]. |
|
839 |
||
840 |
"/ exported aspects - need setter methods |
|
841 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
|
842 |
self generateCodeFrom:exportSels in:cls |
|
843 |
do:[:aSel| |
|
844 |
|aspect| |
|
845 |
||
846 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
847 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
848 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
|
849 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
|
850 |
codePieces add:thisCode. |
|
851 |
definedMethodSelectors add:aSel. |
|
852 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
853 |
] |
|
854 |
] |
|
855 |
]. |
|
856 |
||
857 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
858 |
do:[:aSel| |
|
859 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
860 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
861 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
862 |
codePieces add:thisCode. |
|
863 |
definedMethodSelectors add:aSel. |
|
864 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
865 |
] |
|
866 |
] |
|
867 |
]. |
|
868 |
||
869 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
870 |
do:[:aSel| |
|
871 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
872 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
873 |
"/ uppercase: - assume its a globals name. |
|
874 |
aSel first isUppercase ifFalse:[ |
|
875 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
876 |
codePieces add:thisCode. |
|
877 |
definedMethodSelectors add:aSel. |
|
878 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
879 |
] |
|
880 |
] |
|
881 |
] |
|
882 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
883 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
884 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
885 |
AspectsAsInstances ifTrue:[ |
1834 | 886 |
iVars := cls instVarNames asOrderedCollection. |
887 |
definedMethodSelectors do:[:ivar | |
|
888 |
(iVars includes:ivar) ifFalse:[ |
|
889 |
iVars add:ivar |
|
890 |
] |
|
891 |
]. |
|
892 |
iVars := iVars asArray. |
|
893 |
t := cls shallowCopy. |
|
894 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
895 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
896 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
897 |
|
1834 | 898 |
^ String |
899 |
streamContents: |
|
900 |
[:codeStream | |
|
901 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
902 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
903 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
904 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
905 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
906 |
|
60 | 907 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
908 |
|modelClass modelValueString modelValue modelGen code| |
134 | 909 |
|
149 | 910 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
911 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
912 |
modelValueString notNil ifTrue:[ |
1834 | 913 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
914 |
] ifFalse:[ |
1834 | 915 |
modelValue := protoSpec defaultModelValueFor:aspect. |
916 |
modelValue isNil ifTrue:[ |
|
917 |
modelGen := modelClass name , ' new' |
|
918 |
] ifFalse:[ |
|
919 |
modelGen := modelValue storeString , ' asValue' |
|
920 |
]. |
|
352 | 921 |
|
922 |
]. |
|
134 | 923 |
|
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
924 |
code := '!!' , targetClass name , ' methodsFor:''aspects''!!\\' , |
60 | 925 |
aspect , '\' , |
352 | 926 |
' "automatically generated by UIPainter ..."\\' , |
927 |
' "*** the code below creates a default model when invoked."\' , |
|
928 |
' "*** (which may not be the one you wanted)"\' , |
|
1441
36916e4ce9ab
generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents:
1429
diff
changeset
|
929 |
' "*** Please change as required and accept it in the browser."\' , |
36916e4ce9ab
generate better comments (in aspect methods)
Claus Gittinger <cg@exept.de>
parents:
1429
diff
changeset
|
930 |
' "*** (and replace this comment by something more useful ;-)"\' . |
655
093cba68e10a
simplified to make microsoft cc happy
Claus Gittinger <cg@exept.de>
parents:
588
diff
changeset
|
931 |
|
1474 | 932 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
933 |
AspectsAsInstances ifTrue:[ |
1834 | 934 |
code := code , '\' , |
935 |
' ' , aspect , ' isNil ifTrue:[\' , |
|
936 |
' ' , aspect , ' := ' , modelGen , '.\'. |
|
937 |
modelClass ~~ TriggerValue ifTrue:[ |
|
938 |
code := code , |
|
939 |
'"/ if your app needs to be notified of changes, uncomment one of the lines below:\' , |
|
940 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
941 |
'"/ ' , aspect , ' onChangeSend:#', aspect ,'Changed to:self.\'. |
|
942 |
]. |
|
943 |
code := code , |
|
944 |
' ].\' , |
|
945 |
' ^ ' , aspect ,'.\' , |
|
946 |
'!! !!\\' |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
947 |
] ifFalse:[ |
1834 | 948 |
code := code , '\' , |
949 |
' |holder|\' , |
|
950 |
'\' , |
|
951 |
' (holder := builder bindingAt:#' , aspect , ') isNil ifTrue:[\' , |
|
952 |
' holder := ', modelGen, '.\', |
|
953 |
' builder aspectAt:#' , aspect , ' put:holder.\'. |
|
954 |
modelClass ~~ TriggerValue ifTrue:[ |
|
955 |
code := code , |
|
956 |
'"/ if your app needs to be notified of changes, uncomment one of the lines below:\' , |
|
957 |
'"/ holder addDependent:self.\' , |
|
958 |
'"/ holder onChangeSend:#', aspect ,'Changed to:self.\'. |
|
959 |
]. |
|
960 |
code := code , |
|
961 |
' ].\' , |
|
962 |
' ^ holder.\' , |
|
963 |
'!! !!\\' |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
964 |
]. |
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
965 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
966 |
^ code withCRs |
352 | 967 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
968 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
1225 | 969 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
60 | 970 |
! |
971 |
||
1358 | 972 |
generateAspectSelectorsMethod |
973 |
"generate aspectSelectors method. |
|
974 |
Return a string ready to compile into the application class." |
|
975 |
||
976 |
|cls code spec| |
|
977 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
978 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
979 |
cls isNil ifTrue:[ |
1834 | 980 |
^ nil |
1358 | 981 |
]. |
982 |
||
983 |
spec := treeView exportedAspects. |
|
984 |
spec size == 0 ifTrue:[^ nil]. |
|
985 |
||
986 |
"/ make it an array ... |
|
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
987 |
spec := spec collect:[:entry | |subAspect type| |
1834 | 988 |
subAspect := entry subAspect asSymbol. |
989 |
(type := entry type) isNil ifTrue:[ |
|
990 |
subAspect |
|
991 |
] ifFalse:[ |
|
992 |
Array with:subAspect with:type asSymbol |
|
993 |
]. |
|
994 |
]. |
|
1358 | 995 |
spec := spec asArray. |
996 |
||
997 |
code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' . |
|
998 |
||
999 |
code := code , 'aspectSelectors |
|
1000 |
"This resource specification was automatically generated |
|
1001 |
by the UIPainter of ST/X." |
|
1002 |
||
1003 |
"Do not manually edit this. If it is corrupted, |
|
1004 |
the UIPainter may not be able to read the specification." |
|
1005 |
||
1006 |
"Return a description of exported aspects; |
|
1007 |
these can be connected to aspects of an embedding application |
|
1008 |
(if this app is embedded in a subCanvas)." |
|
1009 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1010 |
^ #(\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1011 |
spec do:[:el | code := code , (' ' , el storeString , '\') ]. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1012 |
code := code , ' ).\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1013 |
code := code , '\!!\'. |
1358 | 1014 |
code := code withCRs. |
1015 |
^ code |
|
1016 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1017 |
"Modified: / 18.2.2000 / 02:08:34 / cg" |
1358 | 1018 |
! |
1019 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1020 |
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1021 |
|code| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1022 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1023 |
code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1024 |
aspect , ':something\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1025 |
' "automatically generated by UIPainter ..."\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1026 |
' "This method is used when I am embedded as subApplication,"\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1027 |
' "and the mainApp wants to connect its aspects to mine."\'. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1028 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1029 |
AspectsAsInstances ifTrue:[ |
1834 | 1030 |
code := (code , '\' , |
1031 |
'"/ ' , aspect , ' notNil ifTrue:[\' , |
|
1032 |
'"/ ' , aspect , ' removeDependent:self.\' , |
|
1033 |
'"/ ].\' , |
|
1034 |
' ' , aspect ,' := something.\' , |
|
1035 |
'"/ ' , aspect ,' notNil ifTrue:[\' , |
|
1036 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
1037 |
'"/ ].\' , |
|
1038 |
' ^ self.\' , |
|
1039 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1040 |
] ifFalse:[ |
1834 | 1041 |
code := (code , '\' , |
1042 |
'"/ |holder|\' , |
|
1043 |
'\' , |
|
1044 |
'"/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' , |
|
1045 |
'"/ holder removeDependent:self.\' , |
|
1046 |
'"/ ].\' , |
|
1047 |
' builder aspectAt:#' , aspect , ' put:something.\', |
|
1048 |
'"/ something notNil ifTrue:[\' , |
|
1049 |
'"/ something addDependent:self.\' , |
|
1050 |
'"/ ].\' , |
|
1051 |
' ^ self.\' , |
|
1052 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1053 |
]. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1054 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1055 |
^ code withCRs |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1056 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1057 |
"Modified: / 29.7.1998 / 11:29:16 / cg" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1058 |
"Modified: / 22.9.1999 / 12:33:47 / stefan" |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1059 |
! |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1060 |
|
698 | 1061 |
generateCodeFrom:aListOfSelectors in:aClass do:aBlock |
1696 | 1062 |
|realSelectors redefCondition redefMessage| |
1063 |
||
1064 |
realSelectors := aListOfSelectors select:[:sel | sel isArray not]. |
|
698 | 1065 |
|
744 | 1066 |
self class redefineAspectMethods ifTrue:[ |
1834 | 1067 |
redefCondition := [:cls :sel | (cls includesSelector:sel) not]. |
1068 |
redefMessage := ' skipped - already implemented in the class'. |
|
698 | 1069 |
] ifFalse:[ |
1834 | 1070 |
redefCondition := [:cls :sel | (cls canUnderstand:sel) not]. |
1071 |
redefMessage := ' skipped - already implemented in the class (or superclass)'. |
|
1696 | 1072 |
]. |
1073 |
||
1074 |
realSelectors do:[:aSelector| |
|
1834 | 1075 |
(redefCondition value:aClass value:aSelector) ifTrue:[ |
1076 |
aBlock value:aSelector asSymbol |
|
1077 |
] ifFalse:[ |
|
1078 |
Transcript showCR:('#' , aSelector , redefMessage) |
|
1079 |
] |
|
698 | 1080 |
] |
376 | 1081 |
! |
1082 |
||
1083 |
generateHookMethodFor:selectorSpec comment:commentWhen note:noteOrNil defaultCode:defaultCode inClass:targetClass |
|
1084 |
^ ('!!' , targetClass name , ' methodsFor:''hooks''!!\\' , |
|
1085 |
selectorSpec , '\' , |
|
1086 |
' "automatically generated by UIPainter ..."\\' , |
|
1087 |
' "*** the code here does nothing. It is invoked when"\' , |
|
1088 |
' "*** ' , commentWhen , '"\' , |
|
1089 |
' "*** Please change as required and accept in the browser."\' , |
|
1090 |
'\' , |
|
1091 |
' "specific code to be added below ..."\' , |
|
1092 |
' "' , (noteOrNil ? '') , '"\' , |
|
1093 |
'\' , |
|
1094 |
(defaultCode ? '^ self.') , |
|
1095 |
'!! !!\\') withCRs |
|
1096 |
||
1097 |
"Modified: / 25.10.1997 / 19:22:17 / cg" |
|
1098 |
"Created: / 31.10.1997 / 17:31:53 / cg" |
|
1099 |
! |
|
1100 |
||
1101 |
generateHookMethods |
|
1102 |
"generate hook methods |
|
1103 |
- but do not overwrite existing ones. |
|
1104 |
Return a string ready to compile into the application class." |
|
1105 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1106 |
|cls| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1107 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1108 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1109 |
cls isNil ifTrue:[ |
1834 | 1110 |
^ nil |
376 | 1111 |
]. |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1112 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1113 |
^ self generateHookMethodsInClass:cls. |
376 | 1114 |
! |
1115 |
||
1116 |
generateHookMethodsInClass:targetClass |
|
1117 |
|code| |
|
1118 |
||
1119 |
code := ''. |
|
1120 |
||
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1121 |
(targetClass includesSelector:#postBuildWith:) ifFalse:[ |
1834 | 1122 |
code := code |
1123 |
, (self |
|
1124 |
generateHookMethodFor:'postBuildWith:aBuilder' |
|
1125 |
comment:'the widgets have been built, but before the view is opened' |
|
1126 |
note:'or after the super send' |
|
1127 |
defaultCode:' super postBuildWith:aBuilder' |
|
1128 |
inClass:targetClass) |
|
376 | 1129 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1130 |
(targetClass includesSelector:#postOpenWith:) ifFalse:[ |
1834 | 1131 |
code := code |
1132 |
, (self |
|
1133 |
generateHookMethodFor:'postOpenWith:aBuilder' |
|
1134 |
comment:'the topView has been opened, but before events are dispatched for it' |
|
1135 |
note:'or after the super send' |
|
1136 |
defaultCode:' super postOpenWith:aBuilder' |
|
1137 |
inClass:targetClass) |
|
376 | 1138 |
]. |
1554
d5e4612bf7cf
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1543
diff
changeset
|
1139 |
(targetClass includesSelector:#closeRequest) ifFalse:[ |
1834 | 1140 |
code := code |
1141 |
, (self |
|
1142 |
generateHookMethodFor:'closeRequest' |
|
1143 |
comment:'the topView has been asked to close' |
|
1144 |
note:'return without the ''super closeRequest'' to stay open' |
|
1145 |
defaultCode:' ^super closeRequest' |
|
1146 |
inClass:targetClass) |
|
376 | 1147 |
]. |
1148 |
^ code |
|
1149 |
||
1150 |
"Modified: / 31.10.1997 / 17:30:34 / cg" |
|
1151 |
"Created: / 31.10.1997 / 17:32:49 / cg" |
|
316 | 1152 |
! |
1153 |
||
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1154 |
generateMenuMethodFor:menuSel inClass:targetClass |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1155 |
|selector args showIt code alreadyInSuperclass numArgs method category| |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1156 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1157 |
selector := menuSel asSymbol. |
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1158 |
category := UserPreferences current categoryForMenuActionsMethods. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1159 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1160 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1161 |
|
1805
cf1a9d636bf7
category and comment flags now in Userprefs
Claus Gittinger <cg@exept.de>
parents:
1785
diff
changeset
|
1162 |
code := '!!' , targetClass name , ' methodsFor:''' , category , '''!!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1163 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1164 |
selector = 'openAboutThisApplication' ifTrue:[ |
1834 | 1165 |
code := code , |
1166 |
'openAboutThisApplication\' , |
|
1167 |
' "opens an about box for this application."\\' , |
|
1168 |
' "automatically generated by UIPainter ..."\\' , |
|
1169 |
||
1170 |
' |rev box myClass clsRev image msg|\\' , |
|
1171 |
||
1172 |
' rev := ''''.\' , |
|
1173 |
' myClass := self class.\' , |
|
1174 |
||
1175 |
' (clsRev := myClass revision) notNil ifTrue:[\' , |
|
1176 |
' rev := '' (rev: '', clsRev printString, '')''].\\' , |
|
1177 |
||
1178 |
' msg := Character cr asString , myClass name asBoldText, rev.\' , |
|
1179 |
' msg := (msg , ''\\*** add more info here ***\\'') withCRs.\\' , |
|
1180 |
' box := AboutBox title:msg.\' , |
|
1181 |
||
1182 |
' "/ *** add a #defaultIcon method in the class\' , |
|
1183 |
' "/ *** and uncomment the following line:\' , |
|
1184 |
' "/ image := self class defaultIcon.\\' , |
|
1185 |
' image notNil ifTrue:[\' , |
|
1186 |
' box image:image\' , |
|
1187 |
' ].\' , |
|
1188 |
' box label:(resources string:''About %1'' with:myClass name).\' , |
|
1189 |
' box autoHideAfter:10 with:[].\' , |
|
1190 |
' box showAtPointer.\' , |
|
1191 |
'!! !!\\'. |
|
1192 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1193 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1194 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1195 |
selector = 'menuOpen' ifTrue:[ |
1834 | 1196 |
code := code , |
1197 |
'menuOpen\' , |
|
1198 |
' "automatically generated by UIPainter ..."\\' , |
|
1199 |
' "*** the code below opens a dialog for file selection"\' , |
|
1200 |
' "*** and invokes the #doOpen: method with the selected file."\' , |
|
1201 |
' "*** Please change as required and accept in the browser."\\' , |
|
1202 |
' |file|\\' , |
|
1203 |
' file :=\' , |
|
1204 |
' (FileSelectionBrowser\' , |
|
1205 |
' request: ''Open''\' , |
|
1206 |
' fileName: ''''\' , |
|
1207 |
' "/ inDirectory: lastOpenDirectory\' , |
|
1208 |
' withFileFilters: #(''*'')).\\' , |
|
1209 |
' file notNil ifTrue:[\' , |
|
1210 |
' "/ lastOpenDirectory := file asFilename directory.\' , |
|
1211 |
' self doOpen:file\' , |
|
1212 |
' ]\' , |
|
1213 |
'!! !!\'. |
|
1214 |
^ code withCRs |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1215 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1216 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1217 |
numArgs := selector numArgs. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1218 |
method := selector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1219 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1220 |
numArgs == 1 ifTrue:[ |
1834 | 1221 |
args := 'anArgument'. |
1222 |
showIt := ''' , anArgument printString , '' ...''.\'. |
|
1223 |
] ifFalse:[ |
|
1224 |
args := ''. |
|
1225 |
showIt := ' ...''.\'. |
|
1226 |
||
1227 |
numArgs ~~ 0 ifTrue:[ |
|
1228 |
method := ''. |
|
1229 |
||
1230 |
selector keywords keysAndValuesDo:[:i :key| |
|
1231 |
method := method, key, 'arg', i printString, ' ' |
|
1232 |
] |
|
1233 |
] |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1234 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1235 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1236 |
code := code , |
1834 | 1237 |
method , args , '\' , |
1238 |
' "automatically generated by UIPainter ..."\\' , |
|
1239 |
' "*** the code below performs no action"\' , |
|
1240 |
' "*** (except for some feedback on the Transcript)"\' , |
|
1241 |
' "*** Please change as required and accept in the browser."\' , |
|
1242 |
'\' . |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1243 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1244 |
alreadyInSuperclass ifTrue:[ |
1834 | 1245 |
code := code , |
1246 |
' "action for ' , selector , ' is already provided in a superclass."\' , |
|
1247 |
' "It may be redefined here ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1248 |
] ifFalse:[ |
1834 | 1249 |
code := code , |
1250 |
' "action to be added ..."\\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1251 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1252 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1253 |
code := code , |
1834 | 1254 |
' Transcript showCR:self class name, '': '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1255 |
alreadyInSuperclass ifTrue:[ |
1834 | 1256 |
code := code , 'inherited '. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1257 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1258 |
code := code , 'menu action for ' , selector , showIt. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1259 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1260 |
alreadyInSuperclass ifTrue:[ |
1834 | 1261 |
code := code , |
1262 |
' super ' , selector , args , '.\'. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1263 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1264 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1265 |
code := code , |
1834 | 1266 |
'!! !!\\'. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1267 |
^ code withCRs |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1268 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1269 |
"Created: / 23.8.1998 / 16:46:51 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1270 |
"Modified: / 23.8.1998 / 18:13:05 / cg" |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1271 |
! |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1272 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1273 |
generateMenuMethods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1274 |
"generate menu methods |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1275 |
- but do not overwrite existing ones. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1276 |
Return a string ready to compile into the application class." |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1277 |
|
1069 | 1278 |
|cls code menuSelector thisCode |
1279 |
definedMethodSelectors |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1280 |
specArray fullSpec winSpec menuSpec |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1281 |
| |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1282 |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1283 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1284 |
cls isNil ifTrue:[ |
1834 | 1285 |
^ nil |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1286 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1287 |
|
1058 | 1288 |
specArray := treeView generateFullSpecForComponents:#() named:nil. |
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1289 |
fullSpec := specArray decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1290 |
winSpec := fullSpec window. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1291 |
menuSelector := winSpec menu. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1292 |
|
1834 | 1293 |
(menuSelector notNil |
1069 | 1294 |
and:[ (cls respondsTo:menuSelector) ]) ifFalse:[ |
1834 | 1295 |
self warn:'No menu defined (yet)'. |
1296 |
^ nil. |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1297 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1298 |
menuSpec := cls perform:menuSelector. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1299 |
menuSpec := menuSpec decodeAsLiteralArray. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1300 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1301 |
definedMethodSelectors := IdentitySet new. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1302 |
code := ''. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1303 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1304 |
menuSpec allItemsDo:[:item | |
1834 | 1305 |
|sel| |
1306 |
||
1307 |
(sel := item value) notNil ifTrue:[ |
|
1308 |
(definedMethodSelectors includes:sel) ifFalse:[ |
|
1309 |
self generateCodeFrom:(Array with:sel) in:cls do:[:aSel| |
|
1310 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
|
1311 |
code := code, thisCode. |
|
1312 |
]. |
|
1313 |
definedMethodSelectors add:sel. |
|
1314 |
]. |
|
1315 |
] |
|
965
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1316 |
]. |
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1317 |
|
4f786b46a569
added menu-action code generation
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
1318 |
(definedMethodSelectors includes:#menuOpen) ifTrue:[ |
1834 | 1319 |
self generateCodeFrom:(Array with:#doOpen:) in:cls do:[:aSel| |
1320 |
thisCode := (self generateMenuMethodFor:aSel inClass:cls). |
|
2c640b5f7fa9
*** empty log message ***
werne |