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 | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 Rev 174
Line 18... Line 18...
18
import org.openconcerto.erp.core.common.ui.MultiLineTableCellEditor;
18
import org.openconcerto.erp.core.common.ui.MultiLineTableCellEditor;
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.preferences.DefaultNXProps;
21
import org.openconcerto.erp.preferences.DefaultNXProps;
22
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.sql.Configuration;
-
 
23
import org.openconcerto.sql.TM;
23
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.element.SQLElement;
24
import org.openconcerto.sql.model.SQLBase;
25
import org.openconcerto.sql.model.SQLBase;
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.SQLRowListRSH;
28
import org.openconcerto.sql.model.SQLRowListRSH;
Line 36... Line 37...
36
import org.openconcerto.sql.view.list.RowValuesTableModel;
37
import org.openconcerto.sql.view.list.RowValuesTableModel;
37
import org.openconcerto.sql.view.list.SQLTableElement;
38
import org.openconcerto.sql.view.list.SQLTableElement;
38
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
39
import org.openconcerto.sql.view.list.TextTableCellEditorWithCompletion;
39
import org.openconcerto.sql.view.list.ValidStateChecker;
40
import org.openconcerto.sql.view.list.ValidStateChecker;
40
import org.openconcerto.ui.DefaultGridBagConstraints;
41
import org.openconcerto.ui.DefaultGridBagConstraints;
-
 
42
import org.openconcerto.ui.JComponentUtils;
41
import org.openconcerto.utils.checks.ValidState;
43
import org.openconcerto.utils.checks.ValidState;
42
 
44
 
43
import java.awt.GridBagConstraints;
45
import java.awt.GridBagConstraints;
44
import java.awt.GridBagLayout;
46
import java.awt.GridBagLayout;
45
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionEvent;
-
 
48
import java.awt.event.ActionListener;
46
import java.awt.event.MouseEvent;
49
import java.awt.event.MouseEvent;
47
import java.awt.event.MouseListener;
50
import java.awt.event.MouseListener;
-
 
51
import java.util.Arrays;
48
import java.util.HashMap;
52
import java.util.HashMap;
49
import java.util.List;
53
import java.util.List;
50
import java.util.Map;
54
import java.util.Map;
51
import java.util.Vector;
55
import java.util.Vector;
52
 
56
 
53
import javax.swing.AbstractAction;
57
import javax.swing.AbstractAction;
-
 
58
import javax.swing.JButton;
54
import javax.swing.JPanel;
59
import javax.swing.JPanel;
55
import javax.swing.JPopupMenu;
60
import javax.swing.JPopupMenu;
56
import javax.swing.JScrollPane;
61
import javax.swing.JScrollPane;
57
import javax.swing.SwingUtilities;
62
import javax.swing.SwingUtilities;
58
import javax.swing.ToolTipManager;
63
import javax.swing.ToolTipManager;
Line 141... Line 146...
141
                    ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
146
                    ComptePCESQLElement elt = Configuration.getInstance().getDirectory().getElement(ComptePCESQLElement.class);
142
 
147
 
143
                    @Override
148
                    @Override
144
                    public ValidState getValidState(Object o) {
149
                    public ValidState getValidState(Object o) {
145
                        if (o != null) {
150
                        if (o != null) {
146
                            return elt.getCompteNumeroValidState(o.toString());
151
                            return this.elt.getCompteNumeroValidState(o.toString());
147
                        }
152
                        }
148
                        return super.getValidState(o);
153
                        return super.getValidState(o);
149
                    }
154
                    }
150
                });
155
                });
151
        m.fill("NOM", "NOM");
156
        m.fill("NOM", "NOM");
Line 159... Line 164...
159
        m2.fill("NUMERO", "NUMERO");
164
        m2.fill("NUMERO", "NUMERO");
160
        m2.setFillWithField("NOM");
165
        m2.setFillWithField("NOM");
161
        m2.setWhere(w);
166
        m2.setWhere(w);
162
 
167
 
163
        TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
168
        TextTableCellEditorWithCompletion t = (TextTableCellEditorWithCompletion) this.tableElementNumeroCompte.getTableCellEditor(this.table);
-
 
169
        JButton buttonClone = new JButton(TM.tr("duplicateLine"));
-
 
170
        buttonClone.addActionListener(new ActionListener() {
-
 
171
            public void actionPerformed(ActionEvent event) {
-
 
172
                cloneLine(table.getSelectedRow());
-
 
173
            }
-
 
174
        });
-
 
175
        buttonClone.setEnabled(false);
-
 
176
        c.gridx++;
-
 
177
        JComponentUtils.setMinimumWidth(buttonClone, 95);
164
 
178
 
-
 
179
        RowValuesTableControlPanel rowValuesTableControlPanel = new RowValuesTableControlPanel(this.table, Arrays.asList(buttonClone));
-
 
180
        rowValuesTableControlPanel.setVisibleButtonClone(false);
165
        this.add(new RowValuesTableControlPanel(this.table), c);
181
        this.add(rowValuesTableControlPanel, c);
166
 
182
 
167
        c.gridy++;
183
        c.gridy++;
168
        c.fill = GridBagConstraints.BOTH;
184
        c.fill = GridBagConstraints.BOTH;
169
        c.weightx = 1;
185
        c.weightx = 1;
170
        c.weighty = 1;
186
        c.weighty = 1;
Line 220... Line 236...
220
        final SQLRowValues rowVals = new SQLRowValues(getModel().getSQLElement().getTable(), m);
236
        final SQLRowValues rowVals = new SQLRowValues(getModel().getSQLElement().getTable(), m);
221
        this.table.getRowValuesTableModel().addRow(rowVals, false);
237
        this.table.getRowValuesTableModel().addRow(rowVals, false);
222
 
238
 
223
    }
239
    }
224
 
240
 
-
 
241
    private void cloneLine(int row) {
-
 
242
        if (row < 0) {
-
 
243
            System.err.println("RowValuesTableControlPanel.cloneLine() wrong selected line, index = " + row);
-
 
244
            Thread.dumpStack();
-
 
245
            return;
-
 
246
        }
-
 
247
        SQLRowValues rowVals = this.table.getRowValuesTableModel().getRowValuesAt(row);
-
 
248
 
-
 
249
        SQLRowValues rowValsBis = rowVals.deepCopy();
-
 
250
        rowValsBis.clearPrimaryKeys();
-
 
251
        rowValsBis.put(rowValsBis.getTable().getOrderField().getName(), null);
-
 
252
 
-
 
253
        this.table.getRowValuesTableModel().getSQLElement().clearPrivateFields(rowValsBis);
-
 
254
        rowValsBis.putEmptyLink("ID_ECRITURE");
-
 
255
        for (String elt : this.table.getClearCloneTableElement()) {
-
 
256
            if (rowValsBis.getTable().getFieldsName().contains(elt)) {
-
 
257
                rowValsBis.putEmptyLink(elt);
-
 
258
            }
-
 
259
        }
-
 
260
 
-
 
261
        this.table.getRowValuesTableModel().addRow(rowValsBis);
-
 
262
    }
-
 
263
 
225
    /**
264
    /**
226
     * Remplit la RowValuesTable avec les ecritures du mouvement
265
     * Remplit la RowValuesTable avec les ecritures du mouvement
227
     * 
266
     * 
228
     * @param idMvt id du mouvement
267
     * @param idMvt id du mouvement
229
     * @param contrePasser contrePasser le mouvement
268
     * @param contrePasser contrePasser le mouvement
Line 332... Line 371...
332
 
371
 
333
    public void fillEmptyEntryLabel(String previousText, String text) {
372
    public void fillEmptyEntryLabel(String previousText, String text) {
334
        assert SwingUtilities.isEventDispatchThread();
373
        assert SwingUtilities.isEventDispatchThread();
335
        if (text == null)
374
        if (text == null)
336
            return;
375
            return;
337
        RowValuesTableModel model = table.getRowValuesTableModel();
376
        RowValuesTableModel model = this.table.getRowValuesTableModel();
338
        int size = model.getRowCount();
377
        int size = model.getRowCount();
339
        for (int i = 0; i < size; i++) {
378
        for (int i = 0; i < size; i++) {
340
            SQLRowValues r = model.getRowValuesAt(i);
379
            SQLRowValues r = model.getRowValuesAt(i);
341
            if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").trim().equals(previousText)) {
380
            if (r.getString("NOM_ECRITURE") == null || r.getString("NOM_ECRITURE").trim().isEmpty() || r.getString("NOM_ECRITURE").equals(previousText)) {
342
                r.put("NOM_ECRITURE", text);
381
                r.put("NOM_ECRITURE", text);
343
            }
382
            }
344
        }
383
        }
345
        model.fireTableDataChanged();
384
        model.fireTableDataChanged();
346
    }
385
    }