Class AddRecipeController
java.lang.Object
stud.ntnu.idatt1005.pantrypal.controllers.Controller
stud.ntnu.idatt1005.pantrypal.controllers.AddRecipeController
- All Implemented Interfaces:
Observer
Controller class for the AddRecipeView. This class is responsible for handling the logic for the
AddRecipeView.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private final CookbookController
private GroceryRegister
private StepRegister
private stud.ntnu.idatt1005.pantrypal.views.AddRecipeView
The view for the AddRecipeController.Fields inherited from class stud.ntnu.idatt1005.pantrypal.controllers.Controller
viewManager
-
Constructor Summary
ConstructorsConstructorDescriptionAddRecipeController
(ViewManager viewManager, CookbookController cookBookController) Constructor that takes in a ViewManager and a CookBookController. -
Method Summary
Modifier and TypeMethodDescriptionvoid
rerender()
Re-renders the view with the current groceryRegister and stepRegister.void
setRecipeToAddRecipeView
(Recipe recipe) Changes the view to a new AddRecipeView() with an already existing recipe to edit.void
update
(ButtonEnum buttonEnum) Updates the observer with the button that was pressed.void
update
(ButtonEnum buttonEnum, Object object) Updates the observer based on the type of button pressed, and object associated object.Methods inherited from class stud.ntnu.idatt1005.pantrypal.controllers.Controller
isLoggedIn, logOut, onNavLinkPress
-
Field Details
-
groceryRegister
-
stepRegister
-
BUTTON_NOT_SUPPORTED
- See Also:
-
view
private stud.ntnu.idatt1005.pantrypal.views.AddRecipeView viewThe view for the AddRecipeController. -
cookBookController
-
-
Constructor Details
-
AddRecipeController
Constructor that takes in a ViewManager and a CookBookController. The viewManager is sent to the superclass Constructor. the AddRecipeView is created and rendered with the controller. The view is added to the viewManager.- Parameters:
viewManager
- the ViewManager for the applicationcookBookController
- the CookBookController for the application
-
-
Method Details
-
setRecipeToAddRecipeView
Changes the view to a new AddRecipeView() with an already existing recipe to edit.- Parameters:
recipe
- the recipe to edit
-
update
Updates the observer based on the type of button pressed, and object associated object. If the object is a Recipe it will be added to the Cookbook. If the object is a Grocery it will be added/removed to/from the GroceryRegister, and the view will be re-rendered. If the object is a String it will be added/removed to/from the StepRegister, and the view will be re-rendered. -
update
Updates the observer with the button that was pressed. -
rerender
public void rerender()Re-renders the view with the current groceryRegister and stepRegister.
-