private void addItemOkPressed(String itemName, String itemPrice, String itemQuantity) {
        StringBuffer errorMessage = new StringBuffer();
        double price = 0.0;
        int quantity = 0;
        boolean nameValid = false;
        boolean priceValid = false;
        boolean quantityValid = false;

        nameValid = itemName.length() > 0;
        if (!nameValid) {
            errorMessage.append("A non-empty name must be entered for the product!\n");
        } else if (!model.getWarehouseTableModel().validateNameUniqueness(itemName)) {
            errorMessage.append("Entered name already exists!\n");
            nameValid = false;
        }

        try {
            price = Double.parseDouble(itemPrice);
            priceValid = (price >= 0.0);
        } catch (NumberFormatException ex) {}

        if (!priceValid) {
            errorMessage.append("Entered price is not valid!\n");
        }

        try {
            quantity = Integer.parseInt(itemQuantity);
            quantityValid = (quantity >= 0);
        } catch (NumberFormatException ex) {}

        if (!quantityValid) {
            errorMessage.append("Entered quantity is not valid!");
        }

        if (nameValid && priceValid && quantityValid) {
            StockItem newItem = new StockItem(itemName, "", price, quantity);
            controller.createStockItem(newItem);

        // Show the error messages
        } else {
            JOptionPane.showMessageDialog(
                    null,
                    errorMessage.toString(),
                    "Error",
                    JOptionPane.ERROR_MESSAGE
            );
        }
    }