UIHelpTool.st
changeset 700 2aae4f3b6526
parent 696 e91402372900
child 701 bcd65f75ade4
--- a/UIHelpTool.st	Thu Mar 05 23:18:15 1998 +0100
+++ b/UIHelpTool.st	Thu Mar 05 23:30:36 1998 +0100
@@ -127,11 +127,11 @@
           #window: 
            #(#WindowSpec
               #name: 'HelpTool'
-              #layout: #(#LayoutFrame 59 0 376 0 344 0 646 0)
+              #layout: #(#LayoutFrame 90 0 295 0 375 0 565 0)
               #label: 'unnamed canvas'
               #min: #(#Point 10 10)
               #max: #(#Point 1160 870)
-              #bounds: #(#Rectangle 59 376 345 647)
+              #bounds: #(#Rectangle 90 295 376 566)
               #usePreferredExtent: false
           )
           #component: 
@@ -146,6 +146,7 @@
                     #model: #listModel
                     #hasHorizontalScrollBar: true
                     #hasVerticalScrollBar: true
+                    #miniScrollerHorizontal: true
                     #useIndex: false
                     #sequenceList: #listChannel
                 )
@@ -197,6 +198,8 @@
                     #model: #selectionOfHelpSpecClass
                     #hasHorizontalScrollBar: true
                     #hasVerticalScrollBar: true
+                    #miniScrollerHorizontal: true
+                    #miniScrollerVertical: true
                     #valueChangeSelector: #helpSpecClassSelected
                     #useIndex: false
                     #sequenceList: #listOfHelpSpecClasses
@@ -327,7 +330,7 @@
     "set the value of the instance variable 'dictionary' (automatically generated)"
 
     (dictionary := aDictionary) isNil ifTrue:[
-        dictionary := IdentityDictionary new.
+        dictionary := Dictionary new.
     ].
     self updateList
 !
@@ -355,12 +358,19 @@
     |help|
 
     isModified := false.
-    dictionary   := IdentityDictionary new.
-    dictionaries := IdentityDictionary new.
+    specClass notNil
+    ifTrue:
+    [   
+        dictionary   := Dictionary new.
+        dictionaries := Dictionary new.
+    ].
     specClass  := self applicationClassAssociatedWith:aClass.
-    specClass isClass 
+    (specClass isClass and: [specClass isLoaded])
     ifTrue: 
-    [
+    [                                               
+        (specClass class implements:#helpSpec) ifFalse:[
+            dictionaries at: specClass name put: dictionary 
+        ].
         self listOfHelpSpecClasses contents: (specClass withAllSuperclasses reverse collect: [:cls| cls name]).
         self listOfHelpSpecClasses removeAll: (ApplicationModel withAllSuperclasses collect: [:cls| cls name]).
         self selectionOfHelpSpecClass value: specClass name. 
@@ -368,14 +378,19 @@
                 (self listOfHelpSpecClasses value indexOf: specClass name).
         self helpSpecClassSelected.
     ].
-    (specClass respondsTo:#helpSpec) ifTrue:[
-        help := specClass helpSpec
-    ] ifFalse:[
-        specClass := nil
-    ].
+
     self updateList
 !
 
+isModified
+    ^ isModified
+!
+
+isModified: aBoolean
+
+    isModified := aBoolean
+!
+
 modifiedHolder:aValueHolder
     "set the value holder set to true in case of modifying attributes
     "
@@ -414,7 +429,7 @@
 
         (listChgd := (dictionary at:key ifAbsent:nil) isNil) ifTrue:[
             list add:key.
-        ].          
+        ].             
         dictionary at:key put:txt.
 
         listChgd ifTrue:[
@@ -446,7 +461,9 @@
 helpSpecClassSelected
 
     |clsName|
+
     clsName := self selectionOfHelpSpecClass value.
+
     (dictionary := dictionaries at: clsName ifAbsent: nil) isNil
     ifTrue:
     [        
@@ -454,18 +471,28 @@
     ].
 
     self updateList.
+
     listSelection notNil
-        ifTrue: [(dictionary keys includes: listSelection asSymbol)
-        ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: 
-        (self listChannel value indexOf: (builder componentAt: #helpKeyInputField) contents)]
-        ifFalse: [(builder componentAt: #listOfHelpKeysView) selection: nil]].
-    self editTextView contents: ''
+    ifTrue: 
+    [
+        (dictionary keys includes: listSelection asSymbol)
+            ifTrue: [(builder componentAt: #listOfHelpKeysView) selection: 
+                     (self listChannel value indexOf: (builder componentAt: #helpKeyInputField) contents)]
+            ifFalse: [(builder componentAt: #listOfHelpKeysView) selection: nil].
+    ].
+    listSelection notNil
+    ifTrue: 
+    [
+        self editTextView contents: (dictionary at: listSelection asSymbol ifAbsent: '')
+    ]
+
+
 !
 
 installHelpSpecInto:aClass
     "install help text
     "
-    |cls src superHelpSpecKeys helpSpec mayRemoveHelpSpecSelector|
+    |cls src helpSpec|
 
     cls := self applicationClassAssociatedWith:aClass.
 
@@ -473,20 +500,41 @@
         ^ self information:'No application class defined!!'.
     ].
 
-    aClass == cls name 
-        ifTrue: [cls allSuperclasses value do: [:c| self installHelpSpecInto:c]. isModified := true].
+    aClass = cls name asString       
+        ifTrue: [self listOfHelpSpecClasses value do: [:c| c ~~ cls name ifTrue: [self installHelpSpecInto: (Smalltalk at: c)]. isModified := true]].
 
     isModified not ifTrue:[
         ^nil
     ].
 
-    (cls superclass respondsTo: #helpSpec) 
-        ifTrue:  [superHelpSpecKeys := cls superclass helpSpec keys. mayRemoveHelpSpecSelector := true]
-        ifFalse: [superHelpSpecKeys := IdentityDictionary new. mayRemoveHelpSpecSelector := false].
+    helpSpec := dictionaries at: cls name ifAbsent: [dictionary].
+
+    (cls class implements: #helpSpec) 
+    ifTrue: 
+    [
+        |superclassHelpKeys implementedHelpSpec hasChanged|
+        implementedHelpSpec := Dictionary new.
+        superclassHelpKeys := (cls superclass respondsTo: #helpSpec)
+            ifTrue:  [cls superclass helpSpec keys]
+            ifFalse: [Array new].
+
+        cls helpSpec associationsDo: [:h| (superclassHelpKeys includes: h key) 
+            ifFalse: [implementedHelpSpec at: h key put: h value]].
 
-    helpSpec := dictionaries at: cls name ifAbsent: [^nil].
+        hasChanged := false.
+        implementedHelpSpec associationsDo: [:h| (helpSpec            includesAssociation: h) ifFalse: [hasChanged := true]].
+        helpSpec            associationsDo: [:h| (implementedHelpSpec includesAssociation: h) ifFalse: [hasChanged := true]].
+
+        (implementedHelpSpec notEmpty and: [hasChanged and:
+        [DialogBox confirm: 'Class ', cls name asBoldText, ' already implements\a menu spec!!\\Do only replace, if you have removed\help keys in an existing help spec.\' withCRs yesLabel: ' Merge ' noLabel: ' Replace ']])
+        ifTrue:
+        [
+             implementedHelpSpec associationsDo: [:h| helpSpec at: h key put: h value].
+        ]
+    ].
+
     helpSpec isEmpty ifTrue:[
-        mayRemoveHelpSpecSelector ifTrue: [cls class removeSelector: #helpSpec].
+        (cls superclass respondsTo: #helpSpec) ifTrue: [cls class removeSelector: #helpSpec].
         ^nil
     ].
 
@@ -528,6 +576,7 @@
 
     isModified := false.
 
+
 !
 
 remove
@@ -590,8 +639,8 @@
     "setup instance attributes
     "
     super initialize.
-    dictionary   := IdentityDictionary new.
-    dictionaries := IdentityDictionary new.
+    dictionary   := Dictionary new.
+    dictionaries := Dictionary new.
     isModified := false.
 
 ! !
@@ -628,23 +677,23 @@
     ifTrue:
     [                  
         superHelpSpecKeys := helpSpecSuperClass helpSpec keys.
-        helpSpec := IdentityDictionary new.
+        helpSpec := Dictionary new.
         aClass helpSpec associationsDo:
         [:asso|
             (superHelpSpecKeys includes: asso key) ifFalse: [helpSpec at: asso key put: asso value]
         ].          
         ^dictionary := helpSpec
     ].
-    ^dictionary := IdentityDictionary new 
+    ^dictionary := Dictionary new 
 !
 
 findHelpSpecForKey: aHelpKey
     "update list from dictionary
     "
-    |helpSpecClass superHelpSpecKeys helpSpec|
+    |dictTemp helpSpecClass superHelpSpecKeys helpSpec|
 
     aHelpKey isNil ifTrue: [^nil].
-
+    dictTemp := dictionary.
     self listOfHelpSpecClasses value do:
     [:clsName|            
         (dictionary := dictionaries at: clsName ifAbsent: nil) isNil
@@ -660,6 +709,7 @@
                 (self listOfHelpSpecClasses value indexOf: clsName).
         ]
     ].
+    dictionary := dictTemp
 
 
 !
@@ -685,10 +735,6 @@
   ^ cls
 
 
-!
-
-isModified
-    ^ isModified
 ! !
 
 !UIHelpTool methodsFor:'selection'!