author | Claus Gittinger <cg@exept.de> |
Fri, 31 Mar 2006 19:53:06 +0200 | |
changeset 2131 | 768a3cb71598 |
parent 2120 | 0d32d6e4a918 |
child 2200 | 98ec425dc11c |
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 |
2111
c3aee5cae2fe
embedding as special editors
Claus Gittinger <cg@exept.de>
parents:
2110
diff
changeset
|
166 |
self modified:false |
2097 | 167 |
! |
168 |
||
867 | 169 |
modified |
889 | 170 |
"returns whether the resource spec was modified" |
867 | 171 |
|
2110 | 172 |
^ modified |
867 | 173 |
! |
174 |
||
175 |
modified: aBoolean |
|
896 | 176 |
"sets the resource spec modified as aBoolean" |
867 | 177 |
|
178 |
modified := aBoolean |
|
179 |
! |
|
180 |
||
2097 | 181 |
setModified |
2111
c3aee5cae2fe
embedding as special editors
Claus Gittinger <cg@exept.de>
parents:
2110
diff
changeset
|
182 |
self modified:true |
2097 | 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 |
||
2120 | 222 |
aspectAt:aKey put:aValueHolder |
223 |
aspects at: aKey put:aValueHolder |
|
224 |
! |
|
225 |
||
867 | 226 |
aspectFor:aKey |
889 | 227 |
"returns the aspect for a aKey or nil" |
867 | 228 |
|
229 |
^aspects at: aKey ifAbsent: [super aspectFor:aKey] |
|
230 |
||
231 |
! |
|
232 |
||
2103 | 233 |
canPasteHolder |
234 |
"returns whether the application can paste; as value holder" |
|
235 |
||
236 |
|holder| |
|
237 |
||
238 |
holder := super canPasteHolder. |
|
239 |
holder value:(self class clipboard notNil). |
|
240 |
^ holder |
|
241 |
! |
|
242 |
||
243 |
enableMovingInAboveHolder |
|
244 |
"returns whether the selected item can move into the previous item as child; |
|
245 |
as a value holder" |
|
246 |
||
247 |
^builder booleanValueAspectFor: #valueOfEnableMovingInAbove |
|
248 |
! |
|
249 |
||
250 |
enableMovingInHolder |
|
251 |
"returns whether the selected item can move into next item as child; as value holder" |
|
252 |
||
253 |
^builder booleanValueAspectFor: #valueOfEnableMovingIn |
|
254 |
! |
|
255 |
||
256 |
enableMovingOutHolder |
|
257 |
"returns whether the selected item can move out from its parent item; as value holder" |
|
258 |
||
259 |
^builder booleanValueAspectFor: #valueOfEnableMovingOut |
|
260 |
! |
|
261 |
||
262 |
enableMovingUpOrDownHolder |
|
263 |
"returns whether the selected item can move up or down; as value holder" |
|
264 |
||
265 |
^builder booleanValueAspectFor: #valueOfEnableMovingUpOrDown |
|
266 |
! |
|
267 |
||
867 | 268 |
tabModel |
889 | 269 |
"returns the value holder for the tab selection" |
867 | 270 |
|
271 |
|holder| |
|
272 |
(holder := builder bindingAt:#tabModel) isNil ifTrue:[ |
|
273 |
holder := AspectAdaptor new subject:self; forAspect:#tabSelection. |
|
274 |
builder aspectAt:#tabModel put:holder. |
|
275 |
]. |
|
276 |
^ holder |
|
277 |
! |
|
278 |
||
279 |
valueOfEnableMovingIn |
|
1470 | 280 |
"returns whether the selected item can move into next item as child; as value holder" |
867 | 281 |
|
2103 | 282 |
self obsoleteMethodWarning:'stupid name - use #enableMovingInHolder'. |
283 |
^ self enableMovingInHolder |
|
1470 | 284 |
! |
867 | 285 |
|
1470 | 286 |
valueOfEnableMovingInAbove |
287 |
"returns whether the selected item can move into the previous item as child; |
|
288 |
as a value holder" |
|
867 | 289 |
|
2103 | 290 |
self obsoleteMethodWarning:'stupid name - use #enableMovingInAboveHolder'. |
291 |
^ self enableMovingInAboveHolder |
|
867 | 292 |
! |
293 |
||
294 |
valueOfEnableMovingOut |
|
1470 | 295 |
"returns whether the selected item can move out from its parent item; as value holder" |
867 | 296 |
|
2103 | 297 |
self obsoleteMethodWarning:'stupid name - use #enableMovingOutHolder'. |
298 |
^ self enableMovingOutHolder |
|
867 | 299 |
! |
300 |
||
301 |
valueOfEnableMovingUpOrDown |
|
1470 | 302 |
"returns whether the selected item can move up or down; as value holder" |
867 | 303 |
|
2103 | 304 |
self obsoleteMethodWarning:'stupid name - use #enableMovingUpOrDownHolder'. |
305 |
^ self enableMovingUpOrDownHolder |
|
867 | 306 |
! ! |
307 |
||
308 |
!ResourceSpecEditor methodsFor:'building'! |
|
309 |
||
2037 | 310 |
buildFromClass: aClass andSelector: aSelector |
2097 | 311 |
^ self loadFromClass: aClass andSelector: aSelector |
2037 | 312 |
! |
313 |
||
867 | 314 |
buildFromResourceSpec: aResourceSpec |
868 | 315 |
"concrete subclass has to reimplement this method |
867 | 316 |
in order to build its resource spec from aResourceSpec" |
317 |
||
2097 | 318 |
^ self loadFromResourceSpec:aResourceSpec |
319 |
! |
|
320 |
||
321 |
loadFromClass: aClass andSelector: aSelector |
|
322 |
^ self subclassResponsibility |
|
323 |
! |
|
324 |
||
325 |
loadFromResourceSpec: aResourceSpec |
|
326 |
"concrete subclass has to reimplement this method |
|
327 |
in order to build its resource spec from aResourceSpec" |
|
328 |
||
868 | 329 |
^self subclassResponsibility |
867 | 330 |
! ! |
331 |
||
332 |
!ResourceSpecEditor methodsFor:'change & update'! |
|
333 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
334 |
update:something with:aParameter from:changedObject |
867 | 335 |
"one of my aspects has changed; update modified channel for the commit buttons" |
336 |
||
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
337 |
|enableCommitButtonsHolder| |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
338 |
|
2103 | 339 |
enableCommitButtonsHolder := self enablingCommitButtonsHolder. |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
340 |
|
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
341 |
changedObject ~~ enableCommitButtonsHolder ifTrue:[ |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
342 |
enableCommitButtonsHolder value: true |
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
343 |
] |
876 | 344 |
! |
345 |
||
346 |
updateAllToolInstances |
|
896 | 347 |
"updates the channels of all other instances of my class" |
876 | 348 |
|
349 |
self allToolInstances do: [:inst| inst updateChannels] |
|
350 |
||
351 |
! |
|
352 |
||
353 |
updateChannels |
|
896 | 354 |
"updates my channels" |
876 | 355 |
|
2103 | 356 |
"/ self valueOfCanPaste |
867 | 357 |
! ! |
358 |
||
359 |
!ResourceSpecEditor methodsFor:'help'! |
|
360 |
||
361 |
defaultInfoLabel |
|
889 | 362 |
"returns the default label for the info bar" |
867 | 363 |
|
2097 | 364 |
specClass isBehavior ifTrue:[ |
365 |
(specClass respondsTo:specSelector) ifTrue:[ |
|
366 |
^ specClass name, ' >> ', specSelector |
|
876 | 367 |
]. |
2097 | 368 |
specSelector isNil ifTrue:[ |
369 |
^ specClass name, ' >> ? (no selector defined)' |
|
370 |
]. |
|
371 |
^ specClass name, ' >> ', specSelector, ' (not implemented)' |
|
867 | 372 |
]. |
2097 | 373 |
^ 'No class and selector defined.' |
867 | 374 |
! ! |
375 |
||
376 |
!ResourceSpecEditor methodsFor:'initialization'! |
|
377 |
||
378 |
initialize |
|
379 |
"initialize the flags and the aspects" |
|
380 |
||
381 |
super initialize. |
|
382 |
||
896 | 383 |
hasSaved := modified := false. |
384 |
aspects := IdentityDictionary new. |
|
867 | 385 |
tabSelection := 0. |
386 |
||
387 |
self class aspects do: |
|
388 |
[:aKey| |
|
389 |
|holder| |
|
390 |
aspects at:aKey put: (holder := ValueHolder new). |
|
391 |
holder addDependent: self |
|
896 | 392 |
] |
867 | 393 |
! ! |
394 |
||
395 |
!ResourceSpecEditor methodsFor:'private'! |
|
396 |
||
397 |
askForItemModification |
|
889 | 398 |
"asks for resource item modification" |
867 | 399 |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
400 |
|anythingChangedHolder anythingChanged answer| |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
401 |
|
2103 | 402 |
anythingChangedHolder := self enablingCommitButtonsHolder. |
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
403 |
anythingChanged := anythingChangedHolder value. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
404 |
anythingChanged ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
405 |
"/ 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
|
406 |
"/ noText:'No'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
407 |
"/ yesText:'Yes'; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
408 |
"/ showAtPointer; |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
409 |
"/ accepted). |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
410 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
411 |
answer := Dialog |
1645 | 412 |
confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs) |
413 |
labels:(resources array:#('Cancel' 'No' 'Yes')) |
|
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
414 |
default:3. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
415 |
answer isNil ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
416 |
^ false |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
417 |
]. |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
418 |
|
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
419 |
answer ifTrue:[ |
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
420 |
self accept |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
421 |
] ifFalse:[ |
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
422 |
anythingChangedHolder value: false. |
1201 | 423 |
self clearModifiedFlag. |
2097 | 424 |
self clearModified. |
1874
4bd4f25fdada
oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents:
1870
diff
changeset
|
425 |
]. |
867 | 426 |
]. |
427 |
^true |
|
428 |
||
1524
6a0a84872e73
added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents:
1504
diff
changeset
|
429 |
"Modified: / 30.10.2001 / 18:38:34 / cg" |
867 | 430 |
! |
431 |
||
432 |
askForListModification |
|
889 | 433 |
"asks for resource modification" |
867 | 434 |
|
1870
c0475972bf3e
Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents:
1767
diff
changeset
|
435 |
self modified ifTrue: |
867 | 436 |
[ |
2037 | 437 |
((YesNoBox title:(resources string:'%1 spec was modified. Proceed?' with:self class resourceType asUppercaseFirst)) |
929 | 438 |
noText:(resources string:'Cancel'); |
2037 | 439 |
yesText:(resources string:'Discard Changes and Proceed'); |
867 | 440 |
showAtPointer; |
2037 | 441 |
accepted) ifFalse: [^ false]. |
2097 | 442 |
self clearModified |
867 | 443 |
]. |
2037 | 444 |
^ true |
929 | 445 |
|
446 |
"Modified: / 20.5.1998 / 03:40:26 / cg" |
|
867 | 447 |
! |
448 |
||
449 |
askForModification |
|
889 | 450 |
"asks first for item and then for resource modification" |
867 | 451 |
|
452 |
^self askForItemModification and: [self askForListModification] |
|
453 |
||
454 |
! |
|
455 |
||
2097 | 456 |
extractClassAndSelectorFrom:aString |
457 |
"extracts class and selector from a resource string. On success |
|
458 |
an association with the key a class and the selector as value |
|
459 |
is returned. Otherwise nil is returned |
|
460 |
" |
|
461 |
|words newClass newSel| |
|
462 |
||
463 |
aString size ~~ 0 ifTrue:[ |
|
464 |
words := aString asCollectionOfWords. |
|
867 | 465 |
|
2097 | 466 |
words size == 2 ifTrue:[ |
467 |
newClass := self resolveName:(words first). |
|
468 |
||
469 |
(newClass isClass and:[newClass isLoaded]) ifTrue:[ |
|
470 |
newSel := words last asSymbol. |
|
471 |
||
472 |
(newClass class includesSelector:newSel) ifTrue:[ |
|
473 |
^ Association key:newClass value:newSel |
|
474 |
]. |
|
475 |
]. |
|
476 |
]. |
|
477 |
]. |
|
478 |
^ nil |
|
867 | 479 |
! |
480 |
||
2097 | 481 |
updateHistory |
482 |
"updates the history, if there was loaded a resource spec" |
|
483 |
||
484 |
specClass notNil ifTrue:[ |
|
485 |
self addHistoryEntryForClass:specClass selector:specSelector |
|
486 |
] |
|
487 |
! |
|
867 | 488 |
|
2097 | 489 |
xxresourceMessage:aString |
490 |
"extracts the specClass and the specSelector from aString " |
|
491 |
||
492 |
|msg cls| |
|
493 |
||
494 |
(aString notNil and:[self askForModification]) ifTrue:[ |
|
867 | 495 |
msg := aString asCollectionOfWords. |
2097 | 496 |
(msg size == 2 |
497 |
and: [ (cls := self resolveName:(msg at:1)) notNil ]) |
|
498 |
ifTrue:[ |
|
499 |
specClass := cls. |
|
867 | 500 |
specSelector := (msg at: 2) asSymbol. |
501 |
^true |
|
502 |
] |
|
503 |
]. |
|
504 |
^false |
|
505 |
! ! |
|
506 |
||
507 |
!ResourceSpecEditor methodsFor:'queries'! |
|
508 |
||
509 |
hasSaved |
|
2107 | 510 |
"returns true if the resource spec was saved" |
867 | 511 |
|
2107 | 512 |
^ hasSaved |
867 | 513 |
! |
514 |
||
2110 | 515 |
isModified |
2111
c3aee5cae2fe
embedding as special editors
Claus Gittinger <cg@exept.de>
parents:
2110
diff
changeset
|
516 |
^ self modified |
2110 | 517 |
! |
518 |
||
2097 | 519 |
isNotStandAlone |
2107 | 520 |
"returns true if the editor was NOT started from or in another tool" |
2097 | 521 |
|
2107 | 522 |
^ self masterApplication notNil |
2097 | 523 |
! |
524 |
||
867 | 525 |
isStandAlone |
2097 | 526 |
"returns true if the editor was started from or in another tool" |
867 | 527 |
|
2107 | 528 |
^ self masterApplication isNil |
867 | 529 |
! ! |
530 |
||
531 |
!ResourceSpecEditor methodsFor:'selection'! |
|
532 |
||
533 |
tabSelection |
|
534 |
"returns selected tab index or 0" |
|
535 |
||
536 |
^tabSelection |
|
537 |
||
538 |
! ! |
|
539 |
||
1767 | 540 |
!ResourceSpecEditor methodsFor:'startup & release'! |
867 | 541 |
|
542 |
closeRequest |
|
2120 | 543 |
"asks for permission before closing" |
867 | 544 |
|
2120 | 545 |
self askForModification ifTrue: [ |
546 |
super closeRequest |
|
547 |
] |
|
867 | 548 |
! |
549 |
||
2097 | 550 |
loadFromMessage:classAndSelector |
896 | 551 |
"builds by evaluating aString the resource spec for editing" |
867 | 552 |
|
2097 | 553 |
|cls sel| |
554 |
||
555 |
self askForModification ifFalse:[ ^ false]. |
|
556 |
classAndSelector isNil ifTrue:[^ false]. |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
557 |
|
2097 | 558 |
cls := classAndSelector methodClass. |
559 |
sel := classAndSelector methodSelector. |
|
560 |
self isStandAlone |
|
561 |
ifFalse: [self loadFromResourceSpec: (cls perform: sel).] |
|
562 |
ifTrue: [self loadFromClass:cls andSelector:sel ]. |
|
563 |
^ true |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
564 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
565 |
"Modified: / 21.5.1998 / 02:56:46 / cg" |
867 | 566 |
! |
567 |
||
568 |
openModalOnClass:aClass andSelector:aSelector |
|
896 | 569 |
"sets the specClass and specSelector and opens modal the interface" |
867 | 570 |
|
2097 | 571 |
specClass := aClass isClass ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass]. |
867 | 572 |
specSelector := aSelector. |
573 |
||
1735 | 574 |
self openInterfaceModal. |
867 | 575 |
! |
576 |
||
577 |
openModalOnResourceSpec: aListSpec |
|
896 | 578 |
"builds first from specClass and specSelector the resource spec for editing, |
579 |
then opens modal the interface" |
|
867 | 580 |
|
1735 | 581 |
self allButOpen. |
2097 | 582 |
self loadFromResourceSpec:aListSpec. |
1735 | 583 |
self openWindowModal. |
867 | 584 |
! |
585 |
||
586 |
openOnClass:aClass andSelector:aSelector |
|
896 | 587 |
"sets the specClass and specSelector and opens the interface" |
867 | 588 |
|
2097 | 589 |
specClass := aClass isBehavior ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass]. |
867 | 590 |
specSelector := aSelector. |
591 |
||
1735 | 592 |
self openInterface. |
867 | 593 |
! |
594 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
595 |
postBuildWith:aBuilder |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
596 |
"after creating the views and before opening, |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
597 |
adds myself to the instances dictionary in the settings" |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
598 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
599 |
super postBuildWith:aBuilder. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
600 |
|
1090 | 601 |
self class rememberInstance:self |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
602 |
|
1090 | 603 |
"Modified: / 4.2.1999 / 15:33:23 / cg" |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
604 |
! |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
605 |
|
867 | 606 |
postOpenWith:aBuilder |
896 | 607 |
"after opening, builds from specClass and specSelector the resource spec for editing" |
867 | 608 |
|
609 |
super postOpenWith:aBuilder. |
|
610 |
||
2097 | 611 |
specClass notNil ifTrue:[ |
612 |
self loadFromClass: specClass andSelector: specSelector |
|
613 |
] |
|
876 | 614 |
! |
615 |
||
616 |
uninitialize |
|
896 | 617 |
"uninitializes; removes myself from the instances dictionary in the settings" |
876 | 618 |
|
619 |
super uninitialize. |
|
620 |
||
1090 | 621 |
self class forgetInstance:self |
876 | 622 |
|
1090 | 623 |
"Modified: / 4.2.1999 / 15:34:25 / cg" |
867 | 624 |
! ! |
625 |
||
626 |
!ResourceSpecEditor methodsFor:'user actions'! |
|
627 |
||
628 |
accept |
|
896 | 629 |
"invoked by the OK button; disables the commit buttons and sets myself modified" |
867 | 630 |
|
1157 | 631 |
self acceptChannel |
1158 | 632 |
value:false; |
1157 | 633 |
value:true; "/ toggle to force inputFields to accept |
634 |
value:false. |
|
635 |
||
2103 | 636 |
self enablingCommitButtonsHolder value: false. |
1201 | 637 |
self clearModifiedFlag. |
2097 | 638 |
self setModified |
867 | 639 |
! |
640 |
||
641 |
doBrowseClass |
|
889 | 642 |
"opens a System Browser on the specClass and specSelector" |
867 | 643 |
|
2097 | 644 |
specClass notNil |
645 |
ifTrue: [UserPreferences systemBrowserClass openInClass:specClass class selector: specSelector] |
|
867 | 646 |
ifFalse:[self information:'No class defined!!'] |
647 |
! |
|
648 |
||
649 |
doEditImage |
|
896 | 650 |
"opens a Image Editor on the resource retriever and the icon selector" |
867 | 651 |
|
2097 | 652 |
|resourceClass resourceSelector classAndSelector retrieverName| |
867 | 653 |
|
2097 | 654 |
resourceSelector := (aspects at:#icon) value. |
655 |
resourceSelector isEmptyOrNil ifTrue:[ resourceSelector := #icon ]. |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
656 |
|
2097 | 657 |
retrieverName := (aspects at:#retriever) value. |
658 |
retrieverName notEmptyOrNil ifTrue:[ |
|
659 |
resourceClass := Smalltalk classNamed:retrieverName |
|
1147 | 660 |
] ifFalse:[ |
2097 | 661 |
specClass notNil ifTrue:[ |
662 |
resourceClass := specClass withAllSuperclasses |
|
663 |
detect:[:cls| cls class includesSelector: resourceSelector] |
|
664 |
ifNone:[specClass] |
|
1003 | 665 |
] |
666 |
]. |
|
867 | 667 |
|
2097 | 668 |
(classAndSelector := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil |
1147 | 669 |
ifTrue: [ |
2097 | 670 |
resourceClass := classAndSelector at:1. |
671 |
resourceSelector := classAndSelector at:2. |
|
672 |
(aspects at:#retriever) value: resourceClass name. |
|
673 |
(aspects at:#icon) value: resourceSelector. |
|
2103 | 674 |
self enablingCommitButtonsHolder value: true |
867 | 675 |
] |
676 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
677 |
"Modified: / 21.5.1998 / 02:44:04 / cg" |
867 | 678 |
! |
679 |
||
680 |
doLoad |
|
889 | 681 |
"opens a Resource Selection Browser in order to get a resource message" |
867 | 682 |
|
2097 | 683 |
|myResourceType classAndSelector| |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
684 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
685 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
686 |
|
2097 | 687 |
classAndSelector := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
688 |
request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class' |
867 | 689 |
onSuperclass: nil |
690 |
andClass: specClass |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
691 |
andSelector: specSelector ? myResourceType |
2097 | 692 |
withResourceTypes: (Array with: myResourceType). |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
693 |
|
2097 | 694 |
classAndSelector isNil ifTrue:[ ^ self ]. |
695 |
^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) |
|
867 | 696 |
! |
697 |
||
698 |
doNew |
|
699 |
"first ask for modification; then clean specClass and specSelector, |
|
700 |
but only, if the editor is opened as stand alone; |
|
701 |
finally make a build of a resource spec containing no items" |
|
702 |
||
2037 | 703 |
self askForModification ifTrue:[ |
867 | 704 |
self isStandAlone ifTrue: [specClass := specSelector := nil]. |
2097 | 705 |
self loadFromClass:nil andSelector:(self class resourceType). |
2037 | 706 |
^ true |
867 | 707 |
]. |
2037 | 708 |
^ false |
867 | 709 |
! |
710 |
||
711 |
doSave |
|
712 |
"before saving ask for modification; if no specClass and specSelector |
|
713 |
is defined, do save as" |
|
714 |
||
715 |
self askForItemModification. |
|
716 |
||
717 |
(specClass isNil or:[specSelector isNil]) ifTrue:[ |
|
718 |
self doSaveAs. |
|
2097 | 719 |
^ false |
867 | 720 |
]. |
2097 | 721 |
^ true |
867 | 722 |
! |
723 |
||
724 |
doSaveAs |
|
725 |
"first ask for modification; |
|
726 |
then open a ResourceSelectionBrowser; |
|
727 |
after that extract the resource message; |
|
728 |
finally do save and make a new build" |
|
729 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
730 |
|resourceMessage myResourceType| |
867 | 731 |
|
732 |
self askForItemModification. |
|
733 |
||
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
734 |
myResourceType := self class resourceType. |
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
735 |
|
2097 | 736 |
resourceMessage := ResourceSelectionBrowser |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
737 |
request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class' |
867 | 738 |
onSuperclass: #Object |
2097 | 739 |
andClass: specClass name |
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
740 |
andSelector: specSelector ? myResourceType |
2097 | 741 |
withResourceTypes: (Array with: myResourceType). |
742 |
||
743 |
resourceMessage isNil ifTrue:[ ^ false ]. |
|
744 |
||
745 |
self clearModified. |
|
746 |
specClass := resourceMessage methodClass. |
|
747 |
specSelector := resourceMessage methodSelector. |
|
748 |
self doSave. |
|
749 |
self loadFromClass: specClass andSelector: specSelector. |
|
750 |
self halt. |
|
751 |
^ true |
|
934
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
752 |
|
c32a44c8913e
should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents:
929
diff
changeset
|
753 |
"Modified: / 21.5.1998 / 02:59:46 / cg" |
867 | 754 |
! ! |
755 |
||
756 |
!ResourceSpecEditor class methodsFor:'documentation'! |
|
757 |
||
758 |
version |
|
2120 | 759 |
^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.37 2006-03-06 08:52:26 cg Exp $' |
867 | 760 |
! ! |