package mealplaner.gui.dialogs.mealinput;

import static mealplaner.commons.BundleStore.BUNDLES;
import static mealplaner.commons.gui.buttonpanel.ButtonPanelBuilder.builder;
import static mealplaner.gui.dialogs.mealinput.MealInputGrid.inputGrid;

import java.awt.event.ActionListener;
import java.util.Optional;

import javax.swing.JFrame;

import mealplaner.DataStore;
import mealplaner.commons.gui.GridPanel;
import mealplaner.commons.gui.MessageDialog;
import mealplaner.commons.gui.buttonpanel.ButtonPanel;
import mealplaner.commons.gui.dialogs.DialogCreating;
import mealplaner.commons.gui.dialogs.DialogWindow;
import mealplaner.model.Meal;

public abstract class MealInput<T> implements DialogCreating<T> {
  private final JFrame parentFrame;
  private final DialogWindow dialogWindow;

  private final MealInputGrid inputGrid;

  public MealInput(JFrame parent) {
    dialogWindow = DialogWindow.window(parent, BUNDLES.message("mealInputDialogTitle"));
    this.parentFrame = parent;
    inputGrid = inputGrid(dialogWindow);
  }

  @Override
  public abstract T showDialog(DataStore store);

  protected void display(DataStore mealPlan, ActionListener saveListener) {
    GridPanel mealCreationPanel = inputGrid.initialiseInputFields(mealPlan);

    ButtonPanel buttonPanel = buildButtonPanel(saveListener);

    dialogWindow.addCentral(mealCreationPanel);
    dialogWindow.addSouth(buttonPanel);
    dialogWindow.arrangeWithSize(300, 400);
    dialogWindow.setVisible();
  }

  private ButtonPanel buildButtonPanel(ActionListener saveListener) {
    return builder("MealInput")
        .addSaveButton(saveListener)
        .addCancelDialogButton(dialogWindow)
        .build();
  }

  protected void resetFields() {
    inputGrid.resetFields();
  }

  protected void dispose() {
    dialogWindow.dispose();
  }

  protected Optional<Meal> getMealAndShowDialog() {
    Optional<Meal> mealFromInput = inputGrid.getMealFromUserInput();
    if (!mealFromInput.isPresent()) {
      MessageDialog.userErrorMessage(parentFrame, BUNDLES.message("menuNameChoiceEmpty"));
    }
    return mealFromInput;
  }
}
@@ -1480,24 +1480,44 @@
 300, 400);%0D%0A
+    resetFields();%0D%0A
     dialogWi

Use default values for meal input fields