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-- |
1355 | 1 |
" |
2 |
COPYRIGHT (c) 1997 eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
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 | 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 | 19 |
! |
20 |
||
21 |
!TypeConverter class methodsFor:'documentation'! |
|
22 |
||
1355 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1997 eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
37 |
! |
|
38 |
||
442 | 39 |
documentation |
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 | 49 |
No real new functionality is added here - all is inherited |
50 |
from PluggableAdapter; however, some specialized instance creation |
|
947 | 51 |
methods are added here. |
442 | 52 |
|
53 |
Notice: |
|
54 |
this class was implemented using protocol information |
|
55 |
from alpha testers - it may not be complete or compatible to |
|
56 |
the corresponding ST-80 class. |
|
57 |
If you encounter any incompatibilities, please forward a note |
|
58 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
59 |
||
60 |
[author:] |
|
61 |
Claus Gittinger |
|
62 |
" |
|
63 |
||
64 |
||
65 |
! |
|
66 |
||
67 |
examples |
|
68 |
" |
|
69 |
convert a number to a string: |
|
70 |
[exBegin] |
|
71 |
|v t i| |
|
72 |
||
73 |
v := 1 asValue. |
|
74 |
||
75 |
t := HorizontalPanelView new. |
|
76 |
t extent:200@50. |
|
77 |
t horizontalLayout:#fitSpace. |
|
78 |
||
79 |
i := EditField in:t. |
|
80 |
i model:(TypeConverter onNumberValue:v). |
|
81 |
t open. |
|
82 |
||
83 |
(Delay forSeconds:3) wait. |
|
84 |
v value:2. |
|
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 | 103 |
convert a date to a string: |
104 |
[exBegin] |
|
105 |
|d v| |
|
106 |
||
107 |
v := nil asValue. |
|
108 |
||
109 |
d := DialogBox new. |
|
110 |
d addInputFieldOn:(TypeConverter onDateValue:v). |
|
111 |
d addOkButton. |
|
112 |
d open. |
|
113 |
d accepted ifTrue:[ |
|
114 |
Transcript showCR:v value |
|
115 |
] |
|
116 |
[exEnd] |
|
2379 | 117 |
convert with thousands: |
118 |
[exBegin] |
|
119 |
|d v| |
|
120 |
||
121 |
v := 1234567 asValue. |
|
122 |
||
123 |
d := DialogBox new. |
|
124 |
d addInputFieldOn:((TypeConverter on:v) integerWithThousandsSeparator:$'). |
|
125 |
d addOkButton. |
|
126 |
d open. |
|
127 |
d accepted ifTrue:[ |
|
128 |
Transcript showCR:v value |
|
129 |
] |
|
130 |
[exEnd] |
|
442 | 131 |
" |
132 |
! ! |
|
133 |
||
134 |
!TypeConverter class methodsFor:'instance creation'! |
|
135 |
||
486 | 136 |
onDateValue:aValueHolder |
137 |
"create and return a typeConverter, which retrieves |
|
138 |
a date via #value, and converts |
|
139 |
a date-string to a date via #value:. |
|
140 |
Useful as an editFields model, which operates on some |
|
141 |
date value (or aspectAdaptor, which adapts to a numeric slot)" |
|
142 |
||
143 |
^ (self on:aValueHolder) dateToText |
|
144 |
||
145 |
"Modified: 21.2.1997 / 18:46:11 / cg" |
|
146 |
"Created: 4.3.1997 / 12:30:49 / cg" |
|
147 |
! |
|
148 |
||
442 | 149 |
onNumberValue:aValueHolder |
150 |
"create and return a typeConverter, which retrieves |
|
151 |
a values string representation via #value, and converts |
|
152 |
a number-string to a value via #value:. |
|
153 |
Useful as an editFields model, which operates on some |
|
154 |
numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
|
155 |
||
156 |
^ (self on:aValueHolder) numberToText |
|
157 |
||
158 |
"Modified: 21.2.1997 / 18:46:11 / cg" |
|
446 | 159 |
! |
160 |
||
487 | 161 |
onNumberValue:aValueHolder format:formatString |
162 |
"create and return a typeConverter, which retrieves |
|
163 |
a values string representation via #value, and converts |
|
164 |
a number-string to a value via #value:. |
|
165 |
Useful as an editFields model, which operates on some |
|
166 |
numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
|
167 |
||
168 |
^ (self on:aValueHolder) numberToTextFormattedBy:formatString |
|
169 |
||
170 |
"Created: 4.3.1997 / 11:51:25 / cg" |
|
171 |
"Modified: 4.3.1997 / 11:51:41 / cg" |
|
172 |
! |
|
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 | 217 |
onSymbolValue:aValueHolder |
218 |
"create and return a typeConverter, which retrieves |
|
219 |
a symbol-values string representation via #value, and converts |
|
220 |
a string to a symbol via #value:. |
|
221 |
Useful as an editFields model, which operates on some |
|
222 |
numeric value (or aspectAdaptor, which adapts to a numeric slot)" |
|
223 |
||
224 |
^ (self on:aValueHolder) symbolOrNil |
|
225 |
||
226 |
"Modified: 21.2.1997 / 18:46:11 / cg" |
|
487 | 227 |
! |
228 |
||
229 |
onTimeValue:aValueHolder |
|
230 |
"create and return a typeConverter, which retrieves |
|
231 |
a time via #value, and converts |
|
232 |
a time-string to a time via #value:. |
|
233 |
Useful as an editFields model, which operates on some |
|
234 |
date value (or aspectAdaptor, which adapts to a numeric slot)" |
|
235 |
||
236 |
^ (self on:aValueHolder) timeToText |
|
237 |
||
238 |
"Modified: 21.2.1997 / 18:46:11 / cg" |
|
239 |
"Created: 4.3.1997 / 11:52:10 / cg" |
|
442 | 240 |
! ! |
241 |
||
242 |
!TypeConverter methodsFor:'accessing'! |
|
243 |
||
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 | 246 |
|
247 |
^ model |
|
248 |
! |
|
249 |
||
250 |
value:newValue |
|
251 |
"convert and change" |
|
252 |
||
253 |
self setValue:newValue |
|
254 |
||
255 |
"Created: 21.2.1997 / 18:45:39 / cg" |
|
256 |
! ! |
|
257 |
||
1001 | 258 |
!TypeConverter methodsFor:'input testing'! |
259 |
||
260 |
setNumberValue: value inModel: model fromInput: string |
|
1463 | 261 |
"for invalid numbers, the model is set to nil. |
262 |
By this, the dependents are forced to update their contents |
|
263 |
(that is: a bad input string will lead to a cleared input field here)." |
|
1001 | 264 |
|
1463 | 265 |
|lastInputChar needChange| |
266 |
||
267 |
string notEmpty ifTrue:[ |
|
268 |
1 to: string size - 1 do: [:i| (string at: i) isLetter ifTrue: [needChange := true]]. |
|
1001 | 269 |
lastInputChar := string at: string size. |
270 |
(lastInputChar isDigit not and: [lastInputChar isPrintable and: [ |
|
271 |
(string size > 1 or: [lastInputChar ~~ $-]) and: [ |
|
1463 | 272 |
(string occurrencesOf: $.) > 1 or: [lastInputChar ~~ $.]]]]) ifTrue: [needChange := true]. |
1001 | 273 |
]. |
274 |
||
1463 | 275 |
needChange == true ifTrue:[ |
276 |
value notNil ifTrue:[ |
|
277 |
model setValue:nil |
|
278 |
] ifFalse:[ |
|
279 |
model value isNil ifTrue:[ |
|
280 |
model changed:#value. |
|
281 |
^ self |
|
282 |
] |
|
283 |
]. |
|
284 |
]. |
|
1001 | 285 |
model value:value |
286 |
! ! |
|
287 |
||
726 | 288 |
!TypeConverter methodsFor:'standard converters'! |
442 | 289 |
|
1149 | 290 |
arrayLiteralOrStringOrSymbolOrNil |
291 |
"setup the converter to convert from a string to either a literal |
|
292 |
Array, a String or a symbol and vice versa. |
|
293 |
Invalid strings (i.e. empty) are converted to nil; |
|
294 |
nil values are converted to an empty string. |
|
295 |
This is a very special converter (for the GUI builder) |
|
296 |
- probably not belonging to here" |
|
297 |
||
298 |
self |
|
299 |
getBlock:[:model | |
|
300 |
|symbolValue| |
|
301 |
||
302 |
(symbolValue := model value) isNil ifTrue:[ |
|
303 |
String new |
|
304 |
] ifFalse:[ |
|
305 |
symbolValue storeString |
|
306 |
]] |
|
307 |
||
308 |
putBlock: |
|
309 |
[:model :string | |
|
310 |
||
311 |
|value s| |
|
312 |
||
2560 | 313 |
string isEmptyOrNil ifTrue:[ |
1149 | 314 |
value := nil |
315 |
] ifFalse:[ |
|
316 |
s := string withoutSeparators. |
|
317 |
(s startsWith:'#(') ifTrue:[ |
|
318 |
value := Array readFrom:s onError:nil |
|
319 |
] ifFalse:[ |
|
320 |
(s startsWith:'''') ifTrue:[ |
|
321 |
value := String readFrom:s onError:nil |
|
322 |
] ifFalse:[ |
|
323 |
(s startsWith:'#') ifTrue:[ |
|
324 |
s := s copyFrom:2 |
|
325 |
]. |
|
326 |
value := s asSymbol |
|
327 |
] |
|
328 |
] |
|
329 |
]. |
|
330 |
model value:value] |
|
331 |
||
332 |
updateBlock: [:m :a :p | true] |
|
333 |
||
334 |
"Modified: / 26.10.1997 / 13:50:32 / cg" |
|
335 |
"Created: / 26.10.1997 / 14:01:02 / cg" |
|
336 |
! |
|
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 | 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 | 394 |
dateDDMMYYYY |
1026 | 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 | 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 | 399 |
! |
400 |
||
1047 | 401 |
dateMMDDYYYY |
1026 | 402 |
"setup the converter to convert from a string to a date formatted by printFormat |
403 |
MM:DD:YYYY; see also Date>>printFormat:" |
|
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 | 406 |
! |
407 |
||
487 | 408 |
dateOrNil |
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 | 412 |
|
1832 | 413 |
^ self dateWithFormat:nil orDefault:nil |
414 |
! |
|
487 | 415 |
|
1832 | 416 |
dateOrNilWithFormat:aFormatString |
417 |
"setup the converter to convert from a string to a date |
|
418 |
and vice versa. Invalid dates are converted to nil; likewise, |
|
419 |
a nil date is converted to an empty string. |
|
420 |
The format string must have one of the forms: |
|
421 |
'mm/dd/yyyy' (for VW-backward compatibility) |
|
422 |
or: |
|
423 |
'%m %d %y' |
|
424 |
" |
|
487 | 425 |
|
1832 | 426 |
^ self dateWithFormat:aFormatString orDefault:nil |
487 | 427 |
! |
428 |
||
486 | 429 |
dateToText |
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 | 433 |
|
1832 | 434 |
^ self dateWithFormat:nil orDefault:Date today |
486 | 435 |
! |
436 |
||
1026 | 437 |
dateToTextFormattedBy: printFormat |
438 |
"setup the converter to convert from a string to a date formatted by printFormat |
|
439 |
and vice versa. Nil is converted to todays date-string, |
|
1697 | 440 |
likewise, an empty string is converted back to todays date. |
441 |
Uses the old, obsolete ST80 printFormat (see Date printFormat:)" |
|
1026 | 442 |
|
1832 | 443 |
^ self dateWithFormat:printFormat orDefault:Date today |
444 |
! |
|
445 |
||
446 |
dateWithFormat:aFormatString |
|
447 |
"setup the converter to convert from a string to a date |
|
448 |
and vice versa. Invalid dates are converted to nil; likewise, |
|
449 |
a nil date is converted to an empty string. |
|
450 |
The format string must have one of the forms: |
|
451 |
'mm/dd/yyyy' (for VW-backward compatibility) |
|
452 |
or: |
|
453 |
'%m %d %y' |
|
454 |
" |
|
455 |
||
456 |
^ self dateWithFormat:aFormatString orDefault:Date today |
|
457 |
! |
|
458 |
||
459 |
dateWithFormat:aFormatString orDefault:defaultValue |
|
460 |
"setup the converter to convert from a string to a date |
|
461 |
and vice versa. Invalid dates are converted to nil; likewise, |
|
462 |
a nil date is converted to an empty string. |
|
463 |
The format string must have one of the forms: |
|
464 |
'mm/dd/yyyy' (for VW-backward compatibility) |
|
465 |
or: |
|
466 |
'%m %d %y' |
|
467 |
" |
|
468 |
||
469 |
|in out stxFormat c nDigits| |
|
470 |
||
471 |
aFormatString notNil ifTrue:[ |
|
472 |
(aFormatString includes:$%) ifTrue:[ |
|
473 |
"/ a new (ST/X) formatString |
|
474 |
stxFormat := aFormatString |
|
475 |
] ifFalse:[ |
|
476 |
"/ an old (VW) formatString |
|
477 |
out := '' writeStream. |
|
478 |
in := aFormatString readStream. |
|
479 |
[in atEnd] whileFalse:[ |
|
480 |
c := in next. |
|
481 |
nDigits := 1. |
|
482 |
c == $m ifTrue:[ |
|
483 |
[in peek == $m] whileTrue:[ nDigits := nDigits + 1. in next ]. |
|
484 |
nDigits == 1 ifTrue:[ |
|
485 |
out nextPutAll:'%M'. "/ unpadded |
|
486 |
] ifFalse:[ |
|
487 |
out nextPutAll:'%m'. |
|
488 |
]. |
|
489 |
] ifFalse:[ |
|
490 |
c == $d ifTrue:[ |
|
491 |
[in peek == $d] whileTrue:[ nDigits := nDigits + 1. in next ]. |
|
492 |
nDigits == 1 ifTrue:[ |
|
493 |
out nextPutAll:'%D'. "/ unpadded |
|
494 |
] ifFalse:[ |
|
495 |
out nextPutAll:'%d'. |
|
496 |
]. |
|
497 |
] ifFalse:[ |
|
498 |
c == $y ifTrue:[ |
|
499 |
[in peek == $y] whileTrue:[ nDigits := nDigits + 1. in next ]. |
|
500 |
nDigits == 2 ifTrue:[ |
|
501 |
out nextPutAll:'%Y'. "/ 2 digits only |
|
502 |
] ifFalse:[ |
|
503 |
out nextPutAll:'%y'. |
|
504 |
]. |
|
505 |
] ifFalse:[ |
|
506 |
out nextPut:c. |
|
507 |
]. |
|
508 |
]. |
|
509 |
]. |
|
510 |
]. |
|
511 |
stxFormat := out contents. |
|
512 |
]. |
|
513 |
]. |
|
514 |
||
1026 | 515 |
self |
516 |
getBlock:[:model | |
|
1832 | 517 |
|date| |
1696 | 518 |
|
1832 | 519 |
(date := model value) isNil ifTrue:[ |
520 |
date := defaultValue |
|
521 |
]. |
|
522 |
date isNil ifTrue:[ |
|
523 |
'' |
|
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 | 526 |
date printString |
527 |
] ifFalse:[ |
|
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 | 531 |
|
532 |
putBlock: |
|
533 |
[:model :string | |
|
534 |
||
535 |
|value| |
|
536 |
||
2560 | 537 |
string isEmptyOrNil ifTrue:[ |
1832 | 538 |
value := defaultValue |
539 |
] ifFalse:[ |
|
540 |
stxFormat isNil ifTrue:[ |
|
541 |
value := Date readFrom:string onError:defaultValue |
|
542 |
] ifFalse:[ |
|
543 |
value := Date readFrom:string printFormat:stxFormat onError:defaultValue |
|
544 |
] |
|
1026 | 545 |
]. |
546 |
model value:value] |
|
547 |
||
548 |
updateBlock: [:m :a :p | true] |
|
549 |
! |
|
550 |
||
1791 | 551 |
fileSize |
552 |
"setup the converter to convert from a fileSize string to a number |
|
553 |
and vice versa. |
|
554 |
A fileSize can have a scale of 1024 (k or kB), |
|
555 |
1024*1024 (m or mB), 1024*1024*1024 (g or gB)." |
|
556 |
||
557 |
self |
|
558 |
getBlock:[:model | |
|
559 |
|numericValue| |
|
560 |
||
561 |
(numericValue := model value) isNumber ifFalse:[ |
|
562 |
String new |
|
563 |
] ifTrue:[ |
|
564 |
UnitConverter fileSizeStringFor:numericValue |
|
565 |
]] |
|
566 |
||
567 |
putBlock: |
|
568 |
[:model :string | |
|
569 |
||
570 |
model value:(UnitConverter fileSizeFromString:string)] |
|
571 |
||
572 |
updateBlock: [:m :a :p | true] |
|
573 |
! |
|
574 |
||
1122 | 575 |
hexadecimal |
1047 | 576 |
"setup the converter to convert from a hexadecimal string to a number |
577 |
and vice versa." |
|
578 |
||
579 |
self |
|
580 |
getBlock:[:model | |
|
581 |
|hexValue| |
|
582 |
||
583 |
(hexValue := model value) isNumber ifFalse:[ |
|
584 |
String new |
|
585 |
] ifTrue:[ |
|
586 |
hexValue hexPrintString |
|
587 |
]] |
|
588 |
||
589 |
putBlock: |
|
590 |
[:model :string | |
|
591 |
||
592 |
|value| |
|
593 |
||
2560 | 594 |
string isEmptyOrNil ifTrue:[ |
1047 | 595 |
value := 0 |
596 |
] ifFalse:[ |
|
597 |
value := Integer readFrom: string radix:16 onError:[0] |
|
598 |
]. |
|
599 |
model value:value] |
|
600 |
||
601 |
updateBlock: [:m :a :p | true] |
|
602 |
! |
|
603 |
||
2366 | 604 |
integerToHexTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
605 |
"setup the converter to convert from a string to a number |
|
606 |
and vice versa, but clamping the number into the range." |
|
607 |
||
608 |
^ self integerToTextMinValue:minVal maxValue:maxVal radix:16 format:formatStringOrNil |
|
609 |
! |
|
610 |
||
1974 | 611 |
integerToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
612 |
"setup the converter to convert from a string to a number |
|
613 |
and vice versa, but clamping the number into the range." |
|
614 |
||
2366 | 615 |
^ self integerToTextMinValue:minVal maxValue:maxVal radix:10 format:formatStringOrNil |
616 |
! |
|
617 |
||
618 |
integerToTextMinValue:minVal maxValue:maxVal radix:radix format:formatStringOrNil |
|
619 |
"setup the converter to convert from a string to a number |
|
620 |
and vice versa, but clamping the number into the range." |
|
621 |
||
1974 | 622 |
self |
623 |
getBlock:[:model | |
|
624 |
|numericValue| |
|
625 |
||
626 |
(numericValue := model value) isNil ifTrue:[ |
|
627 |
String new |
|
628 |
] ifFalse:[ |
|
2379 | 629 |
numericValue isString ifTrue:[ |
630 |
numericValue |
|
1974 | 631 |
] ifFalse:[ |
2379 | 632 |
formatStringOrNil isNil ifTrue:[ |
633 |
numericValue printStringRadix:radix |
|
634 |
] ifFalse:[ |
|
635 |
numericValue printfPrintString:formatStringOrNil |
|
636 |
] |
|
1974 | 637 |
] |
638 |
]] |
|
639 |
||
640 |
putBlock: |
|
641 |
[:model :string | |
|
642 |
||
643 |
|value c| |
|
644 |
||
2560 | 645 |
string isEmptyOrNil ifTrue:[ |
1974 | 646 |
value := 0 |
647 |
] ifFalse:[ |
|
2366 | 648 |
value := Integer readFromString:string radix:radix onError:[0]. |
1974 | 649 |
]. |
650 |
minVal notNil ifTrue:[ |
|
651 |
(value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
652 |
value := value max:minVal. |
|
653 |
]. |
|
654 |
maxVal notNil ifTrue:[ |
|
655 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
656 |
value := value min:maxVal. |
|
657 |
]. |
|
658 |
self setNumberValue: value inModel: model fromInput: string. |
|
659 |
] |
|
660 |
||
661 |
updateBlock: [:m :a :p | true] |
|
662 |
||
663 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
664 |
! |
|
665 |
||
2379 | 666 |
integerWithThousandsSeparator |
667 |
^ self integerWithThousandsSeparator:$' |
|
668 |
"/ ^ self integerWithThousandsSeparator:(UserPreferences current thousandsSeparatorCharacter) |
|
669 |
! |
|
670 |
||
671 |
integerWithThousandsSeparator:sep |
|
672 |
"setup the converter to convert from a string to a number with thousands separator |
|
673 |
and vice versa." |
|
674 |
||
675 |
self |
|
676 |
getBlock:[:model | |
|
677 |
|numericValue| |
|
678 |
||
679 |
(numericValue := model value) isNumber ifFalse:[ |
|
680 |
String new |
|
681 |
] ifTrue:[ |
|
682 |
String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep]. |
|
683 |
]] |
|
684 |
||
685 |
putBlock: |
|
686 |
[:model :string | |
|
687 |
||
688 |
|value s2| |
|
689 |
||
2559 | 690 |
string isEmptyOrNil ifTrue:[ |
2379 | 691 |
value := 0 |
692 |
] ifFalse:[ |
|
693 |
s2 := string reject:[:ch | ch = sep]. |
|
694 |
value := Number readFromString:s2 onError:[0] |
|
695 |
]. |
|
696 |
model value:value] |
|
697 |
||
2407 | 698 |
updateBlock: [:m :a :p | true] |
2379 | 699 |
! |
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 | 736 |
"be careful, #readFrom:onError: returns nil for an undefined identifier" |
737 |
s = 'true' ifTrue:[ |
|
738 |
value := true. |
|
739 |
] ifFalse:[s = 'false' ifTrue:[ |
|
740 |
value := false. |
|
741 |
] ifFalse:[s = 'nil' ifTrue:[ |
|
742 |
value := nil. |
|
743 |
] ifFalse:[s first isLetter ifTrue:[ |
|
744 |
value := s asSymbol. |
|
745 |
] ifFalse:[ |
|
746 |
value := Object readFrom:s onError:[ |
|
747 |
s asSymbol |
|
748 |
]. |
|
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 | 759 |
number |
760 |
"setup the converter to convert from a string to a number |
|
761 |
and vice versa. Invalid numbers are converted to nil." |
|
762 |
||
763 |
self numberToText |
|
764 |
||
765 |
"Created: 4.4.1997 / 12:46:14 / cg" |
|
766 |
! |
|
767 |
||
442 | 768 |
numberOrNil |
769 |
"setup the converter to convert from a string to a number |
|
770 |
and vice versa. Invalid numbers are converted to nil." |
|
771 |
||
2372 | 772 |
self objectOrNilOfType:Number |
442 | 773 |
|
2372 | 774 |
"Modified: / 12-01-2008 / 19:08:42 / cg" |
442 | 775 |
! |
776 |
||
1463 | 777 |
numberOrNilToTextMinValue:minVal maxValue:maxVal |
778 |
"setup the converter to convert from a string to a number or nil |
|
779 |
and vice versa, but clamping the number into the range." |
|
780 |
||
1974 | 781 |
self numberOrNilToTextMinValue:minVal maxValue:maxVal format:nil |
782 |
! |
|
783 |
||
784 |
numberOrNilToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
|
785 |
"setup the converter to convert from a string to a number or nil |
|
786 |
and vice versa, but clamping the number into the range." |
|
787 |
||
1463 | 788 |
self |
789 |
getBlock:[:model | |
|
790 |
|numericValue| |
|
791 |
||
792 |
(numericValue := model value) isNil ifTrue:[ |
|
793 |
String new |
|
794 |
] ifFalse:[ |
|
1974 | 795 |
formatStringOrNil isNil ifTrue:[ |
796 |
numericValue printString |
|
797 |
] ifFalse:[ |
|
798 |
numericValue printfPrintString:formatStringOrNil |
|
799 |
] |
|
1463 | 800 |
]] |
801 |
||
802 |
putBlock: |
|
803 |
[:model :string | |
|
804 |
||
805 |
|value c| |
|
806 |
||
2560 | 807 |
(string isEmptyOrNil or:[string isBlank]) ifTrue:[ |
1463 | 808 |
value := nil |
809 |
] ifFalse:[ |
|
810 |
value := Number readFromString:string onError:[nil]. |
|
811 |
value isNil ifTrue:[ |
|
812 |
||
813 |
] ifFalse:[ |
|
814 |
minVal notNil ifTrue:[ |
|
815 |
(value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
816 |
value := value max:minVal. |
|
817 |
]. |
|
818 |
maxVal notNil ifTrue:[ |
|
819 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
820 |
value := value min:maxVal. |
|
821 |
]. |
|
822 |
]. |
|
823 |
]. |
|
824 |
self setNumberValue: value inModel: model fromInput: string. |
|
825 |
] |
|
826 |
||
827 |
updateBlock: [:m :a :p | true] |
|
828 |
||
829 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
830 |
! |
|
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 | 863 |
numberOrStringOrSymbolOrNil |
864 |
"setup the converter to convert from a string to either a numeric literal |
|
865 |
or a symbol and vice versa. |
|
866 |
Invalid strings (i.e. empty) are converted to nil; |
|
867 |
nil values are converted to an empty string. |
|
868 |
This is a very special converter (for the GUI builder) |
|
869 |
- probably not belonging to here" |
|
870 |
||
871 |
self |
|
872 |
getBlock:[:model | |
|
873 |
|litValue| |
|
874 |
||
875 |
(litValue := model value) isNil ifTrue:[ |
|
876 |
String new |
|
877 |
] ifFalse:[ |
|
878 |
litValue storeString |
|
879 |
]] |
|
880 |
||
881 |
putBlock: |
|
882 |
[:model :string | |
|
883 |
||
884 |
|value s| |
|
885 |
||
2560 | 886 |
string isEmptyOrNil ifTrue:[ |
1149 | 887 |
value := nil |
888 |
] ifFalse:[ |
|
889 |
value := Number readFrom:string onError:nil. |
|
890 |
value isNil ifTrue:[ |
|
891 |
s := string withoutSeparators. |
|
892 |
(s startsWith:'''') ifTrue:[ |
|
893 |
value := String readFrom:s readStream onError:nil |
|
894 |
] ifFalse:[ |
|
895 |
(s startsWith:'#') ifTrue:[ |
|
896 |
s := s copyFrom:2. |
|
897 |
(s startsWith:$') ifTrue:[ |
|
898 |
s := s copyFrom:2 to:(s size - 1) |
|
899 |
]. |
|
900 |
]. |
|
901 |
value := s asSymbol |
|
902 |
] |
|
903 |
] |
|
904 |
]. |
|
905 |
model value:value] |
|
906 |
||
907 |
updateBlock: [:m :a :p | true] |
|
908 |
||
909 |
"Modified: / 26.10.1997 / 13:50:32 / cg" |
|
910 |
"Created: / 29.10.1997 / 15:49:26 / cg" |
|
911 |
! |
|
912 |
||
726 | 913 |
numberOrSymbolOrNil |
914 |
"setup the converter to convert from a string to either a numeric literal |
|
915 |
or a symbol and vice versa. |
|
916 |
Invalid strings (i.e. empty) are converted to nil; |
|
917 |
nil values are converted to an empty string. |
|
918 |
This is a very special converter (for the GUI builder) |
|
919 |
- probably not belonging to here" |
|
920 |
||
921 |
self |
|
922 |
getBlock:[:model | |
|
923 |
|litValue| |
|
924 |
||
925 |
(litValue := model value) isNil ifTrue:[ |
|
926 |
String new |
|
927 |
] ifFalse:[ |
|
928 |
litValue storeString |
|
929 |
]] |
|
930 |
||
931 |
putBlock: |
|
932 |
[:model :string | |
|
933 |
||
934 |
|value s| |
|
935 |
||
2560 | 936 |
string isEmptyOrNil ifTrue:[ |
726 | 937 |
value := nil |
938 |
] ifFalse:[ |
|
939 |
value := Number readFrom:string onError:nil. |
|
940 |
value isNil ifTrue:[ |
|
941 |
s := string withoutSeparators. |
|
942 |
(s startsWith:'#') ifTrue:[ |
|
943 |
s := s copyFrom:2. |
|
944 |
(s startsWith:$') ifTrue:[ |
|
945 |
s := s copyFrom:2 to:(s size - 1) |
|
946 |
]. |
|
947 |
]. |
|
948 |
value := s asSymbol |
|
949 |
] |
|
950 |
]. |
|
951 |
model value:value] |
|
952 |
||
953 |
updateBlock: [:m :a :p | true] |
|
954 |
||
955 |
"Modified: / 26.10.1997 / 13:50:32 / cg" |
|
956 |
"Created: / 29.10.1997 / 15:49:26 / cg" |
|
957 |
! |
|
958 |
||
442 | 959 |
numberToText |
960 |
"setup the converter to convert from a string to a number |
|
487 | 961 |
and vice versa." |
442 | 962 |
|
963 |
self |
|
964 |
getBlock:[:model | |
|
965 |
|numericValue| |
|
966 |
||
726 | 967 |
(numericValue := model value) isNumber ifFalse:[ |
442 | 968 |
String new |
726 | 969 |
] ifTrue:[ |
442 | 970 |
numericValue printString |
971 |
]] |
|
972 |
||
973 |
putBlock: |
|
974 |
[:model :string | |
|
975 |
||
976 |
|value| |
|
977 |
||
2560 | 978 |
string isEmptyOrNil ifTrue:[ |
442 | 979 |
value := 0 |
980 |
] ifFalse:[ |
|
1000
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
981 |
value := Number readFromString: string onError:[0] |
442 | 982 |
]. |
983 |
model value:value] |
|
984 |
||
985 |
updateBlock: [:m :a :p | true] |
|
986 |
||
726 | 987 |
"Created: / 21.2.1997 / 18:57:05 / cg" |
988 |
"Modified: / 29.10.1997 / 15:49:21 / cg" |
|
442 | 989 |
! |
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 | 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 | 1015 |
self setNumberValue: value inModel: model fromInput: string. |
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 | 1024 |
numberToTextFormattedBy:formatString |
1025 |
"setup the converter to convert from a string to a number |
|
1026 |
and vice versa, using formatString. |
|
1027 |
The formatString is currently ignored when numbers are converted |
|
1028 |
from a string." |
|
1029 |
||
1030 |
self |
|
1031 |
getBlock:[:model | |
|
1032 |
|numericValue| |
|
1033 |
||
1034 |
(numericValue := model value) isNil ifTrue:[ |
|
1035 |
String new |
|
1036 |
] ifFalse:[ |
|
1037 |
PrintConverter print:numericValue formattedBy:formatString |
|
1038 |
]] |
|
1039 |
||
1040 |
putBlock: |
|
1041 |
[:model :string | |
|
1042 |
||
1043 |
|value| |
|
1044 |
||
2560 | 1045 |
string isEmptyOrNil ifTrue:[ |
442 | 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 | 1049 |
]. |
1050 |
model value:value] |
|
1051 |
||
1052 |
updateBlock: [:m :a :p | true] |
|
1053 |
||
1054 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
446 | 1055 |
! |
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 | 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 | 1094 |
self numberToTextMinValue:minVal maxValue:maxVal format:nil |
1095 |
! |
|
1096 |
||
1097 |
numberToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
|
1098 |
"setup the converter to convert from a string to a number |
|
1099 |
and vice versa, but clamping the number into the range." |
|
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 | 1108 |
formatStringOrNil isNil ifTrue:[ |
1109 |
numericValue printString |
|
1110 |
] ifFalse:[ |
|
1111 |
numericValue printfPrintString:formatStringOrNil |
|
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 | 1118 |
|value c| |
941
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1119 |
|
2560 | 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 | 1122 |
] ifFalse:[ |
997 | 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 | 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 | 1130 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
944 | 1131 |
value := value min:maxVal. |
1001 | 1132 |
]. |
1133 |
self setNumberValue: value inModel: model fromInput: string. |
|
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 | 1141 |
objectOrNilOfType:timeOrDateClass |
1142 |
"common code for timeOrNil, dateOrNil and timeStampOrNil" |
|
1143 |
||
1144 |
self |
|
1145 |
getBlock:[:model | |
|
1146 |
|timeOrDate| |
|
1147 |
||
1148 |
(timeOrDate := model value) isNil ifTrue:[ |
|
1149 |
'' |
|
1150 |
] ifFalse:[ |
|
1151 |
timeOrDate printString |
|
1152 |
]] |
|
1153 |
||
1154 |
putBlock: |
|
1155 |
[:model :string | |
|
1156 |
||
1157 |
|value| |
|
1158 |
||
2560 | 1159 |
string isEmptyOrNil ifTrue:[ |
2372 | 1160 |
value := nil |
1161 |
] ifFalse:[ |
|
1162 |
value := timeOrDateClass readFrom:string onError:nil |
|
1163 |
]. |
|
1164 |
model value:value] |
|
1165 |
||
1166 |
updateBlock: [:m :a :p | true] |
|
1167 |
||
1168 |
"Created: / 12-01-2008 / 19:05:18 / cg" |
|
1169 |
! |
|
1170 |
||
726 | 1171 |
smalltalkObject |
1172 |
"setup the converter to convert from a string to any smalltalk object |
|
1173 |
and vice versa. The string used is the objects storeString. |
|
1174 |
Invalid strings (i.e. empty) are converted to nil. |
|
1175 |
This is a very special converter (for the GUI builder) |
|
1176 |
- probably not belonging to here" |
|
1177 |
||
1786 | 1178 |
^ self smalltalkObjectWithClass:Object |
1407 | 1179 |
! |
1180 |
||
1181 |
smalltalkObjectOrNil |
|
1182 |
"setup the converter to convert from a string to any smalltalk object |
|
1183 |
and vice versa. The string used is the objects storeString. |
|
1184 |
Invalid strings (i.e. empty) are converted to nil. |
|
1185 |
This is a very special converter (for the GUI builder) |
|
1186 |
- probably not belonging to here" |
|
1187 |
||
1786 | 1188 |
^ self smalltalkObjectOrNilWithClass:Object |
1189 |
! |
|
1190 |
||
1191 |
smalltalkObjectOrNilWithClass:classOfObject |
|
1192 |
"setup the converter to convert from a string to a smalltalk object |
|
1193 |
and vice versa. The string used is the objects storeString. |
|
1194 |
Invalid strings (i.e. empty) are converted to nil. |
|
1195 |
This is a very special converter (for the GUI builder) |
|
1196 |
- probably not belonging to here" |
|
1197 |
||
1407 | 1198 |
self |
1199 |
getBlock:[:model | |v s| |
|
1200 |
v := model value. |
|
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 | 1210 |
] |
1211 |
||
1212 |
putBlock: |
|
1213 |
[:model :string | |
|
1214 |
||
1215 |
|value| |
|
1216 |
||
1199
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1217 |
string size > 0 ifTrue:[ |
2199 | 1218 |
value := classOfObject readFrom:string onError:nil. |
1219 |
value := value ? string. |
|
1192
6db390e6463e
default: String in SmalltalkObject
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
1220 |
]. |
726 | 1221 |
model value:value |
1222 |
] |
|
1223 |
||
1224 |
updateBlock: [:m :a :p | true] |
|
1225 |
||
2199 | 1226 |
"Created: / 29-10-1997 / 15:50:16 / cg" |
1227 |
"Modified: / 05-09-2006 / 17:57:53 / cg" |
|
726 | 1228 |
! |
1229 |
||
1786 | 1230 |
smalltalkObjectWithClass:classOfObject |
1231 |
"setup the converter to convert from a string to a smalltalk object |
|
1232 |
and vice versa. The string used is the objects storeString. |
|
1233 |
Invalid strings (i.e. empty) are converted to nil. |
|
1234 |
This is a very special converter (for the GUI builder) |
|
1235 |
- probably not belonging to here" |
|
1236 |
||
1237 |
self |
|
1238 |
getBlock:[:model | |v s| |
|
1239 |
v := model value. |
|
1240 |
v isNil ifTrue:[ |
|
1241 |
s := '' |
|
1242 |
] ifFalse:[ |
|
1243 |
s := v storeString. |
|
1244 |
(v isString or:[v isNumber]) ifFalse:[ |
|
1245 |
s := s , ' "' , v class name , '" ' |
|
1246 |
] |
|
1247 |
]. |
|
1248 |
s |
|
1249 |
] |
|
1250 |
||
1251 |
putBlock: |
|
1252 |
[:model :string | |
|
1253 |
||
1254 |
|value| |
|
1255 |
||
1256 |
string size > 0 ifTrue:[ |
|
1257 |
value := classOfObject readFrom:string onError:nil. |
|
2199 | 1258 |
model value:value ? string |
1786 | 1259 |
]. |
1260 |
] |
|
1261 |
||
1262 |
updateBlock: [:m :a :p | true] |
|
1263 |
||
2199 | 1264 |
"Created: / 29-10-1997 / 15:50:16 / cg" |
1265 |
"Modified: / 05-09-2006 / 17:57:37 / cg" |
|
1786 | 1266 |
! |
1267 |
||
1268 |
smalltalkPoint |
|
1269 |
"setup the converter to convert from a string to a point object |
|
1270 |
and vice versa. The string used is the points storeString. |
|
1271 |
Invalid strings (i.e. empty) are converted to nil. |
|
1272 |
This is a very special converter (for the GUI builder) |
|
1273 |
- probably not belonging to here" |
|
1274 |
||
1275 |
^ self smalltalkObjectWithClass:Point |
|
1276 |
! |
|
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 | 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 | 1327 |
symbolOrNil |
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 | 1331 |
|
1332 |
self |
|
1333 |
getBlock:[:model | |
|
1334 |
|symbolValue| |
|
1335 |
||
726 | 1336 |
(symbolValue := model value) isSymbol ifFalse:[ |
446 | 1337 |
String new |
726 | 1338 |
] ifTrue:[ |
946 | 1339 |
symbolValue printString. "/ storeString |
446 | 1340 |
]] |
1341 |
||
1342 |
putBlock: |
|
1343 |
[:model :string | |
|
1344 |
||
1345 |
|value s| |
|
1346 |
||
1314 | 1347 |
string size == 0 ifTrue:[ |
446 | 1348 |
value := nil |
1349 |
] ifFalse:[ |
|
1350 |
s := string withoutSeparators. |
|
1351 |
(s startsWith:'#') ifTrue:[ |
|
726 | 1352 |
s := s copyFrom:2. |
1353 |
(s startsWith:$') ifTrue:[ |
|
1354 |
s := s copyFrom:2 to:(s size - 1) |
|
1355 |
] |
|
446 | 1356 |
]. |
1357 |
value := s asSymbol |
|
1358 |
]. |
|
1359 |
model value:value] |
|
1360 |
||
1361 |
updateBlock: [:m :a :p | true] |
|
1362 |
||
722
ea6d08251333
added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents:
508
diff
changeset
|
1363 |
"Created: / 21.2.1997 / 18:58:38 / cg" |
946 | 1364 |
"Modified: / 26.5.1998 / 15:06:06 / cg" |
487 | 1365 |
! |
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 | 1371 |
time12H |
1026 | 1372 |
"setup the converter to convert from a string to a time formatted by 12 hours |
1373 |
and vice versa." |
|
1374 |
||
1027 | 1375 |
self timeToTextFormattedBy: #printString12HourFormat |
1026 | 1376 |
|
1377 |
||
1378 |
! |
|
1379 |
||
1047 | 1380 |
time24H |
1026 | 1381 |
"setup the converter to convert from a string to a time formatted by 24 hours |
1382 |
and vice versa." |
|
1383 |
||
1027 | 1384 |
self timeToTextFormattedBy: #printString24HourFormat |
1026 | 1385 |
|
1386 |
||
1387 |
! |
|
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 | 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 | 1430 |
timeOrNil |
2372 | 1431 |
"setup the converter to convert from a string to a time and vice versa." |
487 | 1432 |
|
2372 | 1433 |
self objectOrNilOfType:Time |
487 | 1434 |
|
2372 | 1435 |
"Created: / 04-03-1997 / 11:52:47 / cg" |
1436 |
"Modified: / 12-01-2008 / 19:06:21 / cg" |
|
1437 |
! |
|
487 | 1438 |
|
2372 | 1439 |
timeStampOrNil |
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1440 |
<resource: #obsolete> |
2372 | 1441 |
"setup the converter to convert from a string to a timeStamp and vice versa." |
487 | 1442 |
|
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1443 |
self timestampOrNil |
487 | 1444 |
! |
1445 |
||
1446 |
timeToText |
|
1447 |
"setup the converter to convert from a string to a time |
|
1448 |
and vice versa." |
|
1449 |
||
1026 | 1450 |
self timeToTextFormattedBy: #printString |
1451 |
! |
|
1452 |
||
1453 |
timeToTextFormattedBy: format |
|
1454 |
"setup the converter to convert from a string to a time formatted by format |
|
1455 |
and vice versa." |
|
1456 |
||
487 | 1457 |
self |
1458 |
getBlock:[:model | |
|
1459 |
|time| |
|
1460 |
||
1461 |
(time := model value) isNil ifTrue:[ |
|
1026 | 1462 |
Time now perform: format |
487 | 1463 |
] ifFalse:[ |
1026 | 1464 |
time perform: format |
487 | 1465 |
]] |
1466 |
||
1467 |
putBlock: |
|
1468 |
[:model :string | |
|
1469 |
||
1470 |
|value| |
|
1471 |
||
2560 | 1472 |
string isEmptyOrNil ifTrue:[ |
487 | 1473 |
value := Time now |
1026 | 1474 |
] ifFalse:[ |
1475 |
value := Time readFrom:string onError:[Time now] |
|
487 | 1476 |
]. |
1477 |
model value:value] |
|
1478 |
||
1479 |
updateBlock: [:m :a :p | true] |
|
1480 |
||
1481 |
"Modified: 21.2.1997 / 18:59:06 / cg" |
|
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 | 1497 |
! ! |
1498 |
||
1499 |
!TypeConverter class methodsFor:'documentation'! |
|
1500 |
||
1501 |
version |
|
2560 | 1502 |
^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.57 2008-11-03 13:22:48 sr Exp $' |
442 | 1503 |
! ! |