示例#1
0
  private synchronized void addTicket(KitchenTicket ticket, boolean updateView) {
    if (!isShowing()) return;

    Printer selectedPrinter = (Printer) cbPrinters.getSelectedItem();
    if (selectedPrinter != null && !selectedPrinter.equals(ticket.getPrinters())) {
      return;
    }

    OrderType selectedTicketType = (OrderType) cbTicketTypes.getSelectedItem();
    if (selectedTicketType != null && selectedTicketType != ticket.getType()) {
      return;
    }

    if (ticketPanel.addTicket(ticket)) {
      if (updateView) {
        // ticketPanel.revalidate();
        ticketPanel.repaint();
      }
    }
  }
示例#2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand() != null
       && e.getActionCommand().equalsIgnoreCase("log out")) { // $NON-NLS-1$
     Application.getInstance().doLogout();
   }
   if (e.getSource() == viewUpdateTimer) {
     updateTicketView();
   } else {
     ticketPanel.removeAll();
     updateTicketView();
   }
 }
示例#3
0
  private synchronized void updateTicketView() {
    try {
      viewUpdateTimer.stop();

      List<KitchenTicket> list = KitchenTicketDAO.getInstance().findAllOpen();

      for (KitchenTicket kitchenTicket : list) {
        addTicket(kitchenTicket, false);
      }
      // ticketPanel.updateView();
      ticketPanel.repaint();

    } catch (Exception e2) {
      POSMessageDialog.showError(this, e2.getMessage(), e2);
    } finally {
      viewUpdateTimer.restart();
    }
  }
示例#4
0
  public KitchenDisplayView(boolean showHeader) {
    setLayout(new BorderLayout(5, 5));
    PosPrinters printers = Application.getPrinters();
    List<Printer> kitchenPrinters = printers.getKitchenPrinters();
    DefaultComboBoxModel<Printer> printerModel = new DefaultComboBoxModel<Printer>();
    printerModel.addElement(null);
    for (Printer printer : kitchenPrinters) {
      printerModel.addElement(printer);
    }

    Font font = getFont().deriveFont(18f);

    cbPrinters.setFont(font);
    cbPrinters.setRenderer(new PosComboRenderer());
    cbPrinters.setModel(printerModel);
    cbPrinters.addActionListener(this);

    JPanel firstTopPanel = new JPanel(new BorderLayout(5, 5));
    if (showHeader) {
      headerPanel = new HeaderPanel();
      firstTopPanel.add(headerPanel, BorderLayout.NORTH);
    }

    filterPanel = new JPanel();

    PosButton btnBack = new PosButton("Back");
    btnBack.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            RootView.getInstance().showDefaultView();
          }
        });

    JLabel label = new JLabel(Messages.getString("KitchenDisplayView.5")); // $NON-NLS-1$
    label.setFont(font);

    JLabel label2 = new JLabel(Messages.getString("KitchenDisplayView.6")); // $NON-NLS-1$
    label2.setFont(font);

    filterPanel.setLayout(new MigLayout("", "[][][][][fill,grow][]", ""));
    filterPanel.add(label);
    filterPanel.add(cbPrinters);

    filterPanel.add(label2);
    filterPanel.add(cbTicketTypes);

    btnFilter = new PosButton("Filter");
    btnFilter.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            KitchenFilterDialog dialog = new KitchenFilterDialog();
            dialog.add(filterPanel, BorderLayout.CENTER);
            dialog.open();
          }
        });

    JPanel topPanel =
        new JPanel(
            new MigLayout(
                "fill, ins 2 2 0 2",
                "[][fill, grow][]",
                "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    // topPanel.setBorder(BorderFactory.createTitledBorder("Filter: All Printers- All Orders"));
    // //$NON-NLS-1$

    // topPanel.add(label);
    // topPanel.add(cbPrinters);

    Dimension size = PosUIManager.getSize(60, 40);

    Font filterFont = getFont().deriveFont(Font.BOLD, 12f);
    lblFilter = new JLabel("Filter: All Printers- All Orders"); // $NON-NLS-1$
    lblFilter.setForeground(new Color(49, 106, 196));
    lblFilter.setFont(filterFont);
    topPanel.add(lblFilter);
    topPanel.add(btnFilter, "w " + size.width + "!,h " + size.height + "!");
    topPanel.add(btnBack, "w " + size.width + "!, h " + size.height + "!");
    topPanel.setBackground(Color.white);

    cbTicketTypes.setFont(font);
    cbTicketTypes.setRenderer(new PosComboRenderer());
    DefaultComboBoxModel<OrderType> ticketTypeModel = new DefaultComboBoxModel<OrderType>();
    for (OrderType orderType : Application.getInstance().getOrderTypes()) {
      ticketTypeModel.addElement(orderType);
    }
    ticketTypeModel.insertElementAt(null, 0);
    cbTicketTypes.setModel(ticketTypeModel);
    cbTicketTypes.setSelectedIndex(0);
    cbTicketTypes.addActionListener(this);

    // topPanel.add(label2);
    // topPanel.add(cbTicketTypes);

    btnLogout = new PosButton(new LogoutAction(true, false)); // $NON-NLS-1$
    // btnLogout.addActionListener(this);
    topPanel.add(btnLogout, "w " + size.width + "!, h " + size.height + "!, wrap");

    topPanel.add(new JSeparator(), "grow,span");

    firstTopPanel.setPreferredSize(new Dimension(0, PosUIManager.getSize(50)));
    firstTopPanel.add(topPanel);
    add(firstTopPanel, BorderLayout.NORTH);

    ticketPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    // JScrollPane scrollPane = new JScrollPane(ticketPanel);
    // scrollPane.getHorizontalScrollBar().setSize(new Dimension(100, 60));
    // scrollPane.getHorizontalScrollBar().setPreferredSize(new Dimension(100, 60));
    add(ticketPanel);

    add(ticketPanel.getPaginationPanel(), BorderLayout.SOUTH);

    viewUpdateTimer = new Timer(5 * 1000, this);
    viewUpdateTimer.setRepeats(true);
  }
示例#5
0
 public synchronized void cleanup() {
   viewUpdateTimer.stop();
   ticketPanel.removeAll();
 }