Examples of Popup


Examples of javafx.stage.Popup

    {
      @Override
      public Void call(final Appointment appointment)
      {
        // create popup
        final Popup lPopup = new Popup();
        Button lButton = new Button("Close custom popup");
        lButton.setPrefWidth(lImageView.getImage().getWidth());
        lButton.setPrefHeight(lImageView.getImage().getHeight());
        lButton.setOnAction(new EventHandler<ActionEvent>()
        {
          @Override
          public void handle(ActionEvent evt)
          {
            lPopup.hide();
            appointment.setSummary("custom popup");
            lAgenda.refresh();
          }
        });
        lPopup.getContent().add(lButton);
        lPopup.show(lImageView, NodeUtil.screenX(lImageView), NodeUtil.screenY(lImageView));
        return null;
      }
    });
       
    // setup appointment groups
View Full Code Here

Examples of javafx.stage.Popup

      lEditCallback.call(abstractAppointmentPane.appointment);
      return;
    }
   
    // create popup
    final Popup lPopup = new Popup();
    lPopup.setAutoFix(true);
    lPopup.setAutoHide(true);
    lPopup.setHideOnEscape(true);
    lPopup.setOnHidden(new EventHandler<WindowEvent>()
    {
      @Override
      public void handle(WindowEvent arg0)
      {
        setupAppointments();
      }
    });

    BorderPane lBorderPane = new BorderPane();
    lBorderPane.getStyleClass().add(getSkinnable().getClass().getSimpleName() + "Popup");
    lPopup.getContent().add(lBorderPane);

    // close icon
    {
      ImageViewButton lImageView = new ImageViewButton();
      lImageView.getStyleClass().add("close-icon");
      lImageView.setPickOnBounds(true);
      lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
      {
        @Override public void handle(MouseEvent evt)
        {
          lPopup.hide();
        }
      });
      lBorderPane.setRight(lImageView);
    }
   
    // initial layout
    VBox lMenuVBox = new VBox(padding);
    lBorderPane.setCenter(lMenuVBox);

    // time
    lMenuVBox.getChildren().add(new Text("Time:"));
    // start
    final CalendarTextField lStartCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lStartCalendarTextField.setLocale(getSkinnable().getLocale());
    lStartCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getStartTime());
    lMenuVBox.getChildren().add(lStartCalendarTextField);
    // end
    final CalendarTextField lEndCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
    lEndCalendarTextField.setLocale(getSkinnable().getLocale());
    lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
    lMenuVBox.getChildren().add(lEndCalendarTextField);
    lEndCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        abstractAppointmentPane.appointment.setEndTime(newValue);
        // refresh is done upon popup close
      }
    });
    lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
    // wholeday
    if ((abstractAppointmentPane.appointment.isWholeDay() != null && abstractAppointmentPane.appointment.isWholeDay() == true) || abstractAppointmentPane.appointment.getEndTime() != null)
    {
      final CheckBox lWholedayCheckBox = new CheckBox("Wholeday");
      lWholedayCheckBox.setId("wholeday-checkbox");
      lWholedayCheckBox.selectedProperty().set(abstractAppointmentPane.appointment.isWholeDay());
      lMenuVBox.getChildren().add(lWholedayCheckBox);
      lWholedayCheckBox.selectedProperty().addListener(new ChangeListener<Boolean>()
      {
        @Override
        public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue)
        {
          abstractAppointmentPane.appointment.setWholeDay(newValue);
          if (newValue == true)
          {
            abstractAppointmentPane.appointment.setEndTime(null);
          }
          else
          {
            Calendar lEndTime = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndTime.add(Calendar.MINUTE, 30);
            abstractAppointmentPane.appointment.setEndTime(lEndTime);
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }
          lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
          // refresh is done upon popup close
        }
      });
    }
    // event handling
    lStartCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
    {
      @Override
      public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
      {
        // enddate
        if (abstractAppointmentPane.appointment.isWholeDay())
        {
          abstractAppointmentPane.appointment.setStartTime(newValue);
        }
        else
        {
          // remember
          Calendar lOldStart = abstractAppointmentPane.appointment.getStartTime();

          // set
          abstractAppointmentPane.appointment.setStartTime(newValue);

          // end date
          if (abstractAppointmentPane.appointment.getEndTime() != null)
          {
            long lDurationInMS = abstractAppointmentPane.appointment.getEndTime().getTimeInMillis() - lOldStart.getTimeInMillis();
            Calendar lEndCalendar = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
            lEndCalendar.add(Calendar.MILLISECOND, (int)lDurationInMS);
            abstractAppointmentPane.appointment.setEndTime(lEndCalendar);

            // update field
            lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
          }

          // refresh is done upon popup close
        }
      }
    });

    // summary
    lMenuVBox.getChildren().add(new Text("Summary:"));
    TextField lSummaryTextField = new TextField();
    lSummaryTextField.setText(abstractAppointmentPane.appointment.getSummary());
    lSummaryTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setSummary(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lSummaryTextField);

    // location
    lMenuVBox.getChildren().add(new Text("Location:"));
    TextField lLocationTextField = new TextField();
    lLocationTextField.setText( abstractAppointmentPane.appointment.getLocation() == null ? "" : abstractAppointmentPane.appointment.getLocation());
    lLocationTextField.textProperty().addListener(new ChangeListener<String>()
    {
      @Override
      public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
      {
        abstractAppointmentPane.appointment.setLocation(newValue);
        // refresh is done upon popup close
      }
    });
    lMenuVBox.getChildren().add(lLocationTextField);

    // actions
    lMenuVBox.getChildren().add(new Text("Actions:"))// TODO: internationalize
    HBox lHBox = new HBox();
    lMenuVBox.getChildren().add(lHBox);
    // delete
    {
      // close icon
      ImageViewButton lImageView = new ImageViewButton();
      lImageView.getStyleClass().add("delete-icon");
      lImageView.setPickOnBounds(true);
      lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
      {
        @Override public void handle(MouseEvent evt)
        {
          lPopup.hide();
          getSkinnable().appointments().remove(abstractAppointmentPane.appointment);
          // refresh is done via the collection events
        }
      });
      Tooltip.install(lImageView, new Tooltip("Delete")); // TODO: internationalize
      lHBox.getChildren().add(lImageView);
    }

    // construct a area of appointment groups
    lMenuVBox.getChildren().add(new Text("Group:"));
    GridPane lAppointmentGroupGridPane = new GridPane();
    lMenuVBox.getChildren().add(lAppointmentGroupGridPane);
    lAppointmentGroupGridPane.getStyleClass().add("AppointmentGroups");
    lAppointmentGroupGridPane.setHgap(2);
    lAppointmentGroupGridPane.setVgap(2);
    int lCnt = 0;
    for (Agenda.AppointmentGroup lAppointmentGroup : getSkinnable().appointmentGroups())
    {
      // create the appointment group
      final Pane lPane = new Pane();
      lPane.setPrefSize(15, 15);
      lPane.getStyleClass().addAll("AppointmentGroup", lAppointmentGroup.getStyleClass());
      lAppointmentGroupGridPane.add(lPane, lCnt % 10, lCnt / 10 );
      lCnt++;

      // tooltip
      if (lAppointmentGroup.getDescription() != null) {
        Tooltip.install(lPane, new Tooltip(lAppointmentGroup.getDescription()));
      }

      // mouse reactions
      lPane.setOnMouseEntered((mouseEvent) -> {
        if (!mouseEvent.isPrimaryButtonDown())
        {
          mouseEvent.consume();
          lPane.setCursor(Cursor.HAND);
        }
      });
      lPane.setOnMouseExited((mouseEvent) -> {
        if (!mouseEvent.isPrimaryButtonDown())
        {
          mouseEvent.consume();
          lPane.setCursor(Cursor.DEFAULT);
        }
      });
      final Agenda.AppointmentGroup lAppointmentGroupFinal = lAppointmentGroup;
      lPane.setOnMouseClicked((mouseEvent) -> {
        mouseEvent.consume();

        // assign appointment group
        abstractAppointmentPane.appointment.setAppointmentGroup(lAppointmentGroupFinal);

        // refresh is done upon popup close
        lPopup.hide();
      });
    }
   
    // show it just below the menu icon
    lPopup.show(abstractAppointmentPane, NodeUtil.screenX(abstractAppointmentPane), NodeUtil.screenY(abstractAppointmentPane.menuIcon) + abstractAppointmentPane.menuIcon.getHeight());
  }
View Full Code Here

Examples of javafx.stage.Popup

  private void showPopup(MouseEvent evt)
  {
    // create popup
    if (popup == null)
    {
      popup = new Popup();
      popup.setAutoFix(true);
      popup.setAutoHide(true);
      popup.setHideOnEscape(true);
     
      // add the timepicker
View Full Code Here

Examples of javafx.stage.Popup

//                      @Override public void dispose() { }
//                  });
//                  getScene().getRoot().impl_processCSS(true);
//              }
//          };
    Popup lPopup = new Popup();
    lPopup.setAutoFix(true);
    lPopup.setAutoHide(true);
    lPopup.setHideOnEscape(true);
    BorderPane lBorderPane = new BorderPane();
    lBorderPane.getStyleClass().add(this.getClass().getSimpleName() + "_popup");
    lBorderPane.setCenter(calendarPicker);
    calendarPicker.showTimeProperty().set( getSkinnable().getShowTime() );
   
    // because the Java 8 DateTime classes use the CalendarPicker, we need to add some specific CSS classes here to support seamless CSS
    if (getSkinnable().getStyleClass().contains(LocalDateTextField.class.getSimpleName())) {
      calendarPicker.getStyleClass().addAll(LocalDatePicker.class.getSimpleName());
    }
    if (getSkinnable().getStyleClass().contains(LocalDateTimeTextField.class.getSimpleName())) {
      calendarPicker.getStyleClass().addAll(LocalDateTimePicker.class.getSimpleName());
    }
   
    // add a close and accept button if we're showing time
    if ( getSkinnable().getShowTime())
    {
      VBox lVBox = new VBox();
      lBorderPane.rightProperty().set(lVBox);
     
      ImageView lAcceptIconImageView = new ImageViewButton();
      lAcceptIconImageView.getStyleClass().addAll("accept-icon");
      lAcceptIconImageView.setPickOnBounds(true);
      lAcceptIconImageView.setOnMouseClicked( (mouseEvent) ->  {
        getSkinnable().calendarProperty().set(calendarPicker.calendarProperty().get());
        lPopup.hide();
      });
      lVBox.add(lAcceptIconImageView);
     
      ImageView lCloseIconImageView = new ImageViewButton();
      lCloseIconImageView.getStyleClass().addAll("close-icon");
      lCloseIconImageView.setPickOnBounds(true);
      lCloseIconImageView.setOnMouseClicked( (mouseEvent) ->  {
        lPopup.hide();
      });
      lVBox.add(lCloseIconImageView);
    }
   
    // if a value is selected in date mode, immediately close the popup
    calendarPicker.calendarProperty().addListener( (observable) -> {
      if (lPopup != null &&  getSkinnable().getShowTime() == false && lPopup.isShowing()) {
        lPopup.hide();
      }
    });

    // when the popup is hidden
    lPopup.setOnHiding( (windowEvent) -> {
      // and time is not shown, the value must be set into the textfield
      if ( getSkinnable().getShowTime() == false) {
        getSkinnable().calendarProperty().set(calendarPicker.calendarProperty().get());
      }
      // but at least the textfield must be enabled again
      textField.setDisable(false);
    });
   
    // add to popup
    lPopup.getContent().add(lBorderPane);
   
    // show it just below the textfield
    textField.setDisable(true);
    lPopup.show(textField, NodeUtil.screenX(getSkinnable()), NodeUtil.screenY(getSkinnable()) + textField.getHeight());

    // move the focus over   
    calendarPicker.requestFocus(); // TODO: not working
  }
View Full Code Here

Examples of javafx.stage.Popup

 
  protected Popup findPopup(Node ownedBy) {
    TestUtil.waitForPaintPulse();
    for (Window w : getWindows() ) {
      if (w instanceof Popup) {
        Popup lPopup = (Popup)w;
        if (ownedBy == null || ownedBy.equals(lPopup.getOwnerNode())) {
          return lPopup;
        }
      }
    }
    return null;
View Full Code Here

Examples of javafx.stage.Popup

 
  protected void assertPopupIsNotVisible(Node ownedBy) {
    TestUtil.waitForPaintPulse();
    for (Window w : getWindows() ) {
      if (w instanceof Popup) {
        Popup lPopup = (Popup)w;
        if (ownedBy.equals(lPopup.getOwnerNode())) {
          throw new IllegalStateException("Popup is visible (and should not be), owner = " + lPopup.getOwnerNode());
        }
      }
    }
  }
View Full Code Here

Examples of javafx.stage.Popup

 
  protected void assertPopupIsVisible(Node ownedBy) {
    TestUtil.waitForPaintPulse();
    for (Window w : getWindows() ) {
      if (w instanceof Popup) {
        Popup lPopup = (Popup)w;
        if (ownedBy.equals(lPopup.getOwnerNode())) {
          return;
        }
      }
    }
    throw new IllegalStateException("Popup is not visible (and should be)");
View Full Code Here

Examples of javafx.stage.Popup

    hL.endXProperty().bind(localRadius.multiply(2));

    // Adding all parts in a container.
    mainContent.getChildren().addAll(frame, viewer, vL, hL);

    final Popup popUp = new Popup();
    popUp.getContent().add(mainContent);

    final EventHandler<MouseEvent> enteredEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        popUp.show(getSkinnable(), e.getScreenX() - shift, e.getScreenY() - shift);
        takeSnap(e.getX(), e.getY());
      }
    };
    final EventHandler<MouseEvent> exitedEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        popUp.hide();
      }
    };
    final EventHandler<MouseEvent> movedEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        final double r = localRadius.get();
        final double s = localScaleFactor.get();
        if (e.getSceneX() > (scene.getWidth() - (2 * r))) {
          popUp.setX(e.getScreenX() - (2 * r) - shift);
        } else {
          popUp.setX(e.getScreenX() - shift);
        }

        if (e.getSceneY() > (scene.getHeight() - (2 * r))) {
          popUp.setY(e.getScreenY() - (2 * r) - shift);
        } else {
          popUp.setY(e.getScreenY() - shift);
        }
        prevX.set(e.getX());
        prevY.set(e.getY());
        shiftViewerContent(prevX.get(), prevY.get(), r, s);
      }
View Full Code Here

Examples of javafx.stage.Popup

      final StackPane cont = new StackPane();
      cont.setMaxWidth(275);
      cont.getStyleClass().add("doc-tool-tip");
      cont.getChildren().add(tooltipText);

      final Popup popup = new Popup();
      popup.setAutoHide(true);
      popup.setAutoFix(true);
      popup.setHideOnEscape(true);
      popup.getContent().add(cont);
      tooltipPopup = popup;
    }
    return tooltipPopup;
  }
View Full Code Here

Examples of javafx.stage.Popup

            }
        }
    }

    private Popup createPopup(final String INFO_TEXT) {
        Popup popup = new Popup();
        popup.setAutoHide(true);
        popup.setAutoFix(true);
        popup.setHideOnEscape(true);

        popup.getContent().setAll(createPopupContent(INFO_TEXT));

        return popup;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.