author | Claus Gittinger <cg@exept.de> |
Fri, 30 May 2008 14:25:31 +0200 | |
changeset 2348 | a9c60093561a |
parent 2333 | cd866952bf20 |
child 2358 | ba3ed08ea8dd |
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 |
||
698 | 257 |
|specs coll sel| |
258 |
||
259 |
sel := treeView selection. |
|
71 | 260 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
261 |
coll := self minClosedViewSetFor:(self selection). |
60 | 262 |
|
71 | 263 |
coll notNil ifTrue:[ |
776 | 264 |
"/ self select:nil. |
1870 | 265 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
266 |
self setClipboardObject:specs. |
|
776 | 267 |
"/ treeView selection: sel |
60 | 268 |
]. |
269 |
! |
|
270 |
||
723 | 271 |
deleteSelection |
1959 | 272 |
"delete the selection buffered" |
273 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
274 |
self deleteSelectionBuffered: true |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
275 |
! |
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
276 |
|
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
277 |
deleteSelectionBuffered: buffered |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
278 |
"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
|
279 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
280 |
|specs specsToRemove index oldSelection newSelection treeModel children size node| |
71 | 281 |
|
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
282 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
283 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
284 |
specsToRemove := self minClosedViewSetFor:(self selection). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
285 |
specsToRemove notEmptyOrNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
286 |
treeView canvasEventsDisabledDo:[ |
1870 | 287 |
treeModel := treeView model. |
288 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
289 |
||
290 |
oldSelection notNil ifTrue:[ |
|
291 |
children := oldSelection parent children. |
|
292 |
(size := children size) > 1 ifTrue:[ |
|
293 |
index := children identityIndexOf:oldSelection. |
|
294 |
size == index ifTrue:[ |
|
295 |
index := index - 1 |
|
296 |
]. |
|
297 |
newSelection := children at:index ifAbsent:1. |
|
298 |
] ifFalse:[ |
|
299 |
newSelection := oldSelection parent |
|
300 |
]. |
|
301 |
newSelection := treeModel indexOf:newSelection. |
|
302 |
] ifFalse:[ |
|
303 |
newSelection := 1 |
|
304 |
]. |
|
305 |
||
306 |
self hideSelection. |
|
307 |
selection := nil. |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
308 |
specs := specsToRemove collect:[:aView| self fullSpecFor:aView ]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
309 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
310 |
self withinTransaction:#cut objects:specsToRemove do:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
311 |
specsToRemove reverseDo:[:aView| |
1870 | 312 |
self createUndoRemove:aView. |
313 |
self remove:aView. |
|
314 |
] |
|
315 |
]. |
|
316 |
buffered ifTrue: [self setClipboardObject:specs]. |
|
317 |
treeView selection:nil. |
|
318 |
treeView selection:(Array with: newSelection). |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
319 |
(node := treeView selectedNode) notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
320 |
self setSelection:node contents view withRedraw:true. |
1870 | 321 |
] |
322 |
] |
|
698 | 323 |
] |
324 |
! |
|
325 |
||
723 | 326 |
deleteTotalSelection |
1959 | 327 |
"delete the selection" |
328 |
||
887
79a6e12e1d0f
after deleting a widget do select the neighbour then the parent (step 2)
tz
parents:
886
diff
changeset
|
329 |
self deleteSelectionBuffered: false |
60 | 330 |
! |
331 |
||
1832 | 332 |
getSelectedViewsAndSpecs |
333 |
"return an array filed with selected views and corresponding specs. |
|
1959 | 334 |
Nil if there is none." |
335 |
||
1832 | 336 |
|specs coll sel| |
337 |
||
338 |
sel := treeView selection. |
|
339 |
||
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
340 |
coll := self minClosedViewSetFor:(self selection). |
1832 | 341 |
|
342 |
coll isNil ifTrue:[^ nil]. |
|
343 |
||
344 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
345 |
^ Array with: coll with: specs |
|
346 |
! |
|
347 |
||
60 | 348 |
pasteBuffer |
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
349 |
"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
|
350 |
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
|
351 |
|
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
352 |
|sel clipboard| |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
353 |
|
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
354 |
clipboard := self getClipboardObject. |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
355 |
sel := self pasteSpecifications:clipboard keepLayout:(clipboard size > 1). |
2221 | 356 |
self changeSelectionAfterPasteOf:sel. |
89 | 357 |
! |
358 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
359 |
pasteKeepingPosition |
1834 | 360 |
"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
|
361 |
translate the layout as appropriate, to position the component |
1959 | 362 |
at the same absolute position (relative to topView) as before" |
363 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
364 |
|sel| |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
365 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
366 |
sel := self |
1872 | 367 |
pasteSpecifications:(self getClipboardObject) |
368 |
keepLayout:true |
|
369 |
keepPosition:true |
|
370 |
at:nil. |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
371 |
|
2221 | 372 |
self changeSelectionAfterPasteOf:sel. |
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
373 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
374 |
|
89 | 375 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
376 |
"add the specs to the object view; returns list of pasted widgets" |
278 | 377 |
|
378 |
^ self |
|
1959 | 379 |
pasteSpecifications:aSpecificationOrList |
380 |
keepLayout:keepLayout |
|
381 |
at:nil |
|
278 | 382 |
|
383 |
"Modified: 11.8.1997 / 01:00:35 / cg" |
|
384 |
! |
|
385 |
||
386 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
387 |
"add the specs to the object view; returns list of pasted widgets" |
1959 | 388 |
|
1834 | 389 |
^ self |
1959 | 390 |
pasteSpecifications:aSpecificationOrList |
391 |
keepLayout:keepLayout |
|
392 |
keepPosition:false |
|
393 |
at:aPointOrNil |
|
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
394 |
! |
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
395 |
|
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
396 |
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
397 |
"add the specs to the object view; returns list of pasted widgets" |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
398 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
399 |
|specsToPaste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
400 |
|
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
401 |
treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
402 |
|
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
403 |
containerToPasteInto := self singleSelection. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
404 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
405 |
self selection size > 0 ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
406 |
containerToPasteInto := self commonContainerOf:self selection |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
407 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
408 |
containerToPasteInto := self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
409 |
]. |
2221 | 410 |
"/ self selection:containerToPasteInto. |
1744
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
411 |
]. |
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
412 |
|
c59a91953b64
paste with no container selected: search for a good one
Claus Gittinger <cg@exept.de>
parents:
1733
diff
changeset
|
413 |
(self canPasteInto:containerToPasteInto) ifFalse:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
414 |
containerToPasteInto notNil ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
415 |
"/ search up parent list for something we can paste into |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
416 |
[containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[ |
2212 | 417 |
containerToPasteInto == self ifTrue:[ |
418 |
containerToPasteInto := nil |
|
419 |
] ifFalse:[ |
|
420 |
containerToPasteInto := containerToPasteInto container. |
|
421 |
]. |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
422 |
]. |
2221 | 423 |
"/ self selection:containerToPasteInto. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
424 |
]. |
1621
112670159075
cg: check if selection change is allowed BEFORE changing the
tm
parents:
1574
diff
changeset
|
425 |
]. |
1752 | 426 |
containerToPasteInto isNil ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
427 |
containerToPasteInto := self |
1752 | 428 |
]. |
60 | 429 |
|
2221 | 430 |
(self canPaste:aSpecificationOrList into:containerToPasteInto) |
431 |
ifFalse:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
432 |
Dialog warn:'Cannot paste into selected component (not a container ?)'. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
433 |
^ nil |
89 | 434 |
]. |
223 | 435 |
|
776 | 436 |
aSpecificationOrList isCollection ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
437 |
specsToPaste := aSpecificationOrList |
776 | 438 |
] ifFalse:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
439 |
specsToPaste := Array with:aSpecificationOrList |
776 | 440 |
]. |
2221 | 441 |
"/ self setClipboardObject:nil. |
776 | 442 |
|
443 |
newSel := OrderedCollection new. |
|
444 |
builder := UIBuilder new isEditing:true. |
|
445 |
||
446 |
className notNil ifTrue:[ |
|
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
447 |
builder applicationClass:(self resolveName:className) |
776 | 448 |
]. |
449 |
||
1338
3c1a528c50db
added paste-keeping-absolute-position function
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
450 |
(keepLayout not or:[keepPosition]) ifTrue:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
451 |
pasteOffset := 0@0. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
452 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
453 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
454 |
pasteOrigin := device translatePoint:0@0 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
455 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
456 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
457 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
458 |
aPointOrNil isNil ifTrue:[ |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
459 |
pasteOrigin := device translatePoint:(self sensor mousePoint) |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
460 |
fromView:nil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
461 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
462 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
463 |
pasteOrigin := device translatePoint:aPointOrNil |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
464 |
fromView:self |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
465 |
toView:containerToPasteInto. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
466 |
] |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
467 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
468 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
469 |
bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent) |
776 | 470 |
]. |
60 | 471 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
472 |
specsToPaste do:[:eachSpec| |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
473 |
|view newOrigin| |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
474 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
475 |
view := self addSpec:eachSpec builder:builder in:containerToPasteInto. |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
476 |
|
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
477 |
keepPosition ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
478 |
self moveObject:view to:(view origin + pasteOrigin). |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
479 |
] ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
480 |
keepLayout ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
481 |
(bounds containsPoint:pasteOrigin) ifFalse:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
482 |
newOrigin := pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
483 |
] ifTrue:[ |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
484 |
newOrigin := pasteOrigin + pasteOffset. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
485 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
486 |
self moveObject:view to:newOrigin. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
487 |
pasteOffset := pasteOffset + 4 |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
488 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
489 |
]. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
490 |
view realize. |
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
491 |
newSel add:view. |
776 | 492 |
]. |
60 | 493 |
|
776 | 494 |
self withinTransaction:#paste objects:newSel do:[ |
1878
6ae0cf83738f
Use #setClipboardText: instead of obsolete #setTextSelection:
Stefan Vogel <sv@exept.de>
parents:
1872
diff
changeset
|
495 |
undoHistory addUndoSelector:#undoCreate: |
1954 | 496 |
withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]). |
497 |
self undoHistoryChanged. |
|
776 | 498 |
]. |
60 | 499 |
|
776 | 500 |
self realizeAllSubViews. |
501 |
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
|
502 |
self elementChangedSize:containerToPasteInto. |
134 | 503 |
|
776 | 504 |
newSel size == 1 ifTrue:[newSel := newSel at:1]. |
223 | 505 |
^ newSel |
1500
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
506 |
|
36c0b4b268b8
use new translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
1494
diff
changeset
|
507 |
"Modified: / 10.10.2001 / 14:15:12 / cg" |
89 | 508 |
! |
509 |
||
2315 | 510 |
pasteWithLayout |
511 |
"add the objects in the paste-buffer to the object view" |
|
512 |
||
513 |
|sel| |
|
514 |
||
515 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. |
|
516 |
self changeSelectionAfterPasteOf:sel. |
|
517 |
! |
|
518 |
||
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
519 |
pasteWithoutLayout |
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
520 |
"add the objects in the paste-buffer to the object view" |
1959 | 521 |
|
223 | 522 |
|sel| |
523 |
||
2311
67811bdeb0f5
Support sorting of items in tree
Stefan Vogel <sv@exept.de>
parents:
2295
diff
changeset
|
524 |
sel := self pasteSpecifications:(self getClipboardObject) keepLayout:false. |
2221 | 525 |
self changeSelectionAfterPasteOf:sel. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
526 |
! |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
527 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
528 |
replaceSelectionBy:aNewSpec |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
529 |
"replace the selected widget by another one." |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
530 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
531 |
|specs coll index oldSelection newSelection treeModel children size node |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
532 |
container widgets builder newView property| |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
533 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
534 |
treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
535 |
self assert:(self selection size == 1). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
536 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
537 |
treeModel := treeView model. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
538 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
539 |
property := oldSelection contents. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
540 |
property spec:aNewSpec. |
2333 | 541 |
|
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
542 |
self rebuildView:(property view) fromSpec:aNewSpec withBuilder:nil forceNewView:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
543 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
544 |
"/ p := self propertyOfView:aView) |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
545 |
"/ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
546 |
"/ builder := UIBuilder new isEditing:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
547 |
"/ newView := aNewSpec buildViewWithLayoutFor:builder in:(container contents view). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
548 |
self halt. |
2265 | 549 |
"/ ^self. |
2257
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
550 |
self deleteSelectionBuffered:false. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
551 |
widgets := self pasteSpecifications:(Array with:aNewSpec) keepLayout:false. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
552 |
self select:widgets. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
553 |
^ widgets. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
554 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
555 |
treeView canvasEventsDisabledDo:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
556 |
treeModel := treeView model. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
557 |
oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
558 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
559 |
oldSelection notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
560 |
children := oldSelection parent children. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
561 |
(size := children size) > 1 ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
562 |
index := children identityIndexOf:oldSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
563 |
size == index ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
564 |
index := index - 1 |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
565 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
566 |
newSelection := children at:index ifAbsent:1. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
567 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
568 |
newSelection := oldSelection parent |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
569 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
570 |
newSelection := treeModel indexOf:newSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
571 |
] ifFalse:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
572 |
newSelection := 1 |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
573 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
574 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
575 |
self hideSelection. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
576 |
selection := nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
577 |
specs := coll collect:[:aView| self fullSpecFor:aView ]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
578 |
|
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
579 |
self withinTransaction:#cut objects:coll do:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
580 |
coll reverseDo:[:aView| |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
581 |
self createUndoRemove:aView. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
582 |
self remove:aView. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
583 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
584 |
]. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
585 |
treeView selection:nil. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
586 |
treeView selection:(Array with: newSelection). |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
587 |
(node := treeView selectedNode) notNil ifTrue:[ |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
588 |
self setSelection:node contents view withRedraw:true. |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
589 |
] |
badd429a2a2a
code beautification; reasonable methodNames;
Claus Gittinger <cg@exept.de>
parents:
2250
diff
changeset
|
590 |
] |
60 | 591 |
! ! |
592 |
||
593 |
!UIPainterView methodsFor:'drag & drop'! |
|
594 |
||
2116 | 595 |
canDrop:aDropContext |
596 |
^ self canDropObjects:aDropContext dropObjects |
|
597 |
||
598 |
"Created: / 13-10-2006 / 17:46:11 / cg" |
|
599 |
! |
|
600 |
||
601 |
canDropObjects:aCollectionOfDropObjects |
|
1914 | 602 |
"returns true if something can be dropped" |
603 |
||
2112 | 604 |
^ (aCollectionOfDropObjects size == 1 |
605 |
and:[ self enabled |
|
606 |
and:[ self numberOfSelections <= 1 |
|
607 |
and:[ aCollectionOfDropObjects first theObject isKindOf:UISpecification ]]]) |
|
608 |
||
2116 | 609 |
"Created: / 13-10-2006 / 16:09:24 / cg" |
223 | 610 |
! |
611 |
||
285 | 612 |
canPaste |
1914 | 613 |
"returns true if there is something which can be pasted in the clipboard" |
614 |
||
1872 | 615 |
^ self canPaste:(self getClipboardObject) |
285 | 616 |
! |
617 |
||
223 | 618 |
canPaste:something |
1914 | 619 |
"returns true if something could be pasted" |
620 |
||
2221 | 621 |
^ self canPaste:something into:(self singleSelection) |
622 |
! |
|
623 |
||
624 |
canPaste:something into:containerToPasteInto |
|
625 |
"returns true if something could be pasted" |
|
626 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
627 |
(self enabled) ifFalse:[ |
1914 | 628 |
^ false |
223 | 629 |
]. |
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
630 |
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
|
631 |
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
|
632 |
^ 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
|
633 |
]. |
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
634 |
|
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
635 |
(something isKindOf:UISpecification) ifFalse:[ |
1914 | 636 |
^ false |
223 | 637 |
]. |
638 |
||
2276
485bda17023f
more changes to allow for non-class/selector (i.e. spec-only) use
Claus Gittinger <cg@exept.de>
parents:
2265
diff
changeset
|
639 |
^ self canPasteInto:containerToPasteInto |
223 | 640 |
! |
641 |
||
642 |
canPasteInto:aView |
|
1914 | 643 |
"return true, if I can paste into a view" |
644 |
||
285 | 645 |
|prop| |
60 | 646 |
|
1870 | 647 |
aView isNil ifTrue:[ ^ false ]. |
2265 | 648 |
aView == self ifTrue:[ ^ true ]. |
1870 | 649 |
|
650 |
(prop := self propertyOfView:aView) notNil ifTrue:[ |
|
651 |
^ prop spec class supportsSubComponents |
|
89 | 652 |
]. |
1870 | 653 |
^ aView specClass supportsSubComponents. |
60 | 654 |
! |
655 |
||
2116 | 656 |
dropObjects:aCollectionOfDropObjects at:aPoint |
1833 | 657 |
|spec newSel oldSel dragOffset widg doit| |
658 |
||
659 |
doit := true. |
|
288 | 660 |
self selection notNil ifTrue:[ |
1953 | 661 |
oldSel := self singleSelection. |
662 |
||
663 |
"/ search selections hierarchy for a widget into which we can paste |
|
664 |
widg := oldSel. |
|
665 |
[widg isNil or:[self canPasteInto:widg]] whileFalse:[ |
|
666 |
widg notNil ifTrue:[ |
|
667 |
widg := widg container |
|
668 |
]. |
|
669 |
]. |
|
670 |
||
671 |
oldSel := nil. |
|
672 |
self setSelection:widg withRedraw:true. |
|
231 | 673 |
]. |
1953 | 674 |
spec := (aCollectionOfDropObjects at:1) theObject. |
1833 | 675 |
doit ifTrue:[ |
1953 | 676 |
dragOffset := DragAndDropManager dragOffsetQuerySignal query. |
677 |
newSel := self pasteSpecifications:spec keepLayout:false at:aPoint - dragOffset. |
|
678 |
||
679 |
self select:(oldSel ? newSel) |
|
1833 | 680 |
]. |
1060
0332a41de5c5
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
1058
diff
changeset
|
681 |
|
2116 | 682 |
"Modified: / 18-03-1999 / 18:29:43 / stefan" |
683 |
"Created: / 13-10-2006 / 16:09:27 / cg" |
|
60 | 684 |
! ! |
685 |
||
2244 | 686 |
!UIPainterView methodsFor:'drawing'! |
687 |
||
688 |
clearRectangle:visRect |
|
689 |
super clearRectangle:visRect. |
|
690 |
sketchPainter notNil ifTrue:[ |
|
691 |
sketchPainter redrawInTargetView |
|
692 |
]. |
|
693 |
||
694 |
"Created: / 16-01-2008 / 17:52:27 / cg" |
|
695 |
! |
|
696 |
||
697 |
clearView |
|
698 |
super clearView. |
|
699 |
sketchPainter notNil ifTrue:[ |
|
700 |
sketchPainter redrawInTargetView |
|
701 |
]. |
|
702 |
||
703 |
"Created: / 16-01-2008 / 17:46:08 / cg" |
|
704 |
! |
|
705 |
||
2248 | 706 |
useSketchFile:aFilename |
707 |
|mime sketchPainterClass| |
|
708 |
||
709 |
mime := aFilename asFilename mimeTypeFromName. |
|
710 |
mime isNil ifTrue:[ |
|
711 |
mime := aFilename asFilename mimeTypeOfContents. |
|
712 |
]. |
|
713 |
||
714 |
mime notNil ifTrue:[ |
|
715 |
mime = 'application/x-waltop-digital-notepad' ifTrue:[ |
|
716 |
sketchPainterClass := TOPFileDrawer. |
|
717 |
]. |
|
2278
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
718 |
(mime startsWith:'image') ifTrue:[ |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
719 |
self viewBackground:(ImageReader fromFile:aFilename). |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
720 |
^ self. |
8ff3bd6f0820
Allow to load background from image file #useSketchFile:
Stefan Vogel <sv@exept.de>
parents:
2276
diff
changeset
|
721 |
]. |
2248 | 722 |
]. |
723 |
sketchPainterClass isNil ifTrue:[ |
|
724 |
self error:'unsupported sketch file format' |
|
725 |
]. |
|
726 |
||
727 |
sketchPainter := sketchPainterClass new. |
|
2244 | 728 |
sketchPainter targetView:self. |
729 |
sketchPainter readFile:aFilename. |
|
730 |
sketchPainter ajustSketch. |
|
731 |
self invalidate. |
|
732 |
||
733 |
"Created: / 16-01-2008 / 17:46:26 / cg" |
|
734 |
! ! |
|
735 |
||
361 | 736 |
!UIPainterView methodsFor:'event handling'! |
737 |
||
738 |
keyPress:key x:x y:y view:aView |
|
376 | 739 |
"a delegated keyEvent from aView" |
740 |
||
361 | 741 |
self keyPress:key x:x y:y |
742 |
||
376 | 743 |
"Modified: / 31.10.1997 / 20:27:22 / cg" |
361 | 744 |
! |
745 |
||
746 |
keyRelease:key x:x y:y view:aView |
|
376 | 747 |
"a delegated keyEvent from aView" |
748 |
||
361 | 749 |
self keyRelease:key x:x y:y |
750 |
||
376 | 751 |
"Modified: / 31.10.1997 / 20:27:32 / cg" |
754 | 752 |
! |
753 |
||
754 |
sizeChanged:how |
|
755 |
||
1834 | 756 |
super sizeChanged:how. |
754 | 757 |
|
758 |
self layoutChanged |
|
361 | 759 |
! ! |
760 |
||
78 | 761 |
!UIPainterView methodsFor:'generating output'! |
762 |
||
352 | 763 |
aspectMethods |
764 |
"extract a list of aspect methods - for browsing" |
|
765 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
766 |
|cls methods| |
352 | 767 |
|
768 |
className isNil ifTrue:[ |
|
1834 | 769 |
self warn:'No class defined !!'. |
770 |
^ #() |
|
352 | 771 |
]. |
772 |
||
773 |
cls := self resolveName:className. |
|
774 |
methods := IdentitySet new. |
|
775 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
776 |
self aspectSelectorsAndTypesDo: |
1834 | 777 |
[:selector :typeSymbol | |
778 |
|skip| |
|
779 |
||
780 |
(cls includesSelector:selector) ifTrue:[ |
|
781 |
||
782 |
skip := false. |
|
783 |
(typeSymbol == #modelAspect) ifTrue:[ |
|
784 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
785 |
skip := SimpleDialog includesSelector:(selector asSymbol) |
|
786 |
]. |
|
787 |
]. |
|
788 |
skip ifFalse:[ |
|
789 |
methods add:(cls compiledMethodAt:selector) |
|
790 |
]. |
|
791 |
] |
|
792 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
793 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
794 |
^ methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
795 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
796 |
"Created: / 25.10.1997 / 18:58:25 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
797 |
"Modified: / 26.10.1997 / 15:06:18 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
798 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
799 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
800 |
aspectSelectorsAndTypesDo:aTwoArgBlock |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
801 |
"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
|
802 |
|
1726 | 803 |
|cls selector protoSpec| |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
804 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
805 |
className isNil ifTrue:[ |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
806 |
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
|
807 |
^ self |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
808 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
809 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
810 |
cls := self resolveName:className. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
811 |
|
352 | 812 |
treeView propertiesDo:[:aProp| |
2195
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
813 |
|selector| |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
814 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
815 |
(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
|
816 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
817 |
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
|
818 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
819 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
820 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
821 |
(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
|
822 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
823 |
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
|
824 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
825 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
826 |
|
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
827 |
(aProp spec aspectSelectors) do:[:aSel | |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
828 |
(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
|
829 |
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
|
830 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
831 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
832 |
aProp spec actionSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
833 |
(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
|
834 |
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
|
835 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
836 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
837 |
aProp spec valueSelectors do:[:aSel| |
2250
e65b8bf6224b
care for non-symbolic aspects (false)
Claus Gittinger <cg@exept.de>
parents:
2248
diff
changeset
|
838 |
(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
|
839 |
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
|
840 |
]. |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
841 |
] |
352 | 842 |
]. |
843 |
||
844 |
protoSpec := treeView canvasSpec. |
|
845 |
||
846 |
(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
|
847 |
selector isArray ifFalse:[ |
bb6de5f8fd03
Take care of true or false as pseudo-aspect-selectors
Stefan Vogel <sv@exept.de>
parents:
2191
diff
changeset
|
848 |
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
|
849 |
]. |
352 | 850 |
]. |
851 |
! |
|
852 |
||
60 | 853 |
generateActionMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 854 |
|selector args showIt codeStream alreadyInSuperclass numArgs method| |
288 | 855 |
|
856 |
selector := aspect asSymbol. |
|
141 | 857 |
|
288 | 858 |
alreadyInSuperclass := targetClass superclass canUnderstand:selector. |
859 |
||
568 | 860 |
numArgs := selector numArgs. |
861 |
method := aspect. |
|
862 |
||
863 |
numArgs == 1 ifTrue:[ |
|
2244 | 864 |
args := 'anArgument'. |
2295 | 865 |
showIt := ''' , anArgument printString , ''...''.'. |
1834 | 866 |
] ifFalse:[ |
2244 | 867 |
args := ''. |
868 |
showIt := ' ...''.'. |
|
869 |
||
870 |
numArgs ~~ 0 ifTrue:[ |
|
871 |
method := ''. |
|
872 |
||
873 |
selector keywords keysAndValuesDo:[:i :key| |
|
874 |
method := method, key, 'arg', i printString, ' ' |
|
875 |
] |
|
876 |
] |
|
149 | 877 |
]. |
2244 | 878 |
codeStream := WriteStream on:(String new:100). |
879 |
codeStream |
|
880 |
nextPutLine:('!!',targetClass name,' methodsFor:''actions''!!'); |
|
881 |
nextPutLine:(method,args); |
|
882 |
nextPutLine:' <resource: #uiCallback>'; |
|
883 |
cr. |
|
884 |
||
885 |
self class generateCommentedCode ifTrue:[ |
|
886 |
codeStream |
|
2295 | 887 |
nextPutAll:' "automatically generated by UIPainter..." |
2244 | 888 |
|
889 |
"*** the code below performs no action" |
|
890 |
"*** (except for some feedback on the Transcript)" |
|
891 |
"*** Please change as required and accept in the browser." |
|
892 |
"*** (and replace this comment by something more useful ;-)" |
|
893 |
||
894 |
'. |
|
895 |
||
896 |
alreadyInSuperclass ifTrue:[ |
|
897 |
codeStream |
|
898 |
nextPutLine:' "action for ' , aspect , ' is already provided in a superclass."'; |
|
899 |
nextPutLine:' "It may be redefined here..."'; |
|
900 |
cr. |
|
901 |
] ifFalse:[ |
|
902 |
codeStream |
|
903 |
nextPutLine:' "action to be defined here..."'; |
|
904 |
cr. |
|
905 |
]. |
|
906 |
]. |
|
907 |
||
908 |
codeStream |
|
909 |
nextPutAll:' Transcript showCR:self class name, '': '. |
|
288 | 910 |
|
911 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 912 |
codeStream |
913 |
nextPutAll:'inherited '. |
|
288 | 914 |
]. |
2244 | 915 |
codeStream |
916 |
nextPutAll:'action for '; |
|
917 |
nextPutAll:aspect; |
|
918 |
nextPutLine:showIt. |
|
288 | 919 |
|
920 |
alreadyInSuperclass ifTrue:[ |
|
2244 | 921 |
codeStream |
922 |
nextPutAll:' super '; |
|
923 |
nextPutAll:aspect; |
|
924 |
nextPutAll:args; |
|
925 |
nextPutLine:'.'. |
|
288 | 926 |
]. |
927 |
||
2244 | 928 |
codeStream |
929 |
nextPutLine:'!! !!'; cr. |
|
930 |
||
931 |
^ codeStream contents. |
|
932 |
||
933 |
"Modified: / 12-01-2008 / 10:21:52 / cg" |
|
60 | 934 |
! |
935 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
936 |
generateAspectMethodCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
937 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
938 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
939 |
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
|
940 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
941 |
^ self generateAspectMethodCodeFiltering:nil |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
942 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
943 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
944 |
generateAspectMethodCodeFiltering:aFilterOrEmpty |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
945 |
"generate aspect, action & menu methods |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
946 |
- but do not overwrite existing ones. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
947 |
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
|
948 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
949 |
|cls codePieces skip protoSpec thisCode |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
950 |
definedMethodSelectors iVars t exportSels| |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
951 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
952 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
953 |
cls isNil ifTrue:[ |
2024 | 954 |
^ nil |
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
955 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
956 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
957 |
codePieces := OrderedCollection new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
958 |
definedMethodSelectors := IdentitySet new. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
959 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
960 |
treeView propertiesDo:[:aProp| |
2024 | 961 |
|modelSelector| |
962 |
||
963 |
protoSpec := aProp spec. |
|
964 |
||
965 |
(modelSelector := aProp model) notNil ifTrue:[ |
|
966 |
self generateCodeFrom:(Array with:modelSelector) in:cls |
|
967 |
do:[:aSel| |
|
968 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
969 |
skip := false. |
|
970 |
||
971 |
(cls isSubclassOf:SimpleDialog) ifTrue:[ |
|
972 |
skip := SimpleDialog includesSelector:aSel |
|
973 |
]. |
|
974 |
(definedMethodSelectors includes:aSel) ifTrue:[ |
|
975 |
skip := true. |
|
976 |
]. |
|
977 |
||
978 |
skip ifFalse:[ |
|
979 |
"/ kludge .. |
|
980 |
"/ (protoSpec isKindOf:ActionButtonSpec) |
|
981 |
(protoSpec defaultModelIsCallBackMethodSelector:aSel) |
|
982 |
ifTrue:[ |
|
983 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
984 |
] ifFalse:[ |
|
985 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
986 |
]. |
|
987 |
codePieces add:thisCode. |
|
988 |
definedMethodSelectors add:aSel. |
|
989 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
990 |
] ifTrue:[ |
|
991 |
Transcript showCR:'*** no code generated for aspect: ' , aSel , ' (method already exists)' |
|
992 |
]. |
|
993 |
]. |
|
994 |
]. |
|
995 |
]. |
|
996 |
||
997 |
"/ for each aspect, generate getter (if not yet implemented) |
|
998 |
self generateCodeFrom:(aProp spec aspectSelectors) in:cls |
|
999 |
do:[:aSel| |
|
1000 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1001 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1002 |
thisCode := (self generateAspectMethodFor:aSel spec:protoSpec inClass:cls). |
|
1003 |
codePieces add:thisCode. |
|
1004 |
definedMethodSelectors add:aSel. |
|
1005 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1006 |
] |
|
1007 |
] |
|
1008 |
]. |
|
1009 |
||
1010 |
"/ exported aspects - need setter methods |
|
1011 |
exportSels := (treeView exportedAspects ? #()) collect:[:entry | (entry subAspect , ':') asSymbol]. |
|
1012 |
self generateCodeFrom:exportSels in:cls |
|
1013 |
do:[:aSel| |
|
1014 |
|aspect| |
|
1015 |
||
1016 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1017 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1018 |
aspect := (aSel copyWithoutLast:1) asSymbol. |
|
1019 |
thisCode := (self generateAspectSetMethodFor:aspect spec:protoSpec inClass:cls). |
|
1020 |
codePieces add:thisCode. |
|
1021 |
definedMethodSelectors add:aSel. |
|
1022 |
Transcript showCR:'export code generated for aspect: ' , aSel |
|
1023 |
] |
|
1024 |
] |
|
1025 |
]. |
|
1026 |
||
1027 |
self generateCodeFrom:(aProp spec actionSelectors) in:cls |
|
1028 |
do:[:aSel| |
|
1029 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1030 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1031 |
thisCode := (self generateActionMethodFor:aSel spec:protoSpec inClass:cls). |
|
1032 |
codePieces add:thisCode. |
|
1033 |
definedMethodSelectors add:aSel. |
|
1034 |
Transcript showCR:'action generated for aspect: ' , aSel |
|
1035 |
] |
|
1036 |
] |
|
1037 |
]. |
|
1038 |
||
1039 |
self generateCodeFrom:(aProp spec valueSelectors) in:cls |
|
1040 |
do:[:aSel| |
|
1041 |
(aFilterOrEmpty isNil or:[aFilterOrEmpty includes:aSel]) ifTrue:[ |
|
1042 |
(definedMethodSelectors includes:aSel) ifFalse:[ |
|
1043 |
"/ uppercase: - assume its a globals name. |
|
1044 |
aSel isUppercaseFirst ifFalse:[ |
|
1045 |
thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls). |
|
1046 |
codePieces add:thisCode. |
|
1047 |
definedMethodSelectors add:aSel. |
|
1048 |
Transcript showCR:'code generated for aspect: ' , aSel |
|
1049 |
] |
|
1050 |
] |
|
1051 |
] |
|
1052 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1053 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1054 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1055 |
AspectsAsInstances ifTrue:[ |
2024 | 1056 |
iVars := cls instVarNames asOrderedCollection. |
1057 |
definedMethodSelectors do:[:ivar | |
|
1058 |
(iVars includes:ivar) ifFalse:[ |
|
1059 |
iVars add:ivar |
|
1060 |
] |
|
1061 |
]. |
|
1062 |
iVars := iVars asArray. |
|
1063 |
t := cls shallowCopy. |
|
1064 |
t setInstanceVariableString:iVars asStringCollection asString. |
|
1065 |
codePieces addFirst:(t definition , '!!\' withCRs). |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1066 |
]. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1067 |
|
1834 | 1068 |
^ String |
2024 | 1069 |
streamContents: |
1070 |
[:codeStream | |
|
1071 |
codePieces do:[:eachPiece | codeStream nextPutAll:eachPiece]. |
|
1072 |
]. |
|
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1073 |
|
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1074 |
"Modified: / 29.7.1998 / 12:21:19 / cg" |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1075 |
! |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1076 |
|
60 | 1077 |
generateAspectMethodFor:aspect spec:protoSpec inClass:targetClass |
2244 | 1078 |
|modelClass modelValueString modelValue modelGen codeStream| |
134 | 1079 |
|
149 | 1080 |
modelClass := protoSpec defaultModelClassFor:aspect. |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1081 |
modelValueString := protoSpec defaultModelValueStringFor:aspect. |
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1082 |
modelValueString notNil ifTrue:[ |
2244 | 1083 |
modelGen := modelValueString |
1257
acb8c0a58ef3
dataSPec defaultValue when generating aspects
Claus Gittinger <cg@exept.de>
parents:
1252
diff
changeset
|
1084 |
] ifFalse:[ |
2244 | 1085 |
modelValue := protoSpec defaultModelValueFor:aspect. |
1086 |
modelValue isNil ifTrue:[ |
|
1087 |
modelGen := modelClass name , ' new' |
|
1088 |
] ifFalse:[ |
|
1089 |
modelGen := modelValue storeString , ' asValue' |
|
1090 |
]. |
|
352 | 1091 |
|
1092 |
]. |
|
134 | 1093 |
|
2244 | 1094 |
codeStream := WriteStream on:(String new:100). |
1095 |
codeStream |
|
1096 |
nextPutLine:('!!' , targetClass name , ' methodsFor:''aspects''!!'); |
|
1097 |
nextPutLine:aspect; |
|
1098 |
nextPutLine:' <resource: #uiAspect>'; |
|
1099 |
cr. |
|
1100 |
||
1101 |
self class generateCommentedCode ifTrue:[ |
|
1102 |
codeStream |
|
1103 |
nextPutAll:' "automatically generated by UIPainter ..." |
|
1104 |
||
1105 |
"*** the code below creates a default model when invoked." |
|
1106 |
"*** (which may not be the one you wanted)" |
|
1107 |
"*** Please change as required and accept it in the browser." |
|
1108 |
"*** (and replace this comment by something more useful ;-)" |
|
1109 |
||
1110 |
'. |
|
1111 |
]. |
|
1474 | 1112 |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1113 |
AspectsAsInstances ifTrue:[ |
2244 | 1114 |
codeStream |
1115 |
nextPutLine:(' ',aspect,' isNil ifTrue:['); |
|
1116 |
nextPutLine:(' ',aspect,' := ',modelGen,'.'). |
|
1117 |
||
1118 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1119 |
self class generateCommentedCode ifTrue:[ |
|
1120 |
codeStream |
|
1121 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1122 |
]. |
|
1123 |
codeStream |
|
1124 |
nextPutLine:'"/ ',aspect,' addDependent:self.'; |
|
1125 |
nextPutLine:'"/ ',aspect,' onChangeSend:#',aspect,'Changed to:self.'. |
|
1126 |
]. |
|
1127 |
codeStream |
|
1128 |
nextPutLine:' ].'; |
|
1129 |
nextPutLine:' ^ ',aspect,'.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1130 |
] ifFalse:[ |
2244 | 1131 |
codeStream |
1132 |
nextPutLine:(' |holder|'); |
|
1133 |
cr; |
|
1134 |
nextPutLine:(' (holder := builder bindingAt:#',aspect,') isNil ifTrue:['); |
|
1135 |
nextPutLine:(' holder := ',modelGen,'.'); |
|
1136 |
nextPutLine:(' builder aspectAt:#',aspect,' put:holder.'). |
|
1137 |
||
1138 |
modelClass ~~ TriggerValue ifTrue:[ |
|
1139 |
self class generateCommentedCode ifTrue:[ |
|
1140 |
codeStream |
|
1141 |
nextPutLine:'"/ if your app needs to be notified of changes, uncomment one of the lines below:'. |
|
1142 |
]. |
|
1143 |
codeStream |
|
1144 |
nextPutLine:'"/ holder addDependent:self.'; |
|
1145 |
nextPutLine:'"/ holder onChangeSend:#',aspect,'Changed to:self.'. |
|
1146 |
]. |
|
1147 |
codeStream |
|
1148 |
nextPutLine:' ].'; |
|
1149 |
nextPutLine:' ^ holder.'. |
|
925
e6ddd46581c3
added option of generating aspects as instvars.
Claus Gittinger <cg@exept.de>
parents:
887
diff
changeset
|
1150 |
]. |
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1151 |
|
2244 | 1152 |
codeStream |
1153 |
nextPutLine:'!! !!'; cr. |
|
1154 |
"/ self halt. |
|
1155 |
^ codeStream contents. |
|
1156 |
||
1157 |
"Modified: / 22-09-1999 / 12:33:47 / stefan" |
|
1158 |
"Modified: / 12-01-2008 / 10:21:43 / cg" |
|
60 | 1159 |
! |
1160 |
||
1358 | 1161 |
generateAspectSelectorsMethod |
1162 |
"generate aspectSelectors method. |
|
1163 |
Return a string ready to compile into the application class." |
|
1164 |
||
1165 |
|cls code spec| |
|
1166 |
||
1683
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1167 |
cls := self targetClass. |
f95658463570
added selective aspect method generation.
Claus Gittinger <cg@exept.de>
parents:
1671
diff
changeset
|
1168 |
cls isNil ifTrue:[ |
1834 | 1169 |
^ nil |
1358 | 1170 |
]. |
1171 |
||
1172 |
spec := treeView exportedAspects. |
|
1173 |
spec size == 0 ifTrue:[^ nil]. |
|
1174 |
||
1175 |
"/ make it an array ... |
|
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1176 |
spec := spec collect:[:entry | |subAspect type| |
1834 | 1177 |
subAspect := entry subAspect asSymbol. |
1178 |
(type := entry type) isNil ifTrue:[ |
|
1179 |
subAspect |
|
1180 |
] ifFalse:[ |
|
1181 |
Array with:subAspect with:type asSymbol |
|
1182 |
]. |
|
1183 |
]. |
|
1358 | 1184 |
spec := spec asArray. |
1185 |
||
1186 |
code := '!!' , cls name , ' class methodsFor:''plugIn spec''!!\\' . |
|
1187 |
||
1188 |
code := code , 'aspectSelectors |
|
1189 |
"This resource specification was automatically generated |
|
1190 |
by the UIPainter of ST/X." |
|
1191 |
||
1192 |
"Do not manually edit this. If it is corrupted, |
|
1193 |
the UIPainter may not be able to read the specification." |
|
1194 |
||
1195 |
"Return a description of exported aspects; |
|
1196 |
these can be connected to aspects of an embedding application |
|
1197 |
(if this app is embedded in a subCanvas)." |
|
1198 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1199 |
^ #(\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1200 |
spec do:[:el | code := code , (' ' , el storeString , '\') ]. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1201 |
code := code , ' ).\'. |
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1202 |
code := code , '\!!\'. |
1358 | 1203 |
code := code withCRs. |
1204 |
^ code |
|
1205 |
||
1362
b710bba663cb
fixed generateAspectSelectors code generator
Claus Gittinger <cg@exept.de>
parents:
1361
diff
changeset
|
1206 |
"Modified: / 18.2.2000 / 02:08:34 / cg" |
1358 | 1207 |
! |
1208 |
||
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1209 |
generateAspectSetMethodFor:aspect spec:protoSpec inClass:targetClass |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1210 |
|code| |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1211 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1212 |
code := '!!' , targetClass name , ' methodsFor:''aspects - exported''!!\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1213 |
aspect , ':something\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1214 |
' "automatically generated by UIPainter ..."\\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1215 |
' "This method is used when I am embedded as subApplication,"\' , |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1216 |
' "and the mainApp wants to connect its aspects to mine."\'. |
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1217 |
|
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1218 |
AspectsAsInstances ifTrue:[ |
1834 | 1219 |
code := (code , '\' , |
1220 |
'"/ ' , aspect , ' notNil ifTrue:[\' , |
|
1221 |
'"/ ' , aspect , ' removeDependent:self.\' , |
|
1222 |
'"/ ].\' , |
|
1223 |
' ' , aspect ,' := something.\' , |
|
1224 |
'"/ ' , aspect ,' notNil ifTrue:[\' , |
|
1225 |
'"/ ' , aspect , ' addDependent:self.\' , |
|
1226 |
'"/ ].\' , |
|
1227 |
' ^ self.\' , |
|
1228 |
'!! !!\\') |
|
1361
9020214f03e6
generate aspect-setters for exported aspects
Claus Gittinger <cg@exept.de>
parents:
1358
diff
changeset
|
1229 |
] ifFalse:[ |
1834 | 1230 |
code := (code , '\' , |
1231 |
'"/ |holder|\' , |
|
1232 |
'\' , |
|
1233 |
'"/ (holder := builder bindingAt:#' , aspect , ') notNil ifTrue:[\' , |
|
1234 |
'"/ holder removeDependent:self.\' , |
|
1235 |
'"/ ].\' , |
|
1236 |
' builder aspectAt:#' , aspect , ' put:something.\', |
|
1237 |
'"/ something notNil ifTrue:[\' , |
|
1238 |