本文整理了Java中org.eclipse.swt.widgets.DateTime.setDate()
方法的一些代码示例,展示了DateTime.setDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.setDate()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.DateTime
类名称:DateTime
方法名:setDate
[英]Sets the receiver's year, month, and day in a single operation.
This is the recommended way to set the date, because setting the year, month, and day separately may result in invalid intermediate dates.
[中]在单个操作中设置接收器的年、月和日。
这是设置日期的推荐方法,因为单独设置年、月和日可能会导致中间日期无效。
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.databinding
@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));
}
}
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
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();
}
});
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
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() );
}
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
popupCalendar.setDate (savedYear, savedMonth, savedDay);
setDate(savedYear, savedMonth, savedDay);
hideCalendar();
return;
int day = getDay();
int year = getYear();
popupCalendar.setDate(year, month, day);
代码示例来源:origin: BiglySoftware/BiglyBT
cal.setTimeInMillis( current );
calendar.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
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 );
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
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 );
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
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);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
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);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
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);
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
if (year != -1) popupCalendar.setDate(year, month, day);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
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);
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
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);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
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);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
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);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
popupCalendar.setDate (savedYear, savedMonth, savedDay);
focusDayOnPopupCalendar ();
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
popupCalendar.setDate (savedYear, savedMonth, savedDay);
focusDayOnPopupCalendar ();
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
popupCalendar.setDate (savedYear, savedMonth, savedDay);
focusDayOnPopupCalendar ();
内容来源于网络,如有侵权,请联系作者删除!