public class GroceryListController extends ControllerWithMenuThatSaves implements ProductCreationObserver
Modifier and Type | Field and Description |
---|---|
private GroceryList |
groceryList |
private GroceryListDB |
groceryListDB |
private GroceryListView |
view |
master
Constructor and Description |
---|
GroceryListController(ControllerMaster master,
java.lang.String listName) |
Modifier and Type | Method and Description |
---|---|
protected void |
askSaveConfirmation()
Asks the user whether he wants to save the grocery list changes and saves it if he does.
|
void |
createProduct()
Creates a new Product
|
java.lang.String |
getGroceryListName() |
void |
onCreateProductClosed()
Asks the view to enable the addProduct button
|
void |
onProductCreated(Product product)
Asks the view to add a newly created product to the choices
|
void |
saveGroceryList(java.util.List<ProductAmount> productAmountsList)
Creates a new GroceryList, fill it with all the items retrieved from the
view and saves it in the database.
|
private void |
saveListInDB(GroceryList listToSave)
Saves the GroceryList in the database.
|
void |
showShopsWithAllProducts()
Finds all shops whose contain every item from the list
|
void |
showShopsWithProduct(ProductAmount productAmount)
Shows shops containing a product
|
onLogout, onShowAllGroceryLists, onShowAllRecipes, onShowEditProfile, onShowMap
onHelpViewStatusChanged, onShowHelp, setView
isHelpOpen
private GroceryListView view
private GroceryListDB groceryListDB
private GroceryList groceryList
public GroceryListController(ControllerMaster master, java.lang.String listName)
public void createProduct()
public void showShopsWithProduct(ProductAmount productAmount)
public void saveGroceryList(java.util.List<ProductAmount> productAmountsList)
private void saveListInDB(GroceryList listToSave)
listToSave
- GroceryListpublic void showShopsWithAllProducts()
public java.lang.String getGroceryListName()
protected void askSaveConfirmation()
askSaveConfirmation
in class ControllerWithMenuThatSaves
public void onProductCreated(Product product)
onProductCreated
in interface ProductCreationObserver
product
- The newly created productpublic void onCreateProductClosed()
onCreateProductClosed
in interface ProductCreationObserver