Exemplo n.º 1
0
  private void setReceiptBinds() {
    ContentView view = viewDisplay.getView(receiptPane);
    BindingGroup group = btnToReceipt.getBindingGroup();
    group.addBinding(purchasePaneController.getBindings().and(PURCHASE_VIEW_ACTIVE));

    view.getBindingGroup().setAll(group.getBinds());
  }
Exemplo n.º 2
0
  private void setPurchaseBinds() {
    ContentView view = viewDisplay.getView(purchasePane);
    BindingGroup group = btnToPurchase.getBindingGroup();
    group.addBindings(
        credentialsPaneController.getBindings().and(CART_NONEMPTY).and(not(RECEIPT_VIEW_ACTIVE)));

    view.getBindingGroup().setAll(group.getBinds());
  }
Exemplo n.º 3
0
  private void setCredentialBinds() {
    ContentView view = viewDisplay.getView(credentialsPane);

    BindingGroup group = btnToCredentials.getBindingGroup();
    group.addBinding(CART_NONEMPTY.and(not(RECEIPT_VIEW_ACTIVE)));
    group
        .getState()
        .addListener(
            (obs, o, n) -> {
              ContentView storeView = viewDisplay.getView(storePane);
              ContentView receiptView = viewDisplay.getView(storePane);
              ContentView currentView = viewDisplay.getCurrentView().getValue();

              if (not(CART_NONEMPTY).get()
                  && !currentView.equals(storeView)
                  && !currentView.equals(receiptView)) viewDisplay.show(storeView);

              btnToCredentials.setDisable(true);
            });

    view.getBindingGroup().setAll(group.getBinds());
  }
Exemplo n.º 4
0
  public void initialize(URL url, ResourceBundle bundle) {
    prevButton.disable();
    nextButton.disable();

    me = this;

    popupShadePane.setMouseTransparent(true);

    // Necessary to disable the last arrow
    btnToReceipt.setUserData("lastButton");

    // Give the popup-system required panes
    ModalPopup.initialize(popupPane, wrapperStackPane, popupShadePane);

    // Start viewDisplay-system
    viewDisplay = new ViewDisplay(contentPane);
    NavigationButton.setViewDisplay(viewDisplay);

    // Create the views,
    ContentView storeView = new ContentView(storePane);
    ContentView credentialsView = new ContentView(credentialsPane);
    ContentView purchaseView = new ContentView(purchasePane);
    ContentView receiptView = new ContentView(receiptPane);
    ContentView dummyView = new ContentView(dummyPane);

    // and add the views to the viewDisplay
    viewDisplay.addView(storeView);
    viewDisplay.addView(credentialsView);
    viewDisplay.addView(purchaseView);
    viewDisplay.addView(receiptView);
    viewDisplay.addView(dummyView);

    // Define necessary bindings
    PURCHASE_VIEW_ACTIVE = activeViewBinding(purchaseView);
    RECEIPT_VIEW_ACTIVE = activeViewBinding(receiptView);

    // Setup bindings that determine how you can move between views
    // setStoreBinds();
    setCredentialBinds();
    setPurchaseBinds();
    setReceiptBinds();

    // Set next & previous relationships
    storeView.setNext(credentialsView);
    credentialsView.setNext(purchaseView);
    credentialsView.setPrevious(storeView);
    purchaseView.setPrevious(credentialsView);
    purchaseView.setNext(receiptView);
    receiptView.setNext(storeView);
    receiptView.setPrevious(null);

    // Set actions for the previous & next buttons
    prevButton.setDirection(Direction.LEFT);
    nextButton.setDirection(Direction.RIGHT);
    prevButton.setOnAction(event -> viewDisplay.previous());
    nextButton.setOnAction(
        event -> {
          // If we are on purchase, going to the next view means finishing the purchase.
          if (viewDisplay.getCurrentView().get().equals(purchaseView)) sendOrder().handle(event);
          else viewDisplay.next();
        });

    // Initialize the navigation buttons
    btnToStore.initialize(storeView, show(storeView), btnToCredentials, storeLabel, null);
    btnToCredentials.initialize(
        credentialsView, show(credentialsView), btnToPurchase, credentialsLabel, fromStoreArrow);
    btnToPurchase.initialize(
        purchaseView, show(purchaseView), btnToReceipt, purchaseLabel, fromCredentialsArrow);
    btnToReceipt.initialize(receiptView, sendOrder(), null, receiptLabel, fromPurchaseArrow);

    shoppingCartController.getShoppingListButton().setOnAction(e -> loadListPopup.show());
    shoppingCartController.getSaveListButton().setOnAction(e -> saveListPopup.show());

    contactButton.setOnAction(e -> contactPopup.show());
    historyButton.setOnAction(
        e -> {
          purchaseHistoryPopupController.update();
          purchaseHistoryPopup.show();
        });
    helpButton.setOnAction(e -> helpPopup.show());

    // Drag & drop:  resizing of window to 'highlight' the shopping cart.
    purchaseHistoryPopup.setOnDragOver(
        e -> {
          popupPane.setMouseTransparent(true);
          removeShadePane.getStyleClass().add("transparent");
        });

    // Show the store
    viewDisplay.show(storeView);

    wrapperStackPane.toFront();
  }