Java tutorial
// uniCenta oPOS - Touch Friendly Point Of Sale // Copyright (c) 2009-2014 uniCenta & previous Openbravo POS works // http://www.unicenta.com // // This file is part of uniCenta oPOS // // uniCenta oPOS is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // uniCenta oPOS is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. package com.openbravo.pos.panels; import com.openbravo.basic.BasicException; import com.openbravo.beans.JCalendarDialog; import com.openbravo.data.gui.ComboBoxValModel; import com.openbravo.data.gui.ListQBFModelNumber; import com.openbravo.data.gui.MessageInf; import com.openbravo.data.loader.QBFCompareEnum; import com.openbravo.data.loader.SentenceList; import com.openbravo.data.user.EditorCreator; import com.openbravo.data.user.ListProvider; import com.openbravo.data.user.ListProviderCreator; import com.openbravo.format.Formats; import com.openbravo.pos.customers.DataLogicCustomers; import com.openbravo.pos.customers.JCustomerFinder; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.forms.DataLogicSales; import com.openbravo.pos.inventory.TaxCategoryInfo; import com.openbravo.pos.sales.JTicketsBagTicket; import com.openbravo.pos.ticket.FindTicketsInfo; import com.openbravo.pos.ticket.FindTicketsRenderer; import com.openbravo.pos.ticket.ProductInfoExt; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import javax.swing.DefaultComboBoxModel; import javax.swing.JFrame; import org.apache.commons.lang.StringEscapeUtils; /** * * @author Mikel irurita */ public class JTicketsFinder extends javax.swing.JDialog implements EditorCreator { private ListProvider lpr; private SentenceList m_sentcat; private ComboBoxValModel m_CategoryModel; private DataLogicSales dlSales; private DataLogicCustomers dlCustomers; private FindTicketsInfo selectedTicket; private Component parentComponent; /** Creates new form JTicketsFinder */ private JTicketsFinder(java.awt.Frame parent, boolean modal) { super(parent, modal); } /** Creates new form JTicketsFinder */ private JTicketsFinder(java.awt.Dialog parent, boolean modal) { super(parent, modal); } /** * * @param parent * @param dlSales * @param dlCustomers * @return */ public static JTicketsFinder getReceiptFinder(Component parent, DataLogicSales dlSales, DataLogicCustomers dlCustomers) { Window window = getWindow(parent); JTicketsFinder myMsg; if (window instanceof Frame) { myMsg = new JTicketsFinder((Frame) window, true); } else { myMsg = new JTicketsFinder((Dialog) window, true); } myMsg.init(dlSales, dlCustomers, parent); myMsg.applyComponentOrientation(parent.getComponentOrientation()); return myMsg; } /** * * @return */ public FindTicketsInfo getSelectedCustomer() { return selectedTicket; } private void init(DataLogicSales dlSales, DataLogicCustomers dlCustomers, Component parentComponent) { this.dlSales = dlSales; this.dlCustomers = dlCustomers; this.parentComponent = parentComponent; initComponents(); jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); m_jKeys.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent ke) { jButton3ActionPerformed(null); } }); jtxtTicketID.addEditorKeys(m_jKeys); jtxtMoney.addEditorKeys(m_jKeys); //jtxtTicketID.activate(); lpr = new ListProviderCreator(dlSales.getTicketsList(), this); jListTickets.setCellRenderer(new FindTicketsRenderer()); getRootPane().setDefaultButton(jcmdOK); initCombos(); defaultValues(); selectedTicket = null; } /** * */ public void executeSearch() { try { jListTickets.setModel(new MyListData(lpr.loadData())); if (jListTickets.getModel().getSize() > 0) { jListTickets.setSelectedIndex(0); } } catch (BasicException e) { } } private void initCombos() { String[] values = new String[] { AppLocal.getIntString("label.sales"), AppLocal.getIntString("label.refunds"), AppLocal.getIntString("label.all") }; jComboBoxTicket.setModel(new DefaultComboBoxModel(values)); // jcboMoney.setModel(new ListQBFModelNumber()); jcboMoney.setModel(ListQBFModelNumber.getMandatoryNumber()); m_sentcat = dlSales.getUserList(); m_CategoryModel = new ComboBoxValModel(); List catlist = null; try { catlist = m_sentcat.list(); } catch (BasicException ex) { ex.getMessage(); } catlist.add(0, null); m_CategoryModel = new ComboBoxValModel(catlist); jcboUser.setModel(m_CategoryModel); } private void defaultValues() { jListTickets.setModel(new MyListData(new ArrayList())); jcboUser.setSelectedItem(null); jtxtTicketID.reset(); jtxtTicketID.activate(); jTxtEndDate.setText(null); jtxtCustomer.setText(null); jComboBoxTicket.setSelectedIndex(0); jcboUser.setSelectedItem(null); jcboMoney.setSelectedItem(QBFCompareEnum.COMP_GREATEROREQUALS); jcboMoney.revalidate(); jcboMoney.repaint(); jtxtMoney.reset(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -90); jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(calendar.getTime())); jTxtEndDate.setText(null); jtxtCustomer.setText(null); jtxtCodebar.setText(""); } /** * * @return * @throws BasicException */ @Override public Object createValue() throws BasicException { Object[] afilter = new Object[16]; // Ticket ID if (jtxtTicketID.getText() == null || jtxtTicketID.getText().equals("")) { afilter[0] = QBFCompareEnum.COMP_NONE; afilter[1] = null; } else { afilter[0] = QBFCompareEnum.COMP_EQUALS; afilter[1] = jtxtTicketID.getValueInteger(); } // Sale and refund checkbox if (jComboBoxTicket.getSelectedIndex() == 2) { afilter[2] = QBFCompareEnum.COMP_DISTINCT; afilter[3] = 2; } else if (jComboBoxTicket.getSelectedIndex() == 0) { afilter[2] = QBFCompareEnum.COMP_EQUALS; afilter[3] = 0; } else if (jComboBoxTicket.getSelectedIndex() == 1) { afilter[2] = QBFCompareEnum.COMP_EQUALS; afilter[3] = 1; } // Receipt money afilter[5] = jtxtMoney.getDoubleValue(); afilter[4] = afilter[5] == null ? QBFCompareEnum.COMP_NONE : jcboMoney.getSelectedItem(); // Date range Object startdate = Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); Object enddate = Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); afilter[6] = (startdate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_GREATEROREQUALS; afilter[7] = startdate; afilter[8] = (enddate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_LESSOREQUALS; afilter[9] = enddate; //User if (jcboUser.getSelectedItem() == null) { afilter[10] = QBFCompareEnum.COMP_NONE; afilter[11] = null; } else { afilter[10] = QBFCompareEnum.COMP_EQUALS; afilter[11] = ((TaxCategoryInfo) jcboUser.getSelectedItem()).getName(); } //Customer if (jtxtCustomer.getText() == null || jtxtCustomer.getText().equals("")) { afilter[12] = QBFCompareEnum.COMP_NONE; afilter[13] = null; } else { afilter[12] = QBFCompareEnum.COMP_RE; afilter[13] = "%" + StringEscapeUtils.escapeSql(jtxtCustomer.getText()) + "%"; } //Product Code if (jtxtCodebar.getText() == null || jtxtCodebar.getText().equals("")) { afilter[14] = QBFCompareEnum.COMP_NONE; afilter[15] = null; } else { List<String> ticketIds = dlSales .getTicketsByCode("%" + StringEscapeUtils.escapeSql(jtxtCodebar.getText()) + "%"); afilter[14] = QBFCompareEnum.COMP_IN; afilter[15] = ticketIds; } return afilter; } private static Window getWindow(Component parent) { if (parent == null) { return new JFrame(); } else if (parent instanceof Frame || parent instanceof Dialog) { return (Window) parent; } else { return getWindow(parent.getParent()); } } private static class MyListData extends javax.swing.AbstractListModel { private final java.util.List m_data; public MyListData(java.util.List data) { m_data = data; } @Override public Object getElementAt(int index) { return m_data.get(index); } @Override public int getSize() { return m_data.size(); } } private void assignProduct(ProductInfoExt prod) { jtxtCodebar.setText(null); if (prod != null) { jtxtCodebar.setText(prod.getCode()); } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jPanel3 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jtxtMoney = new com.openbravo.editor.JEditorCurrency(); jcboUser = new javax.swing.JComboBox(); jcboMoney = new javax.swing.JComboBox(); jtxtTicketID = new com.openbravo.editor.JEditorIntegerPositive(); labelCustomer = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jTxtStartDate = new javax.swing.JTextField(); jTxtEndDate = new javax.swing.JTextField(); btnDateStart = new javax.swing.JButton(); btnDateEnd = new javax.swing.JButton(); jtxtCustomer = new javax.swing.JTextField(); btnCustomer = new javax.swing.JButton(); jComboBoxTicket = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jtxtCodebar = new javax.swing.JTextField(); jEditProduct = new javax.swing.JButton(); jPanel6 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jPanel4 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); jListTickets = new javax.swing.JList(); jPanel8 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); jcmdCancel = new javax.swing.JButton(); jcmdOK = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); m_jKeys = new com.openbravo.editor.JEditorKeys(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle(AppLocal.getIntString("form.tickettitle")); // NOI18N jPanel3.setLayout(new java.awt.BorderLayout()); jPanel5.setLayout(new java.awt.BorderLayout()); jPanel7.setPreferredSize(new java.awt.Dimension(10, 250)); jPanel7.setLayout(new java.awt.GridBagLayout()); jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel1.setText(AppLocal.getIntString("label.ticketid")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel1, gridBagConstraints); jLabel6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel6.setText(AppLocal.getIntString("label.user")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel6, gridBagConstraints); jLabel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel7.setText(AppLocal.getIntString("label.totalcash")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel7, gridBagConstraints); jtxtMoney.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); jPanel7.add(jtxtMoney, gridBagConstraints); jcboUser.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N jcboUser.setPreferredSize(new java.awt.Dimension(200, 25)); jcboUser.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { jcboUserItemStateChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); jPanel7.add(jcboUser, gridBagConstraints); jcboMoney.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0); jPanel7.add(jcboMoney, gridBagConstraints); jtxtTicketID.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jtxtTicketID, gridBagConstraints); labelCustomer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N labelCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(labelCustomer, gridBagConstraints); jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel3.setText(AppLocal.getIntString("Label.StartDate")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel3, gridBagConstraints); jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel4.setText(AppLocal.getIntString("Label.EndDate")); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel4, gridBagConstraints); jTxtStartDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jTxtStartDate.setPreferredSize(new java.awt.Dimension(200, 25)); jTxtStartDate.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jTxtEndDateKeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jTxtStartDate, gridBagConstraints); jTxtEndDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jTxtEndDate.setPreferredSize(new java.awt.Dimension(200, 25)); jTxtEndDate.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jTxtEndDateKeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jTxtEndDate, gridBagConstraints); btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N btnDateStart.setToolTipText("Open Calendar"); btnDateStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDateStartActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(btnDateStart, gridBagConstraints); btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/date.png"))); // NOI18N btnDateEnd.setToolTipText("Open Calendar"); btnDateEnd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDateEndActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(btnDateEnd, gridBagConstraints); jtxtCustomer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jtxtCustomer.setPreferredSize(new java.awt.Dimension(200, 25)); jtxtCustomer.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jTxtEndDateKeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jtxtCustomer, gridBagConstraints); btnCustomer.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/customer_sml.png"))); // NOI18N btnCustomer.setToolTipText("Open Customers"); btnCustomer.setFocusPainted(false); btnCustomer.setFocusable(false); btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); btnCustomer.setPreferredSize(new java.awt.Dimension(57, 33)); btnCustomer.setRequestFocusEnabled(false); btnCustomer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCustomerActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(btnCustomer, gridBagConstraints); jComboBoxTicket.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jComboBoxTicket, gridBagConstraints); jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jLabel2.setText(AppLocal.getIntString("label.prodbarcode")); jLabel2.setPreferredSize(new java.awt.Dimension(95, 14)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 6; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jLabel2, gridBagConstraints); jtxtCodebar.setPreferredSize(new java.awt.Dimension(200, 25)); jtxtCodebar.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jTxtEndDateKeyReleased(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); jPanel7.add(jtxtCodebar, gridBagConstraints); jEditProduct .setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/search24.png"))); // NOI18N jEditProduct.setMargin(new java.awt.Insets(8, 14, 8, 14)); jEditProduct.setPreferredSize(new java.awt.Dimension(57, 33)); jEditProduct.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jEditProductActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 6; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; jPanel7.add(jEditProduct, gridBagConstraints); jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/reload.png"))); // NOI18N jButton1.setText(AppLocal.getIntString("button.clean")); // NOI18N jButton1.setToolTipText("Clear Filter"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jPanel6.add(jButton1); jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N jButton3.setToolTipText("Execute Filter"); jButton3.setFocusPainted(false); jButton3.setFocusable(false); jButton3.setRequestFocusEnabled(false); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jPanel6.add(jButton3); jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH); jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); jPanel4.setLayout(new java.awt.BorderLayout()); jListTickets.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N jListTickets.setFocusable(false); jListTickets.setRequestFocusEnabled(false); jListTickets.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jListTicketsMouseClicked(evt); } }); jListTickets.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { jListTicketsValueChanged(evt); } }); jScrollPane1.setViewportView(jListTickets); jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); jPanel8.setLayout(new java.awt.BorderLayout()); jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/cancel.png"))); // NOI18N jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N jcmdCancel.setFocusPainted(false); jcmdCancel.setFocusable(false); jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); jcmdCancel.setRequestFocusEnabled(false); jcmdCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jcmdCancelActionPerformed(evt); } }); jPanel1.add(jcmdCancel); jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N jcmdOK.setEnabled(false); jcmdOK.setFocusPainted(false); jcmdOK.setFocusable(false); jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); jcmdOK.setPreferredSize(new java.awt.Dimension(103, 44)); jcmdOK.setRequestFocusEnabled(false); jcmdOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jcmdOKActionPerformed(evt); } }); jPanel1.add(jcmdOK); jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH); getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); jPanel2.setPreferredSize(new java.awt.Dimension(200, 250)); jPanel2.setLayout(new java.awt.BorderLayout()); jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); setSize(new java.awt.Dimension(690, 511)); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed selectedTicket = (FindTicketsInfo) jListTickets.getSelectedValue(); dispose(); }//GEN-LAST:event_jcmdOKActionPerformed private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed dispose(); }//GEN-LAST:event_jcmdCancelActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed executeSearch(); }//GEN-LAST:event_jButton3ActionPerformed private void jListTicketsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListTicketsValueChanged jcmdOK.setEnabled(jListTickets.getSelectedValue() != null); }//GEN-LAST:event_jListTicketsValueChanged private void jListTicketsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListTicketsMouseClicked if (evt.getClickCount() == 2) { selectedTicket = (FindTicketsInfo) jListTickets.getSelectedValue(); if (parentComponent != null && parentComponent instanceof JTicketsBagTicket) { ((JTicketsBagTicket) parentComponent).readTicket(selectedTicket.getTicketId(), selectedTicket.getTicketType()); } } }//GEN-LAST:event_jListTicketsMouseClicked private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed defaultValues(); }//GEN-LAST:event_jButton1ActionPerformed private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); finder.search(null); finder.setVisible(true); try { jtxtCustomer.setText(finder.getSelectedCustomer() == null ? null : dlSales.loadCustomerExt(finder.getSelectedCustomer().getId()).toString()); } catch (BasicException e) { MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e); msg.show(this); } }//GEN-LAST:event_btnCustomerActionPerformed private void btnDateEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateEndActionPerformed Date date; try { date = (Date) Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); } catch (BasicException e) { date = null; } date = JCalendarDialog.showCalendarTimeHours(this, date); if (date != null) { jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(date)); } }//GEN-LAST:event_btnDateEndActionPerformed private void btnDateStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateStartActionPerformed Date date; try { date = (Date) Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); } catch (BasicException e) { date = null; } date = JCalendarDialog.showCalendarTimeHours(this, date); if (date != null) { jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(date)); } }//GEN-LAST:event_btnDateStartActionPerformed private void jEditProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditProductActionPerformed assignProduct(JProductFinder.showMessage(this, dlSales)); }//GEN-LAST:event_jEditProductActionPerformed private void jTxtEndDateKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtEndDateKeyReleased jButton3ActionPerformed(null); }//GEN-LAST:event_jTxtEndDateKeyReleased private void jcboUserItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcboUserItemStateChanged if (evt.getStateChange() == ItemEvent.SELECTED) { jButton3ActionPerformed(null); } }//GEN-LAST:event_jcboUserItemStateChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCustomer; private javax.swing.JButton btnDateEnd; private javax.swing.JButton btnDateStart; private javax.swing.JButton jButton1; private javax.swing.JButton jButton3; private javax.swing.JComboBox jComboBoxTicket; private javax.swing.JButton jEditProduct; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JList jListTickets; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField jTxtEndDate; private javax.swing.JTextField jTxtStartDate; private javax.swing.JComboBox jcboMoney; private javax.swing.JComboBox jcboUser; private javax.swing.JButton jcmdCancel; private javax.swing.JButton jcmdOK; private javax.swing.JTextField jtxtCodebar; private javax.swing.JTextField jtxtCustomer; private com.openbravo.editor.JEditorCurrency jtxtMoney; private com.openbravo.editor.JEditorIntegerPositive jtxtTicketID; private javax.swing.JLabel labelCustomer; private com.openbravo.editor.JEditorKeys m_jKeys; // End of variables declaration//GEN-END:variables }