--- a/TypeConverter.st Mon Feb 24 12:12:59 1997 +0100
+++ b/TypeConverter.st Mon Feb 24 19:05:08 1997 +0100
@@ -64,6 +64,18 @@
^ (self on:aValueHolder) numberToText
"Modified: 21.2.1997 / 18:46:11 / cg"
+!
+
+onSymbolValue:aValueHolder
+ "create and return a typeConverter, which retrieves
+ a symbol-values string representation via #value, and converts
+ a string to a symbol via #value:.
+ Useful as an editFields model, which operates on some
+ numeric value (or aspectAdaptor, which adapts to a numeric slot)"
+
+ ^ (self on:aValueHolder) symbolOrNil
+
+ "Modified: 21.2.1997 / 18:46:11 / cg"
! !
!TypeConverter methodsFor:'accessing'!
@@ -180,10 +192,45 @@
updateBlock: [:m :a :p | true]
"Modified: 21.2.1997 / 18:59:44 / cg"
+!
+
+symbolOrNil
+ "setup the converter to convert from a string to a symbol
+ and vice versa. Invalid symbols (i.e. empty) are converted to nil."
+
+ self
+ getBlock:[:model |
+ |symbolValue|
+
+ (symbolValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ '#' , symbolValue asString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value s|
+
+ string isEmpty ifTrue:[
+ value := nil
+ ] ifFalse:[
+ s := string withoutSeparators.
+ (s startsWith:'#') ifTrue:[
+ s := s copyFrom:2
+ ].
+ value := s asSymbol
+ ].
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Created: 21.2.1997 / 18:58:38 / cg"
! !
!TypeConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.1 1997-02-21 18:09:11 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.2 1997-02-24 18:05:08 ca Exp $'
! !