package com.itmill.toolkit.terminal.gwt.client.ui;\r
\r
+import com.google.gwt.user.client.Window;\r
import com.google.gwt.user.client.ui.ClickListener;\r
import com.google.gwt.user.client.ui.PopupListener;\r
import com.google.gwt.user.client.ui.PopupPanel;\r
public void onClick(Widget sender) {\r
if(sender == calendarToggle) {\r
calendar.updateCalendar();\r
- popup.setPopupPosition(calendarToggle.getAbsoluteLeft(), calendarToggle.getAbsoluteTop() + calendarToggle.getOffsetHeight() + 2);\r
popup.show();\r
- popup.setWidth(calendar.getOffsetWidth() + "px");\r
- popup.setHeight(calendar.getOffsetHeight() + "px");\r
+ int w = calendar.getOffsetWidth();\r
+ int h = calendar.getOffsetHeight();\r
+ int t = calendarToggle.getAbsoluteTop();\r
+ int l = calendarToggle.getAbsoluteLeft();\r
+ if(l+w > Window.getClientWidth())\r
+ l = Window.getClientWidth() - w;\r
+ if(t+h > Window.getClientHeight())\r
+ t = Window.getClientHeight() - h - calendarToggle.getOffsetHeight() - 2;\r
+ popup.setPopupPosition(l, t + calendarToggle.getOffsetHeight() + 2);\r
+ popup.setWidth(w + "px");\r
+ popup.setHeight(h + "px");\r
}\r
}\r
\r
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_MONTH;\r
else if(currentResolution >= IDateField.RESOLUTION_DAY)\r
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;\r
- \r
- format = new SimpleDateFormat(verifyFormat(dts.getDateFormat()));\r
+ \r
+ format = new SimpleDateFormat(cleanFormat(dts.getDateFormat()));\r
format.setLocale(dl);\r
\r
+ // Size the textfield a bit smaller if no clock time is needed\r
+ if(currentResolution <= IDateField.RESOLUTION_DAY)\r
+ text.setColumns(12);\r
+ \r
+ // Create the initial text for the textfield\r
String dateText = "";\r
if(date != null) {\r
dateText = format.format(date);\r
else if(currentResolution == IDateField.RESOLUTION_DAY)\r
DateLocale.SUPPORTED_DF_TOKENS = DateLocale.TOKENS_RESOLUTION_DAY;\r
\r
- String f = verifyFormat(dts.getDateFormat());\r
+ String f = cleanFormat(dts.getDateFormat());\r
\r
if(currentResolution >= IDateField.RESOLUTION_HOUR)\r
f += " " + (dts.isTwelveHourClock()?\r
\r
// Update variables\r
// (only the smallest defining resolution needs to be immediate)\r
- client.updateVariable(id, "year", date!=null?date.getYear()+1900:-1, currentResolution==IDateField.RESOLUTION_YEAR);\r
+ client.updateVariable(id, "year", date!=null?date.getYear()+1900:-1, currentResolution==IDateField.RESOLUTION_YEAR&&immediate);\r
if(currentResolution >= IDateField.RESOLUTION_MONTH)\r
client.updateVariable(id, "month", date!=null?date.getMonth()+1:-1, currentResolution==IDateField.RESOLUTION_MONTH&&immediate);\r
if(currentResolution >= IDateField.RESOLUTION_DAY)\r
}\r
}\r
\r
- private String verifyFormat(String format) {\r
+ private String cleanFormat(String format) {\r
// Remove unnecessary d & M if resolution is too low\r
if(currentResolution < IDateField.RESOLUTION_DAY)\r
format = format.replaceAll("d", "");\r