author | Stefan Vogel <sv@exept.de> |
Thu, 05 Jun 2008 11:21:41 +0200 | |
changeset 2490 | 9bcc1b3fd7e0 |
parent 2440 | 83ae5c86ce7a |
child 2559 | 87d81ccdf4a0 |
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 |
||
313 |
string isEmpty ifTrue:[ |
|
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 |
|
ea6d08251333
added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents:
508
diff
changeset
|
365 |
string isEmpty ifTrue:[ |
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 |
||
1832 | 537 |
string isEmpty ifTrue:[ |
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 |
||
594 |
string isEmpty ifTrue:[ |
|
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 |
||
604 |
! |
|
605 |
||
2366 | 606 |
integerToHexTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
607 |
"setup the converter to convert from a string to a number |
|
608 |
and vice versa, but clamping the number into the range." |
|
609 |
||
610 |
^ self integerToTextMinValue:minVal maxValue:maxVal radix:16 format:formatStringOrNil |
|
611 |
! |
|
612 |
||
1974 | 613 |
integerToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
614 |
"setup the converter to convert from a string to a number |
|
615 |
and vice versa, but clamping the number into the range." |
|
616 |
||
2366 | 617 |
^ self integerToTextMinValue:minVal maxValue:maxVal radix:10 format:formatStringOrNil |
618 |
! |
|
619 |
||
620 |
integerToTextMinValue:minVal maxValue:maxVal radix:radix format:formatStringOrNil |
|
621 |
"setup the converter to convert from a string to a number |
|
622 |
and vice versa, but clamping the number into the range." |
|
623 |
||
1974 | 624 |
self |
625 |
getBlock:[:model | |
|
626 |
|numericValue| |
|
627 |
||
628 |
(numericValue := model value) isNil ifTrue:[ |
|
629 |
String new |
|
630 |
] ifFalse:[ |
|
2379 | 631 |
numericValue isString ifTrue:[ |
632 |
numericValue |
|
1974 | 633 |
] ifFalse:[ |
2379 | 634 |
formatStringOrNil isNil ifTrue:[ |
635 |
numericValue printStringRadix:radix |
|
636 |
] ifFalse:[ |
|
637 |
numericValue printfPrintString:formatStringOrNil |
|
638 |
] |
|
1974 | 639 |
] |
640 |
]] |
|
641 |
||
642 |
putBlock: |
|
643 |
[:model :string | |
|
644 |
||
645 |
|value c| |
|
646 |
||
647 |
string isEmpty ifTrue:[ |
|
648 |
value := 0 |
|
649 |
] ifFalse:[ |
|
2366 | 650 |
value := Integer readFromString:string radix:radix onError:[0]. |
1974 | 651 |
]. |
652 |
minVal notNil ifTrue:[ |
|
653 |
(value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
654 |
value := value max:minVal. |
|
655 |
]. |
|
656 |
maxVal notNil ifTrue:[ |
|
657 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
658 |
value := value min:maxVal. |
|
659 |
]. |
|
660 |
self setNumberValue: value inModel: model fromInput: string. |
|
661 |
] |
|
662 |
||
663 |
updateBlock: [:m :a :p | true] |
|
664 |
||
665 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
666 |
! |
|
667 |
||
2379 | 668 |
integerWithThousandsSeparator |
669 |
^ self integerWithThousandsSeparator:$' |
|
670 |
"/ ^ self integerWithThousandsSeparator:(UserPreferences current thousandsSeparatorCharacter) |
|
671 |
! |
|
672 |
||
673 |
integerWithThousandsSeparator:sep |
|
674 |
"setup the converter to convert from a string to a number with thousands separator |
|
675 |
and vice versa." |
|
676 |
||
677 |
self |
|
678 |
getBlock:[:model | |
|
679 |
|numericValue| |
|
680 |
||
681 |
(numericValue := model value) isNumber ifFalse:[ |
|
682 |
String new |
|
683 |
] ifTrue:[ |
|
684 |
String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep]. |
|
685 |
]] |
|
686 |
||
687 |
putBlock: |
|
688 |
[:model :string | |
|
689 |
||
690 |
|value s2| |
|
691 |
||
692 |
string isEmpty ifTrue:[ |
|
693 |
value := 0 |
|
694 |
] ifFalse:[ |
|
695 |
s2 := string reject:[:ch | ch = sep]. |
|
696 |
value := Number readFromString:s2 onError:[0] |
|
697 |
]. |
|
698 |
model value:value] |
|
699 |
||
2407 | 700 |
updateBlock: [:m :a :p | true] |
2379 | 701 |
! |
702 |
||
1464
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
703 |
literal |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
704 |
"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
|
705 |
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
|
706 |
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
|
707 |
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
|
708 |
|
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
709 |
self |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
710 |
getBlock:[:model | |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
711 |
|val s| |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
712 |
|
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
713 |
val := model value. |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
714 |
(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
|
715 |
val isSymbol ifTrue:[ |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
716 |
"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
|
717 |
(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
|
718 |
s |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
719 |
] ifFalse:[ |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
720 |
val printString |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
721 |
] |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
722 |
] ifFalse:[ |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
723 |
val storeString |
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 |
] ifFalse:[ |
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 |
]] |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
728 |
|
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
729 |
putBlock: |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
730 |
[:model :string | |
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 |
|value s| |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
733 |
|
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
734 |
string size == 0 ifTrue:[ |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
735 |
value := nil |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
736 |
] ifFalse:[ |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
737 |
s := string withoutSeparators. |
1465 | 738 |
"be careful, #readFrom:onError: returns nil for an undefined identifier" |
739 |
s = 'true' ifTrue:[ |
|
740 |
value := true. |
|
741 |
] ifFalse:[s = 'false' ifTrue:[ |
|
742 |
value := false. |
|
743 |
] ifFalse:[s = 'nil' ifTrue:[ |
|
744 |
value := nil. |
|
745 |
] ifFalse:[s first isLetter ifTrue:[ |
|
746 |
value := s asSymbol. |
|
747 |
] ifFalse:[ |
|
748 |
value := Object readFrom:s onError:[ |
|
749 |
s asSymbol |
|
750 |
]. |
|
751 |
]]]]. |
|
1464
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 |
model value:value] |
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 |
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
|
756 |
|
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
757 |
"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
|
758 |
"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
|
759 |
! |
883cfaa89ffa
Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents:
1463
diff
changeset
|
760 |
|
508 | 761 |
number |
762 |
"setup the converter to convert from a string to a number |
|
763 |
and vice versa. Invalid numbers are converted to nil." |
|
764 |
||
765 |
self numberToText |
|
766 |
||
767 |
"Created: 4.4.1997 / 12:46:14 / cg" |
|
768 |
! |
|
769 |
||
442 | 770 |
numberOrNil |
771 |
"setup the converter to convert from a string to a number |
|
772 |
and vice versa. Invalid numbers are converted to nil." |
|
773 |
||
2372 | 774 |
self objectOrNilOfType:Number |
442 | 775 |
|
2372 | 776 |
"Modified: / 12-01-2008 / 19:08:42 / cg" |
442 | 777 |
! |
778 |
||
1463 | 779 |
numberOrNilToTextMinValue:minVal maxValue:maxVal |
780 |
"setup the converter to convert from a string to a number or nil |
|
781 |
and vice versa, but clamping the number into the range." |
|
782 |
||
1974 | 783 |
self numberOrNilToTextMinValue:minVal maxValue:maxVal format:nil |
784 |
! |
|
785 |
||
786 |
numberOrNilToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
|
787 |
"setup the converter to convert from a string to a number or nil |
|
788 |
and vice versa, but clamping the number into the range." |
|
789 |
||
1463 | 790 |
self |
791 |
getBlock:[:model | |
|
792 |
|numericValue| |
|
793 |
||
794 |
(numericValue := model value) isNil ifTrue:[ |
|
795 |
String new |
|
796 |
] ifFalse:[ |
|
1974 | 797 |
formatStringOrNil isNil ifTrue:[ |
798 |
numericValue printString |
|
799 |
] ifFalse:[ |
|
800 |
numericValue printfPrintString:formatStringOrNil |
|
801 |
] |
|
1463 | 802 |
]] |
803 |
||
804 |
putBlock: |
|
805 |
[:model :string | |
|
806 |
||
807 |
|value c| |
|
808 |
||
809 |
(string isEmpty or:[string isBlank]) ifTrue:[ |
|
810 |
value := nil |
|
811 |
] ifFalse:[ |
|
812 |
value := Number readFromString:string onError:[nil]. |
|
813 |
value isNil ifTrue:[ |
|
814 |
||
815 |
] ifFalse:[ |
|
816 |
minVal notNil ifTrue:[ |
|
817 |
(value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
818 |
value := value max:minVal. |
|
819 |
]. |
|
820 |
maxVal notNil ifTrue:[ |
|
821 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
|
822 |
value := value min:maxVal. |
|
823 |
]. |
|
824 |
]. |
|
825 |
]. |
|
826 |
self setNumberValue: value inModel: model fromInput: string. |
|
827 |
] |
|
828 |
||
829 |
updateBlock: [:m :a :p | true] |
|
830 |
||
831 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
832 |
! |
|
833 |
||
1335
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
834 |
numberOrPointOrNil |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
835 |
"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
|
836 |
and vice versa. Invalid numbers/points are converted to nil." |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
837 |
|
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
838 |
self |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
839 |
getBlock:[:model | |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
840 |
|value| |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
841 |
|
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
842 |
(value := model value) isNil ifTrue:[ |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
843 |
String new |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
844 |
] ifFalse:[ |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
845 |
value printString |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
846 |
]] |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
847 |
|
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
848 |
putBlock: |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
849 |
[:model :string | |
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 |
|value| |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
852 |
|
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
853 |
string size > 0 ifTrue:[ |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
854 |
value := Point readFrom:string onError:[ |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
855 |
Number readFrom:string onError:nil |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
856 |
] |
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 |
model value:value] |
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 |
updateBlock: [:m :a :p | true] |
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 |
"Created: / 5.2.2000 / 01:26:48 / cg" |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
863 |
! |
275352274890
a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents:
1314
diff
changeset
|
864 |
|
1149 | 865 |
numberOrStringOrSymbolOrNil |
866 |
"setup the converter to convert from a string to either a numeric literal |
|
867 |
or a symbol and vice versa. |
|
868 |
Invalid strings (i.e. empty) are converted to nil; |
|
869 |
nil values are converted to an empty string. |
|
870 |
This is a very special converter (for the GUI builder) |
|
871 |
- probably not belonging to here" |
|
872 |
||
873 |
self |
|
874 |
getBlock:[:model | |
|
875 |
|litValue| |
|
876 |
||
877 |
(litValue := model value) isNil ifTrue:[ |
|
878 |
String new |
|
879 |
] ifFalse:[ |
|
880 |
litValue storeString |
|
881 |
]] |
|
882 |
||
883 |
putBlock: |
|
884 |
[:model :string | |
|
885 |
||
886 |
|value s| |
|
887 |
||
888 |
string isEmpty ifTrue:[ |
|
889 |
value := nil |
|
890 |
] ifFalse:[ |
|
891 |
value := Number readFrom:string onError:nil. |
|
892 |
value isNil ifTrue:[ |
|
893 |
s := string withoutSeparators. |
|
894 |
(s startsWith:'''') ifTrue:[ |
|
895 |
value := String readFrom:s readStream onError:nil |
|
896 |
] ifFalse:[ |
|
897 |
(s startsWith:'#') ifTrue:[ |
|
898 |
s := s copyFrom:2. |
|
899 |
(s startsWith:$') ifTrue:[ |
|
900 |
s := s copyFrom:2 to:(s size - 1) |
|
901 |
]. |
|
902 |
]. |
|
903 |
value := s asSymbol |
|
904 |
] |
|
905 |
] |
|
906 |
]. |
|
907 |
model value:value] |
|
908 |
||
909 |
updateBlock: [:m :a :p | true] |
|
910 |
||
911 |
"Modified: / 26.10.1997 / 13:50:32 / cg" |
|
912 |
"Created: / 29.10.1997 / 15:49:26 / cg" |
|
913 |
! |
|
914 |
||
726 | 915 |
numberOrSymbolOrNil |
916 |
"setup the converter to convert from a string to either a numeric literal |
|
917 |
or a symbol and vice versa. |
|
918 |
Invalid strings (i.e. empty) are converted to nil; |
|
919 |
nil values are converted to an empty string. |
|
920 |
This is a very special converter (for the GUI builder) |
|
921 |
- probably not belonging to here" |
|
922 |
||
923 |
self |
|
924 |
getBlock:[:model | |
|
925 |
|litValue| |
|
926 |
||
927 |
(litValue := model value) isNil ifTrue:[ |
|
928 |
String new |
|
929 |
] ifFalse:[ |
|
930 |
litValue storeString |
|
931 |
]] |
|
932 |
||
933 |
putBlock: |
|
934 |
[:model :string | |
|
935 |
||
936 |
|value s| |
|
937 |
||
938 |
string isEmpty ifTrue:[ |
|
939 |
value := nil |
|
940 |
] ifFalse:[ |
|
941 |
value := Number readFrom:string onError:nil. |
|
942 |
value isNil ifTrue:[ |
|
943 |
s := string withoutSeparators. |
|
944 |
(s startsWith:'#') ifTrue:[ |
|
945 |
s := s copyFrom:2. |
|
946 |
(s startsWith:$') ifTrue:[ |
|
947 |
s := s copyFrom:2 to:(s size - 1) |
|
948 |
]. |
|
949 |
]. |
|
950 |
value := s asSymbol |
|
951 |
] |
|
952 |
]. |
|
953 |
model value:value] |
|
954 |
||
955 |
updateBlock: [:m :a :p | true] |
|
956 |
||
957 |
"Modified: / 26.10.1997 / 13:50:32 / cg" |
|
958 |
"Created: / 29.10.1997 / 15:49:26 / cg" |
|
959 |
! |
|
960 |
||
442 | 961 |
numberToText |
962 |
"setup the converter to convert from a string to a number |
|
487 | 963 |
and vice versa." |
442 | 964 |
|
965 |
self |
|
966 |
getBlock:[:model | |
|
967 |
|numericValue| |
|
968 |
||
726 | 969 |
(numericValue := model value) isNumber ifFalse:[ |
442 | 970 |
String new |
726 | 971 |
] ifTrue:[ |
442 | 972 |
numericValue printString |
973 |
]] |
|
974 |
||
975 |
putBlock: |
|
976 |
[:model :string | |
|
977 |
||
978 |
|value| |
|
979 |
||
980 |
string isEmpty ifTrue:[ |
|
981 |
value := 0 |
|
982 |
] ifFalse:[ |
|
1000
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
983 |
value := Number readFromString: string onError:[0] |
442 | 984 |
]. |
985 |
model value:value] |
|
986 |
||
987 |
updateBlock: [:m :a :p | true] |
|
988 |
||
726 | 989 |
"Created: / 21.2.1997 / 18:57:05 / cg" |
990 |
"Modified: / 29.10.1997 / 15:49:21 / cg" |
|
442 | 991 |
! |
992 |
||
747
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
993 |
numberToText:numberOfPostDecimals |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
994 |
"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
|
995 |
and vice versa." |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
996 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
997 |
self |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
998 |
getBlock:[:model | |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
999 |
|numericValue| |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1000 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1001 |
(numericValue := model value) isNumber ifFalse:[ |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1002 |
String new |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1003 |
] ifTrue:[ |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1004 |
(numericValue asFixedPoint:numberOfPostDecimals) printString |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1005 |
]] |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1006 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1007 |
putBlock: |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1008 |
[:model :string | |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1009 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1010 |
|value| |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1011 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1012 |
string isEmpty ifTrue:[ |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1013 |
value := 0 |
1000
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
1014 |
] ifFalse:[ |
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
1015 |
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
|
1016 |
]. |
1001 | 1017 |
self setNumberValue: value inModel: model fromInput: string. |
1018 |
] |
|
747
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 |
updateBlock: [:m :a :p | true] |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1021 |
|
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1022 |
"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
|
1023 |
"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
|
1024 |
! |
fe0360fb81ee
added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
1025 |
|
442 | 1026 |
numberToTextFormattedBy:formatString |
1027 |
"setup the converter to convert from a string to a number |
|
1028 |
and vice versa, using formatString. |
|
1029 |
The formatString is currently ignored when numbers are converted |
|
1030 |
from a string." |
|
1031 |
||
1032 |
self |
|
1033 |
getBlock:[:model | |
|
1034 |
|numericValue| |
|
1035 |
||
1036 |
(numericValue := model value) isNil ifTrue:[ |
|
1037 |
String new |
|
1038 |
] ifFalse:[ |
|
1039 |
PrintConverter print:numericValue formattedBy:formatString |
|
1040 |
]] |
|
1041 |
||
1042 |
putBlock: |
|
1043 |
[:model :string | |
|
1044 |
||
1045 |
|value| |
|
1046 |
||
1047 |
string isEmpty ifTrue:[ |
|
1048 |
value := 0 |
|
1000
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
1049 |
] ifFalse:[ |
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
1050 |
value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString" |
442 | 1051 |
]. |
1052 |
model value:value] |
|
1053 |
||
1054 |
updateBlock: [:m :a :p | true] |
|
1055 |
||
1056 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
|
446 | 1057 |
! |
1058 |
||
1426
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1059 |
numberToTextLeftPaddedTo:aSize with:aCharacter |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1060 |
"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
|
1061 |
and vice versa, using formatString. |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1062 |
The formatString is currently ignored when numbers are converted |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1063 |
from a string." |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1064 |
|
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1065 |
self |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1066 |
getBlock:[:model | |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1067 |
|numericValue| |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1068 |
|
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1069 |
(numericValue := model value) isNil ifTrue:[ |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1070 |
String new |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1071 |
] ifFalse:[ |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1072 |
numericValue printStringLeftPaddedTo:aSize with:aCharacter |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1073 |
]] |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1074 |
|
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1075 |
putBlock: |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1076 |
[:model :string | |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1077 |
|
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1078 |
|value| |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1079 |
|
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1080 |
string isEmpty ifTrue:[ |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1081 |
value := 0 |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1082 |
] ifFalse:[ |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1083 |
value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString" |
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 |
model value:value] |
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 |
updateBlock: [:m :a :p | true] |
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 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1090 |
! |
6a5f5372fcc4
added: a converter for number - string, string lwftpaddedTo: with:
tm
parents:
1407
diff
changeset
|
1091 |
|
941
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1092 |
numberToTextMinValue:minVal maxValue:maxVal |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1093 |
"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
|
1094 |
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
|
1095 |
|
1974 | 1096 |
self numberToTextMinValue:minVal maxValue:maxVal format:nil |
1097 |
! |
|
1098 |
||
1099 |
numberToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil |
|
1100 |
"setup the converter to convert from a string to a number |
|
1101 |
and vice versa, but clamping the number into the range." |
|
1102 |
||
941
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1103 |
self |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1104 |
getBlock:[:model | |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1105 |
|numericValue| |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1106 |
|
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1107 |
(numericValue := model value) isNil ifTrue:[ |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1108 |
String new |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1109 |
] ifFalse:[ |
1974 | 1110 |
formatStringOrNil isNil ifTrue:[ |
1111 |
numericValue printString |
|
1112 |
] ifFalse:[ |
|
1113 |
numericValue printfPrintString:formatStringOrNil |
|
1114 |
] |
|
941
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1115 |
]] |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1116 |
|
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1117 |
putBlock: |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1118 |
[:model :string | |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1119 |
|
1001 | 1120 |
|value c| |
941
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1121 |
|
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1122 |
string isEmpty ifTrue:[ |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1123 |
value := 0 |
1001 | 1124 |
] ifFalse:[ |
997 | 1125 |
value := Number readFromString: string onError:[0]. |
1000
70e95e4dca22
use #readFromString:onError: for string->number convertations
tz
parents:
997
diff
changeset
|
1126 |
]. |
942
54949af3f3c1
number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents:
941
diff
changeset
|
1127 |
minVal notNil ifTrue:[ |
1001 | 1128 |
(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
|
1129 |
value := value max:minVal. |
54949af3f3c1
number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents:
941
diff
changeset
|
1130 |
]. |
54949af3f3c1
number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents:
941
diff
changeset
|
1131 |
maxVal notNil ifTrue:[ |
1001 | 1132 |
(value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil]. |
944 | 1133 |
value := value min:maxVal. |
1001 | 1134 |
]. |
1135 |
self setNumberValue: value inModel: model fromInput: string. |
|
1136 |
] |
|
941
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 |
updateBlock: [:m :a :p | true] |
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 |
"Modified: 21.2.1997 / 18:59:44 / cg" |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1141 |
! |
ba196649eaec
added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents:
747
diff
changeset
|
1142 |
|
2372 | 1143 |
objectOrNilOfType:timeOrDateClass |
1144 |
"common code for timeOrNil, dateOrNil and timeStampOrNil" |
|
1145 |
||
1146 |
self |
|
1147 |
getBlock:[:model | |
|
1148 |
|timeOrDate| |
|
1149 |
||
1150 |
(timeOrDate := model value) isNil ifTrue:[ |
|
1151 |
'' |
|
1152 |
] ifFalse:[ |
|
1153 |
timeOrDate printString |
|
1154 |
]] |
|
1155 |
||
1156 |
putBlock: |
|
1157 |
[:model :string | |
|
1158 |
||
1159 |
|value| |
|
1160 |
||
1161 |
string isEmpty ifTrue:[ |
|
1162 |
value := nil |
|
1163 |
] ifFalse:[ |
|
1164 |
value := timeOrDateClass readFrom:string onError:nil |
|
1165 |
]. |
|
1166 |
model value:value] |
|
1167 |
||
1168 |
updateBlock: [:m :a :p | true] |
|
1169 |
||
1170 |
"Created: / 12-01-2008 / 19:05:18 / cg" |
|
1171 |
! |
|
1172 |
||
726 | 1173 |
smalltalkObject |
1174 |
"setup the converter to convert from a string to any smalltalk object |
|
1175 |
and vice versa. The string used is the objects storeString. |
|
1176 |
Invalid strings (i.e. empty) are converted to nil. |
|
1177 |
This is a very special converter (for the GUI builder) |
|
1178 |
- probably not belonging to here" |
|
1179 |
||
1786 | 1180 |
^ self smalltalkObjectWithClass:Object |
1407 | 1181 |
! |
1182 |
||
1183 |
smalltalkObjectOrNil |
|
1184 |
"setup the converter to convert from a string to any smalltalk object |
|
1185 |
and vice versa. The string used is the objects storeString. |
|
1186 |
Invalid strings (i.e. empty) are converted to nil. |
|
1187 |
This is a very special converter (for the GUI builder) |
|
1188 |
- probably not belonging to here" |
|
1189 |
||
1786 | 1190 |
^ self smalltalkObjectOrNilWithClass:Object |
1191 |
! |
|
1192 |
||
1193 |
smalltalkObjectOrNilWithClass:classOfObject |
|
1194 |
"setup the converter to convert from a string to a smalltalk object |
|
1195 |
and vice versa. The string used is the objects storeString. |
|
1196 |
Invalid strings (i.e. empty) are converted to nil. |
|
1197 |
This is a very special converter (for the GUI builder) |
|
1198 |
- probably not belonging to here" |
|
1199 |
||
1407 | 1200 |
self |
1201 |
getBlock:[:model | |v s| |
|
1202 |
v := model value. |
|
1203 |
v isNil ifTrue:[ |
|
1406
7cd10ca1a425
smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents:
1355
diff
changeset
|
1204 |
s := 'nil' |
1199
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1205 |
] ifFalse:[ |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1206 |
s := v storeString. |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1207 |
(v isString or:[v isNumber]) ifFalse:[ |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1208 |
s := s , ' "' , v class name , '" ' |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1209 |
] |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1210 |
]. |
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1211 |
s |
726 | 1212 |
] |
1213 |
||
1214 |
putBlock: |
|
1215 |
[:model :string | |
|
1216 |
||
1217 |
|value| |
|
1218 |
||
1199
623c4cfe253d
better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents:
1197
diff
changeset
|
1219 |
string size > 0 ifTrue:[ |
2199 | 1220 |
value := classOfObject readFrom:string onError:nil. |
1221 |
value := value ? string. |
|
1192
6db390e6463e
default: String in SmalltalkObject
Claus Gittinger <cg@exept.de>
parents:
1149
diff
changeset
|
1222 |
]. |
726 | 1223 |
model value:value |
1224 |
] |
|
1225 |
||
1226 |
updateBlock: [:m :a :p | true] |
|
1227 |
||
2199 | 1228 |
"Created: / 29-10-1997 / 15:50:16 / cg" |
1229 |
"Modified: / 05-09-2006 / 17:57:53 / cg" |
|
726 | 1230 |
! |
1231 |
||
1786 | 1232 |
smalltalkObjectWithClass:classOfObject |
1233 |
"setup the converter to convert from a string to a smalltalk object |
|
1234 |
and vice versa. The string used is the objects storeString. |
|
1235 |
Invalid strings (i.e. empty) are converted to nil. |
|
1236 |
This is a very special converter (for the GUI builder) |
|
1237 |
- probably not belonging to here" |
|
1238 |
||
1239 |
self |
|
1240 |
getBlock:[:model | |v s| |
|
1241 |
v := model value. |
|
1242 |
v isNil ifTrue:[ |
|
1243 |
s := '' |
|
1244 |
] ifFalse:[ |
|
1245 |
s := v storeString. |
|
1246 |
(v isString or:[v isNumber]) ifFalse:[ |
|
1247 |
s := s , ' "' , v class name , '" ' |
|
1248 |
] |
|
1249 |
]. |
|
1250 |
s |
|
1251 |
] |
|
1252 |
||
1253 |
putBlock: |
|
1254 |
[:model :string | |
|
1255 |
||
1256 |
|value| |
|
1257 |
||
1258 |
string size > 0 ifTrue:[ |
|
1259 |
value := classOfObject readFrom:string onError:nil. |
|
2199 | 1260 |
model value:value ? string |
1786 | 1261 |
]. |
1262 |
] |
|
1263 |
||
1264 |
updateBlock: [:m :a :p | true] |
|
1265 |
||
2199 | 1266 |
"Created: / 29-10-1997 / 15:50:16 / cg" |
1267 |
"Modified: / 05-09-2006 / 17:57:37 / cg" |
|
1786 | 1268 |
! |
1269 |
||
1270 |
smalltalkPoint |
|
1271 |
"setup the converter to convert from a string to a point object |
|
1272 |
and vice versa. The string used is the points storeString. |
|
1273 |
Invalid strings (i.e. empty) are converted to nil. |
|
1274 |
This is a very special converter (for the GUI builder) |
|
1275 |
- probably not belonging to here" |
|
1276 |
||
1277 |
^ self smalltalkObjectWithClass:Point |
|
1278 |
! |
|
1279 |
||
1653
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1280 |
symbolOrBooleanOrNil |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1281 |
"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
|
1282 |
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
|
1283 |
nil values are converted to an empty string. |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1284 |
In addition, the strings true/false convert to/from booleans." |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1285 |
|
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1286 |
self |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1287 |
getBlock:[:model | |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1288 |
|symbolValue| |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1289 |
|
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1290 |
((symbolValue := model value) isSymbol |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1291 |
or:[symbolValue isBoolean]) |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1292 |
ifFalse:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1293 |
'' |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1294 |
] ifTrue:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1295 |
symbolValue printString. "/ storeString |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1296 |
]] |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1297 |
|
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1298 |
putBlock: |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1299 |
[:model :string | |
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 |
|value s| |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1302 |
|
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1303 |
string size == 0 ifTrue:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1304 |
value := nil |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1305 |
] ifFalse:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1306 |
s := string withoutSeparators. |
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. |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1309 |
(s startsWith:$') ifTrue:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1310 |
s := s copyFrom:2 to:(s size - 1) |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1311 |
]. |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1312 |
value := s asSymbol |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1313 |
] ifFalse:[ |
2440 | 1314 |
(#('true' 'false') includes:s) ifTrue:[ |
1653
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1315 |
value := Object readFromString:s. |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1316 |
] ifFalse:[ |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1317 |
value := s asSymbol |
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 |
]. |
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 |
model value:value] |
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 |
updateBlock: [:m :a :p | true] |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1324 |
|
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1325 |
"Created: / 21.2.1997 / 18:58:38 / cg" |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1326 |
"Modified: / 26.5.1998 / 15:06:06 / cg" |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1327 |
! |
f086f72cc8fa
new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents:
1465
diff
changeset
|
1328 |
|
446 | 1329 |
symbolOrNil |
1330 |
"setup the converter to convert from a string to a symbol |
|
722
ea6d08251333
added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents:
508
diff
changeset
|
1331 |
and vice versa. Invalid symbols (i.e. empty) are converted to nil; |
ea6d08251333
added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents:
508
diff
changeset
|
1332 |
nil values are converted to an empty string." |
446 | 1333 |
|
1334 |
self |
|
1335 |
getBlock:[:model | |
|
1336 |
|symbolValue| |
|
1337 |
||
726 | 1338 |
(symbolValue := model value) isSymbol ifFalse:[ |
446 | 1339 |
String new |
726 | 1340 |
] ifTrue:[ |
946 | 1341 |
symbolValue printString. "/ storeString |
446 | 1342 |
]] |
1343 |
||
1344 |
putBlock: |
|
1345 |
[:model :string | |
|
1346 |
||
1347 |
|value s| |
|
1348 |
||
1314 | 1349 |
string size == 0 ifTrue:[ |
446 | 1350 |
value := nil |
1351 |
] ifFalse:[ |
|
1352 |
s := string withoutSeparators. |
|
1353 |
(s startsWith:'#') ifTrue:[ |
|
726 | 1354 |
s := s copyFrom:2. |
1355 |
(s startsWith:$') ifTrue:[ |
|
1356 |
s := s copyFrom:2 to:(s size - 1) |
|
1357 |
] |
|
446 | 1358 |
]. |
1359 |
value := s asSymbol |
|
1360 |
]. |
|
1361 |
model value:value] |
|
1362 |
||
1363 |
updateBlock: [:m :a :p | true] |
|
1364 |
||
722
ea6d08251333
added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents:
508
diff
changeset
|
1365 |
"Created: / 21.2.1997 / 18:58:38 / cg" |
946 | 1366 |
"Modified: / 26.5.1998 / 15:06:06 / cg" |
487 | 1367 |
! |
1368 |
||
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1369 |
time |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1370 |
^ self time24H |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1371 |
! |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1372 |
|
1047 | 1373 |
time12H |
1026 | 1374 |
"setup the converter to convert from a string to a time formatted by 12 hours |
1375 |
and vice versa." |
|
1376 |
||
1027 | 1377 |
self timeToTextFormattedBy: #printString12HourFormat |
1026 | 1378 |
|
1379 |
||
1380 |
! |
|
1381 |
||
1047 | 1382 |
time24H |
1026 | 1383 |
"setup the converter to convert from a string to a time formatted by 24 hours |
1384 |
and vice versa." |
|
1385 |
||
1027 | 1386 |
self timeToTextFormattedBy: #printString24HourFormat |
1026 | 1387 |
|
1388 |
||
1389 |
! |
|
1390 |
||
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1391 |
timeOfClass:timeClass withFormat:aFormatString orDefault:defaultValue |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1392 |
"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
|
1393 |
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
|
1394 |
Invalid times are converted to defaultValue; likewise, |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1395 |
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
|
1396 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1397 |
self |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1398 |
getBlock:[:model | |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1399 |
|time| |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1400 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1401 |
(time := model value) isNil ifTrue:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1402 |
time := defaultValue |
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 |
time isNil ifTrue:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1405 |
'' |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1406 |
] ifFalse:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1407 |
aFormatString isNil ifTrue:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1408 |
time printString |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1409 |
] ifFalse:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1410 |
time printStringFormat:aFormatString |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1411 |
]]] |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1412 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1413 |
putBlock: |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1414 |
[:model :string | |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1415 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1416 |
|value| |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1417 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1418 |
string isEmpty ifTrue:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1419 |
value := defaultValue |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1420 |
] ifFalse:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1421 |
"/ aFormatString isNil ifTrue:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1422 |
value := timeClass readFrom:string onError:defaultValue |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1423 |
"/ ] ifFalse:[ |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1424 |
"/ value := timeClass readFrom:string printFormat:aFormatString onError:defaultValue |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1425 |
"/ ] |
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 |
model value:value] |
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 |
updateBlock: [:m :a :p | true] |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1430 |
! |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1431 |
|
487 | 1432 |
timeOrNil |
2372 | 1433 |
"setup the converter to convert from a string to a time and vice versa." |
487 | 1434 |
|
2372 | 1435 |
self objectOrNilOfType:Time |
487 | 1436 |
|
2372 | 1437 |
"Created: / 04-03-1997 / 11:52:47 / cg" |
1438 |
"Modified: / 12-01-2008 / 19:06:21 / cg" |
|
1439 |
! |
|
487 | 1440 |
|
2372 | 1441 |
timeStampOrNil |
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1442 |
<resource: #obsolete> |
2372 | 1443 |
"setup the converter to convert from a string to a timeStamp and vice versa." |
487 | 1444 |
|
2401
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1445 |
self timestampOrNil |
487 | 1446 |
! |
1447 |
||
1448 |
timeToText |
|
1449 |
"setup the converter to convert from a string to a time |
|
1450 |
and vice versa." |
|
1451 |
||
1026 | 1452 |
self timeToTextFormattedBy: #printString |
1453 |
! |
|
1454 |
||
1455 |
timeToTextFormattedBy: format |
|
1456 |
"setup the converter to convert from a string to a time formatted by format |
|
1457 |
and vice versa." |
|
1458 |
||
487 | 1459 |
self |
1460 |
getBlock:[:model | |
|
1461 |
|time| |
|
1462 |
||
1463 |
(time := model value) isNil ifTrue:[ |
|
1026 | 1464 |
Time now perform: format |
487 | 1465 |
] ifFalse:[ |
1026 | 1466 |
time perform: format |
487 | 1467 |
]] |
1468 |
||
1469 |
putBlock: |
|
1470 |
[:model :string | |
|
1471 |
||
1472 |
|value| |
|
1473 |
||
1474 |
string isEmpty ifTrue:[ |
|
1475 |
value := Time now |
|
1026 | 1476 |
] ifFalse:[ |
1477 |
value := Time readFrom:string onError:[Time now] |
|
487 | 1478 |
]. |
1479 |
model value:value] |
|
1480 |
||
1481 |
updateBlock: [:m :a :p | true] |
|
1482 |
||
1483 |
"Modified: 21.2.1997 / 18:59:06 / cg" |
|
1484 |
"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
|
1485 |
! |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1486 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1487 |
timestamp |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1488 |
"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
|
1489 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1490 |
^ self timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1491 |
! |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1492 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1493 |
timestampOrNil |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1494 |
"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
|
1495 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1496 |
self objectOrNilOfType:Timestamp |
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1497 |
|
6ce0d64635e0
Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents:
2379
diff
changeset
|
1498 |
"Modified: / 12-01-2008 / 19:06:06 / cg" |
442 | 1499 |
! ! |
1500 |
||
1501 |
!TypeConverter class methodsFor:'documentation'! |
|
1502 |
||
1503 |
version |
|
2440 | 1504 |
^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.55 2008-04-23 10:00:27 cg Exp $' |
442 | 1505 |
! ! |