Example usage for org.joda.time YearMonth getYear

List of usage examples for org.joda.time YearMonth getYear

Introduction

In this page you can find the example usage for org.joda.time YearMonth getYear.

Prototype

public int getYear() 

Source Link

Document

Get the year field value.

Usage

From source file:org.vaadin.addons.tuningdatefield.InlineTuningDateField.java

License:Apache License

@Override
public void beforeClientResponse(boolean initial) {
    super.beforeClientResponse(initial);

    getState().setControlsEnabled(isControlsEnabled());
    getState().setCalendarResolution(calendarResolution);

    if (calendarResolution.equals(CalendarResolution.DAY)) {
        YearMonth yearMonthDisplayed = getYearMonthDisplayed();
        String displayedMonthText = monthTexts[yearMonthDisplayed.getMonthOfYear() - 1];
        getState().setCalendarResolutionText(displayedMonthText + " " + yearMonthDisplayed.getYear());
        getState().setWeekHeaderNames(weekDayNames);
        getState().setCalendarItems(buildDayItems());
    } else if (calendarResolution.equals(CalendarResolution.MONTH)) {
        getState().setCalendarItems(buildMonthItems());
        getState().setCalendarResolutionText(Integer.toString(yearMonthDisplayed.getYear()));
    } else if (calendarResolution.equals(CalendarResolution.YEAR)) {
        getState().setCalendarItems(buildYearItems());
        getState().setCalendarResolutionText(getCalendarFirstYear() + " - " + getCalendarLastYear());
    }//from  www .  j ava 2s .  c o m
}

From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java

License:Apache License

@Override
public void beforeClientResponse(boolean initial) {
    super.beforeClientResponse(initial);

    // For days of first week that are in previous month
    // Get first day of week of last week's previous month
    if (getValue() != null) {
        ((TuningDateFieldState) getState()).setDisplayedDateText(getValue());
    } else {//from w  w  w  . ja v  a  2  s.  c  o m
        ((TuningDateFieldState) getState()).setDisplayedDateText(null);
    }
    ((TuningDateFieldState) getState()).setCalendarOpen(calendarOpen);
    ((TuningDateFieldState) getState()).setDateTextReadOnly(dateTextReadOnly);
    ((TuningDateFieldState) getState()).setOpenCalendarOnFocusEnabled(openCalendarOnFocusEnabled);

    // We send calendar state only if it's open
    if (calendarOpen) {
        ((TuningDateFieldState) getState()).setControlsEnabled(controlsEnabled);
        ((TuningDateFieldState) getState()).setCalendarResolution(calendarResolution);

        if (calendarResolution.equals(CalendarResolution.DAY)) {
            YearMonth yearMonthDisplayed = getYearMonthDisplayed();
            String displayedMonthText = monthTexts[yearMonthDisplayed.getMonthOfYear() - 1];
            ((TuningDateFieldState) getState())
                    .setCalendarResolutionText(displayedMonthText + " " + yearMonthDisplayed.getYear());
            ((TuningDateFieldState) getState()).setWeekHeaderNames(weekDayNames);
            calendarItems = buildDayItems();
        } else if (calendarResolution.equals(CalendarResolution.MONTH)) {
            calendarItems = buildMonthItems();
            ((TuningDateFieldState) getState())
                    .setCalendarResolutionText(Integer.toString(yearMonthDisplayed.getYear()));
        } else if (calendarResolution.equals(CalendarResolution.YEAR)) {
            calendarItems = buildYearItems();
            ((TuningDateFieldState) getState())
                    .setCalendarResolutionText(getCalendarFirstYear() + " - " + getCalendarLastYear());
        }
        ((TuningDateFieldState) getState()).setCalendarItems(calendarItems);
    }

}

From source file:org.vaadin.addons.tuningdatefield.TuningDateField.java

License:Apache License

/**
 * @param yearMonthDisplayed/*w ww .jav a  2s .  c  o m*/
 *            the yearMonthDisplayed to set
 */
public void setYearMonthDisplayed(YearMonth yearMonthDisplayed) {
    this.yearMonthDisplayed = yearMonthDisplayed;
    this.yearDisplayed = yearMonthDisplayed.getYear();
    markAsDirty();
}