AssistantApplication.st
changeset 3813 0595ad4f2239
parent 3812 f65a55aadf08
child 3814 71bd81ca3f67
equal deleted inserted replaced
3812:f65a55aadf08 3813:0595ad4f2239
    11 	category:'Views-DialogBoxes'
    11 	category:'Views-DialogBoxes'
    12 !
    12 !
    13 
    13 
    14 !AssistantApplication class methodsFor:'documentation'!
    14 !AssistantApplication class methodsFor:'documentation'!
    15 
    15 
    16 documentation'
    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.
       
    24 "
    17 ! !
    25 ! !
    18 
    26 
    19 !AssistantApplication class methodsFor:'help'!
    27 !AssistantApplication class methodsFor:'help'!
    20 
    28 
    21 hodsFor:'help'
    29 flyByHelpSpec
       
    30     <resource: #help>
       
    31 
       
    32     ^ super flyByHelpSpec addPairsFrom:#(
       
    33 
       
    34 #backButton
       
    35 'Navigate to the previous page %(previousPageInfo)'
       
    36 
       
    37 #nextButton
       
    38 'Navigate to the next page %(nextPageInfo)'
       
    39 
       
    40 )
    22 ! !
    41 ! !
    23 
    42 
    24 !AssistantApplication class methodsFor:'image specs'!
    43 !AssistantApplication class methodsFor:'image specs'!
    25 
    44 
    26 :'image specs'
    45 bulletIcon
    27 !
    46     "This resource specification was automatically generated
    28 
    47      by the ImageEditor of ST/X."
    29 ); yourself]
    48 
    30 !
    49     "Do not manually edit this!! If it is corrupted,
    31 
    50      the ImageEditor may not be able to read the specification."
    32 ); yourself]
    51 
       
    52     "
       
    53      self bulletIcon inspect
       
    54      ImageEditor openOnClass:self andSelector:#bulletIcon
       
    55      Icon flushCachedIcons
       
    56     "
       
    57 
       
    58     <resource: #image>
       
    59 
       
    60     ^Icon
       
    61         constantNamed:'AssistantApplication class bulletIcon'
       
    62         ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@% @@BPA @@P@D@@ @@ @D@@D@A@@A@@ @@ @A@@P@@$@X@@@% @@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@<@O<@?0G? _>A?8G? O<@?0@<@@@@@@@@@b') ; yourself); yourself]
       
    63 !
       
    64 
       
    65 leftArrowIcon
       
    66     "This resource specification was automatically generated
       
    67      by the ImageEditor of ST/X."
       
    68 
       
    69     "Do not manually edit this!! If it is corrupted,
       
    70      the ImageEditor may not be able to read the specification."
       
    71 
       
    72     "
       
    73      self leftArrowIcon inspect
       
    74      ImageEditor openOnClass:self andSelector:#leftArrowIcon
       
    75      Icon flushCachedIcons
       
    76     "
       
    77 
       
    78     <resource: #image>
       
    79 
       
    80     ^Icon
       
    81         constantNamed:'AssistantApplication class leftArrowIcon'
       
    82         ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@D@@@@G@@@@G??<@A???@@G@@@@@P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@A@@L@A0@O@A?>O?9??''?>O?8_? <@A0@C@@D@@@@b') ; yourself); yourself]
       
    83 !
       
    84 
       
    85 rightArrowIcon
       
    86     "This resource specification was automatically generated
       
    87      by the ImageEditor of ST/X."
       
    88 
       
    89     "Do not manually edit this!! If it is corrupted,
       
    90      the ImageEditor may not be able to read the specification."
       
    91 
       
    92     "
       
    93      self rightArrowIcon inspect
       
    94      ImageEditor openOnClass:self andSelector:#rightArrowIcon
       
    95      Icon flushCachedIcons
       
    96     "
       
    97 
       
    98     <resource: #image>
       
    99 
       
   100     ^Icon
       
   101         constantNamed:'AssistantApplication class rightArrowIcon'
       
   102         ifAbsentPut:[(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#[2]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@P@@@@M@@O??4@C??=@@@@M@@@@A@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 84 84 84 170 170 170 255 255 255]; mask:((Depth1Image new) width: 16; height: 16; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@ @C@@N@@<G?8_?1??''?>_?1?>@C0@N@@0@B@@@@b') ; yourself); yourself]
    33 ! !
   103 ! !
    34 
   104 
    35 !AssistantApplication class methodsFor:'interface specs'!
   105 !AssistantApplication class methodsFor:'interface specs'!
    36 
   106 
    37 windowSpec
   107 windowSpec
    54         name: windowSpec
   124         name: windowSpec
    55         window: 
   125         window: 
    56        (WindowSpec
   126        (WindowSpec
    57           label: 'NewApplication'
   127           label: 'NewApplication'
    58           name: 'NewApplication'
   128           name: 'NewApplication'
    59           min: (Point 534 440)
       
    60           bounds: (Rectangle 0 0 534 440)
   129           bounds: (Rectangle 0 0 534 440)
    61           menu: mainMenu
   130           menu: mainMenu
    62         )
   131         )
    63         component: 
   132         component: 
    64        (SpecCollection
   133        (SpecCollection
    86                           component: 
   155                           component: 
    87                          (SpecCollection
   156                          (SpecCollection
    88                             collection: (
   157                             collection: (
    89                              (SequenceViewSpec
   158                              (SequenceViewSpec
    90                                 name: 'PagesLabelList'
   159                                 name: 'PagesLabelList'
    91                                 layout: (LayoutFrame 0 0 0 0 0 1 0 0.6)
   160                                 layout: (LayoutFrame 0 0 0 0 0 1 0 0.7)
    92                                 level: 0
   161                                 level: 0
    93                                 enableChannel: false
   162                                 enableChannel: false
    94                                 hasHorizontalScrollBar: true
   163                                 hasHorizontalScrollBar: true
    95                                 hasVerticalScrollBar: true
   164                                 hasVerticalScrollBar: true
    96                                 miniScrollerHorizontal: true
       
    97                                 miniScrollerVertical: true
       
    98                                 useIndex: true
   165                                 useIndex: true
    99                                 sequenceList: pageLabelsInList
   166                                 sequenceList: pageLabelsInList
   100                               )
   167                               )
   101                              (HTMLViewSpec
   168                              (HTMLViewSpec
   102                                 name: 'HTMLBrowser1'
   169                                 name: 'HTMLBrowser1'
   103                                 layout: (LayoutFrame 0 0 0 0.6 0 1 0 1)
   170                                 layout: (LayoutFrame 0 0 0 0.7 0 1 0 1)
   104                                 level: 0
   171                                 level: 0
   105                                 hasHorizontalScrollBar: true
   172                                 hasHorizontalScrollBar: true
   106                                 hasVerticalScrollBar: true
   173                                 hasVerticalScrollBar: true
   107                                 miniScrollerHorizontal: true
   174                                 miniScrollerHorizontal: true
   108                                 miniScrollerVertical: true
   175                                 miniScrollerVertical: true
   214       )
   281       )
   215 ! !
   282 ! !
   216 
   283 
   217 !AssistantApplication class methodsFor:'menu specs'!
   284 !AssistantApplication class methodsFor:'menu specs'!
   218 
   285 
   219 enableChannel: finishButtonEnabled
   286 mainMenu
   220                           extent: (Point 65 22)
   287     "This resource specification was automatically generated
   221                         )
   288      by the MenuEditor of ST/X."
   222                        (ActionButtonSpec
   289 
   223                           label: 'Cancel'
   290     "Do not manually edit this!! If it is corrupted,
   224                           name: 'Button8'
   291      the MenuEditor may not be able to read the specification."
   225                           translateLabel: true
   292 
   226                           resizeForLabel: true
   293     "
   227                           model: doCancel
   294      MenuEditor new openOnClass:AssistantApplication andSelector:#mainMenu
   228                           extent: (Point 65 22)
   295      (Menu new fromLiteralArrayEncoding:(AssistantApplication mainMenu)) startUp
   229                         )
   296     "
   230                        )
   297 
   231                      
   298     <resource: #menu>
   232                     )
   299 
   233                   )
   300     ^ 
   234                  )
   301      #(Menu
   235                
   302         (
   236               )
   303          (MenuItem
   237             )
   304             label: 'File'
   238            (LabelSpec
   305             translateLabel: true
   239               label: 'Label'
   306             submenu: 
   240               name: 'Label1'
   307            (Menu
   241               layout: (LayoutFrame 1 0 -25 1 -1 1 -1 1)
   308               (
   242               level: -1
   309                (MenuItem
   243               translateLabel: true
   310                   label: 'Exit'
   244               labelChannel: infoHolder
       
   245               adjust: left
       
   246             )
       
   247            )
       
   248          
       
   249         )
       
   250       )
       
   251 ! !
       
   252 
       
   253 !AssistantApplication class methodsFor:'required protocol'!
       
   254 
       
   255 label: 'Exit'
       
   256                   itemValue: closeRequest
   311                   itemValue: closeRequest
   257                   translateLabel: true
   312                   translateLabel: true
   258                 )
   313                 )
   259                )
   314                )
   260               nil
   315               nil
   290         nil
   345         nil
   291         nil
   346         nil
   292       )
   347       )
   293 ! !
   348 ! !
   294 
   349 
       
   350 !AssistantApplication class methodsFor:'required protocol'!
       
   351 
       
   352 assistantSpec
       
   353     "must return a sequenceable collection of assistantPageSpecs - one for each page"
       
   354 
       
   355     self subclassResponsibility
       
   356 ! !
       
   357 
   295 !AssistantApplication methodsFor:'actions'!
   358 !AssistantApplication methodsFor:'actions'!
   296 
   359 
   297 )
   360 canGoBackward
   298          (MenuItem
   361     |currentPageSpec previousPageSpec|
   299             label: 'Help'
   362 
   300             translateLabel: true
   363     "/ see if we are allowed to leave...
   301             startGroup: right
   364     currentPageSpec := self currentPageSpec.
   302             submenu: 
   365     currentPageSpec canLeaveQuerySelector notNil ifTrue:[
   303            (Menu
   366         (self perform:currentPageSpec canLeaveQuerySelector) ifFalse:[^ false].
   304               (
       
   305                (MenuItem
       
   306                   label: 'Documentation'
       
   307                   itemValue: openDocumentation
       
   308                   translateLabel: true
       
   309                 )
       
   310                (MenuItem
       
   311                   label: '-'
       
   312                 )
       
   313                (MenuItem
       
   314                   label: 'About this Application...'
       
   315                   itemValue: openAboutThisApplication
       
   316                   translateLabel: true
       
   317                 )
       
   318                )
       
   319               nil
       
   320               nil
       
   321             )
       
   322           )
       
   323          )
       
   324         nil
       
   325         nil
       
   326       )
       
   327 !
       
   328 
       
   329 )
       
   330                )
       
   331               nil
       
   332               nil
       
   333             )
       
   334           )
       
   335          )
       
   336         nil
       
   337         nil
       
   338       )
       
   339 !
       
   340 
       
   341 ector) ifFalse:[^ false].
       
   342     ].
   367     ].
   343 
   368 
   344     "/ see if we are allowed to enter the next...
   369     "/ see if we are allowed to enter the next...
   345     previousPageSpec := self previousEnabledPageSpec.
   370     previousPageSpec := self previousEnabledPageSpec.
   346     previousPageSpec isNil ifTrue:[^ false].
   371     previousPageSpec isNil ifTrue:[^ false].
   349         (self perform:previousPageSpec canEnterQuerySelector) ifFalse:[^ false].
   374         (self perform:previousPageSpec canEnterQuerySelector) ifFalse:[^ false].
   350     ].
   375     ].
   351     ^ true
   376     ^ true
   352 !
   377 !
   353 
   378 
   354 "/ see if we are allowed to enter the next...
   379 canGoForward
   355     previousPageSpec := self previousEnabledPageSpec.
   380     |currentPageSpec nextPageSpec|
   356     previousPageSpec isNil ifTrue:[^ false].
   381 
   357 
   382     self currentPageIndex == self numberOfPages ifTrue:[^ false].
   358     previousPageSpec canEnterQuerySelector notNil ifTrue:[
   383 
   359         (self perform:previousPageSpec canEnterQuerySelector) ifFalse:[^ false].
   384     "/ see if we are allowed to leave...
   360     ].
   385     currentPageSpec := self currentPageSpec.
   361     ^ true
   386     currentPageSpec canLeaveQuerySelector notNil ifTrue:[
   362 !
   387         (self perform:currentPageSpec canLeaveQuerySelector) ifFalse:[^ false].
   363 
       
   364 he next...
       
   365     previousPageSpec := self previousEnabledPageSpec.
       
   366     previousPageSpec isNil ifTrue:[^ false].
       
   367 
       
   368     previousPageSpec canEnterQuerySelector notNil ifTrue:[
       
   369         (self perform:previousPageSpec canEnterQuerySelector) ifFalse:[^ false].
       
   370     ].
       
   371     ^ true
       
   372 !
       
   373 
       
   374 lf perform:currentPageSpec canLeaveQuerySelector) ifFalse:[^ false].
       
   375     ].
   388     ].
   376 
   389 
   377     "/ see if we are allowed to enter the next...
   390     "/ see if we are allowed to enter the next...
   378     nextPageSpec := self nextEnabledPageSpec.
   391     nextPageSpec := self nextEnabledPageSpec.
   379     nextPageSpec isNil ifTrue:[^ false].
   392     nextPageSpec isNil ifTrue:[^ false].
   380 
   393 
   381     nextPageSpec canEnterQuerySelector notNil ifTrue:[
   394     nextPageSpec canEnterQuerySelector notNil ifTrue:[
   382         (self perform:nextPageSpec canEnterQuerySelector) ifFalse:[^ false].
   395         (self perform:nextPageSpec canEnterQuerySelector) ifFalse:[^ false].
   383     ].
   396     ].
   384     ^ true
   397     ^ true
   385 ! !
   398 !
   386 
   399 
   387 !AssistantApplication methodsFor:'aspects'!
   400 doCancel
   388 
   401     self closeRequest
   389 tPageSpec leaveCallbackSelector notNil ifTrue:[
   402 !
       
   403 
       
   404 doFinish
       
   405     self closeRequest
       
   406 !
       
   407 
       
   408 goBackward
       
   409     |currentPageSpec|
       
   410 
       
   411     (self canGoBackward) ifFalse:[^ self].
       
   412 
       
   413     currentPageSpec := self currentPageSpec.
       
   414     currentPageSpec leaveCallbackSelector notNil ifTrue:[
   390         self perform:currentPageSpec leaveCallbackSelector
   415         self perform:currentPageSpec leaveCallbackSelector
   391     ].
   416     ].
   392 
   417 
   393     self currentPageIndexHolder value:((self indexOfPreviousEnabledPageSpec) max:1).
   418     self currentPageIndexHolder value:((self indexOfPreviousEnabledPageSpec) max:1).
   394 
   419 
   398     ].
   423     ].
   399 
   424 
   400     self updateButtonEnableState.
   425     self updateButtonEnableState.
   401 !
   426 !
   402 
   427 
   403 self perform:currentPageSpec leaveCallbackSelector
   428 goForward
   404     ].
   429     |currentPageSpec|
   405 
   430 
   406     self currentPageIndexHolder value:((self indexOfPreviousEnabledPageSpec) max:1).
   431     (self canGoForward) ifFalse:[^ self].
       
   432 
       
   433     currentPageSpec := self currentPageSpec.
       
   434     currentPageSpec leaveCallbackSelector notNil ifTrue:[
       
   435         self perform:currentPageSpec leaveCallbackSelector
       
   436     ].
       
   437 
       
   438     self currentPageIndexHolder value:(self indexOfNextEnabledPageSpec).
   407 
   439 
   408     currentPageSpec := self currentPageSpec.
   440     currentPageSpec := self currentPageSpec.
   409     currentPageSpec enterCallbackSelector notNil ifTrue:[
   441     currentPageSpec enterCallbackSelector notNil ifTrue:[
   410         self perform:currentPageSpec enterCallbackSelector
   442         self perform:currentPageSpec enterCallbackSelector
   411     ].
   443     ].
   412 
   444 
   413     self updateButtonEnableState.
   445     self updateButtonEnableState.
   414 !
   446 ! !
   415 
   447 
   416 Spec := self currentPageSpec.
   448 !AssistantApplication methodsFor:'aspects'!
   417     currentPageSpec enterCallbackSelector notNil ifTrue:[
       
   418         self perform:currentPageSpec enterCallbackSelector
       
   419     ].
       
   420 
       
   421     self updateButtonEnableState.
       
   422 !
       
   423 
       
   424 oForward
       
   425     |currentPageSpec|
       
   426 
       
   427     (self canGoForward) ifFalse:[^ self].
       
   428 
       
   429     currentPageSpec := self currentPageSpec.
       
   430     currentPageSpec leaveCallbackSelector notNil ifTrue:[
       
   431         self perform:currentPageSpec leaveCallbackSelector
       
   432     ].
       
   433 
       
   434     self currentPageIndexHolder value:(self indexOfNextEnabledPageSpec).
       
   435 
       
   436     currentPageSpec := self currentPageSpec.
       
   437     currentPageSpec enterCallbackSelector notNil ifTrue:[
       
   438         self perform:currentPageSpec enterCallbackSelector
       
   439     ].
       
   440 
       
   441     self updateButtonEnableState.
       
   442 !
       
   443 
       
   444 otNil ifTrue:[
       
   445         self perform:currentPageSpec leaveCallbackSelector
       
   446     ].
       
   447 
       
   448     self currentPageIndexHolder value:(self indexOfNextEnabledPageSpec).
       
   449 
       
   450     currentPageSpec := self currentPageSpec.
       
   451     currentPageSpec enterCallbackSelector notNil ifTrue:[
       
   452         self perform:currentPageSpec enterCallbackSelector
       
   453     ].
       
   454 
       
   455     self updateButtonEnableState.
       
   456 !
       
   457 
       
   458 Nil ifTrue:[
       
   459         self perform:currentPageSpec enterCallbackSelector
       
   460     ].
       
   461 
       
   462     self updateButtonEnableState.
       
   463 !
       
   464 
   449 
   465 assistantSpec
   450 assistantSpec
   466 !
   451     ^ self class assistantSpec
   467 
   452 !
   468 !
   453 
   469 
   454 backButtonEnabled
   470 backButtonLabelHolder.
   455     <resource: #uiAspect>
   471 !
   456 
   472 
   457     backButtonEnabled isNil ifTrue:[
   473 ButtonVisible.
   458         backButtonEnabled := false asValue.
   474 !
   459     ].
   475 
   460     ^ backButtonEnabled.
   476 IndexHolder onChangeSend:#updateCanvas to:self
   461 !
       
   462 
       
   463 backButtonLabelHolder
       
   464     <resource: #uiAspect>
       
   465 
       
   466     backButtonLabelHolder isNil ifTrue:[
       
   467         backButtonLabelHolder := self backButtonLabel asValue.
       
   468     ].
       
   469     ^ backButtonLabelHolder.
       
   470 !
       
   471 
       
   472 backButtonVisible
       
   473     <resource: #uiAspect>
       
   474 
       
   475     backButtonVisible isNil ifTrue:[
       
   476         backButtonVisible := true asValue.
       
   477     ].
       
   478     ^ backButtonVisible.
       
   479 !
       
   480 
       
   481 currentPageIndexHolder
       
   482     <resource: #uiAspect>
       
   483 
       
   484     currentPageIndexHolder isNil ifTrue:[
       
   485         currentPageIndexHolder := 1 asValue.
       
   486         currentPageIndexHolder onChangeSend:#updateCanvas to:self
   477     ].
   487     ].
   478     ^ currentPageIndexHolder.
   488     ^ currentPageIndexHolder.
   479 !
   489 !
   480 
   490 
   481 il ifTrue:[
   491 currentPageInfoHTMLHolder
       
   492     <resource: #uiAspect>
       
   493 
       
   494     currentPageInfoHTMLHolder isNil ifTrue:[
   482         currentPageInfoHTMLHolder := ValueHolder new.
   495         currentPageInfoHTMLHolder := ValueHolder new.
   483     ].
   496     ].
   484     ^ currentPageInfoHTMLHolder.
   497     ^ currentPageInfoHTMLHolder.
   485 !
   498 !
   486 
   499 
   487 True:[
   500 currentPageSpecHolder
       
   501     <resource: #uiAspect>
       
   502 
       
   503     currentPageSpecHolder isNil ifTrue:[
   488         currentPageSpecHolder := nil asValue.
   504         currentPageSpecHolder := nil asValue.
   489     ].
   505     ].
   490     ^ currentPageSpecHolder.
   506     ^ currentPageSpecHolder.
       
   507 !
       
   508 
       
   509 finishButtonEnabled
       
   510     <resource: #uiAspect>
       
   511 
       
   512     finishButtonEnabled isNil ifTrue:[
       
   513         finishButtonEnabled := false asValue.
       
   514     ].
       
   515     ^ finishButtonEnabled.
       
   516 !
       
   517 
       
   518 finishButtonVisible
       
   519     <resource: #uiAspect>
       
   520 
       
   521     finishButtonVisible isNil ifTrue:[
       
   522         finishButtonVisible := false asValue.
       
   523     ].
       
   524     ^ finishButtonVisible.
       
   525 !
       
   526 
       
   527 forwardButtonEnabled
       
   528     <resource: #uiAspect>
       
   529 
       
   530     forwardButtonEnabled isNil ifTrue:[
       
   531         forwardButtonEnabled := false asValue.
       
   532     ].
       
   533     ^ forwardButtonEnabled.
       
   534 !
       
   535 
       
   536 forwardButtonVisible
       
   537     <resource: #uiAspect>
       
   538 
       
   539     forwardButtonVisible isNil ifTrue:[
       
   540         forwardButtonVisible := true asValue.
       
   541     ].
       
   542     ^ forwardButtonVisible.
       
   543 !
       
   544 
       
   545 nextButtonLabelHolder
       
   546     <resource: #uiAspect>
       
   547 
       
   548     nextButtonLabelHolder isNil ifTrue:[
       
   549         nextButtonLabelHolder := self nextButtonLabel asValue.
       
   550     ].
       
   551     ^ nextButtonLabelHolder.
       
   552 !
       
   553 
       
   554 pageInfoHolder
       
   555     <resource: #uiAspect>
       
   556 
       
   557     pageInfoHolder isNil ifTrue:[
       
   558         pageInfoHolder := nil asValue.
       
   559     ].
       
   560     ^ pageInfoHolder.
       
   561 !
       
   562 
       
   563 pageLabelsInList
       
   564     pageLabelsInList isNil ifTrue:[
       
   565         pageLabelsInList := List new.
       
   566         pageLabelsInList contents:(self pageLabelsInListWithBullet).
       
   567     ].
       
   568     ^ pageLabelsInList
   491 !
   569 !
   492 
   570 
   493 pageLabelsInListWithBullet
   571 pageLabelsInListWithBullet
   494     |newList|
   572     |newList|
   495 
   573 
   512     ^ newList
   590     ^ newList
   513 ! !
   591 ! !
   514 
   592 
   515 !AssistantApplication methodsFor:'help'!
   593 !AssistantApplication methodsFor:'help'!
   516 
   594 
   517 pageInfoHolder isNil ifTrue:[
   595 flyByHelpTextForKey:aKey
   518         pageInfoHolder := nil asValue.
   596     <resource: #help>
   519     ].
   597 
   520     ^ pageInfoHolder.
   598     |text bindings nextSpec prevSpec|
   521 !
   599 
   522 
   600     text := super flyByHelpTextForKey:aKey.
   523 pageInfoHolder isNil ifTrue:[
   601 
   524         pageInfoHolder := nil asValue.
   602     nextSpec := self nextEnabledPageSpec.
   525     ].
   603     prevSpec := self previousEnabledPageSpec.
   526     ^ pageInfoHolder.
       
   527 ! !
       
   528 
       
   529 !AssistantApplication methodsFor:'initialization & release'!
       
   530 
       
   531 ith:(TextView defaultSelectionForegroundColor) on:(TextView defaultSelectionBackgroundColor) );
       
   532                             icon:(self class rightArrowIcon);
       
   533                             image2:(self class leftArrowIcon)
       
   534                     ] ifFalse:[
       
   535                         (self isPageEnabledAtIndex:index) ifFalse:[
       
   536                             entry colorizeAllWith:(Button defaultDisabledForegroundColor) "Color grey".
       
   537                         ] ifTrue:[
       
   538                             entry
       
   539                         ].
       
   540                     ].
       
   541                 ].
       
   542     ^ newList
       
   543 ! !
       
   544 
       
   545 !AssistantApplication methodsFor:'look'!
       
   546 
       
   547 revSpec := self previousEnabledPageSpec.
       
   548 
   604 
   549     bindings := Dictionary new.
   605     bindings := Dictionary new.
   550     bindings 
   606     bindings 
   551         at:#'previousPageInfo' 
   607         at:#'previousPageInfo' 
   552         put:(prevSpec notNil ifTrue:[ '"',prevSpec pageTitle,'"' ] ifFalse:['']).
   608         put:(prevSpec notNil ifTrue:[ '"',prevSpec pageTitle,'"' ] ifFalse:['']).
   553     bindings 
   609     bindings 
   554         at:#'nextPageInfo'
   610         at:#'nextPageInfo'
   555         put:(nextSpec notNil ifTrue:[ '"',nextSpec pageTitle,'"' ] ifFalse:['']).
   611         put:(nextSpec notNil ifTrue:[ '"',nextSpec pageTitle,'"' ] ifFalse:['']).
   556 
   612 
   557     ^ self resources string:text withArgs:bindings.    
   613     ^ self resources string:text withArgs:bindings.    
   558 !
   614 ! !
   559 
   615 
   560 xtSpec notNil ifTrue:[ '"',nextSpec pageTitle,'"' ] ifFalse:['']).
   616 !AssistantApplication methodsFor:'initialization & release'!
   561 
   617 
   562     ^ self resources string:text withArgs:bindings.    
   618 postBuildWith:aBuilder
   563 !
   619     |maxCanvasExtent|
   564 
   620 
   565 self updateCanvas.
   621     super postBuildWith:aBuilder.
       
   622     self updateCanvas.
   566 
   623 
   567     maxCanvasExtent := (self assistantSpec 
   624     maxCanvasExtent := (self assistantSpec 
   568                             collect:[:eachPageSpec | 
   625                             collect:[:eachPageSpec | 
   569                                 |windowSpecSelector specArray windowSpec|
   626                                 |windowSpecSelector specArray windowSpec|
   570 
   627 
   576                        ) max.
   633                        ) max.
   577 
   634 
   578     self window extent:(maxCanvasExtent + (200 @ 40)).
   635     self window extent:(maxCanvasExtent + (200 @ 40)).
   579 ! !
   636 ! !
   580 
   637 
       
   638 !AssistantApplication methodsFor:'look'!
       
   639 
       
   640 backButtonLabel
       
   641     ^ LabelAndIcon 
       
   642         label:(resources string:'Back')
       
   643         icon:(self backButtonEnabled value
       
   644                 ifTrue:[ToolbarIconLibrary leftArrow24x24Icon]
       
   645                 ifFalse:[ToolbarIconLibrary leftArrow24x24disabledIcon])
       
   646 !
       
   647 
       
   648 nextButtonLabel
       
   649     ^ LabelAndTwoIcons new 
       
   650         string:(resources string:'Next');
       
   651         image2:(self forwardButtonEnabled value
       
   652                 ifTrue:[ToolbarIconLibrary rightArrow24x24Icon]
       
   653                 ifFalse:[ToolbarIconLibrary rightArrow24x24disabledIcon])
       
   654 !
       
   655 
       
   656 pageLabels
       
   657     ^ self assistantSpec collect:[:specEntry | specEntry pageTitle].
       
   658 ! !
       
   659 
   581 !AssistantApplication methodsFor:'private'!
   660 !AssistantApplication methodsFor:'private'!
   582 
   661 
   583 |windowSpecSelector specArray windowSpec|
   662 canFinish
   584 
   663     |pageIndex pageSpec|
   585                                 windowSpecSelector := eachPageSpec windowSpecSelector.
   664 
   586                                 specArray := self perform:windowSpecSelector ifNotUnderstood:[self class perform:windowSpecSelector].
   665     pageIndex := self currentPageIndexHolder value.
   587                                 windowSpec := specArray decodeAsLiteralArray.
   666     pageSpec := self assistantSpec at:pageIndex.
   588                                 windowSpec window bounds extent.
   667     ^ pageSpec canLeaveQuerySelector isNil
   589                             ]
       
   590                        ) max.
       
   591 
       
   592     self window extent:(maxCanvasExtent + (200 @ 40)).
       
   593 !
       
   594 
       
   595 [self class perform:windowSpecSelector].
       
   596                                 windowSpec := specArray decodeAsLiteralArray.
       
   597                                 windowSpec window bounds extent.
       
   598                             ]
       
   599                        ) max.
       
   600 
       
   601     self window extent:(maxCanvasExtent + (200 @ 40)).
       
   602 !
       
   603 
       
   604 windowSpec := specArray decodeAsLiteralArray.
       
   605                                 windowSpec window bounds extent.
       
   606                             ]
       
   607                        ) max.
       
   608 
       
   609     self window extent:(maxCanvasExtent + (200 @ 40)).
       
   610 !
       
   611 
       
   612 windowSpec window bounds extent.
       
   613                             ]
       
   614                        ) max.
       
   615 
       
   616     self window extent:(maxCanvasExtent + (200 @ 40)).
       
   617 !
       
   618 
       
   619 Arrow24x24disabledIcon])
       
   620 !
       
   621 
       
   622 ication methodsFor:'private'
       
   623 !
       
   624 
       
   625 isNil
       
   626     or:[ self perform:pageSpec canLeaveQuerySelector ]
   668     or:[ self perform:pageSpec canLeaveQuerySelector ]
   627 !
   669 !
   628 
   670 
   629 elf assistantSpec at:(self currentPageIndex).
   671 currentPageIndex
   630 !
   672     ^ self currentPageIndexHolder value
   631 
   673 !
   632 c
   674 
       
   675 currentPageSpec
       
   676     ^ self assistantSpec at:(self currentPageIndex).
       
   677 !
       
   678 
       
   679 indexOfNextEnabledPageSpec
   633     |delta currentPageIndex|
   680     |delta currentPageIndex|
   634 
   681 
   635     currentPageIndex := self currentPageIndex.
   682     currentPageIndex := self currentPageIndex.
   636     delta := 1.
   683     delta := 1.
   637     [ 
   684     [ 
   644         ^ (currentPageIndex + delta).
   691         ^ (currentPageIndex + delta).
   645     ].
   692     ].
   646     ^ nil
   693     ^ nil
   647 !
   694 !
   648 
   695 
   649 ndex := self currentPageIndex.
   696 indexOfPreviousEnabledPageSpec
       
   697     |delta currentPageIndex|
       
   698 
       
   699     currentPageIndex := self currentPageIndex.
   650     delta := 1.
   700     delta := 1.
   651     [ 
   701     [ 
   652         (currentPageIndex + delta) <= (self numberOfPages)
   702         (currentPageIndex - delta) > 0
   653         and:[ (self isPageEnabledAtIndex:(currentPageIndex + delta)) not ]
   703         and:[ (self isPageEnabledAtIndex:(currentPageIndex - delta)) not ]
   654     ] whileTrue:[
   704     ] whileTrue:[
   655         delta := delta + 1.
   705         delta := delta + 1.
   656     ].
   706     ].
   657     (currentPageIndex + delta) <= (self numberOfPages) ifTrue:[
   707     (currentPageIndex - delta) > 0 ifTrue:[
   658         ^ (currentPageIndex + delta).
   708         ^ (currentPageIndex - delta).
   659     ].
   709     ].
   660     ^ nil
   710     ^ nil
   661 !
   711 !
   662 
   712 
   663 tPageIndex + delta)) not ]
   713 isPageEnabledAtIndex:index
   664     ] whileTrue:[
   714     |isEnabledSelector|
   665         delta := delta + 1.
   715 
   666     ].
   716     isEnabledSelector := (self assistantSpec at:index) isEnabledQuerySelector.
   667     (currentPageIndex + delta) <= (self numberOfPages) ifTrue:[
   717     ^ isEnabledSelector isNil or:[ (self perform:isEnabledSelector) ]
   668         ^ (currentPageIndex + delta).
   718 !
   669     ].
   719 
   670     ^ nil
   720 nextEnabledPageSpec
       
   721     |index|
       
   722 
       
   723     index := self indexOfNextEnabledPageSpec.
       
   724     index isNil ifTrue:[^ nil].
       
   725     ^ self assistantSpec at:index.
       
   726 !
       
   727 
       
   728 nextPageSpec
       
   729     ^ self assistantSpec at:(self currentPageIndex + 1).
       
   730 !
       
   731 
       
   732 numberOfPages
       
   733     ^ self assistantSpec size
       
   734 !
       
   735 
       
   736 previousEnabledPageSpec
       
   737     |index|
       
   738 
       
   739     index := self indexOfPreviousEnabledPageSpec.
       
   740     index isNil ifTrue:[^ nil].
       
   741     ^ self assistantSpec at:index.
       
   742 !
       
   743 
       
   744 previousPageSpec
       
   745     ^ self assistantSpec at:(self currentPageIndex - 1).
   671 ! !
   746 ! !
   672 
   747 
   673 !AssistantApplication methodsFor:'update'!
   748 !AssistantApplication methodsFor:'update'!
   674 
   749 
   675 .
   750 updateButtonEnableState
   676     (currentPageIndex + delta) <= (self numberOfPages) ifTrue:[
   751     self backButtonEnabled value:(self canGoBackward).
   677         ^ (currentPageIndex + delta).
   752     self forwardButtonEnabled value:(self canGoForward).
   678     ].
   753     self backButtonLabelHolder value:(self backButtonLabel).
   679     ^ nil
   754     self nextButtonLabelHolder value:(self nextButtonLabel).
   680 !
   755 !
   681 
   756 
   682 updateCanvas
   757 updateCanvas
   683     |pageIndex pageSpec sel uiSpec|
   758     |pageIndex pageSpec sel uiSpec|
   684 
   759 
   703 ! !
   778 ! !
   704 
   779 
   705 !AssistantApplication class methodsFor:'documentation'!
   780 !AssistantApplication class methodsFor:'documentation'!
   706 
   781 
   707 version_CVS
   782 version_CVS
   708     ^ '$Header: /cvs/stx/stx/libwidg2/AssistantApplication.st,v 1.10 2009-10-22 19:07:29 cg Exp $'
   783     ^ '$Header: /cvs/stx/stx/libwidg2/AssistantApplication.st,v 1.11 2009-10-22 19:24:38 cg Exp $'
   709 ! !
   784 ! !