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