author | Claus Gittinger <cg@exept.de> |
Thu, 17 May 2001 13:11:11 +0200 | |
changeset 1470 | 1ac79214af0f |
parent 1427 | b3e355574ccf |
child 1504 | 336f460e691b |
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 |
||
264 |
update:something with:aParameter from:someObject |
|
265 |
"one of my aspects has changed; update modified channel for the commit buttons" |
|
266 |
||
267 |
self valueOfEnablingCommitButtons value: true |
|
268 |
||
876 | 269 |
! |
270 |
||
271 |
updateAllToolInstances |
|
896 | 272 |
"updates the channels of all other instances of my class" |
876 | 273 |
|
274 |
self allToolInstances do: [:inst| inst updateChannels] |
|
275 |
||
276 |
! |
|
277 |
||
278 |
updateChannels |
|
896 | 279 |
"updates my channels" |
876 | 280 |
|
281 |
self valueOfCanPaste |
|
282 |
||
283 |
||
867 | 284 |
! ! |
285 |
||
286 |
!ResourceSpecEditor methodsFor:'help'! |
|
287 |
||
288 |
defaultInfoLabel |
|
889 | 289 |
"returns the default label for the info bar" |
867 | 290 |
|
291 |
|cls| |
|
292 |
(specClass isSymbol and: [(cls := Smalltalk at: specClass) isClass]) |
|
293 |
ifTrue: |
|
294 |
[ |
|
295 |
(cls class implements: specSelector) |
|
876 | 296 |
ifFalse: |
297 |
[ |
|
298 |
^specSelector isNil |
|
299 |
ifTrue: [specClass, ' >> ? (no selector defined)'] |
|
300 |
ifFalse: [specClass, ' >> ', specSelector, ' (not implemented)'] |
|
301 |
]. |
|
867 | 302 |
^specClass, ' >> ', specSelector |
303 |
]. |
|
304 |
^'No class and selector defined.' |
|
305 |
||
306 |
! ! |
|
307 |
||
308 |
!ResourceSpecEditor methodsFor:'initialization'! |
|
309 |
||
310 |
initialize |
|
311 |
"initialize the flags and the aspects" |
|
312 |
||
313 |
super initialize. |
|
314 |
||
896 | 315 |
hasSaved := modified := false. |
316 |
aspects := IdentityDictionary new. |
|
867 | 317 |
tabSelection := 0. |
318 |
||
319 |
self class aspects do: |
|
320 |
[:aKey| |
|
321 |
|holder| |
|
322 |
aspects at:aKey put: (holder := ValueHolder new). |
|
323 |
holder addDependent: self |
|
896 | 324 |
] |
867 | 325 |
! ! |
326 |
||
327 |
!ResourceSpecEditor methodsFor:'private'! |
|
328 |
||
329 |
askForItemModification |
|
889 | 330 |
"asks for resource item modification" |
867 | 331 |
|
1147 | 332 |
self valueOfEnablingCommitButtons value ifTrue:[ |
867 | 333 |
((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs) |
334 |
noText:'No'; |
|
335 |
yesText:'Yes'; |
|
336 |
showAtPointer; |
|
337 |
accepted) |
|
1147 | 338 |
ifFalse: [ |
867 | 339 |
self valueOfEnablingCommitButtons value: false. |
1201 | 340 |
self clearModifiedFlag. |
867 | 341 |
modified := false. |
342 |
^true |
|
343 |
]. |
|
344 |
self accept |
|
345 |
]. |
|
346 |
^true |
|
347 |
||
348 |
! |
|
349 |
||
350 |
askForListModification |
|
889 | 351 |
"asks for resource modification" |
867 | 352 |
|
353 |
modified |
|
354 |
ifTrue: |
|
355 |
[ |
|
929 | 356 |
((YesNoBox title:(resources string:'%1 spec was modified !!' with:self class resourceType asUppercaseFirst)) |
357 |
noText:(resources string:'Cancel'); |
|
358 |
yesText:(resources string:'Forget it and proceed'); |
|
867 | 359 |
showAtPointer; |
360 |
accepted) ifFalse: [^false]. |
|
361 |
modified := false |
|
362 |
]. |
|
363 |
^true |
|
929 | 364 |
|
365 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 366 |
! |
367 |
||
368 |
askForModification |
|
889 | 369 |
"asks first for item and then for resource modification" |
867 | 370 |
|
371 |
^self askForItemModification and: [self askForListModification] |
|
372 |
||
373 |
! |
|
374 |
||
375 |
resolveClassNamed |
|
889 | 376 |
"returns current class or nil" |
867 | 377 |
|
378 |
^Smalltalk resolveName:specClass inClass:self class |
|
379 |
! |
|
380 |
||
381 |
resourceMessage: aString |
|
889 | 382 |
"extracts from aString the specClass and the specSelector" |
867 | 383 |
|
384 |
(aString notNil and: [self askForModification]) |
|
385 |
ifTrue: |
|
386 |
[ |
|
387 |
|msg cls sel| |
|
388 |
msg := aString asCollectionOfWords. |
|
389 |
(msg size == 2 and: |
|
390 |
[(cls := self resolveName:(msg at:1)) notNil]) |
|
391 |
ifTrue: |
|
392 |
[ |
|
393 |
specClass := cls name. |
|
394 |
specSelector := (msg at: 2) asSymbol. |
|
395 |
^true |
|
396 |
] |
|
397 |
]. |
|
398 |
^false |
|
399 |
! |
|
400 |
||
401 |
updateHistory |
|
896 | 402 |
"updates the history, if there was loaded a resource spec" |
867 | 403 |
|
404 |
|cls| |
|
405 |
((cls := self resolveClassNamed) notNil and: [cls class implements: specSelector]) |
|
406 |
ifTrue: |
|
407 |
[ |
|
408 |
|className message| |
|
409 |
specClass isClass ifTrue: [className := specClass name]. |
|
410 |
specClass isString ifTrue: [className := specClass]. |
|
411 |
message := className, ' ', specSelector. |
|
412 |
self addToHistory: message -> #loadFromMessage: |
|
413 |
] |
|
414 |
! ! |
|
415 |
||
416 |
!ResourceSpecEditor methodsFor:'queries'! |
|
417 |
||
418 |
hasSaved |
|
896 | 419 |
"returns true if resource spec has saved" |
867 | 420 |
|
421 |
^hasSaved |
|
422 |
||
423 |
! |
|
424 |
||
425 |
isStandAlone |
|
896 | 426 |
"returns true if the editor was not started from another tool" |
867 | 427 |
|
428 |
^self masterApplication isNil |
|
429 |
! ! |
|
430 |
||
431 |
!ResourceSpecEditor methodsFor:'selection'! |
|
432 |
||
433 |
tabSelection |
|
434 |
"returns selected tab index or 0" |
|
435 |
||
436 |
^tabSelection |
|
437 |
||
438 |
! ! |
|
439 |
||
440 |
!ResourceSpecEditor methodsFor:'startup / release'! |
|
441 |
||
442 |
closeRequest |
|
896 | 443 |
"asks first for modification, then sends close request to super" |
867 | 444 |
|
445 |
self askForModification ifTrue: [super closeRequest] |
|
446 |
||
447 |
! |
|
448 |
||
449 |
loadFromMessage:aString |
|
896 | 450 |
"builds by evaluating aString the resource spec for editing" |
867 | 451 |
|
452 |
(aString notNil and: [self askForModification]) |
|
453 |
ifTrue: |
|
454 |
[ |
|
455 |
|msg cls sel| |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
456 |
|
867 | 457 |
msg := aString asCollectionOfWords. |
458 |
(msg size == 2 and: |
|
459 |
[(cls := self resolveName:(msg at:1)) notNil and: |
|
460 |
[cls class implements: (sel := (msg at: 2) asSymbol)]]) |
|
461 |
ifTrue: |
|
462 |
[ |
|
463 |
self isStandAlone |
|
464 |
ifFalse: [self buildFromResourceSpec: (cls perform: sel)] |
|
465 |
ifTrue: [self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel)]. |
|
466 |
^true |
|
467 |
] |
|
468 |
]. |
|
469 |
^false |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
470 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
471 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 472 |
! |
473 |
||
474 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 475 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 476 |
|
896 | 477 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 478 |
specSelector := aSelector. |
479 |
||
480 |
super openInterfaceModal. |
|
481 |
||
482 |
! |
|
483 |
||
484 |
openModalOnResourceSpec: aListSpec |
|
896 | 485 |
"builds first from specClass and specSelector the resource spec for editing, |
486 |
then opens modal the interface" |
|
867 | 487 |
|
488 |
self buildFromResourceSpec: aListSpec. |
|
489 |
||
490 |
super openInterfaceModal. |
|
491 |
||
492 |
! |
|
493 |
||
494 |
openOnClass:aClass andSelector:aSelector |
|
896 | 495 |
"sets the specClass and specSelector and opens the interface" |
867 | 496 |
|
896 | 497 |
specClass := aClass isClass ifTrue: [aClass name] ifFalse: [aClass asSymbol]. |
867 | 498 |
specSelector := aSelector. |
499 |
||
500 |
super openInterface. |
|
501 |
! |
|
502 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
503 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
504 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
505 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
506 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
507 |
super postBuildWith:aBuilder. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
508 |
|
1090 | 509 |
self class rememberInstance:self |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
510 |
|
1090 | 511 |
"Modified: / 4.2.1999 / 15:33:23 / cg" |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
512 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
513 |
|
867 | 514 |
postOpenWith:aBuilder |
896 | 515 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 516 |
|
517 |
super postOpenWith:aBuilder. |
|
518 |
||
896 | 519 |
self buildFromClass: specClass andSelector: specSelector |
867 | 520 |
|
876 | 521 |
! |
522 |
||
523 |
uninitialize |
|
896 | 524 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 525 |
|
526 |
super uninitialize. |
|
527 |
||
1090 | 528 |
self class forgetInstance:self |
876 | 529 |
|
1090 | 530 |
"Modified: / 4.2.1999 / 15:34:25 / cg" |
867 | 531 |
! ! |
532 |
||
533 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
534 |
||
535 |
accept |
|
896 | 536 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 537 |
|
1157 | 538 |
self acceptChannel |
1158 | 539 |
value:false; |
1157 | 540 |
value:true; "/ toggle to force inputFields to accept |
541 |
value:false. |
|
542 |
||
867 | 543 |
self valueOfEnablingCommitButtons value: false. |
1201 | 544 |
self clearModifiedFlag. |
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 |
|
1390
35f90684be49
browserClass from preferences
Claus Gittinger <cg@exept.de>
parents:
1201
diff
changeset
|
554 |
ifTrue: [UserPreferences current systemBrowserClass openInClass:cls class selector: specSelector] |
867 | 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 |
|
1470 | 678 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.19 2001-05-17 11:11:11 cg Exp $' |
867 | 679 |
! ! |