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