UIHelpTool.st
changeset 1646 4d2809c829e0
parent 1622 766547778a34
child 1648 d88ec5777284
equal deleted inserted replaced
1645:714b89cb8ff7 1646:4d2809c829e0
    13 
    13 
    14 
    14 
    15 "{ Package: 'stx:libtool2' }"
    15 "{ Package: 'stx:libtool2' }"
    16 
    16 
    17 ToolApplicationModel subclass:#UIHelpTool
    17 ToolApplicationModel subclass:#UIHelpTool
    18 	instanceVariableNames:'specClass specSelector dictionary dictionaries listSelection
    18 	instanceVariableNames:'specClass specSelector dictionary dictionaries modifiedHolder
    19 		maxCharsPerLine modifiedHolder modified'
    19 		modified listOfKeys listOfKeysModel listOfClasses
       
    20 		listOfClassesModel contentsModifiedChannel editModel editTextView'
    20 	classVariableNames:''
    21 	classVariableNames:''
    21 	poolDictionaries:''
    22 	poolDictionaries:''
    22 	category:'Interface-UIPainter'
    23 	category:'Interface-UIPainter'
    23 !
    24 !
    24 
    25 
    89 !
    90 !
    90 
    91 
    91 openOnClass:aClass
    92 openOnClass:aClass
    92     "opens a Help Tool on aClass"
    93     "opens a Help Tool on aClass"
    93 
    94 
    94     self new openOnClass:aClass
    95     ^ self openOnClass:aClass andSelector:#helpSpec
    95 
    96 
    96     "
    97     "
    97      UIHelpTool openOnClass:self
    98      UIHelpTool openOnClass:self
    98     "
    99     "
    99 
   100 
   139 'Selected help text key.'
   140 'Selected help text key.'
   140 
   141 
   141 #deleteHelpTextKey
   142 #deleteHelpTextKey
   142 'Deletes the key from the help spec.'
   143 'Deletes the key from the help spec.'
   143 
   144 
       
   145 #fileLoad
       
   146 'Opens a dialog for selecting and loading a help spec from a class.'
       
   147 
       
   148 #fileSave
       
   149 'Saves the current help spec.'
       
   150 
       
   151 #fileUpdate
       
   152 'Reload the help spec.'
       
   153 
       
   154 #helpTextView
       
   155 'Shows the help text. Menu action ''Accept'' commits changes'
       
   156 
       
   157 #listOfClasses
       
   158 'Classes where help specs can be/are implemented.'
       
   159 
       
   160 #listOfHelpTexts
       
   161 'List of help text keys.'
       
   162 
       
   163 #removeHelpTextKey
       
   164 'Removes the help message from the widget.'
       
   165 
   144 #updateHelpTextKey
   166 #updateHelpTextKey
   145 'Refetch the help spec.'
   167 'Refetch the help spec.'
   146 
       
   147 #fileLoad
       
   148 'Opens a dialog for selecting and loading a help spec from a class.'
       
   149 
       
   150 #fileSave
       
   151 'Saves the current help spec.'
       
   152 
       
   153 #fileUpdate
       
   154 'Reload the help spec.'
       
   155 
       
   156 #helpTextView
       
   157 'Shows the help text. Menu action ''Accept'' commits changes'
       
   158 
       
   159 #listOfHelpSpecClasses
       
   160 'Classes where help specs can be/are implemented.'
       
   161 
       
   162 #listOfHelpTexts
       
   163 'List of help text keys.'
       
   164 
       
   165 #removeHelpTextKey
       
   166 'Removes the help message from the widget.'
       
   167 
   168 
   168 )
   169 )
   169 ! !
   170 ! !
   170 
   171 
   171 !UIHelpTool class methodsFor:'interface specs'!
   172 !UIHelpTool class methodsFor:'interface specs'!
   192        #(#WindowSpec
   193        #(#WindowSpec
   193           #label: 'Help Tool'
   194           #label: 'Help Tool'
   194           #name: 'Help Tool'
   195           #name: 'Help Tool'
   195           #min: #(#Point 10 10)
   196           #min: #(#Point 10 10)
   196           #max: #(#Point 1160 870)
   197           #max: #(#Point 1160 870)
   197           #bounds: #(#Rectangle 218 175 504 446)
   198           #bounds: #(#Rectangle 31 306 317 577)
   198         )
   199         )
   199         #component: 
   200         #component: 
   200        #(#SpecCollection
   201        #(#SpecCollection
   201           #collection: #(
   202           #collection: #(
   202            #(#VariableVerticalPanelSpec
   203            #(#VariableVerticalPanelSpec
   203               #name: 'VariableVerticalPanel'
   204               #name: 'VariableVerticalPanel'
   204               #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   205               #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   205               #component: 
   206               #component: 
   206              #(#SpecCollection
   207              #(#SpecCollection
   207                 #collection: #(
   208                 #collection: #(
       
   209                  #(#VariableHorizontalPanelSpec
       
   210                     #name: 'VariableHorizontalPanel'
       
   211                     #component: 
       
   212                    #(#SpecCollection
       
   213                       #collection: #(
       
   214                        #(#SelectionInListModelViewSpec
       
   215                           #name: 'listOfKeys'
       
   216                           #activeHelpKey: #listOfHelpTexts
       
   217                           #model: #listOfKeysModel
       
   218                           #menu: #listOfKeysMenu
       
   219                           #hasHorizontalScrollBar: true
       
   220                           #hasVerticalScrollBar: true
       
   221                           #miniScrollerHorizontal: true
       
   222                           #listModel: #listOfKeys
       
   223                           #useIndex: false
       
   224                           #highlightMode: #line
       
   225                         )
       
   226                        #(#ViewSpec
       
   227                           #name: 'Box'
       
   228                           #component: 
       
   229                          #(#SpecCollection
       
   230                             #collection: #(
       
   231                              #(#InputFieldSpec
       
   232                                 #name: 'helpKeyInputField'
       
   233                                 #layout: #(#LayoutFrame 2 0.0 2 0 -2 1.0 25 0)
       
   234                                 #activeHelpKey: #currentHelpTexts
       
   235                                 #tabable: true
       
   236                                 #model: #editModel
       
   237                                 #immediateAccept: true
       
   238                                 #acceptOnReturn: false
       
   239                                 #acceptOnTab: false
       
   240                                 #acceptOnPointerLeave: false
       
   241                               )
       
   242                              #(#SelectionInListModelViewSpec
       
   243                                 #name: 'listOfClasses'
       
   244                                 #layout: #(#LayoutFrame 0 0.0 27 0 0 1.0 0 1.0)
       
   245                                 #activeHelpKey: #listOfClasses
       
   246                                 #model: #listOfClassesModel
       
   247                                 #hasHorizontalScrollBar: true
       
   248                                 #hasVerticalScrollBar: true
       
   249                                 #miniScrollerHorizontal: true
       
   250                                 #miniScrollerVertical: true
       
   251                                 #listModel: #listOfClasses
       
   252                                 #useIndex: false
       
   253                                 #highlightMode: #line
       
   254                               )
       
   255                              )
       
   256                            
       
   257                           )
       
   258                         )
       
   259                        )
       
   260                      
       
   261                     )
       
   262                     #handles: #(#Any 0.5 1.0)
       
   263                   )
   208                  #(#ViewSpec
   264                  #(#ViewSpec
   209                     #name: 'Box1'
   265                     #name: 'Box1'
   210                     #component: 
   266                     #component: 
   211                    #(#SpecCollection
   267                    #(#SpecCollection
   212                       #collection: #(
   268                       #collection: #(
   213                        #(#HorizontalPanelViewSpec
   269                        #(#MenuPanelSpec
   214                           #name: 'HorizontalPanel1'
   270                           #name: 'helpTextMenu'
   215                           #layout: #(#LayoutFrame 0 0 0 0 0 1 25 0)
   271                           #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 24 0)
   216                           #horizontalLayout: #fit
   272                           #menu: #helpTextMenu
   217                           #verticalLayout: #fit
   273                           #textDefault: true
   218                           #horizontalSpace: 3
       
   219                           #verticalSpace: 3
       
   220                           #component: 
       
   221                          #(#SpecCollection
       
   222                             #collection: #(
       
   223                              #(#ActionButtonSpec
       
   224                                 #label: 'Add'
       
   225                                 #name: 'AddButton'
       
   226                                 #activeHelpKey: #addHelpTextKey
       
   227                                 #translateLabel: true
       
   228                                 #tabable: true
       
   229                                 #model: #doAdd
       
   230                                 #extent: #(#Point 69 25)
       
   231                               )
       
   232                              #(#ActionButtonSpec
       
   233                                 #label: 'Remove'
       
   234                                 #name: 'RemoveButton'
       
   235                                 #activeHelpKey: #removeHelpTextKey
       
   236                                 #translateLabel: true
       
   237                                 #tabable: true
       
   238                                 #model: #doRemove
       
   239                                 #extent: #(#Point 69 25)
       
   240                               )
       
   241                              #(#ActionButtonSpec
       
   242                                 #label: 'Update'
       
   243                                 #name: 'UpdateButton'
       
   244                                 #activeHelpKey: #updateHelpTextKey
       
   245                                 #translateLabel: true
       
   246                                 #tabable: true
       
   247                                 #model: #doUpdate
       
   248                                 #extent: #(#Point 69 25)
       
   249                               )
       
   250                              #(#ActionButtonSpec
       
   251                                 #label: 'Delete'
       
   252                                 #name: 'DeleteButton'
       
   253                                 #activeHelpKey: #deleteHelpTextKey
       
   254                                 #translateLabel: true
       
   255                                 #tabable: true
       
   256                                 #model: #doDelete
       
   257                                 #extent: #(#Point 70 25)
       
   258                               )
       
   259                              )
       
   260                            
       
   261                           )
       
   262                         )
   274                         )
   263                        #(#VariableHorizontalPanelSpec
   275                        #(#TextEditorSpec
   264                           #name: 'VariableHorizontalPanel'
   276                           #name: 'helpTextView'
   265                           #layout: #(#LayoutFrame 0 0 25 0 0 1 0 1)
   277                           #layout: #(#LayoutFrame 0 0.0 24 0.0 0 1.0 0 1.0)
   266                           #component: 
   278                           #activeHelpKey: #helpTextView
   267                          #(#SpecCollection
   279                           #tabable: true
   268                             #collection: #(
   280                           #hasHorizontalScrollBar: true
   269                              #(#SequenceViewSpec
   281                           #hasVerticalScrollBar: true
   270                                 #name: 'listOfHelpKeysView'
   282                           #miniScrollerHorizontal: true
   271                                 #activeHelpKey: #listOfHelpTexts
   283                           #miniScrollerVertical: true
   272                                 #tabable: true
   284                           #modifiedChannel: #contentsModifiedChannel
   273                                 #model: #listModel
   285                           #postBuildCallback: #postBuildTextView:
   274                                 #hasHorizontalScrollBar: true
       
   275                                 #hasVerticalScrollBar: true
       
   276                                 #miniScrollerHorizontal: true
       
   277                                 #useIndex: false
       
   278                                 #sequenceList: #listChannel
       
   279                               )
       
   280                              #(#ViewSpec
       
   281                                 #name: 'Box'
       
   282                                 #component: 
       
   283                                #(#SpecCollection
       
   284                                   #collection: #(
       
   285                                    #(#InputFieldSpec
       
   286                                       #name: 'helpKeyInputField'
       
   287                                       #layout: #(#LayoutFrame 2 0.0 2 0 -2 1.0 25 0)
       
   288                                       #activeHelpKey: #currentHelpTexts
       
   289                                       #tabable: true
       
   290                                       #model: #listModel
       
   291                                       #immediateAccept: false
       
   292                                       #acceptOnPointerLeave: false
       
   293                                     )
       
   294                                    #(#SequenceViewSpec
       
   295                                       #name: 'listOfHelpSpecClassesView'
       
   296                                       #layout: #(#LayoutFrame 0 0.0 27 0 0 1.0 0 1.0)
       
   297                                       #activeHelpKey: #listOfHelpSpecClasses
       
   298                                       #tabable: true
       
   299                                       #model: #selectionOfHelpSpecClass
       
   300                                       #hasHorizontalScrollBar: true
       
   301                                       #hasVerticalScrollBar: true
       
   302                                       #miniScrollerHorizontal: true
       
   303                                       #miniScrollerVertical: true
       
   304                                       #valueChangeSelector: #helpSpecClassSelected
       
   305                                       #useIndex: false
       
   306                                       #sequenceList: #listOfHelpSpecClasses
       
   307                                     )
       
   308                                    )
       
   309                                  
       
   310                                 )
       
   311                               )
       
   312                              )
       
   313                            
       
   314                           )
       
   315                           #handles: #(#Any 0.5 1.0)
       
   316                         )
   286                         )
   317                        )
   287                        )
   318                      
   288                      
   319                     )
   289                     )
   320                   )
       
   321                  #(#TextEditorSpec
       
   322                     #name: 'helpTextView'
       
   323                     #activeHelpKey: #helpTextView
       
   324                     #tabable: true
       
   325                     #hasHorizontalScrollBar: true
       
   326                     #hasVerticalScrollBar: true
       
   327                     #miniScrollerHorizontal: true
       
   328                     #miniScrollerVertical: true
       
   329                   )
   290                   )
   330                  )
   291                  )
   331                
   292                
   332               )
   293               )
   333               #handles: #(#Any 0.5 1.0)
   294               #handles: #(#Any 0.5 1.0)
   350      UIHelpTool new openInterface:#windowSpecForStandAlone
   311      UIHelpTool new openInterface:#windowSpecForStandAlone
   351     "
   312     "
   352 
   313 
   353     <resource: #canvas>
   314     <resource: #canvas>
   354 
   315 
   355     ^
   316     ^ 
   356      
   317      #(#FullSpec
   357        #(#FullSpec
   318         #name: #windowSpecForStandAlone
   358           #window: 
   319         #window: 
   359            #(#WindowSpec
   320        #(#WindowSpec
   360               #name: 'Help Tool'
   321           #label: 'Help Tool'
   361               #layout: #(#LayoutFrame 191 0 334 0 660 0 663 0)
   322           #name: 'Help Tool'
   362               #label: 'Help Tool'
   323           #min: #(#Point 300 300)
   363               #min: #(#Point 300 300)
   324           #max: #(#Point 1152 900)
   364               #max: #(#Point 1152 900)
   325           #bounds: #(#Rectangle 83 333 796 896)
   365               #bounds: #(#Rectangle 191 334 661 664)
   326           #menu: #menu
   366               #menu: #menu
   327         )
   367               #usePreferredExtent: false
   328         #component: 
       
   329        #(#SpecCollection
       
   330           #collection: #(
       
   331            #(#UISubSpecification
       
   332               #name: 'windowSpec'
       
   333               #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -26 1.0)
       
   334               #minorKey: #windowSpec
       
   335             )
       
   336            #(#UISubSpecification
       
   337               #name: 'windowSpecForInfoBar'
       
   338               #layout: #(#LayoutFrame 0 0 -24 1 0 1 0 1)
       
   339               #majorKey: #ToolApplicationModel
       
   340               #minorKey: #windowSpecForInfoBar
       
   341             )
       
   342            )
       
   343          
       
   344         )
       
   345       )
       
   346 ! !
       
   347 
       
   348 !UIHelpTool class methodsFor:'menu specs'!
       
   349 
       
   350 helpTextMenu
       
   351     "This resource specification was automatically generated
       
   352      by the MenuEditor of ST/X."
       
   353 
       
   354     "Do not manually edit this!! If it is corrupted,
       
   355      the MenuEditor may not be able to read the specification."
       
   356 
       
   357     "
       
   358      MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu
       
   359      (Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp
       
   360     "
       
   361 
       
   362     <resource: #menu>
       
   363 
       
   364     ^ 
       
   365      #(#Menu
       
   366         #(
       
   367          #(#MenuItem
       
   368             #activeHelpKey: #commitOK
       
   369             #enabled: #contentsModifiedChannel
       
   370             #label: 'Accept'
       
   371             #itemValue: #accept
       
   372             #translateLabel: true
   368           )
   373           )
   369           #component: 
   374          #(#MenuItem
   370            #(#SpecCollection
   375             #activeHelpKey: #commitCancel
   371               #collection: 
   376             #enabled: #contentsModifiedChannel
   372                #(
   377             #label: 'Cancel'
   373                  #(#UISubSpecification
   378             #itemValue: #cancel
   374                     #name: 'windowSpec'
   379             #translateLabel: true
   375                     #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 -26 1.0)
       
   376                     #minorKey: #windowSpec
       
   377                 )
       
   378                  #(#UISubSpecification
       
   379                     #name: 'windowSpecForInfoBar'
       
   380                     #layout: #(#LayoutFrame 0 0 -24 1 0 1 0 1)
       
   381                     #majorKey: #ToolApplicationModel
       
   382                     #minorKey: #windowSpecForInfoBar
       
   383                 )
       
   384               )
       
   385           )
   380           )
       
   381          )
       
   382         nil
       
   383         nil
   386       )
   384       )
   387 ! !
   385 !
   388 
   386 
   389 !UIHelpTool class methodsFor:'menu specs'!
   387 listOfKeysMenu
       
   388     "This resource specification was automatically generated
       
   389      by the MenuEditor of ST/X."
       
   390 
       
   391     "Do not manually edit this!! If it is corrupted,
       
   392      the MenuEditor may not be able to read the specification."
       
   393 
       
   394     "
       
   395      MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu
       
   396      (Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp
       
   397     "
       
   398 
       
   399     <resource: #menu>
       
   400 
       
   401     ^ 
       
   402      #(#Menu
       
   403         #(
       
   404          #(#MenuItem
       
   405             #activeHelpKey: #deleteHelpTextKey
       
   406             #label: 'Delete'
       
   407             #itemValue: #doDelete
       
   408             #translateLabel: true
       
   409           )
       
   410          )
       
   411         nil
       
   412         nil
       
   413       )
       
   414 !
   390 
   415 
   391 menu
   416 menu
   392     "This resource specification was automatically generated
   417     "This resource specification was automatically generated
   393      by the MenuEditor of ST/X."
   418      by the MenuEditor of ST/X."
   394 
   419 
   400      (Menu new fromLiteralArrayEncoding:(UIHelpTool menu)) startUp
   425      (Menu new fromLiteralArrayEncoding:(UIHelpTool menu)) startUp
   401     "
   426     "
   402 
   427 
   403     <resource: #menu>
   428     <resource: #menu>
   404 
   429 
   405     ^
   430     ^ 
   406 
   431      #(#Menu
   407        #(#Menu
   432         #(
   408 
   433          #(#MenuItem
   409            #(
   434             #label: 'File'
   410              #(#MenuItem
   435             #translateLabel: true
   411                 #label: 'File'
   436             #submenu: 
   412                 #translateLabel: true
   437            #(#Menu
   413                 #submenu: 
   438               #(
   414                  #(#Menu
   439                #(#MenuItem
   415 
   440                   #activeHelpKey: #fileLoad
   416                      #(
   441                   #label: 'Load...'
   417                        #(#MenuItem
   442                   #itemValue: #doLoad
   418                           #label: 'Load...'
   443                   #translateLabel: true
   419                           #translateLabel: true
       
   420                           #value: #doLoad
       
   421                           #activeHelpKey: #fileLoad
       
   422                       )
       
   423                        #(#MenuItem
       
   424                           #label: 'Update'
       
   425                           #translateLabel: true
       
   426                           #value: #doUpdate
       
   427                           #activeHelpKey: #fileUpdate
       
   428                       )
       
   429                        #(#MenuItem
       
   430                           #label: '-'
       
   431                       )
       
   432                        #(#MenuItem
       
   433                           #label: 'Save'
       
   434                           #translateLabel: true
       
   435                           #value: #doSave
       
   436                           #activeHelpKey: #fileSave
       
   437                       )
       
   438                        #(#MenuItem
       
   439                           #label: '-'
       
   440                       )
       
   441                        #(#MenuItem
       
   442                           #label: 'Exit'
       
   443                           #translateLabel: true
       
   444                           #value: #closeRequest
       
   445                           #activeHelpKey: #fileExit
       
   446                       )
       
   447                     ) nil
       
   448                     nil
       
   449                 )
   444                 )
       
   445                #(#MenuItem
       
   446                   #activeHelpKey: #fileSave
       
   447                   #label: 'Save'
       
   448                   #itemValue: #doSave
       
   449                   #translateLabel: true
       
   450                 )
       
   451                #(#MenuItem
       
   452                   #label: '-'
       
   453                 )
       
   454                #(#MenuItem
       
   455                   #activeHelpKey: #fileExit
       
   456                   #label: 'Exit'
       
   457                   #itemValue: #closeRequest
       
   458                   #translateLabel: true
       
   459                 )
       
   460                )
       
   461               nil
       
   462               nil
   450             )
   463             )
   451              #(#MenuItem
   464           )
   452                 #label: 'Edit'
   465          #(#MenuItem
   453                 #translateLabel: true
   466             #label: 'Edit'
   454                 #submenu: 
   467             #translateLabel: true
   455                  #(#Menu
   468             #submenu: 
   456 
   469            #(#Menu
   457                      #(
   470               #(
   458                        #(#MenuItem
   471                #(#MenuItem
   459                           #label: 'Add'
   472                   #activeHelpKey: #deleteHelpTextKey
   460                           #translateLabel: true
   473                   #label: 'Delete'
   461                           #value: #doAdd
   474                   #itemValue: #doDelete
   462                           #activeHelpKey: #addHelpTextKey
   475                   #translateLabel: true
   463                       )
       
   464                        #(#MenuItem
       
   465                           #label: '-'
       
   466                       )
       
   467                        #(#MenuItem
       
   468                           #label: 'Delete'
       
   469                           #translateLabel: true
       
   470                           #value: #doDelete
       
   471                           #activeHelpKey: #deleteHelpTextKey
       
   472                       )
       
   473                     ) nil
       
   474                     nil
       
   475                 )
   476                 )
       
   477                )
       
   478               nil
       
   479               nil
   476             )
   480             )
   477              #(#MenuItem
   481           )
   478                 #label: 'Help'
   482          #(#MenuItem
   479                 #translateLabel: true
   483             #activeHelpKey: #help
   480                 #startGroup: #right
   484             #label: 'Help'
   481                 #activeHelpKey: #help
   485             #translateLabel: true
   482                 #submenuChannel: #menuHelp
   486             #startGroup: #right
   483             )
   487             #submenuChannel: #menuHelp
   484           ) nil
   488           )
   485           nil
   489          )
       
   490         nil
       
   491         nil
   486       )
   492       )
   487 
       
   488 ! !
   493 ! !
   489 
   494 
   490 !UIHelpTool methodsFor:'accessing'!
   495 !UIHelpTool methodsFor:'accessing'!
   491 
   496 
   492 dictionaries
   497 dictionaries
   508     "returns the dictionary of the selected class"
   513     "returns the dictionary of the selected class"
   509 
   514 
   510     ^dictionary
   515     ^dictionary
   511 !
   516 !
   512 
   517 
   513 dictionary:aDictionary
       
   514     "sets dictionary of the selected class"
       
   515 
       
   516     (dictionary := aDictionary) isNil ifTrue:[
       
   517         dictionary := Dictionary new.
       
   518     ].
       
   519     self updateList
       
   520 !
       
   521 
       
   522 helpKey
   518 helpKey
   523     "returns the help key of selected help text"
   519     "returns the help key as symbol or nil
   524 
   520     "
   525     listSelection size ~~ 0 ifTrue:[
   521     |value|
   526         ^ listSelection asSymbol
   522 
       
   523     value := editModel value.
       
   524 
       
   525     value notNil ifTrue:[
       
   526         value := value withoutSeparators.
       
   527         value notEmpty ifTrue:[ ^ value asSymbol ]
   527     ].
   528     ].
   528     ^ nil
   529     ^ nil
   529 !
   530 !
   530 
   531 
   531 helpKey:aKey
   532 helpKey:aKey
   532     "sets the help key into the selection channel in order to show the help text"
   533     "sets the help key into the selection channel in order to show the help text"
   533 
   534 
   534     |key|
   535     |key|
       
   536 
   535     aKey size ~~ 0 ifTrue:[
   537     aKey size ~~ 0 ifTrue:[
   536         key := aKey asString
   538         aKey isSymbol ifTrue:[
   537     ].
   539             key := aKey
   538     self listModel value:key
   540         ] ifFalse:[
   539 
   541             key := aKey withoutSeparators.
       
   542             key notEmpty ifTrue:[ key := key asSymbol ]
       
   543                         ifFalse:[ key := nil ].
       
   544         ]
       
   545     ] ifFalse:[
       
   546         key := nil
       
   547     ].
       
   548     editModel value:key.            
       
   549     self cancel.
   540 !
   550 !
   541 
   551 
   542 modified
   552 modified
   543     "returns whether the help tool was modified"
   553     "true if the helpSpec is modified, items are added, deleted or modified
   544 
   554     "
   545     ^modified
   555     ^ modified
   546 !
   556 !
   547 
   557 
   548 modified: aBoolean
   558 modified: aBoolean
   549     "sets the help tool as modified"
   559     "true if the helpSpec is modified, items are added, deleted or modified
   550 
   560     "
   551     modified := aBoolean
   561     modified := aBoolean.
   552 !
   562 !
   553 
   563 
   554 modifiedHolder:aValueHolder
   564 modifiedHolder:aValueHolder
   555     "sets the value holder to true in case of modifying attributes"
   565     "sets the value holder to true in case of modifying attributes"
   556 
   566 
   557     |eTxtView modChannel|
       
   558 
       
   559     modifiedHolder notNil ifTrue:[
   567     modifiedHolder notNil ifTrue:[
   560         modifiedHolder removeDependent:self. 
   568         modifiedHolder removeDependent:self. 
   561     ].
   569     ].
   562 
   570     modifiedHolder := aValueHolder.
   563     (modifiedHolder := aValueHolder) notNil ifTrue:[
   571 
       
   572     modifiedHolder notNil ifTrue:[
   564         modifiedHolder addDependent:self.
   573         modifiedHolder addDependent:self.
   565 
       
   566         (eTxtView := self editTextView) notNil ifTrue: [
       
   567             modChannel := eTxtView modifiedChannel.
       
   568             modChannel onChangeEvaluate:[
       
   569                 modifiedHolder notNil ifTrue:[
       
   570                     modChannel value ifTrue:[
       
   571                         modifiedHolder value:true
       
   572                     ]
       
   573                 ]
       
   574             ]
       
   575         ]
       
   576     ]
   574     ]
   577 
       
   578     "Modified: / 16.7.1998 / 18:12:09 / cg"
       
   579 !
   575 !
   580 
   576 
   581 setHelpKey:aKey
   577 setHelpKey:aKey
   582     "set the helpKey without notification
   578     "set the helpKey without notification
   583     "
   579     "
   588     self helpKey:aKey.
   584     self helpKey:aKey.
   589     modifiedHolder := model.
   585     modifiedHolder := model.
   590 !
   586 !
   591 
   587 
   592 specClass
   588 specClass
   593     "returns the class on which the help tool works"
   589     "returns the class on which the help tool works
   594 
   590     "
   595     ^specClass
   591     ^ specClass
       
   592 !
       
   593 
       
   594 specSelector
       
   595     "returns the selector on which the class is opened
       
   596     "
       
   597     ^ specSelector
   596 ! !
   598 ! !
   597 
   599 
   598 !UIHelpTool methodsFor:'aspects'!
   600 !UIHelpTool methodsFor:'aspects'!
   599 
   601 
   600 listChannel
   602 contentsModifiedChannel
   601     "returns the value holder of the help texts"
   603     "returns the model which indicates whether the current helpText is modified
   602 
   604     "
   603     |holder|
   605     ^ contentsModifiedChannel
   604     (holder := builder bindingAt:#listChannel) isNil ifTrue:[
   606 !
   605         builder aspectAt:#listChannel put:(holder :=  OrderedCollection new asValue).
   607 
   606     ].
   608 editModel
   607     ^ holder
   609     "returns the model which keeps the current editing key
   608 !
   610     "
   609 
   611     ^ editModel
   610 listModel
   612 !
   611     "returns the value holder of the help key"
   613 
   612 
   614 listOfClasses
   613     |holder|
   615     "returns the list which keeps the classes
   614     (holder := builder bindingAt:#listModel) isNil ifTrue:[
   616     "
   615         holder := AspectAdaptor new subject:self; forAspect:#listSelection.
   617     ^ listOfClasses
   616         builder aspectAt:#listModel put:holder.
   618 !
   617     ].
   619 
   618     ^ holder
   620 listOfClassesModel
   619 !
   621     "returns the model which keeps the current class selection
   620 
   622      or nil
   621 listOfHelpSpecClasses
   623     "
   622     "returns the value holder of the specClass and its superclasses 
   624     ^ listOfClassesModel
   623      which are subclasses of ApplicationModel"
   625 !
   624 
   626 
   625     ^ builder listAspectFor:#listOfHelpSpecClasses
   627 listOfKeys
   626 
   628     "returns the list which keeps the current keys
   627 !
   629     "
   628 
   630     ^ listOfKeys
   629 selectionOfHelpSpecClass
   631 !
   630     "returns the value holder of the selected help spec class"
   632 
   631 
   633 listOfKeysModel
   632     |holder|
   634     "returns the model which keeps the current list selection
   633     (holder := builder bindingAt:#selectionOfHelpSpecClass) isNil ifTrue:[
   635      or nil
   634         builder aspectAt:#selectionOfHelpSpecClass put: (holder := ValueHolder new)
   636     "
   635     ].
   637     ^ listOfKeysModel
   636     ^ holder
       
   637 
       
   638 !
   638 !
   639 
   639 
   640 valueOfInfoLabel
   640 valueOfInfoLabel
   641 
   641 
   642     masterApplication notNil ifTrue:[
   642     masterApplication notNil ifTrue:[
   649 
   649 
   650 buildFromClass:aClass
   650 buildFromClass:aClass
   651     "reads the help dictionary from aClass and find remaining classes 
   651     "reads the help dictionary from aClass and find remaining classes 
   652      'between' aClass and ApplicationModel" 
   652      'between' aClass and ApplicationModel" 
   653 
   653 
   654     modified := false.
   654     |list|
   655     specClass  := self getHelpSpecClassFromClass:aClass.
   655 
   656     self rebuild.
   656     modified  := false.
       
   657     specClass := self getHelpSpecClassFromClass:aClass.
       
   658 
       
   659     specClass notNil ifTrue:[   
       
   660         dictionary   := Dictionary new.
       
   661         dictionaries removeAll.
       
   662     ].
       
   663 
       
   664     (specClass isClass and:[specClass isLoaded]) ifFalse:[
       
   665         self updateList.
       
   666         ^ self
       
   667     ].
       
   668     (specClass class includesSelector:specSelector) ifFalse:[
       
   669         dictionaries at:(specClass name) put:dictionary. 
       
   670     ].
       
   671     list := specClass withAllSuperclasses reverse collect:[:cls| cls name ].
       
   672 
       
   673     (list includes: #ApplicationModel) ifTrue:[
       
   674         list := list asOrderedCollection.
       
   675         list removeAll:(ApplicationModel withAllSuperclasses collect:[:cls| cls name])
       
   676     ].
       
   677     listOfClasses contents:list.
       
   678     listOfClassesModel triggerValue:(specClass name).
   657 !
   679 !
   658 
   680 
   659 buildFromClass: aClass andSelector: aSelector
   681 buildFromClass: aClass andSelector: aSelector
   660     "sets aSelector and reads the help dictionary from aClass"
   682     "sets aSelector and reads the help dictionary from aClass"
   661 
   683 
   662     specSelector := aSelector.
   684     specSelector := aSelector.
   663     self buildFromClass:aClass
   685     self buildFromClass:aClass
   664 
   686 
   665 !
   687 !
   666 
   688 
   667 rebuild
   689 buildFromHelpTool:aHelpTool
   668     "reads the help dictionary from aClass and find remaining classes 
   690 
   669      'between' aClass and ApplicationModel" 
   691     self doNew.
   670 
   692 
   671     |list listOfHelpSpecClassesView|
   693     dictionaries := aHelpTool dictionaries.
   672 
   694     dictionary   := aHelpTool dictionary.
   673     specClass notNil ifTrue:[   
   695 
   674         dictionary   := Dictionary new.
   696     specSelector := aHelpTool specSelector.
   675         dictionaries := Dictionary new.
   697     specClass    := aHelpTool specClass.
   676     ].
   698 
   677 
   699     listOfClasses contents:(aHelpTool listOfClasses).
   678     (specClass isClass and: [specClass isLoaded])
   700     listOfClassesModel triggerValue:(listOfClasses at:1 ifAbsent:nil).
   679     ifTrue: 
   701 ! !
   680     [                                               
   702 
   681         (specClass class includesSelector:specSelector) ifFalse:[
   703 !UIHelpTool methodsFor:'change & update'!
   682             dictionaries at: specClass name put: dictionary 
   704 
       
   705 editModelChanged
       
   706     "called if the edit model changed
       
   707     "
       
   708     |key|
       
   709 
       
   710     key := self helpKey.
       
   711     modifiedHolder notNil ifTrue:[ modifiedHolder value:true ].
       
   712 
       
   713     (key notNil and:[(dictionary at:key ifAbsent:nil) isNil]) ifTrue:[
       
   714         listOfClasses do:[:name| |dir|
       
   715             dir := self dictionaryForClassNamed:name.
       
   716 
       
   717             (dir includesKey:key) ifTrue:[
       
   718                 "/ setup new class
       
   719                 listOfKeysModel setValue:key.
       
   720                 listOfClassesModel value:name.
       
   721                 ^ self
       
   722             ].
   683         ].
   723         ].
   684         list := self listOfHelpSpecClasses.
   724         key := nil.
   685 
   725     ].
   686         list contents:  (specClass withAllSuperclasses reverse collect: [:cls| cls name]).
   726     listOfKeysModel value:key.
   687         (list includes: #ApplicationModel)
   727 !
   688             ifTrue: [list removeAll: (ApplicationModel withAllSuperclasses collect: [:cls| cls name])].
   728 
   689         self selectionOfHelpSpecClass value: specClass name.  
   729 listOfClassesModelChanged
   690 
   730     "called if the class selection changed
   691         listOfHelpSpecClassesView := self componentAt: #listOfHelpSpecClassesView.
   731     "
   692         listOfHelpSpecClassesView notNil ifTrue:[
   732     |clsName|
   693             listOfHelpSpecClassesView selection: 
   733 
   694                     (list value indexOf: specClass name).
   734     clsName := listOfClassesModel value.
       
   735     clsName isNil ifTrue:[^ self].
       
   736 
       
   737     dictionary := self dictionaryForClassNamed:clsName.
       
   738     self updateList.
       
   739 !
       
   740 
       
   741 listOfKeysModelChanged
       
   742     "called if the selection of the key list changed
       
   743     "
       
   744     |key txt|
       
   745 
       
   746     key := listOfKeysModel value.
       
   747 
       
   748     key notNil ifTrue:[
       
   749         key := key asSymbol.
       
   750         txt := dictionary at:key ifAbsent:nil.
       
   751 
       
   752         txt isNil ifTrue:[
       
   753             listOfKeysModel value:nil.
       
   754             ^ self
   695         ].
   755         ].
   696         self helpSpecClassSelected.
   756         editModel value ~= key ifTrue:[
   697     ].
   757             editModel value:key withoutNotifying:self.
   698 
   758             modifiedHolder notNil ifTrue:[ modifiedHolder value:true ].
   699     self updateList
       
   700 ! !
       
   701 
       
   702 !UIHelpTool methodsFor:'callbacks'!
       
   703 
       
   704 helpSpecClassSelected
       
   705     "extracts the help dictionary from the selected class and make it current"
       
   706 
       
   707     |clsName listOfHelpKeysView newSelection|
       
   708 
       
   709     clsName := self selectionOfHelpSpecClass value.
       
   710 
       
   711     dictionary := self dictionaryForClassNamed:clsName.
       
   712 
       
   713     self updateList.
       
   714 
       
   715     listSelection notNil ifTrue: [
       
   716         listOfHelpKeysView := self componentAt: #listOfHelpKeysView.
       
   717 
       
   718         (dictionary keys includes: listSelection asSymbol)
       
   719         ifTrue: [
       
   720             newSelection := 
       
   721                  (self listChannel value indexOf: (self componentAt: #helpKeyInputField) contents)
       
   722         ] ifFalse: [
       
   723             newSelection := nil
       
   724         ].
   759         ].
   725 
   760     ].
   726         listOfHelpKeysView selection:newSelection.
   761 
   727     ].
   762     contentsModifiedChannel value ifFalse:[
   728     listSelection notNil ifTrue: [
   763         self cancel
   729         self editTextView contents: (dictionary at: listSelection asSymbol ifAbsent: '')
   764     ].
   730     ]
   765 !
       
   766 
       
   767 update:something with:aParameter from:changedObject
       
   768     "Invoked when an object that I depend upon sends a change notification."
       
   769 
       
   770     editModel == changedObject ifTrue:[
       
   771         self editModelChanged.
       
   772         ^ self
       
   773     ].
       
   774 
       
   775     listOfKeysModel == changedObject ifTrue:[
       
   776         self listOfKeysModelChanged.
       
   777         ^ self
       
   778     ].
       
   779 
       
   780     listOfClassesModel == changedObject ifTrue:[
       
   781         self listOfClassesModelChanged.
       
   782         ^ self
       
   783     ].
       
   784 
       
   785     contentsModifiedChannel == changedObject ifTrue:[
       
   786         contentsModifiedChannel value ifTrue:[
       
   787             modifiedHolder notNil ifTrue:[modifiedHolder value:true].
       
   788         ].
       
   789         ^ self
       
   790     ].
       
   791 
       
   792     super update:something with:aParameter from:changedObject
   731 ! !
   793 ! !
   732 
   794 
   733 !UIHelpTool methodsFor:'help'!
   795 !UIHelpTool methodsFor:'help'!
   734 
       
   735 defaultInfoLabel
       
   736     "returns the default label for the info bar"
       
   737 
       
   738     specClass isClass
       
   739     ifTrue:
       
   740     [
       
   741         (specClass class includesSelector: specSelector)
       
   742         ifFalse: 
       
   743         [
       
   744             ^specSelector isNil 
       
   745                 ifTrue:  [specClass name, ' >> ? (no selector defined)']
       
   746                 ifFalse: [specClass name, ' >> ', specSelector, ' (not implemented)']
       
   747         ].
       
   748         ^specClass name, ' >> ', specSelector
       
   749     ].
       
   750     ^'No class and selector defined.'
       
   751 !
       
   752 
   796 
   753 openDocumentation
   797 openDocumentation
   754     "opens the documentation file of the Help Tool"
   798     "opens the documentation file of the Help Tool"
   755 
   799 
   756     self openHTMLDocument: 'tools/uipainter/HelpTool.html'
   800     self openHTMLDocument: 'tools/uipainter/HelpTool.html'
   759 !UIHelpTool methodsFor:'private'!
   803 !UIHelpTool methodsFor:'private'!
   760 
   804 
   761 askForModification
   805 askForModification
   762     "asks for modification"
   806     "asks for modification"
   763 
   807 
   764     modified
   808     modified ifTrue:[
   765     ifTrue:
   809         ( (YesNoBox title: 'List was modified!!')        
   766     [
   810                    noText:'Cancel';
   767         ((YesNoBox title: 'List was modified!!')        
   811                   yesText:'Waste it and proceed';
   768             noText:'Cancel';
       
   769             yesText:'Waste it and proceed';
       
   770             showAtPointer;
   812             showAtPointer;
   771             accepted) ifFalse: [^false].
   813             accepted
       
   814         ) ifFalse:[
       
   815             ^ false
       
   816         ].
   772         modified := false
   817         modified := false
   773     ].
   818     ].
   774     ^true
   819     ^ true
   775 
       
   776 
       
   777 
       
   778 !
   820 !
   779 
   821 
   780 dictionaryForClassNamed:clsName
   822 dictionaryForClassNamed:clsName
   781     |dictionary|
   823     "returns the directory assigned to a class name
   782 
   824     "
   783     dictionary := dictionaries at:clsName ifAbsent:nil.
   825     ^ dictionaries at:clsName
   784     dictionary isNil ifTrue: [        
   826           ifAbsentPut:[ self extractHelpSpecForClass: (Smalltalk at:clsName) ].
   785         dictionary := dictionaries at:clsName put:(self extractHelpSpecForClass: (Smalltalk at:clsName))
       
   786     ].
       
   787     ^ dictionary
       
   788 !
       
   789 
       
   790 editTextView
       
   791     "returns the editTextView or nil"
       
   792 
       
   793     |view|
       
   794 
       
   795     (view := self componentAt:#helpTextView) notNil ifTrue:[
       
   796         view := view scrolledView.
       
   797 
       
   798         view acceptAction isNil ifTrue:[
       
   799             view acceptAction:[:aList| self accept ].
       
   800         ].
       
   801 
       
   802         view left ~~ 0 ifTrue:[
       
   803             (maxCharsPerLine := view extent x // view font width) < 10 ifTrue:[
       
   804                 maxCharsPerLine := nil
       
   805             ]
       
   806         ].
       
   807     ].       
       
   808     ^ view
       
   809 !
   827 !
   810 
   828 
   811 extractHelpSpecForClass: aClass
   829 extractHelpSpecForClass: aClass
   812     "extracts the help dictionary of aClass, it current and return it"
   830     "extracts the help dictionary of aClass, it current and return it"
   813 
   831 
   814     |helpSpecSuperClass superHelpSpecKeys helpSpec|
   832     |helpSpecSuperClass superHelpSpecKeys helpSpec|
       
   833 
       
   834     helpSpec := Dictionary new.
   815 
   835 
   816     ((aClass class includesSelector: specSelector)
   836     ((aClass class includesSelector: specSelector)
   817     and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class includesSelector: specSelector] ifNone: nil) notNil])
   837     and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class includesSelector: specSelector] ifNone: nil) notNil])
   818     ifTrue:[                  
   838     ifTrue:[                  
   819         superHelpSpecKeys := helpSpecSuperClass helpSpec keys.
   839         superHelpSpecKeys := helpSpecSuperClass helpSpec keys.
   820         helpSpec := Dictionary new.
   840 
   821         aClass helpSpec keysAndValuesDo:[:key :value |
   841         aClass helpSpec keysAndValuesDo:[:key :value |
   822             (superHelpSpecKeys includes:key) ifFalse: [
   842             (superHelpSpecKeys includes:key) ifFalse: [
   823                 helpSpec at:key put:value
   843                 helpSpec at:key put:value
   824             ]
   844             ]
   825         ].          
   845         ].          
   826         ^ dictionary := helpSpec
   846     ].
   827     ].
   847     ^ helpSpec 
   828     ^ dictionary := Dictionary new 
       
   829 !
       
   830 
       
   831 findHelpSpecForKey: aHelpKey
       
   832     "finds the help spec class including aHelpKey in its help dictionary and make it current"
       
   833 
       
   834     |dictTemp listOfHelpSpecClasses|
       
   835 
       
   836     aHelpKey isNil ifTrue: [^nil].
       
   837 
       
   838     dictTemp := dictionary.
       
   839     listOfHelpSpecClasses := self listOfHelpSpecClasses.
       
   840     listOfHelpSpecClasses value do:[:clsName|            
       
   841         dictionary := self dictionaryForClassNamed:clsName.
       
   842         (dictionary includesKey: aHelpKey asSymbol) ifTrue:[            
       
   843             self updateList.
       
   844             ^(self componentAt: #listOfHelpSpecClassesView) selection: 
       
   845                 (listOfHelpSpecClasses value indexOf: clsName).
       
   846         ]
       
   847     ].
       
   848     dictionary := dictTemp
       
   849 !
   848 !
   850 
   849 
   851 getHelpSpecClassFromClass:aClass
   850 getHelpSpecClassFromClass:aClass
   852     "returns application class keeping the associated help text or nil"
   851     "returns application class keeping the associated help text or nil"
   853 
   852 
   965     "saves the help dicts on aClass and its superclasses which are subclasses of ApplicationModel"
   964     "saves the help dicts on aClass and its superclasses which are subclasses of ApplicationModel"
   966 
   965 
   967     |cls helpSpecClasses|
   966     |cls helpSpecClasses|
   968 
   967 
   969     cls := self getHelpSpecClassFromClass:aClass.
   968     cls := self getHelpSpecClassFromClass:aClass.
   970     cls isNil ifTrue: [^self information:'No application class defined!!'].
   969 
       
   970     cls isNil ifTrue: [
       
   971         self information:'No application class defined!!'.
       
   972         ^ self  
       
   973     ].
   971 
   974 
   972     modified ifFalse:[
   975     modified ifFalse:[
   973         masterApplication isNil ifTrue: [self information:'Nothing was modified!!'].
   976         masterApplication isNil ifTrue: [self information:'Nothing was modified!!'].
   974         ^nil
   977         ^ self
   975     ].
   978     ].
   976 
   979     helpSpecClasses := listOfClasses copy.
   977     (helpSpecClasses := self listOfHelpSpecClasses value) notNil
   980 
   978     ifTrue:
   981     helpSpecClasses notEmpty ifTrue:[
   979     [        
       
   980         (helpSpecClasses includes: cls name) ifFalse: [helpSpecClasses add: cls name].
   982         (helpSpecClasses includes: cls name) ifFalse: [helpSpecClasses add: cls name].
   981         helpSpecClasses do: [:clsName| (self installHelpSpecOnClass: clsName) isNil ifTrue: [^modified := false]].
   983 
       
   984         helpSpecClasses do:[:clsName|
       
   985             (self installHelpSpecOnClass: clsName) isNil ifTrue:[
       
   986                 modified := false.
       
   987                 ^ self
       
   988             ]
       
   989         ].
   982     ]
   990     ]
   983     ifFalse:
   991     ifFalse:
   984     [      
   992     [      
   985         self installHelpSpecOnClass: cls
   993         self installHelpSpecOnClass: cls
   986     ].
   994     ].
   987 
   995 
   988     modified := false.
   996     modified := false.
   989 
       
   990 !
   997 !
   991 
   998 
   992 resourceMessage: aString
   999 resourceMessage: aString
   993     "extracts from aString the specClass and the specSelector"
  1000     "extracts from aString the specClass and the specSelector"
   994 
  1001 
  1009     ^false
  1016     ^false
  1010 
  1017 
  1011 !
  1018 !
  1012 
  1019 
  1013 updateList
  1020 updateList
  1014     "updates the list channel from dictionary"
  1021     "updates the list of keys
  1015 
  1022     "
  1016     self listChannel value: dictionary keys asSortedCollection
  1023     |key|
  1017 ! !
  1024 
  1018 
  1025     listOfKeysModel setValue:nil.
  1019 !UIHelpTool methodsFor:'selection'!
  1026     listOfKeys contents:(dictionary keys asSortedCollection).
  1020 
  1027 
  1021 listSelection
  1028     key := self helpKey.
  1022     "returns current selection"
  1029 
  1023 
  1030     (key notNil and:[listOfKeys includes:key]) ifFalse:[
  1024     ^ listSelection
  1031         key := nil.
  1025 !
  1032     ].
  1026 
  1033     listOfKeysModel triggerValue:key
  1027 listSelection:aSelection
       
  1028     "sets current selection"
       
  1029 
       
  1030     |txt view selection|
       
  1031 
       
  1032     aSelection notNil ifTrue:[
       
  1033         aSelection isNumber ifTrue:[
       
  1034             aSelection ~~ 0 ifTrue:[
       
  1035                 selection := self listChannel value at:aSelection ifAbsent:nil
       
  1036             ]
       
  1037         ] ifFalse:[
       
  1038             selection := aSelection withoutSeparators.
       
  1039 
       
  1040             selection size == 0 ifTrue:[
       
  1041                 selection := nil
       
  1042             ]
       
  1043         ]
       
  1044     ].
       
  1045 
       
  1046     selection isNil ifTrue:[
       
  1047         (self componentAt:#listOfHelpKeysView) selection:nil
       
  1048     ] ifFalse:[
       
  1049         (dictionary includesKey:selection asSymbol) ifFalse:[
       
  1050             self findHelpSpecForKey:selection
       
  1051         ]
       
  1052     ].
       
  1053     listSelection == selection ifTrue:[
       
  1054         ^ self
       
  1055     ].
       
  1056     listSelection := selection.
       
  1057 
       
  1058     modifiedHolder notNil ifTrue:[
       
  1059         modifiedHolder value:true.
       
  1060     ].
       
  1061 
       
  1062     (view := self editTextView) notNil ifTrue:[
       
  1063         listSelection notNil ifTrue:[
       
  1064             txt := dictionary at:(listSelection asSymbol) ifAbsent:nil.
       
  1065 
       
  1066             (txt isNil or:[maxCharsPerLine isNil]) ifFalse:[
       
  1067                 txt := UIPainter convertString:(txt asString) maxLineSize:maxCharsPerLine skipLineFeed:false.
       
  1068             ]
       
  1069         ]. 
       
  1070         view contents:txt.
       
  1071         view modified:false.
       
  1072     ]
       
  1073 ! !
  1034 ! !
  1074 
  1035 
  1075 !UIHelpTool methodsFor:'startup / release'!
  1036 !UIHelpTool methodsFor:'startup / release'!
  1076 
  1037 
  1077 closeRequest
  1038 closeRequest
  1088     super initialize.
  1049     super initialize.
  1089 
  1050 
  1090     specSelector := #helpSpec.
  1051     specSelector := #helpSpec.
  1091     dictionary   := Dictionary new.
  1052     dictionary   := Dictionary new.
  1092     dictionaries := Dictionary new.
  1053     dictionaries := Dictionary new.
  1093     modified   := false.
  1054     modified     := false.
  1094 
  1055 
       
  1056     editModel := nil asValue.
       
  1057     editModel addDependent:self.
       
  1058 
       
  1059     listOfKeys   := List new.
       
  1060     listOfKeysModel := nil asValue.
       
  1061     listOfKeysModel addDependent:self.
       
  1062 
       
  1063     listOfClasses := List new.
       
  1064     listOfClassesModel := nil asValue.
       
  1065     listOfClassesModel addDependent:self.
       
  1066 
       
  1067     contentsModifiedChannel := false asValue.
       
  1068     contentsModifiedChannel addDependent:self.
  1095 !
  1069 !
  1096 
  1070 
  1097 loadFromMessage:aString
  1071 loadFromMessage:aString
  1098     "loads a help spec by evaluating aString"
  1072     "loads a help spec by evaluating aString"
  1099 
  1073 
  1134 openOnClass:aClass andSelector: aSelector
  1108 openOnClass:aClass andSelector: aSelector
  1135     "opens the UIHelpTool on aClass and aSelector"
  1109     "opens the UIHelpTool on aClass and aSelector"
  1136 
  1110 
  1137     super openInterface: #windowSpecForStandAlone.
  1111     super openInterface: #windowSpecForStandAlone.
  1138 
  1112 
  1139     self masterApplication isNil ifTrue: [(self componentAt: #RemoveButton) beInvisible].
       
  1140     builder window label: 'Help Tool'.
  1113     builder window label: 'Help Tool'.
  1141     self buildFromClass:aClass andSelector:aSelector
  1114     self buildFromClass:aClass andSelector:aSelector
       
  1115 !
       
  1116 
       
  1117 postBuildTextView:aView
       
  1118 
       
  1119     editTextView := aView scrolledView.
       
  1120     editTextView acceptAction:[:dummy| self accept ].
  1142 ! !
  1121 ! !
  1143 
  1122 
  1144 !UIHelpTool methodsFor:'user actions'!
  1123 !UIHelpTool methodsFor:'user actions'!
  1145 
  1124 
  1146 accept
  1125 accept
  1147     "accepts the help text"
  1126     "accepts the help text"
  1148 
  1127 
  1149     |view key txt list listChgd|   
  1128     |key txt|   
  1150 
  1129 
  1151     (listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[
  1130     contentsModifiedChannel value ifFalse:[^ self].
  1152         txt    := view contents asString.
  1131     contentsModifiedChannel value:false.
  1153         key    := listSelection asSymbol.
  1132 
  1154         list   := self listChannel value.
  1133     key := self helpKey.
  1155 
  1134     key isNil ifTrue:[^ self].
  1156         (listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[
  1135 
  1157             list add:key.
  1136     txt := editTextView contents ? ''.
  1158         ].             
  1137     txt := txt asString.
  1159         dictionary at:key put:txt.
  1138 
  1160 
  1139     dictionary at:key put:txt.
  1161         listChgd ifTrue:[
  1140 
  1162             self updateList.
  1141     listOfKeys detect:[:el| el = key ] ifNone:[ |idx|
  1163             (self componentAt: #listOfHelpKeysView) selection: (list indexOf: key).
  1142         idx := listOfKeys findFirst:[:el| el > key ].
  1164         ]. 
  1143         idx == 0 ifTrue:[ listOfKeys add:key ]
  1165 
  1144                 ifFalse:[ listOfKeys add:key beforeIndex:idx]
       
  1145     ].
       
  1146 
       
  1147     listOfKeysModel value:key withoutNotifying:self.
       
  1148 
       
  1149     modified := true.
       
  1150     modifiedHolder notNil ifTrue:[ modifiedHolder value:true ].
       
  1151 !
       
  1152 
       
  1153 cancel
       
  1154     |key txt|
       
  1155 
       
  1156     editTextView notNil ifTrue:[
       
  1157         key := listOfKeysModel value.
       
  1158 
       
  1159         key notNil ifTrue:[
       
  1160             txt := dictionary at:key ifAbsent:nil.
       
  1161         ] ifFalse:[
       
  1162             txt := nil
       
  1163         ].
       
  1164         editTextView contents:txt.
       
  1165     ].
       
  1166     contentsModifiedChannel value:false.
       
  1167 !
       
  1168 
       
  1169 doDelete
       
  1170     "deletes the selected help key
       
  1171     "
       
  1172     |key|
       
  1173 
       
  1174     key := listOfKeysModel value.
       
  1175 
       
  1176     key isNil ifTrue:[
       
  1177         self warn:'No key selected !!'.
       
  1178         ^ self
       
  1179     ].
       
  1180 
       
  1181     listOfKeysModel value:nil.
       
  1182 
       
  1183     key := key asSymbol.
       
  1184     listOfKeys remove:key ifAbsent:nil.
       
  1185 
       
  1186     (dictionary removeKey:key ifAbsent:nil) notNil ifTrue:[
  1166         modified := true.
  1187         modified := true.
  1167         modifiedHolder notNil ifTrue: [modifiedHolder value:true]
  1188         modifiedHolder notNil ifTrue: [modifiedHolder value:true].
  1168     ]
  1189     ].
  1169 !
       
  1170 
       
  1171 doAdd
       
  1172     "adds a help key"
       
  1173 
       
  1174     |helpKey|
       
  1175     (helpKey := (self componentAt: #helpKeyInputField asSymbol) contents) size > 0
       
  1176     ifTrue:
       
  1177     [
       
  1178         self listModel value: helpKey.
       
  1179         self accept
       
  1180     ]
       
  1181     ifFalse:
       
  1182     [
       
  1183         self warn:'No key was entered !!'
       
  1184     ]
       
  1185 
       
  1186     "Modified: / 20.5.1998 / 01:15:06 / cg"
       
  1187 !
       
  1188 
       
  1189 doDelete
       
  1190     "deletes the selected help key"
       
  1191 
       
  1192     listSelection notNil
       
  1193     ifTrue:
       
  1194     [
       
  1195         dictionary removeKey: listSelection asSymbol ifAbsent: nil.
       
  1196         self doRemove.
       
  1197         self updateList.
       
  1198         modified := true.
       
  1199         modifiedHolder notNil ifTrue: [modifiedHolder value:true]
       
  1200     ]
       
  1201     ifFalse:
       
  1202     [
       
  1203         self warn:'No key selected !!'
       
  1204     ]
       
  1205 
       
  1206     "Modified: / 20.5.1998 / 01:15:00 / cg"
       
  1207 !
  1190 !
  1208 
  1191 
  1209 doLoad
  1192 doLoad
  1210     "opens a Resource Selection Browser in order to get a resource message"
  1193     "opens a Resource Selection Browser in order to get a resource message"
  1211 
  1194 
  1222 !
  1205 !
  1223 
  1206 
  1224 doNew
  1207 doNew
  1225     "resets the help tool"
  1208     "resets the help tool"
  1226 
  1209 
  1227     specClass := listSelection := nil.
  1210     specClass := nil.
  1228     self dictionary: nil.
  1211 
  1229     self dictionaries: nil.
  1212     editModel          value:nil withoutNotifying:self.
  1230     self listOfHelpSpecClasses removeAll.
  1213     listOfKeysModel    value:nil.
  1231     modified := false.
  1214     listOfClassesModel value:nil.
  1232 !
  1215 
  1233 
  1216     listOfKeys    removeAll.
  1234 doReload
  1217     listOfClasses removeAll.
  1235     "reloads the help dictionaries"
  1218     dictionaries  removeAll.
  1236 
  1219 
  1237     |oldSel model|
  1220     dictionary   := Dictionary new.
  1238 
  1221     modified     := false.
  1239     model  := self listModel.
       
  1240     oldSel := model value.
       
  1241     model value:nil.
       
  1242     self helpSpecFrom:specClass.
       
  1243     model value:oldSel.
       
  1244     modified := false.
       
  1245 
       
  1246 !
       
  1247 
       
  1248 doRemove
       
  1249     "removes the selected help key"
       
  1250 
       
  1251     listSelection notNil
       
  1252     ifTrue:
       
  1253     [
       
  1254         self listModel value: nil.
       
  1255         self updateList.
       
  1256         modifiedHolder notNil ifTrue: [modifiedHolder value:true]
       
  1257     ]
       
  1258     ifFalse:
       
  1259     [
       
  1260         self warn:'No key selected !!'
       
  1261     ]
       
  1262 
       
  1263     "Modified: / 20.5.1998 / 01:15:11 / cg"
       
  1264 !
  1222 !
  1265 
  1223 
  1266 doSave
  1224 doSave
  1267     "saves the help dictionaries on specClass"
  1225     "saves the help dictionaries on specClass"
  1268 
  1226 
  1269     self installHelpSpecsOnClass:specClass
  1227     self installHelpSpecsOnClass:specClass
  1270 !
       
  1271 
       
  1272 doUpdate
       
  1273     "reread the helpspecs and update my lists"
       
  1274 
       
  1275     specClass isNil ifTrue:[
       
  1276         ^ self warn:'No spec loaded'.
       
  1277     ].
       
  1278 
       
  1279     (self askForModification) ifTrue:[
       
  1280         self rebuild
       
  1281     ]
       
  1282 ! !
  1228 ! !
  1283 
  1229 
  1284 !UIHelpTool class methodsFor:'documentation'!
  1230 !UIHelpTool class methodsFor:'documentation'!
  1285 
  1231 
  1286 version
  1232 version