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