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