@Override protected void doSetValue(Object source, Object value) { if (value == null) { // ignore null, since it cannot be applied to the DateTimeWidget return; } DateTime dateTime = (DateTime) source; Calendar cal = (Calendar) calendar.get(); cal.setTime((Date) value); if ((dateTime.getStyle() & SWT.TIME) != 0) { dateTime.setTime(cal.get(Calendar.HOUR_OF_DAY), cal .get(Calendar.MINUTE), cal.get(Calendar.SECOND)); } else { dateTime.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH)); } } }
public void handleEvent(Event event) { int year = popupCalendar.getYear (); int month = popupCalendar.getMonth (); int day = popupCalendar.getDay (); setDate(year, month, day); Event e = new Event (); e.time = event.time; notifyListeners (SWT.Selection, e); hideCalendar(); } });
public void handleSetDate( DateTime dateTime, JsonObject properties ) { JsonValue yearValue = properties.get( PROP_YEAR ); JsonValue monthValue = properties.get( PROP_MONTH ); JsonValue dayValue = properties.get( PROP_DAY ); if( yearValue != null && monthValue != null && dayValue != null ) { dateTime.setDate( yearValue.asInt(), monthValue.asInt(), dayValue.asInt() ); } }
cal.setTimeInMillis( current ); calendar.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
void readData( final DateTime dateTime ) { String day = WidgetLCAUtil.readPropertyValue( dateTime, PROP_DAY ); String month = WidgetLCAUtil.readPropertyValue( dateTime, PROP_MONTH ); String year = WidgetLCAUtil.readPropertyValue( dateTime, PROP_YEAR ); if( day != null && month != null && year != null ) { dateTime.setDate( NumberFormatUtil.parseInt( year ), NumberFormatUtil.parseInt( month ), NumberFormatUtil.parseInt( day ) ); } ControlLCAUtil.processSelection( dateTime, null, true ); ControlLCAUtil.processMouseEvents( dateTime ); ControlLCAUtil.processKeyEvents( dateTime ); ControlLCAUtil.processMenuDetect( dateTime ); WidgetLCAUtil.processHelp( dateTime ); }
void readData( final DateTime dateTime ) { String day = WidgetLCAUtil.readPropertyValue( dateTime, PROP_DAY ); String month = WidgetLCAUtil.readPropertyValue( dateTime, PROP_MONTH ); String year = WidgetLCAUtil.readPropertyValue( dateTime, PROP_YEAR ); if( day != null && month != null && year != null ) { dateTime.setDate( NumberFormatUtil.parseInt( year ), NumberFormatUtil.parseInt( month ), NumberFormatUtil.parseInt( day ) ); } ControlLCAUtil.processSelection( dateTime, null, true ); ControlLCAUtil.processMouseEvents( dateTime ); ControlLCAUtil.processKeyEvents( dateTime ); ControlLCAUtil.processMenuDetect( dateTime ); WidgetLCAUtil.processHelp( dateTime ); }
void createPopupShell (int year, int month, int day) { popupShell = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); popupCalendar = new DateTime (popupShell, SWT.CALENDAR); if (font != null) popupCalendar.setFont (font); if (fg != null) popupCalendar.setForeground (fg); if (bg != null) popupCalendar.setBackground (bg); mouseEventListener = new Listener () { @Override public void handleEvent (Event event) { if (event.widget instanceof Control) { Control c = (Control)event.widget; if (c != down && c.getShell () != popupShell) dropDownCalendar (false); } } }; int [] listeners = {SWT.Close, SWT.MouseUp, SWT.Paint}; for (int i=0; i < listeners.length; i++) { popupShell.addListener (listeners [i], popupListener); } listeners = new int [] {SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose}; for (int i=0; i < listeners.length; i++) { popupCalendar.addListener (listeners [i], popupListener); } addListener (SWT.Dispose, popupListener); if (year != -1) popupCalendar.setDate (year, month, day); }
void createPopupShell (int year, int month, int day) { popupShell = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); popupCalendar = new DateTime (popupShell, SWT.CALENDAR); if (font != null) popupCalendar.setFont (font); if (fg != null) popupCalendar.setForeground (fg); if (bg != null) popupCalendar.setBackground (bg); mouseEventListener = new Listener () { @Override public void handleEvent (Event event) { if (event.widget instanceof Control) { Control c = (Control)event.widget; if (c != down && c.getShell () != popupShell) dropDownCalendar (false); } } }; int [] listeners = {SWT.Close, SWT.MouseUp, SWT.Paint}; for (int i=0; i < listeners.length; i++) { popupShell.addListener (listeners [i], popupListener); } listeners = new int [] {SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose}; for (int i=0; i < listeners.length; i++) { popupCalendar.addListener (listeners [i], popupListener); } addListener (SWT.Dispose, popupListener); if (year != -1) popupCalendar.setDate (year, month, day); }
void createPopupShell (int year, int month, int day) { popupShell = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP); popupCalendar = new DateTime (popupShell, SWT.CALENDAR); if (font != null) popupCalendar.setFont (font); if (fg != null) popupCalendar.setForeground (fg); if (bg != null) popupCalendar.setBackground (bg); mouseEventListener = new Listener () { @Override public void handleEvent (Event event) { if (event.widget instanceof Control) { Control c = (Control)event.widget; if (c != down && c.getShell () != popupShell) dropDownCalendar (false); } } }; int [] listeners = {SWT.Close, SWT.MouseUp, SWT.Paint}; for (int i=0; i < listeners.length; i++) { popupShell.addListener (listeners [i], popupListener); } listeners = new int [] {SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose}; for (int i=0; i < listeners.length; i++) { popupCalendar.addListener (listeners [i], popupListener); } addListener (SWT.Dispose, popupListener); if (year != -1) popupCalendar.setDate (year, month, day); }
if (year != -1) popupCalendar.setDate(year, month, day);
int month = popupCalendar.getMonth (); int day = popupCalendar.getDay (); setDate (year, month, day); Event e = new Event (); e.time = event.time; if (event.character == SWT.ESC) { popupCalendar.setDate (savedYear, savedMonth, savedDay); setDate (savedYear, savedMonth, savedDay); dropDownCalendar (false);
void showCalendar() { if (isDropped ()) return; savedYear = getYear (); savedMonth = getMonth (); savedDay = getDay (); if (getShell() != popupShell.getParent ()) { disposePopupShell(); createPopupShell (savedYear, savedMonth, savedDay); } Point dateBounds = getSize (); Point calendarSize = popupCalendar.computeSize (SWT.DEFAULT, SWT.DEFAULT, false); popupCalendar.setBounds (1, 1, Math.max (dateBounds.x - 2, calendarSize.x), calendarSize.y); popupCalendar.setDate(savedYear, savedMonth, savedDay); Rectangle parentRect = display.map (getParent (), null, getBounds ()); Rectangle displayRect = getMonitor ().getClientArea (); int width = Math.max (dateBounds.x, calendarSize.x + 2); int height = calendarSize.y + 2; int x = parentRect.x; int y = parentRect.y + dateBounds.y; if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height; if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - calendarSize.x; popupShell.setBounds (x, y, width, height); popupShell.setVisible (true); if (isFocusControl()) popupCalendar.setFocus (); display.addFilter(SWT.MouseDown, clickListener); }
int month = popupCalendar.getMonth (); int day = popupCalendar.getDay (); setDate (year, month, day); Event e = new Event (); e.time = event.time; if (event.character == SWT.ESC) { popupCalendar.setDate (savedYear, savedMonth, savedDay); setDate (savedYear, savedMonth, savedDay); dropDownCalendar (false);
int month = popupCalendar.getMonth (); int day = popupCalendar.getDay (); setDate (year, month, day); Event e = new Event (); e.time = event.time; if (event.character == SWT.ESC) { popupCalendar.setDate (savedYear, savedMonth, savedDay); setDate (savedYear, savedMonth, savedDay); dropDownCalendar (false);
popupCalendar.setDate (savedYear, savedMonth, savedDay); focusDayOnPopupCalendar ();
popupCalendar.setDate (savedYear, savedMonth, savedDay); focusDayOnPopupCalendar ();
popupCalendar.setDate (savedYear, savedMonth, savedDay); focusDayOnPopupCalendar ();