author | Claus Gittinger <cg@exept.de> |
Thu, 22 Oct 2009 19:38:57 +0200 | |
changeset 3811 | ebc2b9a0f94e |
parent 3810 | 0df3ba9c453a |
child 3812 | f65a55aadf08 |
permissions | -rw-r--r-- |
3796 | 1 |
"{ Package: 'stx:libwidg2' }" |
2 |
||
3 |
ApplicationModel subclass:#AssistantApplication |
|
4 |
instanceVariableNames:'currentPageSpecHolder backButtonEnabled forwardButtonEnabled |
|
5 |
backButtonVisible forwardButtonVisible finishButtonVisible |
|
3805 | 6 |
finishButtonEnabled currentPageInfoHTMLHolder |
3796 | 7 |
currentPageIndexHolder backButtonLabelHolder |
3811 | 8 |
nextButtonLabelHolder pageLabelsInList pageInfoHolder' |
3796 | 9 |
classVariableNames:'' |
10 |
poolDictionaries:'' |
|
11 |
category:'Views-DialogBoxes' |
|
12 |
! |
|
13 |
||
14 |
!AssistantApplication class methodsFor:'documentation'! |
|
15 |
||
16 |
documentation |
|
17 |
" |
|
18 |
an easy to use framework for assistant-dialog applications. |
|
3807 | 19 |
These are multipage applications, in which the user is able to navigate |
20 |
along achain of pages as specified in the AssistantSpec |
|
21 |
||
22 |
see stx:doc/coding:DemoAssistant for a demo example. |
|
23 |
see ProjectBuilderAssistantApplication for a concrete example. |
|
3796 | 24 |
" |
25 |
! ! |
|
26 |
||
3809 | 27 |
!AssistantApplication class methodsFor:'help'! |
28 |
||
29 |
flyByHelpSpec |
|
30 |
<resource: #help> |
|
31 |
||
32 |
^ super flyByHelpSpec addPairsFrom:#( |
|
33 |
||
34 |
#backButton |
|
35 |
'Navigate to the previous page %(previousPageInfo)' |
|
36 |
||
37 |
#nextButton |
|
38 |
'Navigate to the next page %(nextPageInfo)' |
|
39 |
||
40 |
) |
|
41 |
! ! |
|
42 |
||
3805 | 43 |
!AssistantApplication class methodsFor:'image specs'! |
44 |
||
45 |
bulletIcon |
|
46 |
"This resource specification was automatically generated |
|
47 |
by the ImageEditor of ST/X." |
|
48 |
||
49 |
"Do not manually edit this!! If it is corrupted, |
|
50 |
the ImageEditor may not be able to read the specification." |
|
51 |
||
52 |
" |
|
53 |
self bulletIcon inspect |
|
54 |
ImageEditor openOnClass:self andSelector:#bulletIcon |
|
55 |
Icon flushCachedIcons |
|
56 |
" |
|
57 |
||
58 |
<resource: #image> |
|
59 |
||
60 |
^Icon |
|
61 |
constantNamed:'AssistantApplication class bulletIcon' |
|
62 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@% @@BPA @@P@D@@ @@ @D@@D@A@@A@@ @@ @A@@P@@$@X@@@% @@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@<@O<@?0G? _>A?8G? O<@?0@<@@@@@@@@@b') ; yourself); yourself] |
|
63 |
! |
|
64 |
||
65 |
leftArrowIcon |
|
66 |
"This resource specification was automatically generated |
|
67 |
by the ImageEditor of ST/X." |
|
68 |
||
69 |
"Do not manually edit this!! If it is corrupted, |
|
70 |
the ImageEditor may not be able to read the specification." |
|
71 |
||
72 |
" |
|
73 |
self leftArrowIcon inspect |
|
74 |
ImageEditor openOnClass:self andSelector:#leftArrowIcon |
|
75 |
Icon flushCachedIcons |
|
76 |
" |
|
77 |
||
78 |
<resource: #image> |
|
79 |
||
80 |
^Icon |
|
81 |
constantNamed:'AssistantApplication class leftArrowIcon' |
|
82 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@D@@@@G@@@@G??<@A???@@G@@@@@P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@A@@L@A0@O@A?>O?9??''?>O?8_? <@A0@C@@D@@@@b') ; yourself); yourself] |
|
83 |
! |
|
84 |
||
85 |
rightArrowIcon |
|
86 |
"This resource specification was automatically generated |
|
87 |
by the ImageEditor of ST/X." |
|
88 |
||
89 |
"Do not manually edit this!! If it is corrupted, |
|
90 |
the ImageEditor may not be able to read the specification." |
|
91 |
||
92 |
" |
|
93 |
self rightArrowIcon inspect |
|
94 |
ImageEditor openOnClass:self andSelector:#rightArrowIcon |
|
95 |
Icon flushCachedIcons |
|
96 |
" |
|
97 |
||
98 |
<resource: #image> |
|
99 |
||
100 |
^Icon |
|
101 |
constantNamed:'AssistantApplication class rightArrowIcon' |
|
102 |
ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@P@@@@M@@O??4@C??=@@@@M@@@@A@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@ @C@@N@@<G?8_?1??''?>_?1?>@C0@N@@0@B@@@@b') ; yourself); yourself] |
|
103 |
! ! |
|
104 |
||
3796 | 105 |
!AssistantApplication class methodsFor:'interface specs'! |
106 |
||
107 |
windowSpec |
|
108 |
"This resource specification was automatically generated |
|
109 |
by the UIPainter of ST/X." |
|
110 |
||
111 |
"Do not manually edit this!! If it is corrupted, |
|
112 |
the UIPainter may not be able to read the specification." |
|
113 |
||
114 |
" |
|
115 |
UIPainter new openOnClass:AssistantApplication andSelector:#windowSpec |
|
116 |
AssistantApplication new openInterface:#windowSpec |
|
117 |
AssistantApplication open |
|
118 |
" |
|
119 |
||
120 |
<resource: #canvas> |
|
121 |
||
122 |
^ |
|
123 |
#(FullSpec |
|
124 |
name: windowSpec |
|
125 |
window: |
|
126 |
(WindowSpec |
|
127 |
label: 'NewApplication' |
|
128 |
name: 'NewApplication' |
|
129 |
bounds: (Rectangle 0 0 534 440) |
|
3808 | 130 |
menu: mainMenu |
3796 | 131 |
) |
132 |
component: |
|
133 |
(SpecCollection |
|
134 |
collection: ( |
|
3808 | 135 |
(MenuPanelSpec |
136 |
name: 'ToolBar1' |
|
137 |
layout: (LayoutFrame 0 0 0 0 0 1 40 0) |
|
138 |
menu: toolbarMenu |
|
139 |
textDefault: true |
|
140 |
) |
|
3809 | 141 |
(ViewSpec |
142 |
name: 'Box1' |
|
143 |
layout: (LayoutFrame 0 0 40 0 0 1 -25 1) |
|
3796 | 144 |
component: |
145 |
(SpecCollection |
|
146 |
collection: ( |
|
3809 | 147 |
(VariableHorizontalPanelSpec |
148 |
name: 'VariableHorizontalPanel1' |
|
149 |
layout: (LayoutFrame 0 0 0 0 0 1 -40 1) |
|
150 |
component: |
|
151 |
(SpecCollection |
|
152 |
collection: ( |
|
3811 | 153 |
(ViewSpec |
154 |
name: 'Box2' |
|
155 |
component: |
|
156 |
(SpecCollection |
|
157 |
collection: ( |
|
158 |
(SequenceViewSpec |
|
159 |
name: 'PagesLabelList' |
|
160 |
layout: (LayoutFrame 0 0 0 0 0 1 0 0.7) |
|
161 |
level: 0 |
|
162 |
enableChannel: false |
|
163 |
hasHorizontalScrollBar: true |
|
164 |
hasVerticalScrollBar: true |
|
165 |
useIndex: true |
|
166 |
sequenceList: pageLabelsInList |
|
167 |
) |
|
168 |
(HTMLViewSpec |
|
169 |
name: 'HTMLBrowser1' |
|
170 |
layout: (LayoutFrame 0 0 0 0.7 0 1 0 1) |
|
171 |
level: 0 |
|
172 |
hasHorizontalScrollBar: true |
|
173 |
hasVerticalScrollBar: true |
|
174 |
miniScrollerHorizontal: true |
|
175 |
miniScrollerVertical: true |
|
176 |
htmlText: pageInfoHolder |
|
177 |
) |
|
178 |
) |
|
179 |
||
180 |
) |
|
3809 | 181 |
) |
182 |
(SubCanvasSpec |
|
183 |
name: 'SubCanvas1' |
|
184 |
hasHorizontalScrollBar: false |
|
185 |
hasVerticalScrollBar: false |
|
186 |
miniScrollerHorizontal: false |
|
187 |
miniScrollerVertical: false |
|
188 |
specHolder: currentPageSpecHolder |
|
189 |
createNewBuilder: false |
|
190 |
) |
|
191 |
) |
|
192 |
||
193 |
) |
|
194 |
handles: (Any 0.5 1.0) |
|
3796 | 195 |
) |
3809 | 196 |
(HorizontalPanelViewSpec |
197 |
name: 'ButtonPanel1' |
|
198 |
layout: (LayoutFrame 0 0 -40 1 0 0.5 0 1) |
|
199 |
horizontalLayout: centerMax |
|
200 |
verticalLayout: center |
|
201 |
horizontalSpace: 3 |
|
202 |
verticalSpace: 3 |
|
203 |
component: |
|
204 |
(SpecCollection |
|
205 |
collection: ( |
|
206 |
(ActionButtonSpec |
|
207 |
label: 'Back' |
|
208 |
name: 'Button1' |
|
209 |
activeHelpKey: backButton |
|
210 |
visibilityChannel: backButtonVisible |
|
211 |
translateLabel: true |
|
212 |
labelChannel: backButtonLabelHolder |
|
213 |
model: goBackward |
|
214 |
enableChannel: backButtonEnabled |
|
3811 | 215 |
useDefaultExtent: true |
3809 | 216 |
) |
217 |
(ActionButtonSpec |
|
218 |
label: 'Next' |
|
219 |
name: 'Button2' |
|
220 |
activeHelpKey: nextButton |
|
221 |
visibilityChannel: forwardButtonVisible |
|
222 |
translateLabel: true |
|
223 |
labelChannel: nextButtonLabelHolder |
|
224 |
model: goForward |
|
225 |
enableChannel: forwardButtonEnabled |
|
3811 | 226 |
useDefaultExtent: true |
3809 | 227 |
) |
228 |
) |
|
229 |
||
230 |
) |
|
3796 | 231 |
) |
3809 | 232 |
(HorizontalPanelViewSpec |
233 |
name: 'ButtonPanel2' |
|
234 |
layout: (LayoutFrame 0 0.5 -40 1 0 1 0 1) |
|
235 |
horizontalLayout: centerMax |
|
236 |
verticalLayout: center |
|
237 |
horizontalSpace: 3 |
|
238 |
verticalSpace: 3 |
|
239 |
ignoreInvisibleComponents: false |
|
240 |
component: |
|
241 |
(SpecCollection |
|
242 |
collection: ( |
|
243 |
(ActionButtonSpec |
|
244 |
label: 'Finish' |
|
245 |
name: 'Button7' |
|
246 |
visibilityChannel: finishButtonVisible |
|
247 |
translateLabel: true |
|
248 |
resizeForLabel: true |
|
249 |
model: doFinish |
|
250 |
enableChannel: finishButtonEnabled |
|
251 |
extent: (Point 65 22) |
|
252 |
) |
|
253 |
(ActionButtonSpec |
|
254 |
label: 'Cancel' |
|
255 |
name: 'Button8' |
|
256 |
translateLabel: true |
|
257 |
resizeForLabel: true |
|
258 |
model: doCancel |
|
259 |
extent: (Point 65 22) |
|
260 |
) |
|
261 |
) |
|
262 |
||
263 |
) |
|
3796 | 264 |
) |
265 |
) |
|
266 |
||
267 |
) |
|
268 |
) |
|
3809 | 269 |
(LabelSpec |
270 |
label: 'Label' |
|
271 |
name: 'Label1' |
|
272 |
layout: (LayoutFrame 1 0 -25 1 -1 1 -1 1) |
|
273 |
level: -1 |
|
274 |
translateLabel: true |
|
275 |
labelChannel: infoHolder |
|
276 |
adjust: left |
|
3796 | 277 |
) |
278 |
) |
|
279 |
||
280 |
) |
|
281 |
) |
|
282 |
! ! |
|
283 |
||
284 |
!AssistantApplication class methodsFor:'menu specs'! |
|
285 |
||
286 |
mainMenu |
|
3808 | 287 |
"This resource specification was automatically generated |
288 |
by the MenuEditor of ST/X." |
|
3796 | 289 |
|
290 |
"Do not manually edit this!! If it is corrupted, |
|
291 |
the MenuEditor may not be able to read the specification." |
|
292 |
||
293 |
" |
|
294 |
MenuEditor new openOnClass:AssistantApplication andSelector:#mainMenu |
|
3808 | 295 |
(Menu new fromLiteralArrayEncoding:(AssistantApplication mainMenu)) startUp |
3796 | 296 |
" |
297 |
||
298 |
<resource: #menu> |
|
299 |
||
3808 | 300 |
^ |
301 |
#(Menu |
|
302 |
( |
|
303 |
(MenuItem |
|
304 |
label: 'File' |
|
305 |
translateLabel: true |
|
306 |
submenu: |
|
307 |
(Menu |
|
308 |
( |
|
309 |
(MenuItem |
|
310 |
label: 'Exit' |
|
311 |
itemValue: closeRequest |
|
312 |
translateLabel: true |
|
3796 | 313 |
) |
3808 | 314 |
) |
315 |
nil |
|
316 |
nil |
|
3796 | 317 |
) |
3808 | 318 |
) |
319 |
(MenuItem |
|
320 |
label: 'Help' |
|
321 |
translateLabel: true |
|
322 |
startGroup: right |
|
323 |
submenu: |
|
324 |
(Menu |
|
325 |
( |
|
326 |
(MenuItem |
|
327 |
label: 'Documentation' |
|
328 |
itemValue: openDocumentation |
|
329 |
translateLabel: true |
|
3796 | 330 |
) |
3808 | 331 |
(MenuItem |
332 |
label: '-' |
|
333 |
) |
|
334 |
(MenuItem |
|
335 |
label: 'About this Application...' |
|
336 |
itemValue: openAboutThisApplication |
|
337 |
translateLabel: true |
|
338 |
) |
|
339 |
) |
|
340 |
nil |
|
341 |
nil |
|
3796 | 342 |
) |
3808 | 343 |
) |
344 |
) |
|
345 |
nil |
|
346 |
nil |
|
3796 | 347 |
) |
348 |
! ! |
|
349 |
||
3805 | 350 |
!AssistantApplication class methodsFor:'required protocol'! |
351 |
||
352 |
assistantSpec |
|
353 |
"must return a sequenceable collection of assistantPageSpecs - one for each page" |
|
354 |
||
355 |
self subclassResponsibility |
|
356 |
! ! |
|
357 |
||
3796 | 358 |
!AssistantApplication methodsFor:'actions'! |
359 |
||
3806 | 360 |
canGoBackward |
361 |
|currentPageSpec previousPageSpec| |
|
362 |
||
363 |
"/ see if we are allowed to leave... |
|
364 |
currentPageSpec := self currentPageSpec. |
|
365 |
currentPageSpec canLeaveQuerySelector notNil ifTrue:[ |
|
366 |
(self perform:currentPageSpec canLeaveQuerySelector) ifFalse:[^ false]. |
|
367 |
]. |
|
368 |
||
369 |
"/ see if we are allowed to enter the next... |
|
370 |
previousPageSpec := self previousEnabledPageSpec. |
|
371 |
previousPageSpec isNil ifTrue:[^ false]. |
|
372 |
||
373 |
previousPageSpec canEnterQuerySelector notNil ifTrue:[ |
|
374 |
(self perform:previousPageSpec canEnterQuerySelector) ifFalse:[^ false]. |
|
375 |
]. |
|
376 |
^ true |
|
377 |
! |
|
378 |
||
379 |
canGoForward |
|
380 |
|currentPageSpec nextPageSpec| |
|
381 |
||
382 |
self currentPageIndex == self numberOfPages ifTrue:[^ false]. |
|
383 |
||
384 |
"/ see if we are allowed to leave... |
|
385 |
currentPageSpec := self currentPageSpec. |
|
386 |
currentPageSpec canLeaveQuerySelector notNil ifTrue:[ |
|
387 |
(self perform:currentPageSpec canLeaveQuerySelector) ifFalse:[^ false]. |
|
388 |
]. |
|
389 |
||
390 |
"/ see if we are allowed to enter the next... |
|
391 |
nextPageSpec := self nextEnabledPageSpec. |
|
392 |
nextPageSpec isNil ifTrue:[^ false]. |
|
393 |
||
394 |
nextPageSpec canEnterQuerySelector notNil ifTrue:[ |
|
395 |
(self perform:nextPageSpec canEnterQuerySelector) ifFalse:[^ false]. |
|
396 |
]. |
|
397 |
^ true |
|
398 |
! |
|
399 |
||
3796 | 400 |
doCancel |
401 |
self closeRequest |
|
402 |
! |
|
403 |
||
404 |
doFinish |
|
405 |
self closeRequest |
|
406 |
! |
|
407 |
||
408 |
goBackward |
|
3806 | 409 |
|currentPageSpec| |
3796 | 410 |
|
3806 | 411 |
(self canGoBackward) ifFalse:[^ self]. |
412 |
||
3796 | 413 |
currentPageSpec := self currentPageSpec. |
414 |
currentPageSpec leaveCallbackSelector notNil ifTrue:[ |
|
415 |
self perform:currentPageSpec leaveCallbackSelector |
|
416 |
]. |
|
417 |
||
3805 | 418 |
self currentPageIndexHolder value:((self indexOfPreviousEnabledPageSpec) max:1). |
3796 | 419 |
|
420 |
currentPageSpec := self currentPageSpec. |
|
421 |
currentPageSpec enterCallbackSelector notNil ifTrue:[ |
|
422 |
self perform:currentPageSpec enterCallbackSelector |
|
423 |
]. |
|
3806 | 424 |
|
425 |
self updateButtonEnableState. |
|
3796 | 426 |
! |
427 |
||
428 |
goForward |
|
3806 | 429 |
|currentPageSpec| |
3796 | 430 |
|
3806 | 431 |
(self canGoForward) ifFalse:[^ self]. |
432 |
||
3796 | 433 |
currentPageSpec := self currentPageSpec. |
434 |
currentPageSpec leaveCallbackSelector notNil ifTrue:[ |
|
435 |
self perform:currentPageSpec leaveCallbackSelector |
|
436 |
]. |
|
437 |
||
3805 | 438 |
self currentPageIndexHolder value:(self indexOfNextEnabledPageSpec). |
3796 | 439 |
|
440 |
currentPageSpec := self currentPageSpec. |
|
441 |
currentPageSpec enterCallbackSelector notNil ifTrue:[ |
|
442 |
self perform:currentPageSpec enterCallbackSelector |
|
443 |
]. |
|
3806 | 444 |
|
445 |
self updateButtonEnableState. |
|
3796 | 446 |
! ! |
447 |
||
448 |
!AssistantApplication methodsFor:'aspects'! |
|
449 |
||
3805 | 450 |
assistantSpec |
451 |
^ self class assistantSpec |
|
452 |
! |
|
453 |
||
3796 | 454 |
backButtonEnabled |
455 |
<resource: #uiAspect> |
|
456 |
||
457 |
backButtonEnabled isNil ifTrue:[ |
|
458 |
backButtonEnabled := false asValue. |
|
459 |
]. |
|
460 |
^ backButtonEnabled. |
|
461 |
! |
|
462 |
||
463 |
backButtonLabelHolder |
|
464 |
<resource: #uiAspect> |
|
465 |
||
466 |
backButtonLabelHolder isNil ifTrue:[ |
|
467 |
backButtonLabelHolder := self backButtonLabel asValue. |
|
468 |
]. |
|
469 |
^ backButtonLabelHolder. |
|
470 |
! |
|
471 |
||
472 |
backButtonVisible |
|
473 |
<resource: #uiAspect> |
|
474 |
||
475 |
backButtonVisible isNil ifTrue:[ |
|
476 |
backButtonVisible := true asValue. |
|
477 |
]. |
|
478 |
^ backButtonVisible. |
|
479 |
! |
|
480 |
||
481 |
currentPageIndexHolder |
|
482 |
<resource: #uiAspect> |
|
483 |
||
484 |
currentPageIndexHolder isNil ifTrue:[ |
|
485 |
currentPageIndexHolder := 1 asValue. |
|
486 |
currentPageIndexHolder onChangeSend:#updateCanvas to:self |
|
487 |
]. |
|
488 |
^ currentPageIndexHolder. |
|
489 |
! |
|
490 |
||
491 |
currentPageInfoHTMLHolder |
|
492 |
<resource: #uiAspect> |
|
493 |
||
494 |
currentPageInfoHTMLHolder isNil ifTrue:[ |
|
495 |
currentPageInfoHTMLHolder := ValueHolder new. |
|
496 |
]. |
|
497 |
^ currentPageInfoHTMLHolder. |
|
498 |
! |
|
499 |
||
500 |
currentPageSpecHolder |
|
501 |
<resource: #uiAspect> |
|
502 |
||
503 |
currentPageSpecHolder isNil ifTrue:[ |
|
504 |
currentPageSpecHolder := nil asValue. |
|
505 |
]. |
|
506 |
^ currentPageSpecHolder. |
|
507 |
! |
|
508 |
||
509 |
finishButtonEnabled |
|
510 |
<resource: #uiAspect> |
|
511 |
||
512 |
finishButtonEnabled isNil ifTrue:[ |
|
513 |
finishButtonEnabled := false asValue. |
|
514 |
]. |
|
515 |
^ finishButtonEnabled. |
|
516 |
! |
|
517 |
||
518 |
finishButtonVisible |
|
519 |
<resource: #uiAspect> |
|
520 |
||
521 |
finishButtonVisible isNil ifTrue:[ |
|
522 |
finishButtonVisible := false asValue. |
|
523 |
]. |
|
524 |
^ finishButtonVisible. |
|
525 |
! |
|
526 |
||
527 |
forwardButtonEnabled |
|
528 |
<resource: #uiAspect> |
|
529 |
||
530 |
forwardButtonEnabled isNil ifTrue:[ |
|
531 |
forwardButtonEnabled := false asValue. |
|
532 |
]. |
|
533 |
^ forwardButtonEnabled. |
|
534 |
! |
|
535 |
||
536 |
forwardButtonVisible |
|
537 |
<resource: #uiAspect> |
|
538 |
||
539 |
forwardButtonVisible isNil ifTrue:[ |
|
540 |
forwardButtonVisible := true asValue. |
|
541 |
]. |
|
542 |
^ forwardButtonVisible. |
|
543 |
! |
|
544 |
||
545 |
nextButtonLabelHolder |
|
546 |
<resource: #uiAspect> |
|
547 |
||
548 |
nextButtonLabelHolder isNil ifTrue:[ |
|
549 |
nextButtonLabelHolder := self nextButtonLabel asValue. |
|
550 |
]. |
|
551 |
^ nextButtonLabelHolder. |
|
3805 | 552 |
! |
553 |
||
3811 | 554 |
pageInfoHolder |
555 |
<resource: #uiAspect> |
|
556 |
||
557 |
pageInfoHolder isNil ifTrue:[ |
|
558 |
pageInfoHolder := nil asValue. |
|
559 |
]. |
|
560 |
^ pageInfoHolder. |
|
561 |
! |
|
562 |
||
3805 | 563 |
pageLabelsInList |
564 |
pageLabelsInList isNil ifTrue:[ |
|
565 |
pageLabelsInList := List new. |
|
566 |
pageLabelsInList contents:(self pageLabelsInListWithBullet). |
|
567 |
]. |
|
568 |
^ pageLabelsInList |
|
569 |
! |
|
570 |
||
571 |
pageLabelsInListWithBullet |
|
572 |
|newList| |
|
573 |
||
574 |
newList := self pageLabels. |
|
575 |
newList := newList with:(1 to:newList size) |
|
576 |
collect:[:entry :index | |
|
577 |
index == self currentPageIndex ifTrue:[ |
|
578 |
LabelAndTwoIcons new |
|
3811 | 579 |
string:(entry allBold colorizeAllWith:(TextView defaultSelectionForegroundColor) on:(TextView defaultSelectionBackgroundColor) ); |
3805 | 580 |
icon:(self class rightArrowIcon); |
581 |
image2:(self class leftArrowIcon) |
|
582 |
] ifFalse:[ |
|
583 |
(self isPageEnabledAtIndex:index) ifFalse:[ |
|
3810
0df3ba9c453a
no need for #asText to emphasize a string
Claus Gittinger <cg@exept.de>
parents:
3809
diff
changeset
|
584 |
entry colorizeAllWith:(Button defaultDisabledForegroundColor) "Color grey". |
3805 | 585 |
] ifTrue:[ |
586 |
entry |
|
587 |
]. |
|
588 |
]. |
|
589 |
]. |
|
590 |
^ newList |
|
3796 | 591 |
! ! |
592 |
||
3809 | 593 |
!AssistantApplication methodsFor:'help'! |
594 |
||
595 |
flyByHelpTextForKey:aKey |
|
596 |
<resource: #help> |
|
597 |
||
598 |
|text bindings nextSpec prevSpec| |
|
599 |
||
600 |
text := super flyByHelpTextForKey:aKey. |
|
601 |
||
602 |
nextSpec := self nextEnabledPageSpec. |
|
603 |
prevSpec := self previousEnabledPageSpec. |
|
604 |
||
605 |
bindings := Dictionary new. |
|
606 |
bindings |
|
607 |
at:#'previousPageInfo' |
|
608 |
put:(prevSpec notNil ifTrue:[ '"',prevSpec pageTitle,'"' ] ifFalse:['']). |
|
609 |
bindings |
|
610 |
at:#'nextPageInfo' |
|
611 |
put:(nextSpec notNil ifTrue:[ '"',nextSpec pageTitle,'"' ] ifFalse:['']). |
|
612 |
||
613 |
^ self resources string:text withArgs:bindings. |
|
614 |
! ! |
|
615 |
||
3796 | 616 |
!AssistantApplication methodsFor:'initialization & release'! |
617 |
||
618 |
postBuildWith:aBuilder |
|
3805 | 619 |
|maxCanvasExtent| |
620 |
||
3796 | 621 |
super postBuildWith:aBuilder. |
622 |
self updateCanvas. |
|
3805 | 623 |
|
624 |
maxCanvasExtent := (self assistantSpec |
|
625 |
collect:[:eachPageSpec | |
|
626 |
|windowSpecSelector specArray windowSpec| |
|
627 |
||
628 |
windowSpecSelector := eachPageSpec windowSpecSelector. |
|
629 |
specArray := self perform:windowSpecSelector ifNotUnderstood:[self class perform:windowSpecSelector]. |
|
630 |
windowSpec := specArray decodeAsLiteralArray. |
|
631 |
windowSpec window bounds extent. |
|
632 |
] |
|
633 |
) max. |
|
634 |
||
635 |
self window extent:(maxCanvasExtent + (200 @ 40)). |
|
3796 | 636 |
! ! |
637 |
||
638 |
!AssistantApplication methodsFor:'look'! |
|
639 |
||
640 |
backButtonLabel |
|
641 |
^ LabelAndIcon |
|
642 |
label:(resources string:'Back') |
|
643 |
icon:(self backButtonEnabled value |
|
644 |
ifTrue:[ToolbarIconLibrary leftArrow24x24Icon] |
|
645 |
ifFalse:[ToolbarIconLibrary leftArrow24x24disabledIcon]) |
|
646 |
! |
|
647 |
||
648 |
nextButtonLabel |
|
649 |
^ LabelAndTwoIcons new |
|
650 |
string:(resources string:'Next'); |
|
651 |
image2:(self forwardButtonEnabled value |
|
652 |
ifTrue:[ToolbarIconLibrary rightArrow24x24Icon] |
|
653 |
ifFalse:[ToolbarIconLibrary rightArrow24x24disabledIcon]) |
|
654 |
! |
|
655 |
||
656 |
pageLabels |
|
657 |
^ self assistantSpec collect:[:specEntry | specEntry pageTitle]. |
|
658 |
! ! |
|
659 |
||
660 |
!AssistantApplication methodsFor:'private'! |
|
661 |
||
662 |
canFinish |
|
663 |
|pageIndex pageSpec| |
|
664 |
||
665 |
pageIndex := self currentPageIndexHolder value. |
|
666 |
pageSpec := self assistantSpec at:pageIndex. |
|
667 |
^ pageSpec canLeaveQuerySelector isNil |
|
668 |
or:[ self perform:pageSpec canLeaveQuerySelector ] |
|
669 |
! |
|
670 |
||
671 |
currentPageIndex |
|
672 |
^ self currentPageIndexHolder value |
|
673 |
! |
|
674 |
||
675 |
currentPageSpec |
|
676 |
^ self assistantSpec at:(self currentPageIndex). |
|
677 |
! |
|
678 |
||
3805 | 679 |
indexOfNextEnabledPageSpec |
680 |
|delta currentPageIndex| |
|
681 |
||
682 |
currentPageIndex := self currentPageIndex. |
|
683 |
delta := 1. |
|
684 |
[ |
|
685 |
(currentPageIndex + delta) <= (self numberOfPages) |
|
686 |
and:[ (self isPageEnabledAtIndex:(currentPageIndex + delta)) not ] |
|
687 |
] whileTrue:[ |
|
688 |
delta := delta + 1. |
|
689 |
]. |
|
690 |
(currentPageIndex + delta) <= (self numberOfPages) ifTrue:[ |
|
691 |
^ (currentPageIndex + delta). |
|
692 |
]. |
|
693 |
^ nil |
|
694 |
! |
|
695 |
||
696 |
indexOfPreviousEnabledPageSpec |
|
697 |
|delta currentPageIndex| |
|
698 |
||
699 |
currentPageIndex := self currentPageIndex. |
|
700 |
delta := 1. |
|
701 |
[ |
|
702 |
(currentPageIndex - delta) > 0 |
|
703 |
and:[ (self isPageEnabledAtIndex:(currentPageIndex - delta)) not ] |
|
704 |
] whileTrue:[ |
|
705 |
delta := delta + 1. |
|
706 |
]. |
|
707 |
(currentPageIndex - delta) > 0 ifTrue:[ |
|
708 |
^ (currentPageIndex - delta). |
|
709 |
]. |
|
710 |
^ nil |
|
711 |
! |
|
712 |
||
713 |
isPageEnabledAtIndex:index |
|
714 |
|isEnabledSelector| |
|
715 |
||
716 |
isEnabledSelector := (self assistantSpec at:index) isEnabledQuerySelector. |
|
717 |
^ isEnabledSelector isNil or:[ (self perform:isEnabledSelector) ] |
|
718 |
! |
|
719 |
||
720 |
nextEnabledPageSpec |
|
721 |
|index| |
|
722 |
||
723 |
index := self indexOfNextEnabledPageSpec. |
|
724 |
index isNil ifTrue:[^ nil]. |
|
725 |
^ self assistantSpec at:index. |
|
726 |
! |
|
727 |
||
3796 | 728 |
nextPageSpec |
729 |
^ self assistantSpec at:(self currentPageIndex + 1). |
|
730 |
! |
|
731 |
||
732 |
numberOfPages |
|
733 |
^ self assistantSpec size |
|
734 |
! |
|
735 |
||
3805 | 736 |
previousEnabledPageSpec |
737 |
|index| |
|
738 |
||
739 |
index := self indexOfPreviousEnabledPageSpec. |
|
740 |
index isNil ifTrue:[^ nil]. |
|
741 |
^ self assistantSpec at:index. |
|
742 |
! |
|
743 |
||
3796 | 744 |
previousPageSpec |
745 |
^ self assistantSpec at:(self currentPageIndex - 1). |
|
3811 | 746 |
! ! |
747 |
||
748 |
!AssistantApplication methodsFor:'update'! |
|
3796 | 749 |
|
3806 | 750 |
updateButtonEnableState |
751 |
self backButtonEnabled value:(self canGoBackward). |
|
752 |
self forwardButtonEnabled value:(self canGoForward). |
|
753 |
self backButtonLabelHolder value:(self backButtonLabel). |
|
754 |
self nextButtonLabelHolder value:(self nextButtonLabel). |
|
755 |
! |
|
756 |
||
3796 | 757 |
updateCanvas |
758 |
|pageIndex pageSpec sel uiSpec| |
|
759 |
||
760 |
pageIndex := self currentPageIndex. |
|
761 |
pageSpec := self currentPageSpec. |
|
762 |
sel := pageSpec windowSpecSelector. |
|
3805 | 763 |
uiSpec := self perform:sel ifNotUnderstood:[ self class perform:sel ]. |
3796 | 764 |
|
3805 | 765 |
self pageLabelsInList contents:(self pageLabelsInListWithBullet). |
3796 | 766 |
self currentPageSpecHolder value:uiSpec. |
767 |
self window label:(pageSpec pageTitle). |
|
768 |
||
769 |
self finishButtonVisible value:(pageIndex == self numberOfPages). |
|
770 |
self backButtonEnabled value:(pageIndex > 1). |
|
771 |
self forwardButtonEnabled value:(pageIndex < self numberOfPages). |
|
772 |
self finishButtonEnabled value:(pageIndex == self numberOfPages and:[ self canFinish ]). |
|
773 |
||
774 |
self backButtonLabelHolder value:(self backButtonLabel). |
|
775 |
self nextButtonLabelHolder value:(self nextButtonLabel). |
|
3811 | 776 |
|
777 |
self pageInfoHolder value:(pageSpec infoText). |
|
3796 | 778 |
! ! |
779 |
||
780 |
!AssistantApplication class methodsFor:'documentation'! |
|
781 |
||
782 |
version_CVS |
|
3811 | 783 |
^ '$Header: /cvs/stx/stx/libwidg2/AssistantApplication.st,v 1.9 2009-10-22 17:38:57 cg Exp $' |
3796 | 784 |
! ! |