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