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