Skip to content

Commit

Permalink
App: Ticket Bag "SIMPLE" extend from Shared (Standard)
Browse files Browse the repository at this point in the history
* simple enabled only "delete" button hide all others
  • Loading branch information
poolborges committed May 2, 2023
1 parent e5614c3 commit b0ac774
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ");
}

Expand All @@ -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);
}

/**
Expand All @@ -86,16 +90,12 @@ public void activate() {
*/
@Override
public boolean deactivate() {

saveCurrentTicket();
m_panelticket.setActiveTicket(null, null);

return true;
}

/**
*
*/
@Override
public void deleteTicket() {

Expand All @@ -106,7 +106,7 @@ public void deleteTicket() {
"Ticket Deleted",
0.0
});
selectValidTicket();
updateCount();
}

public void updateCount() {
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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<SharedTicketInfo> 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 {
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,113 +17,27 @@
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 {

/**
*
* @param app
* @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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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);
}// </editor-fold>//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


}

0 comments on commit b0ac774

Please sign in to comment.