--- a/UIHelpTool.st Mon Feb 13 09:50:52 2006 +0100
+++ b/UIHelpTool.st Mon Feb 13 09:51:00 2006 +0100
@@ -87,12 +87,6 @@
"opens a Help Tool on aClass
"
^ self openOnClass:aClass andSelector:#helpSpec
-!
-
-openOnClass:aClass andSelector: aSelector
- "opens a Help Tool on aClass and aSelector
- "
- ^ self new openOnClass:aClass andSelector:aSelector
! !
!UIHelpTool class methodsFor:'constants'!
@@ -189,7 +183,7 @@
label: 'UIHelpTool'
name: 'UIHelpTool'
min: (Point 10 10)
- bounds: (Rectangle 14 46 475 339)
+ bounds: (Rectangle 0 0 461 293)
)
component:
(SpecCollection
@@ -197,6 +191,7 @@
(VariableVerticalPanelSpec
name: 'PanelVrt'
layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+ activeHelpKey: foo
component:
(SpecCollection
collection: (
@@ -452,6 +447,14 @@
(Menu
(
(MenuItem
+ label: 'New'
+ itemValue: doNew
+ translateLabel: true
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
activeHelpKey: fileLoad
label: 'Load...'
itemValue: doLoad
@@ -464,11 +467,6 @@
translateLabel: true
)
(MenuItem
- label: 'New'
- itemValue: doNew
- translateLabel: true
- )
- (MenuItem
label: '-'
)
(MenuItem
@@ -483,17 +481,17 @@
)
)
(MenuItem
- label: 'History'
- translateLabel: true
- submenuChannel: menuHistory
- )
- (MenuItem
label: 'Edit'
translateLabel: true
submenuChannel: keyItemMenu
keepLinkedMenu: true
)
(MenuItem
+ label: 'History'
+ translateLabel: true
+ submenuChannel: menuHistory
+ )
+ (MenuItem
label: 'Help'
translateLabel: true
startGroup: right
@@ -676,32 +674,32 @@
root := classItemList first.
root isUnspecified ifTrue:[ mergeItems := root children ]
- ifFalse:[ mergeItems := nil ].
+ ifFalse:[ mergeItems := nil ].
- self buildFromClass:aClass.
+ self loadFromClass:aClass.
mergeItems size ~~ 0 ifTrue:[
- root := classItemList first.
+ root := classItemList first.
- mergeItems do:[:anItem| |item hkey|
- hkey := anItem helpKey.
- item := root detectItemWithKey:hkey.
+ mergeItems do:[:anItem| |item hkey|
+ hkey := anItem helpKey.
+ item := root detectItemWithKey:hkey.
- item isNil ifTrue:[
- item := KeyItem helpKey:hkey helpText:(anItem helpText).
- root add:item sortBlock:[:a :b| a label < b label ].
- ] ifFalse:[
- item helpText:(anItem helpText).
- ]
- ]
+ item isNil ifTrue:[
+ item := KeyItem helpKey:hkey helpText:(anItem helpText).
+ root add:item sortBlock:[:a :b| a label < b label ].
+ ] ifFalse:[
+ item helpText:(anItem helpText).
+ ]
+ ]
].
!
-buildFromClass:aClass
+loadFromClass:aClass
"reads the help dictionary from aClass and find remaining classes
'between' aClass and ApplicationModel
"
- |lastContents root list resource helpSpecSelector|
+ |lastContents root list helpSpecSelector|
helpSpecSelector := self specSelector.
specClass := self getHelpSpecClassFromClass:aClass.
@@ -710,8 +708,8 @@
(specClass isClass and:[specClass isLoaded]) ifTrue:[
lastContents := nil.
- resource := specClass name, ' ', helpSpecSelector.
- self addToHistory:(Association key:resource value:#'loadFromMessage:').
+
+ self addHistoryEntryForClass:specClass selector:helpSpecSelector.
specClass withAllSuperclasses reverse do:[:aClass| |value name|
lastContents isNil ifTrue:[
@@ -721,9 +719,11 @@
] ifFalse:[
root := ClassItem onClass:aClass.
- (aClass class includesSelector:helpSpecSelector) ifTrue:[
- value := aClass perform:helpSpecSelector.
+ (aClass respondsTo: helpSpecSelector) ifTrue:[
+ value := aClass perform: helpSpecSelector.
+ ].
+ value notNil ifTrue:[
value keysAndValuesDo:[:k :v| |cval|
cval := lastContents at:k ifAbsent:self.
cval = v ifFalse:[ root add:(KeyItem helpKey:k helpText:v) ].
@@ -747,14 +747,16 @@
].
!
-buildFromClass: aClass andSelector: aSelector
- "sets aSelector and reads the help dictionary from aClass
- "
+loadFromClass:aClass andSelector:aSelector
+ "reads the help dictionary from aClass"
+
+ self assert:(aClass isNil or:[aClass isClass]).
+
specSelector := aSelector.
- self buildFromClass:aClass
+ self loadFromClass:aClass
!
-buildFromHelpTool:aHelpTool
+loadFromHelpTool:aHelpTool
"build from another helpTool
"
specClass := aHelpTool specClass.
@@ -865,80 +867,32 @@
!UIHelpTool methodsFor:'private'!
-extractResourceFrom:aString
- "extracts class and selector from a resource string. On success
- an association with the key a class and the selector as value
- is returned. Otherwise nil is returned
- "
- |words newClass newSel|
+getHelpSpecClassFromClass:aClass
+ |cls|
- aString size ~~ 0 ifTrue:[
- words := aString asCollectionOfWords.
+ aClass isNil ifTrue:[^ nil].
- words size == 2 ifTrue:[
- newClass := self resolveName:(words first).
-
- (newClass isClass and:[newClass isLoaded]) ifTrue:[
- newSel := words last asSymbol.
+ cls := self resolveName:aClass.
+ cls isNil ifTrue:[ ^ nil ].
- (newClass class includesSelector:newSel) ifTrue:[
- ^ Association key:newClass value:newSel
- ].
- ].
- ].
+ cls := cls perform:#helpSpecClass ifNotUnderstood:cls.
+
+ (cls isBehavior and:[cls isLoaded]) ifTrue:[
+ ^ cls
].
^ nil
!
-getHelpSpecClassFromClass:aClass
- "oops
- "
- |cls|
-
- aClass notNil ifTrue:[
- cls := self resolveName:aClass.
-
- cls notNil ifTrue:[
- cls := cls perform:#helpSpecClass ifNotUnderstood:cls.
-
- (cls isClass and:[cls isLoaded]) ifTrue:[
- ^ cls
- ].
- ].
- ].
- ^ nil
-!
-
-loadFromMessage:aString
+loadFromMessage:classAndSelector
"Set and rebuild the specClass and specSelector from a resource string.
On success true is returned otherwise false. If the current spec is
- modified, a dialog is launched.
- "
- |association|
+ modified, a dialog is launched."
- association := self extractResourceFrom:aString.
+ self askForModification ifFalse:[ ^ false].
- association notNil ifTrue:[
- self askForModification ifTrue:[
- self buildFromClass:(association key) andSelector:(association value).
- ^ true
- ].
- ].
- ^ false
-!
-
-resourceMessage:aString
- "Set the specClass and specSelector from a resource string. On
- success true is returned otherwise false.
- "
- |association|
-
- association := self extractResourceFrom:aString.
-
- association notNil ifTrue:[
- specClass := association key.
- specSelector := association value.
- ^ true
+ classAndSelector notNil ifTrue:[
+ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector).
+ ^ true
].
^ false
!
@@ -1018,12 +972,7 @@
editModel := nil asValue.
editModel addDependent:self.
- self buildFromClass:nil.
-!
-
-openInterface:aSymbol
- "do not open as stand alone
- "
+ self loadFromClass:nil.
!
openOnClass:aClass
@@ -1035,10 +984,10 @@
openOnClass:aClass andSelector: aSelector
"opens the UIHelpTool on aClass and aSelector"
- super openInterface:#windowSpecForStandAlone.
+ self openInterface:#windowSpecForStandAlone.
- builder window label: 'Help Tool'.
- self buildFromClass:aClass andSelector:aSelector
+ builder window label:'Help Tool'.
+ self loadFromClass:aClass andSelector:aSelector
! !
!UIHelpTool methodsFor:'user actions'!
@@ -1104,8 +1053,8 @@
!
doLoad
- "opens 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 Help Spec From Class'
@@ -1122,12 +1071,12 @@
"
contentsModifiedChannel value:false.
self helpKey:nil.
- self buildFromClass:nil.
+ self loadFromClass:nil.
!
doSave
- "save the help spec to the spec-class(es)
- "
+ "save the help spec to the spec-class(es)"
+
specClass isNil ifTrue:[
self information:(resources string:'No class specified !!').
^ nil