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