author | Claus Gittinger <cg@exept.de> |
Thu, 04 Dec 2003 15:55:55 +0100 | |
changeset 1874 | 4bd4f25fdada |
parent 1870 | c0475972bf3e |
child 1967 | 815ac59338e1 |
permissions | -rw-r--r-- |
867 | 1 |
" |
896 | 2 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
867 | 3 |
All Rights Reserved |
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
15 |
||
16 |
||
1390
35f90684be49
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
1201
diff
changeset
|
17 |
"{ Package: 'stx:libview2' }" |
35f90684be49
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
1201
diff
changeset
|
18 |
|
867 | 19 |
ToolApplicationModel subclass:#ResourceSpecEditor |
896 | 20 |
instanceVariableNames:'specClass specSelector aspects modified hasSaved tabSelection' |
867 | 21 |
classVariableNames:'' |
22 |
poolDictionaries:'' |
|
23 |
category:'Interface-Framework' |
|
24 |
! |
|
25 |
||
26 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
27 |
||
28 |
copyright |
|
29 |
" |
|
896 | 30 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
867 | 31 |
All Rights Reserved |
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
||
41 |
||
42 |
||
43 |
||
44 |
! |
|
45 |
||
46 |
documentation |
|
47 |
" |
|
896 | 48 |
Abstract super class for the MenuEditor, HierarchicalListEditor, |
49 |
and the TabListEditor. |
|
50 |
It provides common behavior for initializing, loading, saving, and |
|
51 |
asking for modifications of the resource specs (#menu, #hierarchicalList, |
|
52 |
#tabList) for the concrete subclasses. |
|
53 |
||
54 |
[instance variables:] |
|
55 |
specClass <Symbol> class implementing the resource spec |
|
56 |
specSelector <Symbol> selector returning the resource spec |
|
57 |
aspects <IdentityDictionary> dictionary with the attributes of the resource spec |
|
58 |
modified <Boolean> flag whether the resource spec was modified |
|
59 |
hasSaved <Boolean> flag whether the resource spec was saved |
|
60 |
tabSelection <Integer> index of the tab selection |
|
61 |
||
62 |
[see also:] |
|
63 |
MenuEditor |
|
64 |
HierarchicalListEditor |
|
65 |
TabListEditor |
|
867 | 66 |
|
67 |
[author:] |
|
876 | 68 |
Thomas Zwick, eXept Software AG |
867 | 69 |
" |
70 |
! ! |
|
71 |
||
72 |
!ResourceSpecEditor class methodsFor:'instance creation'! |
|
73 |
||
74 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 75 |
"opens modal the Resource Spec Editor on aClass and aSelector" |
867 | 76 |
|
77 |
^self new openModalOnClass:aClass andSelector:aSelector |
|
78 |
||
79 |
! |
|
80 |
||
81 |
openOnClass:aClass andSelector:aSelector |
|
896 | 82 |
"opens the Resource Spec Editor on aClass and aSelector" |
867 | 83 |
|
84 |
^self new openOnClass:aClass andSelector:aSelector |
|
85 |
! ! |
|
86 |
||
87 |
!ResourceSpecEditor class methodsFor:'accessing'! |
|
88 |
||
89 |
codeGenerationComment |
|
896 | 90 |
"returns a comment for the method code generated by myself" |
867 | 91 |
|
92 |
^self codeGenerationCommentForClass: self |
|
93 |
||
94 |
||
95 |
||
96 |
||
97 |
! |
|
98 |
||
99 |
codeGenerationCommentForClass: aClass |
|
896 | 100 |
"returns a comment for the method code generated by aClass" |
867 | 101 |
|
102 |
^' "This resource specification was automatically generated\', |
|
103 |
' by the ', aClass name, ' of ST/X."\\', |
|
104 |
||
105 |
' "Do not manually edit this!! If it is corrupted,\', |
|
106 |
' the ', aClass name, ' may not be able to read the specification."' |
|
107 |
||
108 |
||
109 |
||
110 |
||
111 |
||
112 |
! |
|
113 |
||
114 |
resourceType |
|
896 | 115 |
"returns the type of resource of the method generated by the Resource Spec Editor; |
116 |
concrete subclasses has to reimplement this method" |
|
867 | 117 |
|
868 | 118 |
^self subclassResponsibility |
867 | 119 |
! ! |
120 |
||
121 |
!ResourceSpecEditor class methodsFor:'aspects'! |
|
122 |
||
123 |
aspects |
|
896 | 124 |
"returns the aspects for the attributes of the resource spec components; |
125 |
concrete subclasses might reimplement this method in order to return an array" |
|
867 | 126 |
|
127 |
^#() |
|
128 |
! ! |
|
129 |
||
896 | 130 |
!ResourceSpecEditor class methodsFor:'queries'! |
131 |
||
132 |
isVisualStartable |
|
1427 | 133 |
"return true, if this application can be started via #open. |
134 |
(to allow start of a change browser via double-click in the browser)" |
|
896 | 135 |
|
136 |
self == ResourceSpecEditor ifTrue:[^false]. |
|
137 |
^super isVisualStartable |
|
138 |
! ! |
|
139 |
||
876 | 140 |
!ResourceSpecEditor class methodsFor:'startup / release'! |
141 |
||
142 |
preSnapshot |
|
896 | 143 |
"before a snapshot; updates the channels, |
144 |
because the clipboard has removed" |
|
876 | 145 |
|
146 |
super preSnapshot. |
|
147 |
||
1090 | 148 |
instances notNil ifTrue:[ |
149 |
instances do:[:inst | |
|
150 |
inst updateChannels. |
|
1147 | 151 |
inst valueOfEnablingCommitButtons value: false. |
152 |
inst modifiedChannel value: false. |
|
1090 | 153 |
] |
876 | 154 |
] |
155 |
||
1090 | 156 |
"Modified: / 4.2.1999 / 15:32:17 / cg" |
876 | 157 |
! ! |
158 |
||
867 | 159 |
!ResourceSpecEditor methodsFor:'accessing'! |
160 |
||
161 |
modified |
|
889 | 162 |
"returns whether the resource spec was modified" |
867 | 163 |
|
164 |
^modified |
|
165 |
! |
|
166 |
||
167 |
modified: aBoolean |
|
896 | 168 |
"sets the resource spec modified as aBoolean" |
867 | 169 |
|
170 |
modified := aBoolean |
|
171 |
! |
|
172 |
||
173 |
specClass |
|
889 | 174 |
"returns the class where the resource spec is implemented" |
867 | 175 |
|
176 |
^specClass |
|
177 |
! |
|
178 |
||
179 |
specClass:aClass |
|
889 | 180 |
"sets the class (or name) where the resource spec is (or should be) implemented" |
867 | 181 |
|
896 | 182 |
aClass isClass ifTrue: [specClass := aClass name] |
183 |
ifFalse:[specClass := aClass asSymbol] |
|
867 | 184 |
! |
185 |
||
186 |
specSelector |
|
889 | 187 |
"returns the method selector of the resource spec" |
867 | 188 |
|
189 |
^specSelector |
|
190 |
||
191 |
! |
|
192 |
||
193 |
specSelector:aSelector |
|
889 | 194 |
"sets the method selector of the resource spec" |
867 | 195 |
|
196 |
specSelector := aSelector |
|
197 |
! ! |
|
198 |
||
199 |
!ResourceSpecEditor methodsFor:'aspects'! |
|
200 |
||
201 |
aspectFor:aKey |
|
889 | 202 |
"returns the aspect for a aKey or nil" |
867 | 203 |
|
204 |
^aspects at: aKey ifAbsent: [super aspectFor:aKey] |
|
205 |
||
206 |
! |
|
207 |
||
208 |
tabModel |
|
889 | 209 |
"returns the value holder for the tab selection" |
867 | 210 |
|
211 |
|holder| |
|
212 |
(holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
213 |
holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
214 |
builder aspectAt:#tabModel put:holder. |
|
215 |
]. |
|
216 |
^ holder |
|
217 |
! |
|
218 |
||
876 | 219 |
valueOfCanPaste |
1470 | 220 |
"returns whether the application can paste; as value holder" |
876 | 221 |
|
222 |
|holder| |
|
223 |
holder := super valueOfCanPaste. |
|
224 |
holder value: self class clipboard notNil. |
|
225 |
^ holder |
|
226 |
! |
|
227 |
||
867 | 228 |
valueOfEnableMovingIn |
1470 | 229 |
"returns whether the selected item can move into next item as child; as value holder" |
867 | 230 |
|
231 |
^builder booleanValueAspectFor: #valueOfEnableMovingIn |
|
1470 | 232 |
! |
867 | 233 |
|
1470 | 234 |
valueOfEnableMovingInAbove |
235 |
"returns whether the selected item can move into the previous item as child; |
|
236 |
as a value holder" |
|
867 | 237 |
|
1470 | 238 |
^builder booleanValueAspectFor: #valueOfEnableMovingInAbove |
867 | 239 |
! |
240 |
||
241 |
valueOfEnableMovingOut |
|
1470 | 242 |
"returns whether the selected item can move out from its parent item; as value holder" |
867 | 243 |
|
244 |
^builder booleanValueAspectFor: #valueOfEnableMovingOut |
|
245 |
! |
|
246 |
||
247 |
valueOfEnableMovingUpOrDown |
|
1470 | 248 |
"returns whether the selected item can move up or down; as value holder" |
867 | 249 |
|
250 |
^builder booleanValueAspectFor: #valueOfEnableMovingUpOrDown |
|
251 |
! ! |
|
252 |
||
253 |
!ResourceSpecEditor methodsFor:'building'! |
|
254 |
||
255 |
buildFromResourceSpec: aResourceSpec |
|
868 | 256 |
"concrete subclass has to reimplement this method |
867 | 257 |
in order to build its resource spec from aResourceSpec" |
258 |
||
868 | 259 |
^self subclassResponsibility |
867 | 260 |
! ! |
261 |
||
262 |
!ResourceSpecEditor methodsFor:'change & update'! |
|
263 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
264 |
update:something with:aParameter from:changedObject |
867 | 265 |
"one of my aspects has changed; update modified channel for the commit buttons" |
266 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
267 |
|enableCommitButtonsHolder| |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
268 |
|
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
269 |
enableCommitButtonsHolder := self valueOfEnablingCommitButtons. |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
270 |
|
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
271 |
changedObject ~~ enableCommitButtonsHolder ifTrue:[ |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
272 |
enableCommitButtonsHolder value: true |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
273 |
] |
867 | 274 |
|
876 | 275 |
! |
276 |
||
277 |
updateAllToolInstances |
|
896 | 278 |
"updates the channels of all other instances of my class" |
876 | 279 |
|
280 |
self allToolInstances do: [:inst| inst updateChannels] |
|
281 |
||
282 |
! |
|
283 |
||
284 |
updateChannels |
|
896 | 285 |
"updates my channels" |
876 | 286 |
|
287 |
self valueOfCanPaste |
|
288 |
||
289 |
||
867 | 290 |
! ! |
291 |
||
292 |
!ResourceSpecEditor methodsFor:'help'! |
|
293 |
||
294 |
defaultInfoLabel |
|
889 | 295 |
"returns the default label for the info bar" |
867 | 296 |
|
297 |
|cls| |
|
298 |
(specClass isSymbol and: [(cls := Smalltalk at: specClass) isClass]) |
|
299 |
ifTrue: |
|
300 |
[ |
|
1554
d01ffa42ca7a
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
301 |
(cls class includesSelector: specSelector) |
876 | 302 |
ifFalse: |
303 |
[ |
|
304 |
^specSelector isNil |
|
305 |
ifTrue: [specClass, ' >> ? (no selector defined)'] |
|
306 |
ifFalse: [specClass, ' >> ', specSelector, ' (not implemented)'] |
|
307 |
]. |
|
867 | 308 |
^specClass, ' >> ', specSelector |
309 |
]. |
|
310 |
^'No class and selector defined.' |
|
311 |
! ! |
|
312 |
||
313 |
!ResourceSpecEditor methodsFor:'initialization'! |
|
314 |
||
315 |
initialize |
|
316 |
"initialize the flags and the aspects" |
|
317 |
||
318 |
super initialize. |
|
319 |
||
896 | 320 |
hasSaved := modified := false. |
321 |
aspects := IdentityDictionary new. |
|
867 | 322 |
tabSelection := 0. |
323 |
||
324 |
self class aspects do: |
|
325 |
[:aKey| |
|
326 |
|holder| |
|
327 |
aspects at:aKey put: (holder := ValueHolder new). |
|
328 |
holder addDependent: self |
|
896 | 329 |
] |
867 | 330 |
! ! |
331 |
||
332 |
!ResourceSpecEditor methodsFor:'private'! |
|
333 |
||
334 |
askForItemModification |
|
889 | 335 |
"asks for resource item modification" |
867 | 336 |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
337 |
|anythingChangedHolder anythingChanged answer| |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
338 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
339 |
anythingChangedHolder := self valueOfEnablingCommitButtons. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
340 |
anythingChanged := anythingChangedHolder value. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
341 |
anythingChanged ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
342 |
"/ answer := ((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs) |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
343 |
"/ noText:'No'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
344 |
"/ yesText:'Yes'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
345 |
"/ showAtPointer; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
346 |
"/ accepted). |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
347 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
348 |
answer := Dialog |
1645 | 349 |
confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs) |
350 |
labels:(resources array:#('Cancel' 'No' 'Yes')) |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
351 |
default:3. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
352 |
answer isNil ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
353 |
^ false |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
354 |
]. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
355 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
356 |
answer ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
357 |
self accept |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
358 |
] ifFalse:[ |
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
359 |
anythingChangedHolder value: false. |
1201 | 360 |
self clearModifiedFlag. |
867 | 361 |
modified := false. |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
362 |
]. |
867 | 363 |
]. |
364 |
^true |
|
365 |
||
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
366 |
"Modified: / 30.10.2001 / 18:38:34 / cg" |
867 | 367 |
! |
368 |
||
369 |
askForListModification |
|
889 | 370 |
"asks for resource modification" |
867 | 371 |
|
1870
c0475972bf3e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
1767
diff
changeset
|
372 |
self modified ifTrue: |
867 | 373 |
[ |
1870
c0475972bf3e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
1767
diff
changeset
|
374 |
((YesNoBox title:(resources string:'%1 spec was modified. Exit anyway?' with:self class resourceType asUppercaseFirst)) |
929 | 375 |
noText:(resources string:'Cancel'); |
1870
c0475972bf3e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
1767
diff
changeset
|
376 |
yesText:(resources string:'Discard Changes and Exit'); |
867 | 377 |
showAtPointer; |
378 |
accepted) ifFalse: [^false]. |
|
379 |
modified := false |
|
380 |
]. |
|
381 |
^true |
|
929 | 382 |
|
383 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 384 |
! |
385 |
||
386 |
askForModification |
|
889 | 387 |
"asks first for item and then for resource modification" |
867 | 388 |
|
389 |
^self askForItemModification and: [self askForListModification] |
|
390 |
||
391 |
! |
|
392 |
||
393 |
resolveClassNamed |
|
889 | 394 |
"returns current class or nil" |
867 | 395 |
|
396 |
^Smalltalk resolveName:specClass inClass:self class |
|
397 |
! |
|
398 |
||
399 |
resourceMessage: aString |
|
889 | 400 |
"extracts from aString the specClass and the specSelector" |
867 | 401 |
|
402 |
(aString notNil and: [self askForModification]) |
|
403 |
ifTrue: |
|
404 |
[ |
|
405 |
|msg cls sel| |
|
406 |
msg := aString asCollectionOfWords. |
|
407 |
(msg size == 2 and: |
|
408 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
409 |
ifTrue: |
|
410 |
[ |
|
411 |
specClass := cls name. |
|
412 |
specSelector := (msg at: 2) asSymbol. |
|
413 |
^true |
|
414 |
] |
|
415 |
]. |
|
416 |
^false |
|
417 |
! |
|
418 |
||
419 |
updateHistory |
|
896 | 420 |
"updates the history, if there was loaded a resource spec" |
867 | 421 |
|
422 |
|cls| |
|
1554
d01ffa42ca7a
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
423 |
((cls := self resolveClassNamed) notNil and: [cls class includesSelector: specSelector]) |
867 | 424 |
ifTrue: |
425 |
[ |
|
426 |
|className message| |
|
427 |
specClass isClass ifTrue: [className := specClass name]. |
|
428 |
specClass isString ifTrue: [className := specClass]. |
|
429 |
message := className, ' ', specSelector. |
|
430 |
self addToHistory: message -> #loadFromMessage: |
|
431 |
] |
|
432 |
! ! |
|
433 |
||
434 |
!ResourceSpecEditor methodsFor:'queries'! |
|
435 |
||
436 |
hasSaved |
|
896 | 437 |
"returns true if resource spec has saved" |
867 | 438 |
|
439 |
^hasSaved |
|
440 |
||
441 |
! |
|
442 |
||
443 |
isStandAlone |
|
896 | 444 |
"returns true if the editor was not started from another tool" |
867 | 445 |
|
446 |
^self masterApplication isNil |
|
447 |
! ! |
|
448 |
||
449 |
!ResourceSpecEditor methodsFor:'selection'! |
|
450 |
||
451 |
tabSelection |
|
452 |
"returns selected tab index or 0" |
|
453 |
||
454 |
^tabSelection |
|
455 |
||
456 |
! ! |
|
457 |
||
1767 | 458 |
!ResourceSpecEditor methodsFor:'startup & release'! |
867 | 459 |
|
460 |
closeRequest |
|
896 | 461 |
"asks first for modification, then sends close request to super" |
867 | 462 |
|
463 |
self askForModification ifTrue: [super closeRequest] |
|
464 |
||
465 |
! |
|
466 |
||
467 |
loadFromMessage:aString |
|
896 | 468 |
"builds by evaluating aString the resource spec for editing" |
867 | 469 |
|
470 |
(aString notNil and: [self askForModification]) |
|
471 |
ifTrue: |
|
472 |
[ |
|
473 |
|msg cls sel| |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
474 |
|
867 | 475 |
msg := aString asCollectionOfWords. |
476 |
(msg size == 2 and: |
|
477 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
1554
d01ffa42ca7a
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
478 |
[cls class includesSelector: (sel := (msg at: 2) asSymbol)]]) |
867 | 479 |
ifTrue: |
480 |
[ |
|
481 |
self isStandAlone |
|
482 |
ifFalse: [self buildFromResourceSpec: (cls perform: sel)] |
|
483 |
ifTrue: [self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel)]. |
|
484 |
^true |
|
485 |
] |
|
486 |
]. |
|
487 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
488 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
489 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 490 |
! |
491 |
||
492 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 493 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 494 |
|
896 | 495 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 496 |
specSelector := aSelector. |
497 |
||
1735 | 498 |
self openInterfaceModal. |
867 | 499 |
! |
500 |
||
501 |
openModalOnResourceSpec: aListSpec |
|
896 | 502 |
"builds first from specClass and specSelector the resource spec for editing, |
503 |
then opens modal the interface" |
|
867 | 504 |
|
1735 | 505 |
self allButOpen. |
867 | 506 |
self buildFromResourceSpec: aListSpec. |
1735 | 507 |
self openWindowModal. |
867 | 508 |
|
509 |
! |
|
510 |
||
511 |
openOnClass:aClass andSelector:aSelector |
|
896 | 512 |
"sets the specClass and specSelector and opens the interface" |
867 | 513 |
|
896 | 514 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 515 |
specSelector := aSelector. |
516 |
||
1735 | 517 |
self openInterface. |
867 | 518 |
! |
519 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
520 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
521 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
522 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
523 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
524 |
super postBuildWith:aBuilder. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
525 |
|
1090 | 526 |
self class rememberInstance:self |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
527 |
|
1090 | 528 |
"Modified: / 4.2.1999 / 15:33:23 / cg" |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
529 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
530 |
|
867 | 531 |
postOpenWith:aBuilder |
896 | 532 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 533 |
|
534 |
super postOpenWith:aBuilder. |
|
535 |
||
896 | 536 |
self buildFromClass: specClass andSelector: specSelector |
867 | 537 |
|
876 | 538 |
! |
539 |
||
540 |
uninitialize |
|
896 | 541 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 542 |
|
543 |
super uninitialize. |
|
544 |
||
1090 | 545 |
self class forgetInstance:self |
876 | 546 |
|
1090 | 547 |
"Modified: / 4.2.1999 / 15:34:25 / cg" |
867 | 548 |
! ! |
549 |
||
550 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
551 |
||
552 |
accept |
|
896 | 553 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 554 |
|
1157 | 555 |
self acceptChannel |
1158 | 556 |
value:false; |
1157 | 557 |
value:true; "/ toggle to force inputFields to accept |
558 |
value:false. |
|
559 |
||
867 | 560 |
self valueOfEnablingCommitButtons value: false. |
1201 | 561 |
self clearModifiedFlag. |
867 | 562 |
modified := true |
563 |
! |
|
564 |
||
565 |
doBrowseClass |
|
889 | 566 |
"opens a System Browser on the specClass and specSelector" |
867 | 567 |
|
568 |
|cls| |
|
569 |
||
570 |
(cls := self resolveClassNamed) notNil |
|
1504 | 571 |
ifTrue: [UserPreferences systemBrowserClass openInClass:cls class selector: specSelector] |
867 | 572 |
ifFalse:[self information:'No class defined!!'] |
573 |
! |
|
574 |
||
575 |
doEditImage |
|
896 | 576 |
"opens a Image Editor on the resource retriever and the icon selector" |
867 | 577 |
|
1003 | 578 |
|cls resourceClass resourceSelector imageResourceMessage readStream icon retriever| |
867 | 579 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
580 |
(icon := (aspects at:#icon) value) size > 0 |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
581 |
ifTrue: [resourceSelector := icon] |
867 | 582 |
ifFalse: [resourceSelector := #icon]. |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
583 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
584 |
(retriever := (aspects at:#retriever) value) size > 0 |
1147 | 585 |
ifTrue:[ |
1003 | 586 |
resourceClass := retriever |
1147 | 587 |
] ifFalse:[ |
1003 | 588 |
(cls := self resolveName: specClass) notNil |
1147 | 589 |
ifTrue:[ |
1554
d01ffa42ca7a
implements -> includesSelector
Claus Gittinger <cg@exept.de>
parents:
1524
diff
changeset
|
590 |
resourceClass := cls withAllSuperclasses detect: [:cls| cls class includesSelector: resourceSelector] ifNone: [cls] |
1003 | 591 |
] |
592 |
]. |
|
867 | 593 |
|
594 |
(imageResourceMessage := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
|
1147 | 595 |
ifTrue: [ |
867 | 596 |
readStream := imageResourceMessage readStream. |
597 |
resourceClass := (readStream upTo: $ ) asSymbol. |
|
598 |
resourceSelector := readStream upToEnd asSymbol. |
|
1147 | 599 |
resourceClass size > 0 ifTrue: [ |
600 |
(aspects at:#retriever) value: resourceClass |
|
601 |
]. |
|
602 |
resourceSelector size > 0 ifTrue: [ |
|
603 |
(aspects at:#icon) value: resourceSelector. |
|
604 |
self valueOfEnablingCommitButtons value: true |
|
605 |
] |
|
867 | 606 |
] |
607 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
608 |
"Modified: / 21.5.1998 / 02:44:04 / cg" |
867 | 609 |
! |
610 |
||
611 |
doLoad |
|
889 | 612 |
"opens a Resource Selection Browser in order to get a resource message" |
867 | 613 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
614 |
|myResourceType| |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
615 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
616 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
617 |
|
867 | 618 |
self loadFromMessage: |
619 |
(ResourceSelectionBrowser |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
620 |
request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class' |
867 | 621 |
onSuperclass: nil |
622 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
623 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
624 |
withResourceTypes: (Array with: myResourceType)) |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
625 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
626 |
"Modified: / 21.5.1998 / 02:59:02 / cg" |
867 | 627 |
! |
628 |
||
629 |
doNew |
|
630 |
"first ask for modification; then clean specClass and specSelector, |
|
631 |
but only, if the editor is opened as stand alone; |
|
632 |
finally make a build of a resource spec containing no items" |
|
633 |
||
634 |
self askForModification |
|
635 |
ifTrue: |
|
636 |
[ |
|
637 |
self isStandAlone ifTrue: [specClass := specSelector := nil]. |
|
638 |
self buildFromClass: nil andSelector: self class resourceType. |
|
639 |
^true |
|
640 |
]. |
|
641 |
^false |
|
642 |
||
643 |
! |
|
644 |
||
645 |
doSave |
|
646 |
"before saving ask for modification; if no specClass and specSelector |
|
647 |
is defined, do save as" |
|
648 |
||
649 |
self askForItemModification. |
|
650 |
||
651 |
(specClass isNil or:[specSelector isNil]) ifTrue:[ |
|
652 |
self doSaveAs. |
|
653 |
^false |
|
654 |
]. |
|
655 |
^true |
|
656 |
! |
|
657 |
||
658 |
doSaveAs |
|
659 |
"first ask for modification; |
|
660 |
then open a ResourceSelectionBrowser; |
|
661 |
after that extract the resource message; |
|
662 |
finally do save and make a new build" |
|
663 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
664 |
|resourceMessage myResourceType| |
867 | 665 |
|
666 |
self askForItemModification. |
|
667 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
668 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
669 |
|
867 | 670 |
(resourceMessage := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
671 |
request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class' |
867 | 672 |
onSuperclass: #Object |
673 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
674 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
675 |
withResourceTypes: (Array with: myResourceType)) notNil |
867 | 676 |
ifTrue: |
677 |
[ |
|
678 |
modified := false. |
|
679 |
(self resourceMessage: resourceMessage) |
|
680 |
ifTrue: |
|
681 |
[ |
|
682 |
self doSave. |
|
683 |
self buildFromClass: specClass andSelector: specSelector. |
|
684 |
^true |
|
685 |
] |
|
686 |
]. |
|
687 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
688 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
689 |
"Modified: / 21.5.1998 / 02:59:46 / cg" |
867 | 690 |
! ! |
691 |
||
692 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
693 |
||
694 |
version |
|
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
695 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.27 2003-12-04 14:55:55 cg Exp $' |
867 | 696 |
! ! |