OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 83 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 45... Line 45...
45
 
45
 
46
    protected int precision;
46
    protected int precision;
47
    protected final DecimalFormat decimalFormat = new DecimalFormat("0.00#######");
47
    protected final DecimalFormat decimalFormat = new DecimalFormat("0.00#######");
48
 
48
 
49
    public DeviseNumericCellEditor(SQLField field) {
49
    public DeviseNumericCellEditor(SQLField field) {
-
 
50
        this(field.getType().getDecimalDigits());
-
 
51
    }
-
 
52
 
-
 
53
    public DeviseNumericCellEditor(int precision) {
50
        final DecimalFormatSymbols symbol = DecimalFormatSymbols.getInstance();
54
        final DecimalFormatSymbols symbol = DecimalFormatSymbols.getInstance();
51
        symbol.setDecimalSeparator('.');
55
        symbol.setDecimalSeparator('.');
52
        decimalFormat.setDecimalFormatSymbols(symbol);
56
        decimalFormat.setDecimalFormatSymbols(symbol);
53
 
57
 
54
        // Mimic JTable.GenericEditor behavior
58
        // Mimic JTable.GenericEditor behavior
55
        this.textField.setBorder(new LineBorder(Color.black));
59
        this.textField.setBorder(new LineBorder(Color.black));
56
        this.textField.setHorizontalAlignment(JTextField.RIGHT);
60
        this.textField.setHorizontalAlignment(JTextField.RIGHT);
57
        this.precision = field.getType().getDecimalDigits();
61
        this.precision = precision;
58
        // On ne peut saisir qu'un chiffre à 2 décimales
62
        // On ne peut saisir qu'un chiffre à 2 décimales
59
        textField.addKeyListener(new KeyAdapter() {
63
        textField.addKeyListener(new KeyAdapter() {
60
            public void keyTyped(java.awt.event.KeyEvent keyEvent) {
64
            public void keyTyped(java.awt.event.KeyEvent keyEvent) {
61
 
65
 
62
                final char keychar = keyEvent.getKeyChar();
66
                final char keychar = keyEvent.getKeyChar();