TypeConverter.st
author Claus Gittinger <cg@exept.de>
Tue, 17 Feb 2009 17:45:30 +0100
changeset 2602 87adcdcddc17
parent 2560 03c5e1535b9d
child 2607 2f81fde8732a
permissions -rw-r--r--
preps for pixelSize fonts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1355
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     1
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     2
 COPYRIGHT (c) 1997 eXept Software AG
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     3
              All Rights Reserved
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     4
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     5
 This software is furnished under a license and may be used
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     6
 only in accordance with the terms of that license and with the
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     8
 be provided or otherwise made available to, or used by, any
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     9
 other person.  No title to or ownership of the software is
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    10
 hereby transferred.
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    11
"
1406
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
    12
"{ Package: 'stx:libview2' }"
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
    13
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
PluggableAdaptor subclass:#TypeConverter
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    15
	instanceVariableNames:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    16
	classVariableNames:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    17
	poolDictionaries:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    18
	category:'Interface-Support-Models'
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!TypeConverter class methodsFor:'documentation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
1355
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    23
copyright
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    24
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    25
 COPYRIGHT (c) 1997 eXept Software AG
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    26
              All Rights Reserved
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    27
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    28
 This software is furnished under a license and may be used
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    29
 only in accordance with the terms of that license and with the
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    31
 be provided or otherwise made available to, or used by, any
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    32
 other person.  No title to or ownership of the software is
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    33
 hereby transferred.
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    34
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    35
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    36
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    37
!
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    38
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    41
    a typeConverter can be used as an editFields model
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    42
    (remember, that an editField expects a string in its model),
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    43
    to convert the fields string value to some object and vice versa.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    44
    Its main use is when building interfaces with inputFields,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    45
    where the datum to be entered is a non-string and you
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    46
    want to have the entered value be converted automatically.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    47
    (and vice versa, to convert the datum to a string).
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    48
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    No real new functionality is added here - all is inherited
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    from PluggableAdapter; however, some specialized instance creation
947
a5325410e4fd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
    51
    methods are added here.
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    Notice: 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        this class was implemented using protocol information
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        from alpha testers - it may not be complete or compatible to
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        the corresponding ST-80 class. 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        If you encounter any incompatibilities, please forward a note 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [author:]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        Claus Gittinger
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
examples 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    convert a number to a string:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
                                                                        [exBegin]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        |v t i|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        v := 1 asValue.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        t := HorizontalPanelView new.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        t extent:200@50.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        t horizontalLayout:#fitSpace.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        i := EditField in:t.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        i model:(TypeConverter onNumberValue:v).
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        t open.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        (Delay forSeconds:3) wait.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        v value:2.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
                                                                        [exEnd]
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    86
    convert a number to a string with range:
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    87
                                                                        [exBegin]
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    88
        |v t i|
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    89
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    90
        v := 1 asValue.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    91
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    92
        t := HorizontalPanelView new.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    93
        t extent:200@50.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    94
        t horizontalLayout:#fitSpace.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    95
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    96
        i := EditField in:t.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    97
        i model:(TypeConverter onNumberValue:v minValue:0 maxValue:100).
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    98
        t open.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    99
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   100
        (Delay forSeconds:3) wait.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   101
        v value:2.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   102
                                                                        [exEnd]
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   103
    convert a date to a string:
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   104
                                                                        [exBegin]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   105
        |d v|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   106
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   107
        v := nil asValue.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   108
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   109
        d := DialogBox new.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   110
        d addInputFieldOn:(TypeConverter onDateValue:v).
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   111
        d addOkButton.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   112
        d open.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   113
        d accepted ifTrue:[
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   114
            Transcript showCR:v value
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   115
        ]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   116
                                                                        [exEnd]
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   117
    convert with thousands:
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   118
                                                                        [exBegin]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   119
        |d v|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   120
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   121
        v := 1234567 asValue.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   122
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   123
        d := DialogBox new.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   124
        d addInputFieldOn:((TypeConverter on:v) integerWithThousandsSeparator:$').
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   125
        d addOkButton.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   126
        d open.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   127
        d accepted ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   128
            Transcript showCR:v value
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   129
        ]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   130
                                                                        [exEnd]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!TypeConverter class methodsFor:'instance creation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   136
onDateValue:aValueHolder
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   137
    "create and return a typeConverter, which retrieves
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   138
     a date via #value, and converts
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   139
     a date-string to a date via #value:.
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   140
     Useful as an editFields model, which operates on some
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   141
     date value (or aspectAdaptor, which adapts to a numeric slot)"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   142
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   143
    ^ (self on:aValueHolder) dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   144
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   145
    "Modified: 21.2.1997 / 18:46:11 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   146
    "Created: 4.3.1997 / 12:30:49 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   147
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   148
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
onNumberValue:aValueHolder
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    "create and return a typeConverter, which retrieves
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
     a values string representation via #value, and converts
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
     a number-string to a value via #value:.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     Useful as an editFields model, which operates on some
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    ^ (self on:aValueHolder) numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "Modified: 21.2.1997 / 18:46:11 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   159
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   160
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   161
onNumberValue:aValueHolder format:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   162
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   163
     a values string representation via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   164
     a number-string to a value via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   165
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   166
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   167
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   168
    ^ (self on:aValueHolder) numberToTextFormattedBy:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   169
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   170
    "Created: 4.3.1997 / 11:51:25 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   171
    "Modified: 4.3.1997 / 11:51:41 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   172
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   173
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   174
onNumberValue:aValueHolder leftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   175
    "create and return a typeConverter, which retrieves
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   176
     a values string representation via #value, and converts
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   177
     a number-string to a value via #value:.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   178
     Useful as an editFields model, which operates on some
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   179
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   180
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   181
    ^ (self on:aValueHolder) numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   182
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   183
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   184
  |m|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   185
  m := 5 asValue.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   186
  ((EditField model:(TypeConverter onNumberValue:m leftPaddedTo:2 with:$-)) width:100) openAt:(200@200).
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   187
  m inspect.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   188
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   189
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   190
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   191
onNumberValue:aValueHolder minValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   192
    "create and return a typeConverter, which retrieves
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   193
     a values string representation via #value, and converts
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   194
     a number-string to a value via #value:.
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   195
     Useful as an editFields model, which operates on some
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   196
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   197
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   198
    ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   199
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   200
    "Created: 4.3.1997 / 11:51:25 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   201
    "Modified: 4.3.1997 / 11:51:41 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   202
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   203
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   204
onNumberValue:aValueHolder postDecimalDigits:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   205
    "create and return a typeConverter, which retrieves
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   206
     a values string representation via #value, and converts
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   207
     a number-string to a value via #value:.
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   208
     Useful as an editFields model, which operates on some
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   209
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   210
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   211
    ^ (self on:aValueHolder) numberToText:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   212
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   213
    "Modified: / 21.2.1997 / 18:46:11 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   214
    "Created: / 5.12.1997 / 02:55:18 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   215
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   216
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   217
onSymbolValue:aValueHolder
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   218
    "create and return a typeConverter, which retrieves
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   219
     a symbol-values string representation via #value, and converts
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   220
     a string to a symbol via #value:.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   221
     Useful as an editFields model, which operates on some
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   222
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   223
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   224
    ^ (self on:aValueHolder) symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   225
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   226
    "Modified: 21.2.1997 / 18:46:11 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   227
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   228
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   229
onTimeValue:aValueHolder
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   230
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   231
     a time via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   232
     a time-string to a time via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   233
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   234
     date value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   235
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   236
    ^ (self on:aValueHolder) timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   237
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   238
    "Modified: 21.2.1997 / 18:46:11 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   239
    "Created: 4.3.1997 / 11:52:10 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!TypeConverter methodsFor:'accessing'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
subject
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   245
    "return the subject to be converted"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    ^ model
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
value:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "convert and change"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    self setValue:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "Created: 21.2.1997 / 18:45:39 / cg"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   258
!TypeConverter methodsFor:'input testing'!
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   259
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   260
setNumberValue: value inModel: model fromInput: string
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   261
    "for invalid numbers, the model is set to nil. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   262
     By this, the dependents are forced to update their contents
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   263
     (that is: a bad input string will lead to a cleared input field here)."
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   264
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   265
    |lastInputChar needChange|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   266
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   267
    string notEmpty ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   268
        1 to: string size - 1 do: [:i| (string at: i) isLetter ifTrue: [needChange := true]].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   269
        lastInputChar := string at: string size.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   270
        (lastInputChar isDigit not and: [lastInputChar isPrintable and: [
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   271
        (string size > 1               or: [lastInputChar ~~ $-])  and: [
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   272
        (string occurrencesOf: $.) > 1 or: [lastInputChar ~~ $.]]]]) ifTrue: [needChange := true].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   273
    ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   274
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   275
    needChange == true ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   276
        value notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   277
            model setValue:nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   278
        ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   279
            model value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   280
                model changed:#value.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   281
                ^ self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   282
            ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   283
        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   284
    ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   285
    model value:value
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   286
! !
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   287
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   288
!TypeConverter methodsFor:'standard converters'!
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   290
arrayLiteralOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   291
    "setup the converter to convert from a string to either a literal
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   292
     Array, a String or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   293
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   294
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   295
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   296
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   297
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   298
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   299
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   300
                |symbolValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   301
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   302
                (symbolValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   303
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   304
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   305
                    symbolValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   306
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   307
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   308
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   309
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   310
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   311
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   312
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   313
                string isEmptyOrNil ifTrue:[
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   314
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   315
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   316
                    s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   317
                    (s startsWith:'#(') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   318
                        value := Array readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   319
                    ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   320
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   321
                            value := String readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   322
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   323
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   324
                                s := s copyFrom:2
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   325
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   326
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   327
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   328
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   329
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   330
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   331
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   332
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   333
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   334
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   335
    "Created: / 26.10.1997 / 14:01:02 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   336
!
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   337
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   338
arrayLiteralOrSymbolOrNil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   339
    "setup the converter to convert from a string to either a literal
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   340
     Array or a symbol and vice versa. 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   341
     Invalid strings (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   342
     nil values are converted to an empty string.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   343
     This is a very special converter (for the GUI builder) 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   344
     - probably not belonging to here"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   345
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   346
    self
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   347
        getBlock:[:model |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   348
                |symbolValue|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   349
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   350
                (symbolValue := model value) isNil ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   351
                    String new
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   352
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   353
                    symbolValue isArray ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   354
                        symbolValue storeString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   355
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   356
                        '#' , symbolValue asString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   357
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   358
                ]]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   359
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   360
        putBlock:
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   361
                [:model :string |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   362
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   363
                |value s|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   364
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   365
                string isEmptyOrNil ifTrue:[
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   366
                    value := nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   367
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   368
                    s := string withoutSeparators.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   369
                    (s startsWith:'#(') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   370
                        value := Array readFrom:s onError:nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   371
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   372
                        (s startsWith:'#') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   373
                            s := s copyFrom:2
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   374
                        ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   375
                        value := s asSymbol
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   376
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   377
                ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   378
                model value:value]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   379
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   380
        updateBlock: [:m :a :p | true]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   381
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   382
    "Modified: / 26.10.1997 / 13:50:32 / cg"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   383
    "Created: / 26.10.1997 / 14:01:02 / cg"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   384
!
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   385
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   386
date
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   387
    "setup the converter to convert from a string to a date
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   388
     and vice versa. Nil is converted to todays date-string,
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   389
     likewise, an empty string is converted back to todays date."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   390
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   391
    ^ self dateWithFormat:nil orDefault:Date today
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   392
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   393
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   394
dateDDMMYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   395
    "setup the converter to convert from a string to a date formatted by printFormat
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   396
     DD-MM-YYYY; see also Date>>printFormat:"
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   397
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   398
    self dateToTextFormattedBy: #(1 2 3 $- 1 1 true)
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   399
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   400
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   401
dateMMDDYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   402
    "setup the converter to convert from a string to a date formatted by printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   403
     MM:DD:YYYY; see also Date>>printFormat:"
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   404
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   405
    self dateToTextFormattedBy: #(2 1 3 $/ 1 1 true)
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   406
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   407
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   408
dateOrNil
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   409
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   410
     and vice versa. Invalid dates are converted to nil; likewise,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   411
     a nil date is converted to an empty string."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   412
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   413
    ^ self dateWithFormat:nil orDefault:nil
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   414
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   415
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   416
dateOrNilWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   417
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   418
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   419
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   420
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   421
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   422
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   423
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   424
    "
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   425
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   426
    ^ self dateWithFormat:aFormatString orDefault:nil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   427
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   428
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   429
dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   430
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   431
     and vice versa. Nil is converted to todays date-string,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   432
     likewise, an empty string is converted back to todays date."
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   433
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   434
    ^ self dateWithFormat:nil orDefault:Date today
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   435
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   436
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   437
dateToTextFormattedBy: printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   438
    "setup the converter to convert from a string to a date formatted by printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   439
     and vice versa. Nil is converted to todays date-string,
1697
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   440
     likewise, an empty string is converted back to todays date.
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   441
     Uses the old, obsolete ST80 printFormat (see Date printFormat:)"
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   442
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   443
    ^ self dateWithFormat:printFormat orDefault:Date today
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   444
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   445
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   446
dateWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   447
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   448
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   449
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   450
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   451
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   452
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   453
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   454
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   455
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   456
    ^ self dateWithFormat:aFormatString orDefault:Date today
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   457
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   458
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   459
dateWithFormat:aFormatString orDefault:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   460
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   461
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   462
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   463
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   464
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   465
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   466
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   467
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   468
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   469
    |in out stxFormat c nDigits|
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   470
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   471
    aFormatString notNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   472
        (aFormatString includes:$%) ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   473
            "/ a new (ST/X) formatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   474
            stxFormat := aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   475
        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   476
            "/ an old (VW) formatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   477
            out := '' writeStream.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   478
            in := aFormatString readStream.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   479
            [in atEnd] whileFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   480
                c := in next.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   481
                nDigits := 1.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   482
                c == $m ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   483
                    [in peek == $m] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   484
                    nDigits == 1 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   485
                        out nextPutAll:'%M'.    "/ unpadded
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   486
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   487
                        out nextPutAll:'%m'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   488
                    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   489
                ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   490
                    c == $d ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   491
                        [in peek == $d] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   492
                        nDigits == 1 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   493
                            out nextPutAll:'%D'.    "/ unpadded
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   494
                        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   495
                            out nextPutAll:'%d'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   496
                        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   497
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   498
                        c == $y ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   499
                            [in peek == $y] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   500
                            nDigits == 2 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   501
                                out nextPutAll:'%Y'.    "/ 2 digits only
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   502
                            ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   503
                                out nextPutAll:'%y'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   504
                            ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   505
                        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   506
                            out nextPut:c.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   507
                        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   508
                    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   509
                ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   510
            ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   511
            stxFormat := out contents.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   512
        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   513
    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   514
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   515
    self
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   516
        getBlock:[:model |
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   517
                |date|
1696
7dbac9fb8894 *** empty log message ***
penk
parents: 1695
diff changeset
   518
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   519
                (date := model value) isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   520
                    date := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   521
                ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   522
                date isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   523
                    ''
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   524
                ] ifFalse:[
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   525
                    (stxFormat isNil or:[date isString]) ifTrue:[
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   526
                        date printString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   527
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   528
                        date printStringFormat:stxFormat
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   529
                    ].
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   530
                ]]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   531
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   532
        putBlock:
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   533
                [:model :string |
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   534
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   535
                |value|
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   536
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   537
                string isEmptyOrNil ifTrue:[
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   538
                    value := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   539
                ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   540
                    stxFormat isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   541
                        value := Date readFrom:string onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   542
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   543
                        value := Date readFrom:string printFormat:stxFormat onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   544
                    ]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   545
                ].
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   546
                model value:value]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   547
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   548
        updateBlock: [:m :a :p | true]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   549
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   550
1791
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   551
fileSize
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   552
    "setup the converter to convert from a fileSize string to a number
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   553
     and vice versa.
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   554
     A fileSize can have a scale of 1024 (k or kB),
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   555
     1024*1024 (m or mB), 1024*1024*1024 (g or gB)."
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   556
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   557
    self
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   558
        getBlock:[:model |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   559
                |numericValue|
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   560
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   561
                (numericValue := model value) isNumber ifFalse:[
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   562
                    String new
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   563
                ] ifTrue:[  
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   564
                    UnitConverter fileSizeStringFor:numericValue
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   565
                ]]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   566
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   567
        putBlock:
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   568
                [:model :string |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   569
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   570
                model value:(UnitConverter fileSizeFromString:string)]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   571
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   572
        updateBlock: [:m :a :p | true]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   573
!
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   574
1122
d8e73d8209d7 hexilein -> hexa
tm
parents: 1047
diff changeset
   575
hexadecimal
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   576
    "setup the converter to convert from a hexadecimal string to a number
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   577
     and vice versa."
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   578
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   579
    self
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   580
        getBlock:[:model |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   581
                |hexValue|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   582
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   583
                (hexValue := model value) isNumber ifFalse:[
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   584
                    String new
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   585
                ] ifTrue:[  
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   586
                    hexValue hexPrintString
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   587
                ]]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   588
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   589
        putBlock:
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   590
                [:model :string |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   591
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   592
                |value|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   593
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   594
                string isEmptyOrNil ifTrue:[
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   595
                    value := 0
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   596
                ] ifFalse:[     
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   597
                    value := Integer readFrom: string radix:16 onError:[0]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   598
                ].
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   599
                model value:value]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   600
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   601
        updateBlock: [:m :a :p | true]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   602
!
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   603
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   604
integerToHexTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   605
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   606
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   607
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   608
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:16 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   609
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   610
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   611
integerToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   612
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   613
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   614
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   615
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:10 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   616
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   617
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   618
integerToTextMinValue:minVal maxValue:maxVal radix:radix format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   619
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   620
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   621
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   622
    self
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   623
        getBlock:[:model |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   624
                |numericValue|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   625
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   626
                (numericValue := model value) isNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   627
                    String new
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   628
                ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   629
                    numericValue isString ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   630
                        numericValue    
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   631
                    ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   632
                        formatStringOrNil isNil ifTrue:[    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   633
                            numericValue printStringRadix:radix
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   634
                        ] ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   635
                            numericValue printfPrintString:formatStringOrNil
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   636
                        ]
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   637
                    ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   638
                ]]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   639
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   640
        putBlock:
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   641
                [:model :string |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   642
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   643
                |value c|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   644
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   645
                string isEmptyOrNil ifTrue:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   646
                    value := 0
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   647
                ] ifFalse:[
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   648
                    value := Integer readFromString:string radix:radix onError:[0]. 
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   649
                ].               
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   650
                minVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   651
                    (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   652
                    value := value max:minVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   653
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   654
                maxVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   655
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   656
                    value := value min:maxVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   657
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   658
                self setNumberValue: value inModel: model fromInput: string.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   659
                ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   660
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   661
        updateBlock: [:m :a :p | true]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   662
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   663
    "Modified: 21.2.1997 / 18:59:44 / cg"
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   664
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   665
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   666
integerWithThousandsSeparator    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   667
    ^ self integerWithThousandsSeparator:$'
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   668
"/     ^ self integerWithThousandsSeparator:(UserPreferences current thousandsSeparatorCharacter)
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   669
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   670
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   671
integerWithThousandsSeparator:sep
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   672
    "setup the converter to convert from a string to a number with thousands separator
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   673
     and vice versa."
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   674
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   675
    self
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   676
        getBlock:[:model |
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   677
                |numericValue|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   678
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   679
                (numericValue := model value) isNumber ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   680
                    String new
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   681
                ] ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   682
                    String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep].
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   683
                ]]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   684
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   685
        putBlock:
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   686
                [:model :string |
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   687
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   688
                |value s2|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   689
2559
87d81ccdf4a0 changed #integerWithThousandsSeparator:
sr
parents: 2440
diff changeset
   690
                string isEmptyOrNil ifTrue:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   691
                    value := 0
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   692
                ] ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   693
                    s2 := string reject:[:ch | ch = sep].    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   694
                    value := Number readFromString:s2 onError:[0]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   695
                ].
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   696
                model value:value]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   697
2407
d66421abe47d Avoid stc compiler warning
Stefan Vogel <sv@exept.de>
parents: 2406
diff changeset
   698
        updateBlock: [:m :a :p | true]
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   699
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   700
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   701
literal
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   702
    "setup the converter to convert from a string to a literal
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   703
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   704
     nil values are converted to an empty string.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   705
     true, false, Numbers are parsed"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   706
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   707
    self
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   708
        getBlock:[:model |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   709
                |val s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   710
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   711
                val := model value.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   712
                (val isLiteral and:[val notNil]) ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   713
                    val isSymbol ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   714
                        "print 'special' symbols as symbols i.e. as #'symbol'"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   715
                        (s := val storeString) second == $' ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   716
                            s
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   717
                        ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   718
                            val printString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   719
                        ]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   720
                    ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   721
                        val storeString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   722
                    ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   723
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   724
                    ''.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   725
                ]]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   726
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   727
        putBlock:
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   728
                [:model :string |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   729
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   730
                |value s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   731
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   732
                string size == 0 ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   733
                    value := nil
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   734
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   735
                    s := string withoutSeparators.
1465
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   736
                    "be careful, #readFrom:onError: returns nil for an undefined identifier"
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   737
                    s = 'true' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   738
                        value := true.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   739
                    ] ifFalse:[s = 'false' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   740
                        value := false.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   741
                    ] ifFalse:[s = 'nil' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   742
                        value := nil.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   743
                    ] ifFalse:[s first isLetter ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   744
                        value := s asSymbol.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   745
                    ] ifFalse:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   746
                        value := Object readFrom:s onError:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   747
                            s asSymbol
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   748
                        ].
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   749
                    ]]]].
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   750
                ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   751
                model value:value]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   752
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   753
        updateBlock: [:m :a :p | true]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   754
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   755
    "Created: / 21.2.1997 / 18:58:38 / cg"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   756
    "Modified: / 26.5.1998 / 15:06:06 / cg"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   757
!
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   758
508
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   759
number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   760
    "setup the converter to convert from a string to a number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   761
     and vice versa. Invalid numbers are converted to nil."
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   762
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   763
    self numberToText
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   764
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   765
    "Created: 4.4.1997 / 12:46:14 / cg"
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   766
!
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   767
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
numberOrNil
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
     and vice versa. Invalid numbers are converted to nil."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   772
    self objectOrNilOfType:Number
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   774
    "Modified: / 12-01-2008 / 19:08:42 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   777
numberOrNilToTextMinValue:minVal maxValue:maxVal
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   778
    "setup the converter to convert from a string to a number or nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   779
     and vice versa, but clamping the number into the range."
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   780
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   781
    self numberOrNilToTextMinValue:minVal maxValue:maxVal format:nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   782
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   783
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   784
numberOrNilToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   785
    "setup the converter to convert from a string to a number or nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   786
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   787
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   788
    self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   789
        getBlock:[:model |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   790
                |numericValue|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   791
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   792
                (numericValue := model value) isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   793
                    String new
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   794
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   795
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   796
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   797
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   798
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   799
                    ]
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   800
                ]]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   801
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   802
        putBlock:
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   803
                [:model :string |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   804
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   805
                |value c|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   806
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   807
                (string isEmptyOrNil or:[string isBlank]) ifTrue:[
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   808
                    value := nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   809
                ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   810
                    value := Number readFromString:string onError:[nil]. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   811
                    value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   812
                        
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   813
                    ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   814
                        minVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   815
                            (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   816
                            value := value max:minVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   817
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   818
                        maxVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   819
                            (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   820
                            value := value min:maxVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   821
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   822
                    ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   823
                ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   824
                self setNumberValue: value inModel: model fromInput: string.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   825
                ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   826
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   827
        updateBlock: [:m :a :p | true]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   828
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   829
    "Modified: 21.2.1997 / 18:59:44 / cg"
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   830
!
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   831
1335
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   832
numberOrPointOrNil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   833
    "setup the converter to convert from a string to a number or point
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   834
     and vice versa. Invalid numbers/points are converted to nil."
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   835
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   836
    self
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   837
        getBlock:[:model |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   838
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   839
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   840
                (value := model value) isNil ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   841
                    String new
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   842
                ] ifFalse:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   843
                    value printString
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   844
                ]]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   845
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   846
        putBlock:
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   847
                [:model :string |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   848
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   849
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   850
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   851
                string size > 0 ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   852
                    value := Point readFrom:string onError:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   853
                        Number readFrom:string onError:nil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   854
                    ]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   855
                ]. 
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   856
                model value:value]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   857
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   858
        updateBlock: [:m :a :p | true]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   859
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   860
    "Created: / 5.2.2000 / 01:26:48 / cg"
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   861
!
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   862
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   863
numberOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   864
    "setup the converter to convert from a string to either a numeric literal
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   865
     or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   866
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   867
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   868
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   869
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   870
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   871
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   872
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   873
                |litValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   874
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   875
                (litValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   876
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   877
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   878
                    litValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   879
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   880
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   881
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   882
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   883
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   884
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   885
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   886
                string isEmptyOrNil ifTrue:[
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   887
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   888
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   889
                    value := Number readFrom:string onError:nil.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   890
                    value isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   891
                        s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   892
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   893
                            value := String readFrom:s readStream onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   894
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   895
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   896
                                s := s copyFrom:2.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   897
                                (s startsWith:$') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   898
                                    s := s copyFrom:2 to:(s size - 1)
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   899
                                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   900
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   901
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   902
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   903
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   904
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   905
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   906
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   907
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   908
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   909
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   910
    "Created: / 29.10.1997 / 15:49:26 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   911
!
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   912
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   913
numberOrSymbolOrNil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   914
    "setup the converter to convert from a string to either a numeric literal
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   915
     or a symbol and vice versa. 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   916
     Invalid strings (i.e. empty) are converted to nil;
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   917
     nil values are converted to an empty string.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   918
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   919
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   920
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   921
    self
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   922
        getBlock:[:model |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   923
                |litValue|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   924
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   925
                (litValue := model value) isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   926
                    String new
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   927
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   928
                    litValue storeString
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   929
                ]]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   930
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   931
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   932
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   933
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   934
                |value s|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   935
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   936
                string isEmptyOrNil ifTrue:[
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   937
                    value := nil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   938
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   939
                    value := Number readFrom:string onError:nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   940
                    value isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   941
                        s := string withoutSeparators.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   942
                        (s startsWith:'#') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   943
                            s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   944
                            (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   945
                                s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   946
                            ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   947
                        ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   948
                        value := s asSymbol
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   949
                    ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   950
                ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   951
                model value:value]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   952
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   953
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   954
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   955
    "Modified: / 26.10.1997 / 13:50:32 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   956
    "Created: / 29.10.1997 / 15:49:26 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   957
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   958
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
    "setup the converter to convert from a string to a number
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   961
     and vice versa."
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   967
                (numericValue := model value) isNumber ifFalse:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   969
                ] ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
                    numericValue printString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   978
                string isEmptyOrNil ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
                    value := 0
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
                ] ifFalse:[
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
   981
                    value := Number readFromString: string onError:[0]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   987
    "Created: / 21.2.1997 / 18:57:05 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   988
    "Modified: / 29.10.1997 / 15:49:21 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   991
numberToText:numberOfPostDecimals
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   992
    "setup the converter to convert from a string to a number
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   993
     and vice versa."
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   994
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   995
    self
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   996
        getBlock:[:model |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   997
                |numericValue|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   998
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   999
                (numericValue := model value) isNumber ifFalse:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1000
                    String new
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1001
                ] ifTrue:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1002
                    (numericValue asFixedPoint:numberOfPostDecimals) printString
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1003
                ]]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1004
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1005
        putBlock:
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1006
                [:model :string |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1007
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1008
                |value|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1009
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1010
                string isEmptyOrNil ifTrue:[
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1011
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1012
                ] ifFalse:[     
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1013
                    value := Number readFromString:string onError:[0]
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1014
                ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1015
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1016
                ]
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1017
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1018
        updateBlock: [:m :a :p | true]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1019
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1020
    "Created: / 5.12.1997 / 02:54:13 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1021
    "Modified: / 5.12.1997 / 18:21:04 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1022
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1023
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
numberToTextFormattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
     and vice versa, using formatString.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
     The formatString is currently ignored when numbers are converted
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
     from a string."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
                (numericValue := model value) isNil ifTrue:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
                    String new
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
                ] ifFalse:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
                    PrintConverter print:numericValue formattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1045
                string isEmptyOrNil ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1047
                ] ifFalse:[          
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1048
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
    "Modified: 21.2.1997 / 18:59:44 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1055
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1056
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1057
numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1058
    "setup the converter to convert from a string to a number
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1059
     and vice versa, using formatString.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1060
     The formatString is currently ignored when numbers are converted
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1061
     from a string."
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1062
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1063
    self
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1064
        getBlock:[:model |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1065
                |numericValue|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1066
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1067
                (numericValue := model value) isNil ifTrue:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1068
                    String new
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1069
                ] ifFalse:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1070
                    numericValue printStringLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1071
                ]]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1072
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1073
        putBlock:
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1074
                [:model :string |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1075
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1076
                |value|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1077
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1078
                string isEmptyOrNil ifTrue:[
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1079
                    value := 0
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1080
                ] ifFalse:[          
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1081
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1082
                ].
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1083
                model value:value]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1084
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1085
        updateBlock: [:m :a :p | true]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1086
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1087
    "Modified: 21.2.1997 / 18:59:44 / cg"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1088
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1089
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1090
numberToTextMinValue:minVal maxValue:maxVal
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1091
    "setup the converter to convert from a string to a number
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1092
     and vice versa, but clamping the number into the range."
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1093
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1094
    self numberToTextMinValue:minVal maxValue:maxVal format:nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1095
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1096
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1097
numberToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1098
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1099
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1100
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1101
    self
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1102
        getBlock:[:model |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1103
                |numericValue|
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1104
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1105
                (numericValue := model value) isNil ifTrue:[
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1106
                    String new
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1107
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1108
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1109
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1110
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1111
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1112
                    ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1113
                ]]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1114
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1115
        putBlock:
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1116
                [:model :string |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1117
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1118
                |value c|
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1119
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1120
                string isEmptyOrNil ifTrue:[
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1121
                    value := 0
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1122
                ] ifFalse:[
997
9871b863dc3a it does invoke a debugger for wrong inputs
tz
parents: 947
diff changeset
  1123
                    value := Number readFromString: string onError:[0]. 
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1124
                ].               
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1125
                minVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1126
                    (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1127
                    value := value max:minVal.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1128
                ].
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1129
                maxVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1130
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
944
4ef99f8da24f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1131
                    value := value min:maxVal.
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1132
                ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1133
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1134
                ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1135
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1136
        updateBlock: [:m :a :p | true]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1137
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1138
    "Modified: 21.2.1997 / 18:59:44 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1139
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1140
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1141
objectOrNilOfType:timeOrDateClass
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1142
    "common code for timeOrNil, dateOrNil and timeStampOrNil"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1143
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1144
    self
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1145
        getBlock:[:model |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1146
                |timeOrDate|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1147
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1148
                (timeOrDate := model value) isNil ifTrue:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1149
                    ''
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1150
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1151
                    timeOrDate printString
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1152
                ]]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1153
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1154
        putBlock:
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1155
                [:model :string |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1156
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1157
                |value|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1158
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1159
                string isEmptyOrNil ifTrue:[
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1160
                    value := nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1161
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1162
                    value := timeOrDateClass readFrom:string onError:nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1163
                ].
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1164
                model value:value]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1165
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1166
        updateBlock: [:m :a :p | true]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1167
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1168
    "Created: / 12-01-2008 / 19:05:18 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1169
!
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1170
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1171
smalltalkObject
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1172
    "setup the converter to convert from a string to any smalltalk object
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1173
     and vice versa. The string used is the objects storeString.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1174
     Invalid strings (i.e. empty) are converted to nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1175
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1176
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1177
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1178
    ^ self smalltalkObjectWithClass:Object
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1179
!
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1180
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1181
smalltalkObjectOrNil
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1182
    "setup the converter to convert from a string to any smalltalk object
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1183
     and vice versa. The string used is the objects storeString.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1184
     Invalid strings (i.e. empty) are converted to nil.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1185
     This is a very special converter (for the GUI builder) 
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1186
     - probably not belonging to here"
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1187
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1188
    ^ self smalltalkObjectOrNilWithClass:Object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1189
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1190
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1191
smalltalkObjectOrNilWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1192
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1193
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1194
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1195
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1196
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1197
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1198
    self
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1199
        getBlock:[:model | |v s|
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1200
                     v := model value.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1201
                     v isNil ifTrue:[
1406
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1202
                        s := 'nil'
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1203
                     ] ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1204
                            s := v storeString.
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1205
                            (v isString or:[v isNumber]) ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1206
                                s := s , ' "' , v class name , '" '
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1207
                            ]
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1208
                     ].
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1209
                     s
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1210
                 ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1211
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1212
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1213
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1214
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1215
                    |value|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1216
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1217
                    string size > 0 ifTrue:[
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1218
                        value := classOfObject readFrom:string onError:nil.
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1219
                        value := value ? string.
1192
6db390e6463e default: String in SmalltalkObject
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
  1220
                    ].
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1221
                    model value:value
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1222
                ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1223
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1224
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1225
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1226
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1227
    "Modified: / 05-09-2006 / 17:57:53 / cg"
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1228
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1229
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1230
smalltalkObjectWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1231
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1232
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1233
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1234
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1235
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1236
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1237
    self
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1238
        getBlock:[:model | |v s|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1239
                     v := model value.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1240
                     v isNil ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1241
                        s := ''
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1242
                     ] ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1243
                            s := v storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1244
                            (v isString or:[v isNumber]) ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1245
                                s := s , ' "' , v class name , '" '
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1246
                            ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1247
                     ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1248
                     s
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1249
                 ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1250
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1251
        putBlock:
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1252
                [:model :string |
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1253
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1254
                    |value|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1255
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1256
                    string size > 0 ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1257
                        value := classOfObject readFrom:string onError:nil.
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1258
                        model value:value ? string
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1259
                    ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1260
                ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1261
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1262
        updateBlock: [:m :a :p | true]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1263
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1264
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1265
    "Modified: / 05-09-2006 / 17:57:37 / cg"
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1266
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1267
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1268
smalltalkPoint
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1269
    "setup the converter to convert from a string to a point object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1270
     and vice versa. The string used is the points storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1271
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1272
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1273
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1274
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1275
    ^ self smalltalkObjectWithClass:Point
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1276
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1277
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1278
symbolOrBooleanOrNil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1279
    "setup the converter to convert from a string to a symbol or boolean
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1280
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1281
     nil values are converted to an empty string.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1282
     In addition, the strings true/false convert to/from booleans."
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1283
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1284
    self
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1285
        getBlock:[:model |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1286
                |symbolValue|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1287
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1288
                ((symbolValue := model value) isSymbol 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1289
                or:[symbolValue isBoolean]) 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1290
                ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1291
                    ''
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1292
                ] ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1293
                    symbolValue printString. "/ storeString
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1294
                ]]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1295
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1296
        putBlock:
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1297
                [:model :string |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1298
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1299
                |value s|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1300
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1301
                string size == 0 ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1302
                    value := nil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1303
                ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1304
                    s := string withoutSeparators.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1305
                    (s startsWith:'#') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1306
                        s := s copyFrom:2.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1307
                        (s startsWith:$') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1308
                            s := s copyFrom:2 to:(s size - 1)
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1309
                        ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1310
                        value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1311
                    ] ifFalse:[
2440
83ae5c86ce7a fixed #symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1312
                        (#('true' 'false') includes:s) ifTrue:[
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1313
                            value := Object readFromString:s.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1314
                        ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1315
                            value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1316
                        ]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1317
                    ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1318
                ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1319
                model value:value]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1320
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1321
        updateBlock: [:m :a :p | true]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1322
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1323
    "Created: / 21.2.1997 / 18:58:38 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1324
    "Modified: / 26.5.1998 / 15:06:06 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1325
!
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1326
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1327
symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1328
    "setup the converter to convert from a string to a symbol
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1329
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1330
     nil values are converted to an empty string."
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1331
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1332
    self
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1333
        getBlock:[:model |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1334
                |symbolValue|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1335
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1336
                (symbolValue := model value) isSymbol ifFalse:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1337
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1338
                ] ifTrue:[
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1339
                    symbolValue printString. "/ storeString
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1340
                ]]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1341
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1342
        putBlock:
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1343
                [:model :string |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1344
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1345
                |value s|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1346
1314
d81678f19c9d bug fix; test not for empty, test for size == 0
ca
parents: 1266
diff changeset
  1347
                string size == 0 ifTrue:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1348
                    value := nil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1349
                ] ifFalse:[
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1350
                    s := string withoutSeparators.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1351
                    (s startsWith:'#') ifTrue:[
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1352
                        s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1353
                        (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1354
                            s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1355
                        ]
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1356
                    ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1357
                    value := s asSymbol
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1358
                ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1359
                model value:value]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1360
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1361
        updateBlock: [:m :a :p | true]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1362
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1363
    "Created: / 21.2.1997 / 18:58:38 / cg"
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1364
    "Modified: / 26.5.1998 / 15:06:06 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1365
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1366
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1367
time
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1368
     ^ self time24H
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1369
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1370
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1371
time12H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1372
    "setup the converter to convert from a string to a time formatted by 12 hours
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1373
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1374
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1375
    self timeToTextFormattedBy: #printString12HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1376
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1377
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1378
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1379
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1380
time24H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1381
    "setup the converter to convert from a string to a time formatted by 24 hours
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1382
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1383
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1384
    self timeToTextFormattedBy: #printString24HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1385
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1386
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1387
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1388
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1389
timeOfClass:timeClass withFormat:aFormatString orDefault:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1390
    "setup the converter to convert from a string to a time
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1391
     and vice versa. TimeClass is the class that should be used (e.g. Time or Timestamp). 
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1392
     Invalid times are converted to defaultValue; likewise,
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1393
     a nil time is converted to an empty string."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1394
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1395
    self
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1396
        getBlock:[:model |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1397
                |time|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1398
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1399
                (time := model value) isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1400
                    time := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1401
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1402
                time isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1403
                    ''
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1404
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1405
                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1406
                        time printString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1407
                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1408
                        time printStringFormat:aFormatString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1409
                ]]]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1410
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1411
        putBlock:
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1412
                [:model :string |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1413
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1414
                |value|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1415
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1416
                string isEmptyOrNil ifTrue:[
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1417
                    value := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1418
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1419
"/                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1420
                        value := timeClass readFrom:string onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1421
"/                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1422
"/                        value := timeClass readFrom:string printFormat:aFormatString onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1423
"/                    ]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1424
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1425
                model value:value]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1426
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1427
        updateBlock: [:m :a :p | true]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1428
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1429
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1430
timeOrNil
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1431
    "setup the converter to convert from a string to a time and vice versa."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1432
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1433
    self objectOrNilOfType:Time
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1434
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1435
    "Created: / 04-03-1997 / 11:52:47 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1436
    "Modified: / 12-01-2008 / 19:06:21 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1437
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1438
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1439
timeStampOrNil
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1440
    <resource: #obsolete>
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1441
    "setup the converter to convert from a string to a timeStamp and vice versa."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1442
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1443
    self timestampOrNil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1444
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1445
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1446
timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1447
    "setup the converter to convert from a string to a time
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1448
     and vice versa."
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1449
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1450
    self timeToTextFormattedBy: #printString
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1451
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1452
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1453
timeToTextFormattedBy: format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1454
    "setup the converter to convert from a string to a time formatted by format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1455
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1456
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1457
    self
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1458
        getBlock:[:model |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1459
                |time|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1460
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1461
                (time := model value) isNil ifTrue:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1462
                    Time now perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1463
                ] ifFalse:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1464
                    time perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1465
                ]]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1466
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1467
        putBlock:
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1468
                [:model :string |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1469
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1470
                |value|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1471
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1472
                string isEmptyOrNil ifTrue:[
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1473
                    value := Time now
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1474
                ] ifFalse:[              
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1475
                    value := Time readFrom:string onError:[Time now]
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1476
                ].
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1477
                model value:value]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1478
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1479
        updateBlock: [:m :a :p | true]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1480
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1481
    "Modified: 21.2.1997 / 18:59:06 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1482
    "Created: 4.3.1997 / 11:52:47 / cg"
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1483
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1484
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1485
timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1486
    "setup the converter to convert from a string to a timestamp and vice versa."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1487
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1488
    ^ self timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1489
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1490
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1491
timestampOrNil
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1492
    "setup the converter to convert from a string to a timestamp and vice versa."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1493
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1494
    self objectOrNilOfType:Timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1495
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1496
    "Modified: / 12-01-2008 / 19:06:06 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1497
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
!TypeConverter class methodsFor:'documentation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
version
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1502
    ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.57 2008-11-03 13:22:48 sr Exp $'
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
! !