OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Rev 25 | Go to most recent revision | Details | Compare with Previous | 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.supplychain.order.element.CommandeSQLElement;
18
import org.openconcerto.erp.generationDoc.gestcomm.CommandeXmlSheet;
19
import org.openconcerto.erp.model.MouseSheetXmlListeListener;
20
import org.openconcerto.sql.Configuration;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.view.IListFrame;
23
import org.openconcerto.sql.view.ListeAddPanel;
24
 
25
import java.awt.event.ActionEvent;
26
import java.util.ArrayList;
27
import java.util.List;
28
 
29
import javax.swing.AbstractAction;
30
import javax.swing.Action;
31
import javax.swing.JFrame;
32
 
33
public class ListeDesCommandesAction extends CreateFrameAbstractAction {
34
    public ListeDesCommandesAction() {
35
        super();
36
        this.putValue(Action.NAME, "Liste des commandes fournisseurs");
37
    }
38
 
39
    public JFrame createFrame() {
40
        final IListFrame frame = new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("COMMANDE")));
41
 
42
        frame.getPanel().getListe().getJTable().addMouseListener(new MouseSheetXmlListeListener(frame.getPanel().getListe(), CommandeXmlSheet.class) {
43
            @Override
44
            public List<AbstractAction> addToMenu() {
45
                // Transfert vers BR
46
                AbstractAction bonAction = (new AbstractAction("Transfert vers BR") {
47
                    public void actionPerformed(ActionEvent e) {
48
                        transfertBonReceptionClient(frame.getPanel().getListe().getSelectedRow());
49
                    }
50
                });
51
 
52
                // Transfert vers facture
53
                AbstractAction factureAction = (new AbstractAction("Transfert vers facture") {
54
                    public void actionPerformed(ActionEvent e) {
55
                        transfertFactureFournisseur(frame.getPanel().getListe().getSelectedRow());
56
                    }
57
                });
58
 
59
                List<AbstractAction> l = new ArrayList<AbstractAction>();
60
                l.add(bonAction);
61
                l.add(factureAction);
62
                return l;
63
            }
64
        });
65
 
66
        return frame;
67
    }
68
 
69
    /**
70
     * Transfert en BR
71
     *
72
     * @param row
73
     */
74
    private void transfertBonReceptionClient(SQLRow row) {
75
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
76
        elt.transfertBR(row.getID());
77
    }
78
 
79
    /**
80
     * Transfert en Facture
81
     *
82
     * @param row
83
     */
84
    private void transfertFactureFournisseur(SQLRow row) {
85
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
86
        elt.transfertFacture(row.getID());
87
    }
88
 
89
}