218 model value:value |
218 model value:value |
219 ! ! |
219 ! ! |
220 |
220 |
221 !TypeConverter methodsFor:'standard converters'! |
221 !TypeConverter methodsFor:'standard converters'! |
222 |
222 |
|
223 arrayLiteralOrStringOrSymbolOrNil |
|
224 "setup the converter to convert from a string to either a literal |
|
225 Array, a String or a symbol and vice versa. |
|
226 Invalid strings (i.e. empty) are converted to nil; |
|
227 nil values are converted to an empty string. |
|
228 This is a very special converter (for the GUI builder) |
|
229 - probably not belonging to here" |
|
230 |
|
231 self |
|
232 getBlock:[:model | |
|
233 |symbolValue| |
|
234 |
|
235 (symbolValue := model value) isNil ifTrue:[ |
|
236 String new |
|
237 ] ifFalse:[ |
|
238 symbolValue storeString |
|
239 ]] |
|
240 |
|
241 putBlock: |
|
242 [:model :string | |
|
243 |
|
244 |value s| |
|
245 |
|
246 string isEmpty ifTrue:[ |
|
247 value := nil |
|
248 ] ifFalse:[ |
|
249 s := string withoutSeparators. |
|
250 (s startsWith:'#(') ifTrue:[ |
|
251 value := Array readFrom:s onError:nil |
|
252 ] ifFalse:[ |
|
253 (s startsWith:'''') ifTrue:[ |
|
254 value := String readFrom:s onError:nil |
|
255 ] ifFalse:[ |
|
256 (s startsWith:'#') ifTrue:[ |
|
257 s := s copyFrom:2 |
|
258 ]. |
|
259 value := s asSymbol |
|
260 ] |
|
261 ] |
|
262 ]. |
|
263 model value:value] |
|
264 |
|
265 updateBlock: [:m :a :p | true] |
|
266 |
|
267 "Modified: / 26.10.1997 / 13:50:32 / cg" |
|
268 "Created: / 26.10.1997 / 14:01:02 / cg" |
|
269 ! |
|
270 |
223 arrayLiteralOrSymbolOrNil |
271 arrayLiteralOrSymbolOrNil |
224 "setup the converter to convert from a string to either a literal |
272 "setup the converter to convert from a string to either a literal |
225 Array or a symbol and vice versa. |
273 Array or a symbol and vice versa. |
226 Invalid strings (i.e. empty) are converted to nil; |
274 Invalid strings (i.e. empty) are converted to nil; |
227 nil values are converted to an empty string. |
275 nil values are converted to an empty string. |
443 model value:value] |
491 model value:value] |
444 |
492 |
445 updateBlock: [:m :a :p | true] |
493 updateBlock: [:m :a :p | true] |
446 |
494 |
447 "Created: 21.2.1997 / 18:58:38 / cg" |
495 "Created: 21.2.1997 / 18:58:38 / cg" |
|
496 ! |
|
497 |
|
498 numberOrStringOrSymbolOrNil |
|
499 "setup the converter to convert from a string to either a numeric literal |
|
500 or a symbol and vice versa. |
|
501 Invalid strings (i.e. empty) are converted to nil; |
|
502 nil values are converted to an empty string. |
|
503 This is a very special converter (for the GUI builder) |
|
504 - probably not belonging to here" |
|
505 |
|
506 self |
|
507 getBlock:[:model | |
|
508 |litValue| |
|
509 |
|
510 (litValue := model value) isNil ifTrue:[ |
|
511 String new |
|
512 ] ifFalse:[ |
|
513 litValue storeString |
|
514 ]] |
|
515 |
|
516 putBlock: |
|
517 [:model :string | |
|
518 |
|
519 |value s| |
|
520 |
|
521 string isEmpty ifTrue:[ |
|
522 value := nil |
|
523 ] ifFalse:[ |
|
524 value := Number readFrom:string onError:nil. |
|
525 value isNil ifTrue:[ |
|
526 s := string withoutSeparators. |
|
527 (s startsWith:'''') ifTrue:[ |
|
528 value := String readFrom:s readStream onError:nil |
|
529 ] ifFalse:[ |
|
530 (s startsWith:'#') ifTrue:[ |
|
531 s := s copyFrom:2. |
|
532 (s startsWith:$') ifTrue:[ |
|
533 s := s copyFrom:2 to:(s size - 1) |
|
534 ]. |
|
535 ]. |
|
536 value := s asSymbol |
|
537 ] |
|
538 ] |
|
539 ]. |
|
540 model value:value] |
|
541 |
|
542 updateBlock: [:m :a :p | true] |
|
543 |
|
544 "Modified: / 26.10.1997 / 13:50:32 / cg" |
|
545 "Created: / 29.10.1997 / 15:49:26 / cg" |
448 ! |
546 ! |
449 |
547 |
450 numberOrSymbolOrNil |
548 numberOrSymbolOrNil |
451 "setup the converter to convert from a string to either a numeric literal |
549 "setup the converter to convert from a string to either a numeric literal |
452 or a symbol and vice versa. |
550 or a symbol and vice versa. |