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