author | Claus Gittinger <cg@exept.de> |
Mon, 12 Apr 1999 13:16:06 +0200 | |
changeset 1156 | abdd5a7dce49 |
parent 1147 | bbaa243ddd1c |
child 1157 | feeae3138d3d |
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. |
|
1147 | 149 |
inst valueOfEnablingCommitButtons value: false. |
150 |
inst modifiedChannel value: false. |
|
1090 | 151 |
] |
876 | 152 |
] |
153 |
||
1090 | 154 |
"Modified: / 4.2.1999 / 15:32:17 / cg" |
876 | 155 |
! ! |
156 |
||
867 | 157 |
!ResourceSpecEditor methodsFor:'accessing'! |
158 |
||
159 |
modified |
|
889 | 160 |
"returns whether the resource spec was modified" |
867 | 161 |
|
162 |
^modified |
|
163 |
! |
|
164 |
||
165 |
modified: aBoolean |
|
896 | 166 |
"sets the resource spec modified as aBoolean" |
867 | 167 |
|
168 |
modified := aBoolean |
|
169 |
! |
|
170 |
||
171 |
specClass |
|
889 | 172 |
"returns the class where the resource spec is implemented" |
867 | 173 |
|
174 |
^specClass |
|
175 |
! |
|
176 |
||
177 |
specClass:aClass |
|
889 | 178 |
"sets the class (or name) where the resource spec is (or should be) implemented" |
867 | 179 |
|
896 | 180 |
aClass isClass ifTrue: [specClass := aClass name] |
181 |
ifFalse:[specClass := aClass asSymbol] |
|
867 | 182 |
! |
183 |
||
184 |
specSelector |
|
889 | 185 |
"returns the method selector of the resource spec" |
867 | 186 |
|
187 |
^specSelector |
|
188 |
||
189 |
! |
|
190 |
||
191 |
specSelector:aSelector |
|
889 | 192 |
"sets the method selector of the resource spec" |
867 | 193 |
|
194 |
specSelector := aSelector |
|
195 |
! ! |
|
196 |
||
197 |
!ResourceSpecEditor methodsFor:'aspects'! |
|
198 |
||
199 |
aspectFor:aKey |
|
889 | 200 |
"returns the aspect for a aKey or nil" |
867 | 201 |
|
202 |
^aspects at: aKey ifAbsent: [super aspectFor:aKey] |
|
203 |
||
204 |
! |
|
205 |
||
206 |
tabModel |
|
889 | 207 |
"returns the value holder for the tab selection" |
867 | 208 |
|
209 |
|holder| |
|
210 |
(holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
211 |
holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
212 |
builder aspectAt:#tabModel put:holder. |
|
213 |
]. |
|
214 |
^ holder |
|
215 |
! |
|
216 |
||
876 | 217 |
valueOfCanPaste |
896 | 218 |
"returns whether the application can paste as value holder" |
876 | 219 |
|
220 |
|holder| |
|
221 |
holder := super valueOfCanPaste. |
|
222 |
holder value: self class clipboard notNil. |
|
223 |
^ holder |
|
224 |
||
225 |
||
226 |
! |
|
227 |
||
867 | 228 |
valueOfEnableMovingIn |
896 | 229 |
"returns whether the selected item can move into next item as child as value holder" |
867 | 230 |
|
231 |
^builder booleanValueAspectFor: #valueOfEnableMovingIn |
|
232 |
||
233 |
||
234 |
||
235 |
! |
|
236 |
||
237 |
valueOfEnableMovingOut |
|
896 | 238 |
"returns whether the selected item can move out from its parent item as value holder" |
867 | 239 |
|
240 |
^builder booleanValueAspectFor: #valueOfEnableMovingOut |
|
241 |
||
242 |
||
243 |
||
244 |
! |
|
245 |
||
246 |
valueOfEnableMovingUpOrDown |
|
896 | 247 |
"returns whether the selected item can move up or down as value holder" |
867 | 248 |
|
249 |
^builder booleanValueAspectFor: #valueOfEnableMovingUpOrDown |
|
250 |
||
251 |
||
252 |
||
253 |
||
254 |
! ! |
|
255 |
||
256 |
!ResourceSpecEditor methodsFor:'building'! |
|
257 |
||
258 |
buildFromResourceSpec: aResourceSpec |
|
868 | 259 |
"concrete subclass has to reimplement this method |
867 | 260 |
in order to build its resource spec from aResourceSpec" |
261 |
||
868 | 262 |
^self subclassResponsibility |
867 | 263 |
! ! |
264 |
||
265 |
!ResourceSpecEditor methodsFor:'change & update'! |
|
266 |
||
267 |
update:something with:aParameter from:someObject |
|
268 |
"one of my aspects has changed; update modified channel for the commit buttons" |
|
269 |
||
270 |
self valueOfEnablingCommitButtons value: true |
|
271 |
||
876 | 272 |
! |
273 |
||
274 |
updateAllToolInstances |
|
896 | 275 |
"updates the channels of all other instances of my class" |
876 | 276 |
|
277 |
self allToolInstances do: [:inst| inst updateChannels] |
|
278 |
||
279 |
! |
|
280 |
||
281 |
updateChannels |
|
896 | 282 |
"updates my channels" |
876 | 283 |
|
284 |
self valueOfCanPaste |
|
285 |
||
286 |
||
867 | 287 |
! ! |
288 |
||
289 |
!ResourceSpecEditor methodsFor:'help'! |
|
290 |
||
291 |
defaultInfoLabel |
|
889 | 292 |
"returns the default label for the info bar" |
867 | 293 |
|
294 |
|cls| |
|
295 |
(specClass isSymbol and: [(cls := Smalltalk at: specClass) isClass]) |
|
296 |
ifTrue: |
|
297 |
[ |
|
298 |
(cls class implements: specSelector) |
|
876 | 299 |
ifFalse: |
300 |
[ |
|
301 |
^specSelector isNil |
|
302 |
ifTrue: [specClass, ' >> ? (no selector defined)'] |
|
303 |
ifFalse: [specClass, ' >> ', specSelector, ' (not implemented)'] |
|
304 |
]. |
|
867 | 305 |
^specClass, ' >> ', specSelector |
306 |
]. |
|
307 |
^'No class and selector defined.' |
|
308 |
||
309 |
! ! |
|
310 |
||
311 |
!ResourceSpecEditor methodsFor:'initialization'! |
|
312 |
||
313 |
initialize |
|
314 |
"initialize the flags and the aspects" |
|
315 |
||
316 |
super initialize. |
|
317 |
||
896 | 318 |
hasSaved := modified := false. |
319 |
aspects := IdentityDictionary new. |
|
867 | 320 |
tabSelection := 0. |
321 |
||
322 |
self class aspects do: |
|
323 |
[:aKey| |
|
324 |
|holder| |
|
325 |
aspects at:aKey put: (holder := ValueHolder new). |
|
326 |
holder addDependent: self |
|
896 | 327 |
] |
867 | 328 |
! ! |
329 |
||
330 |
!ResourceSpecEditor methodsFor:'private'! |
|
331 |
||
332 |
askForItemModification |
|
889 | 333 |
"asks for resource item modification" |
867 | 334 |
|
1147 | 335 |
self valueOfEnablingCommitButtons value ifTrue:[ |
867 | 336 |
((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs) |
337 |
noText:'No'; |
|
338 |
yesText:'Yes'; |
|
339 |
showAtPointer; |
|
340 |
accepted) |
|
1147 | 341 |
ifFalse: [ |
867 | 342 |
self valueOfEnablingCommitButtons value: false. |
1147 | 343 |
self modifiedChannel value: false. |
867 | 344 |
modified := false. |
345 |
^true |
|
346 |
]. |
|
347 |
self accept |
|
348 |
]. |
|
349 |
^true |
|
350 |
||
351 |
! |
|
352 |
||
353 |
askForListModification |
|
889 | 354 |
"asks for resource modification" |
867 | 355 |
|
356 |
modified |
|
357 |
ifTrue: |
|
358 |
[ |
|
929 | 359 |
((YesNoBox title:(resources string:'%1 spec was modified !!' with:self class resourceType asUppercaseFirst)) |
360 |
noText:(resources string:'Cancel'); |
|
361 |
yesText:(resources string:'Forget it and proceed'); |
|
867 | 362 |
showAtPointer; |
363 |
accepted) ifFalse: [^false]. |
|
364 |
modified := false |
|
365 |
]. |
|
366 |
^true |
|
929 | 367 |
|
368 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 369 |
! |
370 |
||
371 |
askForModification |
|
889 | 372 |
"asks first for item and then for resource modification" |
867 | 373 |
|
374 |
^self askForItemModification and: [self askForListModification] |
|
375 |
||
376 |
! |
|
377 |
||
378 |
resolveClassNamed |
|
889 | 379 |
"returns current class or nil" |
867 | 380 |
|
381 |
^Smalltalk resolveName:specClass inClass:self class |
|
382 |
! |
|
383 |
||
384 |
resourceMessage: aString |
|
889 | 385 |
"extracts from aString the specClass and the specSelector" |
867 | 386 |
|
387 |
(aString notNil and: [self askForModification]) |
|
388 |
ifTrue: |
|
389 |
[ |
|
390 |
|msg cls sel| |
|
391 |
msg := aString asCollectionOfWords. |
|
392 |
(msg size == 2 and: |
|
393 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
394 |
ifTrue: |
|
395 |
[ |
|
396 |
specClass := cls name. |
|
397 |
specSelector := (msg at: 2) asSymbol. |
|
398 |
^true |
|
399 |
] |
|
400 |
]. |
|
401 |
^false |
|
402 |
! |
|
403 |
||
404 |
updateHistory |
|
896 | 405 |
"updates the history, if there was loaded a resource spec" |
867 | 406 |
|
407 |
|cls| |
|
408 |
((cls := self resolveClassNamed) notNil and: [cls class implements: specSelector]) |
|
409 |
ifTrue: |
|
410 |
[ |
|
411 |
|className message| |
|
412 |
specClass isClass ifTrue: [className := specClass name]. |
|
413 |
specClass isString ifTrue: [className := specClass]. |
|
414 |
message := className, ' ', specSelector. |
|
415 |
self addToHistory: message -> #loadFromMessage: |
|
416 |
] |
|
417 |
! ! |
|
418 |
||
419 |
!ResourceSpecEditor methodsFor:'queries'! |
|
420 |
||
421 |
hasSaved |
|
896 | 422 |
"returns true if resource spec has saved" |
867 | 423 |
|
424 |
^hasSaved |
|
425 |
||
426 |
! |
|
427 |
||
428 |
isStandAlone |
|
896 | 429 |
"returns true if the editor was not started from another tool" |
867 | 430 |
|
431 |
^self masterApplication isNil |
|
432 |
! ! |
|
433 |
||
434 |
!ResourceSpecEditor methodsFor:'selection'! |
|
435 |
||
436 |
tabSelection |
|
437 |
"returns selected tab index or 0" |
|
438 |
||
439 |
^tabSelection |
|
440 |
||
441 |
! ! |
|
442 |
||
443 |
!ResourceSpecEditor methodsFor:'startup / release'! |
|
444 |
||
445 |
closeRequest |
|
896 | 446 |
"asks first for modification, then sends close request to super" |
867 | 447 |
|
448 |
self askForModification ifTrue: [super closeRequest] |
|
449 |
||
450 |
! |
|
451 |
||
452 |
loadFromMessage:aString |
|
896 | 453 |
"builds by evaluating aString the resource spec for editing" |
867 | 454 |
|
455 |
(aString notNil and: [self askForModification]) |
|
456 |
ifTrue: |
|
457 |
[ |
|
458 |
|msg cls sel| |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
459 |
|
867 | 460 |
msg := aString asCollectionOfWords. |
461 |
(msg size == 2 and: |
|
462 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
463 |
[cls class implements: (sel := (msg at: 2) asSymbol)]]) |
|
464 |
ifTrue: |
|
465 |
[ |
|
466 |
self isStandAlone |
|
467 |
ifFalse: [self buildFromResourceSpec: (cls perform: sel)] |
|
468 |
ifTrue: [self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel)]. |
|
469 |
^true |
|
470 |
] |
|
471 |
]. |
|
472 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
473 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
474 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 475 |
! |
476 |
||
477 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 478 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 479 |
|
896 | 480 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 481 |
specSelector := aSelector. |
482 |
||
483 |
super openInterfaceModal. |
|
484 |
||
485 |
! |
|
486 |
||
487 |
openModalOnResourceSpec: aListSpec |
|
896 | 488 |
"builds first from specClass and specSelector the resource spec for editing, |
489 |
then opens modal the interface" |
|
867 | 490 |
|
491 |
self buildFromResourceSpec: aListSpec. |
|
492 |
||
493 |
super openInterfaceModal. |
|
494 |
||
495 |
! |
|
496 |
||
497 |
openOnClass:aClass andSelector:aSelector |
|
896 | 498 |
"sets the specClass and specSelector and opens the interface" |
867 | 499 |
|
896 | 500 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 501 |
specSelector := aSelector. |
502 |
||
503 |
super openInterface. |
|
504 |
! |
|
505 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
506 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
507 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
508 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
509 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
510 |
super postBuildWith:aBuilder. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
511 |
|
1090 | 512 |
self class rememberInstance:self |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
513 |
|
1090 | 514 |
"Modified: / 4.2.1999 / 15:33:23 / cg" |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
515 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
516 |
|
867 | 517 |
postOpenWith:aBuilder |
896 | 518 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 519 |
|
520 |
super postOpenWith:aBuilder. |
|
521 |
||
896 | 522 |
self buildFromClass: specClass andSelector: specSelector |
867 | 523 |
|
876 | 524 |
! |
525 |
||
526 |
uninitialize |
|
896 | 527 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 528 |
|
529 |
super uninitialize. |
|
530 |
||
1090 | 531 |
self class forgetInstance:self |
876 | 532 |
|
1090 | 533 |
"Modified: / 4.2.1999 / 15:34:25 / cg" |
867 | 534 |
! ! |
535 |
||
536 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
537 |
||
538 |
accept |
|
896 | 539 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 540 |
|
1147 | 541 |
self acceptChannel value:true. "/ toggle to force inputFields to accept |
542 |
self acceptChannel value:false. |
|
867 | 543 |
self valueOfEnablingCommitButtons value: false. |
1147 | 544 |
self modifiedChannel value: false. |
867 | 545 |
modified := true |
546 |
! |
|
547 |
||
548 |
doBrowseClass |
|
889 | 549 |
"opens a System Browser on the specClass and specSelector" |
867 | 550 |
|
551 |
|cls| |
|
552 |
||
553 |
(cls := self resolveClassNamed) notNil |
|
554 |
ifTrue: [SystemBrowser openInClass:cls class selector: specSelector] |
|
555 |
ifFalse:[self information:'No class defined!!'] |
|
556 |
! |
|
557 |
||
558 |
doEditImage |
|
896 | 559 |
"opens a Image Editor on the resource retriever and the icon selector" |
867 | 560 |
|
1003 | 561 |
|cls resourceClass resourceSelector imageResourceMessage readStream icon retriever| |
867 | 562 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
563 |
(icon := (aspects at:#icon) value) size > 0 |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
564 |
ifTrue: [resourceSelector := icon] |
867 | 565 |
ifFalse: [resourceSelector := #icon]. |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
566 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
567 |
(retriever := (aspects at:#retriever) value) size > 0 |
1147 | 568 |
ifTrue:[ |
1003 | 569 |
resourceClass := retriever |
1147 | 570 |
] ifFalse:[ |
1003 | 571 |
(cls := self resolveName: specClass) notNil |
1147 | 572 |
ifTrue:[ |
1003 | 573 |
resourceClass := cls withAllSuperclasses detect: [:cls| cls class implements: resourceSelector] ifNone: [cls] |
574 |
] |
|
575 |
]. |
|
867 | 576 |
|
577 |
(imageResourceMessage := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
|
1147 | 578 |
ifTrue: [ |
867 | 579 |
readStream := imageResourceMessage readStream. |
580 |
resourceClass := (readStream upTo: $ ) asSymbol. |
|
581 |
resourceSelector := readStream upToEnd asSymbol. |
|
1147 | 582 |
resourceClass size > 0 ifTrue: [ |
583 |
(aspects at:#retriever) value: resourceClass |
|
584 |
]. |
|
585 |
resourceSelector size > 0 ifTrue: [ |
|
586 |
(aspects at:#icon) value: resourceSelector. |
|
587 |
self valueOfEnablingCommitButtons value: true |
|
588 |
] |
|
867 | 589 |
] |
590 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
591 |
"Modified: / 21.5.1998 / 02:44:04 / cg" |
867 | 592 |
! |
593 |
||
594 |
doLoad |
|
889 | 595 |
"opens a Resource Selection Browser in order to get a resource message" |
867 | 596 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
597 |
|myResourceType| |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
598 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
599 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
600 |
|
867 | 601 |
self loadFromMessage: |
602 |
(ResourceSelectionBrowser |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
603 |
request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class' |
867 | 604 |
onSuperclass: nil |
605 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
606 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
607 |
withResourceTypes: (Array with: myResourceType)) |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
608 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
609 |
"Modified: / 21.5.1998 / 02:59:02 / cg" |
867 | 610 |
! |
611 |
||
612 |
doNew |
|
613 |
"first ask for modification; then clean specClass and specSelector, |
|
614 |
but only, if the editor is opened as stand alone; |
|
615 |
finally make a build of a resource spec containing no items" |
|
616 |
||
617 |
self askForModification |
|
618 |
ifTrue: |
|
619 |
[ |
|
620 |
self isStandAlone ifTrue: [specClass := specSelector := nil]. |
|
621 |
self buildFromClass: nil andSelector: self class resourceType. |
|
622 |
^true |
|
623 |
]. |
|
624 |
^false |
|
625 |
||
626 |
! |
|
627 |
||
628 |
doSave |
|
629 |
"before saving ask for modification; if no specClass and specSelector |
|
630 |
is defined, do save as" |
|
631 |
||
632 |
self askForItemModification. |
|
633 |
||
634 |
(specClass isNil or:[specSelector isNil]) ifTrue:[ |
|
635 |
self doSaveAs. |
|
636 |
^false |
|
637 |
]. |
|
638 |
^true |
|
639 |
! |
|
640 |
||
641 |
doSaveAs |
|
642 |
"first ask for modification; |
|
643 |
then open a ResourceSelectionBrowser; |
|
644 |
after that extract the resource message; |
|
645 |
finally do save and make a new build" |
|
646 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
647 |
|resourceMessage myResourceType| |
867 | 648 |
|
649 |
self askForItemModification. |
|
650 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
651 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
652 |
|
867 | 653 |
(resourceMessage := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
654 |
request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class' |
867 | 655 |
onSuperclass: #Object |
656 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
657 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
658 |
withResourceTypes: (Array with: myResourceType)) notNil |
867 | 659 |
ifTrue: |
660 |
[ |
|
661 |
modified := false. |
|
662 |
(self resourceMessage: resourceMessage) |
|
663 |
ifTrue: |
|
664 |
[ |
|
665 |
self doSave. |
|
666 |
self buildFromClass: specClass andSelector: specSelector. |
|
667 |
^true |
|
668 |
] |
|
669 |
]. |
|
670 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
671 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
672 |
"Modified: / 21.5.1998 / 02:59:46 / cg" |
867 | 673 |
! ! |
674 |
||
675 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
676 |
||
677 |
version |
|
1147 | 678 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.12 1999-03-19 12:24:05 cg Exp $' |
867 | 679 |
! ! |