UIHelpTool.st
changeset 1554 d5e4612bf7cf
parent 1506 6525741c998e
child 1597 b670ad8c30e1
equal deleted inserted replaced
1553:1d7fd5dde600 1554:d5e4612bf7cf
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
    13 
       
    14 
       
    15 "{ Package: 'stx:libtool2' }"
    14 
    16 
    15 ToolApplicationModel subclass:#UIHelpTool
    17 ToolApplicationModel subclass:#UIHelpTool
    16 	instanceVariableNames:'specClass specSelector dictionary dictionaries listSelection
    18 	instanceVariableNames:'specClass specSelector dictionary dictionaries listSelection
    17 		maxCharsPerLine modifiedHolder modified'
    19 		maxCharsPerLine modifiedHolder modified'
    18 	classVariableNames:''
    20 	classVariableNames:''
   663     ].
   665     ].
   664 
   666 
   665     (specClass isClass and: [specClass isLoaded])
   667     (specClass isClass and: [specClass isLoaded])
   666     ifTrue: 
   668     ifTrue: 
   667     [                                               
   669     [                                               
   668         (specClass class implements:specSelector) ifFalse:[
   670         (specClass class includesSelector:specSelector) ifFalse:[
   669             dictionaries at: specClass name put: dictionary 
   671             dictionaries at: specClass name put: dictionary 
   670         ].
   672         ].
   671         list := self listOfHelpSpecClasses.
   673         list := self listOfHelpSpecClasses.
   672 
   674 
   673         list contents:  (specClass withAllSuperclasses reverse collect: [:cls| cls name]).
   675         list contents:  (specClass withAllSuperclasses reverse collect: [:cls| cls name]).
   682         ].
   684         ].
   683         self helpSpecClassSelected.
   685         self helpSpecClassSelected.
   684     ].
   686     ].
   685 
   687 
   686     self updateList
   688     self updateList
   687 
       
   688 ! !
   689 ! !
   689 
   690 
   690 !UIHelpTool methodsFor:'callbacks'!
   691 !UIHelpTool methodsFor:'callbacks'!
   691 
   692 
   692 helpSpecClassSelected
   693 helpSpecClassSelected
   727     "returns the default label for the info bar"
   728     "returns the default label for the info bar"
   728 
   729 
   729     specClass isClass
   730     specClass isClass
   730     ifTrue:
   731     ifTrue:
   731     [
   732     [
   732         (specClass class implements: specSelector)
   733         (specClass class includesSelector: specSelector)
   733         ifFalse: 
   734         ifFalse: 
   734         [
   735         [
   735             ^specSelector isNil 
   736             ^specSelector isNil 
   736                 ifTrue:  [specClass name, ' >> ? (no selector defined)']
   737                 ifTrue:  [specClass name, ' >> ? (no selector defined)']
   737                 ifFalse: [specClass name, ' >> ', specSelector, ' (not implemented)']
   738                 ifFalse: [specClass name, ' >> ', specSelector, ' (not implemented)']
   738         ].
   739         ].
   739         ^specClass name, ' >> ', specSelector
   740         ^specClass name, ' >> ', specSelector
   740     ].
   741     ].
   741     ^'No class and selector defined.'
   742     ^'No class and selector defined.'
   742 
       
   743 
       
   744 
       
   745 !
   743 !
   746 
   744 
   747 openDocumentation
   745 openDocumentation
   748     "opens the documentation file of the Help Tool"
   746     "opens the documentation file of the Help Tool"
   749 
   747 
   795 extractHelpSpecForClass: aClass
   793 extractHelpSpecForClass: aClass
   796     "extracts the help dictionary of aClass, it current and return it"
   794     "extracts the help dictionary of aClass, it current and return it"
   797 
   795 
   798     |helpSpecSuperClass superHelpSpecKeys helpSpec|
   796     |helpSpecSuperClass superHelpSpecKeys helpSpec|
   799 
   797 
   800     ((aClass class implements: specSelector)
   798     ((aClass class includesSelector: specSelector)
   801     and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class implements: specSelector] ifNone: nil) notNil])
   799     and: [(helpSpecSuperClass := aClass allSuperclasses detect: [:cls| cls class includesSelector: specSelector] ifNone: nil) notNil])
   802     ifTrue:[                  
   800     ifTrue:[                  
   803         superHelpSpecKeys := helpSpecSuperClass helpSpec keys.
   801         superHelpSpecKeys := helpSpecSuperClass helpSpec keys.
   804         helpSpec := Dictionary new.
   802         helpSpec := Dictionary new.
   805         aClass helpSpec keysAndValuesDo:[:key :value |
   803         aClass helpSpec keysAndValuesDo:[:key :value |
   806             (superHelpSpecKeys includes:key) ifFalse: [
   804             (superHelpSpecKeys includes:key) ifFalse: [
   889     helpSpec associationsDo:
   887     helpSpec associationsDo:
   890     [:h|
   888     [:h|
   891         helpSpec at: h key put: (self getUnformattedHelpText: h value)
   889         helpSpec at: h key put: (self getUnformattedHelpText: h value)
   892     ].
   890     ].
   893 
   891 
   894     (cls class implements: specSelector) 
   892     (cls class includesSelector: specSelector) 
   895     ifTrue: 
   893     ifTrue: 
   896     [
   894     [
   897         |superclassHelpKeys implementedHelpSpec hasChanged|
   895         |superclassHelpKeys implementedHelpSpec hasChanged|
   898         implementedHelpSpec := Dictionary new.
   896         implementedHelpSpec := Dictionary new.
   899         superclassHelpKeys := (cls superclass respondsTo: specSelector)
   897         superclassHelpKeys := (cls superclass respondsTo: specSelector)
  1091     [            
  1089     [            
  1092         |msg cls sel|
  1090         |msg cls sel|
  1093         msg := aString asCollectionOfWords.
  1091         msg := aString asCollectionOfWords.
  1094         (msg size == 2 and:
  1092         (msg size == 2 and:
  1095         [(cls := self resolveName:(msg at:1)) notNil and:
  1093         [(cls := self resolveName:(msg at:1)) notNil and:
  1096         [cls class implements: (sel := (msg at: 2) asSymbol)]])
  1094         [cls class includesSelector: (sel := (msg at: 2) asSymbol)]])
  1097         ifTrue:
  1095         ifTrue:
  1098         [               
  1096         [               
  1099             self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel).
  1097             self buildFromClass: (specClass := cls name) andSelector: (specSelector := sel).
  1100             ^true
  1098             ^true
  1101         ]
  1099         ]
  1102     ].
  1100     ].
  1103     ^false
  1101     ^false
  1104 
       
  1105 !
  1102 !
  1106 
  1103 
  1107 openInterface:aSymbol
  1104 openInterface:aSymbol
  1108     "do not open as stand alone"
  1105     "do not open as stand alone"
  1109 
  1106