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