comments + documentation
authortz
Wed, 15 Apr 1998 17:17:31 +0200
changeset 779 2ffa22f97d5d
parent 778 a4b931b2aff6
child 780 96270af95475
comments + documentation
UIHelpTool.st
--- a/UIHelpTool.st	Wed Apr 15 12:46:40 1998 +0200
+++ b/UIHelpTool.st	Wed Apr 15 17:17:31 1998 +0200
@@ -14,7 +14,7 @@
 
 ToolApplicationModel subclass:#UIHelpTool
 	instanceVariableNames:'specClass specSelector dictionary dictionaries listSelection
-		modifiedHolder maxCharsPerLine modified'
+		maxCharsPerLine modifiedHolder modified'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -40,7 +40,7 @@
 
 documentation
 "
-    The UIHelpTool allows you to define help dictionaries for the widgets in
+    The Help Tool allows you to define help dictionaries for the widgets in
     window applications. The tool are able to run stand alone or in other master 
     applications like the GUI Painter and the Menu Editor.
     If the application responds to the selector #showHelp:aHelpText for:aView,
@@ -48,6 +48,16 @@
     If the application does not responds to that selector, and the activeHelp mode
     is enabled, an active help bubble is shown at the widget's view.
 
+    [instance variables:]
+        specClass       <Symbol>        class implementing the help spec
+        specSelector    <Symbol>        selector returning the help spec
+        dictionary      <Dictionary>    dictionary containing pairs of help keys/texts
+        dictionaries    <Dictionary>    dictionary containing pairs of help spec classes/help dictionaries
+        listSelection   <String>        current selected help key
+        maxCharsPerLine <Integer>       maximum number of allowed characters per text line
+        modifiedHolder  <ValueHolder>   value holder for setting as modified
+        modified        <Boolean>       flag whether the help spec was modified
+
     [author:]
         Claus Atzkern, eXept Software AG
         Thomas Zwick, eXept Software AG
@@ -57,6 +67,8 @@
 !UIHelpTool class methodsFor:'instance creation'!
 
 openOnClass:aClass
+    "opens a Help Tool on aClass"
+
     "
      UIHelpTool openOnClass:self
     "
@@ -65,19 +77,10 @@
 
 ! !
 
-!UIHelpTool class methodsFor:'accessing'!
-
-resourceType
-    "get the type of resource of the method generated by the Help Tool"
-
-    ^#help
-
-
-! !
-
 !UIHelpTool class methodsFor:'constants'!
 
 label
+    "returns the label; used if embedded as sub canvas in the GUI Painter or Menu Editor"
 
     ^'Help'
 ! !
@@ -434,14 +437,14 @@
 !UIHelpTool methodsFor:'accessing'!
 
 dictionaries
-    "get the dictionary of the help dictionaries of the classes having help specs
-    "
+    "returns the dictionary of the help dictionaries of the classes having help specs"
+
     ^dictionaries
 !
 
 dictionaries:aDictionaryOfDictionaries
-    "set a dictionary of the help dictionaries of the classes having help specs
-    "
+    "sets a dictionary of the help dictionaries of the classes having help specs"
+
     (dictionaries := aDictionaryOfDictionaries) isNil ifTrue:[
         dictionaries := Dictionary new.
     ].
@@ -449,14 +452,14 @@
 !
 
 dictionary
-    "get the dictionary of the selected class
-    "
+    "returns the dictionary of the selected class"
+
     ^dictionary
 !
 
 dictionary:aDictionary
-    "set dictionary of the selected class
-    "
+    "sets dictionary of the selected class"
+
     (dictionary := aDictionary) isNil ifTrue:[
         dictionary := Dictionary new.
     ].
@@ -464,8 +467,8 @@
 !
 
 helpKey
-    "get the help key of selected help text
-    "
+    "returns the help key of selected help text"
+
     listSelection size ~~ 0 ifTrue:[
         ^ listSelection asSymbol
     ].
@@ -473,8 +476,8 @@
 !
 
 helpKey:aKey
-    "set the help key into the selection channel in order to show the help text
-    "
+    "sets the help key into the selection channel in order to show the help text"
+
     |key|
     aKey size ~~ 0 ifTrue:[
         key := aKey asString
@@ -484,20 +487,20 @@
 !
 
 modified
-    "answer whether the help tool was modified
-    "
+    "returns whether the help tool was modified"
+
     ^modified
 !
 
 modified: aBoolean
-    "set the help tool as modified
-    "
+    "sets the help tool as modified"
+
     modified := aBoolean
 !
 
 modifiedHolder:aValueHolder
-    "set the value holder set to true in case of modifying attributes
-    "
+    "sets the value holder to true in case of modifying attributes"
+
     modifiedHolder notNil ifTrue:[
         modifiedHolder removeDependent:self. 
     ].
@@ -520,16 +523,16 @@
 !
 
 specClass
-    "get the class on which the help tool works
-    "
+    "returns the class on which the help tool works"
+
     ^specClass
 ! !
 
 !UIHelpTool methodsFor:'aspects'!
 
 listChannel
-    "get the value holder of the help texts
-    "
+    "returns the value holder of the help texts"
+
     |holder|
     (holder := builder bindingAt:#listChannel) isNil ifTrue:[
         builder aspectAt:#listChannel put:(holder :=  OrderedCollection new asValue).
@@ -538,8 +541,8 @@
 !
 
 listModel
-    "get the value holder of the help key
-    "
+    "returns the value holder of the help key"
+
     |holder|
     (holder := builder bindingAt:#listModel) isNil ifTrue:[
         holder := AspectAdaptor new subject:self; forAspect:#listSelection.
@@ -549,9 +552,9 @@
 !
 
 listOfHelpSpecClasses
-    "get the value holder of the specClass and its superclasses 
-     which are subclasses of ApplicationModel
-    "
+    "returns the value holder of the specClass and its superclasses 
+     which are subclasses of ApplicationModel"
+
     |holder|       
     (holder := builder bindingAt:#listOfHelpSpecClasses) isNil ifTrue:[
         builder aspectAt:#listOfHelpSpecClasses put: (holder := List new)
@@ -561,8 +564,8 @@
 !
 
 selectionOfHelpSpecClass
-    "get the value holder of the selected help spec class
-    "
+    "returns the value holder of the selected help spec class"
+
     |holder|
     (holder := builder bindingAt:#selectionOfHelpSpecClass) isNil ifTrue:[
         builder aspectAt:#selectionOfHelpSpecClass put: (holder := ValueHolder new)
@@ -574,9 +577,9 @@
 !UIHelpTool methodsFor:'building'!
 
 buildFromClass:aClass
-    "read the help dictionary from aClass and find remaining classes 
-     'between' aClass and ApplicationModel 
-    "
+    "reads the help dictionary from aClass and find remaining classes 
+     'between' aClass and ApplicationModel" 
+
     modified := false.
     specClass notNil
     ifTrue:
@@ -604,6 +607,7 @@
 !
 
 buildFromClass: aClass andSelector: aSelector
+    "sets aSelector and reads the help dictionary from aClass"
 
     specSelector := aSelector.
     self buildFromClass:aClass
@@ -613,8 +617,8 @@
 !UIHelpTool methodsFor:'callbacks'!
 
 helpSpecClassSelected
-    "extract the help dictionary from the selected class and make it current
-    "
+    "extracts the help dictionary from the selected class and make it current"
+
     |clsName|
 
     clsName := self selectionOfHelpSpecClass value.
@@ -647,7 +651,7 @@
 !UIHelpTool methodsFor:'help'!
 
 defaultInfoLabel
-    "get default label for the info bar"
+    "returns the default label for the info bar"
 
     specClass isClass
     ifTrue:
@@ -670,7 +674,7 @@
 !UIHelpTool methodsFor:'private'!
 
 askForModification
-    "ask for modification"
+    "asks for modification"
 
     modified
     ifTrue:
@@ -689,8 +693,8 @@
 !
 
 editTextView
-    "get the editTextView or nil.
-    "
+    "returns the editTextView or nil"
+
     |view|
 
     (view := builder componentAt:#helpTextView) notNil ifTrue:[
@@ -710,8 +714,8 @@
 !
 
 extractHelpSpecForClass: aClass
-    "extract the help dictionary of aClass, it current and return it
-    "
+    "extracts the help dictionary of aClass, it current and return it"
+
     |helpSpecSuperClass superHelpSpecKeys helpSpec|
 
     ((aClass class implements: specSelector)
@@ -730,8 +734,8 @@
 !
 
 findHelpSpecForKey: aHelpKey
-    "find the help spec class including aHelpKey in its help dictionary and make it current
-    "
+    "finds the help spec class including aHelpKey in its help dictionary and make it current"
+
     |dictTemp|
 
     aHelpKey isNil ifTrue: [^nil].
@@ -757,8 +761,8 @@
 !
 
 getHelpSpecClassFromClass:aClass
-    "get application class keeping the associated help text or nil
-    "
+    "returns application class keeping the associated help text or nil"
+
     |cls|
 
     ((cls := self resolveName:aClass) notNil and:[cls respondsTo: #helpSpecClass]) ifTrue:[
@@ -781,7 +785,7 @@
 !
 
 installHelpSpecOnClass:aClass
-    "save the help dicts in aClass which is subclass of ApplicationModel"
+    "saves the help dicts in aClass which is subclass of ApplicationModel"
 
     |cls src helpSpec|
 
@@ -867,8 +871,8 @@
 !
 
 installHelpSpecsOnClass:aClass
-    "save the help dicts on aClass and its superclasses which are subclasses of ApplicationModel
-    "
+    "saves the help dicts on aClass and its superclasses which are subclasses of ApplicationModel"
+
     |cls helpSpecClasses|
 
     cls := self getHelpSpecClassFromClass:aClass.
@@ -895,7 +899,7 @@
 !
 
 resourceMessage: aString
-    "extract from aString the specClass and the specSelector"
+    "extracts from aString the specClass and the specSelector"
 
     (aString notNil and: [self askForModification]) 
     ifTrue:
@@ -916,22 +920,22 @@
 !
 
 updateList
-    "update the list channel from dictionary
-    "
+    "updates the list channel from dictionary"
+
     self listChannel value: dictionary keys asSortedCollection
 ! !
 
 !UIHelpTool methodsFor:'selection'!
 
 listSelection
-    "returns current selection
-    "
+    "returns current selection"
+
     ^ listSelection
 !
 
 listSelection:aSelection
-    "current selection changed
-    "
+    "sets current selection"
+
     |txt view sel|
 
     aSelection isNil 
@@ -976,14 +980,14 @@
 !UIHelpTool methodsFor:'startup / release'!
 
 closeRequest
-    "before closing the help tool, ask for permission
-    "
+    "asks for permission before closing"
+
     (self masterApplication isNil and:[self askForModification]) ifTrue:[super closeRequest]
 !
 
 initialize
-    "initialize instance variables
-    "
+    "initializes instance variables"
+
     super initialize.
 
     specSelector := #helpSpec.
@@ -994,7 +998,7 @@
 !
 
 loadFromMessage:aString
-    "load a spec from class and selector"
+    "loads a help spec by evaluating aString"
 
     (aString notNil and: [self askForModification]) 
     ifTrue:
@@ -1015,15 +1019,14 @@
 !
 
 openInterface:aSymbol
-    "do not open as stand alone
-    "
+    "do not open as stand alone"
+
 
    
 !
 
 openOnClass:aClass
-    "open the UIHelpTool on aClass
-    "
+    "opens the UIHelpTool on aClass"
 
     super openInterface: #windowSpecForStandAlone.
     self masterApplication isNil ifTrue: [(builder componentAt: #RemoveButton) beInvisible].
@@ -1034,8 +1037,8 @@
 !UIHelpTool methodsFor:'user actions'!
 
 accept
-    "accept the help text
-    "
+    "accepts the help text"
+
     |view key txt list listChgd|   
 
     (listSelection size == 0 or:[(view := self editTextView) isNil]) ifFalse:[
@@ -1059,8 +1062,8 @@
 !
 
 doAdd
-    "add help key
-    "
+    "adds a help key"
+
     |helpKey|
     (helpKey := (builder componentAt: #helpKeyInputField asSymbol) contents) size > 0
     ifTrue:
@@ -1075,8 +1078,8 @@
 !
 
 doDelete
-    "delete selected help key
-    "    
+    "deletes the selected help key"
+
     listSelection notNil
     ifTrue:
     [
@@ -1093,21 +1096,23 @@
 !
 
 doLoad
-    "open a Resource Selection Browser in order to get a resource message"
+    "opens a Resource Selection Browser in order to get a resource message"
 
     self loadFromMessage: 
         (ResourceSelectionBrowser
-            request: 'Load ', self class resourceType asUppercaseFirst, ' Spec From Class'
+            request: 'Load Help Spec From Class'
             onSuperclass: nil
             andClass: specClass
-            andSelector: specSelector ? self class resourceType
-            withResourceTypes: (Array with: self class resourceType))
+            andSelector: specSelector ? #help
+            withResourceTypes: (Array with: #help)).
+
+    self updateInfoLabel
 
 !
 
 doNew
-    "reset the help tool
-    "
+    "resets the help tool"
+
     specClass := listSelection := nil.
     self dictionary: nil.
     self dictionaries: nil.
@@ -1116,8 +1121,8 @@
 !
 
 doReload
-    "reload the help dictionaries
-    "
+    "reloads the help dictionaries"
+
     |oldSel model|
 
     model  := self listModel.
@@ -1130,8 +1135,8 @@
 !
 
 doRemove
-    "remove selected help key
-    "
+    "removes the selected help key"
+
     listSelection notNil
     ifTrue:
     [
@@ -1146,8 +1151,8 @@
 !
 
 doSave
-    "save the help dictionaries
-    "
+    "saves the help dictionaries on specClass"
+
     self installHelpSpecsOnClass:specClass
 ! !