--- a/UIHelpTool.st Thu Oct 30 16:48:51 1997 +0100
+++ b/UIHelpTool.st Thu Oct 30 16:49:16 1997 +0100
@@ -13,7 +13,8 @@
ApplicationModel subclass:#UIHelpTool
- instanceVariableNames:'specClass dictionary listSelection maxCharsPerLine modifiedHolder'
+ instanceVariableNames:'isModified specClass dictionary listSelection maxCharsPerLine
+ modifiedHolder'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -107,8 +108,8 @@
#(
#(#MenuItem
- #'label:' 'new key ...'
- #'value:' #newKey
+ #'label:' 'save as ...'
+ #'value:' #saveAs
)
#(#MenuItem
#'label:' '-'
@@ -208,11 +209,12 @@
#'window:'
#(#WindowSpec
#'name:' 'HelpTool'
- #'layout:' #(#LayoutFrame 176 0 150 0 771 0 647 0)
+ #'layout:' #(#LayoutFrame 219 0 193 0 814 0 690 0)
#'label:' 'HelpTool'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1160 870)
- #'bounds:' #(#Rectangle 176 150 772 648)
+ #'bounds:' #(#Rectangle 219 193 815 691)
+ #'usePreferredExtent:' false
)
#'component:'
#(#SpecCollection
@@ -250,13 +252,11 @@
)
)
)
- #'handles:' #(#Any 0.5 1.0)
+ #'handles:' #(#Any 0.647651 1.0)
)
)
)
)
-
- "Modified: / 27.10.1997 / 00:55:35 / cg"
!
windowSpec
@@ -355,7 +355,8 @@
"
|help|
- specClass := self applicationClassAssociatedWith:aClass.
+ specClass := self applicationClassAssociatedWith:aClass.
+ isModified := false.
(specClass respondsTo:#helpSpec) ifTrue:[
help := specClass helpSpec
@@ -410,7 +411,8 @@
(dictionary at:key ifAbsent:nil) isNil ifTrue:[
list add:key.
].
- dictionary at:key put:txt
+ dictionary at:key put:txt.
+ isModified := true.
]
!
@@ -461,9 +463,10 @@
Compiler compile:(src contents)
forClass:cls class
- inCategory:'help specs'
+ inCategory:'help specs'.
- "Modified: / 26.10.1997 / 23:01:44 / cg"
+ isModified := false.
+
! !
!UIHelpTool methodsFor:'aspects'!
@@ -500,29 +503,12 @@
"
super initialize.
dictionary := IdentityDictionary new.
+ isModified := false.
+
! !
!UIHelpTool methodsFor:'menu actions'!
-newKey
- |k sym|
-
- k := Dialog request:'name of new:'.
- k size > 0 ifTrue:[
- ((dictionary includesKey:k)
- or:[(sym := k asSymbolIfInterned) notNil
- and:[dictionary includesKey:sym]])
- ifTrue:[
- ^ self warn:'key is already present.'.
- ].
- dictionary at:k asSymbol put:''.
- self updateList
- ].
-
- "Created: / 27.10.1997 / 01:48:48 / cg"
- "Modified: / 27.10.1997 / 02:24:30 / cg"
-!
-
removeKey
|k sym|
@@ -538,11 +524,32 @@
dictionary removeKey:sym ifAbsent:nil.
].
dictionary removeKey:k ifAbsent:nil.
+ isModified := true.
self updateList
].
"Created: / 27.10.1997 / 01:48:48 / cg"
"Modified: / 27.10.1997 / 02:25:30 / cg"
+!
+
+saveAs
+ |key new|
+
+ key := Dialog request:'save under key:' initialAnswer:(listSelection ? '').
+ key := key withoutSeparators.
+
+ key size ~~ 0 ifTrue:[
+ key := key asSymbol.
+ new := (dictionary at:key ifAbsent:nil) isNil.
+
+ dictionary at:key put:(self editTextView contents asString).
+
+ new ifTrue:[
+ self updateList
+ ].
+ isModified := true.
+ self listModel value:key.
+ ].
! !
!UIHelpTool methodsFor:'private'!
@@ -583,6 +590,10 @@
^ cls
+!
+
+isModified
+ ^ isModified
! !
!UIHelpTool methodsFor:'selection'!
@@ -623,7 +634,7 @@
txt := dictionary at:(listSelection asSymbol) ifAbsent:nil.
(txt isNil or:[maxCharsPerLine isNil]) ifFalse:[
- txt := UIPainter convertString:(txt asString) maxLineSize:maxCharsPerLine.
+ txt := UIPainter convertString:(txt asString) maxLineSize:maxCharsPerLine skipLineFeed:false.
]
].
view contents:txt.
@@ -632,6 +643,18 @@
! !
+!UIHelpTool methodsFor:'startup / release'!
+
+closeRequest
+
+ (isModified and:[self masterApplication isNil]) ifTrue:[
+ (self confirm:'quit without without saving your modifications ?') ifFalse:[
+ ^ self
+ ]
+ ].
+ ^ super closeRequest.
+! !
+
!UIHelpTool methodsFor:'user interactions'!
doFromClass
@@ -678,6 +701,8 @@
model value:nil.
self helpSpecFrom:specClass.
model value:oldSel.
+ isModified := false.
+
! !
!UIHelpTool class methodsFor:'documentation'!