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