--- a/TypeConverter.st Sat Mar 20 16:22:42 1999 +0100
+++ b/TypeConverter.st Mon Mar 22 22:55:40 1999 +0100
@@ -220,6 +220,54 @@
!TypeConverter methodsFor:'standard converters'!
+arrayLiteralOrStringOrSymbolOrNil
+ "setup the converter to convert from a string to either a literal
+ Array, a String or a symbol and vice versa.
+ Invalid strings (i.e. empty) are converted to nil;
+ nil values are converted to an empty string.
+ This is a very special converter (for the GUI builder)
+ - probably not belonging to here"
+
+ self
+ getBlock:[:model |
+ |symbolValue|
+
+ (symbolValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ symbolValue storeString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value s|
+
+ string isEmpty ifTrue:[
+ value := nil
+ ] ifFalse:[
+ s := string withoutSeparators.
+ (s startsWith:'#(') ifTrue:[
+ value := Array readFrom:s onError:nil
+ ] ifFalse:[
+ (s startsWith:'''') ifTrue:[
+ value := String readFrom:s onError:nil
+ ] ifFalse:[
+ (s startsWith:'#') ifTrue:[
+ s := s copyFrom:2
+ ].
+ value := s asSymbol
+ ]
+ ]
+ ].
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: / 26.10.1997 / 13:50:32 / cg"
+ "Created: / 26.10.1997 / 14:01:02 / cg"
+!
+
arrayLiteralOrSymbolOrNil
"setup the converter to convert from a string to either a literal
Array or a symbol and vice versa.
@@ -447,6 +495,56 @@
"Created: 21.2.1997 / 18:58:38 / cg"
!
+numberOrStringOrSymbolOrNil
+ "setup the converter to convert from a string to either a numeric literal
+ or a symbol and vice versa.
+ Invalid strings (i.e. empty) are converted to nil;
+ nil values are converted to an empty string.
+ This is a very special converter (for the GUI builder)
+ - probably not belonging to here"
+
+ self
+ getBlock:[:model |
+ |litValue|
+
+ (litValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ litValue storeString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value s|
+
+ string isEmpty ifTrue:[
+ value := nil
+ ] ifFalse:[
+ value := Number readFrom:string onError:nil.
+ value isNil ifTrue:[
+ s := string withoutSeparators.
+ (s startsWith:'''') ifTrue:[
+ value := String readFrom:s readStream onError:nil
+ ] ifFalse:[
+ (s startsWith:'#') ifTrue:[
+ s := s copyFrom:2.
+ (s startsWith:$') ifTrue:[
+ s := s copyFrom:2 to:(s size - 1)
+ ].
+ ].
+ value := s asSymbol
+ ]
+ ]
+ ].
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: / 26.10.1997 / 13:50:32 / cg"
+ "Created: / 29.10.1997 / 15:49:26 / cg"
+!
+
numberOrSymbolOrNil
"setup the converter to convert from a string to either a numeric literal
or a symbol and vice versa.
@@ -790,5 +888,5 @@
!TypeConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.23 1999-03-09 13:18:26 tm Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.24 1999-03-22 21:55:40 cg Exp $'
! !