UIHelpTool.st
changeset 1681 7a8e5df3f07d
parent 1670 72af7609bb08
child 1723 30d20151ed81
equal deleted inserted replaced
1680:be9c3f67a19b 1681:7a8e5df3f07d
    26 	poolDictionaries:''
    26 	poolDictionaries:''
    27 	privateIn:UIHelpTool
    27 	privateIn:UIHelpTool
    28 !
    28 !
    29 
    29 
    30 HierarchicalItem subclass:#KeyItem
    30 HierarchicalItem subclass:#KeyItem
    31 	instanceVariableNames:'helpKey helpText modified icon'
    31 	instanceVariableNames:'helpKey helpText flyByText modified icon'
    32 	classVariableNames:''
    32 	classVariableNames:''
    33 	poolDictionaries:''
    33 	poolDictionaries:''
    34 	privateIn:UIHelpTool
    34 	privateIn:UIHelpTool
    35 !
    35 !
    36 
    36 
   573     "
   573     "
   574     ^ specClass
   574     ^ specClass
   575 !
   575 !
   576 
   576 
   577 specSelector
   577 specSelector
   578     "returns the selector on which the class is opened
   578     "returns the selector of the edited helpSpec method
   579     "
   579     "
   580     ^ specSelector
   580     ^ specSelector ? #helpSpec
   581 ! !
   581 ! !
   582 
   582 
   583 !UIHelpTool methodsFor:'aspects'!
   583 !UIHelpTool methodsFor:'aspects'!
   584 
   584 
   585 classItemListHolder
   585 classItemListHolder
   695 
   695 
   696 buildFromClass:aClass
   696 buildFromClass:aClass
   697     "reads the help dictionary from aClass and find remaining classes 
   697     "reads the help dictionary from aClass and find remaining classes 
   698      'between' aClass and ApplicationModel
   698      'between' aClass and ApplicationModel
   699     " 
   699     " 
   700     |lastContents root list resource|
   700     |lastContents root list resource helpSpecSelector|
   701 
   701 
   702     specSelector isNil ifTrue:[ specSelector := #helpSpec ].
   702     helpSpecSelector := self specSelector.
   703     specClass := self getHelpSpecClassFromClass:aClass.
   703     specClass := self getHelpSpecClassFromClass:aClass.
   704 
   704 
   705     list := OrderedCollection new.
   705     list := OrderedCollection new.
   706 
   706 
   707     (specClass isClass and:[specClass isLoaded]) ifTrue:[
   707     (specClass isClass and:[specClass isLoaded]) ifTrue:[
   708         lastContents := nil.
   708         lastContents := nil.
   709         resource := specClass name, ' ', specSelector.
   709         resource := specClass name, ' ', helpSpecSelector.
   710         self addToHistory:(Association key:resource value:#'loadFromMessage:').
   710         self addToHistory:(Association key:resource value:#'loadFromMessage:').
   711 
   711 
   712         specClass withAllSuperclasses reverse do:[:aClass| |value name|
   712         specClass withAllSuperclasses reverse do:[:aClass| |value name|
   713             lastContents isNil ifTrue:[
   713             lastContents isNil ifTrue:[
   714                 aClass == ApplicationModel ifTrue:[ 
   714                 aClass == ApplicationModel ifTrue:[ 
   715                     lastContents := IdentityDictionary new
   715                     lastContents := IdentityDictionary new
   716                 ].
   716                 ].
   717             ] ifFalse:[
   717             ] ifFalse:[
   718                 root := ClassItem onClass:aClass.
   718                 root := ClassItem onClass:aClass.
   719 
   719 
   720                 (aClass class includesSelector:specSelector) ifTrue:[
   720                 (aClass class includesSelector:helpSpecSelector) ifTrue:[
   721                     value := aClass perform:specSelector.
   721                     value := aClass perform:helpSpecSelector.
   722 
   722 
   723                     value keysAndValuesDo:[:k :v| |cval|
   723                     value keysAndValuesDo:[:k :v| |cval|
   724                         cval := lastContents at:k ifAbsent:self.
   724                         cval := lastContents at:k ifAbsent:self.
   725                         cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ].
   725                         cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ].
   726                     ].
   726                     ].
  1121 
  1121 
  1122 doLoad
  1122 doLoad
  1123     "opens a Resource Selection Browser in order to get a resource message
  1123     "opens a Resource Selection Browser in order to get a resource message
  1124     "
  1124     "
  1125     self loadFromMessage: 
  1125     self loadFromMessage: 
  1126 	(ResourceSelectionBrowser
  1126         (ResourceSelectionBrowser
  1127 	    request: 'Load Help Spec From Class'
  1127             request: 'Load Help Spec From Class'
  1128 	    onSuperclass: nil
  1128             onSuperclass: nil
  1129 	    andClass: specClass
  1129             andClass: specClass
  1130 	    andSelector: specSelector ? #help
  1130             andSelector: (self specSelector)
  1131 	    withResourceTypes: (Array with: #help)).
  1131             withResourceTypes: (Array with: #help)).
  1132 
  1132 
  1133     self updateInfoLabel
  1133     self updateInfoLabel
  1134 !
  1134 !
  1135 
  1135 
  1136 doNew
  1136 doNew
  1151     (specClass isSubclassOf:ApplicationModel) ifFalse:[
  1151     (specClass isSubclassOf:ApplicationModel) ifFalse:[
  1152         self information:(resources string:'Cannot save help into none Application class').
  1152         self information:(resources string:'Cannot save help into none Application class').
  1153         ^ nil
  1153         ^ nil
  1154     ].
  1154     ].
  1155 
  1155 
  1156     classItemList do:[:aClassItem| aClassItem createHelpMethodNamed:specSelector ].
  1156     classItemList do:[:aClassItem| 
       
  1157         aClassItem createHelpMethodNamed:(self specSelector) 
       
  1158     ].
  1157 !
  1159 !
  1158 
  1160 
  1159 openDocumentation
  1161 openDocumentation
  1160     "opens the documentation file of the Help Tool
  1162     "opens the documentation file of the Help Tool
  1161     "
  1163     "
  1357     ^ nil
  1359     ^ nil
  1358 ! !
  1360 ! !
  1359 
  1361 
  1360 !UIHelpTool::KeyItem class methodsFor:'instance creation'!
  1362 !UIHelpTool::KeyItem class methodsFor:'instance creation'!
  1361 
  1363 
  1362 helpKey:aKey helpText:aText
  1364 helpKey:aKey helpText:aText 
  1363     |key|
  1365     |key|
  1364 
  1366 
  1365     key := self new.
  1367     key := self new.
  1366     key helpKey:aKey helpText:aText.
  1368     key helpKey:aKey helpText:aText.
  1367     ^ key
  1369     ^ key
  1380     "
  1382     "
  1381     ^ helpText
  1383     ^ helpText
  1382 !
  1384 !
  1383 
  1385 
  1384 helpText:aText
  1386 helpText:aText
  1385     "set the contents assigned to the helpKey; if the cxontents changed,
  1387     "set the contents assigned to the helpKey; if the contents changes,
  1386      a notification is raised.
  1388      a notification is raised.
  1387     "
  1389     "
  1388     |text|
  1390     |text|
  1389 
  1391 
  1390     text := self formatText:aText.
  1392     text := self formatText:aText.
  1391 
  1393 
  1392     text ~= helpText ifTrue:[
  1394     text ~= helpText ifTrue:[
  1393 	helpText := text.
  1395         helpText := text.
  1394 
  1396 
  1395 	(modified or:[parent isNil]) ifFalse:[
  1397         (modified or:[parent isNil]) ifFalse:[
  1396 	    parent helpTextChangedFor:self.
  1398             parent helpTextChangedFor:self.
  1397 	]
  1399         ]
  1398     ].
  1400     ].
  1399 ! !
  1401 ! !
  1400 
  1402 
  1401 !UIHelpTool::KeyItem methodsFor:'displaying'!
  1403 !UIHelpTool::KeyItem methodsFor:'displaying'!
  1402 
  1404