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