diff --git a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/shared/JTicketsBagShared.java b/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/shared/JTicketsBagShared.java index f83bf9bc..4be59ab8 100755 --- a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/shared/JTicketsBagShared.java +++ b/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/shared/JTicketsBagShared.java @@ -60,10 +60,12 @@ public JTicketsBagShared(AppView app, TicketsEditor panelticket) { dlSales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales"); dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem"); + showList = m_App.hasPermission("sales.ShowList"); + initComponents(); m_jReprintTickets.setVisible(true); - + LOGGER.log(System.Logger.Level.INFO, "JTicketsBagShared "); } @@ -72,12 +74,14 @@ public JTicketsBagShared(AppView app, TicketsEditor panelticket) { */ @Override public void activate() { - selectValidTicket(); - + LOGGER.log(System.Logger.Level.INFO, "Active panel"); + updateCount(); m_jDelTicket.setEnabled(m_App.hasPermission("com.openbravo.pos.sales.JPanelTicketEdits")); m_jDelTicket.setEnabled(m_App.hasPermission("sales.DeleteTicket")); - LOGGER.log(System.Logger.Level.INFO, "JTicketsBagShared "); + TicketInfo ticket = new TicketInfo(); + LOGGER.log(System.Logger.Level.INFO, "newTicket has id: " + ticket.getId()); + m_panelticket.setActiveTicket(ticket, null); } /** @@ -86,16 +90,12 @@ public void activate() { */ @Override public boolean deactivate() { - saveCurrentTicket(); m_panelticket.setActiveTicket(null, null); return true; } - /** - * - */ @Override public void deleteTicket() { @@ -106,7 +106,7 @@ public void deleteTicket() { "Ticket Deleted", 0.0 }); - selectValidTicket(); + updateCount(); } public void updateCount() { @@ -116,15 +116,18 @@ public void updateCount() { if (count > 0) { m_jListTickets.setText(Integer.toString(count)); + if (showList) { + m_jListTickets.doClick(); + } } else { m_jListTickets.setText(""); } - LOGGER.log(System.Logger.Level.DEBUG, "Shared SharedTicket: " + count); + LOGGER.log(System.Logger.Level.DEBUG, "Count shared ticket: " + count); } catch (BasicException ex) { - LOGGER.log(System.Logger.Level.WARNING, "Exception updateCount: ", ex); - new MessageInf(ex).show(this); m_jListTickets.setText(""); + LOGGER.log(System.Logger.Level.WARNING, "Exception Count shared ticket: ", ex); + new MessageInf(ex).show(this); } } @@ -159,16 +162,16 @@ private void saveCurrentTicket() { m_panelticket.getActiveTicket().getPickupId()); m_jListTickets.setText("*"); - LOGGER.log(System.Logger.Level.DEBUG, "SAVED Current Ticket ID: ", ticketID); + LOGGER.log(System.Logger.Level.INFO, "SAVED Current Ticket ID: ", ticketID); } else { - LOGGER.log(System.Logger.Level.DEBUG, "NOT SAVED Current Ticket because has no line/item, Ticket ID: ", ticketID); + LOGGER.log(System.Logger.Level.INFO, "NOT SAVED Current Ticket because has no line/item, Ticket ID: ", ticketID); } } catch (BasicException e) { - LOGGER.log(System.Logger.Level.WARNING, "Exception saveCurrentTicket: "+ticketID, e); + LOGGER.log(System.Logger.Level.WARNING, "Exception saveCurrentTicket: " + ticketID, e); new MessageInf(e).show(this); } } else { - LOGGER.log(System.Logger.Level.WARNING, "NOT SAVED Current Ticket because ActiveTicket is NULL"); + LOGGER.log(System.Logger.Level.INFO, "NOT SAVED Current Ticket because ActiveTicket is NULL"); } updateCount(); @@ -182,7 +185,6 @@ private void setActiveTicket(String id) throws BasicException { LOGGER.log(System.Logger.Level.WARNING, "NOT FOUND Shared TICKET for id: " + id); throw new BasicException(AppLocal.getIntString("message.noticket")); } else { - dlReceipts.getPickupId(id); Integer pickUp = dlReceipts.getPickupId(id); dlReceipts.deleteSharedTicket(id); m_panelticket.setActiveTicket(ticket, null); @@ -197,25 +199,6 @@ private void setActiveReprintTicket(String id) throws BasicException { LOGGER.log(System.Logger.Level.WARNING, "NOT IMPLEMENTED setActiveReprintTicket"); } - private void selectValidTicket() { - updateCount(); - - try { - List l = dlReceipts.getSharedTicketList(); - if (l.isEmpty()) { - m_jListTickets.setText(""); - } else { - showList = m_App.hasPermission("sales.ShowList"); - if (showList) { - m_jListTickets.doClick(); - } - } - } catch (BasicException e) { - LOGGER.log(System.Logger.Level.WARNING, "Exception selectValidTicket: ", e); - new MessageInf(e).show(this); - } - } - private void newTicket() { try { @@ -233,6 +216,38 @@ private void newTicket() { } } + protected void setEnabledPanel(boolean enabled) { + jPanel1.setEnabled(enabled); + } + + protected void disableAllButtons() { + m_jDelTicket.setEnabled(false); + m_jNewTicket.setEnabled(false); + m_jReprintTickets.setEnabled(false); + m_jListTickets.setEnabled(false); + m_jHold.setEnabled(false); + } + + protected void setEnabledButtonDel(boolean enabled) { + m_jDelTicket.setEnabled(enabled); + } + + protected void setEnabledButtonNew(boolean enabled) { + m_jNewTicket.setEnabled(enabled); + } + + protected void setEnabledButtonReprint(boolean enabled) { + m_jReprintTickets.setEnabled(enabled); + } + + protected void setEnabledButtonList(boolean enabled) { + m_jListTickets.setEnabled(enabled); + } + + protected void setEnabledButtonExpand(boolean enabled) { + m_jHold.setEnabled(enabled); + } + /** * 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 @@ -400,7 +415,7 @@ private void m_jDelTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN- boolean pinOK = false; - if (m_panelticket.getActiveTicket()!= null) { + if (m_panelticket.getActiveTicket() != null) { if (m_App.getProperties().getProperty("override.check").equals("true")) { String pin = m_App.getProperties().getProperty("override.pin"); diff --git a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.form b/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.form deleted file mode 100755 index 8019ab00..00000000 --- a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.form +++ /dev/null @@ -1,54 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.java b/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.java index 69f66610..c3b8a38d 100755 --- a/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.java +++ b/kriolos-opos-app/src/main/java/com/openbravo/pos/sales/simple/JTicketsBagSimple.java @@ -17,17 +17,14 @@ package com.openbravo.pos.sales.simple; import com.openbravo.pos.forms.AppView; -import com.openbravo.pos.forms.AppLocal; -import com.openbravo.pos.forms.*; -import javax.swing.*; import com.openbravo.pos.sales.*; -import com.openbravo.pos.ticket.TicketInfo; +import com.openbravo.pos.sales.shared.JTicketsBagShared; /** * * @author JG uniCenta */ -public class JTicketsBagSimple extends JTicketsBag { +public class JTicketsBagSimple extends JTicketsBagShared { /** * @@ -35,95 +32,12 @@ public class JTicketsBagSimple extends JTicketsBag { * @param panelticket */ public JTicketsBagSimple(AppView app, TicketsEditor panelticket) { - super(app, panelticket); - - initComponents(); + this.setEnabledPanel(true); + this.disableAllButtons(); + this.setEnabledButtonDel(true); } - @Override - public void activate() { - - m_panelticket.setActiveTicket(new TicketInfo(), null); - m_jDelTicket.setEnabled(m_App.hasPermission("com.openbravo.pos.sales.JPanelTicketEdits")); - - } - - /** - * - * @return - */ - public boolean deactivate() { - m_panelticket.setActiveTicket(null, null); - return true; - } - - /** - * - */ - public void deleteTicket() { - m_panelticket.setActiveTicket(new TicketInfo(), null); - } - - /** - * - * @return - */ - protected JComponent getBagComponent() { - return this; - } - - /** - * - * @return - */ - protected JComponent getNullComponent() { - return new JPanel(); - } - - /** 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. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - m_jDelTicket = new javax.swing.JButton(); - - setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N - setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); - - m_jDelTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/sale_delete.png"))); // NOI18N - java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N - m_jDelTicket.setToolTipText(bundle.getString("tooltip.delete")); // NOI18N - m_jDelTicket.setFocusPainted(false); - m_jDelTicket.setFocusable(false); - m_jDelTicket.setMargin(new java.awt.Insets(0, 4, 0, 4)); - m_jDelTicket.setMaximumSize(new java.awt.Dimension(50, 40)); - m_jDelTicket.setMinimumSize(new java.awt.Dimension(50, 40)); - m_jDelTicket.setPreferredSize(new java.awt.Dimension(80, 45)); - m_jDelTicket.setRequestFocusEnabled(false); - m_jDelTicket.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - m_jDelTicketActionPerformed(evt); - } - }); - add(m_jDelTicket); - }// //GEN-END:initComponents - - private void m_jDelTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDelTicketActionPerformed - - int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannadelete"), AppLocal.getIntString("title.editor"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - if (res == JOptionPane.YES_OPTION) { - deleteTicket(); - } - - }//GEN-LAST:event_m_jDelTicketActionPerformed - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton m_jDelTicket; - // End of variables declaration//GEN-END:variables + }