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