author | Claus Gittinger <cg@exept.de> |
Mon, 18 May 2009 15:28:47 +0200 | |
changeset 2537 | 12e3b32befe4 |
parent 2526 | 29b49d1b4d53 |
child 2560 | efad0ef440c7 |
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 |
" |
|
1387 | 12 |
"{ Package: 'stx:libtool2' }" |
13 |
||
60 | 14 |
UIObjectView subclass:#UIPainterView |
278 | 15 |
instanceVariableNames:'treeView listHolder superclassName className methodName |
2244 | 16 |
categoryName handleColorBlack handleColorWhite handleMasterColor |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
17 |
sketchPainter listOfAspectsHolder' |
2244 | 18 |
classVariableNames:'HandCursor RedefineAspectMethods AspectsAsInstances |
19 |
GenerateCommentedCode' |
|
60 | 20 |
poolDictionaries:'' |
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
211 | 24 |
Object subclass:#ViewProperty |
25 |
instanceVariableNames:'view spec identifier' |
|
26 |
classVariableNames:'Identifier' |
|
27 |
poolDictionaries:'' |
|
28 |
privateIn:UIPainterView |
|
29 |
! |
|
30 |
||
60 | 31 |
!UIPainterView class methodsFor:'documentation'! |
32 |
||
33 |
copyright |
|
34 |
" |
|
156 | 35 |
COPYRIGHT (c) 1995 by Claus Gittinger / eXept Software AG |
1834 | 36 |
All Rights Reserved |
60 | 37 |
|
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
742 | 40 |
inclusion of the above copyright notice. This software may not |
60 | 41 |
be provided or otherwise made available to, or used by, any |
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
128 | 49 |
buildIn view used by the UIPainter; from this view, the layout of the |
50 |
new application derives from. |
|
51 |
||
52 |
[see also:] |
|
1834 | 53 |
UIBuilder |
54 |
UIObjectView |
|
156 | 55 |
|
56 |
[author:] |
|
1834 | 57 |
Claus Gittinger |
58 |
Claus Atzkern |
|
60 | 59 |
" |
60 |
! ! |
|
61 |
||
1225 | 62 |
!UIPainterView class methodsFor:'initialization'! |
63 |
||
64 |
initialize |
|
65 |
||
1494 | 66 |
AspectsAsInstances := true. "/ false. |
1225 | 67 |
RedefineAspectMethods := false. |
68 |
||
69 |
"Created: / 22.9.1999 / 12:32:31 / stefan" |
|
70 |
! ! |
|
71 |
||
698 | 72 |
!UIPainterView class methodsFor:'code generation mode'! |
73 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
74 |
generateAspectsAsInstanceVariables |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
75 |
"if on, aspects are held as instance variables; |
2244 | 76 |
if off (the default), they are kept in the bindings dictionary." |
77 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
78 |
^ AspectsAsInstances |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
79 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
80 |
"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
|
81 |
"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
|
82 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
83 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
84 |
generateAspectsAsInstanceVariables:aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
85 |
"if on, aspects are held as instance variables; |
2244 | 86 |
if off (the default), they are kept in the bindings dictionary." |
87 |
||
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
88 |
AspectsAsInstances := aBoolean |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
89 |
|
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
90 |
"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
|
91 |
"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
|
92 |
! |
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
93 |
|
2244 | 94 |
generateCommentedCode |
95 |
"comments in generated aspect methods; yes or no." |
|
96 |
||
97 |
^ GenerateCommentedCode ? true |
|
98 |
||
99 |
"Modified: / 12-01-2008 / 10:21:06 / cg" |
|
100 |
! |
|
101 |
||
102 |
generateCommentedCode:aBoolean |
|
103 |
"comments in generated aspect methods; yes or no." |
|
104 |
||
105 |
GenerateCommentedCode := aBoolean |
|
106 |
! |
|
107 |
||
742 | 108 |
redefineAspectMethods |
2244 | 109 |
"redefine methods yes or no. |
110 |
If a method is defined in super class should the message be reinstalled ?" |
|
111 |
||
1225 | 112 |
^ RedefineAspectMethods |
698 | 113 |
|
1225 | 114 |
"Modified: / 22.9.1999 / 12:33:03 / stefan" |
698 | 115 |
! |
116 |
||
742 | 117 |
redefineAspectMethods:aBoolean |
2244 | 118 |
"redefine methods yes or no. |
119 |
If a method is defined in super class should the message be reinstalled ?" |
|
120 |
||
742 | 121 |
RedefineAspectMethods := aBoolean |
698 | 122 |
! ! |
123 |
||
60 | 124 |
!UIPainterView class methodsFor:'defaults'! |
125 |
||
1834 | 126 |
defaultMenuMessage |
60 | 127 |
"This message is the default yo be sent to the menuHolder to get a menu |
128 |
" |
|
121 | 129 |
^ #showMiddleButtonMenu |
60 | 130 |
|
131 |
||
132 |
! ! |
|
133 |
||
134 |
!UIPainterView methodsFor:'accessing'! |
|
135 |
||
136 |
application |
|
137 |
^ nil |
|
138 |
||
139 |
"Modified: 6.9.1995 / 00:46:44 / claus" |
|
140 |
! |
|
141 |
||
78 | 142 |
applicationName |
143 |
^ self className |
|
144 |
! |
|
145 |
||
146 |
applicationName:aName |
|
147 |
self className:aName |
|
148 |
! |
|
149 |
||
1977 | 150 |
class:aClass superclassName:aSuperclassName selector:aSelector |
151 |
self assert:(aClass isBehavior). |
|
152 |
className := aClass name. |
|
153 |
superclassName := aSuperclassName. |
|
154 |
methodName := aSelector. |
|
155 |
! |
|
156 |
||
60 | 157 |
className |
158 |
^ className |
|
159 |
! |
|
160 |
||
78 | 161 |
className:aName |
1977 | 162 |
self assert:(aName isString). |
78 | 163 |
className := aName |
60 | 164 |
! |
165 |
||
166 |
className:aClassName superclassName:aSuperclassName selector:aSelector |
|
1977 | 167 |
self assert:(aClassName isString). |
78 | 168 |
className := aClassName. |
60 | 169 |
superclassName := aSuperclassName. |
78 | 170 |
methodName := aSelector. |
60 | 171 |
! |
172 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
173 |
listOfAspectsHolder:something |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
174 |
listOfAspectsHolder := something. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
175 |
! |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
176 |
|
60 | 177 |
methodName |
178 |
^ methodName |
|
179 |
! |
|
180 |
||
78 | 181 |
methodName:aName |
182 |
methodName := aName |
|
60 | 183 |
! |
184 |
||
185 |
selectNames:aStringOrCollection |
|
1031 | 186 |
|prop coll s n newSel| |
187 |
||
188 |
(aStringOrCollection size == 0) ifTrue:[ |
|
1834 | 189 |
newSel := nil. |
1031 | 190 |
] ifFalse:[ |
1834 | 191 |
(s := aStringOrCollection) isString ifFalse:[ |
192 |
s size == 1 ifTrue:[ |
|
193 |
s := s first |
|
194 |
] ifFalse:[ |
|
195 |
coll := OrderedCollection new. |
|
196 |
||
197 |
s do:[:aName| |
|
198 |
(prop := self propertyOfName:aName) notNil ifTrue:[ |
|
199 |
coll add:(prop view) |
|
200 |
] |
|
201 |
]. |
|
202 |
(n := coll size) == 1 ifTrue:[ |
|
203 |
newSel := coll at:1 |
|
204 |
] ifFalse:[ |
|
205 |
n == 0 ifTrue:[ |
|
206 |
newSel := nil |
|
207 |
] ifFalse:[ |
|
208 |
newSel := coll |
|
209 |
] |
|
210 |
]. |
|
211 |
^ self select:newSel. |
|
212 |
] |
|
213 |
]. |
|
214 |
||
215 |
prop := self propertyOfName:s. |
|
216 |
prop isNil ifTrue:[ |
|
217 |
newSel := nil |
|
218 |
] ifFalse:[ |
|
219 |
newSel := prop view |
|
220 |
]. |
|
60 | 221 |
]. |
222 |
||
1031 | 223 |
^ self select:newSel |
60 | 224 |
! ! |
225 |
||
111 | 226 |
!UIPainterView methodsFor:'change & update'! |
227 |
||
223 | 228 |
layoutChanged |
1445 | 229 |
treeView notNil ifTrue:[ |
1834 | 230 |
treeView layoutChanged |
1445 | 231 |
] |
111 | 232 |
! ! |
233 |
||
60 | 234 |
!UIPainterView methodsFor:'copy & cut & paste'! |
235 |
||
2221 | 236 |
changeSelectionAfterPasteOf:sel |
237 |
sel notNil ifTrue:[ |
|
238 |
self select:sel. |
|
239 |
]. |
|
240 |
! |
|
241 |
||
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
242 |
commonContainerOf:someComponents |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
243 |
|container| |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
244 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
245 |
container := someComponents first container. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
246 |
[container notNil |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
247 |
and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]] |
1834 | 248 |
whileTrue:[ |
249 |
container := container container. |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
250 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
251 |
^ container |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
252 |
! |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
253 |
|
60 | 254 |
copySelection |
1959 | 255 |
"copy the selection into the cut & paste-buffer" |
256 |
||
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
257 |
|specs coll| |
71 | 258 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
259 |
coll := self minClosedViewSetFor:(self selection). |
60 | 260 |
|
71 | 261 |
coll notNil ifTrue:[ |
776 | 262 |
"/ self select:nil. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
263 |
specs := coll collect:[:eachView | self fullSpecWithAbsolutePositionFor:eachView]. |
1870 | 264 |
self setClipboardObject:specs. |
776 | 265 |
"/ treeView selection: sel |
60 | 266 |
]. |
267 |
! |
|
268 |
||
723 | 269 |
deleteSelection |
1959 | 270 |
"delete the selection buffered" |
271 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
272 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
273 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
274 |
|
2396 | 275 |
deleteSelectionBuffered:buffered |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
276 |
"cut the selection. If buffered is true, place it into the cut&paste-buffer" |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
277 |
|
2396 | 278 |
|specs viewsToRemove newSelection firstView| |
71 | 279 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
280 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
281 |
|
2396 | 282 |
viewsToRemove := self minClosedViewSetFor:(self selection). |
283 |
viewsToRemove isEmptyOrNil ifTrue:[ ^ self]. |
|
284 |
||
285 |
buffered ifTrue:[ |
|
286 |
specs := viewsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ]. |
|
287 |
self setClipboardObject:specs |
|
288 |
]. |
|
289 |
firstView := viewsToRemove first. |
|
290 |
newSelection := self findContainerOfView:firstView. |
|
291 |
||
292 |
newSelection isNil ifTrue:[ |
|
293 |
newSelection := self. |
|
294 |
] ifFalse:[ |
|
295 |
viewsToRemove size == 1 ifTrue:[ |
|
296 |
|subviews index| |
|
297 |
||
2508 | 298 |
"/ newSelection components notEmptyOrNil ifTrue:[ self halt ]. |
2396 | 299 |
subviews := newSelection subViews. |
300 |
||
301 |
subviews size > 1 ifTrue:[ |
|
302 |
index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ]. |
|
303 |
index > 0 ifTrue:[ |
|
304 |
newSelection := subviews |
|
305 |
at:(index + 1) |
|
306 |
ifAbsent:[subviews at:index -1]. |
|
307 |
]. |
|
308 |
]. |
|
309 |
]. |
|
310 |
]. |
|
311 |
||
312 |
self withSelectionHiddenDo:[ |
|
313 |
self select:newSelection. |
|
314 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
315 |
treeView canvasEventsDisabledDo:[ |
2396 | 316 |
self withinTransaction:#cut objects:viewsToRemove do:[ |
317 |
viewsToRemove reverseDo:[:aView| |
|
1870 | 318 |
self createUndoRemove:aView. |
319 |
self remove:aView. |
|
320 |
] |
|
321 |
]. |
|
2396 | 322 |
]. |
323 |
self windowGroup processRealExposeEvents. |
|
324 |
]. |
|
698 | 325 |
! |
326 |
||
723 | 327 |
deleteTotalSelection |
1959 | 328 |
"delete the selection" |
329 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
330 |
self deleteSelectionBuffered: false |
60 | 331 |
! |
332 |
||
1832 | 333 |
getSelectedViewsAndSpecs |
334 |
"return an array filed with selected views and corresponding specs. |
|
1959 | 335 |
Nil if there is none." |
336 |
||
1832 | 337 |
|specs coll sel| |
338 |
||
339 |
sel := treeView selection. |
|
340 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
341 |
coll := self minClosedViewSetFor:(self selection). |
1832 | 342 |
|
343 |
coll isNil ifTrue:[^ nil]. |
|
344 |
||
345 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
346 |
^ Array with: coll with: specs |
|
347 |
! |
|
348 |
||
60 | 349 |
pasteBuffer |
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
350 |
"add the objects in the paste-buffer to the object view; |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
351 |
don't change the layout if more than a single item has been selected" |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
352 |
|
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
353 |
|sel clipboard| |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
354 |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
355 |
self enabled ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
356 |
Dialog warn:'Operation currently disabled (In geometry test mode)'. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
357 |
^ self |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
358 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
359 |
|
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
360 |
clipboard := self getClipboardObject. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
361 |
sel := self pasteSpecifications:clipboard keepLayout:true "(clipboard size > 1)". |
2221 | 362 |
self changeSelectionAfterPasteOf:sel. |
89 | 363 |
! |
364 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
365 |
pasteKeepingPosition |
1834 | 366 |
"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
|
367 |
translate the layout as appropriate, to position the component |
1959 | 368 |
at the same absolute position (relative to topView) as before" |
369 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
370 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
371 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
372 |
sel := self |
1872 | 373 |
pasteSpecifications:(self getClipboardObject) |
374 |
keepLayout:true |
|
375 |
keepPosition:true |
|
376 |
at:nil. |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
377 |
|
2221 | 378 |
self changeSelectionAfterPasteOf:sel. |
1338
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 |
|
2395 | 381 |
pasteSpecifications:aSpecificationOrList into:aContainerOrNil beforeIndex:anIndexOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
2537 | 382 |
"add the specs to the object view; |
383 |
if given a collection of specs, returns a list of pasted widgets; |
|
384 |
if given a single spec, returns that view (sigh - a stupid bw-compatibility kludge)" |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
385 |
|
2494 | 386 |
|sensor specsToPaste pasteOffset builder newSel |
2395 | 387 |
bounds containerToPasteInto pastePoint beforeIndex| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
388 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
389 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
390 |
|
2494 | 391 |
sensor := self window sensor. |
392 |
||
2387 | 393 |
containerToPasteInto := aContainerOrNil. |
394 |
||
2366 | 395 |
(aPointOrNilOrKeep == #keep |
2494 | 396 |
or:[ sensor shiftDown |
397 |
or:[ sensor ctrlDown ]]) ifTrue:[ |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
398 |
"/ paste into the selection |
2387 | 399 |
containerToPasteInto isNil ifTrue:[ |
400 |
containerToPasteInto := self singleSelection. |
|
401 |
]. |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
402 |
] ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
403 |
"/ ignore the selection and paste where we drop!! |
2366 | 404 |
pastePoint := aPointOrNilOrKeep. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
405 |
pastePoint isNil ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
406 |
pastePoint := device |
2494 | 407 |
translatePoint:(sensor mousePoint) |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
408 |
fromView:nil |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
409 |
toView:self. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
410 |
]. |
2387 | 411 |
containerToPasteInto isNil ifTrue:[ |
412 |
containerToPasteInto := self findObjectAt:pastePoint. |
|
413 |
]. |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
414 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
415 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
416 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
417 |
self selection size > 0 ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
418 |
containerToPasteInto := self commonContainerOf:self selection |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
419 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
420 |
containerToPasteInto := self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
421 |
]. |
2221 | 422 |
"/ self selection:containerToPasteInto. |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
423 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
424 |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
425 |
"/ search up parent list for something we can paste into |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
426 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
427 |
containerToPasteInto == self ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
428 |
containerToPasteInto := nil |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
429 |
] ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
430 |
containerToPasteInto := containerToPasteInto container. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
431 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
432 |
]. |
1752 | 433 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
434 |
containerToPasteInto := self |
1752 | 435 |
]. |
60 | 436 |
|
2221 | 437 |
(self canPaste:aSpecificationOrList into:containerToPasteInto) |
438 |
ifFalse:[ |
|
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
439 |
self enabled ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
440 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
441 |
] ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
442 |
Dialog warn:'Operation currently disabled (In Geometry test mode)'. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
443 |
]. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
444 |
^ nil |
89 | 445 |
]. |
223 | 446 |
|
2537 | 447 |
self hideSelection. |
448 |
||
776 | 449 |
aSpecificationOrList isCollection ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
450 |
specsToPaste := aSpecificationOrList |
776 | 451 |
] ifFalse:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
452 |
specsToPaste := Array with:aSpecificationOrList |
776 | 453 |
]. |
2221 | 454 |
"/ self setClipboardObject:nil. |
776 | 455 |
|
456 |
newSel := OrderedCollection new. |
|
457 |
builder := UIBuilder new isEditing:true. |
|
458 |
||
459 |
className notNil ifTrue:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
460 |
builder applicationClass:(self resolveName:className) |
776 | 461 |
]. |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
462 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent). |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
463 |
|
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
464 |
pasteOffset := 0. |
60 | 465 |
|
2395 | 466 |
(anIndexOrNil notNil and:[anIndexOrNil > 0]) ifTrue:[ |
467 |
beforeIndex := anIndexOrNil. |
|
468 |
]. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
469 |
specsToPaste do:[:eachSpec| |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
470 |
|view newOrigin uiPainterAttributes thisAbsOrigin| |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
471 |
|
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
472 |
uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
2388 | 473 |
eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
474 |
|
2395 | 475 |
view := self addSpec:eachSpec builder:builder in:containerToPasteInto beforeIndex:beforeIndex. |
476 |
beforeIndex notNil ifTrue:[ |
|
477 |
beforeIndex := beforeIndex + 1 |
|
478 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
479 |
|
2369 | 480 |
(keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
2386 | 481 |
aPointOrNilOrKeep == #keep ifTrue:[ |
482 |
newOrigin := uiPainterAttributes at:#origin. |
|
483 |
] ifFalse:[ |
|
484 |
thisAbsOrigin := uiPainterAttributes at:#absOrigin. |
|
485 |
||
486 |
newOrigin := device |
|
487 |
translatePoint:thisAbsOrigin |
|
488 |
fromView:self |
|
489 |
toView:containerToPasteInto. |
|
490 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
491 |
] ifFalse:[ |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
492 |
pastePoint isNil ifTrue:[ pastePoint := 0@0 ]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
493 |
newOrigin := device |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
494 |
translatePoint:pastePoint |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
495 |
fromView:self |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
496 |
toView:containerToPasteInto. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
497 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
498 |
|
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
499 |
(bounds containsPoint:newOrigin) ifFalse:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
500 |
newOrigin := pasteOffset asPoint. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
501 |
pasteOffset := pasteOffset + 4. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
502 |
]. |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
503 |
newOrigin notNil ifTrue:[ |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
504 |
self moveObject:view to:newOrigin. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
505 |
]. |
2395 | 506 |
view realized ifFalse:[ |
507 |
view realize. |
|
508 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
509 |
newSel add:view. |
776 | 510 |
]. |
60 | 511 |
|
2537 | 512 |
self |
513 |
withinTransaction:#paste |
|
514 |
objects:newSel |
|
515 |
do:[ |
|
516 |
undoHistory |
|
517 |
addUndoSelector:#undoCreate: |
|
518 |
withArgs:(newSel collect:[:v| (self propertyOfView:v) identifier]). |
|
519 |
self undoHistoryChanged. |
|
520 |
]. |
|
60 | 521 |
|
776 | 522 |
self realizeAllSubViews. |
2395 | 523 |
"/ 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
|
524 |
self elementChangedSize:containerToPasteInto. |
134 | 525 |
|
2537 | 526 |
"/ because the new-created view will destroy the handles, when it redraws itself, |
527 |
"/ give it a chance to do so, before we return. |
|
528 |
[ (newSel conform:[:v | v shown]) ] whileFalse:[ |
|
529 |
Delay waitForSeconds:0.01. |
|
530 |
]. |
|
531 |
Delay waitForSeconds:0.01. |
|
532 |
self windowGroup repairDamage. |
|
533 |
||
776 | 534 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 535 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
536 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
537 |
"Modified: / 10.10.2001 / 14:15:12 / cg" |
89 | 538 |
! |
539 |
||
2395 | 540 |
pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
541 |
"add the specs to the object view; returns list of pasted widgets" |
|
542 |
||
543 |
^ self pasteSpecifications:aSpecificationOrList |
|
544 |
into:aContainerOrNil |
|
545 |
beforeIndex:nil |
|
546 |
keepLayout:keepLayout |
|
547 |
keepPosition:keepPosition |
|
548 |
at:aPointOrNilOrKeep |
|
549 |
! |
|
550 |
||
2387 | 551 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
552 |
"add the specs to the object view; returns list of pasted widgets" |
|
553 |
||
554 |
^ self |
|
555 |
pasteSpecifications:aSpecificationOrList |
|
556 |
keepLayout:keepLayout |
|
557 |
keepPosition:true |
|
558 |
at:nil |
|
559 |
||
560 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
561 |
! |
|
562 |
||
563 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
564 |
"add the specs to the object view; returns list of pasted widgets" |
|
565 |
||
566 |
^ self |
|
567 |
pasteSpecifications:aSpecificationOrList |
|
568 |
keepLayout:keepLayout |
|
569 |
keepPosition:true |
|
570 |
at:aPointOrNil |
|
571 |
! |
|
572 |
||
573 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
|
574 |
"add the specs to the object view; returns list of pasted widgets" |
|
575 |
||
576 |
^ self pasteSpecifications:aSpecificationOrList |
|
577 |
into:nil |
|
2395 | 578 |
beforeIndex:nil |
2387 | 579 |
keepLayout:keepLayout |
580 |
keepPosition:keepPosition |
|
581 |
at:aPointOrNilOrKeep |
|
582 |
! |
|
583 |
||
2315 | 584 |
pasteWithLayout |
2369 | 585 |
"add the objects in the paste-buffer to the object view - keep the old layout" |
2315 | 586 |
|
587 |
|sel| |
|
588 |
||
2366 | 589 |
sel := self |
590 |
pasteSpecifications:(self getClipboardObject) |
|
591 |
keepLayout:true |
|
592 |
keepPosition:true |
|
593 |
at:#keep. |
|
2315 | 594 |
self changeSelectionAfterPasteOf:sel. |
595 |
! |
|
596 |
||
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
597 |
pasteWithoutLayout |
2369 | 598 |
"add the objects in the paste-buffer to the object view - do not keep the old layout" |
1959 | 599 |
|
223 | 600 |
|sel| |
601 |
||
2367 | 602 |
sel := self |
603 |
pasteSpecifications:(self getClipboardObject) |
|
604 |
keepLayout:false |
|
605 |
keepPosition:true |
|
606 |
at:#keep. |
|
2221 | 607 |
self changeSelectionAfterPasteOf:sel. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
608 |
! |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
609 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
610 |
replaceSelectionBy:aNewSpec |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
611 |
"replace the selected widget by another one." |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
612 |
|
2395 | 613 |
|oldSelection treeModel newView oldView container specs| |
2387 | 614 |
|
615 |
(self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ |
|
616 |
^ self |
|
617 |
]. |
|
618 |
treeModel := treeView model. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
619 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
2387 | 620 |
oldSelection isNil ifTrue:[^ self]. |
621 |
||
2395 | 622 |
oldView := oldSelection contents view. |
623 |
||
624 |
(oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[ |
|
625 |
specs := oldSelection children collect:[:each| |
|
626 |
self fullSpecWithAbsolutePositionFor:(each contents view) |
|
627 |
]. |
|
628 |
]. |
|
2387 | 629 |
|
630 |
aNewSpec |
|
631 |
otherAttributeAt:#uiPainterAttributes |
|
632 |
put:(Dictionary new |
|
633 |
at:#origin put:oldView origin; |
|
634 |
at:#extent put:oldView extent; |
|
635 |
at:#absOrigin put:(oldView originRelativeTo:self); |
|
636 |
yourself). |
|
637 |
||
638 |
container := self singleSelection container. |
|
639 |
||
640 |
self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ |
|
2395 | 641 |
self withSelectionHiddenDo:[ |
642 |
newView := self |
|
643 |
pasteSpecifications:(Array with:aNewSpec) |
|
644 |
into:container |
|
645 |
beforeIndex:1 |
|
646 |
keepLayout:true |
|
647 |
keepPosition:true |
|
648 |
at:#keep. |
|
649 |
||
650 |
self deleteSelectionBuffered:false. |
|
651 |
||
652 |
specs size > 0 ifTrue:[ |
|
653 |
self pasteSpecifications:specs |
|
654 |
into:newView |
|
655 |
keepLayout:(aNewSpec class canResizeSubComponents) |
|
656 |
keepPosition:(aNewSpec class isLayoutContainer not) |
|
657 |
at:nil. |
|
658 |
]. |
|
659 |
self select:newView. |
|
660 |
]. |
|
2387 | 661 |
]. |
2395 | 662 |
^ newView. |
60 | 663 |
! ! |
664 |
||
665 |
!UIPainterView methodsFor:'drag & drop'! |
|
666 |
||
2116 | 667 |
canDrop:aDropContext |
668 |
^ self canDropObjects:aDropContext dropObjects |
|
669 |
||
670 |
"Created: / 13-10-2006 / 17:46:11 / cg" |
|
671 |
! |
|
672 |
||
673 |
canDropObjects:aCollectionOfDropObjects |
|
1914 | 674 |
"returns true if something can be dropped" |
675 |
||
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
676 |
^ (true "aCollectionOfDropObjects size == 1" |
2112 | 677 |
and:[ self enabled |
2362
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
678 |
and:[ true "self numberOfSelections <= 1" |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
679 |
and:[ aCollectionOfDropObjects conform:[:each| each theObject isKindOf:UISpecification] |
a6a7ef98fdc3
can resize - allow resizing all;
Claus Gittinger <cg@exept.de>
parents:
2358
diff
changeset
|
680 |
]]]) |
2112 | 681 |
|
2116 | 682 |
"Created: / 13-10-2006 / 16:09:24 / cg" |
223 | 683 |
! |
684 |
||
285 | 685 |
canPaste |
1914 | 686 |
"returns true if there is something which can be pasted in the clipboard" |
687 |
||
1872 | 688 |
^ self canPaste:(self getClipboardObject) |
285 | 689 |
! |
690 |
||
223 | 691 |
canPaste:something |
1914 | 692 |
"returns true if something could be pasted" |
693 |
||
2221 | 694 |
^ self canPaste:something into:(self singleSelection) |
695 |
! |
|
696 |
||
697 |
canPaste:something into:containerToPasteInto |
|
698 |
"returns true if something could be pasted" |
|
699 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
700 |
(self enabled) ifFalse:[ |
1914 | 701 |
^ false |
223 | 702 |
]. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
703 |
something isCollection ifTrue:[ |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
704 |
something isEmpty ifTrue:[ ^ false]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
705 |
^ something conform:[:el | (self canPaste:el into:containerToPasteInto)] |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
706 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
707 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
708 |
(something isKindOf:UISpecification) ifFalse:[ |
1914 | 709 |
^ false |
223 | 710 |
]. |
711 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
712 |
^ self canPasteInto:containerToPasteInto |
223 | 713 |
! |
714 |
||
715 |
canPasteInto:aView |
|
1914 | 716 |
"return true, if I can paste into a view" |
717 |
||
285 | 718 |
|prop| |
60 | 719 |
|
1870 | 720 |
aView isNil ifTrue:[ ^ false ]. |
2265 | 721 |
aView == self ifTrue:[ ^ true ]. |
1870 | 722 |
|
723 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
724 |
^ prop spec class supportsSubComponents |
|
89 | 725 |
]. |
1870 | 726 |
^ aView specClass supportsSubComponents. |
60 | 727 |
! |
728 |
||
2116 | 729 |
dropObjects:aCollectionOfDropObjects at:aPoint |
2537 | 730 |
|spec newSel oldSel dragOffset dropPoint widg| |
731 |
||
288 | 732 |
self selection notNil ifTrue:[ |
1953 | 733 |
oldSel := self singleSelection. |
734 |
||
735 |
"/ search selections hierarchy for a widget into which we can paste |
|
736 |
widg := oldSel. |
|
737 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
738 |
widg notNil ifTrue:[ |
|
739 |
widg := widg container |
|
740 |
]. |
|
741 |
]. |
|
742 |
||
743 |
oldSel := nil. |
|
744 |
self setSelection:widg withRedraw:true. |
|
231 | 745 |
]. |
1953 | 746 |
spec := (aCollectionOfDropObjects at:1) theObject. |
2537 | 747 |
|
748 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
|
749 |
aPoint isNil ifTrue:[ |
|
750 |
dropPoint := #keep. |
|
751 |
] ifFalse:[ |
|
752 |
dropPoint := aPoint - dragOffset. |
|
1833 | 753 |
]. |
2537 | 754 |
newSel := self pasteSpecifications:spec keepLayout:false keepPosition:false at:dropPoint. |
755 |
||
756 |
self select:(oldSel ? newSel). |
|
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
757 |
|
2116 | 758 |
"Modified: / 18-03-1999 / 18:29:43 / stefan" |
759 |
"Created: / 13-10-2006 / 16:09:27 / cg" |
|
60 | 760 |
! ! |
761 |
||
2244 | 762 |
!UIPainterView methodsFor:'drawing'! |
763 |
||
764 |
clearRectangle:visRect |
|
765 |
super clearRectangle:visRect. |
|
766 |
sketchPainter notNil ifTrue:[ |
|
767 |
sketchPainter redrawInTargetView |
|
768 |
]. |
|
769 |
||
770 |
"Created: / 16-01-2008 / 17:52:27 / cg" |
|
771 |
! |
|
772 |
||
773 |
clearView |
|
774 |
super clearView. |
|
775 |
sketchPainter notNil ifTrue:[ |
|
776 |
sketchPainter redrawInTargetView |
|
777 |
]. |
|
778 |
||
779 |
"Created: / 16-01-2008 / 17:46:08 / cg" |
|
780 |
! |
|
781 |
||
2248 | 782 |
useSketchFile:aFilename |
2443 | 783 |
"a little neat goody: allow for a tablet-sketch file (WALTROP digital notepad) |
784 |
to be used as a background of the UIPainter window. This allows for sketches to |
|
785 |
be drawn, shown in the UIPainter, and then used as a placement hint (manual placement) |
|
786 |
for the user. Not a high-tech solution, but helped a lot, when we protoyped GUIs." |
|
787 |
||
2248 | 788 |
|mime sketchPainterClass| |
789 |
||
790 |
mime := aFilename asFilename mimeTypeFromName. |
|
791 |
mime isNil ifTrue:[ |
|
792 |
mime := aFilename asFilename mimeTypeOfContents. |
|
793 |
]. |
|
794 |
||
795 |
mime notNil ifTrue:[ |
|
2278
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
796 |
(mime startsWith:'image') ifTrue:[ |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
797 |
self viewBackground:(ImageReader fromFile:aFilename). |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
798 |
^ self. |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
799 |
]. |
2444 | 800 |
mime = 'application/x-waltop-digital-notepad' ifTrue:[ |
801 |
sketchPainterClass := TOPFileDrawer. |
|
802 |
]. |
|
2248 | 803 |
]. |
804 |
sketchPainterClass isNil ifTrue:[ |
|
2444 | 805 |
self error:'Unsupported sketch file format' |
2248 | 806 |
]. |
807 |
||
808 |
sketchPainter := sketchPainterClass new. |
|
2244 | 809 |
sketchPainter targetView:self. |
810 |
sketchPainter readFile:aFilename. |
|
811 |
sketchPainter ajustSketch. |
|
812 |
self invalidate. |
|
813 |
||
814 |
"Created: / 16-01-2008 / 17:46:26 / cg" |
|
815 |
! ! |
|
816 |
||
361 | 817 |
!UIPainterView methodsFor:'event handling'! |
818 |
||
819 |
keyPress:key x:x y:y view:aView |
|
376 | 820 |
"a delegated keyEvent from aView" |
821 |
||
361 | 822 |
self keyPress:key x:x y:y |
823 |
||
376 | 824 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 825 |
! |
826 |
||
827 |
keyRelease:key x:x y:y view:aView |
|
376 | 828 |
"a delegated keyEvent from aView" |
829 |
||
361 | 830 |
self keyRelease:key x:x y:y |
831 |
||
376 | 832 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 833 |
! |
834 |
||
835 |
sizeChanged:how |
|
836 |
||
1834 | 837 |
super sizeChanged:how. |
754 | 838 |
|
839 |
self layoutChanged |
|
361 | 840 |
! ! |
841 |
||
78 | 842 |
!UIPainterView methodsFor:'generating output'! |
843 |
||
352 | 844 |
aspectMethods |
845 |
"extract a list of aspect methods - for browsing" |
|
846 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
847 |
|cls methods| |
352 | 848 |
|
849 |
className isNil ifTrue:[ |
|
1834 | 850 |
self warn:'No class defined !!'. |
851 |
^ #() |
|
352 | 852 |
]. |
853 |
||
854 |
cls := self resolveName:className. |
|
855 |
methods := IdentitySet new. |
|
856 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
857 |
self aspectSelectorsAndTypesDo: |
1834 | 858 |
[:selector :typeSymbol | |
859 |
|skip| |
|
860 |
||
861 |
(cls includesSelector:selector) ifTrue:[ |
|
862 |
||
863 |
skip := false. |
|
864 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
865 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
866 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
867 |
]. |
|
868 |
]. |
|
869 |
skip ifFalse:[ |
|
870 |
methods add:(cls compiledMethodAt:selector) |
|
871 |
]. |
|
872 |
] |
|
873 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
874 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
875 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
876 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
877 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
878 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
879 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
880 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
881 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
882 |
"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
|
883 |
|
1726 | 884 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
885 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
886 |
className isNil ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
887 |
self warn:'No class defined !!'. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
888 |
^ self |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
889 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
890 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
891 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
892 |
|
352 | 893 |
treeView propertiesDo:[:aProp| |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
894 |
|selector| |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
895 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
896 |
(selector := aProp model) notNil ifTrue:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
897 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
898 |
aTwoArgBlock value:(selector asSymbol) value:#modelAspect |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
899 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
900 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
901 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
902 |
(selector := aProp menu) notNil ifTrue:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
903 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
904 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
905 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
906 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
907 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
908 |
(aProp spec aspectSelectors) do:[:aSel | |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
909 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
910 |
aTwoArgBlock value:(aSel asSymbol) value:#channelAspect |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
911 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
912 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
913 |
aProp spec actionSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
914 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
915 |
aTwoArgBlock value:(aSel asSymbol) value:#actionSelector |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
916 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
917 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
918 |
aProp spec valueSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
919 |
(aSel isString or:[aSel isSymbol]) ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
920 |
aTwoArgBlock value:(aSel asSymbol) value:#valueSelector |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
921 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
922 |
] |
352 | 923 |
]. |
924 |
||
925 |
protoSpec := treeView canvasSpec. |
|
926 |
||
927 |
(selector := protoSpec menu) notNil ifTrue:[ |
|
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
928 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
929 |
aTwoArgBlock value:(selector asSymbol) value:#menu |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
930 |
]. |
352 | 931 |
]. |
932 |
! |
|
933 |
||
60 | 934 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 935 |
|selector args showIt codeStream alreadyInSuperclass numArgs method| |
288 | 936 |
|
937 |
selector := aspect asSymbol. |
|
141 | 938 |
|
288 | 939 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
940 |
||
568 | 941 |
numArgs := selector numArgs. |
942 |
method := aspect. |
|
943 |
||
944 |
numArgs == 1 ifTrue:[ |
|
2244 | 945 |
args := 'anArgument'. |
2295 | 946 |
showIt := ''' , anArgument printString , ''...''.'. |
1834 | 947 |
] ifFalse:[ |
2244 | 948 |
args := ''. |
949 |
showIt := ' ...''.'. |
|
950 |
||
951 |
numArgs ~~ 0 ifTrue:[ |
|
952 |
method := ''. |
|
953 |
||
954 |
selector keywords keysAndValuesDo:[:i :key| |
|
955 |
method := method, key, 'arg', i printString, ' ' |
|
956 |
] |
|
957 |
] |
|
149 | 958 |
]. |
2244 | 959 |
codeStream := WriteStream on:(String new:100). |
960 |
codeStream |
|
961 |
nextPutLine:('!!',targetClass name,' methodsFor:''actions''!!'); |
|
962 |
nextPutLine:(method,args); |
|
963 |
nextPutLine:' <resource: #uiCallback>'; |
|
964 |
cr. |
|
965 |
||
966 |
self class generateCommentedCode ifTrue:[ |
|
967 |
codeStream |
|
2295 | 968 |
nextPutAll:' "automatically generated by UIPainter..." |
2244 | 969 |
|
970 |
"*** the code below performs no action" |
|
971 |
"*** (except for some feedback on the Transcript)" |
|
972 |
"*** Please change as required and accept in the browser." |
|
973 |
"*** (and replace this comment by something more useful ;-)" |
|
974 |
||
975 |
'. |
|
976 |
||
977 |
alreadyInSuperclass ifTrue:[ |
|
978 |
codeStream |
|
979 |
nextPutLine:' "action for ' , aspect , ' is already provided in a superclass."'; |
|
980 |
nextPutLine:' "It may be redefined here..."'; |
|
981 |
cr. |
|
982 |
] ifFalse:[ |
|
983 |
codeStream |
|
984 |
nextPutLine:' "action to be defined here..."'; |
|
985 |
cr. |
|
986 |
]. |
|
987 |
]. |
|
988 |
||
989 |
codeStream |
|
990 |
nextPutAll:' Transcript showCR:self class name, '': '. |
|
288 | 991 |
|
992 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 993 |
codeStream |
994 |
nextPutAll:'inherited '. |
|
288 | 995 |
]. |
2244 | 996 |
codeStream |
997 |
nextPutAll:'action for '; |
|
998 |
nextPutAll:aspect; |
|
999 |
nextPutLine:showIt. |
|
288 | 1000 |
|
1001 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 1002 |
codeStream |
1003 |
nextPutAll:' super '; |
|
1004 |
nextPutAll:aspect; |
|
1005 |
nextPutAll:args; |
|
1006 |
nextPutLine:'.'. |
|
288 | 1007 |
]. |
1008 |
||
2244 | 1009 |
codeStream |
1010 |
nextPutLine:'!! !!'; cr. |
|
1011 |
||
1012 |
^ codeStream contents. |
|
1013 |
||
1014 |
"Modified: / 12-01-2008 / 10:21:52 / cg" |
|
60 | 1015 |
! |
1016 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1017 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1018 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1019 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1020 |
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
|
1021 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1022 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1023 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1024 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1025 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1026 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1027 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1028 |
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
|
1029 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1030 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1031 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1032 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1033 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1034 |
cls isNil ifTrue:[ |
2024 | 1035 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1036 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1037 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1038 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1039 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1040 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1041 |
treeView propertiesDo:[:aProp| |
2024 | 1042 |
|modelSelector| |
1043 |
||
1044 |
protoSpec := aProp spec. |
|
1045 |
||
1046 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
1047 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
1048 |
do:[:aSel| |
|
1049 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1050 |
skip := false. |
|
1051 |
||
1052 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
1053 |
skip := SimpleDialog includesSelector:aSel |
|
1054 |
]. |
|
1055 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
1056 |
skip := true. |
|
1057 |
]. |
|
1058 |
||
1059 |
skip ifFalse:[ |
|
1060 |
"/ kludge .. |
|
1061 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
1062 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
1063 |
ifTrue:[ |
|
1064 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1065 |
] ifFalse:[ |
|
1066 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
1067 |
]. |
|
1068 |
codePieces add:thisCode. |
|
1069 |
definedMethodSelectors add:aSel. |
|
1070 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1071 |
] ifTrue:[ |
|
1072 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
1073 |
]. |
|
1074 |
]. |
|
1075 |
]. |
|
1076 |
]. |
|
1077 |
||
1078 |
"/ for each aspect, generate getter (if not yet implemented) |
|
1079 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
1080 |
do:[:aSel| |
|
1081 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1082 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1083 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
1084 |
codePieces add:thisCode. |
|
1085 |
definedMethodSelectors add:aSel. |
|
1086 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1087 |
] |
|
1088 |
] |
|
1089 |
]. |
|
1090 |
||
1091 |
"/ exported aspects - need setter methods |
|
1092 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
|
1093 |
self generateCodeFrom:exportSels in:cls |
|
1094 |
do:[:aSel| |
|
1095 |
|aspect| |
|
1096 |
||
1097 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1098 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1099 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
|
1100 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
|
1101 |
codePieces add:thisCode. |
|
1102 |
definedMethodSelectors add:aSel. |
|
1103 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
1104 |
] |
|
1105 |
] |
|
1106 |
]. |
|
1107 |
||
1108 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
1109 |
do:[:aSel| |
|
1110 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1111 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1112 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1113 |
codePieces add:thisCode. |
|
1114 |
definedMethodSelectors add:aSel. |
|
1115 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
1116 |
] |
|
1117 |
] |
|
1118 |
]. |
|
1119 |
||
1120 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
1121 |
do:[:aSel| |
|
1122 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1123 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1124 |
"/ uppercase: - assume its a globals name. |
|
1125 |
aSel isUppercaseFirst ifFalse:[ |
|
1126 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
1127 |
codePieces add:thisCode. |
|
1128 |
definedMethodSelectors add:aSel. |
|
1129 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1130 |
] |
|
1131 |
] |
|
1132 |
] |
|
1133 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1134 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1135 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1136 |
AspectsAsInstances ifTrue:[ |
2024 | 1137 |
iVars := cls instVarNames asOrderedCollection. |
1138 |
definedMethodSelectors do:[:ivar | |
|
1139 |
(iVars includes:ivar) ifFalse:[ |
|
1140 |
iVars add:ivar |
|
1141 |
] |
|
1142 |
]. |
|
1143 |
iVars := iVars asArray. |
|
1144 |
t := cls shallowCopy. |
|
1145 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
1146 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1147 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1148 |
|
1834 | 1149 |
^ String |
2024 | 1150 |
streamContents: |
1151 |
[:codeStream | |
|
1152 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
1153 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1154 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1155 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1156 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1157 |
|
60 | 1158 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 1159 |
|modelClass modelValueString modelValue modelGen codeStream| |
134 | 1160 |
|
149 | 1161 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1162 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1163 |
modelValueString notNil ifTrue:[ |
2244 | 1164 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1165 |
] ifFalse:[ |
2244 | 1166 |
modelValue := protoSpec defaultModelValueFor:aspect. |
1167 |
modelValue isNil ifTrue:[ |
|
1168 |
modelGen := modelClass name , ' new' |
|
1169 |
] ifFalse:[ |
|
1170 |
modelGen := modelValue storeString , ' asValue' |
|
1171 |
]. |
|
352 | 1172 |
|
1173 |
]. |
|
134 | 1174 |
|
2244 | 1175 |
codeStream := WriteStream on:(String new:100). |
1176 |
codeStream |
|
1177 |
nextPutLine:('!!' , targetClass name , ' methodsFor:''aspects''!!'); |
|
1178 |
nextPutLine:aspect; |
|
1179 |
nextPutLine:' <resource: #uiAspect>'; |
|
1180 |
cr. |
|
1181 |
||
1182 |
self class generateCommentedCode ifTrue:[ |
|
1183 |
codeStream |
|
1184 |
nextPutAll:' "automatically generated by UIPainter ..." |
|
1185 |
||
1186 |
"*** the code below creates a default model when invoked." |
|
1187 |
"*** (which may not be the one you wanted)" |
|
1188 |
"*** Please change as required and accept it in the browser." |
|
1189 |
"*** (and replace this comment by something more useful ;-)" |
|
1190 |
||
1191 |
'. |
|
1192 |
]. |
|
1474 | 1193 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1194 |
AspectsAsInstances ifTrue:[ |
2244 | 1195 |
codeStream |
1196 |
nextPutLine:(' ',aspect,' isNil ifTrue:['); |
|
1197 |
nextPutLine:(' ',aspect,' := ',modelGen,'.'). |
|
1198 |
||
1199 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1200 |
self class generateCommentedCode ifTrue:[ |
|
1201 |
codeStream |
|
1202 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1203 |
]. |
|
1204 |
codeStream |
|
1205 |
nextPutLine:'"/ ',aspect,' addDependent:self.'; |
|
1206 |
nextPutLine:'"/ ',aspect,' onChangeSend:#',aspect,'Changed to:self.'. |
|
1207 |
]. |
|
1208 |
codeStream |
|
1209 |
nextPutLine:' ].'; |
|
1210 |
nextPutLine:' ^ ',aspect,'.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1211 |
] ifFalse:[ |
2244 | 1212 |
codeStream |
1213 |
nextPutLine:(' |holder|'); |
|
1214 |
cr; |
|
1215 |
nextPutLine:(' (holder := builder bindingAt:#',aspect,') isNil ifTrue:['); |
|
1216 |
nextPutLine:(' holder := ',modelGen,'.'); |
|
1217 |
nextPutLine:(' builder aspectAt:#',aspect,' put:holder.'). |
|
1218 |
||
1219 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1220 |
self class generateCommentedCode ifTrue:[ |
|
1221 |
codeStream |
|
1222 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1223 |
]. |
|
1224 |
codeStream |
|
1225 |
nextPutLine:'"/ holder addDependent:self.'; |
|
1226 |
nextPutLine:'"/ holder onChangeSend:#',aspect,'Changed to:self.'. |
|
1227 |
]. |
|
1228 |
codeStream |
|
1229 |
nextPutLine:' ].'; |
|
1230 |
nextPutLine:' ^ holder.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1231 |
]. |
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1232 |
|
2244 | 1233 |
codeStream |
1234 |
nextPutLine:'!! !!'; cr. |
|
1235 |
"/ self halt. |
|
1236 |
^ codeStream contents. |
|
1237 |
||
1238 |
"Modified: / 22-09-1999 / 12:33:47 / stefan" |
|
1239 |
"Modified: / 12-01-2008 / 10:21:43 / cg" |
|
60 | 1240 |
! |
1241 |
||
1358 | 1242 |
generateAspectSelectorsMethod |
1243 |
"generate aspectSelectors method. |
|
1244 |
Return a string ready to compile into the application class." |
|
1245 |
||
1246 |
|cls code spec| |
|
1247 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1248 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1249 |
cls isNil ifTrue:[ |
1834 | 1250 |
^ nil |
1358 | 1251 |
]. |