Java 类javafx.scene.control.DateCell 实例源码

项目:git-rekt    文件:BrowseRoomsScreenController.java   
/**
 * Ensures that the date pickers only allow selection of dates within the valid booking date
 * range, as defined in the specifications document.
 *
 * Chief among these rules is that bookings may not be placed more than one year in advance.
 */
private void initializeDatePickers() {
    Callback<DatePicker, DateCell> dayCellFactory =
        (final DatePicker datePicker) -> new DateCell() {
            @Override
            public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if(item.isAfter(LocalDate.now().plusYears(1))) {
                    setDisable(true);
                }
                if(item.isBefore(ChronoLocalDate.from(LocalDate.now()))) {
                    setDisable(true);
                }
            }
        };
    // Disable selecting invalid check-in/check-out dates
    checkInDatePicker.setDayCellFactory(dayCellFactory);
    checkOutDatePicker.setDayCellFactory(dayCellFactory);
}
项目:travelimg    文件:FlickrDatePicker.java   
public void setRanges(LocalDateTime startDate, LocalDateTime endDate){
    logger.debug("Setting allowed dates from {} to {}", startDate, endDate);
    final Callback<DatePicker, DateCell> dayCellFactory =
            new Callback<DatePicker, DateCell>() {
                @Override
                public DateCell call(final DatePicker datePicker) {
                    return new DateCell() {
                        @Override
                        public void updateItem(LocalDate item, boolean empty) {
                            super.updateItem(item, empty);
                            if (item.isBefore(startDate.toLocalDate()) || item.isAfter(endDate.toLocalDate())) {
                                setDisable(true);
                                setStyle("-fx-background-color: #ffc0cb;");
                            }
                        }
                    };
                }
            };
    setDayCellFactory(dayCellFactory);
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
public DateCellDescription(Wrap<? extends DateCell> dateCellWrap) {
    Lookup lookup = dateCellWrap.as(Parent.class, Node.class).lookup();
    if (lookup.lookup(LabeledText.class).size() > 0) {
        final Wrap<? extends LabeledText> mainText = lookup.lookup(LabeledText.class).wrap();
        mainDate = Integer.parseInt(getText(mainText));
    } else {
        mainDate = -1;
    }

    if (lookup.lookup(Text.class, new ByStyleClass("secondary-text")).size() > 0) {
        final Wrap<? extends Text> secondaryText = lookup.lookup(Text.class, new ByStyleClass("secondary-text")).wrap();
        secondaryDate = Integer.parseInt(getText(secondaryText));
    } else {
        secondaryDate = -1;
    }
}
项目:dominoes    文件:ProjectInfoPane.java   
private void UpdateDatePicker(){
    Callback<DatePicker, DateCell> dayCellFactory = dp -> new DateCell()
       {
           @Override
           public void updateItem(LocalDate item, boolean empty)
           {
               super.updateItem(item, empty);

               if(item.isBefore(Instant.ofEpochMilli(repoBeginDate.getTime()).atZone(ZoneId.systemDefault()).toLocalDate()) 
                    || item.isAfter(Instant.ofEpochMilli(repoEndDate.getTime()).atZone(ZoneId.systemDefault()).toLocalDate()))
               {
                   setStyle("-fx-background-color: #ffc0cb;");
                   setDisable(true);

                   /* When Hijri Dates are shown, setDisable() doesn't work. Here is a workaround */
                 //  addEventFilter(MouseEvent.MOUSE_CLICKED, e -> e.consume());
               }


           }
       };

       beginDate.setDayCellFactory(dayCellFactory);
       endDate.setDayCellFactory(dayCellFactory);
}
项目:openjfx-8u-dev-tests    文件:DatePickerApp.java   
public DateCell call(DatePicker param) {
    return new DateCell() {

        @Override
        public void updateItem(LocalDate item, boolean empty) {
            super.updateItem(item, empty);

            if (isRestricted(item)) {
                setStyle("-fx-background-color: #ff4444;");
                setDisable(true);
            }
        }
    };
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
void setDayCellFactory(Callback<DatePicker, DateCell> dayCellFactory) {
    new GetAction<Void>() {
        @Override public void run(Object... parameters) throws Exception {
            testedControl.getControl().setDayCellFactory((Callback<DatePicker, DateCell>) parameters[0]);
        }
    }.dispatch(testedControl.getEnvironment(), dayCellFactory);
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
Callback<DatePicker, DateCell> getDayCellFactory() {
    return new GetAction<Callback<DatePicker, DateCell>>() {
        @Override public void run(Object... parameters) throws Exception {
            setResult(testedControl.getControl().getDayCellFactory());
        }
    }.dispatch(testedControl.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:DatePickerTest.java   
/**
 * Checks that disabled DateCell can't be selected and
 * that state doesn't change after.
 */
@Test(timeout = 10000)
public void daysRestriction() throws InterruptedException {
    rememberInitialState(Properties.showing, Properties.hover, Properties.pressed, Properties.armed);

    final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() {
        public DateCell call(DatePicker param) { return new DateCell(); }
    };
    setDayCellFactory(dayCellFactory);
    assertSame(dayCellFactory, getDayCellFactory());

    selectObjectFromChoiceBox(SettingType.BIDIRECTIONAL, Properties.dayCellFactory, WorkingDays.class);
    setDate(LocalDate.of(2020, 10, 31));
    clickDropDownButton();
    waitPopupShowingState(true);

    PopupSceneDescription description = new PopupSceneDescription();
    description.extractData();
    Wrap<? extends DateCell> cellWrap = description.currentMonthDays.get(24);
    DateCellDescription cell = new DateCellDescription(cellWrap);
    assertEquals("[Selected wrong day]", 25, cell.mainDate);

    cellWrap.mouse().click();
    waitPopupShowingState(true);

    HashMap<String, String> expectedState = new HashMap<String, String>(2);
    expectedState.put("selectedDay", "31");
    expectedState.put("monthName", "October");
    expectedState.put("year", "2020");
    testedControl.waitState(new DateState(expectedState, description));
    waitShownText("10/31/2020");

    testedControl.keyboard().pushKey(KeyboardButtons.ESCAPE);
    setDate(LocalDate.of(2020, Month.OCTOBER, 25));
    checkFinalState();
}
项目:BudgetMaster    文件:NewPaymentController.java   
private void initRepeatingArea() 
{
    checkBoxRepeat.selectedProperty().addListener((listener, oldValue, newValue) -> {
        toggleRepeatingArea(newValue);
    });     

    initSpinnerRepeatingPeriod();
    initComboBoxRepeatingDay();     
    initComboBoxCategory();     

    final ToggleGroup toggleGroup = new ToggleGroup();
    radioButtonPeriod.setToggleGroup(toggleGroup);
    radioButtonDay.setToggleGroup(toggleGroup);
    radioButtonPeriod.selectedProperty().addListener((listener, oldValue, newValue) -> {
        toggleRadioButtonPeriod(newValue);
    });

    datePickerEnddate.setDayCellFactory((p) -> new DateCell()
    {
        @Override
        public void updateItem(LocalDate ld, boolean bln)
        {
            super.updateItem(ld, bln);

            if(datePicker.getValue() != null && ld.isBefore(datePicker.getValue()))
            {
                setDisable(true);
                setStyle("-fx-background-color: #ffc0cb;");
            }
        }
    });

    checkBoxEndDate.selectedProperty().addListener((obs, oldValue, newValue)->{
        datePickerEnddate.setDisable(!newValue);
    });
}
项目:BudgetMaster    文件:ChartController.java   
public void init(Controller controller)
{
    this.controller = controller;

    datePickerEnd.setDayCellFactory(param -> new DateCell()
    {
        @Override
        public void updateItem(LocalDate item, boolean empty)
        {
            super.updateItem(item, empty);
            if(item.isBefore(datePickerStart.getValue().plusDays(1)))
            {
                setDisable(true);
                setStyle("-fx-background-color: #ffc0cb;");
            }
        }
    });

    comboBoxStartMonth.setItems(FXCollections.observableArrayList(Helpers.getMonthList()));
    comboBoxStartYear.setItems(FXCollections.observableArrayList(Helpers.getYearList()));
    comboBoxEndMonth.setItems(FXCollections.observableArrayList(Helpers.getMonthList()));
    comboBoxEndYear.setItems(FXCollections.observableArrayList(Helpers.getYearList()));

    final ToggleGroup toggleGroup = new ToggleGroup();
    radioButtonBars.setToggleGroup(toggleGroup);
    radioButtonBars.setSelected(true);
    radioButtonLines.setToggleGroup(toggleGroup);

    accordion.setExpandedPane(accordion.getPanes().get(0));
    vboxChartMonth.setSpacing(15);

    applyStyle();
}
项目:JFoenix    文件:JFXDatePickerContent.java   
private DateCell findDayCellOfDate(LocalDate date) {
    for (int i = 0; i < dayCellDates.length; i++) {
        if (date.equals(dayCellDates[i])) {
            return dayCells.get(i);
        }
    }
    return dayCells.get(dayCells.size() / 2 + 1);
}
项目:Cachoeira    文件:TaskInformationModuleController.java   
private DateCell makeStartDatePickerCellsDisabled(DatePicker datePicker) {
    return new DateCell() {
        @Override
        public void updateItem(LocalDate startDate, boolean empty) {
            super.updateItem(startDate, empty);
            if (startDate.isBefore(controller.getProject().getStartDate())) {
                setDisable(true);
            }
            if (startDate.isEqual(controller.getProject().getFinishDate()) || startDate.isAfter(controller.getProject().getFinishDate())) {
                setDisable(true);
            }
        }
    };
}
项目:Cachoeira    文件:TaskInformationModuleController.java   
private DateCell makeFinishDatePickerCellsDisabled(DatePicker datePicker) {
    return new DateCell() {
        @Override
        public void updateItem(LocalDate finishDate, boolean empty) {
            super.updateItem(finishDate, empty);
            if (finishDate.isBefore(module.getStartDatePicker().getValue().plusDays(1))) {
                setDisable(true);
            }
            if (finishDate.isEqual(controller.getProject().getFinishDate().plusDays(1)) || finishDate.isAfter(controller.getProject().getFinishDate().plusDays(1))) {
                setDisable(true);
            }
        }
    };
}
项目:Cachoeira    文件:ProjectInformationModuleController.java   
private DateCell makeFinishDatePickerCellsDisabledBeforeStartDate(DatePicker datePicker) {
    return new DateCell() {
        @Override
        public void updateItem(LocalDate finishDate, boolean empty) {
            super.updateItem(finishDate, empty);
            if (finishDate.isBefore(module.getStartDatePicker().getValue().plusDays(1))) {
                setDisable(true);
            }
        }
    };
}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetDateCellAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(DateCell.class);

    assertThat(adjuster, is(instanceOf(ControlAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class)));
}
项目:marathonv5    文件:DatePickerSample.java   
private void initUI() {
    VBox vbox = new VBox(20);
    vbox.setStyle("-fx-padding: 10;");
    Scene scene = new Scene(vbox, 400, 400);
    stage.setScene(scene);

    checkInDatePicker = new DatePicker();
    checkOutDatePicker = new DatePicker();                         
    checkInDatePicker.setValue(LocalDate.now());

    final Callback<DatePicker, DateCell> dayCellFactory = 
        new Callback<DatePicker, DateCell>() {
            @Override
            public DateCell call(final DatePicker datePicker) {
                return new DateCell() {
                    @Override
                    public void updateItem(LocalDate item, boolean empty) {
                        super.updateItem(item, empty);

                        if (item.isBefore(
                                checkInDatePicker.getValue().plusDays(1))
                            ) {
                                setDisable(true);
                                setStyle("-fx-background-color: #ffc0cb;");                                       
                        }
                        long p = ChronoUnit.DAYS.between(
                                checkInDatePicker.getValue(), item
                        );
                        setTooltip(new Tooltip(
                            "You're about to stay for " + p + " days")
                        );
                }
            };
        }
    };

    checkOutDatePicker.setDayCellFactory(dayCellFactory);
    checkOutDatePicker.setValue(checkInDatePicker.getValue().plusDays(1));
    checkInDatePicker.setChronology(ThaiBuddhistChronology.INSTANCE);
    checkOutDatePicker.setChronology(HijrahChronology.INSTANCE);

    GridPane gridPane = new GridPane();
    gridPane.setHgap(10);
    gridPane.setVgap(10);

    Label checkInlabel = new Label("Check-In Date:");
    gridPane.add(checkInlabel, 0, 0);
    GridPane.setHalignment(checkInlabel, HPos.LEFT);

    gridPane.add(checkInDatePicker, 0, 1);

    Label checkOutlabel = new Label("Check-Out Date:");
    gridPane.add(checkOutlabel, 0, 2);
    GridPane.setHalignment(checkOutlabel, HPos.LEFT);

    gridPane.add(checkOutDatePicker, 0, 3);

    vbox.getChildren().add(gridPane);

}
项目:fxcomponents    文件:DateTimePicker.java   
public DateTimePicker() {
  allowTime.addListener((observable, oldValue, newValue) -> {
    textHours.setEditable(newValue);
    textMinutes.setEditable(newValue);

    if (!newValue) {
      textHours.setText("00");
      textMinutes.setText("00");
    }
  });

  limitTimeField(textHours, 23);
  limitTimeField(textMinutes, 59);
  setConverter();

  setOnShowing(event -> {
    if (dateTimeProperty.get() == null) {
      if (allowTime.get()) {
        LocalTime now = LocalTime.now();
        textHours.setText(String.valueOf(now.getHour()));
        textMinutes.setText(String.valueOf(now.getMinute()));
      }
    }
    getEditor().fireEvent(new KeyEvent(getEditor(), getEditor(), KeyEvent.KEY_PRESSED, null, null, KeyCode.ENTER, false, false, false, false));
  });

  addValuePropertyListener();

  // Synchronize changes to dateTimePropertyProperty back to the underlying date value
  dateTimeProperty.addListener((observable, oldValue, newValue) -> {
    if (oldValue != null && newValue == null && !allowNull.get()) {
      dateTimeProperty.setValue(oldValue);
    }

    setValue(newValue == null ? null : newValue.toLocalDate());
  });

  // Persist changes onblur
  getEditor().focusedProperty().addListener((observable, oldValue, newValue) -> {
    if (!newValue) {
      getEditor().fireEvent(new KeyEvent(getEditor(), getEditor(), KeyEvent.KEY_PRESSED, null, null, KeyCode.ENTER, false, false, false, false));
    }
  });

  setOnMouseClicked(event -> {
    if (!isShowing()) {
      canBeHidden = false;
      setTimeFromCalendarPopup();
    }
  });

  final EventHandler<MouseEvent> dayCellActionHandler = ev -> {
    if (ev.getButton() != MouseButton.PRIMARY) {
      return;
    }
    setTimeFromCalendarPopup();
  };

  setDayCellFactory(param -> {
    DateCell dateCell = new DateCell();
    dateCell.addEventHandler(MouseEvent.MOUSE_CLICKED, dayCellActionHandler);
    return dateCell;
  });

  btnOk.setOnAction(event -> {
    canBeHidden = true;
    setTimeFromCalendarPopup();
    hide();
    ((DatePickerSkin)getSkin()).hide();
    canBeHidden = false;
  });
}
项目:openjfx-8u-dev-tests    文件:TestBase.java   
/**
 * Performs the exploration of the popup and wraps it graphical
 * components
 */
public void extractData() throws InterruptedException {
    checkPopupVisibility(true);
    popupScene = getPopupWrap();
    Parent<Node> sceneParent = popupScene.as(Parent.class, Node.class);

    previousMonthWrap = sceneParent.lookup(Button.class, new ByStyleClass("left-button")).wrap(0);
    previousYearWrap = sceneParent.lookup(Button.class, new ByStyleClass("left-button")).wrap(1);

    nextMonthWrap = sceneParent.lookup(Button.class, new ByStyleClass("right-button")).wrap(0);
    nextYearWrap = sceneParent.lookup(Button.class, new ByStyleClass("right-button")).wrap(1);

    currentMonthWrap = sceneParent.lookup(Label.class, new ByStyleClass("spinner-label")).wrap(0);
    currentYearWrap = sceneParent.lookup(Label.class, new ByStyleClass("spinner-label")).wrap(1);

    weeksNumbers = new ArrayList<Wrap<? extends DateCell>>();
    Lookup weekNumbersLookup = sceneParent.lookup(DateCell.class, new ByStyleClass("week-number-cell"));
    for (int i = 0; i < weekNumbersLookup.size(); i++) {
        weeksNumbers.add(weekNumbersLookup.wrap(i));
    }

    previousMonthDays = new ArrayList<Wrap<? extends DateCell>>();
    currentMonthDays = new ArrayList<Wrap<? extends DateCell>>();
    nextMonthDays = new ArrayList<Wrap<? extends DateCell>>();
    Lookup monthDaysLookup = sceneParent.lookup(DateCell.class, new ByStyleClass("day-cell"));
    for (int i = 0; i < monthDaysLookup.size(); i++) {
        if (((Wrap<? extends DateCell>) monthDaysLookup.wrap(i)).getControl().getStyleClass().contains("previous-month")) {
            previousMonthDays.add(monthDaysLookup.wrap(i));
        } else if (((Wrap<? extends DateCell>) monthDaysLookup.wrap(i)).getControl().getStyleClass().contains("next-month")) {
            nextMonthDays.add(monthDaysLookup.wrap(i));
        } else {
            currentMonthDays.add(monthDaysLookup.wrap(i));
        }
    }

    daysNames = new ArrayList<Wrap<? extends DateCell>>();
    Lookup daysNamesLookup = sceneParent.lookup(DateCell.class, new ByStyleClass("day-name-cell"));
    for (int i = 0; i < daysNamesLookup.size(); i++) {
        daysNames.add(daysNamesLookup.wrap(i));
    }

    final Lookup todayLookup = sceneParent.lookup(DateCell.class, new ByStyleClass("today"));
    if (todayLookup.size() > 0) {
        today = todayLookup.wrap();
    } else {
        today = null;
    }

    final Lookup secondaryLabelLookup = sceneParent.lookup(Label.class, new ByStyleClass("secondary-text"));
    if (secondaryLabelLookup.size() > 0) {
        secondaryLabel = todayLookup.wrap();
    } else {
        secondaryLabel = null;
    }
}
项目:openjfx-8u-dev-tests    文件:DatePickerTest.java   
/**
 * Changes value of the property 'showWeekNumbers'
 * and checks that DateChooser is rendered correctly.
 * The value is set via api and via context menu.
 */
@Test(timeout = 20000)
public void showWeekNumbersProperty() throws InterruptedException {
    assertFalse(new GetAction<Boolean>() {
        @Override public void run(Object... parameters) throws Exception {
            setResult(new DatePicker().isShowWeekNumbers());
        }
    }.dispatch(testedControl.getEnvironment()).booleanValue());

    rememberInitialState(Properties.showing, Properties.hover, Properties.pressed, Properties.armed);

    setDate(LocalDate.of(2013, Month.DECEMBER, 31));
    for(SettingType settingType : SettingType.values()) {
        System.out.format("Testing binding:%s\n", settingType.toString());
        setPropertyByToggleClick(settingType, Properties.showWeekNumbers, Boolean.TRUE);

        checkTextFieldText(Properties.showWeekNumbers, "true");

        clickDropDownButton(); waitPopupShowingState(true);

        PopupSceneDescription description = new PopupSceneDescription();
        description.extractData();
        assertEquals("[Incorrect count of week numbers]", 6, description.weeksNumbers.size());

        description.weeksNumbers.sort(new Comparator<Wrap<? extends DateCell>>() {
            public int compare(Wrap<? extends DateCell> o1, Wrap<? extends DateCell> o2) {
                return o1.getScreenBounds().y - o2.getScreenBounds().y;
            }
        });

        Integer[] expectedNumbers = {49, 50, 51, 52, 1, 2};
        assertEquals("[Weeks are not in correct order]", Arrays.asList(expectedNumbers), description.getInfoDescription().weekNumbers);

        setPropertyByToggleClick(settingType, Properties.showWeekNumbers, Boolean.FALSE);

        description.extractData();
        assertEquals("[No week numbers expected]", 0, description.weeksNumbers.size());

        scene.mouse().click(1, new Point(2, 2));
        switchOffBinding(settingType, Properties.showWeekNumbers);
    }
    checkFinalState();
}
项目:JFoenix    文件:JFXDatePickerContent.java   
private void updateDayCells() {
    Locale locale = getLocale();
    Chronology chrono = getPrimaryChronology();
    // get the index of the first day of the month
    int firstDayOfWeek = WeekFields.of(getLocale()).getFirstDayOfWeek().getValue();
    int firstOfMonthIndex = selectedYearMonth.get().atDay(1).getDayOfWeek().getValue() - firstDayOfWeek;
    firstOfMonthIndex += firstOfMonthIndex < 0 ? daysPerWeek : 0;
    YearMonth currentYearMonth = selectedYearMonth.get();

    int daysInCurMonth = -1;

    for (int i = 0; i < 6 * daysPerWeek; i++) {
        DateCell dayCell = dayCells.get(i);
        dayCell.getStyleClass().setAll("cell", "date-cell", "day-cell");
        dayCell.setPrefSize(40, 42);
        dayCell.setDisable(false);
        dayCell.setStyle(null);
        dayCell.setGraphic(null);
        dayCell.setTooltip(null);
        dayCell.setTextFill(DEFAULT_COLOR);
        dayCell.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
            CornerRadii.EMPTY,
            Insets.EMPTY)));

        try {
            if (daysInCurMonth == -1) {
                daysInCurMonth = currentYearMonth.lengthOfMonth();
            }

            int dayIndex = i - firstOfMonthIndex + 1;

            LocalDate date = currentYearMonth.atDay(dayIndex);
            dayCellDates[i] = date;

            // if it's today
            if (date.equals(LocalDate.now())) {
                dayCell.setTextFill(this.datePicker.getDefaultColor());
                dayCell.getStyleClass().add("today");
            }
            // if it's the current selected value
            if (date.equals(datePicker.getValue())) {
                dayCell.getStyleClass().add("selected");
                dayCell.setTextFill(Color.WHITE);
                dayCell.setBackground(
                    new Background(new BackgroundFill(this.datePicker.getDefaultColor(),
                        new CornerRadii(40),
                        Insets.EMPTY)));
            }

            ChronoLocalDate cDate = chrono.date(date);
            String cellText = dayCellFormatter.withLocale(locale)
                .withChronology(chrono)
                .withDecimalStyle(DecimalStyle.of(locale))
                .format(cDate);
            dayCell.setText(cellText);
            if (i < firstOfMonthIndex) {
                dayCell.getStyleClass().add("previous-month");
                dayCell.setText("");
            } else if (i >= firstOfMonthIndex + daysInCurMonth) {
                dayCell.getStyleClass().add("next-month");
                dayCell.setText("");
            }
            // update cell item
            dayCell.updateItem(date, false);
        } catch (DateTimeException ex) {
            // Disable day cell if its date is out of range
            dayCell.setText("");
            dayCell.setDisable(true);
        }
    }
}
项目:JFoenix    文件:JFXDatePickerContent.java   
protected LocalDate dayCellDate(DateCell dateCell) {
    assert dayCellDates != null;
    return dayCellDates[dayCells.indexOf(dateCell)];
}
项目:JFoenix    文件:JFXDatePickerContent.java   
private void goToDayCell(DateCell dateCell, int offset, ChronoUnit unit, boolean focusDayCell) {
    goToDate(dayCellDate(dateCell).plus(offset, unit), focusDayCell);
}
项目:JFoenix    文件:JFXDatePickerContent.java   
private void selectDayCell(DateCell dateCell) {
    datePicker.setValue(dayCellDate(dateCell));
    datePicker.hide();
}
项目:JFoenix    文件:JFXDatePickerContent.java   
protected void createDayCells() {
    for (int row = 0; row < 6; row++) {
        for (int col = 0; col < daysPerWeek; col++) {
            DateCell dayCell = createDayCell();
            dayCell.addEventHandler(MouseEvent.MOUSE_CLICKED, click -> {
                // allow date selection on mouse primary button click
                if (click.getButton() != MouseButton.PRIMARY) {
                    return;
                }
                DateCell selectedDayCell = (DateCell) click.getSource();
                selectDayCell(selectedDayCell);
                currentFocusedDayCell = selectedDayCell;
            });
            // add mouse hover listener
            dayCell.setOnMouseEntered((event) -> {
                if (!dayCell.getStyleClass().contains("selected")) {
                    dayCell.setBackground(new Background(new BackgroundFill(Color.valueOf("#EDEDED"),
                        new CornerRadii(40),
                        Insets.EMPTY)));
                }
            });
            dayCell.setOnMouseExited((event) -> {
                if (!dayCell.getStyleClass().contains("selected")) {
                    dayCell.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT,
                        CornerRadii.EMPTY,
                        Insets.EMPTY)));
                }
            });
            dayCell.setAlignment(Pos.BASELINE_CENTER);
            dayCell.setBorder(
                new Border(new BorderStroke(Color.TRANSPARENT,
                    BorderStrokeStyle.SOLID,
                    CornerRadii.EMPTY,
                    new BorderWidths(5))));
            dayCell.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12));
            dayCells.add(dayCell);
        }
    }
    dayCellDates = new LocalDate[6 * daysPerWeek];
    // position the cells into the grid
    updateContentGrid();
}
项目:Client-UI    文件:GroupCreateAssignmentController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    this.manager = Main.getInstance().getAuthHandler().getAssessmentManager();

    // Setup the combobox handler
    this.cmbAssessment.setConverter(new StringConverter<AssessmentProfile>() {
        @Override
        public String toString(AssessmentProfile object) {
            return object.getDisplayName();
        }

        @Override
        public AssessmentProfile fromString(String string) {
            return null; // FIXME
        }
    });

    try {
        // Add all known assessments to the combo box
        for (AssessmentProfile profile : this.manager.getAssessments()) {
            this.cmbAssessment.getItems().add(profile);
        }
    } catch (IOException | AssessmentException e) {
        Throwables.propagate(e);
    }

    dteDeadline.setShowWeekNumbers(false);
    dteDeadline.setDayCellFactory(datePicker -> new DateCell() {
        @Override
        public void updateItem(LocalDate item, boolean empty) {
            super.updateItem(item, empty);

            if (item.isBefore(LocalDate.now())) {
                setDisable(true);
                setStyle("-fx-background-color: #aaaaaa;");
                return;
            }

            long p = ChronoUnit.DAYS.between(LocalDate.now(), item);
            Tooltip tooltip = new Tooltip(String.format("This assessment is due in %d days", p));

            if (p == 0) {
                tooltip = new Tooltip("This assessment is due in today");
                tooltip.setStyle("-fx-text-fill: #FF4F1B;");
            }

            setTooltip(tooltip);
        }
    });
}