author | Claus Gittinger <cg@exept.de> |
Wed, 15 Feb 2006 18:23:51 +0100 | |
changeset 2103 | ebe0bb50303d |
parent 2102 | ef76fea01343 |
child 2107 | 5503c65f2e64 |
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 |
2097 | 20 |
instanceVariableNames:'specClass specClassName specSelector aspects modified hasSaved |
21 |
tabSelection' |
|
867 | 22 |
classVariableNames:'' |
23 |
poolDictionaries:'' |
|
24 |
category:'Interface-Framework' |
|
25 |
! |
|
26 |
||
27 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
28 |
||
29 |
copyright |
|
30 |
" |
|
896 | 31 |
COPYRIGHT (c) 1997-1998 by eXept Software AG |
867 | 32 |
All Rights Reserved |
33 |
||
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
||
42 |
||
43 |
||
44 |
||
45 |
! |
|
46 |
||
47 |
documentation |
|
48 |
" |
|
896 | 49 |
Abstract super class for the MenuEditor, HierarchicalListEditor, |
50 |
and the TabListEditor. |
|
51 |
It provides common behavior for initializing, loading, saving, and |
|
52 |
asking for modifications of the resource specs (#menu, #hierarchicalList, |
|
53 |
#tabList) for the concrete subclasses. |
|
54 |
||
55 |
[instance variables:] |
|
56 |
specClass <Symbol> class implementing the resource spec |
|
57 |
specSelector <Symbol> selector returning the resource spec |
|
58 |
aspects <IdentityDictionary> dictionary with the attributes of the resource spec |
|
59 |
modified <Boolean> flag whether the resource spec was modified |
|
60 |
hasSaved <Boolean> flag whether the resource spec was saved |
|
61 |
tabSelection <Integer> index of the tab selection |
|
62 |
||
63 |
[see also:] |
|
64 |
MenuEditor |
|
65 |
HierarchicalListEditor |
|
66 |
TabListEditor |
|
867 | 67 |
|
68 |
[author:] |
|
876 | 69 |
Thomas Zwick, eXept Software AG |
867 | 70 |
" |
71 |
! ! |
|
72 |
||
73 |
!ResourceSpecEditor class methodsFor:'instance creation'! |
|
74 |
||
75 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 76 |
"opens modal the Resource Spec Editor on aClass and aSelector" |
867 | 77 |
|
78 |
^self new openModalOnClass:aClass andSelector:aSelector |
|
79 |
||
80 |
! |
|
81 |
||
82 |
openOnClass:aClass andSelector:aSelector |
|
896 | 83 |
"opens the Resource Spec Editor on aClass and aSelector" |
867 | 84 |
|
2102 | 85 |
^ self new openOnClass:aClass andSelector:aSelector |
867 | 86 |
! ! |
87 |
||
88 |
!ResourceSpecEditor class methodsFor:'accessing'! |
|
89 |
||
90 |
codeGenerationComment |
|
896 | 91 |
"returns a comment for the method code generated by myself" |
867 | 92 |
|
93 |
^self codeGenerationCommentForClass: self |
|
94 |
||
95 |
||
96 |
||
97 |
||
98 |
! |
|
99 |
||
1994 | 100 |
codeGenerationCommentForClass: generatingClass |
101 |
"returns a comment for the method code generated by generatingClass" |
|
102 |
||
103 |
|generatingClassName| |
|
104 |
||
105 |
generatingClassName := generatingClass name. |
|
867 | 106 |
|
107 |
^' "This resource specification was automatically generated\', |
|
1994 | 108 |
' by the ', generatingClassName, ' of ST/X."\\', |
867 | 109 |
|
110 |
' "Do not manually edit this!! If it is corrupted,\', |
|
1994 | 111 |
' the ', generatingClassName, ' may not be able to read the specification."' |
867 | 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. |
|
2103 | 155 |
inst enablingCommitButtonsHolder value: false. |
1147 | 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 |
||
2097 | 165 |
clearModified |
166 |
modified := false |
|
167 |
! |
|
168 |
||
867 | 169 |
modified |
889 | 170 |
"returns whether the resource spec was modified" |
867 | 171 |
|
172 |
^modified |
|
173 |
! |
|
174 |
||
175 |
modified: aBoolean |
|
896 | 176 |
"sets the resource spec modified as aBoolean" |
867 | 177 |
|
178 |
modified := aBoolean |
|
179 |
! |
|
180 |
||
2097 | 181 |
setModified |
182 |
modified := true |
|
183 |
! |
|
184 |
||
867 | 185 |
specClass |
889 | 186 |
"returns the class where the resource spec is implemented" |
867 | 187 |
|
2097 | 188 |
self halt. |
189 |
^ specClass |
|
867 | 190 |
! |
191 |
||
2097 | 192 |
specClass:aClassOrClassName |
889 | 193 |
"sets the class (or name) where the resource spec is (or should be) implemented" |
867 | 194 |
|
2097 | 195 |
aClassOrClassName isBehavior |
196 |
ifTrue: [ specClass := aClassOrClassName ] |
|
197 |
ifFalse:[ specClass := Smalltalk classNamed:aClassOrClassName ] |
|
198 |
! |
|
199 |
||
200 |
specClassName |
|
201 |
"returns the classes name where the resource spec is implemented" |
|
202 |
||
203 |
self halt. |
|
204 |
^ specClass name |
|
867 | 205 |
! |
206 |
||
207 |
specSelector |
|
889 | 208 |
"returns the method selector of the resource spec" |
867 | 209 |
|
210 |
^specSelector |
|
211 |
||
212 |
! |
|
213 |
||
214 |
specSelector:aSelector |
|
889 | 215 |
"sets the method selector of the resource spec" |
867 | 216 |
|
217 |
specSelector := aSelector |
|
218 |
! ! |
|
219 |
||
220 |
!ResourceSpecEditor methodsFor:'aspects'! |
|
221 |
||
222 |
aspectFor:aKey |
|
889 | 223 |
"returns the aspect for a aKey or nil" |
867 | 224 |
|
225 |
^aspects at: aKey ifAbsent: [super aspectFor:aKey] |
|
226 |
||
227 |
! |
|
228 |
||
2103 | 229 |
canPasteHolder |
230 |
"returns whether the application can paste; as value holder" |
|
231 |
||
232 |
|holder| |
|
233 |
||
234 |
holder := super canPasteHolder. |
|
235 |
holder value:(self class clipboard notNil). |
|
236 |
^ holder |
|
237 |
! |
|
238 |
||
239 |
enableMovingInAboveHolder |
|
240 |
"returns whether the selected item can move into the previous item as child; |
|
241 |
as a value holder" |
|
242 |
||
243 |
^builder booleanValueAspectFor: #valueOfEnableMovingInAbove |
|
244 |
! |
|
245 |
||
246 |
enableMovingInHolder |
|
247 |
"returns whether the selected item can move into next item as child; as value holder" |
|
248 |
||
249 |
^builder booleanValueAspectFor: #valueOfEnableMovingIn |
|
250 |
! |
|
251 |
||
252 |
enableMovingOutHolder |
|
253 |
"returns whether the selected item can move out from its parent item; as value holder" |
|
254 |
||
255 |
^builder booleanValueAspectFor: #valueOfEnableMovingOut |
|
256 |
! |
|
257 |
||
258 |
enableMovingUpOrDownHolder |
|
259 |
"returns whether the selected item can move up or down; as value holder" |
|
260 |
||
261 |
^builder booleanValueAspectFor: #valueOfEnableMovingUpOrDown |
|
262 |
! |
|
263 |
||
867 | 264 |
tabModel |
889 | 265 |
"returns the value holder for the tab selection" |
867 | 266 |
|
267 |
|holder| |
|
268 |
(holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
269 |
holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
270 |
builder aspectAt:#tabModel put:holder. |
|
271 |
]. |
|
272 |
^ holder |
|
273 |
! |
|
274 |
||
275 |
valueOfEnableMovingIn |
|
1470 | 276 |
"returns whether the selected item can move into next item as child; as value holder" |
867 | 277 |
|
2103 | 278 |
self obsoleteMethodWarning:'stupid name - use #enableMovingInHolder'. |
279 |
^ self enableMovingInHolder |
|
1470 | 280 |
! |
867 | 281 |
|
1470 | 282 |
valueOfEnableMovingInAbove |
283 |
"returns whether the selected item can move into the previous item as child; |
|
284 |
as a value holder" |
|
867 | 285 |
|
2103 | 286 |
self obsoleteMethodWarning:'stupid name - use #enableMovingInAboveHolder'. |
287 |
^ self enableMovingInAboveHolder |
|
867 | 288 |
! |
289 |
||
290 |
valueOfEnableMovingOut |
|
1470 | 291 |
"returns whether the selected item can move out from its parent item; as value holder" |
867 | 292 |
|
2103 | 293 |
self obsoleteMethodWarning:'stupid name - use #enableMovingOutHolder'. |
294 |
^ self enableMovingOutHolder |
|
867 | 295 |
! |
296 |
||
297 |
valueOfEnableMovingUpOrDown |
|
1470 | 298 |
"returns whether the selected item can move up or down; as value holder" |
867 | 299 |
|
2103 | 300 |
self obsoleteMethodWarning:'stupid name - use #enableMovingUpOrDownHolder'. |
301 |
^ self enableMovingUpOrDownHolder |
|
867 | 302 |
! ! |
303 |
||
304 |
!ResourceSpecEditor methodsFor:'building'! |
|
305 |
||
2037 | 306 |
buildFromClass: aClass andSelector: aSelector |
2097 | 307 |
^ self loadFromClass: aClass andSelector: aSelector |
2037 | 308 |
! |
309 |
||
867 | 310 |
buildFromResourceSpec: aResourceSpec |
868 | 311 |
"concrete subclass has to reimplement this method |
867 | 312 |
in order to build its resource spec from aResourceSpec" |
313 |
||
2097 | 314 |
^ self loadFromResourceSpec:aResourceSpec |
315 |
! |
|
316 |
||
317 |
loadFromClass: aClass andSelector: aSelector |
|
318 |
^ self subclassResponsibility |
|
319 |
! |
|
320 |
||
321 |
loadFromResourceSpec: aResourceSpec |
|
322 |
"concrete subclass has to reimplement this method |
|
323 |
in order to build its resource spec from aResourceSpec" |
|
324 |
||
868 | 325 |
^self subclassResponsibility |
867 | 326 |
! ! |
327 |
||
328 |
!ResourceSpecEditor methodsFor:'change & update'! |
|
329 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
330 |
update:something with:aParameter from:changedObject |
867 | 331 |
"one of my aspects has changed; update modified channel for the commit buttons" |
332 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
333 |
|enableCommitButtonsHolder| |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
334 |
|
2103 | 335 |
enableCommitButtonsHolder := self enablingCommitButtonsHolder. |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
336 |
|
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
337 |
changedObject ~~ enableCommitButtonsHolder ifTrue:[ |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
338 |
enableCommitButtonsHolder value: true |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
339 |
] |
876 | 340 |
! |
341 |
||
342 |
updateAllToolInstances |
|
896 | 343 |
"updates the channels of all other instances of my class" |
876 | 344 |
|
345 |
self allToolInstances do: [:inst| inst updateChannels] |
|
346 |
||
347 |
! |
|
348 |
||
349 |
updateChannels |
|
896 | 350 |
"updates my channels" |
876 | 351 |
|
2103 | 352 |
"/ self valueOfCanPaste |
867 | 353 |
! ! |
354 |
||
355 |
!ResourceSpecEditor methodsFor:'help'! |
|
356 |
||
357 |
defaultInfoLabel |
|
889 | 358 |
"returns the default label for the info bar" |
867 | 359 |
|
2097 | 360 |
specClass isBehavior ifTrue:[ |
361 |
(specClass respondsTo:specSelector) ifTrue:[ |
|
362 |
^ specClass name, ' >> ', specSelector |
|
876 | 363 |
]. |
2097 | 364 |
specSelector isNil ifTrue:[ |
365 |
^ specClass name, ' >> ? (no selector defined)' |
|
366 |
]. |
|
367 |
^ specClass name, ' >> ', specSelector, ' (not implemented)' |
|
867 | 368 |
]. |
2097 | 369 |
^ 'No class and selector defined.' |
867 | 370 |
! ! |
371 |
||
372 |
!ResourceSpecEditor methodsFor:'initialization'! |
|
373 |
||
374 |
initialize |
|
375 |
"initialize the flags and the aspects" |
|
376 |
||
377 |
super initialize. |
|
378 |
||
896 | 379 |
hasSaved := modified := false. |
380 |
aspects := IdentityDictionary new. |
|
867 | 381 |
tabSelection := 0. |
382 |
||
383 |
self class aspects do: |
|
384 |
[:aKey| |
|
385 |
|holder| |
|
386 |
aspects at:aKey put: (holder := ValueHolder new). |
|
387 |
holder addDependent: self |
|
896 | 388 |
] |
867 | 389 |
! ! |
390 |
||
391 |
!ResourceSpecEditor methodsFor:'private'! |
|
392 |
||
393 |
askForItemModification |
|
889 | 394 |
"asks for resource item modification" |
867 | 395 |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
396 |
|anythingChangedHolder anythingChanged answer| |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
397 |
|
2103 | 398 |
anythingChangedHolder := self enablingCommitButtonsHolder. |
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
399 |
anythingChanged := anythingChangedHolder value. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
400 |
anythingChanged ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
401 |
"/ 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
|
402 |
"/ noText:'No'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
403 |
"/ yesText:'Yes'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
404 |
"/ showAtPointer; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
405 |
"/ accepted). |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
406 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
407 |
answer := Dialog |
1645 | 408 |
confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs) |
409 |
labels:(resources array:#('Cancel' 'No' 'Yes')) |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
410 |
default:3. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
411 |
answer isNil ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
412 |
^ false |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
413 |
]. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
414 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
415 |
answer ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
416 |
self accept |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
417 |
] ifFalse:[ |
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
418 |
anythingChangedHolder value: false. |
1201 | 419 |
self clearModifiedFlag. |
2097 | 420 |
self clearModified. |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
421 |
]. |
867 | 422 |
]. |
423 |
^true |
|
424 |
||
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
425 |
"Modified: / 30.10.2001 / 18:38:34 / cg" |
867 | 426 |
! |
427 |
||
428 |
askForListModification |
|
889 | 429 |
"asks for resource modification" |
867 | 430 |
|
1870
c0475972bf3e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
1767
diff
changeset
|
431 |
self modified ifTrue: |
867 | 432 |
[ |
2037 | 433 |
((YesNoBox title:(resources string:'%1 spec was modified. Proceed?' with:self class resourceType asUppercaseFirst)) |
929 | 434 |
noText:(resources string:'Cancel'); |
2037 | 435 |
yesText:(resources string:'Discard Changes and Proceed'); |
867 | 436 |
showAtPointer; |
2037 | 437 |
accepted) ifFalse: [^ false]. |
2097 | 438 |
self clearModified |
867 | 439 |
]. |
2037 | 440 |
^ true |
929 | 441 |
|
442 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 443 |
! |
444 |
||
445 |
askForModification |
|
889 | 446 |
"asks first for item and then for resource modification" |
867 | 447 |
|
448 |
^self askForItemModification and: [self askForListModification] |
|
449 |
||
450 |
! |
|
451 |
||
2097 | 452 |
extractClassAndSelectorFrom:aString |
453 |
"extracts class and selector from a resource string. On success |
|
454 |
an association with the key a class and the selector as value |
|
455 |
is returned. Otherwise nil is returned |
|
456 |
" |
|
457 |
|words newClass newSel| |
|
458 |
||
459 |
aString size ~~ 0 ifTrue:[ |
|
460 |
words := aString asCollectionOfWords. |
|
867 | 461 |
|
2097 | 462 |
words size == 2 ifTrue:[ |
463 |
newClass := self resolveName:(words first). |
|
464 |
||
465 |
(newClass isClass and:[newClass isLoaded]) ifTrue:[ |
|
466 |
newSel := words last asSymbol. |
|
467 |
||
468 |
(newClass class includesSelector:newSel) ifTrue:[ |
|
469 |
^ Association key:newClass value:newSel |
|
470 |
]. |
|
471 |
]. |
|
472 |
]. |
|
473 |
]. |
|
474 |
^ nil |
|
867 | 475 |
! |
476 |
||
2097 | 477 |
updateHistory |
478 |
"updates the history, if there was loaded a resource spec" |
|
479 |
||
480 |
specClass notNil ifTrue:[ |
|
481 |
self addHistoryEntryForClass:specClass selector:specSelector |
|
482 |
] |
|
483 |
! |
|
867 | 484 |
|
2097 | 485 |
xxresourceMessage:aString |
486 |
"extracts the specClass and the specSelector from aString " |
|
487 |
||
488 |
|msg cls| |
|
489 |
||
490 |
(aString notNil and:[self askForModification]) ifTrue:[ |
|
867 | 491 |
msg := aString asCollectionOfWords. |
2097 | 492 |
(msg size == 2 |
493 |
and: [ (cls := self resolveName:(msg at:1)) notNil ]) |
|
494 |
ifTrue:[ |
|
495 |
specClass := cls. |
|
867 | 496 |
specSelector := (msg at: 2) asSymbol. |
497 |
^true |
|
498 |
] |
|
499 |
]. |
|
500 |
^false |
|
501 |
! ! |
|
502 |
||
503 |
!ResourceSpecEditor methodsFor:'queries'! |
|
504 |
||
505 |
hasSaved |
|
896 | 506 |
"returns true if resource spec has saved" |
867 | 507 |
|
508 |
^hasSaved |
|
509 |
||
510 |
! |
|
511 |
||
2097 | 512 |
isNotStandAlone |
513 |
"returns true if the editor was not started from or in another tool" |
|
514 |
||
515 |
^self masterApplication notNil |
|
516 |
! |
|
517 |
||
867 | 518 |
isStandAlone |
2097 | 519 |
"returns true if the editor was started from or in another tool" |
867 | 520 |
|
521 |
^self masterApplication isNil |
|
522 |
! ! |
|
523 |
||
524 |
!ResourceSpecEditor methodsFor:'selection'! |
|
525 |
||
526 |
tabSelection |
|
527 |
"returns selected tab index or 0" |
|
528 |
||
529 |
^tabSelection |
|
530 |
||
531 |
! ! |
|
532 |
||
1767 | 533 |
!ResourceSpecEditor methodsFor:'startup & release'! |
867 | 534 |
|
535 |
closeRequest |
|
896 | 536 |
"asks first for modification, then sends close request to super" |
867 | 537 |
|
538 |
self askForModification ifTrue: [super closeRequest] |
|
539 |
||
540 |
! |
|
541 |
||
2097 | 542 |
loadFromMessage:classAndSelector |
896 | 543 |
"builds by evaluating aString the resource spec for editing" |
867 | 544 |
|
2097 | 545 |
|cls sel| |
546 |
||
547 |
self askForModification ifFalse:[ ^ false]. |
|
548 |
classAndSelector isNil ifTrue:[^ false]. |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
549 |
|
2097 | 550 |
cls := classAndSelector methodClass. |
551 |
sel := classAndSelector methodSelector. |
|
552 |
self isStandAlone |
|
553 |
ifFalse: [self loadFromResourceSpec: (cls perform: sel).] |
|
554 |
ifTrue: [self loadFromClass:cls andSelector:sel ]. |
|
555 |
^ true |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
556 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
557 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 558 |
! |
559 |
||
560 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 561 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 562 |
|
2097 | 563 |
specClass := aClass isClass ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass]. |
867 | 564 |
specSelector := aSelector. |
565 |
||
1735 | 566 |
self openInterfaceModal. |
867 | 567 |
! |
568 |
||
569 |
openModalOnResourceSpec: aListSpec |
|
896 | 570 |
"builds first from specClass and specSelector the resource spec for editing, |
571 |
then opens modal the interface" |
|
867 | 572 |
|
1735 | 573 |
self allButOpen. |
2097 | 574 |
self loadFromResourceSpec:aListSpec. |
1735 | 575 |
self openWindowModal. |
867 | 576 |
! |
577 |
||
578 |
openOnClass:aClass andSelector:aSelector |
|
896 | 579 |
"sets the specClass and specSelector and opens the interface" |
867 | 580 |
|
2097 | 581 |
specClass := aClass isBehavior ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass]. |
867 | 582 |
specSelector := aSelector. |
583 |
||
1735 | 584 |
self openInterface. |
867 | 585 |
! |
586 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
587 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
588 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
589 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
590 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
591 |
super postBuildWith:aBuilder. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
592 |
|
1090 | 593 |
self class rememberInstance:self |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
594 |
|
1090 | 595 |
"Modified: / 4.2.1999 / 15:33:23 / cg" |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
596 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
597 |
|
867 | 598 |
postOpenWith:aBuilder |
896 | 599 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 600 |
|
601 |
super postOpenWith:aBuilder. |
|
602 |
||
2097 | 603 |
specClass notNil ifTrue:[ |
604 |
self loadFromClass: specClass andSelector: specSelector |
|
605 |
] |
|
876 | 606 |
! |
607 |
||
608 |
uninitialize |
|
896 | 609 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 610 |
|
611 |
super uninitialize. |
|
612 |
||
1090 | 613 |
self class forgetInstance:self |
876 | 614 |
|
1090 | 615 |
"Modified: / 4.2.1999 / 15:34:25 / cg" |
867 | 616 |
! ! |
617 |
||
618 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
619 |
||
620 |
accept |
|
896 | 621 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 622 |
|
1157 | 623 |
self acceptChannel |
1158 | 624 |
value:false; |
1157 | 625 |
value:true; "/ toggle to force inputFields to accept |
626 |
value:false. |
|
627 |
||
2103 | 628 |
self enablingCommitButtonsHolder value: false. |
1201 | 629 |
self clearModifiedFlag. |
2097 | 630 |
self setModified |
867 | 631 |
! |
632 |
||
633 |
doBrowseClass |
|
889 | 634 |
"opens a System Browser on the specClass and specSelector" |
867 | 635 |
|
2097 | 636 |
specClass notNil |
637 |
ifTrue: [UserPreferences systemBrowserClass openInClass:specClass class selector: specSelector] |
|
867 | 638 |
ifFalse:[self information:'No class defined!!'] |
639 |
! |
|
640 |
||
641 |
doEditImage |
|
896 | 642 |
"opens a Image Editor on the resource retriever and the icon selector" |
867 | 643 |
|
2097 | 644 |
|resourceClass resourceSelector classAndSelector retrieverName| |
867 | 645 |
|
2097 | 646 |
resourceSelector := (aspects at:#icon) value. |
647 |
resourceSelector isEmptyOrNil ifTrue:[ resourceSelector := #icon ]. |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
648 |
|
2097 | 649 |
retrieverName := (aspects at:#retriever) value. |
650 |
retrieverName notEmptyOrNil ifTrue:[ |
|
651 |
resourceClass := Smalltalk classNamed:retrieverName |
|
1147 | 652 |
] ifFalse:[ |
2097 | 653 |
specClass notNil ifTrue:[ |
654 |
resourceClass := specClass withAllSuperclasses |
|
655 |
detect:[:cls| cls class includesSelector: resourceSelector] |
|
656 |
ifNone:[specClass] |
|
1003 | 657 |
] |
658 |
]. |
|
867 | 659 |
|
2097 | 660 |
(classAndSelector := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
1147 | 661 |
ifTrue: [ |
2097 | 662 |
resourceClass := classAndSelector at:1. |
663 |
resourceSelector := classAndSelector at:2. |
|
664 |
(aspects at:#retriever) value: resourceClass name. |
|
665 |
(aspects at:#icon) value: resourceSelector. |
|
2103 | 666 |
self enablingCommitButtonsHolder value: true |
867 | 667 |
] |
668 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
669 |
"Modified: / 21.5.1998 / 02:44:04 / cg" |
867 | 670 |
! |
671 |
||
672 |
doLoad |
|
889 | 673 |
"opens a Resource Selection Browser in order to get a resource message" |
867 | 674 |
|
2097 | 675 |
|myResourceType classAndSelector| |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
676 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
677 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
678 |
|
2097 | 679 |
classAndSelector := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
680 |
request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class' |
867 | 681 |
onSuperclass: nil |
682 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
683 |
andSelector: specSelector ? myResourceType |
2097 | 684 |
withResourceTypes: (Array with: myResourceType). |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
685 |
|
2097 | 686 |
classAndSelector isNil ifTrue:[ ^ self ]. |
687 |
^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
867 | 688 |
! |
689 |
||
690 |
doNew |
|
691 |
"first ask for modification; then clean specClass and specSelector, |
|
692 |
but only, if the editor is opened as stand alone; |
|
693 |
finally make a build of a resource spec containing no items" |
|
694 |
||
2037 | 695 |
self askForModification ifTrue:[ |
867 | 696 |
self isStandAlone ifTrue: [specClass := specSelector := nil]. |
2097 | 697 |
self loadFromClass:nil andSelector:(self class resourceType). |
2037 | 698 |
^ true |
867 | 699 |
]. |
2037 | 700 |
^ false |
867 | 701 |
! |
702 |
||
703 |
doSave |
|
704 |
"before saving ask for modification; if no specClass and specSelector |
|
705 |
is defined, do save as" |
|
706 |
||
707 |
self askForItemModification. |
|
708 |
||
709 |
(specClass isNil or:[specSelector isNil]) ifTrue:[ |
|
710 |
self doSaveAs. |
|
2097 | 711 |
^ false |
867 | 712 |
]. |
2097 | 713 |
^ true |
867 | 714 |
! |
715 |
||
716 |
doSaveAs |
|
717 |
"first ask for modification; |
|
718 |
then open a ResourceSelectionBrowser; |
|
719 |
after that extract the resource message; |
|
720 |
finally do save and make a new build" |
|
721 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
722 |
|resourceMessage myResourceType| |
867 | 723 |
|
724 |
self askForItemModification. |
|
725 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
726 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
727 |
|
2097 | 728 |
resourceMessage := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
729 |
request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class' |
867 | 730 |
onSuperclass: #Object |
2097 | 731 |
andClass: specClass name |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
732 |
andSelector: specSelector ? myResourceType |
2097 | 733 |
withResourceTypes: (Array with: myResourceType). |
734 |
||
735 |
resourceMessage isNil ifTrue:[ ^ false ]. |
|
736 |
||
737 |
self clearModified. |
|
738 |
specClass := resourceMessage methodClass. |
|
739 |
specSelector := resourceMessage methodSelector. |
|
740 |
self doSave. |
|
741 |
self loadFromClass: specClass andSelector: specSelector. |
|
742 |
self halt. |
|
743 |
^ true |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
744 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
745 |
"Modified: / 21.5.1998 / 02:59:46 / cg" |
867 | 746 |
! ! |
747 |
||
748 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
749 |
||
750 |
version |
|
2103 | 751 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.33 2006-02-15 17:23:51 cg Exp $' |
867 | 752 |
! ! |