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