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