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