OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 182 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
182 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
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
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.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 /*
15
 * Créé le 23 avr. 2012
16
 */
17
package org.openconcerto.erp.core.supplychain.stock.element;
18
 
19
import org.openconcerto.sql.element.SQLElement;
20
import org.openconcerto.sql.model.SQLRowAccessor;
21
import org.openconcerto.sql.sqlobject.SQLRequestComboBox;
22
import org.openconcerto.ui.DefaultGridBagConstraints;
23
import org.openconcerto.ui.JDate;
24
 
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.event.ActionEvent;
28
import java.util.Date;
29
 
30
import javax.swing.AbstractAction;
31
import javax.swing.JButton;
32
import javax.swing.JCheckBox;
185 ilm 33
import javax.swing.JFrame;
182 ilm 34
import javax.swing.JLabel;
35
import javax.swing.JPanel;
185 ilm 36
import javax.swing.SwingUtilities;
182 ilm 37
 
38
public class EtatStockCreationPanel extends JPanel {
39
 
40
    public EtatStockCreationPanel(final SQLElement depotElt) {
41
        super(new GridBagLayout());
42
 
43
        final SQLRequestComboBox boxDepot = new SQLRequestComboBox(false);
44
        boxDepot.uiInit(depotElt.createComboRequest());
45
 
46
        GridBagConstraints c = new DefaultGridBagConstraints();
47
        JLabel labelCom = new JLabel("Dépôt ");
48
        this.add(labelCom, c);
49
        c.gridx++;
50
        this.add(boxDepot, c);
51
 
52
        c.gridx++;
53
        JLabel labelD = new JLabel("au");
54
        this.add(labelD, c);
55
        final JDate dateDebut = new JDate(true);
56
        c.gridx++;
57
        this.add(dateDebut, c);
58
 
59
        final JCheckBox box = new JCheckBox("intégrer uniquement les articles du dépôt");
60
        box.setSelected(true);
61
        c.gridx++;
62
        this.add(box, c);
63
 
64
        final JButton buttonValid = new JButton(new AbstractAction("Valider") {
65
 
66
            @Override
67
            public void actionPerformed(ActionEvent e) {
68
                SQLRowAccessor row = boxDepot.getSelectedRow();
69
                final SQLRowAccessor rowDepot;
70
                if (row != null && !row.isUndefined()) {
71
                    rowDepot = boxDepot.getSelectedRow();
72
                } else {
73
                    rowDepot = depotElt.getTable().getRow(DepotStockSQLElement.DEFAULT_ID);
74
                }
75
 
76
                Date d = dateDebut.getDate() == null ? new Date() : dateDebut.getDate();
77
 
78
                EtatStockSnapshotCreator creator = new EtatStockSnapshotCreator(rowDepot, d, depotElt.getTable().getDBRoot(), !box.isSelected());
79
                creator.create();
185 ilm 80
                ((JFrame) SwingUtilities.getRoot(EtatStockCreationPanel.this)).dispose();
182 ilm 81
            }
82
 
83
        });
84
        c.gridx++;
85
        // buttonValid.setEnabled(false);
86
        this.add(buttonValid, c);
87
 
88
    }
89
 
90
}