Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. public void priceTotal(ActionEvent event) throws IOException{
  2.  
  3.  
  4. FXMLLoader loader = new FXMLLoader(getClass().getResource("/views/Shops.fxml"));
  5. Parent root = loader.load();
  6. Stage stage = new Stage();
  7. stage.setScene(new Scene(root));
  8. ShopController controller = loader.getController();
  9.  
  10. List<Product> listProducts = new ArrayList<Product>();
  11. for (Product product : productList) {
  12. listProducts.add(product);
  13. }
  14. ShopProductDataAccessor spda = new ShopProductDataAccessor();
  15. List<ShopPriceView> lst_shops = spda.getShopsForShopping(listProducts);
  16.  
  17. ObservableList<ShopPriceView> shopList = FXCollections.observableArrayList(lst_shops);
  18. controller.setShopList(shopList);
  19.  
  20. stage.show();
  21.  
  22. }
  23.  
  24. /** Après avoir sélectionné un produit dans le menu déroulant, ouvre une
  25. * view qui affiche tous les magasins avec le prix du produit sélectionné */
  26. public void checkPrice(ActionEvent event) throws IOException{
  27.  
  28.  
  29. if(!(textNumber.getText().length()>0 && ingredientList.getSelectionModel().getSelectedItem()!=null)){
  30. Alert alert = new Alert(AlertType.ERROR);
  31. alert.setTitle("Error Dialog");
  32. alert.setHeaderText("Error");
  33. alert.setContentText("Please enter value");
  34. alert.showAndWait();
  35. }
  36. else{
  37. FXMLLoader loader = new FXMLLoader(getClass().getResource("/views/Shops.fxml"));
  38. Parent root = loader.load();
  39. Stage stage = new Stage();
  40. stage.setScene(new Scene(root));
  41. ShopController controller = loader.getController();
  42.  
  43. // HARDCODING
  44. ShopProductDataAccessor op = new ShopProductDataAccessor();
  45. List<ShopPriceView> shopz = op.selectShopsWhereProdExists(new Product(ingredientList.getSelectionModel().getSelectedItem(), op.getUnitOfProduct(ingredientList.getSelectionModel().getSelectedItem()), Integer.valueOf(textNumber.getText())));
  46.  
  47. ObservableList<ShopPriceView> slist = FXCollections.observableArrayList(shopz);
  48. controller.setShopList(slist);
  49. stage.show();
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement