gt:         m_TablePlan.setMargin(new java.awt.Insets(0, 4, 0, 4));
context: //    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/>.
  //    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/>.
  //    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/>.
  //    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.sales.restaurant;
  
  import bsh.Interpreter;
  import bsh.EvalError;
  import com.openbravo.data.gui.JMessageDialog;
  import com.openbravo.data.gui.ListKeyed;
  import com.openbravo.data.gui.MessageInf;
  import com.openbravo.data.loader.SentenceList;
  import com.openbravo.pos.forms.AppLocal;
  import com.openbravo.pos.forms.AppView;
  import com.openbravo.pos.forms.DataLogicSystem;
  import com.openbravo.pos.forms.JRootApp;
  import com.openbravo.pos.printer.DeviceTicket;
  import com.openbravo.pos.printer.TicketParser;
  import com.openbravo.pos.printer.TicketPrinterException;
  import com.openbravo.pos.sales.JPanelTicket;
  import com.openbravo.pos.sales.TaxesLogic;
  import com.openbravo.pos.scripting.ScriptEngine;
  import com.openbravo.pos.scripting.ScriptException;
  import com.openbravo.pos.scripting.ScriptFactory;
  import com.openbravo.pos.ticket.TicketInfo;
  import com.openbravo.pos.ticket.TicketLineInfo;
  import java.util.List;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.swing.*;
  
  /**
   *
   * @author JG uniCenta
   */
  public class JTicketsBagRestaurant extends javax.swing.JPanel {
      
      private AppView m_App;
      private JTicketsBagRestaurantMap m_restaurant;
      private List<TicketLineInfo> m_aLines;
      private TicketLineInfo line;
      private TicketInfo ticket;
      private Object ticketExt; 
      private DataLogicSystem m_dlSystem = null;
      private DeviceTicket m_TP;   
      private TicketParser m_TTP2; 
      private RestaurantDBUtils restDB;    
      
      private DataLogicSystem dlSystem = null;
      private TicketParser m_TTP; 
      
      private SentenceList senttax;
      private ListKeyed taxcollection;
      private TaxesLogic taxeslogic;
      
      private Interpreter i;
     
      
      /** Creates new form JTicketsBagRestaurantMap
       * @param app
       * @param restaurant */
      public JTicketsBagRestaurant(AppView app, JTicketsBagRestaurantMap restaurant) {
          super();
          m_App = app;
          m_restaurant = restaurant;
          initComponents();
  // Added by JDL for kitchen printer
          ticketExt = null;  
          
          restDB = new  RestaurantDBUtils(m_App); 
          
          m_dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");
          m_TP = new DeviceTicket();
          m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_dlSystem);     
          m_KitchenPrint.setVisible(m_App.getAppUserView().getUser().hasPermission("sales.PrintKitchen"));
          m_KitchenPrint.setVisible(false);
          
      }
  
      /**
       *
       */
      public void activate() {
          
          // Authorization
          m_DelTicket.setEnabled(m_App.getAppUserView().getUser().hasPermission("com.openbravo.pos.sales.JPanelTicketEdits"));
    
      }
  
      /**
       *
       * @param resource
       */
      public void printTicket(String resource) {
          printTicket(resource, ticket, m_restaurant.getTable());
      } 
      
  
   private void printTicket(String sresourcename, TicketInfo ticket, String table) {
              if (ticket != null) {
              try {
                  ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY);
                  script.put("ticket", ticket);              
                  script.put("place",m_restaurant.getTableName());
                  m_TTP2.printTicket(script.eval(m_dlSystem.getResourceAsXML(sresourcename)).toString());                
              } catch ( ScriptException | TicketPrinterException e) {
                  JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotprint"), e));
              }
          } 
   }
      
      
      /** 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_DelTicket = new javax.swing.JButton();
          m_MoveTable = new javax.swing.JButton();
          m_TablePlan = new javax.swing.JButton();
          m_KitchenPrint = new javax.swing.JButton();
  
          setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
          setMinimumSize(new java.awt.Dimension(250, 50));
          setPreferredSize(new java.awt.Dimension(250, 50));
          setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
  
          m_DelTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/sale_delete.png"))); // NOI18N
          m_DelTicket.setToolTipText("Delete Current Order");
          m_DelTicket.setFocusPainted(false);
          m_DelTicket.setFocusable(false);
          m_DelTicket.setMargin(new java.awt.Insets(0, 4, 0, 4));
          m_DelTicket.setMaximumSize(new java.awt.Dimension(50, 40));
          m_DelTicket.setMinimumSize(new java.awt.Dimension(50, 40));
          m_DelTicket.setPreferredSize(new java.awt.Dimension(50, 40));
          m_DelTicket.setRequestFocusEnabled(false);
          m_DelTicket.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  m_DelTicketActionPerformed(evt);
              }
          });
          add(m_DelTicket);
  
          m_MoveTable.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/movetable.png"))); // NOI18N
          m_MoveTable.setToolTipText("Move Table");
          m_MoveTable.setFocusPainted(false);
          m_MoveTable.setFocusable(false);
          m_MoveTable.setMargin(new java.awt.Insets(0, 4, 0, 4));
          m_MoveTable.setMaximumSize(new java.awt.Dimension(50, 40));
          m_MoveTable.setMinimumSize(new java.awt.Dimension(50, 40));
          m_MoveTable.setPreferredSize(new java.awt.Dimension(50, 40));
          m_MoveTable.setRequestFocusEnabled(false);
          m_MoveTable.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  m_MoveTableActionPerformed(evt);
              }
          });
          add(m_MoveTable);
  
          m_TablePlan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/tables.png"))); // NOI18N
          m_TablePlan.setToolTipText("Go to Table Plan");
          m_TablePlan.setFocusPainted(false);
          m_TablePlan.setFocusable(false);
  