OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | 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
 *
182 ilm 4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
18 ilm 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.sales.pos.ui;
15
 
132 ilm 16
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
182 ilm 17
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
18 ilm 18
import org.openconcerto.erp.core.sales.pos.model.Ticket;
19
import org.openconcerto.sql.model.SQLRow;
20
import org.openconcerto.ui.DefaultGridBagConstraints;
21
 
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26
 
27
import javax.swing.JButton;
28
import javax.swing.JPanel;
29
import javax.swing.JSeparator;
30
 
31
public class TextAreaTicketPanel extends JPanel {
32
 
182 ilm 33
    public TextAreaTicketPanel(TicketCaisseSQLElement elt, final POSConfiguration conf, SQLRow row) {
18 ilm 34
        super(new GridBagLayout());
35
        GridBagConstraints c = new DefaultGridBagConstraints();
36
        c.fill = GridBagConstraints.BOTH;
37
        c.weightx = 0;
38
        c.weighty = 0;
39
 
182 ilm 40
        final Ticket ticket = elt.createTicket(row);
18 ilm 41
 
42
        JButton button = new JButton("Imprimer");
43
        button.addActionListener(new ActionListener() {
44
            @Override
45
            public void actionPerformed(ActionEvent e) {
156 ilm 46
                conf.print(ticket);
18 ilm 47
            }
48
        });
49
 
50
        c.fill = GridBagConstraints.NONE;
51
        c.anchor = GridBagConstraints.CENTER;
52
        this.add(button, c);
53
 
54
        c.anchor = GridBagConstraints.WEST;
55
        c.fill = GridBagConstraints.HORIZONTAL;
56
        JSeparator sep = new JSeparator();
57
        c.gridy++;
58
        c.weightx = 1;
59
        this.add(sep, c);
60
        final TextAreaTicketPrinter comp = new TextAreaTicketPrinter();
61
        c.gridy++;
62
        c.weighty = 1;
63
        this.add(comp, c);
64
 
156 ilm 65
        ticket.print(comp, conf.getTicketPrinterConfiguration1().getTicketWidth());
18 ilm 66
    }
67
 
68
}