OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 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
 package org.openconcerto.erp.core.supplychain.order.action;
15
 
16
import org.openconcerto.erp.action.CreateFrameAbstractAction;
17
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
18
import org.openconcerto.erp.core.supplychain.order.element.CommandeSQLElement;
19
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
20
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
21
import org.openconcerto.sql.Configuration;
22
import org.openconcerto.sql.model.SQLRow;
23
import org.openconcerto.sql.view.IListFrame;
24
import org.openconcerto.sql.view.ListeAddPanel;
25
 
26
import java.awt.event.ActionEvent;
27
import java.math.BigInteger;
28
import java.util.ArrayList;
29
import java.util.List;
30
 
31
import javax.swing.AbstractAction;
32
import javax.swing.Action;
33
import javax.swing.JFrame;
34
import javax.swing.JTable;
35
 
36
public class ListeDesCommandesAction extends CreateFrameAbstractAction {
37
    public ListeDesCommandesAction() {
38
        super();
39
        this.putValue(Action.NAME, "Liste des commandes fournisseurs");
40
    }
41
 
42
    public JFrame createFrame() {
43
        final IListFrame frame = new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("COMMANDE")));
44
 
45
        DeviseNiceTableCellRenderer rend = new DeviseNiceTableCellRenderer();
46
        JTable table = frame.getPanel().getListe().getJTable();
47
        for (int i = 0; i < table.getColumnCount(); i++) {
48
            if (table.getColumnClass(i) == Long.class || table.getColumnClass(i) == BigInteger.class) {
49
                table.getColumnModel().getColumn(i).setCellRenderer(rend);
50
            }
51
        }
52
 
53
        frame.getPanel().getListe().getJTable().addMouseListener(new MouseSheetXmlListeListener(frame.getPanel().getListe(), CommandeXmlSheet.class) {
54
            @Override
55
            public List<AbstractAction> addToMenu() {
56
                // Transfert vers BR
57
                AbstractAction bonAction = (new AbstractAction("Transfert vers BR") {
58
                    public void actionPerformed(ActionEvent e) {
59
                        transfertBonReceptionClient(frame.getPanel().getListe().getSelectedRow());
60
                    }
61
                });
62
 
63
                // Transfert vers facture
64
                AbstractAction factureAction = (new AbstractAction("Transfert vers facture") {
65
                    public void actionPerformed(ActionEvent e) {
66
                        transfertFactureFournisseur(frame.getPanel().getListe().getSelectedRow());
67
                    }
68
                });
69
 
70
                List<AbstractAction> l = new ArrayList<AbstractAction>();
71
                l.add(bonAction);
72
                l.add(factureAction);
73
                return l;
74
            }
75
        });
76
 
77
        return frame;
78
    }
79
 
80
    /**
81
     * Transfert en BR
82
     *
83
     * @param row
84
     */
85
    private void transfertBonReceptionClient(SQLRow row) {
86
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
87
        elt.transfertBR(row.getID());
88
    }
89
 
90
    /**
91
     * Transfert en Facture
92
     *
93
     * @param row
94
     */
95
    private void transfertFactureFournisseur(SQLRow row) {
96
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
97
        elt.transfertFacture(row.getID());
98
    }
99
 
100
}