Beispiel #1
0
  public void setMenuItem(MenuItem menuItem, TicketItem ticketItem) {
    this.parentMenuItem = menuItem;
    this.parentTicketItem = ticketItem;

    reset();

    // MenuItemDAO dao = new MenuItemDAO();
    try {
      List<MenuItemModifierGroup> menuItemModifierGroups = menuItem.getMenuItemModiferGroups();

      for (Iterator<MenuItemModifierGroup> iter = menuItemModifierGroups.iterator();
          iter.hasNext(); ) {
        MenuItemModifierGroup menuItemModifierGroup = iter.next();
        MenuModifierGroup group = menuItemModifierGroup.getModifierGroup();
        addSeparator(group.getName());

        Set<MenuModifier> modifiers = group.getModifiers();
        for (MenuModifier modifier : modifiers) {
          modifier.setMenuItemModifierGroup(menuItemModifierGroup);
          ModifierButton modifierButton = new ModifierButton(modifier);
          String key = modifier.getId() + "_" + modifier.getModifierGroup().getId();
          buttonMap.put(key, modifierButton);
          addButton(modifierButton);
        }
      }
      revalidate();
      updateVisualRepresentation();
    } catch (PosException e) {
      POSMessageDialog.showError(this, "An error has occured", e);
    }
  }
Beispiel #2
0
  @Override
  public void doGoBack() {
    List<MenuItemModifierGroup> menuItemModifierGroups = parentMenuItem.getMenuItemModiferGroups();
    List<TicketItemModifierGroup> ticketItemModifierGroups =
        parentTicketItem.getTicketItemModifierGroups();

    boolean requiredModifierAdded = true;
    if (menuItemModifierGroups != null) {
      outer:
      for (MenuItemModifierGroup menuItemModifierGroup : menuItemModifierGroups) {
        int minQuantity = menuItemModifierGroup.getMinQuantity();
        if (minQuantity == 0) continue;

        if (ticketItemModifierGroups == null) {
          requiredModifierAdded = false;
          break outer;
        }

        for (TicketItemModifierGroup ticketItemModifierGroup : ticketItemModifierGroups) {
          if (ticketItemModifierGroup.countItems(false) < minQuantity) {
            requiredModifierAdded = false;
            break outer;
          }
        }
      }
    }

    if (!requiredModifierAdded) {
      int option =
          JOptionPane.showConfirmDialog(
              this,
              "Some required modifiers are not added, do you really want to go back?",
              "Confirm",
              JOptionPane.YES_NO_OPTION);
      if (option != JOptionPane.YES_OPTION) {
        return;
      }
    }

    fireModifierSelectionFinished();
  }