Browse Source

#6154 - Exception when opening CalendarPanel for a PopupDateField with resolution year

#5600 - Click on next/prev year in PopupDateField popup is not recorded

svn changeset:16504/svn branch:6.5
tags/6.7.0.beta1
Artur Signell 13 years ago
parent
commit
cff66e958c
1 changed files with 52 additions and 61 deletions
  1. 52
    61
      src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java

+ 52
- 61
src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java View File

@@ -7,7 +7,6 @@ package com.vaadin.terminal.gwt.client.ui;
import java.util.Date;
import java.util.Iterator;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Node;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
@@ -29,7 +28,6 @@ import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseUpEvent;
import com.google.gwt.event.dom.client.MouseUpHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
@@ -325,57 +323,53 @@ public class VCalendarPanel extends FocusableFlexTable implements
/**
* Builds the top buttons and current month and year header.
*
* @param forceRedraw
* Forces the builder to recreate the instances of the buttons.
* @param needsMonth
* Should the month buttons be visible?
*/
private void buildCalendarHeader(boolean forceRedraw, boolean needsMonth) {
if (forceRedraw) {
if (prevMonth == null) {
getFlexCellFormatter().setStyleName(0, 0,
VDateField.CLASSNAME + "-calendarpanel-prevyear");
getFlexCellFormatter().setStyleName(0, 4,
VDateField.CLASSNAME + "-calendarpanel-nextyear");
getFlexCellFormatter().setStyleName(0, 3,
VDateField.CLASSNAME + "-calendarpanel-nextmonth");
getFlexCellFormatter().setStyleName(0, 1,
VDateField.CLASSNAME + "-calendarpanel-prevmonth");
getRowFormatter().addStyleName(0,
VDateField.CLASSNAME + "-calendarpanel-header");
prevYear = new VEventButton();
prevYear.setHTML("«");
prevYear.setStyleName("v-button-prevyear");
prevYear.setTabIndex(-1);
nextYear = new VEventButton();
nextYear.setHTML("»");
nextYear.setStyleName("v-button-nextyear");
nextYear.setTabIndex(-1);
setWidget(0, 0, prevYear);
setWidget(0, 4, nextYear);
if (needsMonth) {
prevMonth = new VEventButton();
prevMonth.setHTML("‹");
prevMonth.setStyleName("v-button-prevmonth");
prevMonth.setTabIndex(-1);
nextMonth = new VEventButton();
nextMonth.setHTML("›");
nextMonth.setStyleName("v-button-nextmonth");
nextMonth.setTabIndex(-1);
setWidget(0, 3, nextMonth);
setWidget(0, 1, prevMonth);
}
} else if (!needsMonth) {
// Remove month traverse buttons
remove(prevMonth);
remove(nextMonth);
prevMonth = null;
nextMonth = null;
}
private void buildCalendarHeader(boolean needsMonth) {
getRowFormatter().addStyleName(0,
VDateField.CLASSNAME + "-calendarpanel-header");
if (prevMonth == null && needsMonth) {
prevMonth = new VEventButton();
prevMonth.setHTML("‹");
prevMonth.setStyleName("v-button-prevmonth");
prevMonth.setTabIndex(-1);
nextMonth = new VEventButton();
nextMonth.setHTML("›");
nextMonth.setStyleName("v-button-nextmonth");
nextMonth.setTabIndex(-1);
getFlexCellFormatter().setStyleName(0, 3,
VDateField.CLASSNAME + "-calendarpanel-nextmonth");
getFlexCellFormatter().setStyleName(0, 1,
VDateField.CLASSNAME + "-calendarpanel-prevmonth");
setWidget(0, 3, nextMonth);
setWidget(0, 1, prevMonth);
} else if (prevMonth != null && !needsMonth) {
// Remove month traverse buttons
remove(prevMonth);
remove(nextMonth);
prevMonth = null;
nextMonth = null;
}
if (prevYear == null) {
prevYear = new VEventButton();
prevYear.setHTML("«");
prevYear.setStyleName("v-button-prevyear");
prevYear.setTabIndex(-1);
nextYear = new VEventButton();
nextYear.setHTML("»");
nextYear.setStyleName("v-button-nextyear");
nextYear.setTabIndex(-1);
setWidget(0, 0, prevYear);
setWidget(0, 4, nextYear);
getFlexCellFormatter().setStyleName(0, 0,
VDateField.CLASSNAME + "-calendarpanel-prevyear");
getFlexCellFormatter().setStyleName(0, 4,
VDateField.CLASSNAME + "-calendarpanel-nextyear");
}
final String monthName = needsMonth ? getDateTimeService().getMonth(
@@ -585,7 +579,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
final boolean needsMonth = getResolution() > VDateField.RESOLUTION_YEAR;
boolean needsBody = getResolution() >= VDateField.RESOLUTION_DAY;
buildCalendarHeader(true, needsMonth);
buildCalendarHeader(needsMonth);
clearCalendarBody(!needsBody);
if (needsBody) {
buildCalendarBody();
@@ -1647,16 +1641,6 @@ public class VCalendarPanel extends FocusableFlexTable implements
* .dom.client.BlurEvent)
*/
public void onBlur(final BlurEvent event) {
if (isAttached()) {
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
if (!hasFocus) {
onTabOut(event);
}
}
});
}
if (event.getSource() instanceof VCalendarPanel) {
hasFocus = false;
focusDay(-1);
@@ -1793,4 +1777,11 @@ public class VCalendarPanel extends FocusableFlexTable implements
return null;
}
@Override
protected void onDetach() {
super.onDetach();
if (mouseTimer != null) {
mouseTimer.cancel();
}
}
}

Loading…
Cancel
Save