author | Claus Gittinger <cg@exept.de> |
Thu, 03 Sep 1998 15:09:40 +0200 | |
changeset 1060 | bf2436846484 |
parent 1003 | 3f728982d7d9 |
child 1090 | d7738a06b696 |
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 |
||
146 |
(self settings at: #Instances ifAbsent: [^nil]) do: |
|
147 |
[:inst| |
|
148 |
inst updateChannels. |
|
149 |
inst valueOfEnablingCommitButtons value: false |
|
150 |
] |
|
151 |
||
152 |
||
153 |
||
154 |
||
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 |
|
335 |
self valueOfEnablingCommitButtons value |
|
336 |
ifTrue: |
|
337 |
[ |
|
338 |
((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs) |
|
339 |
noText:'No'; |
|
340 |
yesText:'Yes'; |
|
341 |
showAtPointer; |
|
342 |
accepted) |
|
343 |
ifFalse: |
|
344 |
[ |
|
345 |
self valueOfEnablingCommitButtons value: false. |
|
346 |
modified := false. |
|
347 |
^true |
|
348 |
]. |
|
349 |
self accept |
|
350 |
]. |
|
351 |
^true |
|
352 |
||
353 |
! |
|
354 |
||
355 |
askForListModification |
|
889 | 356 |
"asks for resource modification" |
867 | 357 |
|
358 |
modified |
|
359 |
ifTrue: |
|
360 |
[ |
|
929 | 361 |
((YesNoBox title:(resources string:'%1 spec was modified !!' with:self class resourceType asUppercaseFirst)) |
362 |
noText:(resources string:'Cancel'); |
|
363 |
yesText:(resources string:'Forget it and proceed'); |
|
867 | 364 |
showAtPointer; |
365 |
accepted) ifFalse: [^false]. |
|
366 |
modified := false |
|
367 |
]. |
|
368 |
^true |
|
929 | 369 |
|
370 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 371 |
! |
372 |
||
373 |
askForModification |
|
889 | 374 |
"asks first for item and then for resource modification" |
867 | 375 |
|
376 |
^self askForItemModification and: [self askForListModification] |
|
377 |
||
378 |
! |
|
379 |
||
380 |
resolveClassNamed |
|
889 | 381 |
"returns current class or nil" |
867 | 382 |
|
383 |
^Smalltalk resolveName:specClass inClass:self class |
|
384 |
! |
|
385 |
||
386 |
resourceMessage: aString |
|
889 | 387 |
"extracts from aString the specClass and the specSelector" |
867 | 388 |
|
389 |
(aString notNil and: [self askForModification]) |
|
390 |
ifTrue: |
|
391 |
[ |
|
392 |
|msg cls sel| |
|
393 |
msg := aString asCollectionOfWords. |
|
394 |
(msg size == 2 and: |
|
395 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
396 |
ifTrue: |
|
397 |
[ |
|
398 |
specClass := cls name. |
|
399 |
specSelector := (msg at: 2) asSymbol. |
|
400 |
^true |
|
401 |
] |
|
402 |
]. |
|
403 |
^false |
|
404 |
! |
|
405 |
||
406 |
updateHistory |
|
896 | 407 |
"updates the history, if there was loaded a resource spec" |
867 | 408 |
|
409 |
|cls| |
|
410 |
((cls := self resolveClassNamed) notNil and: [cls class implements: specSelector]) |
|
411 |
ifTrue: |
|
412 |
[ |
|
413 |
|className message| |
|
414 |
specClass isClass ifTrue: [className := specClass name]. |
|
415 |
specClass isString ifTrue: [className := specClass]. |
|
416 |
message := className, ' ', specSelector. |
|
417 |
self addToHistory: message -> #loadFromMessage: |
|
418 |
] |
|
419 |
! ! |
|
420 |
||
421 |
!ResourceSpecEditor methodsFor:'queries'! |
|
422 |
||
423 |
hasSaved |
|
896 | 424 |
"returns true if resource spec has saved" |
867 | 425 |
|
426 |
^hasSaved |
|
427 |
||
428 |
! |
|
429 |
||
430 |
isStandAlone |
|
896 | 431 |
"returns true if the editor was not started from another tool" |
867 | 432 |
|
433 |
^self masterApplication isNil |
|
434 |
! ! |
|
435 |
||
436 |
!ResourceSpecEditor methodsFor:'selection'! |
|
437 |
||
438 |
tabSelection |
|
439 |
"returns selected tab index or 0" |
|
440 |
||
441 |
^tabSelection |
|
442 |
||
443 |
! ! |
|
444 |
||
445 |
!ResourceSpecEditor methodsFor:'startup / release'! |
|
446 |
||
447 |
closeRequest |
|
896 | 448 |
"asks first for modification, then sends close request to super" |
867 | 449 |
|
450 |
self askForModification ifTrue: [super closeRequest] |
|
451 |
||
452 |
! |
|
453 |
||
454 |
loadFromMessage:aString |
|
896 | 455 |
"builds by evaluating aString the resource spec for editing" |
867 | 456 |
|
457 |
(aString notNil and: [self askForModification]) |
|
458 |
ifTrue: |
|
459 |
[ |
|
460 |
|msg cls sel| |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
461 |
|
867 | 462 |
msg := aString asCollectionOfWords. |
463 |
(msg size == 2 and: |
|
464 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
465 |
[cls class implements: (sel := (msg at: 2) asSymbol)]]) |
|
466 |
ifTrue: |
|
467 |
[ |
|
468 |
self isStandAlone |
|
469 |
ifFalse: [self buildFromResourceSpec: (cls perform: sel)] |
|
470 |
ifTrue: [self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel)]. |
|
471 |
^true |
|
472 |
] |
|
473 |
]. |
|
474 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
475 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
476 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 477 |
! |
478 |
||
479 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 480 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 481 |
|
896 | 482 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 483 |
specSelector := aSelector. |
484 |
||
485 |
super openInterfaceModal. |
|
486 |
||
487 |
! |
|
488 |
||
489 |
openModalOnResourceSpec: aListSpec |
|
896 | 490 |
"builds first from specClass and specSelector the resource spec for editing, |
491 |
then opens modal the interface" |
|
867 | 492 |
|
493 |
self buildFromResourceSpec: aListSpec. |
|
494 |
||
495 |
super openInterfaceModal. |
|
496 |
||
497 |
! |
|
498 |
||
499 |
openOnClass:aClass andSelector:aSelector |
|
896 | 500 |
"sets the specClass and specSelector and opens the interface" |
867 | 501 |
|
896 | 502 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 503 |
specSelector := aSelector. |
504 |
||
505 |
super openInterface. |
|
506 |
! |
|
507 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
508 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
509 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
510 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
511 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
512 |
|settings| |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
513 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
514 |
super postBuildWith:aBuilder. |
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 |
settings := self class settings. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
517 |
settings |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
518 |
at:#Instances |
991 | 519 |
put:((settings at:#Instances ifAbsent:[Set new]) add: self; yourself). |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
520 |
|
991 | 521 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
522 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
523 |
|
867 | 524 |
postOpenWith:aBuilder |
896 | 525 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 526 |
|
527 |
super postOpenWith:aBuilder. |
|
528 |
||
896 | 529 |
self buildFromClass: specClass andSelector: specSelector |
867 | 530 |
|
876 | 531 |
! |
532 |
||
533 |
uninitialize |
|
896 | 534 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 535 |
|
536 |
super uninitialize. |
|
537 |
||
538 |
(self class settings at: #Instances ifAbsent: [^nil]) remove: self ifAbsent: nil |
|
539 |
||
867 | 540 |
! ! |
541 |
||
542 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
543 |
||
544 |
accept |
|
896 | 545 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 546 |
|
547 |
self valueOfEnablingCommitButtons value: false. |
|
548 |
modified := true |
|
549 |
! |
|
550 |
||
551 |
doBrowseClass |
|
889 | 552 |
"opens a System Browser on the specClass and specSelector" |
867 | 553 |
|
554 |
|cls| |
|
555 |
||
556 |
(cls := self resolveClassNamed) notNil |
|
557 |
ifTrue: [SystemBrowser openInClass:cls class selector: specSelector] |
|
558 |
ifFalse:[self information:'No class defined!!'] |
|
559 |
! |
|
560 |
||
561 |
doEditImage |
|
896 | 562 |
"opens a Image Editor on the resource retriever and the icon selector" |
867 | 563 |
|
1003 | 564 |
|cls resourceClass resourceSelector imageResourceMessage readStream icon retriever| |
867 | 565 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
566 |
(icon := (aspects at:#icon) value) size > 0 |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
567 |
ifTrue: [resourceSelector := icon] |
867 | 568 |
ifFalse: [resourceSelector := #icon]. |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
569 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
570 |
(retriever := (aspects at:#retriever) value) size > 0 |
1003 | 571 |
ifTrue: |
572 |
[ |
|
573 |
resourceClass := retriever |
|
574 |
] |
|
575 |
ifFalse: |
|
576 |
[ |
|
577 |
(cls := self resolveName: specClass) notNil |
|
578 |
ifTrue: |
|
579 |
[ |
|
580 |
resourceClass := cls withAllSuperclasses detect: [:cls| cls class implements: resourceSelector] ifNone: [cls] |
|
581 |
] |
|
582 |
]. |
|
867 | 583 |
|
584 |
(imageResourceMessage := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
|
585 |
ifTrue: |
|
586 |
[ |
|
587 |
readStream := imageResourceMessage readStream. |
|
588 |
resourceClass := (readStream upTo: $ ) asSymbol. |
|
589 |
resourceSelector := readStream upToEnd asSymbol. |
|
590 |
resourceClass size > 0 ifTrue: [(aspects at:#retriever) value: resourceClass]. |
|
591 |
resourceSelector size > 0 ifTrue: [(aspects at:#icon) value: resourceSelector. self valueOfEnablingCommitButtons value: true] |
|
592 |
] |
|
593 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
594 |
"Modified: / 21.5.1998 / 02:44:04 / cg" |
867 | 595 |
! |
596 |
||
597 |
doLoad |
|
889 | 598 |
"opens a Resource Selection Browser in order to get a resource message" |
867 | 599 |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
600 |
|myResourceType| |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
601 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
602 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
603 |
|
867 | 604 |
self loadFromMessage: |
605 |
(ResourceSelectionBrowser |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
606 |
request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class' |
867 | 607 |
onSuperclass: nil |
608 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
609 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
610 |
withResourceTypes: (Array with: myResourceType)) |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
611 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
612 |
"Modified: / 21.5.1998 / 02:59:02 / cg" |
867 | 613 |
! |
614 |
||
615 |
doNew |
|
616 |
"first ask for modification; then clean specClass and specSelector, |
|
617 |
but only, if the editor is opened as stand alone; |
|
618 |
finally make a build of a resource spec containing no items" |
|
619 |
||
620 |
self askForModification |
|
621 |
ifTrue: |
|
622 |
[ |
|
623 |
self isStandAlone ifTrue: [specClass := specSelector := nil]. |
|
624 |
self buildFromClass: nil andSelector: self class resourceType. |
|
625 |
^true |
|
626 |
]. |
|
627 |
^false |
|
628 |
||
629 |
! |
|
630 |
||
631 |
doSave |
|
632 |
"before saving ask for modification; if no specClass and specSelector |
|
633 |
is defined, do save as" |
|
634 |
||
635 |
self askForItemModification. |
|
636 |
||
637 |
(specClass isNil or:[specSelector isNil]) ifTrue:[ |
|
638 |
self doSaveAs. |
|
639 |
^false |
|
640 |
]. |
|
641 |
^true |
|
642 |
! |
|
643 |
||
644 |
doSaveAs |
|
645 |
"first ask for modification; |
|
646 |
then open a ResourceSelectionBrowser; |
|
647 |
after that extract the resource message; |
|
648 |
finally do save and make a new build" |
|
649 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
650 |
|resourceMessage myResourceType| |
867 | 651 |
|
652 |
self askForItemModification. |
|
653 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
654 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
655 |
|
867 | 656 |
(resourceMessage := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
657 |
request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class' |
867 | 658 |
onSuperclass: #Object |
659 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
660 |
andSelector: specSelector ? myResourceType |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
661 |
withResourceTypes: (Array with: myResourceType)) notNil |
867 | 662 |
ifTrue: |
663 |
[ |
|
664 |
modified := false. |
|
665 |
(self resourceMessage: resourceMessage) |
|
666 |
ifTrue: |
|
667 |
[ |
|
668 |
self doSave. |
|
669 |
self buildFromClass: specClass andSelector: specSelector. |
|
670 |
^true |
|
671 |
] |
|
672 |
]. |
|
673 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
674 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
675 |
"Modified: / 21.5.1998 / 02:59:46 / cg" |
867 | 676 |
! ! |
677 |
||
678 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
679 |
||
680 |
version |
|
1003 | 681 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.10 1998-07-21 12:16:08 tz Exp $' |
867 | 682 |
! ! |