UIHelpTool.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3362 177a52729a22
child 3392 ade42ddd74fe
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

- All source *.st files are now Unicode UTF8 without BOM
Files are in two groups (fileOut works this way in Smalltalk/X):
- containing a unicode character have "{ Encoding: utf8 }" at the header
- ASCII only are without the header
cg@156
     1
"
cg@156
     2
 COPYRIGHT (c) 1995 by eXept Software AG
ca@1669
     3
	      All Rights Reserved
cg@156
     4
cg@156
     5
 This software is furnished under a license and may be used
cg@156
     6
 only in accordance with the terms of that license and with the
cg@156
     7
 inclusion of the above copyright notice.   This software may not
cg@156
     8
 be provided or otherwise made available to, or used by, any
cg@156
     9
 other person.  No title to or ownership of the software is
cg@156
    10
 hereby transferred.
cg@156
    11
"
cg@1554
    12
"{ Package: 'stx:libtool2' }"
cg@1554
    13
cg@3199
    14
"{ NameSpace: Smalltalk }"
cg@3199
    15
sv@1772
    16
ResourceSpecEditor subclass:#UIHelpTool
sv@1772
    17
	instanceVariableNames:'classItemList classItemModel keyItemModel helpTextView
sv@1772
    18
		modifiedHolder contentsModifiedChannel editModel'
ca@148
    19
	classVariableNames:''
ca@148
    20
	poolDictionaries:''
ca@148
    21
	category:'Interface-UIPainter'
ca@148
    22
!
ca@148
    23
ca@1669
    24
HierarchicalItem subclass:#ClassItem
ca@1669
    25
	instanceVariableNames:'theClass list modified'
ca@1669
    26
	classVariableNames:''
ca@1669
    27
	poolDictionaries:''
ca@1669
    28
	privateIn:UIHelpTool
ca@1669
    29
!
ca@1669
    30
ca@1669
    31
HierarchicalItem subclass:#KeyItem
cg@1681
    32
	instanceVariableNames:'helpKey helpText flyByText modified icon'
ca@1669
    33
	classVariableNames:''
ca@1669
    34
	poolDictionaries:''
ca@1669
    35
	privateIn:UIHelpTool
ca@1669
    36
!
ca@1669
    37
ca@148
    38
!UIHelpTool class methodsFor:'documentation'!
ca@148
    39
cg@156
    40
copyright
cg@156
    41
"
cg@156
    42
 COPYRIGHT (c) 1995 by eXept Software AG
ca@1669
    43
	      All Rights Reserved
cg@156
    44
cg@156
    45
 This software is furnished under a license and may be used
cg@156
    46
 only in accordance with the terms of that license and with the
cg@156
    47
 inclusion of the above copyright notice.   This software may not
cg@156
    48
 be provided or otherwise made available to, or used by, any
cg@156
    49
 other person.  No title to or ownership of the software is
cg@156
    50
 hereby transferred.
cg@156
    51
"
cg@156
    52
!
cg@156
    53
ca@148
    54
documentation
ca@148
    55
"
tz@779
    56
    The Help Tool allows you to define help dictionaries for the widgets in
tz@761
    57
    window applications. The tool are able to run stand alone or in other master 
tz@740
    58
    applications like the GUI Painter and the Menu Editor.
tz@740
    59
    If the application responds to the selector #showHelp:aHelpText for:aView,
tz@740
    60
    this selector is called by the widget's view when the mouse cursor moves over. 
tz@740
    61
    If the application does not responds to that selector, and the activeHelp mode
tz@740
    62
    is enabled, an active help bubble is shown at the widget's view.
cg@156
    63
tz@779
    64
    [instance variables:]
ca@1669
    65
	specClass       <Symbol>        class implementing the help spec
ca@1669
    66
	specSelector    <Symbol>        selector returning the help spec
ca@1669
    67
	classItemList                   the list of classItems
ca@1669
    68
	classItemModel                  keeps the selected class
ca@1669
    69
	keyItemModel                    keeps the selected helpKey
ca@1669
    70
	modifiedHolder  <ValueHolder>   true if the editField or contents changed
ca@1669
    71
	editModel                       keeps the current helpKey
ca@1669
    72
	helpTextView                    the view which shows the helpText
ca@1669
    73
	contentsModifiedChannel         true if the helpText is modified
tz@779
    74
cg@156
    75
    [author:]
ca@1669
    76
	Claus Atzkern, eXept Software AG
ca@1669
    77
	Thomas Zwick,  eXept Software AG
ca@148
    78
"
ca@148
    79
! !
ca@148
    80
ca@286
    81
!UIHelpTool class methodsFor:'instance creation'!
ca@286
    82
cg@832
    83
open
cg@833
    84
    ^ self openOnClass:nil.
cg@832
    85
!
cg@832
    86
ca@286
    87
openOnClass:aClass
ca@1669
    88
    "opens a Help Tool on aClass
ca@1669
    89
    "
ca@1646
    90
    ^ self openOnClass:aClass andSelector:#helpSpec
tz@750
    91
! !
tz@750
    92
ca@286
    93
!UIHelpTool class methodsFor:'constants'!
ca@286
    94
ca@286
    95
label
ca@1669
    96
    "returns the label; used if embedded as sub canvas in the GUI Painter or Menu Editor
ca@1669
    97
    "
tz@696
    98
    ^'Help'
ca@286
    99
! !
ca@286
   100
sv@1772
   101
!UIHelpTool class methodsFor:'defaults'!
sv@1772
   102
sv@1772
   103
resourceType
sv@1772
   104
    "get the type of the resource of the method generated by the UIHelpTool"
sv@1772
   105
sv@1772
   106
    ^ #help
sv@1772
   107
! !
sv@1772
   108
ca@151
   109
!UIHelpTool class methodsFor:'help specs'!
ca@151
   110
cg@3291
   111
flyByHelpSpec
tz@740
   112
    "This resource specification was automatically generated
tz@740
   113
     by the UIHelpTool of ST/X."
tz@740
   114
tz@740
   115
    "Do not manually edit this!! If it is corrupted,
tz@740
   116
     the UIHelpTool may not be able to read the specification."
ca@292
   117
ca@172
   118
    "
tz@740
   119
     UIHelpTool openOnClass:UIHelpTool    
ca@292
   120
    "
ca@292
   121
tz@740
   122
    <resource: #help>
tz@740
   123
cg@3291
   124
    ^ super flyByHelpSpec addPairsFrom:#(
ca@151
   125
tz@696
   126
#addHelpTextKey
cg@1340
   127
'Adds the key to the help spec.'
tz@696
   128
tz@696
   129
#currentHelpTexts
tz@696
   130
'Selected help text key.'
tz@696
   131
tz@696
   132
#deleteHelpTextKey
cg@1340
   133
'Deletes the key from the help spec.'
cg@1340
   134
tz@750
   135
#fileLoad
tz@750
   136
'Opens a dialog for selecting and loading a help spec from a class.'
tz@750
   137
tz@750
   138
#fileSave
cg@1340
   139
'Saves the current help spec.'
cg@1340
   140
cg@1340
   141
#fileUpdate
cg@1340
   142
'Reload the help spec.'
tz@696
   143
tz@696
   144
#helpTextView
sv@1622
   145
'Shows the help text. Menu action ''Accept'' commits changes'
tz@696
   146
ca@1646
   147
#listOfClasses
cg@1340
   148
'Classes where help specs can be/are implemented.'
tz@696
   149
tz@696
   150
#listOfHelpTexts
cg@1340
   151
'List of help text keys.'
tz@696
   152
tz@696
   153
#removeHelpTextKey
cg@1340
   154
'Removes the help message from the widget.'
ca@151
   155
ca@1646
   156
#updateHelpTextKey
ca@1646
   157
'Refetch the help spec.'
ca@1646
   158
ca@172
   159
)
ca@151
   160
! !
ca@151
   161
ca@148
   162
!UIHelpTool class methodsFor:'interface specs'!
ca@148
   163
cg@1982
   164
innerSpec
tz@740
   165
    "This resource specification was automatically generated
tz@740
   166
     by the UIPainter of ST/X."
ca@148
   167
tz@740
   168
    "Do not manually edit this!! If it is corrupted,
tz@740
   169
     the UIPainter may not be able to read the specification."
ca@148
   170
ca@148
   171
    "
cg@1982
   172
     UIPainter new openOnClass:UIHelpTool andSelector:#innerSpec
cg@1982
   173
     UIHelpTool new openInterface:#innerSpec
ca@148
   174
    "
ca@148
   175
ca@148
   176
    <resource: #canvas>
ca@148
   177
ca@1302
   178
    ^ 
sv@1737
   179
     #(FullSpec
cg@1982
   180
        name: innerSpec
sv@1737
   181
        window: 
sv@1737
   182
       (WindowSpec
sv@1737
   183
          label: 'UIHelpTool'
sv@1737
   184
          name: 'UIHelpTool'
sv@1737
   185
          min: (Point 10 10)
cg@1973
   186
          bounds: (Rectangle 0 0 461 293)
sv@1737
   187
        )
sv@1737
   188
        component: 
sv@1737
   189
       (SpecCollection
sv@1737
   190
          collection: (
sv@1737
   191
           (VariableVerticalPanelSpec
sv@1737
   192
              name: 'PanelVrt'
sv@1737
   193
              layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
sv@1737
   194
              component: 
sv@1737
   195
             (SpecCollection
sv@1737
   196
                collection: (
sv@1737
   197
                 (VariableHorizontalPanelSpec
sv@1737
   198
                    name: 'PanelHrz'
sv@1737
   199
                    component: 
sv@1737
   200
                   (SpecCollection
sv@1737
   201
                      collection: (
sv@1737
   202
                       (HierarchicalListViewSpec
sv@1737
   203
                          name: 'keyItemModel'
sv@1737
   204
                          model: keyItemModel
sv@1737
   205
                          menu: keyItemMenu
sv@1737
   206
                          hasHorizontalScrollBar: true
sv@1737
   207
                          hasVerticalScrollBar: true
sv@1737
   208
                          miniScrollerHorizontal: true
sv@1737
   209
                          miniScrollerVertical: false
sv@1737
   210
                          listModel: keyItemListHolder
sv@1737
   211
                          useIndex: false
sv@1737
   212
                          highlightMode: label
sv@1737
   213
                          showLines: false
sv@1737
   214
                          showIndicators: false
sv@1737
   215
                          showLeftIndicators: false
sv@1737
   216
                          useDefaultIcons: false
sv@1737
   217
                          autoScrollHorizontal: false
sv@1737
   218
                        )
sv@1737
   219
                       (ViewSpec
sv@1737
   220
                          name: 'classItemList'
sv@1737
   221
                          component: 
sv@1737
   222
                         (SpecCollection
sv@1737
   223
                            collection: (
sv@1737
   224
                             (InputFieldSpec
sv@1737
   225
                                name: 'editModel'
sv@1737
   226
                                layout: (LayoutFrame 0 0.0 2 0 -1 1.0 25 0)
sv@1737
   227
                                activeHelpKey: currentHelpTexts
sv@1737
   228
                                model: editModel
sv@1737
   229
                                immediateAccept: true
sv@1737
   230
                                acceptOnReturn: false
sv@1737
   231
                                acceptOnTab: false
sv@1737
   232
                                acceptOnLostFocus: false
sv@1737
   233
                                acceptOnPointerLeave: false
sv@1737
   234
                              )
sv@1737
   235
                             (SelectionInListModelViewSpec
sv@1737
   236
                                name: 'classItemModel'
sv@1737
   237
                                layout: (LayoutFrame 0 0.0 27 0.0 0 1.0 0 1.0)
sv@1737
   238
                                model: classItemModel
sv@1737
   239
                                hasHorizontalScrollBar: true
sv@1737
   240
                                hasVerticalScrollBar: true
sv@1737
   241
                                miniScrollerHorizontal: true
sv@1737
   242
                                miniScrollerVertical: true
sv@1737
   243
                                autoHideScrollBars: false
sv@1737
   244
                                listModel: classItemListHolder
sv@1737
   245
                                useIndex: false
sv@1737
   246
                                highlightMode: label
sv@1737
   247
                              )
sv@1737
   248
                             )
ca@1646
   249
                           
sv@1737
   250
                          )
sv@1737
   251
                        )
sv@1737
   252
                       )
ca@1646
   253
                     
sv@1737
   254
                    )
sv@1737
   255
                    handles: (Any 0.607375 1.0)
sv@1737
   256
                  )
sv@1737
   257
                 (ArbitraryComponentSpec
sv@1737
   258
                    name: 'helpTextView'
sv@1737
   259
                    hasHorizontalScrollBar: true
sv@1737
   260
                    hasVerticalScrollBar: true
sv@1737
   261
                    miniScrollerHorizontal: true
sv@1737
   262
                    miniScrollerVertical: true
sv@1737
   263
                    hasBorder: false
sv@1737
   264
                    component: helpTextView
sv@1737
   265
                  )
sv@1737
   266
                 )
ca@1302
   267
               
sv@1737
   268
              )
sv@1737
   269
              handles: (Any 0.679181 1.0)
sv@1737
   270
            )
sv@1737
   271
           )
ca@1302
   272
         
sv@1737
   273
        )
ca@148
   274
      )
tz@696
   275
!
tz@696
   276
cg@1982
   277
windowSpec
tz@740
   278
    "This resource specification was automatically generated
tz@740
   279
     by the UIPainter of ST/X."
tz@696
   280
tz@740
   281
    "Do not manually edit this!! If it is corrupted,
tz@740
   282
     the UIPainter may not be able to read the specification."
tz@696
   283
tz@696
   284
    "
cg@1982
   285
     UIPainter new openOnClass:UIHelpTool andSelector:#windowSpec
cg@1982
   286
     UIHelpTool new openInterface:#windowSpec
cg@1982
   287
     UIHelpTool open
tz@696
   288
    "
tz@696
   289
tz@696
   290
    <resource: #canvas>
tz@696
   291
ca@1646
   292
    ^ 
cg@3291
   293
    #(FullSpec
cg@3291
   294
       name: windowSpec
cg@3291
   295
       window: 
cg@3291
   296
      (WindowSpec
cg@3291
   297
         label: 'Help Tool'
cg@3291
   298
         name: 'Help Tool'
cg@3291
   299
         min: (Point 300 300)
cg@3291
   300
         bounds: (Rectangle 0 0 498 429)
cg@3291
   301
         menu: menu
cg@3291
   302
       )
cg@3291
   303
       component: 
cg@3291
   304
      (SpecCollection
cg@3291
   305
         collection: (
cg@3291
   306
          (ViewSpec
cg@3291
   307
             name: 'mainPanel'
cg@3291
   308
             layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -24 1.0)
cg@3291
   309
             component: 
cg@3291
   310
            (SpecCollection
cg@3291
   311
               collection: (
cg@3291
   312
                (UISubSpecification
cg@3291
   313
                   name: 'innerSpec'
cg@3291
   314
                   layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 -24 1.0)
cg@3291
   315
                   minorKey: innerSpec
cg@2002
   316
                 )
cg@3291
   317
                (UISubSpecification
cg@3291
   318
                   name: 'windowSpecForCommit'
cg@3291
   319
                   layout: (LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0)
cg@3291
   320
                   majorKey: ToolApplicationModel
cg@3291
   321
                   minorKey: windowSpecForCommit
cg@3291
   322
                 )
cg@3291
   323
                )
cg@3291
   324
              
cg@3291
   325
             )
sv@1737
   326
           )
cg@3291
   327
          (UISubSpecification
cg@3291
   328
             name: 'infoBarSubSpec'
cg@3291
   329
             layout: (LayoutFrame 0 0 -24 1 0 1 0 1)
cg@3291
   330
             majorKey: ToolApplicationModel
cg@3291
   331
             minorKey: windowSpecForInfoBar
cg@3291
   332
           )
cg@3291
   333
          )
cg@3291
   334
        
cg@3291
   335
       )
cg@3291
   336
     )
tz@696
   337
! !
tz@696
   338
tz@696
   339
!UIHelpTool class methodsFor:'menu specs'!
tz@696
   340
ca@1646
   341
helpTextMenu
ca@1646
   342
    "This resource specification was automatically generated
ca@1646
   343
     by the MenuEditor of ST/X."
ca@1646
   344
ca@1646
   345
    "Do not manually edit this!! If it is corrupted,
ca@1646
   346
     the MenuEditor may not be able to read the specification."
ca@1646
   347
ca@1646
   348
    "
ca@1646
   349
     MenuEditor new openOnClass:UIHelpTool andSelector:#helpTextMenu
ca@1646
   350
     (Menu new fromLiteralArrayEncoding:(UIHelpTool helpTextMenu)) startUp
ca@1646
   351
    "
ca@1646
   352
ca@1646
   353
    <resource: #menu>
ca@1646
   354
ca@1646
   355
    ^ 
ca@1646
   356
     #(#Menu
ca@1669
   357
	#(
ca@1669
   358
	 #(#MenuItem
ca@1669
   359
	    #activeHelpKey: #commitOK
ca@1669
   360
	    #enabled: #contentsModifiedChannel
ca@1669
   361
	    #label: 'Accept'
ca@1669
   362
	    #itemValue: #accept
ca@1669
   363
	    #translateLabel: true
ca@1669
   364
	  )
ca@1669
   365
	 #(#MenuItem
ca@1669
   366
	    #activeHelpKey: #commitCancel
ca@1669
   367
	    #enabled: #contentsModifiedChannel
ca@1669
   368
	    #label: 'Cancel'
ca@1669
   369
	    #itemValue: #cancel
ca@1669
   370
	    #translateLabel: true
ca@1669
   371
	  )
ca@1669
   372
	 )
ca@1669
   373
	nil
ca@1669
   374
	nil
ca@1669
   375
      )
ca@1669
   376
!
ca@1669
   377
ca@1669
   378
keyItemMenu
ca@1669
   379
    "This resource specification was automatically generated
ca@1669
   380
     by the MenuEditor of ST/X."
ca@1669
   381
ca@1669
   382
    "Do not manually edit this!! If it is corrupted,
ca@1669
   383
     the MenuEditor may not be able to read the specification."
ca@1669
   384
ca@1669
   385
    "
ca@1669
   386
     MenuEditor new openOnClass:UIHelpTool andSelector:#keyItemMenu
ca@1669
   387
     (Menu new fromLiteralArrayEncoding:(UIHelpTool keyItemMenu)) startUp
ca@1669
   388
    "
ca@1669
   389
ca@1669
   390
    <resource: #menu>
ca@1669
   391
ca@1669
   392
    ^ 
ca@1669
   393
     #(#Menu
ca@1669
   394
	#(
ca@1669
   395
	 #(#MenuItem
ca@1669
   396
	    #activeHelpKey: #deleteHelpTextKey
ca@1669
   397
	    #label: 'Delete'
ca@1669
   398
	    #itemValue: #doDelete
ca@1669
   399
	    #translateLabel: true
ca@1669
   400
	  )
ca@1669
   401
	 )
ca@1669
   402
	nil
ca@1669
   403
	nil
ca@1646
   404
      )
ca@1646
   405
!
ca@1646
   406
ca@1646
   407
listOfKeysMenu
ca@1646
   408
    "This resource specification was automatically generated
ca@1646
   409
     by the MenuEditor of ST/X."
ca@1646
   410
ca@1646
   411
    "Do not manually edit this!! If it is corrupted,
ca@1646
   412
     the MenuEditor may not be able to read the specification."
ca@1646
   413
ca@1646
   414
    "
ca@1646
   415
     MenuEditor new openOnClass:UIHelpTool andSelector:#listOfKeysMenu
ca@1646
   416
     (Menu new fromLiteralArrayEncoding:(UIHelpTool listOfKeysMenu)) startUp
ca@1646
   417
    "
ca@1646
   418
ca@1646
   419
    <resource: #menu>
ca@1646
   420
ca@1646
   421
    ^ 
ca@1646
   422
     #(#Menu
ca@1669
   423
	#(
ca@1669
   424
	 #(#MenuItem
ca@1669
   425
	    #activeHelpKey: #deleteHelpTextKey
ca@1669
   426
	    #label: 'Delete'
ca@1669
   427
	    #itemValue: #doDelete
ca@1669
   428
	    #translateLabel: true
ca@1669
   429
	  )
ca@1669
   430
	 )
ca@1669
   431
	nil
ca@1669
   432
	nil
ca@1646
   433
      )
ca@1646
   434
!
ca@1646
   435
tz@696
   436
menu
tz@740
   437
    "This resource specification was automatically generated
tz@740
   438
     by the MenuEditor of ST/X."
tz@696
   439
tz@740
   440
    "Do not manually edit this!! If it is corrupted,
tz@740
   441
     the MenuEditor may not be able to read the specification."
tz@696
   442
tz@696
   443
    "
tz@696
   444
     MenuEditor new openOnClass:UIHelpTool andSelector:#menu
tz@696
   445
     (Menu new fromLiteralArrayEncoding:(UIHelpTool menu)) startUp
tz@696
   446
    "
tz@696
   447
tz@696
   448
    <resource: #menu>
tz@696
   449
ca@1646
   450
    ^ 
ca@1775
   451
     #(Menu
ca@1775
   452
        (
ca@1775
   453
         (MenuItem
ca@1775
   454
            label: 'File'
ca@1775
   455
            translateLabel: true
ca@1775
   456
            submenu: 
ca@1775
   457
           (Menu
ca@1775
   458
              (
ca@1775
   459
               (MenuItem
cg@1973
   460
                  label: 'New'
cg@1973
   461
                  itemValue: doNew
cg@1973
   462
                  translateLabel: true
cg@1973
   463
                )
cg@1973
   464
               (MenuItem
cg@1973
   465
                  label: '-'
cg@1973
   466
                )
cg@1973
   467
               (MenuItem
ca@1775
   468
                  activeHelpKey: fileLoad
ca@1775
   469
                  label: 'Load...'
ca@1775
   470
                  itemValue: doLoad
ca@1775
   471
                  translateLabel: true
ca@1775
   472
                )
ca@1775
   473
               (MenuItem
ca@1775
   474
                  activeHelpKey: fileSave
ca@1775
   475
                  label: 'Save'
ca@1775
   476
                  itemValue: doSave
ca@1775
   477
                  translateLabel: true
ca@1775
   478
                )
ca@1775
   479
               (MenuItem
ca@1775
   480
                  label: '-'
cg@1982
   481
                  isVisible: isStandAlone
ca@1775
   482
                )
ca@1775
   483
               (MenuItem
ca@1775
   484
                  activeHelpKey: fileExit
ca@1775
   485
                  label: 'Exit'
ca@1775
   486
                  itemValue: closeRequest
ca@1775
   487
                  translateLabel: true
cg@1982
   488
                  isVisible: isStandAlone
ca@1775
   489
                )
ca@1775
   490
               )
ca@1775
   491
              nil
ca@1775
   492
              nil
ca@1775
   493
            )
ca@1775
   494
          )
ca@1775
   495
         (MenuItem
ca@1775
   496
            label: 'Edit'
ca@1775
   497
            translateLabel: true
ca@1775
   498
            submenuChannel: keyItemMenu
ca@1775
   499
            keepLinkedMenu: true
ca@1775
   500
          )
ca@1775
   501
         (MenuItem
cg@1973
   502
            label: 'History'
cg@1973
   503
            translateLabel: true
cg@1982
   504
            isVisible: isStandAlone
cg@1973
   505
            submenuChannel: menuHistory
cg@1973
   506
          )
cg@1973
   507
         (MenuItem
cg@2665
   508
            label: 'MENU_Help'
ca@1775
   509
            translateLabel: true
cg@2127
   510
            startGroup: conditionalRight
ca@1775
   511
            submenuChannel: menuHelp
ca@1775
   512
          )
ca@1775
   513
         )
ca@1775
   514
        nil
ca@1775
   515
        nil
tz@696
   516
      )
ca@148
   517
! !
ca@148
   518
ca@148
   519
!UIHelpTool methodsFor:'accessing'!
ca@148
   520
cg@3362
   521
alternativeSpecSelectors
cg@3362
   522
    "returns a set of alternative spec method selectors of the resource spec"
cg@3362
   523
cg@3362
   524
    ^ #( flyByHelpSpec tooltipSpec )
cg@3362
   525
!
cg@3362
   526
ca@1669
   527
helpKey
cg@3291
   528
    "returns the helpKey (symbol) or nil
ca@1669
   529
    "
ca@1669
   530
    |key|
tz@779
   531
ca@1669
   532
    key := editModel value.
tz@710
   533
ca@1669
   534
    key size ~~ 0 ifTrue:[
cg@3291
   535
        key := key withoutSeparators.
cg@3291
   536
        key notEmpty ifTrue:[ ^ key asSymbol ]
ca@286
   537
    ].
ca@286
   538
    ^ nil
ca@286
   539
!
ca@286
   540
ca@286
   541
helpKey:aKey
ca@1669
   542
    "change the helpKey without any change notification (modifiedHolder).
ca@1669
   543
    "
ca@286
   544
    |key|
ca@1646
   545
ca@1669
   546
    self withoutModifyDo:[
cg@3030
   547
        aKey size ~~ 0 ifTrue:[
cg@3030
   548
            key := aKey withoutSeparators asNilIfEmpty.
cg@3030
   549
        ] ifFalse:[
cg@3030
   550
            key := nil
cg@3030
   551
        ].
cg@3030
   552
        editModel value:key.
ca@286
   553
    ].
ca@1646
   554
    self cancel.
ca@151
   555
!
ca@151
   556
tz@740
   557
modified
cg@2020
   558
    "true if any items are added, deleted or modified
cg@2020
   559
    "
cg@2020
   560
    classItemList do:[:aClassItem|
cg@2020
   561
	aClassItem modified ifTrue:[^ true].
cg@2020
   562
    ].
cg@2020
   563
    ^ false
tz@700
   564
!
tz@700
   565
ca@1669
   566
modified:aBoolean
ca@1669
   567
    "true if any items are added, deleted or modified
ca@1646
   568
    "
ca@1669
   569
    classItemList do:[:aClassItem| aClassItem modified:aBoolean ].
ca@1669
   570
!
ca@1669
   571
ca@1669
   572
modifiedHolder
ca@1669
   573
    "boolean holder which is set to true if the helpKey or contents changed
ca@1669
   574
    "
ca@1669
   575
    ^ modifiedHolder
tz@700
   576
!
tz@700
   577
ca@286
   578
modifiedHolder:aValueHolder
ca@1669
   579
    "boolean holder which is set to true if the helpKey or contents changed
ca@1669
   580
    "
ca@286
   581
    modifiedHolder notNil ifTrue:[
ca@1669
   582
	modifiedHolder removeDependent:self. 
ca@286
   583
    ].
ca@1646
   584
    modifiedHolder := aValueHolder.
ca@148
   585
ca@1646
   586
    modifiedHolder notNil ifTrue:[
ca@1669
   587
	modifiedHolder addDependent:self.
ca@1669
   588
    ].
ca@1604
   589
!
ca@1604
   590
tz@715
   591
specClass
ca@1669
   592
    "returns the class on which the help tool works on
ca@1646
   593
    "
ca@1646
   594
    ^ specClass
ca@1646
   595
!
tz@779
   596
ca@1646
   597
specSelector
cg@1681
   598
    "returns the selector of the edited helpSpec method
ca@1646
   599
    "
cg@1681
   600
    ^ specSelector ? #helpSpec
cg@354
   601
! !
cg@354
   602
ca@148
   603
!UIHelpTool methodsFor:'aspects'!
ca@148
   604
ca@1669
   605
classItemListHolder
ca@1669
   606
    "returns the holder which keeps the class items
ca@1669
   607
    "
ca@1669
   608
    |holder|
ca@1669
   609
ca@1669
   610
    holder := builder bindingAt:#classItemListHolder.
ca@1669
   611
ca@1669
   612
    holder isNil ifTrue:[
ca@1669
   613
	holder := nil asValue.
ca@1669
   614
	holder value:classItemList.
ca@1669
   615
	builder aspectAt:#classItemListHolder put:holder.
ca@1669
   616
    ].
ca@1669
   617
    ^ holder
ca@1669
   618
!
ca@1669
   619
ca@1669
   620
classItemModel
ca@1669
   621
    "returns the holder which keeps the current selected class
ca@1669
   622
    "
ca@1669
   623
    ^ classItemModel
ca@1669
   624
!
ca@1669
   625
ca@1646
   626
contentsModifiedChannel
ca@1669
   627
    "boolean holder, which is set to true if the contents assigned to the
ca@1669
   628
     helpKey changed
ca@1646
   629
    "
ca@1646
   630
    ^ contentsModifiedChannel
ca@148
   631
!
ca@148
   632
ca@1646
   633
editModel
ca@1669
   634
    "string holder, which keeps the current editing helpKey as string
ca@1646
   635
    "
ca@1669
   636
    ^ editModel.
tz@696
   637
!
tz@696
   638
cg@1989
   639
enablingCommitButtonsHolder
cg@1989
   640
    "returns the enabling of the commit of this tool as value holder"
cg@1989
   641
cg@1989
   642
    masterApplication notNil ifTrue:[
cg@1989
   643
        ^ masterApplication enablingCommitButtonsHolder
cg@1989
   644
    ].
cg@1989
   645
    ^ contentsModifiedChannel
cg@1989
   646
!
cg@1989
   647
ca@1669
   648
helpTextView
cg@3291
   649
    "the editView which shows the current help contents assigned to the key
ca@1646
   650
    "
ca@1669
   651
    ^ helpTextView
tz@696
   652
!
tz@696
   653
cg@1989
   654
infoLabelHolder
cg@1989
   655
    "returns the info label as value holder"
cg@1989
   656
cg@1989
   657
    masterApplication notNil ifTrue:[
cg@2037
   658
        builder aspectAt:#useAlienInfoLabelHolder put:true.
cg@1989
   659
        ^ masterApplication infoLabelHolder
cg@1989
   660
    ].
cg@1989
   661
    ^ super infoLabelHolder
cg@1989
   662
!
cg@1989
   663
ca@1669
   664
keyItemListHolder
ca@1669
   665
    "holder, which keeps the current hierarchical list
ca@1669
   666
     assigned to the selected class item
ca@1646
   667
    "
ca@1669
   668
    |holder|
ca@1669
   669
ca@1669
   670
    holder := builder bindingAt:#keyItemListHolder.
ca@1669
   671
ca@1669
   672
    holder isNil ifTrue:[
ca@1669
   673
	holder := nil asValue.
ca@1669
   674
	holder value:(classItemList last list).
ca@1669
   675
	builder aspectAt:#keyItemListHolder put:holder.
ca@1669
   676
    ].
ca@1669
   677
    ^ holder
ca@1646
   678
!
tz@779
   679
ca@1669
   680
keyItemModel
ca@1669
   681
    "model which keeps the current selected helpKey or nil
ca@1646
   682
    "
ca@1669
   683
    ^ keyItemModel.
ca@148
   684
! !
ca@148
   685
tz@750
   686
!UIHelpTool methodsFor:'building'!
tz@750
   687
ca@1663
   688
buildAndMergeFromClass:aClass
ca@1669
   689
     "setup a new specClass, merge the current items into
ca@1669
   690
     "
ca@1669
   691
     |root mergeItems|
ca@1663
   692
ca@1669
   693
     root := classItemList first.
ca@1663
   694
ca@1669
   695
     root isUnspecified ifTrue:[ mergeItems := root children ]
cg@1973
   696
                       ifFalse:[ mergeItems := nil ].
ca@1663
   697
cg@1973
   698
     self loadFromClass:aClass.
ca@1669
   699
ca@1669
   700
     mergeItems size ~~ 0 ifTrue:[
cg@1973
   701
        root := classItemList first.
ca@1669
   702
cg@1973
   703
        mergeItems do:[:anItem| |item hkey|
cg@1973
   704
            hkey := anItem helpKey.
cg@1973
   705
            item := root detectItemWithKey:hkey.
ca@1669
   706
cg@1973
   707
            item isNil ifTrue:[
cg@1973
   708
                item := KeyItem helpKey:hkey helpText:(anItem helpText).
cg@1973
   709
                root add:item sortBlock:[:a :b| a label < b label ].
cg@1973
   710
            ] ifFalse:[
cg@1973
   711
                item helpText:(anItem helpText).
cg@1973
   712
            ]
cg@1973
   713
        ]
ca@1663
   714
    ].
ca@1663
   715
!
ca@1663
   716
cg@1973
   717
loadFromClass:aClass
tz@779
   718
    "reads the help dictionary from aClass and find remaining classes 
ca@1669
   719
     'between' aClass and ApplicationModel
ca@1669
   720
    " 
cg@3362
   721
    |lastContents root list helpSpecSelector alternativeSelector|
tz@779
   722
cg@2934
   723
    (specClass notNil and:[specClass == aClass]) ifTrue:[
cg@2934
   724
        ^ self.
cg@2934
   725
    ].
cg@2934
   726
cg@1681
   727
    helpSpecSelector := self specSelector.
ca@1646
   728
    specClass := self getHelpSpecClassFromClass:aClass.
ca@1646
   729
cg@3362
   730
    aClass notNil ifTrue:[
cg@3362
   731
        (aClass theMetaclass implements:helpSpecSelector) ifFalse:[
cg@3362
   732
            alternativeSelector := (self alternativeSpecSelectors ? #()) detect:[:sel | aClass theMetaclass implements:sel] ifNone:nil.
cg@3362
   733
            alternativeSelector notNil ifTrue:[
cg@3362
   734
                helpSpecSelector := specSelector := alternativeSelector.
cg@3362
   735
                specClass := aClass.
cg@3362
   736
            ].
cg@3362
   737
        ].
cg@3362
   738
    ].
cg@3362
   739
    
ca@1669
   740
    list := OrderedCollection new.
ca@1669
   741
ca@1669
   742
    (specClass isClass and:[specClass isLoaded]) ifTrue:[
ca@1670
   743
        lastContents := nil.
cg@1973
   744
cg@1973
   745
        self addHistoryEntryForClass:specClass selector:helpSpecSelector.
ca@1669
   746
cg@3199
   747
        specClass withAllSuperclasses reverseDo:[:aClass| |value name|
ca@1670
   748
            lastContents isNil ifTrue:[
ca@1670
   749
                aClass == ApplicationModel ifTrue:[ 
ca@1670
   750
                    lastContents := IdentityDictionary new
ca@1670
   751
                ].
ca@1670
   752
            ] ifFalse:[
ca@1670
   753
                root := ClassItem onClass:aClass.
ca@1669
   754
cg@1973
   755
                (aClass respondsTo: helpSpecSelector) ifTrue:[ 
cg@1973
   756
                    value := aClass perform: helpSpecSelector.
cg@1973
   757
                ].
ca@1669
   758
cg@1973
   759
                value notNil ifTrue:[
cg@3010
   760
                    (value isDictionary) ifTrue:[
cg@2933
   761
                        value keysAndValuesDo:[:k :v| |cval|
cg@2933
   762
                            cval := lastContents at:k ifAbsent:self.
cg@2933
   763
                            cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ].
cg@2933
   764
                        ].
cg@2933
   765
                        lastContents := value.
cg@2933
   766
                    ] ifFalse:[
cg@2933
   767
                        |dict|
cg@2933
   768
                        dict := Dictionary new.
cg@2933
   769
                        value pairWiseDo:[:k :v| |cval|
cg@2933
   770
                            cval := lastContents at:k ifAbsent:self.
cg@2933
   771
                            cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ].
cg@2933
   772
                            dict at:k put:v.
cg@2933
   773
                        ].
cg@2933
   774
                        lastContents := dict.
ca@1670
   775
                    ].
ca@1670
   776
                ].
ca@1670
   777
                root sort:[:a :b| a label < b label ].
ca@1670
   778
                root modified:false.
ca@1670
   779
                list add:root.
ca@1670
   780
            ]
ca@1670
   781
        ]
ca@1669
   782
    ].
ca@1669
   783
    list isEmpty ifTrue:[
ca@1670
   784
        list add:(ClassItem onClass:nil)
ca@1646
   785
    ].
ca@1646
   786
ca@1669
   787
    self withoutModifyDo:[
ca@1670
   788
        classItemList contents:list.
ca@1670
   789
        self updateIcons.
ca@1670
   790
        classItemModel value:(list last)
ca@1646
   791
    ].
cg@1340
   792
!
cg@1340
   793
cg@1973
   794
loadFromClass:aClass andSelector:aSelector
cg@1973
   795
    "reads the help dictionary from aClass"
cg@1973
   796
cg@1973
   797
    self assert:(aClass isNil or:[aClass isClass]).
cg@1973
   798
cg@1340
   799
    specSelector := aSelector.
cg@1973
   800
    self loadFromClass:aClass
cg@1340
   801
!
cg@1340
   802
cg@1973
   803
loadFromHelpTool:aHelpTool
ca@1669
   804
    "build from another helpTool
ca@1669
   805
    "
ca@1669
   806
    specClass     := aHelpTool specClass.
ca@1669
   807
    specSelector  := aHelpTool specSelector.
ca@1669
   808
    classItemList := aHelpTool classItemListHolder value.
cg@1340
   809
ca@1669
   810
    self classItemListHolder value:classItemList.
cg@1340
   811
ca@1669
   812
    classItemModel triggerValue:(classItemList last).
ca@1646
   813
! !
ca@1646
   814
ca@1646
   815
!UIHelpTool methodsFor:'change & update'!
ca@1646
   816
ca@1646
   817
editModelChanged
ca@1669
   818
    "called if the editModel changed
ca@1646
   819
    "
ca@1646
   820
    |key|
ca@1646
   821
ca@1646
   822
    key := self helpKey.
ca@1646
   823
ca@1669
   824
    modifiedHolder notNil ifTrue:[
cg@1989
   825
        modifiedHolder value:true
ca@1669
   826
    ].
ca@1646
   827
ca@1669
   828
    contentsModifiedChannel value:false.
ca@1646
   829
ca@1646
   830
    key notNil ifTrue:[
cg@1989
   831
        keyItemModel value = key ifTrue:[^ self].
ca@1646
   832
cg@1989
   833
        classItemList reverseDo:[:root| |item|
cg@1989
   834
            item := root detectItemWithKey:key.
ca@1669
   835
cg@1989
   836
            item notNil ifTrue:[
cg@1989
   837
                classItemModel value:root.
cg@1989
   838
                keyItemModel   value:item.
cg@1989
   839
                ^ self.
cg@1989
   840
            ].
cg@1989
   841
        ].
ca@1669
   842
cg@1989
   843
        masterApplication isNil ifTrue:[
cg@1989
   844
            "entered a new helpKey
cg@1989
   845
            "
cg@1989
   846
            self enablingCommitButtonsHolder value:true.
cg@1989
   847
        ].
tz@750
   848
    ].
ca@1669
   849
    keyItemModel value:nil.
ca@1646
   850
!
cg@963
   851
ca@1646
   852
update:something with:aParameter from:changedObject
ca@1669
   853
    "Invoked when an object that I depend upon sends a change notification.
ca@1669
   854
    "
ca@1669
   855
    |root item list|
cg@963
   856
ca@1669
   857
    changedObject == keyItemModel ifTrue:[
ca@1669
   858
	item := keyItemModel value.
ca@1669
   859
ca@1669
   860
	item notNil ifTrue:[
ca@1669
   861
	    editModel value:(item helpKey).
ca@1669
   862
	].
ca@1669
   863
	self cancel.
ca@1669
   864
	^ self
tz@750
   865
    ].
tz@750
   866
ca@1669
   867
    changedObject == classItemModel ifTrue:[
ca@1669
   868
	root := classItemModel value.
ca@1669
   869
ca@1669
   870
	root notNil ifTrue:[
ca@1669
   871
	    item := root detectItemWithKey:(self helpKey).
ca@1669
   872
	    list := root list.
ca@1669
   873
	] ifFalse:[
ca@1669
   874
	    list := item := nil.
ca@1669
   875
	].
ca@1669
   876
ca@1669
   877
	item notNil ifTrue:[
ca@1669
   878
	    keyItemModel value:nil withoutNotifying:self.
ca@1669
   879
	].
ca@1669
   880
	self keyItemListHolder value:list.
ca@1669
   881
	keyItemModel value:item.
ca@1669
   882
	^ self
ca@1646
   883
    ].
tz@750
   884
ca@1669
   885
    changedObject == editModel ifTrue:[
ca@1669
   886
	self editModelChanged.
ca@1669
   887
	^ self
ca@1646
   888
    ].
ca@148
   889
ca@1669
   890
    changedObject == contentsModifiedChannel ifTrue:[
ca@1669
   891
	modifiedHolder notNil ifTrue:[
ca@1669
   892
	    modifiedHolder value:true
ca@1669
   893
	].
ca@1669
   894
	^ self
ca@1646
   895
    ].
ca@1669
   896
    super update:something with:aParameter from:changedObject
ca@1669
   897
!
tz@779
   898
ca@1669
   899
withoutModifyDo:aBlock
ca@1669
   900
    "discard modifications; trigger not the modifiedHolder during
sv@1723
   901
     the action is active"
sv@1723
   902
ca@1669
   903
    |holder|
ca@286
   904
sv@1723
   905
    modifiedHolder isNil ifTrue:[
sv@1723
   906
        ^ aBlock value
sv@1723
   907
    ].
ca@1669
   908
    holder := modifiedHolder.
sv@1723
   909
    ^ aBlock ensure:[modifiedHolder := holder]
tz@750
   910
! !
tz@750
   911
ca@286
   912
!UIHelpTool methodsFor:'private'!
ca@286
   913
cg@1973
   914
getHelpSpecClassFromClass:aClass
cg@1973
   915
    |cls|
tz@696
   916
cg@1973
   917
    aClass isNil ifTrue:[^ nil].
tz@779
   918
cg@1973
   919
    cls := self resolveName:aClass.
cg@1973
   920
    cls isNil ifTrue:[ ^ nil ].
tz@696
   921
cg@1973
   922
    cls := cls perform:#helpSpecClass ifNotUnderstood:cls.
ca@1646
   923
cg@1973
   924
    (cls isBehavior and:[cls isLoaded]) ifTrue:[
cg@1973
   925
        ^ cls
tz@696
   926
    ].
ca@1669
   927
    ^ nil
tz@696
   928
!
tz@696
   929
cg@1973
   930
loadFromMessage:classAndSelector
ca@1669
   931
    "Set and rebuild the specClass and specSelector from a resource string.
ca@1669
   932
     On success true is returned otherwise false. If the current spec is
cg@1973
   933
     modified, a dialog is launched."
tz@761
   934
cg@1973
   935
    self askForModification ifFalse:[ ^ false].
cg@896
   936
cg@1973
   937
    classAndSelector notNil ifTrue:[
cg@1973
   938
        self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector).
cg@1973
   939
        ^ true
tz@740
   940
    ].
ca@1669
   941
    ^ false
ca@1670
   942
!
ca@1670
   943
ca@1670
   944
updateIcons
ca@1670
   945
    "update all icons (redefinitions below above or both)
ca@1670
   946
    "
ca@1670
   947
    |iconBelow iconAbove iconAboveAndBelow isBehind redefinedAbove redefinedBelow icon|
ca@1670
   948
ca@1670
   949
    "/ if only one class exists, its not possible to have redefinitions
ca@1670
   950
    classItemList size > 1 ifFalse:[ ^ self ].
ca@1670
   951
ca@1670
   952
    iconBelow         := SystemBrowser medium_methodRedefinedBelowIcon.
ca@1670
   953
    iconAbove         := SystemBrowser medium_methodInheritedFromAboveIcon.
ca@1670
   954
    iconAboveAndBelow := SystemBrowser medium_methodInheritedFromAboveAndRedefinedBelowIcon.
ca@1670
   955
ca@1670
   956
    classItemList do:[:runClass|
ca@1670
   957
        runClass do:[:aKeyItem|
ca@1670
   958
            isBehind := redefinedBelow := redefinedAbove := false.
ca@1670
   959
ca@1670
   960
            classItemList do:[:testClass|
ca@1670
   961
                testClass == runClass ifTrue:[
ca@1670
   962
                    isBehind := true
ca@1670
   963
                ] ifFalse:[
ca@1670
   964
                    (testClass detectItemWithKey:(aKeyItem helpKey)) notNil ifTrue:[
ca@1670
   965
                        isBehind ifTrue:[ redefinedBelow := true ]
ca@1670
   966
                                ifFalse:[ redefinedAbove := true ].
ca@1670
   967
                    ]
ca@1670
   968
                ]
ca@1670
   969
            ].
ca@1670
   970
ca@1670
   971
            redefinedBelow ifTrue:[
ca@1670
   972
                redefinedAbove ifTrue:[ icon := iconAboveAndBelow ]
ca@1670
   973
                              ifFalse:[ icon := iconBelow ]
ca@1670
   974
            ] ifFalse:[
ca@1670
   975
                redefinedAbove ifTrue:[ icon := iconAbove ]
ca@1670
   976
                              ifFalse:[ icon := nil ]
ca@1670
   977
            ].
ca@1670
   978
            aKeyItem icon:icon.
ca@1670
   979
        ]
ca@1670
   980
    ].
ca@286
   981
! !
ca@286
   982
ca@1669
   983
!UIHelpTool methodsFor:'startup & release'!
ca@369
   984
ca@369
   985
closeRequest
sv@1772
   986
    "asks for permission before closing"
sv@1772
   987
sv@1772
   988
    masterApplication isNil ifTrue:[
sv@1772
   989
        super closeRequest.
ca@1669
   990
    ].
tz@740
   991
!
tz@740
   992
cg@2002
   993
commonPostBuild
cg@2002
   994
    "/ using masters infoHolder ?
cg@2002
   995
    (builder aspectAt:#useAlienInfoLabelHolder) == true ifTrue:[
cg@2002
   996
        (builder componentAt:#mainPanel) layout bottomOffset:0.
cg@2002
   997
        (builder componentAt:#infoBarSubSpec) beInvisible
cg@2002
   998
    ]
cg@2002
   999
!
cg@2002
  1000
tz@740
  1001
initialize
ca@1669
  1002
    "setup default attributes
ca@1669
  1003
    "
ca@1669
  1004
    super initialize.
ca@1669
  1005
    self createBuilder.
tz@779
  1006
ca@1669
  1007
    specSelector   := #helpSpec.
tz@740
  1008
ca@1669
  1009
    classItemList  := List new.
ca@1669
  1010
ca@1669
  1011
    classItemModel := nil asValue.
ca@1669
  1012
    classItemModel addDependent:self.
ca@1669
  1013
ca@1669
  1014
    keyItemModel := nil asValue.
ca@1669
  1015
    keyItemModel addDependent:self.
ca@1669
  1016
ca@1669
  1017
    contentsModifiedChannel := false asValue.
ca@1669
  1018
    contentsModifiedChannel addDependent:self.
ca@1669
  1019
ca@1669
  1020
    helpTextView := EditTextView new.
ca@1669
  1021
    helpTextView acceptAction:[:dummy| self accept ].
ca@1669
  1022
    helpTextView modifiedChannel:contentsModifiedChannel.
tz@740
  1023
ca@1646
  1024
    editModel := nil asValue.
ca@1646
  1025
    editModel addDependent:self.
ca@1646
  1026
cg@1973
  1027
    self loadFromClass:nil.
tz@750
  1028
!
tz@750
  1029
tz@750
  1030
openOnClass:aClass
ca@1669
  1031
    "opens the UIHelpTool on aClass
ca@1669
  1032
    "
cg@1597
  1033
    self openOnClass:aClass andSelector:nil
tz@940
  1034
!
tz@940
  1035
tz@940
  1036
openOnClass:aClass andSelector: aSelector
tz@940
  1037
    "opens the UIHelpTool on aClass and aSelector"
tz@940
  1038
cg@1982
  1039
    self openInterface:#windowSpec "ForStandAlone".
cg@1597
  1040
cg@1973
  1041
    builder window label:'Help Tool'.
cg@1973
  1042
    self loadFromClass:aClass andSelector:aSelector
ca@369
  1043
! !
ca@369
  1044
tz@740
  1045
!UIHelpTool methodsFor:'user actions'!
ca@286
  1046
tz@722
  1047
accept
ca@1669
  1048
    "accepts the help text
ca@1669
  1049
    "
ca@1669
  1050
    |helpKey helpItem root|
tz@779
  1051
ca@1669
  1052
    helpKey := self helpKey.
ca@1669
  1053
    helpKey isNil ifTrue:[^ self].
tz@722
  1054
ca@1669
  1055
    root := classItemModel value.
ca@1669
  1056
    root isNil ifTrue:[^ self].
tz@722
  1057
ca@1669
  1058
    helpItem := root detectItemWithKey:helpKey.
cg@1648
  1059
ca@1669
  1060
    helpItem isNil ifTrue:[
ca@1670
  1061
        helpItem := KeyItem helpKey:helpKey helpText:(helpTextView contents).
ca@1670
  1062
        root add:helpItem sortBlock:[:a :b| a label < b label ].
ca@1670
  1063
        self updateIcons.
ca@1669
  1064
    ] ifFalse:[
ca@1670
  1065
        helpItem helpText:(helpTextView contents).
ca@1646
  1066
    ].
ca@1646
  1067
ca@1669
  1068
    contentsModifiedChannel value:false.
ca@1669
  1069
    keyItemModel triggerValue:helpItem.
tz@722
  1070
!
tz@722
  1071
ca@1646
  1072
cancel
cg@2069
  1073
    "cancel modifications, reload helpText"
cg@2069
  1074
ca@1669
  1075
    |item contents modified|
tz@779
  1076
ca@1669
  1077
    item := keyItemModel value.
ca@1669
  1078
    modified := false.
cg@835
  1079
ca@1669
  1080
    item notNil ifTrue:[
cg@2069
  1081
        contents := item helpText.
ca@1669
  1082
    ] ifFalse:[
cg@2069
  1083
        contents := nil.
ca@1669
  1084
cg@2069
  1085
        modifiedHolder isNil ifTrue:[
cg@2069
  1086
            modified := self helpKey notNil
cg@2069
  1087
        ]
ca@1646
  1088
    ].
ca@1669
  1089
    helpTextView contents:contents.
ca@1669
  1090
    contentsModifiedChannel value:modified.
cg@2069
  1091
cg@2069
  1092
    "Modified: / 29-08-2006 / 10:20:37 / cg"
tz@722
  1093
!
tz@722
  1094
tz@750
  1095
doDelete
ca@1646
  1096
    "deletes the selected help key
ca@1646
  1097
    "
ca@1669
  1098
    |item|
tz@779
  1099
ca@1669
  1100
    item := keyItemModel value.
ca@1670
  1101
ca@1670
  1102
    item notNil ifTrue:[
ca@1670
  1103
        item remove.
ca@1670
  1104
        item icon notNil ifTrue:[ self updateIcons ].
ca@1670
  1105
    ].    
ca@1669
  1106
    editModel value:nil.
tz@722
  1107
!
tz@722
  1108
tz@750
  1109
doLoad
cg@1973
  1110
    "opens a Resource Selection Browser in order to get a resource message"
cg@1973
  1111
tz@750
  1112
    self loadFromMessage: 
cg@1681
  1113
        (ResourceSelectionBrowser
cg@1681
  1114
            request: 'Load Help Spec From Class'
cg@1681
  1115
            onSuperclass: nil
cg@1681
  1116
            andClass: specClass
cg@1681
  1117
            andSelector: (self specSelector)
cg@1681
  1118
            withResourceTypes: (Array with: #help)).
tz@779
  1119
tz@779
  1120
    self updateInfoLabel
tz@750
  1121
!
tz@750
  1122
tz@750
  1123
doNew
ca@1669
  1124
    "reset all to empty
ca@1669
  1125
    "
ca@1669
  1126
    contentsModifiedChannel value:false.
ca@1669
  1127
    self helpKey:nil.
cg@1973
  1128
    self loadFromClass:nil.
tz@750
  1129
!
tz@750
  1130
tz@722
  1131
doSave
cg@1973
  1132
    "save the help spec to the spec-class(es)"
cg@1973
  1133
ca@1669
  1134
    specClass isNil ifTrue:[
cg@3334
  1135
        self information:'No class specified !!'.
ca@1669
  1136
        ^ nil
ca@1669
  1137
    ].
cg@1777
  1138
"/ cg: the following test is rubbish !!
cg@1777
  1139
"/    (specClass isSubclassOf:ApplicationModel) ifFalse:[
cg@1777
  1140
"/        self information:(resources string:'Cannot save help into non-Application class').
cg@1777
  1141
"/        ^ nil
cg@1777
  1142
"/    ].
tz@779
  1143
cg@2934
  1144
    classItemList do:[:aClassItem|
cg@2934
  1145
        aClassItem theClass isNil ifTrue:[
cg@2934
  1146
            aClassItem onClass:specClass
cg@2934
  1147
        ].
cg@1681
  1148
        aClassItem createHelpMethodNamed:(self specSelector) 
cg@1681
  1149
    ].
ca@1669
  1150
!
ca@1669
  1151
cg@2020
  1152
openDocumentation
cg@2020
  1153
    "opens the documentation file of the Help Tool
cg@2020
  1154
    "
cg@2020
  1155
    self openHTMLDocument: 'tools/uipainter/HelpTool.html'
cg@2020
  1156
! !
ca@1669
  1157
cg@2020
  1158
!UIHelpTool::ClassItem class methodsFor:'instance creation'!
cg@2020
  1159
cg@2020
  1160
onClass:aClass
cg@2020
  1161
    |root|
cg@2020
  1162
cg@2020
  1163
    root := self new.
cg@2020
  1164
    root onClass:aClass.
cg@2020
  1165
    ^ root
cg@2020
  1166
! !
cg@2020
  1167
cg@2020
  1168
!UIHelpTool::ClassItem methodsFor:'accessing'!
ca@1669
  1169
ca@1669
  1170
list
ca@1669
  1171
    "returns the hierarchical list assigned to the classItem; the
ca@1669
  1172
     list contains the keyItems
ca@1669
  1173
    "
ca@1669
  1174
    list isNil ifTrue:[
ca@1669
  1175
	list := HierarchicalList new.
ca@1669
  1176
	list showRoot:false.
ca@1669
  1177
	list root:self.
ca@1669
  1178
    ].
ca@1669
  1179
    ^ list
ca@1669
  1180
!
ca@1669
  1181
ca@1669
  1182
theClass
ca@1669
  1183
    "returns the class or nil if unspecified
ca@1669
  1184
    "
ca@1669
  1185
    ^ theClass
ca@1669
  1186
! !
ca@1669
  1187
cg@2020
  1188
!UIHelpTool::ClassItem methodsFor:'change & update'!
ca@1669
  1189
ca@1669
  1190
helpTextChangedFor:anItem
ca@1669
  1191
    "called if an helpKey changed its contents
ca@1669
  1192
    "
ca@1669
  1193
    self model notNil ifTrue:[
ca@1669
  1194
	self   modified:true.
ca@1669
  1195
	anItem modified:true.
ca@1669
  1196
    ].
ca@1669
  1197
! !
ca@1669
  1198
ca@1669
  1199
!UIHelpTool::ClassItem methodsFor:'code generation'!
ca@1669
  1200
ca@1669
  1201
createHelpMethodNamed:aMethodName
ca@1669
  1202
    |stream|
ca@1669
  1203
cg@2934
  1204
    modified ifFalse:[
ca@1669
  1205
        ^ self
ca@1669
  1206
    ].
cg@2934
  1207
    theClass isNil ifTrue:[
cg@2934
  1208
        theClass := Dialog requestClass:'Save helpSpec in which class?' initialAnswer:''.
cg@2934
  1209
        theClass isNil ifTrue:[
cg@2934
  1210
            ^ self
cg@2934
  1211
        ].
cg@2934
  1212
    ].
ca@1669
  1213
    stream := '' writeStream.
ca@1669
  1214
ca@1669
  1215
    stream nextPutAll:
ca@1669
  1216
        aMethodName, '\' withCRs,
ca@1669
  1217
        (ResourceSpecEditor codeGenerationCommentForClass:UIHelpTool) withCRs,
ca@1669
  1218
    '\\' withCRs,
ca@1669
  1219
    '    "\' withCRs,
mawalch@3318
  1220
    '     UIHelpTool openOnClass:', theClass name asString ,'
ca@1669
  1221
    "
ca@1669
  1222
ca@1669
  1223
    <resource: #help>
ca@1669
  1224
ca@1669
  1225
    ^ super ', aMethodName, ' addPairsFrom:#(
ca@1669
  1226
ca@1669
  1227
'.
ca@1669
  1228
ca@1669
  1229
    self do:[:aKeyItem| |helpText|
ca@1669
  1230
        helpText := aKeyItem helpText.
ca@1669
  1231
        helpText isNil ifTrue:[ helpText := '' ].
ca@1669
  1232
ca@1669
  1233
        stream nextPutLine:(aKeyItem helpKey storeString).
ca@1669
  1234
        stream nextPutLine:(helpText storeString); cr.
ca@1669
  1235
    ].
ca@1669
  1236
    stream nextPutLine:')'.
ca@1669
  1237
mawalch@3318
  1238
    Compiler
ca@1669
  1239
        compile:(stream contents)
mawalch@3318
  1240
        forClass:theClass class
ca@1669
  1241
        inCategory:'help specs'.
ca@1669
  1242
ca@1669
  1243
    self modified:false.
cg@2020
  1244
! !
ca@1669
  1245
cg@2020
  1246
!UIHelpTool::ClassItem methodsFor:'displaying'!
cg@2020
  1247
cg@2020
  1248
icon
cg@2020
  1249
    "returns the display icon (always nil)
cg@2020
  1250
    "
cg@2020
  1251
    ^ nil
cg@2020
  1252
!
cg@2020
  1253
cg@2020
  1254
label
cg@2020
  1255
    "returns the display label
cg@2020
  1256
    "
cg@2020
  1257
    |label|
cg@2020
  1258
cg@2020
  1259
    theClass notNil ifTrue:[ label := theClass name ]
cg@2020
  1260
		   ifFalse:[ label := '** not yet defined **' ].
cg@2020
  1261
cg@2020
  1262
    modified ifTrue:[
cg@2020
  1263
	label := Text string:label color:(Color red).
cg@2020
  1264
    ].
cg@2020
  1265
    ^ label
cg@2020
  1266
! !
cg@2020
  1267
cg@2020
  1268
!UIHelpTool::ClassItem methodsFor:'instance creation'!
ca@1669
  1269
ca@1669
  1270
initialize
ca@1669
  1271
    "setup defaults
ca@1669
  1272
    "
ca@1669
  1273
    super initialize.
ca@1669
  1274
ca@1669
  1275
    children   := OrderedCollection new.
ca@1669
  1276
    isExpanded := true.
ca@1669
  1277
    modified   := false.
ca@1669
  1278
!
ca@1669
  1279
ca@1669
  1280
onClass:aClass
ca@1669
  1281
    "the class the ys are assigned to; if the class is nil,
ca@1669
  1282
     the class is not yet specified.
ca@1669
  1283
    "
ca@1669
  1284
    theClass := aClass.
ca@1669
  1285
! !
ca@1669
  1286
ca@1669
  1287
!UIHelpTool::ClassItem methodsFor:'private'!
ca@1669
  1288
ca@1669
  1289
basicAdd:aChild sortBlock:aBlock
ca@1669
  1290
    "catch low-level add to update the modification flag
ca@1669
  1291
    "
ca@1669
  1292
    self   modified:true.
ca@1669
  1293
    aChild modified:true.
ca@1669
  1294
ca@1669
  1295
    ^ super basicAdd:aChild sortBlock:aBlock.
ca@1669
  1296
!
ca@1669
  1297
ca@1669
  1298
basicAddAll:aList beforeIndex:anIndex
ca@1669
  1299
    "catch low-level add to update the modification flag
ca@1669
  1300
    "
ca@1669
  1301
    self modified:true.
ca@1669
  1302
cg@2020
  1303
    aList do:[:el| el modified:true ].
cg@2020
  1304
    ^ super basicAddAll:aList beforeIndex:anIndex.
cg@2020
  1305
!
ca@1669
  1306
ca@1669
  1307
basicRemoveFromIndex:startIndex toIndex:stopIndex
ca@1669
  1308
    "catch low-level remove to update the modification flag
ca@1669
  1309
    "
ca@1669
  1310
    self isUnspecified ifFalse:[
ca@1669
  1311
	self modified:true.
ca@1669
  1312
    ].
ca@1669
  1313
    ^ super basicRemoveFromIndex:startIndex toIndex:stopIndex
ca@1669
  1314
! !
ca@1669
  1315
ca@1669
  1316
!UIHelpTool::ClassItem methodsFor:'queries'!
ca@1669
  1317
ca@1669
  1318
isUnspecified
ca@1669
  1319
    "true if the class is unspecified
ca@1669
  1320
    "
ca@1669
  1321
    ^ theClass isNil
ca@1669
  1322
!
ca@1669
  1323
ca@1669
  1324
modified
cg@2020
  1325
    "true, if any item is modified, created or deleted
cg@2020
  1326
    "
cg@2020
  1327
    ^ modified
cg@2020
  1328
!
ca@1669
  1329
ca@1669
  1330
modified:aBoolean
ca@1669
  1331
    "true, if any item is modified, created or deleted
ca@1669
  1332
    "
ca@1669
  1333
    modified ~~ aBoolean ifTrue:[
ca@1669
  1334
	modified := aBoolean.
ca@1669
  1335
ca@1669
  1336
	modified ifFalse:[
ca@1669
  1337
	    self do:[:el| el modified:false ].
ca@1669
  1338
	].
ca@1669
  1339
    ].
ca@1669
  1340
! !
ca@1669
  1341
ca@1669
  1342
!UIHelpTool::ClassItem methodsFor:'searching'!
ca@1669
  1343
ca@1669
  1344
detectItemWithKey:aKey
ca@1669
  1345
    "returns the item assigned to a helpKey or nil
ca@1669
  1346
    "
ca@1669
  1347
    |key|
ca@1669
  1348
cg@2037
  1349
    aKey isEmptyOrNil ifTrue:[ ^ nil ].
cg@2037
  1350
    key := aKey asSymbol.
ca@1669
  1351
cg@2037
  1352
    self do:[:anItem|
cg@2037
  1353
        anItem helpKey == key ifTrue:[ ^ anItem ].
ca@1669
  1354
    ].
cg@2020
  1355
    ^ nil
ca@1669
  1356
! !
ca@1669
  1357
cg@2020
  1358
!UIHelpTool::KeyItem class methodsFor:'instance creation'!
ca@1669
  1359
cg@2020
  1360
helpKey:aKey helpText:aText 
cg@2020
  1361
    |key|
ca@1669
  1362
cg@2020
  1363
    key := self new.
cg@2020
  1364
    key helpKey:aKey helpText:aText.
cg@2020
  1365
    ^ key
cg@2020
  1366
! !
cg@2020
  1367
cg@2020
  1368
!UIHelpTool::KeyItem methodsFor:'accessing'!
ca@1669
  1369
ca@1669
  1370
helpKey
cg@3291
  1371
    "returns the helpKey, a symbol"
cg@3291
  1372
ca@1669
  1373
    ^ helpKey
ca@1669
  1374
!
ca@1669
  1375
ca@1669
  1376
helpText
ca@1669
  1377
    "returns the contents assigned to the helpKey or nil
ca@1669
  1378
    "
ca@1669
  1379
    ^ helpText
ca@1669
  1380
!
ca@1669
  1381
ca@1669
  1382
helpText:aText
cg@1681
  1383
    "set the contents assigned to the helpKey; if the contents changes,
ca@1669
  1384
     a notification is raised.
ca@1669
  1385
    "
ca@1669
  1386
    |text|
ca@1669
  1387
ca@1669
  1388
    text := self formatText:aText.
ca@1669
  1389
ca@1669
  1390
    text ~= helpText ifTrue:[
cg@1681
  1391
        helpText := text.
ca@1669
  1392
cg@1681
  1393
        (modified or:[parent isNil]) ifFalse:[
cg@1681
  1394
            parent helpTextChangedFor:self.
cg@1681
  1395
        ]
ca@1669
  1396
    ].
ca@1669
  1397
! !
ca@1669
  1398
cg@2020
  1399
!UIHelpTool::KeyItem methodsFor:'displaying'!
cg@2020
  1400
cg@2020
  1401
icon
cg@2020
  1402
    "returns the display icon (always nil)
cg@2020
  1403
    "
cg@2020
  1404
    ^ icon
ca@1670
  1405
!
ca@1670
  1406
cg@2020
  1407
icon:anIcon
cg@2020
  1408
cg@2020
  1409
    icon ~= anIcon ifTrue:[
cg@2020
  1410
        icon := anIcon.
cg@2020
  1411
        self changed:#icon.
cg@2020
  1412
    ].
cg@2020
  1413
!
cg@2020
  1414
cg@2020
  1415
label
cg@2020
  1416
    "returns the display label
cg@2020
  1417
    "
cg@2020
  1418
    modified ifTrue:[
cg@2020
  1419
	^ Text string:helpKey color:(Color red)
cg@2020
  1420
    ].
cg@2020
  1421
    ^ helpKey
cg@2020
  1422
! !
cg@2020
  1423
cg@2020
  1424
!UIHelpTool::KeyItem methodsFor:'instance creation'!
cg@2020
  1425
ca@1669
  1426
helpKey:aKey helpText:aText
ca@1669
  1427
    "set the key and contents without a change notification
ca@1669
  1428
    "
ca@1669
  1429
    helpKey  := aKey asSymbol.
ca@1669
  1430
    helpText := self formatText:aText.
ca@1669
  1431
!
ca@1669
  1432
ca@1669
  1433
initialize
ca@1669
  1434
    "setup defaults
ca@1669
  1435
    "
ca@1669
  1436
    super initialize.
ca@1669
  1437
    children := #().
ca@1669
  1438
    modified := false.
ca@1669
  1439
! !
ca@1669
  1440
ca@1669
  1441
!UIHelpTool::KeyItem methodsFor:'private'!
ca@1669
  1442
ca@1669
  1443
formatText:aText
ca@1669
  1444
    "format the text, replace carriage return by spaces and compress spaces
ca@1669
  1445
    "
ca@1669
  1446
    |text result|
ca@1669
  1447
ca@1669
  1448
    aText size ~~ 0 ifTrue:[
ca@1669
  1449
	text := aText asString asCollectionOfWords.
ca@1669
  1450
ca@1669
  1451
	text notEmpty ifTrue:[
ca@1669
  1452
	    result := text first.
ca@1669
  1453
ca@1669
  1454
	    text from:2 do:[:t| result := result, ' ', t ].
cg@2020
  1455
	    ^ result
cg@2020
  1456
       ].
cg@2020
  1457
    ].
cg@2020
  1458
    ^ nil
cg@2020
  1459
! !
cg@2020
  1460
cg@2020
  1461
!UIHelpTool::KeyItem methodsFor:'queries'!
cg@2020
  1462
cg@2020
  1463
modified
cg@2020
  1464
    "returns true if the helpText is modified
cg@2020
  1465
    "
cg@2020
  1466
    ^ modified
cg@2020
  1467
!
ca@1669
  1468
ca@1669
  1469
modified:aBoolean
ca@1669
  1470
    "set the modification flag
ca@1669
  1471
    "
ca@1669
  1472
    aBoolean == modified ifFalse:[
ca@1669
  1473
	modified := aBoolean.
ca@1669
  1474
	self changed:#redraw.
ca@1669
  1475
    ].
ca@148
  1476
! !
ca@148
  1477
ca@148
  1478
!UIHelpTool class methodsFor:'documentation'!
ca@148
  1479
ca@148
  1480
version
ca@148
  1481
    ^ '$Header$'
cg@2665
  1482
!
cg@2665
  1483
cg@2665
  1484
version_CVS
cg@2665
  1485
    ^ '$Header$'
ca@148
  1486
! !
cg@3010
  1487