Package jfxtras.scene.control

Examples of jfxtras.scene.control.CalendarPicker


        // create agenda
    final Agenda lAgenda = new Agenda();   
   
    // create calendar picker
    CalendarPicker lCalendarPicker = new CalendarPicker();
    lCalendarPicker.setCalendar(Calendar.getInstance()); // set to today
   
    // bind picker to agenda
    lAgenda.displayedCalendar().bind(lCalendarPicker.calendarProperty());
   
    // image
    final ImageView lImageView = new ImageView();
    lImageView.setId("TheImage");
       
View Full Code Here


   * construct the nodes
   */
  private void createNodes()
  {
    // setup the grid so all weekday togglebuttons will grow, but the weeknumbers do not
    calendarPicker = new CalendarPicker();
    getChildren().add(calendarPicker);
   
    // setup CSS
        getSkinnable().getStyleClass().add(this.getClass().getSimpleName()); // always add self as style class, because CSS should relate to the skin not the control
  }
View Full Code Here

   * construct the nodes
   */
  private void createNodes()
  {
    // setup the grid so all weekday togglebuttons will grow, but the weeknumbers do not
    calendarPicker = new CalendarPicker().withShowTime(true);
    getChildren().add(calendarPicker);
   
    // setup CSS
        getSkinnable().getStyleClass().add(this.getClass().getSimpleName()); // always add self as style class, because CSS should relate to the skin not the control
  }
View Full Code Here

   *
   */
  private void showPopup(MouseEvent evt)
  {
    // create a picker
    CalendarPicker calendarPicker = new CalendarPicker();
    calendarPicker.setMode(CalendarPicker.Mode.SINGLE);
    calendarPicker.localeProperty().set(getSkinnable().localeProperty().get());
    calendarPicker.allowNullProperty().set(getSkinnable().allowNullProperty().get());
    calendarPicker.calendarProperty().set(getSkinnable().calendarProperty().get());
    calendarPicker.disabledCalendars().addAll(getSkinnable().disabledCalendars());
    calendarPicker.highlightedCalendars().addAll(getSkinnable().highlightedCalendars());
    calendarPicker.setCalendarRangeCallback(new Callback<CalendarRange,Void>() {
      @Override
      public Void call(CalendarRange calendarRange) {
        Callback<CalendarRange, Void> lCallback = getSkinnable().getCalendarRangeCallback();
        if (lCallback == null) {
          return null;
        }
        return lCallback.call(calendarRange);
      }
    });
   
    // TODO: replace with PopupControl because that is styleable (see C:/Users/user/Documents/openjfx/8.0rt/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ComboBoxPopupControl.java)
//      popup = new PopupControl() {
//
//              @Override public Styleable getStyleableParent() {
//                  return CalendarTextFieldSkin.this.getSkinnable();
//              }
//              {
//                  setSkin(new Skin<Skinnable>() {
//                      @Override public Skinnable getSkinnable() { return CalendarTextFieldSkin.this.getSkinnable(); }
//                      @Override public Node getNode() { return lBorderPane; }
//                      @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

   * Implementation of Builder interface
   */
  @Override
  public CalendarPicker build()
  {
    CalendarPicker lCalendarPicker = new CalendarPicker();
    if (showTime != null) {
      lCalendarPicker.setShowTime(showTime);
    }
    if (locale != null) {
      lCalendarPicker.setLocale(locale);
    }
    if (calendarText != null) {
      // we parse here and not in setCalendar because we need the value of showTime, and that may be specified after the calendar attribute
      try {
        Calendar lCalendar = Calendar.getInstance();
        if (lCalendarPicker.showTimeProperty().get()) {
          lCalendar.setTime( YMDHMSSimpleDateFormat.parse(calendarText) );
        }
        else {
          lCalendar.setTime( YMDSimpleDateFormat.parse(calendarText) );
        }
        lCalendarPicker.setCalendar(lCalendar);
      }
      catch (ParseException e) {
        throw new RuntimeException(e);
      }

    }
    if (displayedCalendar != null) {
      lCalendarPicker.setDisplayedCalendar(displayedCalendar);
    }
    if (mode != null) {
      lCalendarPicker.setMode(mode);
    }
    if (allowNull != null) {
      lCalendarPicker.setAllowNull(allowNull);
    }
    applyCommonProperties(lCalendarPicker);
    return lCalendarPicker;
  }
View Full Code Here

  {
    // show the correct tab
    click("#defaultPicker");
   
    // get the node
    CalendarPicker lCalendarPicker = (CalendarPicker)find(".CalendarPicker");
   
    // default value is null
    Assert.assertNull(lCalendarPicker.getCalendar());

    // click the first of the displayed month   
    click("#id1 #" + new SimpleDateFormat("yyyy-MM-01").format(lCalendarPicker.getDisplayedCalendar().getTime()));
   
    // default value is not null
    Assert.assertNotNull(lCalendarPicker.getCalendar());
  }
View Full Code Here

  {
    // show the correct tab
    click("#atributesAreSet2");
   
    // get the node
    CalendarPicker lCalendarPicker = (CalendarPicker)find(".CalendarPicker");
   
    // set properties
    Assert.assertEquals("2013-01-01", TestUtil.quickFormatCalendarAsDate(lCalendarPicker.getDisplayedCalendar()));
    Assert.assertEquals("de", lCalendarPicker.getLocale().toString());
    Assert.assertEquals("MULTIPLE", lCalendarPicker.getMode().toString());
  }
View Full Code Here

  {
    // show the correct tab
    click("#atributesAreSet3");
   
    // get the node
    CalendarPicker lCalendarPicker = (CalendarPicker)find(".CalendarPicker");
   
    // set properties
    Assert.assertEquals(true, lCalendarPicker.getShowTime());
    Assert.assertEquals("2013-01-10T22:33:44.000", TestUtil.quickFormatCalendarAsDateTime(lCalendarPicker.getCalendar()));
   
  }
View Full Code Here

  {
    // show the correct tab
    click("#atributesAreSet4");
   
    // get the node
    CalendarPicker lCalendarPicker = (CalendarPicker)find(".CalendarPicker");
   
    // set properties
    Assert.assertEquals(false, lCalendarPicker.getAllowNull());
    Assert.assertNotNull(lCalendarPicker.getCalendar());
  }
View Full Code Here

  {
    Locale.setDefault(Locale.ENGLISH);
   
    VBox box = new VBox();

    calendarPicker = new CalendarPicker();
    box.getChildren().add(calendarPicker);

    // display first of January
    calendarPicker.setDisplayedCalendar(new GregorianCalendar(2013, 0, 1, 12, 00, 00));
   
View Full Code Here

TOP

Related Classes of jfxtras.scene.control.CalendarPicker

Copyright © 2018 www.massapicom. 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.