OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 177 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 19... Line 19...
19
import org.openconcerto.erp.core.common.ui.RowValuesMultiLineEditTable;
19
import org.openconcerto.erp.core.common.ui.RowValuesMultiLineEditTable;
20
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
21
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieKm;
21
import org.openconcerto.erp.generationEcritures.GenerationMvtSaisieKm;
22
import org.openconcerto.erp.preferences.DefaultNXProps;
22
import org.openconcerto.erp.preferences.DefaultNXProps;
23
import org.openconcerto.sql.Configuration;
23
import org.openconcerto.sql.Configuration;
-
 
24
import org.openconcerto.sql.TM;
24
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.element.SQLElement;
25
import org.openconcerto.sql.model.SQLRow;
26
import org.openconcerto.sql.model.SQLRow;
26
import org.openconcerto.sql.model.SQLRowAccessor;
27
import org.openconcerto.sql.model.SQLRowAccessor;
27
import org.openconcerto.sql.model.SQLRowValues;
28
import org.openconcerto.sql.model.SQLRowValues;
28
import org.openconcerto.sql.model.SQLTable;
29
import org.openconcerto.sql.model.SQLTable;
Line 34... Line 35...
34
import org.openconcerto.sql.view.list.RowValuesTableModel;
35
import org.openconcerto.sql.view.list.RowValuesTableModel;
35
import org.openconcerto.sql.view.list.SQLTableElement;
36
import org.openconcerto.sql.view.list.SQLTableElement;
36
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
37
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
37
import org.openconcerto.sql.view.list.ValidStateChecker;
38
import org.openconcerto.sql.view.list.ValidStateChecker;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
39
import org.openconcerto.ui.DefaultGridBagConstraints;
-
 
40
import org.openconcerto.ui.JComponentUtils;
39
import org.openconcerto.ui.RangedIntegerTableCellEditor;
41
import org.openconcerto.ui.RangedIntegerTableCellEditor;
40
import org.openconcerto.utils.DecimalUtils;
42
import org.openconcerto.utils.DecimalUtils;
41
import org.openconcerto.utils.GestionDevise;
43
import org.openconcerto.utils.GestionDevise;
42
import org.openconcerto.utils.Tuple2;
44
import org.openconcerto.utils.Tuple2;
43
import org.openconcerto.utils.checks.ValidState;
45
import org.openconcerto.utils.checks.ValidState;
44
 
46
 
45
import java.awt.GridBagConstraints;
47
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
48
import java.awt.GridBagLayout;
47
import java.awt.event.ActionEvent;
49
import java.awt.event.ActionEvent;
-
 
50
import java.awt.event.ActionListener;
48
import java.awt.event.KeyEvent;
51
import java.awt.event.KeyEvent;
49
import java.awt.event.KeyListener;
52
import java.awt.event.KeyListener;
50
import java.awt.event.MouseEvent;
53
import java.awt.event.MouseEvent;
51
import java.awt.event.MouseListener;
54
import java.awt.event.MouseListener;
52
import java.beans.PropertyChangeEvent;
55
import java.beans.PropertyChangeEvent;
53
import java.beans.PropertyChangeListener;
56
import java.beans.PropertyChangeListener;
54
import java.math.BigDecimal;
57
import java.math.BigDecimal;
55
import java.math.RoundingMode;
58
import java.math.RoundingMode;
56
import java.sql.SQLException;
59
import java.sql.SQLException;
-
 
60
import java.util.Arrays;
57
import java.util.Calendar;
61
import java.util.Calendar;
58
import java.util.Collection;
62
import java.util.Collection;
59
import java.util.Date;
63
import java.util.Date;
60
import java.util.List;
64
import java.util.List;
61
import java.util.Vector;
65
import java.util.Vector;
62
 
66
 
63
import javax.swing.AbstractAction;
67
import javax.swing.AbstractAction;
64
import javax.swing.BorderFactory;
68
import javax.swing.BorderFactory;
-
 
69
import javax.swing.JButton;
65
import javax.swing.JCheckBox;
70
import javax.swing.JCheckBox;
66
import javax.swing.JLabel;
71
import javax.swing.JLabel;
67
import javax.swing.JOptionPane;
72
import javax.swing.JOptionPane;
68
import javax.swing.JPanel;
73
import javax.swing.JPanel;
69
import javax.swing.JPopupMenu;
74
import javax.swing.JPopupMenu;
Line 293... Line 298...
293
        m2.setFillWithField("NOM");
298
        m2.setFillWithField("NOM");
294
        m2.setWhere(w);
299
        m2.setWhere(w);
295
 
300
 
296
        TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
301
        TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
297
 
302
 
-
 
303
        JButton buttonClone = new JButton(TM.tr("duplicateLine"));
-
 
304
        buttonClone.addActionListener(new ActionListener() {
-
 
305
            public void actionPerformed(ActionEvent event) {
-
 
306
                cloneLine(table.getSelectedRow());
-
 
307
            }
-
 
308
        });
-
 
309
        buttonClone.setEnabled(false);
-
 
310
        c.gridx++;
-
 
311
        JComponentUtils.setMinimumWidth(buttonClone, 95);
-
 
312
 
298
        this.controlPanel = new RowValuesTableControlPanel(this.table);
313
        this.controlPanel = new RowValuesTableControlPanel(this.table, Arrays.asList(buttonClone));
-
 
314
        this.controlPanel.setVisibleButtonClone(false);
299
        controlPanel.setButtonAjouterEnabled(false);
315
        this.controlPanel.setButtonAjouterEnabled(false);
300
        this.add(controlPanel, c);
316
        this.add(this.controlPanel, c);
301
 
317
 
302
        c.gridy++;
318
        c.gridy++;
303
        c.fill = GridBagConstraints.BOTH;
319
        c.fill = GridBagConstraints.BOTH;
304
        c.weightx = 1;
320
        c.weightx = 1;
305
        c.weighty = 1;
321
        c.weighty = 1;
Line 686... Line 702...
686
    }
702
    }
687
 
703
 
688
    public void mouseExited(final MouseEvent e) {
704
    public void mouseExited(final MouseEvent e) {
689
    }
705
    }
690
 
706
 
-
 
707
    private void cloneLine(int row) {
-
 
708
        if (row < 0) {
-
 
709
            System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
-
 
710
            Thread.dumpStack();
-
 
711
            return;
-
 
712
        }
-
 
713
        SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
-
 
714
 
-
 
715
        SQLRowValues rowValsBis = rowVals.deepCopy();
-
 
716
        rowValsBis.clearPrimaryKeys();
-
 
717
        rowValsBis.put(rowValsBis.getTable().getOrderField().getName(), null);
-
 
718
 
-
 
719
        this.table.getRowValuesTableModel().getSQLElement().clearPrivateFields(rowValsBis);
-
 
720
        rowValsBis.putEmptyLink("ID_ECRITURE");
-
 
721
        for (String elt : this.table.getClearCloneTableElement()) {
-
 
722
            if (rowValsBis.getTable().getFieldsName().contains(elt)) {
-
 
723
                rowValsBis.putEmptyLink(elt);
-
 
724
            }
-
 
725
        }
-
 
726
 
-
 
727
        this.table.getRowValuesTableModel().addRow(rowValsBis);
-
 
728
    }
691
}
729
}