OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 94 | Rev 174 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 156
Line 33... Line 33...
33
import java.beans.PropertyChangeSupport;
33
import java.beans.PropertyChangeSupport;
34
import java.math.BigDecimal;
34
import java.math.BigDecimal;
35
 
35
 
36
import javax.swing.JComponent;
36
import javax.swing.JComponent;
37
import javax.swing.JTextField;
37
import javax.swing.JTextField;
-
 
38
import javax.swing.SwingUtilities;
38
import javax.swing.event.DocumentEvent;
39
import javax.swing.event.DocumentEvent;
39
 
40
 
40
public class NumericTextField extends JTextField implements ValueWrapper<BigDecimal>, Documented, RowItemViewComponent {
41
public class NumericTextField extends JTextField implements ValueWrapper<BigDecimal>, Documented, RowItemViewComponent {
41
 
42
 
42
    private SQLField field;
43
    private SQLField field;
Line 190... Line 191...
190
    @Override
191
    @Override
191
    public BigDecimal getValue() {
192
    public BigDecimal getValue() {
192
        if (this.getText().trim().length() == 0) {
193
        if (this.getText().trim().length() == 0) {
193
            return null;
194
            return null;
194
        } else {
195
        } else {
-
 
196
            try {
195
            return new BigDecimal(this.getText().trim());
197
                return new BigDecimal(this.getText().trim());
-
 
198
            } catch (NumberFormatException ex) {
-
 
199
                SwingUtilities.invokeLater(new Runnable() {
-
 
200
                    @Override
-
 
201
                    public void run() {
-
 
202
                        setText("0");
-
 
203
                    }
-
 
204
                });
-
 
205
                return BigDecimal.ZERO;
-
 
206
            }
196
        }
207
        }
197
    }
208
    }
198
 
209
 
199
    @Override
210
    @Override
200
    public void addValueListener(PropertyChangeListener l) {
211
    public void addValueListener(PropertyChangeListener l) {