OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Rev 61 | 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;
25 ilm 24
import org.openconcerto.sql.view.list.IListe;
25
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
26
import org.openconcerto.sql.view.list.RowAction;
27
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
18 ilm 28
 
29
import java.awt.event.ActionEvent;
30
import java.util.ArrayList;
31
import java.util.List;
32
 
33
import javax.swing.AbstractAction;
34
import javax.swing.Action;
35
import javax.swing.JFrame;
36
 
37
public class ListeDesCommandesAction extends CreateFrameAbstractAction {
38
    public ListeDesCommandesAction() {
39
        super();
40
        this.putValue(Action.NAME, "Liste des commandes fournisseurs");
41
    }
42
 
43
    public JFrame createFrame() {
44
        final IListFrame frame = new IListFrame(new ListeAddPanel(Configuration.getInstance().getDirectory().getElement("COMMANDE")));
45
 
25 ilm 46
        frame.getPanel().getListe().addIListeActions(new MouseSheetXmlListeListener(CommandeXmlSheet.class) {
18 ilm 47
            @Override
25 ilm 48
            public List<RowAction> addToMenu() {
18 ilm 49
                // Transfert vers BR
25 ilm 50
                PredicateRowAction bonAction = new PredicateRowAction(new AbstractAction("Transfert vers BR") {
18 ilm 51
                    public void actionPerformed(ActionEvent e) {
25 ilm 52
                        transfertBonReceptionClient(IListe.get(e).getSelectedRow());
18 ilm 53
                    }
25 ilm 54
                }, false);
18 ilm 55
 
25 ilm 56
                bonAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
57
 
18 ilm 58
                // Transfert vers facture
25 ilm 59
                PredicateRowAction factureAction = new PredicateRowAction(new AbstractAction("Transfert vers facture") {
18 ilm 60
                    public void actionPerformed(ActionEvent e) {
25 ilm 61
                        transfertFactureFournisseur(IListe.get(e).getSelectedRow());
18 ilm 62
                    }
25 ilm 63
                }, false);
18 ilm 64
 
25 ilm 65
                factureAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
66
 
67
                List<RowAction> l = new ArrayList<RowAction>();
18 ilm 68
                l.add(bonAction);
69
                l.add(factureAction);
70
                return l;
71
            }
25 ilm 72
        }.getRowActions());
18 ilm 73
 
74
        return frame;
75
    }
76
 
77
    /**
78
     * Transfert en BR
79
     *
80
     * @param row
81
     */
82
    private void transfertBonReceptionClient(SQLRow row) {
83
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
84
        elt.transfertBR(row.getID());
85
    }
86
 
87
    /**
88
     * Transfert en Facture
89
     *
90
     * @param row
91
     */
92
    private void transfertFactureFournisseur(SQLRow row) {
93
        CommandeSQLElement elt = (CommandeSQLElement) Configuration.getInstance().getDirectory().getElement("COMMANDE");
94
        elt.transfertFacture(row.getID());
95
    }
96
 
97
}