author | Claus Gittinger <cg@exept.de> |
Fri, 28 Mar 2003 20:05:37 +0100 | |
changeset 4740 | ecd679058be3 |
parent 4716 | 3df92d455996 |
child 4826 | 14296f826d27 |
permissions | -rw-r--r-- |
4378 | 1 |
"{ Package: 'stx:libtool' }" |
2 |
||
3 |
ApplicationModel subclass:#SettingsDialog |
|
4 |
instanceVariableNames:'requestor subCanvasApplicationHolder help doReload doSave |
|
5 |
enableReload enableHelp enableOK selectedItem applicationList |
|
4405 | 6 |
categoryIcons lastSelection' |
4378 | 7 |
classVariableNames:'ApplicationList IconList' |
8 |
poolDictionaries:'' |
|
9 |
category:'Interface-Smalltalk' |
|
10 |
! |
|
11 |
||
12 |
HierarchicalList subclass:#HierarchicalApplicationList |
|
13 |
instanceVariableNames:'' |
|
14 |
classVariableNames:'' |
|
15 |
poolDictionaries:'' |
|
16 |
privateIn:SettingsDialog |
|
17 |
! |
|
18 |
||
19 |
HierarchicalItem subclass:#ApplicationItem |
|
20 |
instanceVariableNames:'application applicationClass icon label nameString' |
|
21 |
classVariableNames:'' |
|
22 |
poolDictionaries:'' |
|
23 |
privateIn:SettingsDialog::HierarchicalApplicationList |
|
24 |
! |
|
25 |
||
26 |
!SettingsDialog class methodsFor:'documentation'! |
|
27 |
||
28 |
documentation |
|
29 |
||
30 |
" |
|
4494 | 31 |
This is an application which presents a hierarchy of settings applications |
32 |
||
4378 | 33 |
[author:] |
34 |
Christian Penk, eXept Software AG |
|
4494 | 35 |
|
36 |
[see also:] |
|
37 |
AbstractLauncherApplication defaultSettingsApplicationList |
|
4378 | 38 |
" |
4400 | 39 |
! |
40 |
||
41 |
examples |
|
42 |
||
43 |
" |
|
4494 | 44 |
start a Settings Dialog with a language Settings Application under root |
4400 | 45 |
[exBegin] |
46 |
| settingsApp | |
|
47 |
||
48 |
settingsApp := self new. |
|
49 |
settingsApp addApplClass:#'AbstractSettingsApplication::LanguageSettingsAppl' |
|
50 |
withName:'Language'. |
|
51 |
settingsApp open. |
|
52 |
[exEnd] |
|
53 |
||
54 |
||
4494 | 55 |
start a Settings Dialog with a language Settings Application under root/Test |
4400 | 56 |
[exBegin] |
57 |
| settingsApp | |
|
58 |
||
59 |
settingsApp := self new. |
|
60 |
settingsApp addApplClass:#'AbstractSettingsApplication::LanguageSettingsAppl' |
|
61 |
withName:'Test/Language'. |
|
62 |
settingsApp open. |
|
63 |
[exEnd] |
|
64 |
||
4494 | 65 |
start a Settings Dialog with a language Settings Application under root/Test |
66 |
with an other category test icon |
|
4400 | 67 |
[exBegin] |
68 |
| settingsApp | |
|
69 |
||
70 |
settingsApp := self new. |
|
71 |
settingsApp addApplClass:#'AbstractSettingsApplication::LanguageSettingsAppl' |
|
72 |
withName:'Test/Language'. |
|
4401 | 73 |
settingsApp addIcon:ToolbarIconLibrary start22x22Icon forCategory:'Test'. |
4400 | 74 |
settingsApp open. |
75 |
[exEnd] |
|
4401 | 76 |
|
4494 | 77 |
start a Settings Dialog with a language and memory Settings Application |
78 |
in different categories |
|
4400 | 79 |
[exBegin] |
80 |
| settingsApp | |
|
81 |
||
82 |
settingsApp := self new. |
|
83 |
settingsApp addIcon:ToolbarIconLibrary start22x22Icon forCategory:'Test'. |
|
84 |
settingsApp addApplClass:#'AbstractSettingsApplication::LanguageSettingsAppl' |
|
85 |
withName:'Test/Language'. |
|
86 |
settingsApp addApplClass:#'AbstractSettingsApplication::MemorySettingsAppl' |
|
87 |
withName:'Test2/Memory'. |
|
88 |
settingsApp open. |
|
89 |
[exEnd] |
|
90 |
" |
|
4378 | 91 |
! ! |
92 |
||
93 |
!SettingsDialog class methodsFor:'accessing'! |
|
94 |
||
95 |
itemClass |
|
96 |
||
97 |
^ SettingsDialog::HierarchicalApplicationList::ApplicationItem |
|
98 |
! ! |
|
99 |
||
100 |
!SettingsDialog class methodsFor:'application icons'! |
|
101 |
||
102 |
defaultSettingsAppIcon |
|
103 |
||
104 |
^ self settingsIcon |
|
105 |
! |
|
106 |
||
107 |
settingsIcon |
|
108 |
"This resource specification was automatically generated |
|
109 |
by the ImageEditor of ST/X." |
|
110 |
||
111 |
"Do not manually edit this!! If it is corrupted, |
|
112 |
the ImageEditor may not be able to read the specification." |
|
113 |
||
114 |
" |
|
115 |
self settingsIcon inspect |
|
116 |
ImageEditor openOnClass:self andSelector:#settingsIcon |
|
117 |
Icon flushCachedIcons |
|
118 |
" |
|
119 |
||
120 |
<resource: #image> |
|
121 |
||
122 |
^Icon |
|
123 |
constantNamed:#'AbstractLauncherApplication::SettingsDialog class settingsIcon' |
|
124 |
ifAbsentPut:[(Depth8Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(8 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:' |
|
125 |
@@BP#8>O#8>M @@@@@@@@@@@@@@@@BJ%9&Y&Y&Y%R^B@@@@@@@@@@@@@@BI&J^(*J"(*JZTIIFQ$YFQ$YH@@@@@ JN#(:N#(:N#(9.V%)ZV%)ZKZP@@@HOU |
|
126 |
4=OS4=OL3,''I0<B;/]F3*TE?@@BC5MKR4-KM,\^:.MJ:-;21/:1D_@@@ =SR4-KM3<+K/<J01,R20+R+QG0@@HOT4-KR/,^?-\[H1(Q^WW"1*4Q<@@BC5MKR |
|
127 |
,-CO1<>/+(X*F1(S,Z1D_@@@ =SR4-J:2,[J0X TU!!BE+F$GS!!=@HOT,+WK.\J/28\&TV=EKAV1RELG BC5L7H0-KB/HT TV-CKA8>TG@=_H8M ;[H1+:: |
|
128 |
-;8\TWECKBD9)T=0]R40AXOE2;F5-;:/G6)EKBD?ZF5KV#ITJ0M>''*B_''ZF]''5,(KA8)X8ENU#XR@ )L^1$YFQ$YFQ$WBA PE@QMVSDON82S@@@@@@@@@@@@ |
|
129 |
@@A_@F)IU#DQMWH@@@@@@@@@@@@@@@@@@F1JWC\LMJI''^ @@@@@@@@@@@@@@@F9GU28ROGI%+VY4@@@@@@@@@@@@@GIFXC(IL9(@^VR*X''\@@@@@@@@@@@AU |
|
130 |
IPXKP@@@@@A3XZ4#@@@@@@@@@@@@# 8AK90@@@@@@GX"T @a') ; colorMapFromArray:#[0 0 0 0 60 60 0 84 84 4 45 45 21 20 15 38 38 38 38 192 192 43 43 43 45 45 45 45 151 151 46 99 99 46 147 147 46 151 151 47 47 47 47 88 88 47 151 151 48 48 48 48 144 144 48 145 145 56 53 38 57 57 49 59 52 40 62 56 43 65 65 53 65 65 65 67 67 54 68 68 68 70 70 70 72 64 47 72 72 35 72 72 72 73 69 48 73 73 73 74 74 74 80 44 10 80 62 43 81 81 24 84 132 132 85 85 76 86 86 36 86 86 86 87 87 49 87 87 77 87 193 193 88 88 88 91 101 101 92 193 193 94 117 117 97 97 97 97 193 193 98 195 195 99 120 120 101 75 31 101 107 89 101 193 193 102 193 193 103 103 103 104 86 69 106 193 193 107 120 120 107 121 121 109 109 109 110 96 70 111 78 42 111 119 119 113 113 60 113 113 113 115 115 115 116 116 56 116 116 116 116 145 145 118 147 147 119 121 85 121 150 150 122 151 151 122 152 148 124 124 124 124 146 139 124 151 149 127 118 78 127 119 78 128 128 128 129 120 112 133 157 157 135 216 216 137 137 137 139 207 207 140 206 206 141 141 141 141 201 201 141 202 202 142 136 75 142 201 201 143 128 88 143 143 88 144 144 144 144 204 204 145 85 24 146 126 100 147 82 13 148 83 17 148 86 24 148 123 91 148 127 98 149 122 89 150 150 150 151 151 151 152 152 152 152 155 155 153 129 100 154 154 154 156 156 156 156 199 199 157 157 157 158 158 158 159 159 159 160 160 160 162 179 179 163 161 159 163 163 162 164 151 101 164 160 156 164 163 161 165 165 150 165 165 165 168 168 168 169 169 62 171 171 171 172 172 71 174 117 58 177 177 177 178 178 89 185 174 113 186 178 115 186 186 115 189 179 116 189 189 115 189 189 132 190 190 139 192 192 142 192 192 192 193 193 154 194 194 194 196 196 155 197 197 159 200 200 168 202 202 174 202 202 202 204 204 102 205 205 97 206 206 149 210 210 144 210 210 149 213 213 103 213 213 213 215 215 164 215 215 215 227 212 124 227 213 140 227 217 124 227 220 124 227 227 124 234 156 79 236 236 197 239 214 144 243 201 148 243 243 146 243 243 155 244 244 147 245 232 157 247 165 83 248 215 149 248 231 149 255 170 86 255 227 156 255 228 156 255 229 156 255 230 156 255 231 156 255 233 168 255 234 156 255 235 156 255 235 193 255 236 156 255 237 156 255 238 156 255 239 156 255 239 168 255 240 156 255 240 168 255 241 156 255 242 156 255 242 168 255 243 156 255 244 156 255 244 168 255 245 156 255 245 193 255 246 156 255 247 156 255 248 156 255 248 168 255 249 156 255 250 156 255 250 168 255 251 156 255 251 168 255 252 156 255 253 156 255 253 168 255 255 156 255 255 168 255 255 193 255 255 200]; mask:((ImageMask new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'O<@@_>@@???@??? ???0???0???0???0???0???8???8???<???<???<???<???8@B? @A?0@C?8@G=<@G0<@G0\') ; yourself); yourself] |
|
131 |
! ! |
|
132 |
||
4397 | 133 |
!SettingsDialog class methodsFor:'defaults'! |
134 |
||
135 |
expandParents |
|
136 |
||
137 |
^ true |
|
138 |
! ! |
|
139 |
||
4469 | 140 |
!SettingsDialog class methodsFor:'initialize'! |
141 |
||
142 |
initialize |
|
4494 | 143 |
AbstractSettingsApplication isLoaded ifFalse:[ |
144 |
AbstractSettingsApplication autoload. |
|
4469 | 145 |
] |
146 |
! ! |
|
147 |
||
4378 | 148 |
!SettingsDialog class methodsFor:'interface specs'! |
149 |
||
150 |
windowSpec |
|
151 |
"This resource specification was automatically generated |
|
152 |
by the UIPainter of ST/X." |
|
153 |
||
154 |
"Do not manually edit this!! If it is corrupted, |
|
155 |
the UIPainter may not be able to read the specification." |
|
156 |
||
157 |
" |
|
158 |
UIPainter new openOnClass:SettingsDialog andSelector:#windowSpec |
|
159 |
SettingsDialog new openInterface:#windowSpec |
|
160 |
SettingsDialog open |
|
161 |
" |
|
162 |
||
163 |
<resource: #canvas> |
|
164 |
||
165 |
^ |
|
166 |
#(#FullSpec |
|
167 |
#name: #windowSpec |
|
168 |
#window: |
|
169 |
#(#WindowSpec |
|
170 |
#label: 'Settings Dialog' |
|
171 |
#name: 'Settings Dialog' |
|
172 |
#min: #(#Point 10 10) |
|
173 |
#max: #(#Point 1024 768) |
|
174 |
#bounds: #(#Rectangle 16 42 816 662) |
|
175 |
#menu: #mainMenu |
|
176 |
) |
|
177 |
#component: |
|
178 |
#(#SpecCollection |
|
179 |
#collection: #( |
|
180 |
#(#VariableHorizontalPanelSpec |
|
181 |
#name: 'VariableHorizontalPanel1' |
|
182 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) |
|
183 |
#showHandle: true |
|
184 |
#snapMode: #both |
|
185 |
#component: |
|
186 |
#(#SpecCollection |
|
187 |
#collection: #( |
|
188 |
#(#ViewSpec |
|
189 |
#name: 'Box1' |
|
190 |
#component: |
|
191 |
#(#SpecCollection |
|
192 |
#collection: #( |
|
193 |
#(#HierarchicalListViewSpec |
|
194 |
#name: 'HierarchicalListView1' |
|
195 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1) |
|
196 |
#model: #selectedItem |
|
197 |
#hasHorizontalScrollBar: true |
|
198 |
#hasVerticalScrollBar: true |
|
199 |
#listModel: #applicationList |
|
200 |
#useIndex: false |
|
201 |
#highlightMode: #label |
|
202 |
#showLeftIndicators: false |
|
203 |
#indicatorSelector: #doIndicatorClick: |
|
204 |
) |
|
205 |
#(#HorizontalPanelViewSpec |
|
206 |
#name: 'HorizontalPanel2' |
|
207 |
#layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1) |
|
208 |
#horizontalLayout: #fitSpace |
|
209 |
#verticalLayout: #center |
|
210 |
#horizontalSpace: 3 |
|
211 |
#verticalSpace: 3 |
|
212 |
#component: |
|
213 |
#(#SpecCollection |
|
214 |
#collection: #( |
|
215 |
#(#ActionButtonSpec |
|
216 |
#label: 'Save as...' |
|
217 |
#name: 'Button1' |
|
218 |
#translateLabel: true |
|
4574 | 219 |
#model: #saveSettingsIntoFile |
4378 | 220 |
#extent: #(#Point 128 22) |
221 |
) |
|
222 |
#(#ActionButtonSpec |
|
223 |
#label: 'Load from...' |
|
224 |
#name: 'Button2' |
|
225 |
#translateLabel: true |
|
4574 | 226 |
#model: #loadSettingsFromFile |
4378 | 227 |
#extent: #(#Point 128 22) |
228 |
) |
|
229 |
) |
|
230 |
||
231 |
) |
|
232 |
) |
|
233 |
) |
|
234 |
||
235 |
) |
|
236 |
) |
|
237 |
#(#ViewSpec |
|
238 |
#name: 'Box2' |
|
239 |
#component: |
|
240 |
#(#SpecCollection |
|
241 |
#collection: #( |
|
242 |
#(#SubCanvasSpec |
|
243 |
#name: 'SubCanvas' |
|
244 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -34 1) |
|
245 |
#level: -1 |
|
246 |
#hasHorizontalScrollBar: false |
|
247 |
#hasVerticalScrollBar: false |
|
248 |
#clientHolder: #subCanvasApplicationHolder |
|
249 |
#postBuildCallback: #postBuildSubCanvas: |
|
250 |
) |
|
251 |
#(#HorizontalPanelViewSpec |
|
252 |
#name: 'HorizontalPanel1' |
|
253 |
#layout: #(#LayoutFrame 0 0.0 -34 1 0 1.0 0 1) |
|
254 |
#horizontalLayout: #fitSpace |
|
255 |
#verticalLayout: #center |
|
256 |
#horizontalSpace: 3 |
|
257 |
#verticalSpace: 3 |
|
258 |
#component: |
|
259 |
#(#SpecCollection |
|
260 |
#collection: #( |
|
261 |
#(#ActionButtonSpec |
|
262 |
#label: 'OK' |
|
263 |
#name: 'OK' |
|
264 |
#translateLabel: true |
|
265 |
#model: #doSave |
|
266 |
#enableChannel: #enableOK |
|
267 |
#extent: #(#Point 127 22) |
|
268 |
) |
|
269 |
#(#ActionButtonSpec |
|
270 |
#label: 'Discard' |
|
271 |
#name: 'Reload' |
|
272 |
#translateLabel: true |
|
273 |
#model: #doReload |
|
274 |
#enableChannel: #enableReload |
|
275 |
#extent: #(#Point 128 22) |
|
276 |
) |
|
277 |
#(#ActionButtonSpec |
|
278 |
#label: 'Close' |
|
279 |
#name: 'Close' |
|
280 |
#translateLabel: true |
|
281 |
#model: #closeRequest |
|
282 |
#extent: #(#Point 127 22) |
|
283 |
) |
|
284 |
#(#ActionButtonSpec |
|
285 |
#label: 'Help' |
|
286 |
#name: 'Help' |
|
287 |
#translateLabel: true |
|
288 |
#model: #help |
|
289 |
#enableChannel: #enableHelp |
|
290 |
#extent: #(#Point 128 22) |
|
291 |
) |
|
292 |
) |
|
293 |
||
294 |
) |
|
295 |
) |
|
296 |
) |
|
297 |
||
298 |
) |
|
299 |
) |
|
300 |
) |
|
301 |
||
302 |
) |
|
303 |
#handles: #(#Any 0.3375 1.0) |
|
304 |
) |
|
305 |
) |
|
306 |
||
307 |
) |
|
308 |
) |
|
309 |
! ! |
|
310 |
||
4548 | 311 |
!SettingsDialog class methodsFor:'menu actions'! |
312 |
||
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
313 |
saveSettingsIntoFile |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
314 |
|fileName resources| |
4548 | 315 |
|
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
316 |
resources := self classResources. |
4548 | 317 |
|
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
318 |
fileName := Dialog |
4740 | 319 |
requestFileName:(resources string:'Save Settings in File') |
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
320 |
default:'settings.stx' |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
321 |
ok:(resources string:'Save') |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
322 |
abort:(resources string:'Cancel') |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
323 |
pattern:'*.stx' |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
324 |
fromDirectory:'.'. |
4548 | 325 |
|
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
326 |
fileName size ~~ 0 ifTrue:[ |
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
327 |
"not canceled" |
4639
d52b3f639d93
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4574
diff
changeset
|
328 |
[ |
d52b3f639d93
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4574
diff
changeset
|
329 |
UserPreferences current saveIn:fileName. |
d52b3f639d93
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4574
diff
changeset
|
330 |
] on:StreamError do:[:ex| |
d52b3f639d93
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4574
diff
changeset
|
331 |
self warn:('Cannot save settings into: %1\(%2)' bindWith:fileName with:ex description) withCRs. |
d52b3f639d93
Handle openErrorSignal in preparition for change openErrorSignal
Stefan Vogel <sv@exept.de>
parents:
4574
diff
changeset
|
332 |
] |
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
333 |
] |
4548 | 334 |
! ! |
335 |
||
4378 | 336 |
!SettingsDialog class methodsFor:'menu specs'! |
337 |
||
338 |
mainMenu |
|
339 |
"This resource specification was automatically generated |
|
340 |
by the MenuEditor of ST/X." |
|
341 |
||
342 |
"Do not manually edit this!! If it is corrupted, |
|
343 |
the MenuEditor may not be able to read the specification." |
|
344 |
||
345 |
" |
|
346 |
MenuEditor new openOnClass:SettingsDialog andSelector:#mainMenu |
|
347 |
(Menu new fromLiteralArrayEncoding:(SettingsDialog mainMenu)) startUp |
|
348 |
" |
|
349 |
||
350 |
<resource: #menu> |
|
351 |
||
352 |
^ |
|
353 |
#(#Menu |
|
354 |
#( |
|
355 |
#(#MenuItem |
|
356 |
#label: 'File' |
|
357 |
#translateLabel: true |
|
358 |
#submenu: |
|
359 |
#(#Menu |
|
360 |
#( |
|
361 |
#(#MenuItem |
|
4740 | 362 |
#label: 'Load From...' |
4574 | 363 |
#itemValue: #loadSettingsFromFile |
4378 | 364 |
#translateLabel: true |
365 |
) |
|
366 |
#(#MenuItem |
|
4740 | 367 |
#label: 'Save As...' |
4574 | 368 |
#itemValue: #saveSettingsIntoFile |
4378 | 369 |
#translateLabel: true |
370 |
) |
|
371 |
#(#MenuItem |
|
4740 | 372 |
#label: '-' |
373 |
) |
|
374 |
#(#MenuItem |
|
4378 | 375 |
#label: 'Exit' |
376 |
#itemValue: #closeRequest |
|
377 |
#translateLabel: true |
|
378 |
) |
|
379 |
) |
|
380 |
nil |
|
381 |
nil |
|
382 |
) |
|
383 |
) |
|
384 |
) |
|
385 |
nil |
|
386 |
nil |
|
387 |
) |
|
388 |
! ! |
|
389 |
||
390 |
!SettingsDialog methodsFor:'accessing'! |
|
391 |
||
392 |
requestor |
|
393 |
"return the 'requestor' of the SettingsDialog" |
|
394 |
||
395 |
^ requestor |
|
396 |
! |
|
397 |
||
398 |
requestor:something |
|
399 |
"set the value of the instance variable 'requestor' (automatically generated)" |
|
400 |
||
401 |
requestor := something. |
|
402 |
! ! |
|
403 |
||
404 |
!SettingsDialog methodsFor:'actions'! |
|
405 |
||
406 |
destroyAll |
|
407 |
||
408 |
self applicationList do:[ : applItem | |
|
409 |
(applItem isCategory not and:[applItem application notNil]) ifTrue:[ |
|
410 |
applItem application close. |
|
411 |
]. |
|
412 |
]. |
|
413 |
^ true |
|
414 |
! |
|
415 |
||
416 |
doIndicatorClick:index |
|
417 |
"handle a click on the indicator |
|
418 |
" |
|
419 |
||
420 |
(self applicationList at:index) toggleExpand |
|
421 |
! |
|
422 |
||
423 |
doReload |
|
4574 | 424 |
|item| |
4378 | 425 |
|
426 |
item := self selectedItem value. |
|
4574 | 427 |
(item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ |
428 |
^ self |
|
429 |
]. |
|
430 |
item application readSettings |
|
4378 | 431 |
! |
432 |
||
433 |
doSave |
|
434 |
| item | |
|
435 |
||
436 |
item := self selectedItem value. |
|
437 |
(item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ self]. |
|
4388 | 438 |
self withWaitCursorDo:[ |
4574 | 439 |
item application saveSettingsIfUnsavedChangesArePresent. |
4388 | 440 |
]. |
4378 | 441 |
! |
442 |
||
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
443 |
expandItemForApplication:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
444 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
445 |
| item | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
446 |
item := self applicationList detect:[:item | item application = aApplication] ifNone:[nil]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
447 |
item notNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
448 |
item expand |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
449 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
450 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
451 |
|
4378 | 452 |
help |
453 |
||
454 |
| item | |
|
455 |
||
456 |
item := self selectedItem value. |
|
457 |
(item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ self]. |
|
458 |
item application help. |
|
459 |
! |
|
460 |
||
4740 | 461 |
reopenLauncher |
462 |
self requestor notNil ifTrue:[ |
|
463 |
self requestor reopenLauncher. |
|
464 |
] ifFalse:[ |
|
465 |
NewLauncher current reopenLauncher. |
|
466 |
]. |
|
467 |
! |
|
468 |
||
4378 | 469 |
sendLoadRequestToAll |
4574 | 470 |
self applicationList do:[:applItem | |
4378 | 471 |
(applItem isCategory not and:[applItem application notNil]) ifTrue:[ |
4574 | 472 |
^ applItem application readSettings |
473 |
] |
|
4378 | 474 |
]. |
475 |
^ true |
|
476 |
! |
|
477 |
||
478 |
sendSaveRequestToAll |
|
479 |
||
480 |
self applicationList do:[ : applItem | |
|
481 |
(applItem isCategory not and:[applItem application notNil]) ifTrue:[ |
|
482 |
applItem application saveRequest ifFalse:[ |
|
483 |
^ false |
|
484 |
]. |
|
485 |
]. |
|
486 |
]. |
|
487 |
^ true |
|
4659 | 488 |
! |
489 |
||
490 |
sendSaveRequestToCurrent |
|
491 |
||
492 |
| item | |
|
493 |
||
494 |
item := self selectedItem value. |
|
495 |
(item isNil or:[item isCategory or:[item application isNil]]) ifTrue:[ ^ true]. |
|
496 |
self withWaitCursorDo:[ |
|
497 |
^ item application saveRequest. |
|
498 |
]. |
|
499 |
^ true |
|
4378 | 500 |
! ! |
501 |
||
502 |
!SettingsDialog methodsFor:'application list access'! |
|
503 |
||
504 |
addApplClass:aClass withName:aName |
|
505 |
" add a application in the to the settingsTree, take the icon from the application class defaultIcon method" |
|
506 |
||
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
507 |
^ self addApplClass:aClass withName:aName icon:nil. |
4378 | 508 |
! |
509 |
||
510 |
addApplClass:aClass withName:aName icon:icon |
|
511 |
||
512 |
|applicationLabel locIcon locClass| |
|
513 |
||
514 |
(self applicationNames includes:aName) ifTrue:[ |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
515 |
^ self getItemForName:aName. |
4378 | 516 |
]. |
517 |
self addCategoriesFor:aName. |
|
518 |
locIcon := icon. |
|
519 |
locClass := Smalltalk classNamed:aClass. |
|
4469 | 520 |
locClass isNil ifTrue:[ |
521 |
('SettingsDialog [warning]:cant find ', aClass asString, ' for register') infoPrintCR. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
522 |
^ nil |
4469 | 523 |
]. |
524 |
locClass isLoaded not ifTrue:[ |
|
525 |
locClass autoload. |
|
526 |
]. |
|
4378 | 527 |
(locIcon isNil and:[locClass respondsTo:#defaultIcon]) ifTrue:[ locIcon := locClass defaultIcon]. |
528 |
applicationLabel := (aName asCollectionOfSubstringsSeparatedBy:$/) last. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
529 |
^ self createItemName:aName label:applicationLabel class:locClass icon:locIcon |
4378 | 530 |
! |
531 |
||
532 |
addIcon:aIcon forCategory:aCategoryName |
|
533 |
||
534 |
" add a new category Icon for a categorie " |
|
535 |
||
4401 | 536 |
|existingItem| |
537 |
||
538 |
self categoryIcons at:aCategoryName put:aIcon. |
|
539 |
existingItem := self getItemForName:aCategoryName. |
|
540 |
existingItem notNil ifTrue:[ |
|
541 |
existingItem icon:aIcon |
|
542 |
]. |
|
4378 | 543 |
! |
544 |
||
545 |
applicationNames |
|
546 |
||
547 |
^ self applicationList collect:[:item | item nameString]. |
|
548 |
! |
|
549 |
||
550 |
categoryIcons |
|
551 |
||
552 |
categoryIcons isNil ifTrue:[ |
|
553 |
categoryIcons := Dictionary new. |
|
554 |
]. |
|
555 |
^ categoryIcons |
|
556 |
! |
|
557 |
||
4716 | 558 |
getAllChildrenAppsForApplication:aApplication childrenClass:aClass |
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
559 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
560 |
| children | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
561 |
children := self getAllChildrenByApplication:aApplication. |
4716 | 562 |
aClass notNil ifTrue:[ |
563 |
children := children select:[:aChild | aChild application class == aClass] |
|
564 |
]. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
565 |
^ children collect:[:item | item application]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
566 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
567 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
568 |
getAllChildrenByApplication:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
569 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
570 |
| item | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
571 |
item := self getItemByApplication:aApplication. |
4716 | 572 |
item isNil ifTrue:[ ^ #()]. |
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
573 |
^ item children. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
574 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
575 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
576 |
getApplicationsByClass:aClass |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
577 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
578 |
| classEntries| |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
579 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
580 |
self applicationList isNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
581 |
self initialize. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
582 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
583 |
classEntries := self applicationList select:[:aEntry | aEntry application class == aClass]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
584 |
^ classEntries collect:[:aItem | aItem application]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
585 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
586 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
587 |
getItemByApplication:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
588 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
589 |
self applicationList isNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
590 |
self initialize. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
591 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
592 |
^ self applicationList detect:[:aEntry | aEntry application == aApplication] ifNone:[nil]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
593 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
594 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
595 |
getNameOfApplication:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
596 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
597 |
| item | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
598 |
item := self applicationList detect:[:item | item application = aApplication] ifNone:[nil]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
599 |
item notNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
600 |
^ item nameString |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
601 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
602 |
^ '' |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
603 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
604 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
605 |
remApplClassByName:aName |
4378 | 606 |
" remove a application from the settingsTree" |
607 |
||
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
608 |
|item| |
4378 | 609 |
|
610 |
item := self getItemForName:aName. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
611 |
self removeItem:item |
4378 | 612 |
! |
613 |
||
614 |
removeApplicationByClass:aClass |
|
615 |
||
616 |
| classEntries| |
|
617 |
||
618 |
self applicationList isNil ifTrue:[ |
|
619 |
self initialize. |
|
620 |
]. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
621 |
classEntries := self applicationList select:[:aEntry | aEntry application class == aClass]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
622 |
classEntries do:[:aItem | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
623 |
self removeItem:aItem. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
624 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
625 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
626 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
627 |
removeApplicationFromTree:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
628 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
629 |
| classEntries| |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
630 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
631 |
self applicationList isNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
632 |
self initialize. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
633 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
634 |
classEntries := self applicationList select:[:aEntry | aEntry application == aApplication]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
635 |
classEntries do:[:aItem | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
636 |
self removeItem:aItem. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
637 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
638 |
self applicationList removeAllFoundIn:classEntries. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
639 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
640 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
641 |
removeByApplication:aApplication |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
642 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
643 |
| item | |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
644 |
item := self getItemByApplication:aApplication. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
645 |
item notNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
646 |
self removeItem:item. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
647 |
] |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
648 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
649 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
650 |
|
4378 | 651 |
! ! |
652 |
||
653 |
!SettingsDialog methodsFor:'application list access -private'! |
|
654 |
||
655 |
addCategoriesFor:aName |
|
656 |
||
657 |
" create all the categories before application itself |
|
658 |
" |
|
659 |
||
660 |
(aName includes:$/) not ifTrue:[ ^ self]. |
|
661 |
self treeName:aName do:[:currentLabel :currentName| | length icon| |
|
662 |
currentLabel notEmpty ifTrue:[ |
|
663 |
icon := self categoryIcons at:currentName ifAbsent:[nil]. |
|
664 |
self createItemName:currentName label:currentLabel icon:icon. |
|
665 |
] |
|
666 |
] forgetLast:1. |
|
667 |
! |
|
668 |
||
669 |
createItemName:aNameString label:aLabel class:aClass icon:aIcon |
|
670 |
||
671 |
" create an application item in my application list |
|
672 |
" |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
673 |
| newItem parent locIcon item| |
4378 | 674 |
|
675 |
aNameString ~= aLabel ifTrue:[ |
|
676 |
parent := self getItemForName:(aNameString copyTo:(aNameString size - aLabel size - 1)). |
|
677 |
]. |
|
678 |
parent isNil ifTrue:[ |
|
679 |
parent := self applicationList root. |
|
680 |
]. |
|
681 |
parent children notNil ifTrue:[ |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
682 |
(item := parent children detect:[ :aItem | aItem label = aLabel] ifNone:[nil]) notNil ifTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
683 |
^ item. |
4378 | 684 |
] |
685 |
]. |
|
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
686 |
"/ self halt. |
4378 | 687 |
newItem := self class itemClass new. |
4740 | 688 |
"/ newItem label:(resources string:aLabel) "allBold". |
689 |
newItem label:aLabel "allBold". |
|
4378 | 690 |
newItem nameString:aNameString. |
691 |
newItem applicationClass:aClass. |
|
692 |
locIcon := aIcon. |
|
693 |
locIcon isNil ifTrue:[ locIcon := self class defaultSettingsAppIcon]. |
|
694 |
newItem icon:locIcon. |
|
4384 | 695 |
parent add:newItem. |
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
696 |
^ newItem |
4433 | 697 |
"/ self class expandParents ifTrue:[ |
698 |
"/ parent expand. |
|
699 |
"/ ] |
|
4378 | 700 |
! |
701 |
||
702 |
createItemName:aNameString label:aLabel icon:aIcon |
|
703 |
||
704 |
" create an application item in my application list |
|
705 |
" |
|
706 |
self createItemName:aNameString label:aLabel class:nil icon:aIcon |
|
707 |
! |
|
708 |
||
709 |
getItemForName:aName |
|
710 |
||
711 |
| searchItem| |
|
712 |
||
713 |
searchItem := self applicationList root. |
|
714 |
self treeName:aName do:[:currentLabel :currentName| |
|
715 |
searchItem children isNil ifTrue:[ ^ nil]. |
|
716 |
searchItem := searchItem children detect:[: item | item nameString = currentName] ifNone:[nil]. |
|
717 |
searchItem isNil ifTrue:[ ^ nil]. |
|
718 |
]. |
|
719 |
^ searchItem |
|
720 |
! |
|
721 |
||
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
722 |
removeItem:aItem |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
723 |
" remove a application from the settingsTree" |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
724 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
725 |
|parent remParent| |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
726 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
727 |
parent := aItem parent. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
728 |
parent isNil ifTrue:[" already removed " ^ self]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
729 |
parent remove:aItem. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
730 |
|
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
731 |
[parent isCategory and:[parent children isEmptyOrNil]] whileTrue:[ |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
732 |
remParent := parent. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
733 |
parent := remParent parent. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
734 |
parent remove:remParent. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
735 |
]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
736 |
self applicationList remove:aItem ifAbsent:[nil]. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
737 |
self selectedItem value:parent. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
738 |
! |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
739 |
|
4378 | 740 |
treeName:aName do:aBlock |
741 |
||
742 |
self treeName:aName do:aBlock forgetLast:0 |
|
743 |
! |
|
744 |
||
745 |
treeName:aName do:aBlock forgetLast:last |
|
746 |
||
747 |
| tree length| |
|
748 |
||
749 |
tree := aName asCollectionOfSubstringsSeparatedBy:$/. |
|
750 |
tree from:1 to:(tree size - last) keysAndValuesDo:[:idx :aCategory| | itemName | |
|
751 |
length := 0. |
|
752 |
tree from:1 to:idx keysAndValuesDo:[:idx2 : el | |
|
753 |
length := length + el size. |
|
754 |
idx2 > 1 ifTrue:[length := length + 1]. |
|
755 |
]. |
|
756 |
itemName := aName copyTo:length. |
|
757 |
aBlock value:aCategory value:itemName. |
|
758 |
]. |
|
759 |
! ! |
|
760 |
||
761 |
!SettingsDialog methodsFor:'aspects'! |
|
762 |
||
763 |
applicationList |
|
764 |
||
765 |
applicationList isNil ifTrue:[ |
|
766 |
applicationList := SettingsDialog::HierarchicalApplicationList new. |
|
767 |
]. |
|
768 |
^ applicationList. |
|
769 |
! |
|
770 |
||
771 |
enableHelp |
|
772 |
||
773 |
enableHelp isNil ifTrue:[ |
|
774 |
enableHelp := true asValue. |
|
775 |
]. |
|
776 |
^ enableHelp. |
|
777 |
! |
|
778 |
||
779 |
enableOK |
|
780 |
||
781 |
enableOK isNil ifTrue:[ |
|
782 |
enableOK := true asValue. |
|
783 |
]. |
|
784 |
^ enableOK. |
|
785 |
! |
|
786 |
||
787 |
enableReload |
|
788 |
||
789 |
enableReload isNil ifTrue:[ |
|
790 |
enableReload := true asValue. |
|
791 |
]. |
|
792 |
^ enableReload. |
|
793 |
! |
|
794 |
||
795 |
selectedItem |
|
796 |
||
797 |
selectedItem isNil ifTrue:[ |
|
798 |
selectedItem := ValueHolder new. |
|
799 |
selectedItem addDependent:self. |
|
800 |
]. |
|
801 |
^ selectedItem. |
|
802 |
! |
|
803 |
||
804 |
subCanvasApplicationHolder |
|
805 |
||
806 |
subCanvasApplicationHolder isNil ifTrue:[ |
|
807 |
subCanvasApplicationHolder := ValueHolder new. |
|
808 |
]. |
|
809 |
^ subCanvasApplicationHolder. |
|
810 |
! ! |
|
811 |
||
812 |
!SettingsDialog methodsFor:'change & update'! |
|
813 |
||
814 |
modifiedChanged |
|
815 |
||
816 |
|changedObject| |
|
817 |
||
818 |
changedObject := self subCanvasApplicationHolder value modifiedChannel. |
|
819 |
self enableOK value:(changedObject value). |
|
820 |
self enableReload value:(changedObject value). |
|
821 |
! |
|
822 |
||
823 |
selectionChanged |
|
824 |
||
4435 | 825 |
| item oldAppl noApp lbl window app| |
4378 | 826 |
|
4405 | 827 |
self selectedItem value == lastSelection ifTrue:[ ^ self]. |
4378 | 828 |
oldAppl := self subCanvasApplicationHolder value. |
829 |
oldAppl notNil ifTrue:[ |
|
4405 | 830 |
oldAppl saveRequest ifFalse:[ |
831 |
lastSelection notNil ifTrue:[ |
|
832 |
self |
|
833 |
enqueueMessage:#value |
|
834 |
for:[ |
|
835 |
self selectedItem value:lastSelection. |
|
836 |
] |
|
837 |
arguments:#(). |
|
838 |
]. |
|
839 |
^ self |
|
840 |
]. |
|
4378 | 841 |
oldAppl modifiedChannel removeDependent:self. |
842 |
]. |
|
4435 | 843 |
|
4378 | 844 |
item := self selectedItem value. |
4405 | 845 |
lastSelection := item. |
4378 | 846 |
item isNil ifTrue:[ noApp := true] ifFalse:[noApp := item isCategory]. |
847 |
self enableOK value:(noApp not). |
|
848 |
self enableReload value:(noApp not). |
|
849 |
self enableHelp value:(noApp not). |
|
4435 | 850 |
window := self window. |
851 |
window notNil ifTrue:[ |
|
852 |
lbl := 'Settings Dialog'. |
|
853 |
item notNil ifTrue:[ |
|
854 |
lbl := lbl , ' [', item label , ']'. |
|
855 |
]. |
|
856 |
window label:lbl. |
|
4406 | 857 |
]. |
4378 | 858 |
noApp ifTrue:[ |
859 |
self subCanvasApplicationHolder value:nil. |
|
860 |
^ self |
|
861 |
]. |
|
4435 | 862 |
(app := item application) isNil ifTrue:[ |
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
863 |
item application:(app := item applicationClass basicNew). |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
864 |
app basicInitialize. |
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
865 |
app requestor:self. |
4378 | 866 |
]. |
4703
deb516ae2481
a lot of changes - server is running but there is something left to do
penk
parents:
4659
diff
changeset
|
867 |
app initialize. |
4435 | 868 |
app modifiedChannel addDependent:self. |
869 |
self subCanvasApplicationHolder value:app. |
|
4378 | 870 |
self modifiedChanged. |
871 |
! |
|
872 |
||
873 |
update:something with:aParameter from:changedObject |
|
874 |
"Invoked when an object that I depend upon sends a change notification." |
|
875 |
||
876 |
"stub code automatically generated - please change as required" |
|
877 |
||
878 |
changedObject == self selectedItem ifTrue:[ |
|
4405 | 879 |
super update:something with:aParameter from:changedObject. |
4378 | 880 |
self selectionChanged. |
4405 | 881 |
^ self. |
4378 | 882 |
]. |
4405 | 883 |
self subCanvasApplicationHolder value notNil ifTrue:[ |
884 |
changedObject == self subCanvasApplicationHolder value modifiedChannel ifTrue:[ |
|
885 |
self modifiedChanged. |
|
886 |
]. |
|
4378 | 887 |
]. |
888 |
super update:something with:aParameter from:changedObject |
|
889 |
! ! |
|
890 |
||
891 |
!SettingsDialog methodsFor:'initialization & release'! |
|
892 |
||
893 |
closeRequest |
|
894 |
"This is a hook method generated by the Browser. |
|
895 |
It will be invoked when your app/dialog-window is about to be |
|
896 |
closed (this method has a chance to suppress the close). |
|
897 |
See also #closeDownViews, which is invoked when the close is really done." |
|
898 |
||
4400 | 899 |
| req | |
4659 | 900 |
(self sendSaveRequestToCurrent == false) ifTrue:[^ self]. |
4378 | 901 |
self destroyAll. |
4400 | 902 |
|
903 |
req := self requestor. |
|
904 |
req notNil ifTrue:[ |
|
905 |
req settingsClosed. |
|
906 |
]. |
|
4378 | 907 |
^ super closeRequest |
908 |
! |
|
909 |
||
910 |
initialize |
|
911 |
||
912 |
|rootItem| |
|
913 |
||
914 |
resources := AbstractLauncherApplication resources. |
|
915 |
rootItem := self class itemClass new. |
|
4740 | 916 |
rootItem label:(resources string:'Settings') "allBold". |
4378 | 917 |
rootItem nameString:'Settings'. |
918 |
rootItem icon:self class settingsIcon. |
|
919 |
self applicationList root:rootItem. |
|
920 |
self applicationList showRoot:true. |
|
921 |
self selectedItem value:rootItem. |
|
922 |
super initialize. |
|
923 |
! |
|
924 |
||
925 |
postBuildSubCanvas:aWidget |
|
926 |
||
927 |
aWidget keepClientView:true. |
|
928 |
! |
|
929 |
||
930 |
postOpenWith:aBuilder |
|
931 |
||
932 |
self applicationList root expand. |
|
933 |
super postOpenWith:aBuilder. |
|
934 |
! ! |
|
935 |
||
936 |
!SettingsDialog methodsFor:'menu actions'! |
|
937 |
||
4574 | 938 |
loadSettingsFromFile |
4378 | 939 |
|
940 |
"restore settings from a settings-file." |
|
941 |
||
942 |
"a temporary kludge - we need a central systemSettings object for this, |
|
943 |
which can be saved/restored with a single store/read." |
|
944 |
||
945 |
|fileName| |
|
946 |
||
947 |
fileName := Dialog |
|
4740 | 948 |
requestFileName:(resources string:'Load Settings from File') |
4378 | 949 |
default:'settings.stx' |
950 |
ok:(resources string:'Load') |
|
951 |
abort:(resources string:'Cancel') |
|
952 |
pattern:'*.stx' |
|
953 |
fromDirectory:nil. |
|
954 |
||
955 |
(fileName size == 0) ifTrue:[ |
|
956 |
"/ canceled |
|
957 |
^ self |
|
958 |
]. |
|
959 |
||
960 |
self withWaitCursorDo:[ |
|
961 |
Smalltalk fileIn:fileName. |
|
962 |
Transcript current topView model reOpen. |
|
963 |
self sendLoadRequestToAll. |
|
964 |
]. |
|
965 |
! |
|
966 |
||
4574 | 967 |
saveSettingsIntoFile |
4552
a8df4916183a
saveSettings moved to UserPreferences
Claus Gittinger <cg@exept.de>
parents:
4548
diff
changeset
|
968 |
SettingsDialog saveSettingsIntoFile. |
4378 | 969 |
! ! |
970 |
||
971 |
!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'accessing'! |
|
972 |
||
973 |
application |
|
974 |
"return the value of the instance variable 'application' (automatically generated)" |
|
975 |
||
976 |
^ application |
|
977 |
! |
|
978 |
||
979 |
application:something |
|
980 |
"set the value of the instance variable 'application' (automatically generated)" |
|
981 |
||
982 |
application := something. |
|
983 |
! |
|
984 |
||
985 |
applicationClass |
|
986 |
"return the value of the instance variable 'applicationClass' (automatically generated)" |
|
987 |
||
988 |
^ applicationClass |
|
989 |
! |
|
990 |
||
991 |
applicationClass:something |
|
992 |
"set the value of the instance variable 'applicationClass' (automatically generated)" |
|
993 |
||
994 |
applicationClass := something. |
|
995 |
! |
|
996 |
||
997 |
icon |
|
998 |
"return the value of the instance variable 'icon' (automatically generated)" |
|
999 |
||
1000 |
^ icon |
|
1001 |
! |
|
1002 |
||
1003 |
icon:something |
|
1004 |
"set the value of the instance variable 'icon' (automatically generated)" |
|
1005 |
||
1006 |
icon := something. |
|
1007 |
! |
|
1008 |
||
1009 |
label |
|
1010 |
"return the value of the instance variable 'label' (automatically generated)" |
|
1011 |
||
1012 |
^ label |
|
1013 |
! |
|
1014 |
||
1015 |
label:something |
|
1016 |
"set the value of the instance variable 'label' (automatically generated)" |
|
1017 |
||
1018 |
label := something. |
|
1019 |
! |
|
1020 |
||
1021 |
nameString |
|
1022 |
"return the value of the instance variable 'nameString' (automatically generated)" |
|
1023 |
||
1024 |
^ nameString |
|
1025 |
! |
|
1026 |
||
1027 |
nameString:something |
|
1028 |
"set the value of the instance variable 'nameString' (automatically generated)" |
|
1029 |
||
1030 |
nameString := something. |
|
1031 |
! ! |
|
1032 |
||
4405 | 1033 |
!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'printing & storing'! |
1034 |
||
1035 |
displayString |
|
1036 |
||
1037 |
^ super printString, ' [', (label isText ifTrue:[label string] ifFalse:[label]) ,']' |
|
1038 |
! |
|
1039 |
||
1040 |
printString |
|
1041 |
||
1042 |
^ super printString, ' [', (label isText ifTrue:[label string] ifFalse:[label]) ,']' |
|
1043 |
! ! |
|
1044 |
||
4378 | 1045 |
!SettingsDialog::HierarchicalApplicationList::ApplicationItem methodsFor:'queries'! |
1046 |
||
1047 |
isCategory |
|
1048 |
||
1049 |
^ self applicationClass isNil |
|
1050 |
! ! |
|
1051 |
||
1052 |
!SettingsDialog class methodsFor:'documentation'! |
|
1053 |
||
1054 |
version |
|
4740 | 1055 |
^ '$Header: /cvs/stx/stx/libtool/SettingsDialog.st,v 1.21 2003-03-28 19:05:37 cg Exp $' |
4378 | 1056 |
! ! |
4469 | 1057 |
|
1058 |
SettingsDialog initialize! |