Ejemplo n.º 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);
    }
  }
  @Override
  public String getDisplayText() {
    MenuItemModifierGroup modifierGroup = (MenuItemModifierGroup) getBean();
    if (modifierGroup.getId() == null) {
      return com.floreantpos.POSConstants.ADD_NEW_MODIFIER_GROUP_IN_MENU_ITEM_;
    }

    return com.floreantpos.POSConstants.EDIT_MODIFIER_GROUP_IN_MENU_ITEM_;
  }
 public boolean equals(Object obj) {
   if (null == obj) return false;
   if (!(obj instanceof com.floreantpos.model.MenuItemModifierGroup)) return false;
   else {
     com.floreantpos.model.MenuItemModifierGroup menuItemModifierGroup =
         (com.floreantpos.model.MenuItemModifierGroup) obj;
     if (null == this.getId() || null == menuItemModifierGroup.getId()) return false;
     else return (this.getId().equals(menuItemModifierGroup.getId()));
   }
 }
  @Override
  protected void updateView() {
    MenuItemModifierGroup modifierGroup = (MenuItemModifierGroup) getBean();
    if (modifierGroup == null) return;

    if (modifierGroup.getId() != null) {
      cbModifierGroups.setSelectedItem(modifierGroup.getModifierGroup());
    }
    tfMinQuantity.setText(String.valueOf(modifierGroup.getMinQuantity()));
    tfMaxQuantity.setText(String.valueOf(modifierGroup.getMaxQuantity()));
  }
Ejemplo n.º 5
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();
  }
  @Override
  protected boolean updateModel() {
    int minQuantity = 0;
    int maxQuantity = 0;

    try {
      minQuantity = Integer.parseInt(tfMinQuantity.getText());
      maxQuantity = Integer.parseInt(tfMaxQuantity.getText());
    } catch (Exception e) {
    }

    MenuModifierGroup group = (MenuModifierGroup) cbModifierGroups.getSelectedItem();
    if (group == null) {
      POSMessageDialog.showError(this, com.floreantpos.POSConstants.MODIFIER_GROUP_REQUIRED);
      return false;
    }
    MenuItemModifierGroup modifierGroup = (MenuItemModifierGroup) getBean();
    modifierGroup.setModifierGroup(group);
    modifierGroup.setMinQuantity(minQuantity);
    modifierGroup.setMaxQuantity(maxQuantity);

    return true;
  }