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