List of usage examples for org.joda.time YearMonth equals
public boolean equals(Object partial)
From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java
License:Apache License
protected CalendarItem[] buildMonthItems() { YearMonth calendarFirstMonth = getCalendarFirstMonth(); YearMonth calendarLastMonth = getCalendarLastMonth(); YearMonth currentMonth = YearMonth.now(); int numberOfMonths = Months.monthsBetween(calendarFirstMonth, calendarLastMonth).getMonths() + 1; CalendarItem[] calendarItems = new CalendarItem[numberOfMonths]; YearMonth month = calendarFirstMonth; LocalDate currentValue = getLocalDate(); YearMonth currentYearMonthValue = currentValue == null ? null : new YearMonth(currentValue.getYear(), currentValue.getMonthOfYear()); for (int i = 0; i < numberOfMonths; i++, month = month.plusMonths(1)) { calendarItems[i] = new CalendarItem(); calendarItems[i].setIndex(i);/*from w w w . java2 s . co m*/ calendarItems[i].setRelativeDateIndex(month.getMonthOfYear()); calendarItems[i].setEnabled(true); // By default StringBuilder style = new StringBuilder(""); if (month.equals(currentMonth)) { style.append("currentmonth "); } if (currentYearMonthValue != null && month.equals(currentYearMonthValue)) { style.append("selected "); } if (cellItemCustomizer != null) { String generatedStyle = cellItemCustomizer.getStyle(month, this); if (generatedStyle != null) { style.append(generatedStyle); style.append(" "); } String tooltip = cellItemCustomizer.getTooltip(month, this); if (tooltip != null) { calendarItems[i].setTooltip(tooltip); } } if (isMonthEnabled(month)) { calendarItems[i].setEnabled(true); } String computedStyle = style.toString(); if (!computedStyle.isEmpty()) { calendarItems[i].setStyle(computedStyle); } String calendarItemContent = null; if (cellItemCustomizer != null) { calendarItemContent = cellItemCustomizer.renderMonth(currentYearMonthValue, this); } // fallback to default value if (calendarItemContent == null) { calendarItemContent = shortMonthTexts[i]; } calendarItems[i].setText(calendarItemContent); } return calendarItems; }