Dépôt officiel du code source de l'ERP OpenConcerto
Rev 174 | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.sales.pos.ui;
import org.openconcerto.erp.core.sales.pos.POSConfiguration;
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
import org.openconcerto.erp.core.sales.pos.model.Ticket;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.ui.DefaultGridBagConstraints;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JSeparator;
public class TextAreaTicketPanel extends JPanel {
public TextAreaTicketPanel(TicketCaisseSQLElement elt, final POSConfiguration conf, SQLRow row) {
super(new GridBagLayout());
GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 0;
c.weighty = 0;
final Ticket ticket = elt.createTicket(row);
JButton button = new JButton("Imprimer");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
conf.print(ticket);
}
});
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
this.add(button, c);
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
JSeparator sep = new JSeparator();
c.gridy++;
c.weightx = 1;
this.add(sep, c);
final TextAreaTicketPrinter comp = new TextAreaTicketPrinter();
c.gridy++;
c.weighty = 1;
this.add(comp, c);
ticket.print(comp, conf.getTicketPrinterConfiguration1().getTicketWidth());
}
}