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