Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 107134 Details for
Bug 183177
[DateTime] DateTime widget missing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch without the binary data (images). Calendar is included. Bugfixes.
patch.txt (text/plain), 176.55 KB, created by
Ivan Furnadjiev
on 2008-07-10 16:15:14 EDT
(
hide
)
Description:
Patch without the binary data (images). Calendar is included. Bugfixes.
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2008-07-10 16:15:14 EDT
Size:
176.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/RWTHostTestSuite.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.test/src/org/eclipse/RWTHostTestSuite.java,v >retrieving revision 1.4 >diff -u -r1.4 RWTHostTestSuite.java >--- src/org/eclipse/RWTHostTestSuite.java 12 Jun 2008 13:23:18 -0000 1.4 >+++ src/org/eclipse/RWTHostTestSuite.java 10 Jul 2008 20:11:16 -0000 >@@ -146,6 +146,7 @@ > suite.addTestSuite( ExternalBrowser_Test.class ); > suite.addTestSuite( ProgressBar_Test.class ); > suite.addTestSuite( BusyIndicator_Test.class ); >+ suite.addTestSuite( DateTime_Test.class ); > > suite.addTestSuite( Image_Test.class ); > suite.addTestSuite( ImageData_Test.class ); >Index: src/org/eclipse/swt/widgets/DateTime_Test.java >=================================================================== >RCS file: src/org/eclipse/swt/widgets/DateTime_Test.java >diff -N src/org/eclipse/swt/widgets/DateTime_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/widgets/DateTime_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,167 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Innoopract Informationssysteme GmbH. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 which accompanies this distribution, >+ * and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.swt.widgets; >+ >+import java.util.Calendar; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.swt.RWTFixture; >+import org.eclipse.swt.SWT; >+ >+public class DateTime_Test extends TestCase { >+ >+ protected void setUp() throws Exception { >+ RWTFixture.setUp(); >+ } >+ >+ protected void tearDown() throws Exception { >+ RWTFixture.tearDown(); >+ } >+ >+ public void testInitialValues() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ Calendar rightNow = Calendar.getInstance(); >+ DateTime dateTime = new DateTime( shell, SWT.DATE | SWT.MEDIUM ); >+ assertEquals( rightNow.get( Calendar.DATE ), dateTime.getDay() ); >+ assertEquals( rightNow.get( Calendar.MONTH ), dateTime.getMonth() ); >+ assertEquals( rightNow.get( Calendar.YEAR ), dateTime.getYear() ); >+ assertEquals( rightNow.get( Calendar.HOUR_OF_DAY ), dateTime.getHours() ); >+ assertEquals( rightNow.get( Calendar.MINUTE ), dateTime.getMinutes() ); >+ assertEquals( rightNow.get( Calendar.SECOND ), dateTime.getSeconds() ); >+ } >+ >+ public void testInvalidValues() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ DateTime dateTime = new DateTime( shell, SWT.NONE ); >+ dateTime.setDay( 1 ); >+ dateTime.setMonth( 0 ); >+ dateTime.setYear( 2008 ); >+ dateTime.setHours( 0 ); >+ dateTime.setMinutes( 0 ); >+ dateTime.setSeconds( 0 ); >+ assertEquals( 1, dateTime.getDay() ); >+ assertEquals( 0, dateTime.getMonth() ); >+ assertEquals( 2008, dateTime.getYear() ); >+ assertEquals( 0, dateTime.getHours() ); >+ assertEquals( 0, dateTime.getMinutes() ); >+ assertEquals( 0, dateTime.getSeconds() ); >+ // Test day >+ dateTime.setDay( 61 ); >+ assertEquals( 1, dateTime.getDay() ); >+ dateTime.setDay( 0 ); >+ assertEquals( 1, dateTime.getDay() ); >+ dateTime.setDay( -5 ); >+ assertEquals( 1, dateTime.getDay() ); >+ dateTime.setMonth( 1 ); >+ dateTime.setDay( 29 ); >+ assertEquals( 29, dateTime.getDay() ); >+ dateTime.setDay( 30 ); >+ assertEquals( 29, dateTime.getDay() ); >+ // Test month >+ dateTime.setMonth( 12 ); >+ assertEquals( 1, dateTime.getMonth() ); >+ dateTime.setMonth( -5 ); >+ assertEquals( 1, dateTime.getMonth() ); >+ dateTime.setMonth( 0 ); >+ dateTime.setDay( 31 ); >+ dateTime.setMonth( 1 ); >+ assertEquals( 0, dateTime.getMonth() ); >+ // Test year >+ dateTime.setYear( 12345 ); >+ assertEquals( 2008, dateTime.getYear() ); >+ dateTime.setYear( 123 ); >+ assertEquals( 2008, dateTime.getYear() ); >+ dateTime.setDay( 29 ); >+ dateTime.setMonth( 1 ); >+ dateTime.setYear( 2007 ); >+ assertEquals( 2008, dateTime.getYear() ); >+ // Test hours >+ dateTime.setHours( 24 ); >+ assertEquals( 0, dateTime.getHours() ); >+ dateTime.setHours( -3 ); >+ assertEquals( 0, dateTime.getHours() ); >+ // Test minutes >+ dateTime.setMinutes( 65 ); >+ assertEquals( 0, dateTime.getMinutes() ); >+ dateTime.setMinutes( -7 ); >+ assertEquals( 0, dateTime.getMinutes() ); >+ // Test seconds >+ dateTime.setSeconds( 89 ); >+ assertEquals( 0, dateTime.getSeconds() ); >+ dateTime.setSeconds( -1 ); >+ assertEquals( 0, dateTime.getSeconds() ); >+ } >+ >+ public void testStyle() { >+ Display display = new Display(); >+ Shell shell = new Shell( display, SWT.NONE ); >+ // Test SWT.NONE >+ DateTime dateTime = new DateTime( shell, SWT.NONE ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ); >+ // Test SWT.BORDER >+ dateTime = new DateTime( shell, SWT.BORDER ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.BORDER ) != 0 ); >+ // Test combination of SWT.DATE | SWT.TIME | SWT.CALENDAR >+ dateTime = new DateTime( shell, SWT.DATE | SWT.TIME | SWT.CALENDAR ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.TIME ) == 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.CALENDAR ) == 0 ); >+ dateTime = new DateTime( shell, SWT.DATE | SWT.TIME ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.TIME ) == 0 ); >+ dateTime = new DateTime( shell, SWT.DATE | SWT.CALENDAR ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.CALENDAR ) == 0 ); >+ dateTime = new DateTime( shell, SWT.TIME | SWT.CALENDAR ); >+ assertTrue( ( dateTime.getStyle() & SWT.TIME ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.CALENDAR ) == 0 ); >+ dateTime = new DateTime( shell, SWT.CALENDAR ); >+ assertTrue( ( dateTime.getStyle() & SWT.CALENDAR ) != 0 ); >+ // Test combination of SWT.MEDIUM | SWT.SHORT | SWT.LONG >+ dateTime = new DateTime( shell, SWT.DATE >+ | SWT.MEDIUM >+ | SWT.SHORT >+ | SWT.LONG ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.SHORT ) == 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.LONG ) == 0 ); >+ dateTime = new DateTime( shell, SWT.DATE >+ | SWT.MEDIUM >+ | SWT.SHORT ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.SHORT ) == 0 ); >+ dateTime = new DateTime( shell, SWT.DATE >+ | SWT.MEDIUM >+ | SWT.LONG ); >+ assertTrue( ( dateTime.getStyle() & SWT.DATE ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.LONG ) == 0 ); >+ dateTime = new DateTime( shell, SWT.TIME >+ | SWT.SHORT >+ | SWT.LONG ); >+ assertTrue( ( dateTime.getStyle() & SWT.TIME ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.SHORT ) != 0 ); >+ assertTrue( ( dateTime.getStyle() & SWT.LONG ) == 0 ); >+ } >+ >+ public void testDispose() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ DateTime dateTime = new DateTime( shell, SWT.DATE | SWT.MEDIUM ); >+ dateTime.dispose(); >+ assertTrue( dateTime.isDisposed() ); >+ } >+} >#P org.eclipse.rap.rwt >Index: src/org/eclipse/rwt/internal/theme/ThemeManager.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/theme/ThemeManager.java,v >retrieving revision 1.23 >diff -u -r1.23 ThemeManager.java >--- src/org/eclipse/rwt/internal/theme/ThemeManager.java 12 Jun 2008 13:12:17 -0000 1.23 >+++ src/org/eclipse/rwt/internal/theme/ThemeManager.java 10 Jul 2008 20:11:18 -0000 >@@ -125,7 +125,9 @@ > "tree/only_plus.gif", > "tree/plus.gif", > "tree/start_minus.gif", >- "tree/start_plus.gif", >+ "tree/start_plus.gif", >+ "datechooser/lastMonth.gif", >+ "datechooser/nextMonth.gif", > }; > > /** Where to load the default non-themeable images from */ >Index: src/org/eclipse/swt/SWT.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt/src/org/eclipse/swt/SWT.java,v >retrieving revision 1.30 >diff -u -r1.30 SWT.java >--- src/org/eclipse/swt/SWT.java 4 Jul 2008 07:39:50 -0000 1.30 >+++ src/org/eclipse/swt/SWT.java 10 Jul 2008 20:11:21 -0000 >@@ -1562,6 +1562,82 @@ > * contains a transparent pixel (value is 1<<2). > */ > public static final int TRANSPARENCY_PIXEL = 1 << 2; >+ >+ /** >+ * Style constant for date display (value is 1<<5). >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int DATE = 1 << 5; >+ >+ /** >+ * Style constant for time display (value is 1<<7). >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int TIME = 1 << 7; >+ >+ /** >+ * Style constant for calendar display (value is 1<<10). >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int CALENDAR = 1 << 10; >+ >+ /** >+ * Style constant for short date/time format (value is 1<<15). >+ * <p> >+ * A short date displays the month and year. >+ * A short time displays hours and minutes. >+ * <br>Note that this is a <em>HINT</em>. >+ * </p> >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int SHORT = 1 << 15; >+ >+ /** >+ * Style constant for medium date/time format (value is 1<<16). >+ * <p> >+ * A medium date displays the day, month and year. >+ * A medium time displays hours, minutes, and seconds. >+ * <br>Note that this is a <em>HINT</em>. >+ * </p> >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int MEDIUM = 1 << 16; >+ >+ /** >+ * Style constant for long date/time format (value is 1<<28). >+ * <p> >+ * A long date displays the day, month and year. >+ * A long time displays hours, minutes, and seconds. >+ * The day and month names may be displayed. >+ * <br>Note that this is a <em>HINT</em>. >+ * </p> >+ * <p><b>Used By:</b><ul> >+ * <li><code>DateTime</code></li> >+ * </ul></p> >+ * >+ * @since 3.3 >+ */ >+ public static final int LONG = 1 << 28; > > /** > * Throws an appropriate exception based on the passed in error code. >Index: src/org/eclipse/swt/widgets/DateTime.java >=================================================================== >RCS file: src/org/eclipse/swt/widgets/DateTime.java >diff -N src/org/eclipse/swt/widgets/DateTime.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/widgets/DateTime.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,893 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.widgets; >+ >+import java.text.*; >+import java.util.*; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWTException; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.internal.graphics.TextSizeDetermination; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+ >+/** >+ * Instances of this class are selectable user interface objects that allow the >+ * user to enter and modify date or time values. >+ * <p> >+ * Note that although this class is a subclass of <code>Composite</code>, it >+ * does not make sense to add children to it, or set a layout on it. >+ * </p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>DATE, TIME, CALENDAR, SHORT, MEDIUM, LONG</dd> >+ * <dt><b>Events:</b></dt> >+ * <dd>Selection</dd> >+ * </dl> >+ * <p> >+ * Note: Only one of the styles DATE, TIME, or CALENDAR may be specified, and >+ * only one of the styles SHORT, MEDIUM, or LONG may be specified. >+ * </p> >+ * <p> >+ * IMPORTANT: This class is <em>not</em> intended to be subclassed. >+ * </p> >+ * >+ * @since x.x >+ */ >+public class DateTime extends Composite { >+ >+ private final class DateTimeAdapter implements IDateTimeAdapter { >+ >+ public Rectangle getBounds( final int widget ) { >+ Rectangle result = new Rectangle( 0, 0, 0, 0); >+ switch( widget ) { >+ case WEEKDAY_TEXTFIELD: >+ result = weekdayTextFieldBounds; >+ break; >+ case DAY_TEXTFIELD: >+ result = dayTextFieldBounds; >+ break; >+ case MONTH_TEXTFIELD: >+ result = monthTextFieldBounds; >+ break; >+ case YEAR_TEXTFIELD: >+ result = yearTextFieldBounds; >+ break; >+ case WEEKDAY_MONTH_SEPARATOR: >+ result = separator0Bounds; >+ break; >+ case MONTH_DAY_SEPARATOR: >+ result = separator1Bounds; >+ break; >+ case DAY_YEAR_SEPARATOR: >+ result = separator2Bounds; >+ break; >+ case SPINNER: >+ result = spinnerBounds; >+ break; >+ case HOURS_TEXTFIELD: >+ result = hoursTextFieldBounds; >+ break; >+ case MINUTES_TEXTFIELD: >+ result = minutesTextFieldBounds; >+ break; >+ case SECONDS_TEXTFIELD: >+ result = secondsTextFieldBounds; >+ break; >+ case HOURS_MINUTES_SEPARATOR: >+ result = separator3Bounds; >+ break; >+ case MINUTES_SECONDS_SEPARATOR: >+ result = separator4Bounds; >+ break; >+ } >+ return result; >+ } >+ >+ public String[] getMonthNames() { >+ return MONTH_NAMES; >+ } >+ >+ public String[] getWeekdayNames() { >+ return WEEKDAY_NAMES; >+ } >+ >+ public String getDateSeparator() { >+ return DATE_SEPARATOR; >+ } >+ >+ public String getDatePattern() { >+ return DATE_PATTERN; >+ } >+ } >+ >+ private int V_PADDING = 6; >+ private int H_PADDING = 6; >+ >+ private String[] MONTH_NAMES; >+ private String[] WEEKDAY_NAMES; >+ private String DATE_SEPARATOR; >+ private String DATE_PATTERN; >+ >+ private final IDateTimeAdapter dateTimeAdapter; >+ private Calendar rightNow; >+ >+ // Date fields >+ private Rectangle weekdayTextFieldBounds; >+ private Rectangle dayTextFieldBounds; >+ private Rectangle monthTextFieldBounds; >+ private Rectangle yearTextFieldBounds; >+ private Rectangle separator0Bounds; >+ private Rectangle separator1Bounds; >+ private Rectangle separator2Bounds; >+ private Rectangle spinnerBounds; >+ // Time fields >+ private Rectangle hoursTextFieldBounds; >+ private Rectangle minutesTextFieldBounds; >+ private Rectangle secondsTextFieldBounds; >+ private Rectangle separator3Bounds; >+ private Rectangle separator4Bounds; >+ >+ /** >+ * Constructs a new instance of this class given its parent and a style value >+ * describing its behavior and appearance. >+ * <p> >+ * The style value is either one of the style constants defined in class >+ * <code>SWT</code> which is applicable to instances of this class, or must >+ * be built by <em>bitwise OR</em>'ing together (that is, using the >+ * <code>int</code> "|" operator) two or more of those <code>SWT</code> >+ * style constants. The class description lists the style constants that are >+ * applicable to the class. Style bits are also inherited from superclasses. >+ * </p> >+ * >+ * @param parent a composite control which will be the parent of the new >+ * instance (cannot be null) >+ * @param style the style of control to construct >+ * @exception IllegalArgumentException >+ * <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> >+ * </ul> >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the parent</li> >+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed >+ * subclass</li> >+ * </ul> >+ * @see SWT#DATE >+ * @see SWT#TIME >+ * @see SWT#CALENDAR >+ * @see Widget#checkSubclass >+ * @see Widget#getStyle >+ */ >+ public DateTime( final Composite parent, final int style ) { >+ super( parent, checkStyle( style ) ); >+ dateTimeAdapter = new DateTimeAdapter(); >+ rightNow = Calendar.getInstance(); >+ DateFormatSymbols symbols = new DateFormatSymbols(); >+ MONTH_NAMES = symbols.getMonths(); >+ WEEKDAY_NAMES = symbols.getWeekdays(); >+ DATE_SEPARATOR = getDateSeparator(); >+ DATE_PATTERN = getDatePattern( DATE_SEPARATOR ); >+ computeSubWidgetsBounds(); >+ } >+ >+ /** >+ * Adds the listener to the collection of listeners who will be notified when >+ * the control is selected by the user, by sending it one of the messages >+ * defined in the <code>SelectionListener</code> interface. >+ * <p> >+ * <code>widgetSelected</code> is called when the user changes the control's >+ * value. <code>widgetDefaultSelected</code> is not called. >+ * </p> >+ * >+ * @param listener the listener which should be notified >+ * @exception IllegalArgumentException >+ * <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ * @see SelectionListener >+ * @see #removeSelectionListener >+ * @see SelectionEvent >+ */ >+ public void addSelectionListener( final SelectionListener listener ) { >+ SelectionEvent.addListener( this, listener ); >+ } >+ >+ /** >+ * Removes the listener from the collection of listeners who will be notified >+ * when the control is selected by the user. >+ * >+ * @param listener the listener which should no longer be notified >+ * @exception IllegalArgumentException >+ * <ul> >+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> >+ * </ul> >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ * @see SelectionListener >+ * @see #addSelectionListener >+ */ >+ public void removeSelectionListener( final SelectionListener listener ) { >+ SelectionEvent.removeListener( this, listener ); >+ } >+ >+ /** >+ * Returns the receiver's hours. >+ * <p> >+ * Hours is an integer between 0 and 23. >+ * </p> >+ * >+ * @return an integer between 0 and 23 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getHours() { >+ checkWidget(); >+ return rightNow.get( Calendar.HOUR_OF_DAY ); >+ } >+ >+ /** >+ * Returns the receiver's minutes. >+ * <p> >+ * Minutes is an integer between 0 and 59. >+ * </p> >+ * >+ * @return an integer between 0 and 59 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getMinutes() { >+ checkWidget(); >+ return rightNow.get( Calendar.MINUTE ); >+ } >+ >+ /** >+ * Returns the receiver's seconds. >+ * <p> >+ * Seconds is an integer between 0 and 59. >+ * </p> >+ * >+ * @return an integer between 0 and 59 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getSeconds() { >+ checkWidget(); >+ return rightNow.get( Calendar.SECOND ); >+ } >+ >+ /** >+ * Returns the receiver's date, or day of the month. >+ * <p> >+ * The first day of the month is 1, and the last day depends on the month and >+ * year. >+ * </p> >+ * >+ * @return a positive integer beginning with 1 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getDay() { >+ checkWidget(); >+ return rightNow.get( Calendar.DATE ); >+ } >+ >+ /** >+ * Returns the receiver's month. >+ * <p> >+ * The first month of the year is 0, and the last month is 11. >+ * </p> >+ * >+ * @return an integer between 0 and 11 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getMonth() { >+ checkWidget(); >+ return rightNow.get( Calendar.MONTH ); >+ } >+ >+ /** >+ * Returns the receiver's year. >+ * <p> >+ * The first year is 1752 and the last year is 9999. >+ * </p> >+ * >+ * @return an integer between 1752 and 9999 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public int getYear() { >+ checkWidget(); >+ return rightNow.get( Calendar.YEAR ); >+ } >+ >+ /** >+ * Sets the receiver's hours. >+ * <p> >+ * Hours is an integer between 0 and 23. >+ * </p> >+ * >+ * @param hours an integer between 0 and 23 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setHours( final int hours ) { >+ checkWidget(); >+ if( hours >= 0 && hours <= 23 ) { >+ rightNow.set( Calendar.HOUR_OF_DAY, hours ); >+ } >+ } >+ >+ /** >+ * Sets the receiver's minutes. >+ * <p> >+ * Minutes is an integer between 0 and 59. >+ * </p> >+ * >+ * @param minutes an integer between 0 and 59 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setMinutes( final int minutes ) { >+ checkWidget(); >+ if( minutes >= 0 && minutes <= 59 ) { >+ rightNow.set( Calendar.MINUTE, minutes ); >+ } >+ } >+ >+ /** >+ * Sets the receiver's seconds. >+ * <p> >+ * Seconds is an integer between 0 and 59. >+ * </p> >+ * >+ * @param seconds an integer between 0 and 59 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setSeconds( final int seconds ) { >+ checkWidget(); >+ if( seconds >= 0 && seconds <= 59 ) { >+ rightNow.set( Calendar.SECOND, seconds ); >+ } >+ } >+ >+ /** >+ * Sets the receiver's date, or day of the month, to the specified day. >+ * <p> >+ * The first day of the month is 1, and the last day depends on the month and >+ * year. >+ * </p> >+ * >+ * @param day a positive integer beginning with 1 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setDay( final int day ) { >+ checkWidget(); >+ int month = rightNow.get( Calendar.MONTH ); >+ int year = rightNow.get( Calendar.YEAR ); >+ if( day >= 1 && day <= getDaysInMonth( month, year ) ) { >+ rightNow.set( Calendar.DATE, day ); >+ } >+ } >+ >+ /** >+ * Sets the receiver's month. >+ * <p> >+ * The first month of the year is 0, and the last month is 11. >+ * </p> >+ * >+ * @param month an integer between 0 and 11 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setMonth( final int month ) { >+ checkWidget(); >+ int date = rightNow.get( Calendar.DATE ); >+ int year = rightNow.get( Calendar.YEAR ); >+ if( month >= 0 && month <= 11 && date <= getDaysInMonth( month, year ) ) { >+ rightNow.set( Calendar.MONTH, month ); >+ } >+ } >+ >+ /** >+ * Sets the receiver's year. >+ * <p> >+ * The first year is 1752 and the last year is 9999. >+ * </p> >+ * >+ * @param year an integer between 1752 and 9999 >+ * @exception SWTException >+ * <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the >+ * thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setYear( final int year ) { >+ checkWidget(); >+ int date = rightNow.get( Calendar.DATE ); >+ int month = rightNow.get( Calendar.MONTH ); >+ if( year >= 1752 && year <= 9999 && date <= getDaysInMonth( month, year ) ) { >+ rightNow.set( Calendar.YEAR, year ); >+ } >+ } >+ >+ /** >+ * Sets the font that the receiver will use to paint textual information >+ * to the font specified by the argument, or to the default font for that >+ * kind of control if the argument is null. >+ * >+ * @param font the new font (or null) >+ * >+ * @exception IllegalArgumentException <ul> >+ * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> >+ * </ul> >+ * @exception SWTException <ul> >+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> >+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> >+ * </ul> >+ */ >+ public void setFont( final Font font ) { >+ if( font != getFont() ) { >+ super.setFont( font ); >+ } >+ computeSubWidgetsBounds(); >+ } >+ >+ public Object getAdapter( final Class adapter ) { >+ Object result; >+ if( adapter == IDateTimeAdapter.class ) { >+ result = dateTimeAdapter; >+ } else { >+ result = super.getAdapter( adapter ); >+ } >+ return result; >+ } >+ >+ public Point computeSize( final int wHint, >+ final int hHint, >+ final boolean changed ) { >+ checkWidget(); >+ int width = 0, height = 0; >+ if( wHint == SWT.DEFAULT || hHint == SWT.DEFAULT ) { >+ Point size = computeSubWidgetsBounds(); >+ width = size.x; >+ height = size.y; >+ } >+ if( width == 0 ) { >+ width = DEFAULT_WIDTH; >+ } >+ if( height == 0 ) { >+ height = DEFAULT_HEIGHT; >+ } >+ if( wHint != SWT.DEFAULT ) { >+ width = wHint; >+ } >+ if( hHint != SWT.DEFAULT ) { >+ height = hHint; >+ } >+ int border = getBorderWidth(); >+ width += border * 2; >+ height += border * 2; >+ return new Point( width, height ); >+ } >+ >+ private Point computeSubWidgetsBounds() { >+ Font font = getFont(); >+ int width = 0, height = 0; >+ if( ( style & SWT.CALENDAR ) != 0 ) { >+ width = 168; >+ height = 140; >+ } else if( ( style & SWT.DATE ) != 0 ) { >+ Point prefSize = new Point( 0, 0 ); >+ if( DATE_PATTERN.equals( "MDY" ) ) { >+ prefSize = computeMDYBounds( font ); >+ } else if( DATE_PATTERN.equals( "DMY" ) ) { >+ prefSize = computeDMYBounds( font ); >+ } else { >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ prefSize = computeYMDBounds( font ); >+ } else { >+ prefSize = computeMDYBounds( font ); >+ } >+ } >+ // Overall widget size >+ width = prefSize.x; >+ height = prefSize.y; >+ } else if( ( style & SWT.TIME ) != 0 ) { >+ // Hours text field >+ hoursTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ hoursTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ hoursTextFieldBounds.height >+ = TextSizeDetermination.stringExtent( font, "88" ).y + V_PADDING; >+ // Hours minutes separator >+ separator3Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator3Bounds.x = hoursTextFieldBounds.x + hoursTextFieldBounds.width; >+ separator3Bounds.width >+ = TextSizeDetermination.stringExtent( font, ":" ).x; >+ separator3Bounds.height = hoursTextFieldBounds.height; >+ // Minutes text field >+ minutesTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ minutesTextFieldBounds.x = separator3Bounds.x + separator3Bounds.width; >+ minutesTextFieldBounds.width = hoursTextFieldBounds.width; >+ minutesTextFieldBounds.height = hoursTextFieldBounds.height; >+ // Minutes seconds separator >+ separator4Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator4Bounds.x = minutesTextFieldBounds.x >+ + minutesTextFieldBounds.width; >+ separator4Bounds.width = separator3Bounds.width; >+ separator4Bounds.height = hoursTextFieldBounds.height; >+ // Seconds text field >+ secondsTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ secondsTextFieldBounds.x = separator4Bounds.x + separator4Bounds.width; >+ secondsTextFieldBounds.width = hoursTextFieldBounds.width; >+ secondsTextFieldBounds.height = hoursTextFieldBounds.height; >+ // The spinner bounds >+ spinnerBounds = new Rectangle( 0, 0, 0, 0 ); >+ spinnerBounds.x = minutesTextFieldBounds.x >+ + minutesTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 || ( style & SWT.LONG) != 0 ) { >+ spinnerBounds.x = secondsTextFieldBounds.x >+ + secondsTextFieldBounds.width; >+ } >+ spinnerBounds.width = 17; >+ spinnerBounds.height = hoursTextFieldBounds.height; >+ // Overall widget size >+ width = spinnerBounds.x + spinnerBounds.width; >+ height = hoursTextFieldBounds.height; >+ } >+ return new Point( width, height ); >+ } >+ >+ private Point computeMDYBounds( final Font font ) { >+ // The weekday text field bounds >+ weekdayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ if( ( style & SWT.LONG ) != 0 ) { >+ weekdayTextFieldBounds.width >+ = getMaxStringLength( font, WEEKDAY_NAMES ) + H_PADDING + 2; >+ } >+ weekdayTextFieldBounds.height >+ = TextSizeDetermination.stringExtent( font, WEEKDAY_NAMES[1] ).y >+ + V_PADDING; >+ // The weekday month separator bounds >+ separator0Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator0Bounds.x >+ = weekdayTextFieldBounds.x + weekdayTextFieldBounds.width; >+ if( ( style & SWT.LONG ) != 0 ) { >+ separator0Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator0Bounds.height = weekdayTextFieldBounds.height; >+ // The month text field bounds >+ monthTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ monthTextFieldBounds.x = separator0Bounds.x + separator0Bounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ monthTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } else { >+ monthTextFieldBounds.width >+ = getMaxStringLength( font, MONTH_NAMES ) + H_PADDING + 2; >+ } >+ monthTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The month date separator bounds >+ separator1Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator1Bounds.x = monthTextFieldBounds.x + monthTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator1Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } >+ separator1Bounds.height = weekdayTextFieldBounds.height; >+ // The date text field bounds >+ dayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ dayTextFieldBounds.x = separator1Bounds.x + separator1Bounds.width; >+ if( ( style & SWT.SHORT ) == 0 ) { >+ dayTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } >+ dayTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The date year separator bounds >+ separator2Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator2Bounds.x = dayTextFieldBounds.x + dayTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } else { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator2Bounds.height = weekdayTextFieldBounds.height; >+ // The year text field bounds >+ yearTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ yearTextFieldBounds.x = separator2Bounds.x + separator2Bounds.width; >+ yearTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "8888" ).x + H_PADDING; >+ yearTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The spinner bounds >+ spinnerBounds = new Rectangle( 0, 0, 0, 0 ); >+ spinnerBounds.x = yearTextFieldBounds.x + yearTextFieldBounds.width; >+ spinnerBounds.width = 17; >+ spinnerBounds.height = weekdayTextFieldBounds.height; >+ // Overall widget size >+ int width = spinnerBounds.x + spinnerBounds.width; >+ int height = weekdayTextFieldBounds.height; >+ return new Point( width, height ); >+ } >+ >+ private Point computeDMYBounds( final Font font ) { >+ // The weekday text field bounds >+ weekdayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ if( ( style & SWT.LONG ) != 0 ) { >+ weekdayTextFieldBounds.width >+ = getMaxStringLength( font, WEEKDAY_NAMES ) + H_PADDING + 2; >+ } >+ weekdayTextFieldBounds.height >+ = TextSizeDetermination.stringExtent( font, WEEKDAY_NAMES[1] ).y >+ + V_PADDING; >+ // The weekday day separator bounds >+ separator0Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator0Bounds.x >+ = weekdayTextFieldBounds.x + weekdayTextFieldBounds.width; >+ if( ( style & SWT.LONG ) != 0 ) { >+ separator0Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator0Bounds.height = weekdayTextFieldBounds.height; >+ // The day text field bounds >+ dayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ dayTextFieldBounds.x = separator0Bounds.x + separator0Bounds.width; >+ if( ( style & SWT.SHORT ) == 0 ) { >+ dayTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } >+ dayTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The day month separator bounds >+ separator1Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator1Bounds.x = dayTextFieldBounds.x + dayTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator1Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } >+ separator1Bounds.height = weekdayTextFieldBounds.height; >+ // The month text field bounds >+ monthTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ monthTextFieldBounds.x = separator1Bounds.x + separator1Bounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ monthTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } else { >+ monthTextFieldBounds.width >+ = getMaxStringLength( font, MONTH_NAMES ) + H_PADDING + 2; >+ } >+ monthTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The month year separator bounds >+ separator2Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator2Bounds.x = monthTextFieldBounds.x + monthTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } else { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator2Bounds.height = weekdayTextFieldBounds.height; >+ // The year text field bounds >+ yearTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ yearTextFieldBounds.x = separator2Bounds.x + separator2Bounds.width; >+ yearTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "8888" ).x + H_PADDING; >+ yearTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The spinner bounds >+ spinnerBounds = new Rectangle( 0, 0, 0, 0 ); >+ spinnerBounds.x = yearTextFieldBounds.x + yearTextFieldBounds.width; >+ spinnerBounds.width = 17; >+ spinnerBounds.height = weekdayTextFieldBounds.height; >+ // Overall widget size >+ int width = spinnerBounds.x + spinnerBounds.width; >+ int height = weekdayTextFieldBounds.height; >+ return new Point( width, height ); >+ } >+ >+ private Point computeYMDBounds( final Font font ) { >+ // The weekday text field bounds >+ weekdayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ if( ( style & SWT.LONG ) != 0 ) { >+ weekdayTextFieldBounds.width >+ = getMaxStringLength( font, WEEKDAY_NAMES ) + H_PADDING + 2; >+ } >+ weekdayTextFieldBounds.height >+ = TextSizeDetermination.stringExtent( font, WEEKDAY_NAMES[1] ).y >+ + V_PADDING; >+ // The weekday day separator bounds >+ separator0Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator0Bounds.x >+ = weekdayTextFieldBounds.x + weekdayTextFieldBounds.width; >+ if( ( style & SWT.LONG ) != 0 ) { >+ separator0Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator0Bounds.height = weekdayTextFieldBounds.height; >+ // The year text field bounds >+ yearTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ yearTextFieldBounds.x = separator0Bounds.x + separator0Bounds.width; >+ yearTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "8888" ).x + H_PADDING; >+ yearTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The year month separator bounds >+ separator1Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator1Bounds.x = yearTextFieldBounds.x + yearTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator1Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } >+ // The month text field bounds >+ monthTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ monthTextFieldBounds.x = separator1Bounds.x + separator1Bounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ monthTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } else { >+ monthTextFieldBounds.width >+ = getMaxStringLength( font, MONTH_NAMES ) + H_PADDING + 2; >+ } >+ monthTextFieldBounds.height = weekdayTextFieldBounds.height; >+ // The month day separator bounds >+ separator2Bounds = new Rectangle( 0, 0, 0, 0 ); >+ separator2Bounds.x = monthTextFieldBounds.x + monthTextFieldBounds.width; >+ if( ( style & SWT.MEDIUM ) != 0 ) { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, DATE_SEPARATOR ).x; >+ } else { >+ separator2Bounds.width >+ = TextSizeDetermination.stringExtent( font, "," ).x; >+ } >+ separator2Bounds.height = weekdayTextFieldBounds.height; >+ // The day text field bounds >+ dayTextFieldBounds = new Rectangle( 0, 0, 0, 0 ); >+ dayTextFieldBounds.x = separator2Bounds.x + separator2Bounds.width; >+ if( ( style & SWT.SHORT ) == 0 ) { >+ dayTextFieldBounds.width >+ = TextSizeDetermination.stringExtent( font, "88" ).x + H_PADDING; >+ } >+ dayTextFieldBounds.height = weekdayTextFieldBounds.height; >+ >+ separator1Bounds.height = weekdayTextFieldBounds.height; >+ // The spinner bounds >+ spinnerBounds = new Rectangle( 0, 0, 0, 0 ); >+ spinnerBounds.x = dayTextFieldBounds.x + dayTextFieldBounds.width; >+ spinnerBounds.width = 17; >+ spinnerBounds.height = weekdayTextFieldBounds.height; >+ // Overall widget size >+ int width = spinnerBounds.x + spinnerBounds.width; >+ int height = weekdayTextFieldBounds.height; >+ return new Point( width, height ); >+ } >+ >+ private int getDaysInMonth( final int month, final int year ) { >+ GregorianCalendar cal = new GregorianCalendar( year, month, 1 ); >+ return cal.getActualMaximum( Calendar.DAY_OF_MONTH ); >+ } >+ >+ private int getMaxStringLength( final Font font, final String[] strings ) { >+ int maxLength = 0; >+ for( int i = 0; i < strings.length; i++ ) { >+ int currentStringWidth >+ = TextSizeDetermination.stringExtent( font, strings[i] ).x; >+ maxLength = Math.max( maxLength, currentStringWidth ); >+ } >+ return maxLength; >+ } >+ >+ private String getDateSeparator() { >+ DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); >+ String datePattern = ( ( SimpleDateFormat )df ).toPattern(); >+ String result = ""; >+ int index = 0; >+ while( Character.isLetter( datePattern.charAt( index ) ) ) { >+ index++; >+ } >+ result = Character.toString( datePattern.charAt( index ) ); >+ return result; >+ } >+ >+ private String getDatePattern( final String dateSeparator ) { >+ DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT ); >+ String datePattern = ( ( SimpleDateFormat )df ).toPattern(); >+ String result = ""; >+ StringTokenizer st = new StringTokenizer( datePattern, >+ dateSeparator ); >+ while ( st.hasMoreTokens() ) { >+ String token = st.nextToken(); >+ result += Character.toString( token.charAt( 0 ) ); >+ } >+ return result.toUpperCase(); >+ } >+ >+ String getNameText() { >+ return "DateTime"; >+ } >+ >+ static int checkStyle( final int value ) { >+ /* >+ * Even though it is legal to create this widget with scroll bars, they >+ * serve no useful purpose because they do not automatically scroll the >+ * widget's client area. The fix is to clear the SWT style. >+ */ >+ int style = value; >+ style &= ~( SWT.H_SCROLL | SWT.V_SCROLL ); >+ style = checkBits( style, SWT.DATE, SWT.TIME, SWT.CALENDAR, 0, 0, 0 ); >+ return checkBits( style, SWT.MEDIUM, SWT.SHORT, SWT.LONG, 0, 0, 0 ); >+ } >+ >+ protected void checkSubclass() { >+ if( !isValidSubclass() ) { >+ error( SWT.ERROR_INVALID_SUBCLASS ); >+ } >+ } >+} >Index: src/org/eclipse/swt/internal/widgets/IDateTimeAdapter.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/IDateTimeAdapter.java >diff -N src/org/eclipse/swt/internal/widgets/IDateTimeAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/IDateTimeAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2007-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets; >+ >+import org.eclipse.swt.graphics.Rectangle; >+ >+public interface IDateTimeAdapter { >+ // Date >+ int WEEKDAY_TEXTFIELD = 0; >+ int DAY_TEXTFIELD = 1; >+ int MONTH_TEXTFIELD = 2; >+ int YEAR_TEXTFIELD = 3; >+ int WEEKDAY_MONTH_SEPARATOR = 4; >+ int MONTH_DAY_SEPARATOR = 5; >+ int DAY_YEAR_SEPARATOR = 6; >+ int SPINNER = 7; >+ // Time >+ int HOURS_TEXTFIELD = 8; >+ int MINUTES_TEXTFIELD = 9; >+ int SECONDS_TEXTFIELD = 10; >+ int HOURS_MINUTES_SEPARATOR = 11; >+ int MINUTES_SECONDS_SEPARATOR = 12; >+ >+ Rectangle getBounds( int widget ); >+ >+ String[] getMonthNames(); >+ >+ String[] getWeekdayNames(); >+ >+ String getDateSeparator(); >+ >+ String getDatePattern(); >+ >+} >#P org.eclipse.rap.demo >Index: src/org/eclipse/rap/demo/controls/ControlsDemo.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ControlsDemo.java,v >retrieving revision 1.45 >diff -u -r1.45 ControlsDemo.java >--- src/org/eclipse/rap/demo/controls/ControlsDemo.java 12 Jun 2008 14:00:46 -0000 1.45 >+++ src/org/eclipse/rap/demo/controls/ControlsDemo.java 10 Jul 2008 20:11:22 -0000 >@@ -52,6 +52,7 @@ > ensureMinTabHeight( topFolder ); > > final ExampleTab[] tabs = new ExampleTab[] { >+ new DateTimeTab( topFolder ), > new ButtonTab( topFolder ), > // new RequestTab( topFolder ), > new CBannerTab( topFolder ), >@@ -59,7 +60,7 @@ > new ComboTab( topFolder ), > new CompositeTab( topFolder ), > new CoolBarTab( topFolder ), >- new DialogsTab( topFolder ), >+ new DialogsTab( topFolder ), > new GroupTab( topFolder ), > new LabelTab( topFolder ), > new ListTab( topFolder ), >Index: src/org/eclipse/rap/demo/controls/DateTimeTab.java >=================================================================== >RCS file: src/org/eclipse/rap/demo/controls/DateTimeTab.java >diff -N src/org/eclipse/rap/demo/controls/DateTimeTab.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rap/demo/controls/DateTimeTab.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.rap.demo.controls; >+ >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.layout.RowLayout; >+import org.eclipse.swt.widgets.*; >+ >+class DateTimeTab extends ExampleTab { >+ >+ private static final String PROP_CONTEXT_MENU = "contextMenu"; >+ private static final String PROP_SELECTION_LISTENER = "selectionListener"; >+ DateTime dateTime1; >+ Group group1, group2; >+ >+ DateTimeTab( final CTabFolder topFolder ) { >+ super( topFolder, "DateTime" ); >+ setDefaultStyle( SWT.BORDER | SWT.DATE | SWT.MEDIUM ); >+ } >+ >+ protected void createStyleControls( final Composite parent ) { >+ group1 = new Group( styleComp, SWT.SHADOW_IN ); >+ group1.setLayout( new RowLayout( SWT.VERTICAL ) ); >+ createStyleButton( group1, "DATE", SWT.DATE, SWT.RADIO, true ); >+ createStyleButton( group1, "TIME", SWT.TIME, SWT.RADIO, false ); >+ createStyleButton( group1, "CALENDAR", SWT.CALENDAR, SWT.RADIO, false ); >+ group2 = new Group( styleComp, SWT.SHADOW_IN ); >+ group2.setLayout( new RowLayout( SWT.VERTICAL ) ); >+ createStyleButton( group2, "SHORT", SWT.SHORT, SWT.RADIO, false ); >+ createStyleButton( group2, "MEDIUM", SWT.MEDIUM, SWT.RADIO, true ); >+ createStyleButton( group2, "LONG", SWT.LONG, SWT.RADIO, false ); >+ createStyleButton( "BORDER", SWT.BORDER, true ); >+ createVisibilityButton(); >+ createEnablementButton(); >+ createFontChooser(); >+ createFgColorButton(); >+ createBgColorButton(); >+ createPropertyCheckbox( "Add Context Menu", PROP_CONTEXT_MENU ); >+ createPropertyCheckbox( "Add Selection Listener", PROP_SELECTION_LISTENER ); >+ } >+ >+ protected void createExampleControls( final Composite parent ) { >+ parent.setLayout( new RowLayout( SWT.VERTICAL ) ); >+ int style = getStyle() | getStyle( group1 ) | getStyle( group2 ); >+ /* Create the example widgets */ >+ dateTime1 = new DateTime( parent, style ); >+ if( hasCreateProperty( PROP_CONTEXT_MENU ) ) { >+ Menu dateTimeMenu = new Menu( dateTime1 ); >+ MenuItem dateTimeMenuItem = new MenuItem( dateTimeMenu, SWT.PUSH ); >+ dateTimeMenuItem.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ String message = "You requested a context menu for the DateTime"; >+ MessageDialog.openInformation( dateTime1.getShell(), >+ "Information", >+ message ); >+ } >+ } ); >+ dateTimeMenuItem.setText( "DateTime context menu item" ); >+ dateTime1.setMenu( dateTimeMenu ); >+ } >+ if( hasCreateProperty( PROP_SELECTION_LISTENER ) ) { >+ dateTime1.addSelectionListener( new SelectionListener() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ String message = "DateTime WidgetSelected! Selected date: " >+ + dateTime1.getDay() >+ + "/" + ( dateTime1.getMonth() + 1 ) >+ + "/" + dateTime1.getYear() >+ + " " + dateTime1.getHours() >+ + ":" + dateTime1.getMinutes() >+ + ":" + dateTime1.getSeconds(); >+ log( message ); >+ } >+ >+ public void widgetDefaultSelected( final SelectionEvent event ) { >+ String message = "DateTime WidgetDefaultSelected!"; >+ log( message ); >+ } >+ } ); >+ } >+ registerControl( dateTime1 ); >+ } >+ >+ protected Button createStyleButton( final Composite parent, >+ final String name, >+ final int style, >+ final int buttonStyle, >+ final boolean checked ) >+ { >+ Button button = new Button( parent, buttonStyle ); >+ button.setText( name ); >+ button.addSelectionListener( new SelectionAdapter() { >+ >+ public void widgetSelected( final SelectionEvent event ) { >+ createNew(); >+ } >+ } ); >+ button.setData( "style", new Integer( style ) ); >+ button.setSelection( checked ); >+ return button; >+ } >+ >+ protected int getStyle( final Composite comp ) { >+ int result = SWT.NONE; >+ if( comp != null ) { >+ Control[] ctrls = comp.getChildren(); >+ if( ctrls.length != 0 ) { >+ for( int i = 0; i < ctrls.length; i++ ) { >+ if( ctrls[ i ] instanceof Button ) { >+ Button button = ( Button )ctrls[ i ]; >+ if( button.getSelection() ) { >+ Object data = button.getData( "style" ); >+ if( data != null && data instanceof Integer ) { >+ int style = ( ( Integer )data ).intValue(); >+ result |= style; >+ } >+ } >+ } >+ } >+ } >+ } >+ return result; >+ } >+} >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java,v >retrieving revision 1.2 >diff -u -r1.2 QooxdooResourcesUtil.java >--- src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 12 Jun 2008 13:14:28 -0000 1.2 >+++ src/org/eclipse/swt/internal/widgets/displaykit/QooxdooResourcesUtil.java 10 Jul 2008 20:11:25 -0000 >@@ -51,8 +51,8 @@ > = "org/eclipse/swt/ButtonUtil.js"; > private static final String COMBO_UTIL_JS > = "org/eclipse/swt/ComboUtil.js"; >- private static final String TOOL_ITEM_JS = >- "org/eclipse/swt/ToolItemUtil.js"; >+ private static final String TOOL_ITEM_JS >+ = "org/eclipse/swt/ToolItemUtil.js"; > private static final String MENU_UTIL_JS > = "org/eclipse/swt/MenuUtil.js"; > private static final String LINK_UTIL_JS >@@ -90,7 +90,7 @@ > private static final String COMBO_JS > = "org/eclipse/swt/widgets/Combo.js"; > private static final String GROUP_JS >- = "org/eclipse/swt/widgets/Group.js"; >+ = "org/eclipse/swt/widgets/Group.js"; > private static final String TEXT_UTIL_JS > = "org/eclipse/swt/TextUtil.js"; > private static final String SPINNER_JS >@@ -116,7 +116,15 @@ > private static final String QX_CONSTANT_LAYOUT_JS > = "qx/constant/Layout.js"; > private static final String QX_CONSTANT_STYLE_JS >- = "qx/constant/Style.js"; >+ = "qx/constant/Style.js"; >+ private static final String DATE_TIME_DATE_JS >+ = "org/eclipse/swt/widgets/DateTimeDate.js"; >+ private static final String DATE_TIME_TIME_JS >+ = "org/eclipse/swt/widgets/DateTimeTime.js"; >+ private static final String DATE_TIME_CALENDAR_JS >+ = "org/eclipse/swt/widgets/DateTimeCalendar.js"; >+ private static final String QX_DATE_CHOOSER_JS >+ = "qx/ui/component/DateChooser.js"; > > private QooxdooResourcesUtil() { > // prevent intance creation >@@ -183,7 +191,11 @@ > register( BROWSER_JS ); > register( PROGRESS_BAR_JS ); > register( FONT_SIZE_CALCULATION_JS ); >- register( CLABEL_UTIL_JS ); >+ register( CLABEL_UTIL_JS ); >+ register( DATE_TIME_DATE_JS ); >+ register( DATE_TIME_TIME_JS ); >+ register( DATE_TIME_CALENDAR_JS ); >+ register( QX_DATE_CHOOSER_JS ); > > // register contributions > registerContributions(); >Index: js/org/eclipse/swt/theme/AppearancesBase.js >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/theme/AppearancesBase.js,v >retrieving revision 1.10 >diff -u -r1.10 AppearancesBase.js >--- js/org/eclipse/swt/theme/AppearancesBase.js 8 Jul 2008 19:17:32 -0000 1.10 >+++ js/org/eclipse/swt/theme/AppearancesBase.js 10 Jul 2008 20:11:25 -0000 >@@ -13,7 +13,7 @@ > qx.Theme.define( "org.eclipse.swt.theme.AppearancesBase", > { > title : "Appearances Base Theme", >- >+ > appearances : { > > "empty" : { >@@ -1746,7 +1746,107 @@ > opacity : 0.2 > }; > } >- } >+ }, >+ >+ // ------------------------------------------------------------------------ >+ // DateTime >+ >+ "datetime-date" : { >+ style : function( states ) { >+ return { >+ border : states.rwt_BORDER ? "control.BORDER.border" : "control.border" >+ } >+ } >+ }, >+ >+ "datetime-calendar" : { >+ style : function( states ) { >+ return { >+ border : states.rwt_BORDER ? "control.BORDER.border" : "control.border" >+ } >+ } >+ }, >+ >+ // ------------------------------------------------------------------------ >+ // DateChooser >+ >+ "datechooser-navBar" : { >+ style : function(states) { >+ return { >+ backgroundColor : "#0A246A", >+ padding : [ 4, 4, 4, 4 ] >+ }; >+ } >+ }, >+ >+ "datechooser-toolbar-button" : { >+ style : function(states) { >+ var result = >+ { >+ spacing : 4, >+ width : "auto", >+ verticalChildrenAlign : "middle" >+ }; >+ >+ if (states.pressed || states.checked || states.abandoned) { >+ result.padding = [ 2, 0, 0, 2 ]; >+ } else { >+ result.padding = 2; >+ } >+ >+ return result; >+ } >+ }, >+ >+ "datechooser-monthyear" : { >+ style : function(states) { >+ var boldFont = qx.ui.core.Font.fromString( "11 bold Tahoma, 'Lucida Sans Unicode', sans-serif" ); >+ >+ return { >+ font : boldFont, >+ textAlign : "center", >+ textColor : "white", >+ verticalAlign : "middle" >+ }; >+ } >+ }, >+ >+ "datechooser-datepane" : { >+ style : function(states) { >+ return { >+ backgroundColor : "white" >+ }; >+ } >+ }, >+ >+ "datechooser-weekday" : { >+ style : function(states) { >+ var border = qx.ui.core.Border.fromConfig({ >+ bottom : [ 1, "solid", "gray" ] >+ }); >+ >+ return { >+ border : border, >+ textAlign : "center", >+ textColor : "#0A246A", >+ backgroundColor : "white" >+ }; >+ } >+ }, >+ >+ "datechooser-day" : { >+ style : function(states) { >+ var border = new qx.ui.core.Border( 1, "solid", "red" ); >+ >+ return { >+ textAlign : "center", >+ verticalAlign : "middle", >+ border : states.today ? border : "undefined", >+ textColor : states.selected ? "white" : states.otherMonth ? "#808080" : "undefined", >+ backgroundColor : states.selected ? "#0A246A" : "undefined" >+ }; >+ } >+ } > } > > } ); >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+import java.text.MessageFormat; >+ >+import org.eclipse.rwt.lifecycle.AbstractWidgetLCA; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.*; >+ >+public class DateTimeLCA extends AbstractWidgetLCA { >+ >+ private static final AbstractDateTimeLCADelegate DATE_LCA = new DateTimeDateLCA(); >+ private static final AbstractDateTimeLCADelegate TIME_LCA = new DateTimeTimeLCA(); >+ private static final AbstractDateTimeLCADelegate CALENDAR_LCA = new DateTimeCalendarLCA(); >+ >+ public void preserveValues( final Widget widget ) { >+ getDelegate( widget ).preserveValues( ( DateTime )widget ); >+ } >+ >+ public void readData( final Widget widget ) { >+ getDelegate( widget ).readData( ( DateTime )widget ); >+ } >+ >+ public void renderInitialization( final Widget widget ) throws IOException { >+ getDelegate( widget ).renderInitialization( ( DateTime )widget ); >+ } >+ >+ public void renderChanges( final Widget widget ) throws IOException { >+ getDelegate( widget ).renderChanges( ( DateTime )widget ); >+ } >+ >+ public void renderDispose( final Widget widget ) throws IOException { >+ getDelegate( widget ).renderDispose( ( DateTime )widget ); >+ } >+ >+ public void createResetHandlerCalls( final String typePoolId ) >+ throws IOException >+ { >+ getDelegate( typePoolId ).createResetHandlerCalls( typePoolId ); >+ } >+ >+ public String getTypePoolId( final Widget widget ) { >+ // TODO [rh] disabled pooling, see bugs prefixed with [pooling] >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=204107 >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=199142 >+ // return getDelegate( widget ).getTypePoolId( ( DateTime )widget ); >+ return null; >+ } >+ >+ private static AbstractDateTimeLCADelegate getDelegate( final String tpId ) { >+ AbstractDateTimeLCADelegate result; >+ if( tpId.startsWith( DateTimeDateLCA.TYPE_POOL_ID ) ) { >+ result = DATE_LCA; >+ } else if( tpId.startsWith( DateTimeTimeLCA.TYPE_POOL_ID ) ) { >+ result = TIME_LCA; >+ } else if( tpId.startsWith( DateTimeCalendarLCA.TYPE_POOL_ID ) ) { >+ result = CALENDAR_LCA; >+ } else { >+ String txt = "The typePoolId ''{0}'' is not supported."; >+ String msg = MessageFormat.format( txt, new Object[]{ >+ tpId >+ } ); >+ throw new IllegalArgumentException( msg ); >+ } >+ return result; >+ } >+ >+ private static AbstractDateTimeLCADelegate getDelegate( final Widget widget ) >+ { >+ AbstractDateTimeLCADelegate result; >+ if( ( widget.getStyle() & SWT.DATE ) != 0 ) { >+ result = DATE_LCA; >+ } else if( ( widget.getStyle() & SWT.TIME ) != 0 ) { >+ result = TIME_LCA; >+ } else { >+ result = CALENDAR_LCA; >+ } >+ return result; >+ } >+} >Index: js/org/eclipse/swt/widgets/DateTimeDate.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/DateTimeDate.js >diff -N js/org/eclipse/swt/widgets/DateTimeDate.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/DateTimeDate.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,701 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+qx.Class.define( "org.eclipse.swt.widgets.DateTimeDate", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function( style, monthNames, weekdayNames, >+ dateSeparator, datePattern ) { >+ this.base( arguments ); >+ this.setAppearance( "datetime-date" ); >+ >+ // Get styles >+ this._short = qx.lang.String.contains( style, "short" ); >+ this._medium = qx.lang.String.contains( style, "medium" ); >+ this._long = qx.lang.String.contains( style, "long" ); >+ >+ // Has selection listener >+ this._hasSelectionListener = false; >+ >+ // Flag that indicates that the next request can be sent >+ this._readyToSendChanges = true; >+ >+ // Get names of weekdays and months >+ this._weekday = weekdayNames; >+ this._monthname = monthNames; >+ >+ // Date pattern >+ this._datePattern = datePattern; >+ >+ // Add listeners for font, background and foregraund color change >+ this.addEventListener( "changeFont", this._rwt_onChangeFont, this ); >+ this.addEventListener( "changeTextColor", this._rwt_onChangeTextColor, this ); >+ this.addEventListener( "changeBackgroundColor", this._rwt_onChangeBackgoundColor, this ); >+ >+ // Background color >+ this._backgroundColor = "white"; >+ // Foreground color >+ this._foregroundColor = "black"; >+ >+ // Focused text field >+ this._focusedTextField = null; >+ // Weekday >+ this._weekdayTextField = new qx.ui.form.TextField; >+ this._weekdayTextField.set({ >+ textAlign: "center", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ if( this._long ) { >+ this.add( this._weekdayTextField ); >+ } >+ this._weekdayTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._weekdayTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ // Separator >+ this._separator0 = new qx.ui.basic.Label(","); >+ this._separator0.set({ >+ paddingTop: 3, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._separator0.addEventListener( "contextmenu", this._onContextMenu, this ); >+ if( this._long ) { >+ this.add(this._separator0); >+ } >+ // Month >+ this._monthTextField = new qx.ui.form.TextField; >+ this._monthTextField.set({ >+ textAlign: this._medium ? "right" : "center", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ // Integer value of the month >+ this._monthInt = 1; >+ if( this._medium ) { >+ this._monthTextField.setValue( this._monthInt ); >+ } else { >+ this._monthTextField.setValue( this._monthname[ this._monthInt - 1 ] ); >+ } >+ this._monthTextField.addEventListener( "click", this._onClick, this ); >+ this._monthTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._monthTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._monthTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add( this._monthTextField ); >+ // Separator >+ this._separator1 = new qx.ui.basic.Label( dateSeparator ); >+ this._separator1.set({ >+ paddingTop: 3, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._separator1.addEventListener( "contextmenu", this._onContextMenu, this ); >+ if( this._medium ) { >+ this.add(this._separator1); >+ } >+ // Date >+ this._dayTextField = new qx.ui.form.TextField; >+ this._dayTextField.set({ >+ maxLength: 2, >+ textAlign: "right", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._dayTextField.setValue( 1 ); >+ this._dayTextField.addEventListener( "click", this._onClick, this ); >+ this._dayTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._dayTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._dayTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ if( !this._short ) { >+ this.add( this._dayTextField ); >+ } >+ // Separator >+ this._separator2 = new qx.ui.basic.Label( "," ); >+ this._separator2.set({ >+ paddingTop: 3, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ if( this._medium ) { >+ this._separator2.setText( dateSeparator ); >+ } >+ this._separator2.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add(this._separator2); >+ // Year >+ this._yearTextField = new qx.ui.form.TextField; >+ this._yearTextField.set({ >+ maxLength: 4, >+ textAlign: "right", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ // Last valid year >+ this._lastValidYear = 1970; >+ this._yearTextField.setValue( this._lastValidYear ); >+ this._yearTextField.addEventListener( "click", this._onClick, this ); >+ this._yearTextField.addEventListener( "focusout", this._onFocusOut, this ); >+ this._yearTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._yearTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._yearTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add( this._yearTextField ); >+ // Spinner >+ this._spinner = new qx.ui.form.Spinner; >+ this._spinner.set({ >+ wrap: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._spinner.setMin( 1 ); >+ this._spinner.setMax( 12 ); >+ this._spinner.setValue( this._monthInt ); >+ this._spinner.addEventListener( "change", this._onSpinnerChange, this ); >+ this._spinner.addEventListener( "mousedown", this._onSpinnerMouseDown, this ); >+ this._spinner.addEventListener( "mouseup", this._onSpinnerMouseUp, this ); >+ this._spinner.addEventListener( "keypress", this._onKeyPress, this ); >+ this._spinner.addEventListener( "keyup", this._onKeyUp, this ); >+ this.add( this._spinner ); >+ // Set the default focused text field >+ this._focusedTextField = this._monthTextField; >+ // Set the weekday >+ this._setWeekday(); >+ >+ }, >+ >+ destruct : function() { >+ this.removeEventListener( "changeFont", this._rwt_onChangeFont, this ); >+ this.removeEventListener( "changeTextColor", this._rwt_onChangeTextColor, this ); >+ this.removeEventListener( "changeBackgroundColor", this._rwt_onChangeBackgoundColor, this ); >+ this._weekdayTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._weekdayTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._monthTextField.removeEventListener( "click", this._onClick, this ); >+ this._monthTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._monthTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._monthTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._dayTextField.removeEventListener( "click", this._onClick, this ); >+ this._dayTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._dayTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._dayTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._yearTextField.removeEventListener( "click", this._onClick, this ); >+ this._yearTextField.removeEventListener( "focusout", this._onFocusOut, this ); >+ this._yearTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._yearTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._yearTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._spinner.removeEventListener( "change", this._onSpinnerChange, this ); >+ this._spinner.removeEventListener( "mousedown", this._onSpinnerMouseDown, this ); >+ this._spinner.removeEventListener( "mouseup", this._onSpinnerMouseUp, this ); >+ this._spinner.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._spinner.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._separator0.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._separator1.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._separator2.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._disposeObjects( "_weekdayTextField", >+ "_monthTextField", >+ "_dayTextField", >+ "_yearTextField", >+ "_focusedTextField", >+ "_spinner", >+ "_separator0", >+ "_separator1", >+ "_separator2" ); >+ }, >+ >+ statics : { >+ WEEKDAY_TEXTFIELD : 0, >+ DATE_TEXTFIELD : 1, >+ MONTH_TEXTFIELD : 2, >+ YEAR_TEXTFIELD : 3, >+ WEEKDAY_MONTH_SEPARATOR : 4, >+ MONTH_DATE_SEPARATOR : 5, >+ DATE_YEAR_SEPARATOR : 6, >+ SPINNER : 7, >+ >+ _isNoModifierPressed : function( evt ) { >+ return !evt.isCtrlPressed() >+ && !evt.isShiftPressed() >+ && !evt.isAltPressed() >+ && !evt.isMetaPressed(); >+ } >+ }, >+ >+ members : { >+ _rwt_onChangeFont : function( evt ) { >+ var value = evt.getData(); >+ this._weekdayTextField.setFont( value ); >+ this._dayTextField.setFont( value ); >+ this._monthTextField.setFont( value ); >+ this._yearTextField.setFont( value ); >+ }, >+ >+ _rwt_onChangeTextColor : function( evt ) { >+ var value = evt.getData(); >+ this._foregroundColor = value; >+ this._weekdayTextField.setTextColor( value ); >+ this._dayTextField.setTextColor( value ); >+ this._monthTextField.setTextColor( value ); >+ this._yearTextField.setTextColor( value ); >+ this._separator0.setTextColor( value ); >+ this._separator1.setTextColor( value ); >+ this._separator2.setTextColor( value ); >+ }, >+ >+ _rwt_onChangeBackgoundColor : function( evt ) { >+ var value = evt.getData(); >+ this._backgroundColor = value; >+ this._weekdayTextField.setBackgroundColor( value ); >+ this._dayTextField.setBackgroundColor( value ); >+ this._monthTextField.setBackgroundColor( value ); >+ this._yearTextField.setBackgroundColor( value ); >+ this._separator0.setBackgroundColor( value ); >+ this._separator1.setBackgroundColor( value ); >+ this._separator2.setBackgroundColor( value ); >+ this._spinner.setBackgroundColor( value ); >+ }, >+ >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _onClick : function( evt ) { >+ this._setFocusedTextField( evt.getTarget() ); >+ }, >+ >+ _setFocusedTextField : function( textField ) { >+ var tmpValue; >+ this._focusedTextField.setBackgroundColor( this._backgroundColor ); >+ this._focusedTextField.setTextColor( this._foregroundColor ); >+ // Set focused text field to null >+ this._focusedTextField = null; >+ if( textField === this._dayTextField ) { >+ this._spinner.setMin( 1 ); >+ this._spinner.setMax( this._getDaysInMonth() ); >+ tmpValue = this._removeLeadingZero( this._dayTextField.getValue() ); >+ this._spinner.setValue( parseInt( tmpValue ) ); >+ } else if( textField === this._monthTextField ) { >+ this._spinner.setMin( 1 ); >+ this._spinner.setMax( 12 ); >+ this._spinner.setValue( this._monthInt ); >+ } else if( textField === this._yearTextField ) { >+ this._spinner.setMin( 1752 ); >+ this._spinner.setMax( 9999 ); >+ this._spinner.setValue( this._lastValidYear ); >+ } >+ // Set focused text field >+ this._focusedTextField = textField; >+ // Set highlight on focused text field >+ this._focusedTextField.setBackgroundColor( "#0A246A" ); >+ this._focusedTextField.setTextColor( "white" ); >+ // Request focus >+ this._focusedTextField.setFocused( true ); >+ }, >+ >+ _onFocusOut : function( evt ) { >+ if( evt.getTarget() === this._yearTextField ) { >+ this._checkAndApplyYearValue(); >+ } >+ }, >+ >+ _onSpinnerChange : function( evt ) { >+ if( this._focusedTextField != null ) { >+ var oldValue = this._focusedTextField.getValue(); >+ // Set the value >+ if( this._focusedTextField === this._monthTextField ) { >+ this._monthInt = this._spinner.getValue(); >+ if( this._medium ) { >+ this._focusedTextField.setValue( this._addLeadingZero( this._monthInt ) ); >+ } else { >+ this._focusedTextField.setValue( this._monthname[ this._monthInt - 1 ] ); >+ } >+ } else if( this._focusedTextField === this._yearTextField ) { >+ this._lastValidYear = this._spinner.getValue(); >+ this._focusedTextField.setValue( this._spinner.getValue() ); >+ } else { >+ this._focusedTextField.setValue( this._addLeadingZero( this._spinner.getValue() ) ); >+ } >+ // Adjust date field >+ if( this._focusedTextField == this._monthTextField || // month >+ this._focusedTextField == this._yearTextField ) { // year >+ var dateValue = this._dayTextField.getValue(); >+ if( dateValue > this._getDaysInMonth() ) { >+ this._dayTextField.setValue( this._getDaysInMonth() ); >+ } >+ } >+ // Set the weekday field >+ this._setWeekday(); >+ >+ var newValue = this._focusedTextField.getValue(); >+ if( oldValue != newValue && this._readyToSendChanges ) { >+ this._readyToSendChanges = false; >+ // Send changes >+ qx.client.Timer.once( this._sendChanges, this, 500 ); >+ } >+ } >+ }, >+ >+ _onSpinnerMouseDown : function( evt ) { >+ // Set highlight on focused text field >+ this._focusedTextField.setBackgroundColor( "#0A246A" ); >+ this._focusedTextField.setTextColor( "white" ); >+ }, >+ >+ _onSpinnerMouseUp : function( evt ) { >+ this._focusedTextField.setFocused( true ); >+ }, >+ >+ _onKeyPress : function( evt ) { >+ var keyIdentifier = evt.getKeyIdentifier(); >+ if( org.eclipse.swt.widgets.DateTimeDate._isNoModifierPressed( evt ) ) { >+ switch( keyIdentifier ) { >+ case "Left": >+ if( this._datePattern == "MDY") { >+ this._rollLeft( this._monthTextField, >+ this._dayTextField, >+ this._yearTextField ); >+ } else if( this._datePattern == "DMY") { >+ this._rollLeft( this._dayTextField, >+ this._monthTextField, >+ this._yearTextField ); >+ } else { >+ if( this._medium ) { >+ this._rollLeft( this._yearTextField, >+ this._monthTextField, >+ this._dayTextField ); >+ } else { >+ this._rollLeft( this._monthTextField, >+ this._dayTextField, >+ this._yearTextField ); >+ } >+ } >+ break; >+ case "Right": >+ if( this._datePattern == "MDY") { >+ this._rollRight( this._monthTextField, >+ this._dayTextField, >+ this._yearTextField ); >+ } else if( this._datePattern == "DMY") { >+ this._rollRight( this._dayTextField, >+ this._monthTextField, >+ this._yearTextField ); >+ } else { >+ if( this._medium ) { >+ this._rollRight( this._yearTextField, >+ this._monthTextField, >+ this._dayTextField ); >+ } else { >+ this._rollRight( this._monthTextField, >+ this._dayTextField, >+ this._yearTextField ); >+ } >+ } >+ break; >+ case "Up": >+ if( this._focusedTextField === this._yearTextField ) { >+ this._checkAndApplyYearValue(); >+ } >+ var value = this._spinner.getValue(); >+ if( value == this._spinner.getMax() ) { >+ this._spinner.setValue( this._spinner.getMin() ); >+ } else { >+ this._spinner.setValue( value + 1 ); >+ } >+ break; >+ case "Down": >+ if( this._focusedTextField === this._yearTextField ) { >+ this._checkAndApplyYearValue(); >+ } >+ var value = this._spinner.getValue(); >+ if( value == this._spinner.getMin() ) { >+ this._spinner.setValue( this._spinner.getMax() ); >+ } else { >+ this._spinner.setValue( value - 1 ); >+ } >+ break; >+ } >+ } >+ }, >+ >+ _rollRight : function( first, second, third ) { >+ // Apply year value >+ if( this._focusedTextField === this._yearTextField ) { >+ this._checkAndApplyYearValue(); >+ } >+ // Roll right >+ if( this._focusedTextField === first ){ >+ if( second.isSeeable() ) { >+ this._setFocusedTextField( second ); >+ } else { >+ this._setFocusedTextField( third ); >+ } >+ } else if( this._focusedTextField === second ) { >+ if( third.isSeeable() ) { >+ this._setFocusedTextField( third ); >+ } else { >+ this._setFocusedTextField( first ); >+ } >+ } else if( this._focusedTextField === third ) { >+ if( first.isSeeable() ) { >+ this._setFocusedTextField( first ); >+ } else { >+ this._setFocusedTextField( second ); >+ } >+ } >+ }, >+ >+ _rollLeft : function( first, second, third ) { >+ // Apply year value >+ if( this._focusedTextField === this._yearTextField ) { >+ this._checkAndApplyYearValue(); >+ } >+ // Roll left >+ if( this._focusedTextField === first ){ >+ if( third.isSeeable() ) { >+ this._setFocusedTextField( third ); >+ } else { >+ this._setFocusedTextField( second ); >+ } >+ } else if( this._focusedTextField === second ) { >+ if( first.isSeeable() ) { >+ this._setFocusedTextField( first ); >+ } else { >+ this._setFocusedTextField( third ); >+ } >+ } else if( this._focusedTextField === third ) { >+ if( second.isSeeable() ) { >+ this._setFocusedTextField( second ); >+ } else { >+ this._setFocusedTextField( first ); >+ } >+ } >+ }, >+ >+ _onKeyUp : function( evt ) { >+ var keypress = evt.getKeyIdentifier(); >+ var value = this._focusedTextField.getComputedValue(); >+ value = this._removeLeadingZero( value ); >+ if( org.eclipse.swt.widgets.DateTimeDate._isNoModifierPressed( evt ) ) { >+ switch( keypress ) { >+ case "Tab": >+ this._focusedTextField.setBackgroundColor( this._backgroundColor ); >+ this._focusedTextField.setTextColor( this._foregroundColor ); >+ break; >+ case "0": case "1": case "2": case "3": case "4": >+ case "5": case "6": case "7": case "8": case "9": >+ this._focusedTextField.setFocused( true ); >+ var maxChars = this._focusedTextField.getMaxLength(); >+ if( this._focusedTextField === this._monthTextField ) { >+ value = "" + this._monthInt; >+ maxChars = 2; >+ } >+ var newValue = keypress; >+ if( value.length < maxChars ) { >+ newValue = value + keypress; >+ } >+ var intValue = parseInt( newValue ); >+ if( this._focusedTextField === this._dayTextField || >+ this._focusedTextField === this._monthTextField ) { >+ if( intValue >= this._spinner.getMin() && >+ intValue <= this._spinner.getMax() ) { >+ this._spinner.setValue( intValue ); >+ } else { >+ // Do it again without adding the old value >+ newValue = keypress; >+ intValue = parseInt( newValue ); >+ if( intValue >= this._spinner.getMin() && >+ intValue <= this._spinner.getMax() ) { >+ this._spinner.setValue( intValue ); >+ } >+ } >+ } else if( this._focusedTextField == this._yearTextField ) { >+ this._focusedTextField.setValue( newValue ); >+ } >+ break; >+ case "Home": >+ var newValue = this._spinner.getMin(); >+ this._spinner.setValue( newValue ); >+ break; >+ case "End": >+ var newValue = this._spinner.getMax(); >+ this._spinner.setValue( newValue ); >+ break; >+ } >+ } >+ }, >+ >+ _getDaysInMonth : function() { >+ var result = 31; >+ var tmpMonth = this._monthInt - 1; >+ var tmpYear = parseInt( this._yearTextField.getValue() ); >+ var tmpDate = new Date(); >+ tmpDate.setYear( tmpYear ); >+ tmpDate.setMonth( tmpMonth ); >+ // Test 31 >+ tmpDate.setDate( 31 ); >+ if( tmpDate.getMonth() != tmpMonth ) { >+ result = 30; >+ tmpDate.setMonth( tmpMonth ); >+ // Test 30 >+ tmpDate.setDate( 30 ); >+ if( tmpDate.getMonth() != tmpMonth ) { >+ result = 29; >+ tmpDate.setMonth( tmpMonth ); >+ // Test 29 >+ tmpDate.setDate( 29 ); >+ if( tmpDate.getMonth() != tmpMonth ) { >+ result = 28; >+ } >+ } >+ } >+ return result; >+ }, >+ >+ _setWeekday : function() { >+ var tmpDate = new Date(); >+ tmpDate.setDate( parseInt( this._dayTextField.getValue() ) ); >+ tmpDate.setMonth( this._monthInt - 1 ); >+ tmpDate.setFullYear( parseInt( this._yearTextField.getValue() ) ); >+ this._weekdayTextField.setValue( this._weekday[ tmpDate.getDay() + 1 ] ); >+ }, >+ >+ _checkAndApplyYearValue : function() { >+ var oldValue = this._lastValidYear; >+ var value = parseInt( this._yearTextField.getValue() ); >+ if( value >= 0 && value <= 29 ) { >+ this._lastValidYear = 2000 + value; >+ } else if( value >= 30 && value <= 99 ) { >+ this._lastValidYear = 1900 + value; >+ } else if( value >= 1752 ) { >+ this._lastValidYear = value; >+ } >+ if( oldValue != this._lastValidYear ) { >+ this._spinner.setValue( this._lastValidYear ); >+ } >+ }, >+ >+ _addLeadingZero : function( value ) { >+ return value < 10 ? "0" + value : value; >+ }, >+ >+ _removeLeadingZero : function( value ) { >+ var result = value; >+ if( value.length == 2 ) { >+ var firstChar = value.substring( 0, 1 ); >+ if( firstChar == "0" ) result = value.substring( 1 ); >+ } >+ return result; >+ }, >+ >+ _sendChanges : function() { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var req = org.eclipse.swt.Request.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ req.addParameter( id + ".day", this._removeLeadingZero( this._dayTextField.getValue() ) ); >+ req.addParameter( id + ".month", this._monthInt - 1 ); >+ req.addParameter( id + ".year", this._lastValidYear ); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.send(); >+ } >+ this._readyToSendChanges = true; >+ } >+ }, >+ >+ setMonth : function( value ) { >+ this._monthInt = value + 1; >+ if( this._medium ) { >+ this._monthTextField.setValue( this._addLeadingZero( this._monthInt ) ); >+ } else { >+ this._monthTextField.setValue( this._monthname[ this._monthInt - 1 ] ); >+ } >+ if( this._focusedTextField === this._monthTextField ) { >+ this._spinner.setValue( this._monthInt ); >+ } >+ // Set the weekday >+ this._setWeekday(); >+ }, >+ >+ setDay : function( value ) { >+ this._dayTextField.setValue( this._addLeadingZero( value ) ); >+ if( this._focusedTextField === this._dayTextField ) { >+ this._spinner.setValue( value ); >+ } >+ // Set the weekday >+ this._setWeekday(); >+ }, >+ >+ setYear : function( value ) { >+ this._lastValidYear = value; >+ this._yearTextField.setValue( value ); >+ if( this._focusedTextField === this._yearTextField ) { >+ this._spinner.setValue( value ); >+ } >+ // Set the weekday >+ this._setWeekday(); >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ }, >+ >+ setBounds : function( ind, x, y, width, height ) { >+ var widget; >+ switch( ind ) { >+ case org.eclipse.swt.widgets.DateTimeDate.WEEKDAY_TEXTFIELD: >+ widget = this._weekdayTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.DATE_TEXTFIELD: >+ widget = this._dayTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.MONTH_TEXTFIELD: >+ widget = this._monthTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.YEAR_TEXTFIELD: >+ widget = this._yearTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.WEEKDAY_MONTH_SEPARATOR: >+ widget = this._separator0; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.MONTH_DATE_SEPARATOR: >+ widget = this._separator1; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.DATE_YEAR_SEPARATOR: >+ widget = this._separator2; >+ break; >+ case org.eclipse.swt.widgets.DateTimeDate.SPINNER: >+ widget = this._spinner; >+ break; >+ } >+ widget.set({ >+ left: x, >+ top: y, >+ width: width, >+ height: height >+ }); >+ } >+ } >+} ); >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCAUtil.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCAUtil.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCAUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCAUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+ >+import org.eclipse.rwt.lifecycle.*; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.DateTime; >+ >+final class DateTimeLCAUtil { >+ >+ private DateTimeLCAUtil() { >+ // prevent instantiation >+ } >+ >+ static IDateTimeAdapter getDateTimeAdapter( final DateTime dateTime ) { >+ return ( IDateTimeAdapter )dateTime.getAdapter( IDateTimeAdapter.class ); >+ } >+ >+ static void preserveSubWidgetBounds( final DateTime dateTime, >+ final int subWidgetID ) { >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ IDateTimeAdapter dateTimeAdapter = getDateTimeAdapter( dateTime ); >+ Rectangle subWidgetBounds = dateTimeAdapter.getBounds( subWidgetID ); >+ adapter.preserve( subWidgetID + "_BOUNDS", subWidgetBounds ); >+ } >+ >+ static void writeSubWidgetBounds( final DateTime dateTime, >+ final int subWidgetID ) >+ throws IOException >+ { >+ IDateTimeAdapter dateTimeAdapter = getDateTimeAdapter( dateTime ); >+ Rectangle newValue = dateTimeAdapter.getBounds( subWidgetID ); >+ if( WidgetLCAUtil.hasChanged( dateTime, >+ subWidgetID + "_BOUNDS", newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.call( "setBounds", new Object[]{ >+ new Integer( subWidgetID ), >+ new Integer( newValue.x ), >+ new Integer( newValue.y ), >+ new Integer( newValue.width ), >+ new Integer( newValue.height ) >+ }); >+ } >+ } >+ >+ static void writeListener( final DateTime dateTime ) >+ throws IOException >+ { >+ boolean hasListener = SelectionEvent.hasListener( dateTime ); >+ Boolean newValue = Boolean.valueOf( hasListener ); >+ String prop = Props.SELECTION_LISTENERS; >+ if( WidgetLCAUtil.hasChanged( dateTime, prop, newValue, Boolean.FALSE ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( "hasSelectionListener", newValue ); >+ } >+ } >+} >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeTimeLCA.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeTimeLCA.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeTimeLCA.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeTimeLCA.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,171 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+ >+import org.eclipse.rwt.lifecycle.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.DateTime; >+ >+public class DateTimeTimeLCA extends AbstractDateTimeLCADelegate { >+ >+ static final String TYPE_POOL_ID = DateTimeTimeLCA.class.getName(); >+ // Property names for preserveValues >+ static final String PROP_HOURS = "hours"; >+ static final String PROP_MINUTES = "minutes"; >+ static final String PROP_SECONDS = "seconds"; >+ >+ // Property names for preserveValues >+ void preserveValues( final DateTime dateTime ) { >+ ControlLCAUtil.preserveValues( dateTime ); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ boolean hasListeners = SelectionEvent.hasListener( dateTime ); >+ adapter.preserve( Props.SELECTION_LISTENERS, >+ Boolean.valueOf( hasListeners ) ); >+ adapter.preserve( PROP_HOURS, >+ new Integer( dateTime.getHours() ) ); >+ adapter.preserve( PROP_MINUTES, >+ new Integer( dateTime.getMinutes() ) ); >+ adapter.preserve( PROP_SECONDS, >+ new Integer( dateTime.getSeconds() ) ); >+ preserveSubWidgetsBounds( dateTime ); >+ } >+ >+ void readData( final DateTime dateTime ) { >+ String value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_HOURS ); >+ if( value != null ) { >+ dateTime.setHours( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_MINUTES ); >+ if( value != null ) { >+ dateTime.setMinutes( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_SECONDS ); >+ if( value != null ) { >+ dateTime.setSeconds( Integer.parseInt( value ) ); >+ } >+ ControlLCAUtil.processSelection( dateTime, null, true ); >+ } >+ >+ void renderInitialization( final DateTime dateTime ) >+ throws IOException >+ { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ String style = ""; >+ if( ( dateTime.getStyle() & SWT.SHORT ) != 0 ) { >+ style = "short"; >+ } else if( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ) { >+ style = "medium"; >+ } else if( ( dateTime.getStyle() & SWT.LONG ) != 0 ) { >+ style = "long"; >+ } >+ Object[] args = new Object[]{ >+ style >+ }; >+ writer.newWidget( "org.eclipse.swt.widgets.DateTimeTime", args ); >+ WidgetLCAUtil.writeCustomVariant( dateTime ); >+ ControlLCAUtil.writeStyleFlags( dateTime ); >+ } >+ >+ void renderChanges( final DateTime dateTime ) throws IOException { >+ ControlLCAUtil.writeChanges( dateTime ); >+ writeHours( dateTime ); >+ writeMinutes( dateTime ); >+ writeSeconds( dateTime ); >+ DateTimeLCAUtil.writeListener( dateTime ); >+ writeSubWidgetsBounds( dateTime ); >+ } >+ >+ void renderDispose( final DateTime dateTime ) throws IOException { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.dispose(); >+ } >+ >+ void createResetHandlerCalls( final String typePoolId ) >+ throws IOException >+ { >+ } >+ >+ String getTypePoolId( final DateTime dateTime ) { >+ return null; >+ } >+ // //////////////////////////////////// >+ // Helping methods to write properties >+ private void writeHours( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getHours() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_HOURS, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_HOURS, newValue ); >+ } >+ } >+ >+ private void writeMinutes( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getMinutes() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_MINUTES, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_MINUTES, newValue ); >+ } >+ } >+ >+ private void writeSeconds( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getSeconds() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_SECONDS, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_SECONDS, newValue ); >+ } >+ } >+ >+ private void writeSubWidgetsBounds( final DateTime dateTime ) >+ throws IOException >+ { >+ // The hours text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.HOURS_TEXTFIELD ); >+ // The hours minutes separator bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.HOURS_MINUTES_SEPARATOR ); >+ // The minutes text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MINUTES_TEXTFIELD ); >+ // The minutes seconds separator bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MINUTES_SECONDS_SEPARATOR ); >+ // The seconds text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SECONDS_TEXTFIELD ); >+ // The spinner bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SPINNER ); >+ } >+ >+ private void preserveSubWidgetsBounds( final DateTime dateTime ) { >+ // The hours text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.HOURS_TEXTFIELD ); >+ // The hours minutes separator bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.HOURS_MINUTES_SEPARATOR ); >+ // The minutes text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MINUTES_TEXTFIELD ); >+ // The minutes seconds separator bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MINUTES_SECONDS_SEPARATOR ); >+ // The seconds text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SECONDS_TEXTFIELD ); >+ // The spinner bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SPINNER ); >+ } >+} >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeDateLCA.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeDateLCA.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeDateLCA.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeDateLCA.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,190 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+ >+import org.eclipse.rwt.lifecycle.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.DateTime; >+ >+public class DateTimeDateLCA extends AbstractDateTimeLCADelegate { >+ >+ static final String TYPE_POOL_ID = DateTimeDateLCA.class.getName(); >+ // Property names for preserveValues >+ static final String PROP_DAY = "day"; >+ static final String PROP_MONTH = "month"; >+ static final String PROP_YEAR = "year"; >+ >+ // Property names for preserveValues >+ void preserveValues( final DateTime dateTime ) { >+ ControlLCAUtil.preserveValues( dateTime ); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ boolean hasListeners = SelectionEvent.hasListener( dateTime ); >+ adapter.preserve( Props.SELECTION_LISTENERS, >+ Boolean.valueOf( hasListeners ) ); >+ adapter.preserve( PROP_DAY, >+ new Integer( dateTime.getDay() ) ); >+ adapter.preserve( PROP_MONTH, >+ new Integer( dateTime.getMonth() ) ); >+ adapter.preserve( PROP_YEAR, >+ new Integer( dateTime.getYear() ) ); >+ preserveSubWidgetsBounds( dateTime ); >+ } >+ >+ void readData( final DateTime dateTime ) { >+ String value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_DAY ); >+ if( value != null ) { >+ dateTime.setDay( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_MONTH ); >+ if( value != null ) { >+ dateTime.setMonth( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_YEAR ); >+ if( value != null ) { >+ dateTime.setYear( Integer.parseInt( value ) ); >+ } >+ ControlLCAUtil.processSelection( dateTime, null, true ); >+ } >+ >+ void renderInitialization( final DateTime dateTime ) >+ throws IOException >+ { >+ IDateTimeAdapter dateTimeAdapter >+ = DateTimeLCAUtil.getDateTimeAdapter( dateTime ); >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ String style = ""; >+ if( ( dateTime.getStyle() & SWT.SHORT ) != 0 ) { >+ style = "short"; >+ } else if( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ) { >+ style = "medium"; >+ } else if( ( dateTime.getStyle() & SWT.LONG ) != 0 ) { >+ style = "long"; >+ } >+ Object[] args = new Object[]{ >+ style, >+ dateTimeAdapter.getMonthNames(), >+ dateTimeAdapter.getWeekdayNames(), >+ dateTimeAdapter.getDateSeparator(), >+ dateTimeAdapter.getDatePattern() >+ }; >+ writer.newWidget( "org.eclipse.swt.widgets.DateTimeDate", args ); >+ WidgetLCAUtil.writeCustomVariant( dateTime ); >+ ControlLCAUtil.writeStyleFlags( dateTime ); >+ } >+ >+ void renderChanges( final DateTime dateTime ) throws IOException { >+ ControlLCAUtil.writeChanges( dateTime ); >+ writeDay( dateTime ); >+ writeMonth( dateTime ); >+ writeYear( dateTime ); >+ DateTimeLCAUtil.writeListener( dateTime ); >+ writeSubWidgetsBounds( dateTime ); >+ } >+ >+ void renderDispose( final DateTime dateTime ) throws IOException { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.dispose(); >+ } >+ >+ void createResetHandlerCalls( final String typePoolId ) >+ throws IOException >+ { >+ } >+ >+ String getTypePoolId( final DateTime dateTime ) { >+ return null; >+ } >+ >+ // //////////////////////////////////// >+ // Helping methods to write properties >+ private void writeDay( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getDay() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_DAY, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_DAY, newValue ); >+ } >+ } >+ >+ private void writeMonth( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getMonth() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_MONTH, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_MONTH, newValue ); >+ } >+ } >+ >+ private void writeYear( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getYear() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_YEAR, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_YEAR, newValue ); >+ } >+ } >+ >+ private void writeSubWidgetsBounds( final DateTime dateTime ) >+ throws IOException >+ { >+ // The weekday text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.WEEKDAY_TEXTFIELD ); >+ // The weekday month separator bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.WEEKDAY_MONTH_SEPARATOR ); >+ // The month text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MONTH_TEXTFIELD ); >+ // The month date separator bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MONTH_DAY_SEPARATOR ); >+ // The date text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.DAY_TEXTFIELD ); >+ // The date year separator bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.DAY_YEAR_SEPARATOR ); >+ // The year text field bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.YEAR_TEXTFIELD ); >+ // The spinner bounds >+ DateTimeLCAUtil.writeSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SPINNER ); >+ } >+ >+ private void preserveSubWidgetsBounds( final DateTime dateTime ) { >+ // The weekday text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.WEEKDAY_TEXTFIELD ); >+ // The weekday month separator bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.WEEKDAY_MONTH_SEPARATOR ); >+ // The month text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MONTH_TEXTFIELD ); >+ // The month date separator bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.MONTH_DAY_SEPARATOR ); >+ // The date text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.DAY_TEXTFIELD ); >+ // The date year separator bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.DAY_YEAR_SEPARATOR ); >+ // The year text field bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.YEAR_TEXTFIELD ); >+ // The spinner bounds >+ DateTimeLCAUtil.preserveSubWidgetBounds( dateTime, >+ IDateTimeAdapter.SPINNER ); >+ } >+} >Index: src/org/eclipse/swt/internal/widgets/datetimekit/AbstractDateTimeLCADelegate.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/AbstractDateTimeLCADelegate.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/AbstractDateTimeLCADelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/AbstractDateTimeLCADelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+ >+import org.eclipse.swt.widgets.DateTime; >+ >+abstract class AbstractDateTimeLCADelegate { >+ >+ abstract void preserveValues( DateTime dateTime ); >+ >+ abstract void readData( DateTime dateTime ); >+ >+ abstract void renderInitialization( DateTime dateTime ) throws IOException; >+ >+ abstract void renderChanges( DateTime dateTime ) throws IOException; >+ >+ abstract void renderDispose( DateTime dateTime ) throws IOException; >+ >+ abstract void createResetHandlerCalls( String typePoolId ) throws IOException; >+ >+ abstract String getTypePoolId( DateTime dateTime ); >+} >Index: js/qx/ui/component/DateChooser.js >=================================================================== >RCS file: js/qx/ui/component/DateChooser.js >diff -N js/qx/ui/component/DateChooser.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/qx/ui/component/DateChooser.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,776 @@ >+/* ************************************************************************ >+ >+ qooxdoo - the new era of web development >+ >+ http://qooxdoo.org >+ >+ Copyright: >+ 2006 STZ-IDA, Germany, http://www.stz-ida.de >+ >+ License: >+ LGPL: http://www.gnu.org/licenses/lgpl.html >+ EPL: http://www.eclipse.org/org/documents/epl-v10.php >+ See the LICENSE file in the project's top-level directory for details. >+ >+ Authors: >+ * Til Schneider (til132) >+ >+************************************************************************ */ >+ >+/* ************************************************************************ >+ >+#embed(qx.widgettheme/datechooser/*) >+ >+************************************************************************ */ >+ >+/** >+ * Shows a calendar and allows choosing a date. >+ * >+ * @appearance datechooser-toolbar-button {qx.ui.toolbar.Button} >+ * @appearance datechooser-navBar {qx.ui.layout.BoxLayout} >+ * @appearance datechooser-monthyear {qx.ui.basic.Label} >+ * @appearance datechooser-weekday {qx.ui.basic.Label} >+ * @appearance datechooser-datepane {qx.ui.layout.CanvasLayout} >+ * @appearance datechooser-weekday {qx.ui.basic.Label} >+ * >+ * @appearance datechooser-day {qx.ui.basic.Label} >+ * @state weekend {datechooser-day} >+ * @state otherMonth {datechooser-day} >+ * @state today {datechooser-day} >+ * @state selected {datechooser-day} >+ */ >+qx.Class.define("qx.ui.component.DateChooser", { >+ extend : qx.ui.layout.BoxLayout, >+ >+ /* >+ ***************************************************************************** >+ CONSTRUCTOR >+ ***************************************************************************** >+ */ >+ >+ /** >+ * @param date {Date ? null} The initial date to show. If <code>null</code> >+ * the current day (today) is shown. >+ */ >+ construct : function(date) { >+ this.base(arguments); >+ >+ this.setOrientation("vertical"); >+ >+ // Create the navigation bar >+ var navBar = new qx.ui.layout.BoxLayout; >+ navBar.setAppearance("datechooser-navBar"); >+ >+ navBar.set({ >+ height : "auto", >+ spacing : 1 >+ }); >+ >+ var lastMonthBt = new qx.ui.toolbar.Button(null, "widget/datechooser/lastMonth.gif"); >+ var monthYearLabel = new qx.ui.basic.Label; >+ var nextMonthBt = new qx.ui.toolbar.Button(null, "widget/datechooser/nextMonth.gif"); >+ >+ lastMonthBt.set({ >+ show : 'icon', >+ toolTip : new qx.ui.popup.ToolTip(this.tr("Last month")) >+ }); >+ >+ nextMonthBt.set({ >+ show : 'icon', >+ toolTip : new qx.ui.popup.ToolTip(this.tr("Next month")) >+ }); >+ >+ lastMonthBt.setAppearance("datechooser-toolbar-button"); >+ nextMonthBt.setAppearance("datechooser-toolbar-button"); >+ >+ lastMonthBt.addEventListener("click", this._onNavButtonClicked, this); >+ nextMonthBt.addEventListener("click", this._onNavButtonClicked, this); >+ >+ this._lastMonthBt = lastMonthBt; >+ this._nextMonthBt = nextMonthBt; >+ >+ monthYearLabel.setAppearance("datechooser-monthyear"); >+ monthYearLabel.set({ width : "1*" }); >+ >+ navBar.add(lastMonthBt, monthYearLabel, nextMonthBt); >+ this._monthYearLabel = monthYearLabel; >+ navBar.setHtmlProperty("id", "navBar"); >+ >+ // Create the date pane >+ var datePane = new qx.ui.layout.CanvasLayout; >+ datePane.setAppearance("datechooser-datepane"); >+ >+ datePane.set({ >+ width : qx.ui.component.DateChooser.CELL_WIDTH * 7, >+ height : qx.ui.component.DateChooser.CELL_HEIGHT * 7 >+ }); >+ >+ this._weekdayLabelArr = []; >+ >+ for (var i=0; i<7; i++) { >+ var label = new qx.ui.basic.Label; >+ label.setAppearance("datechooser-weekday"); >+ label.setSelectable(false); >+ label.setCursor("default"); >+ >+ label.set({ >+ width : qx.ui.component.DateChooser.CELL_WIDTH, >+ height : qx.ui.component.DateChooser.CELL_HEIGHT, >+ left : i * qx.ui.component.DateChooser.CELL_WIDTH >+ }); >+ >+ datePane.add(label); >+ this._weekdayLabelArr.push(label); >+ } >+ >+ // Add the days >+ this._dayLabelArr = []; >+ >+ for (var y=0; y<6; y++) { >+ // Add the day labels >+ for (var x=0; x<7; x++) { >+ var label = new qx.ui.basic.Label; >+ label.setAppearance("datechooser-day"); >+ label.setSelectable(false); >+ label.setCursor("default"); >+ >+ label.set({ >+ width : qx.ui.component.DateChooser.CELL_WIDTH, >+ height : qx.ui.component.DateChooser.CELL_HEIGHT, >+ left : x * qx.ui.component.DateChooser.CELL_WIDTH, >+ top : (y + 1) * qx.ui.component.DateChooser.CELL_HEIGHT >+ }); >+ >+ label.addEventListener("mousedown", this._onDayClicked, this); >+ label.addEventListener("dblclick", this._onDayDblClicked, this); >+ datePane.add(label); >+ this._dayLabelArr.push(label); >+ } >+ } >+ >+ // Make focusable >+ this.setTabIndex(1); >+ this.addEventListener("keypress", this._onkeypress); >+ >+ // Show the right date >+ var shownDate = (date != null) ? date : new Date(); >+ this.showMonth(shownDate.getMonth(), shownDate.getFullYear()); >+ >+ // listen for locale changes >+ qx.locale.Manager.getInstance().addEventListener("changeLocale", this._updateDatePane, this); >+ >+ // Add the main widgets >+ this.add(navBar); >+ this.add(datePane); >+ >+ // Initialize dimensions >+ this.initWidth(); >+ this.initHeight(); >+ }, >+ >+ /* >+ ***************************************************************************** >+ EVENTS >+ ***************************************************************************** >+ */ >+ >+ events: { >+ /** Fired when a date was selected. The event holds the new selected date in its data property.*/ >+ "select" : "qx.event.type.DataEvent" >+ }, >+ >+ /* >+ ***************************************************************************** >+ STATICS >+ ***************************************************************************** >+ */ >+ >+ statics : { >+ CELL_WIDTH : 24, >+ CELL_HEIGHT : 16, >+ MONTH_NAMES : [], >+ WEEKDAY_NAMES : [] >+ }, >+ >+ /* >+ ***************************************************************************** >+ PROPERTIES >+ ***************************************************************************** >+ */ >+ >+ properties : { >+ width : { >+ refine : true, >+ init : "auto" >+ }, >+ >+ height : { >+ refine : true, >+ init : "auto" >+ }, >+ >+ /** The currently shown month. 0 = january, 1 = february, and so on. */ >+ shownMonth : { >+ check : "Integer", >+ init : null, >+ nullable : true, >+ event : "changeShownMonth" >+ }, >+ >+ /** The currently shown year. */ >+ shownYear : { >+ check : "Integer", >+ init : null, >+ nullable : true, >+ event : "changeShownYear" >+ }, >+ >+ /** {Date} The currently selected date. */ >+ date : { >+ check : "Date", >+ init : null, >+ nullable : true, >+ apply : "_applyDate", >+ event : "changeDate", >+ transform : "_checkDate" >+ } >+ }, >+ >+ /* >+ ***************************************************************************** >+ MEMBERS >+ ***************************************************************************** >+ */ >+ >+ members : { >+ // property checker >+ /** >+ * TODOC >+ * >+ * @type member >+ * @param value {var} Current value >+ * @return {var} TODOC >+ */ >+ _checkDate : function(value) { >+ // Use a clone of the date internally since date instances may be changed >+ return (value == null) ? null : new Date(value.getTime()); >+ }, >+ >+ // property modifier >+ /** >+ * TODOC >+ * >+ * @type member >+ * @param value {var} Current value >+ * @param old {var} Previous value >+ */ >+ _applyDate : function(value, old) { >+ if ((value != null) && (this.getShownMonth() != value.getMonth() || this.getShownYear() != value.getFullYear())) { >+ // The new date is in another month -> Show that month >+ this.showMonth(value.getMonth(), value.getFullYear()); >+ } else { >+ // The new date is in the current month -> Just change the states >+ var newDay = (value == null) ? -1 : value.getDate(); >+ >+ for (var i=0; i<6*7; i++) { >+ var dayLabel = this._dayLabelArr[i]; >+ >+ if (dayLabel.hasState("otherMonth")) { >+ if (dayLabel.hasState("selected")) { >+ dayLabel.removeState("selected"); >+ } >+ } else { >+ var day = parseInt(dayLabel.getText()); >+ >+ if (day == newDay) { >+ dayLabel.addState("selected"); >+ } else if (dayLabel.hasState("selected")) { >+ dayLabel.removeState("selected"); >+ } >+ } >+ } >+ } >+ }, >+ >+ /** >+ * Event handler. Called when a navigation button has been clicked. >+ * >+ * @type member >+ * @param evt {Map} the event. >+ * @return {void} >+ */ >+ _onNavButtonClicked : function(evt) { >+ var year = this.getShownYear(); >+ var month = this.getShownMonth(); >+ >+ switch(evt.getCurrentTarget()) { >+ case this._lastMonthBt: >+ month--; >+ >+ if (month < 0) { >+ month = 11; >+ year--; >+ } >+ >+ break; >+ >+ case this._nextMonthBt: >+ month++; >+ >+ if (month >= 12) { >+ month = 0; >+ year++; >+ } >+ >+ break; >+ } >+ >+ this.showMonth(month, year); >+ }, >+ >+ /** >+ * Event handler. Called when a day has been clicked. >+ * >+ * @type member >+ * @param evt {Map} the event. >+ * @return {void} >+ */ >+ _onDayClicked : function(evt) { >+ if( evt.isLeftButtonPressed() ) { >+ var time = evt.getCurrentTarget().dateTime; >+ this.setDate(new Date(time)); >+ } >+ }, >+ >+ /** >+ * TODOC >+ * >+ * @type member >+ * @return {void} >+ */ >+ _onDayDblClicked : function() { >+ this.createDispatchDataEvent("select", this.getDate()); >+ }, >+ >+ /** >+ * Event handler. Called when a key was pressed. >+ * >+ * @type member >+ * @param evt {Map} the event. >+ * @return {boolean | void} TODOC >+ */ >+ _onkeypress : function(evt) { >+ var dayIncrement = null; >+ var monthIncrement = null; >+ var yearIncrement = null; >+ >+ if (evt.getModifiers() == 0) { >+ switch(evt.getKeyIdentifier()) { >+ case "Left": >+ dayIncrement = -1; >+ break; >+ >+ case "Right": >+ dayIncrement = 1; >+ break; >+ >+ case "Up": >+ dayIncrement = -7; >+ break; >+ >+ case "Down": >+ dayIncrement = 7; >+ break; >+ >+ case "PageUp": >+ monthIncrement = -1; >+ break; >+ >+ case "PageDown": >+ monthIncrement = 1; >+ break; >+ >+ case "Escape": >+ if (this.getDate() != null) { >+ this.setDate(null); >+ return true; >+ } >+ >+ break; >+ >+ case "Enter": >+ case "Space": >+ if (this.getDate() != null) { >+ this.createDispatchDataEvent("select", this.getDate()); >+ } >+ >+ return; >+ } >+ } >+ else if (evt.isShiftPressed()) { >+ switch(evt.getKeyIdentifier()) { >+ case "PageUp": >+ yearIncrement = -1; >+ break; >+ >+ case "PageDown": >+ yearIncrement = 1; >+ break; >+ } >+ } >+ >+ if (dayIncrement != null || monthIncrement != null || yearIncrement != null) { >+ var date = this.getDate(); >+ >+ if (date != null) { >+ date = new Date(date.getTime()); // TODO: Do cloning in getter >+ } >+ >+ if (date == null) { >+ date = new Date(); >+ } else { >+ if (dayIncrement != null) date.setDate(date.getDate() + dayIncrement); >+ if (monthIncrement != null) date.setMonth(date.getMonth() + monthIncrement); >+ if (yearIncrement != null) date.setFullYear(date.getFullYear() + yearIncrement); >+ } >+ >+ this.setDate(date); >+ } >+ }, >+ >+ // ***** Methods ***** >+ /** >+ * Shows a certain month. >+ * >+ * @type member >+ * @param month {Integer ? null} the month to show (0 = january). If not set the month >+ * will remain the same. >+ * @param year {Integer ? null} the year to show. If not set the year will remain the >+ * same. >+ * @return {void} >+ */ >+ showMonth : function(month, year) { >+ if ((month != null && month != this.getShownMonth()) || (year != null && year != this.getShownYear())) { >+ if (month != null) { >+ this.setShownMonth(month); >+ } >+ >+ if (year != null) { >+ this.setShownYear(year); >+ } >+ >+ this._updateDatePane(); >+ } >+ }, >+ >+ /** >+ * Updates the date pane. >+ * >+ * @type member >+ * @return {void} >+ */ >+ _updateDatePane : function() { >+ var today = new Date(); >+ var todayYear = today.getFullYear(); >+ var todayMonth = today.getMonth(); >+ var todayDayOfMonth = today.getDate(); >+ >+ var selDate = this.getDate(); >+ var selYear = (selDate == null) ? -1 : selDate.getFullYear(); >+ var selMonth = (selDate == null) ? -1 : selDate.getMonth(); >+ var selDayOfMonth = (selDate == null) ? -1 : selDate.getDate(); >+ >+ var shownMonth = this.getShownMonth(); >+ var shownYear = this.getShownYear(); >+ >+ var startOfWeek = this.__getWeekStart(); >+ >+ // Create a help date that points to the first of the current month >+ var helpDate = new Date(this.getShownYear(), this.getShownMonth(), 1); >+ >+ var year = this.getShownYear(); >+ var month = qx.ui.component.DateChooser.MONTH_NAMES[ this.getShownMonth() ]; >+ this._monthYearLabel.setText( month + ", " + year ); >+ >+ // Show the day names >+ var firstDayOfWeek = helpDate.getDay(); >+ var firstSundayInMonth = (1 + 7 - firstDayOfWeek) % 7; >+ >+ for (var i=0; i<7; i++) { >+ var day = (i + startOfWeek) % 7; >+ >+ var dayLabel = this._weekdayLabelArr[i]; >+ >+ helpDate.setDate(firstSundayInMonth + day); >+ >+ var weekdayName = qx.ui.component.DateChooser.WEEKDAY_NAMES[ helpDate.getDay() + 1 ]; >+ weekdayName = weekdayName.substring( 0, 3 ); >+ >+ dayLabel.setText( weekdayName ); >+ >+ if (this.__isWeekend(day)) { >+ dayLabel.addState("weekend"); >+ } else { >+ dayLabel.removeState("weekend"); >+ } >+ } >+ >+ // Show the days >+ helpDate = new Date(shownYear, shownMonth, 1); >+ var nrDaysOfLastMonth = (7 + firstDayOfWeek - startOfWeek) % 7; >+ helpDate.setDate(helpDate.getDate() - nrDaysOfLastMonth); >+ >+ for (var week=0; week<6; week++) { >+ for (var i=0; i<7; i++) { >+ var dayLabel = this._dayLabelArr[week * 7 + i]; >+ >+ var year = helpDate.getFullYear(); >+ var month = helpDate.getMonth(); >+ var dayOfMonth = helpDate.getDate(); >+ >+ var isSelectedDate = (selYear == year && selMonth == month && selDayOfMonth == dayOfMonth); >+ >+ if (isSelectedDate) { >+ dayLabel.addState("selected"); >+ } else { >+ dayLabel.removeState("selected"); >+ } >+ >+ if (month != shownMonth) { >+ dayLabel.addState("otherMonth"); >+ } else { >+ dayLabel.removeState("otherMonth"); >+ } >+ >+ var isToday = (year == todayYear && month == todayMonth && dayOfMonth == todayDayOfMonth); >+ >+ if (isToday) { >+ dayLabel.addState("today"); >+ } else { >+ dayLabel.removeState("today"); >+ } >+ >+ dayLabel.setText("" + dayOfMonth); >+ dayLabel.dateTime = helpDate.getTime(); >+ >+ // Go to the next day >+ helpDate.setDate(helpDate.getDate() + 1); >+ } >+ } >+ }, >+ >+ /** >+ * Return the day the week starts with >+ * >+ * Reference: Common Locale Data Repository (cldr) supplementalData.xml >+ * >+ * @type member >+ * @param locale {String} optional locale to be used >+ * @return {Integer} index of the first day of the week. 0=sunday, 1=monday, ... >+ */ >+ __getWeekStart : function(locale) { >+ var weekStart = { >+ // default is monday >+ "MV" : 5, // friday >+ "AE" : 6, // saturday >+ "AF" : 6, >+ "BH" : 6, >+ "DJ" : 6, >+ "DZ" : 6, >+ "EG" : 6, >+ "ER" : 6, >+ "ET" : 6, >+ "IQ" : 6, >+ "IR" : 6, >+ "JO" : 6, >+ "KE" : 6, >+ "KW" : 6, >+ "LB" : 6, >+ "LY" : 6, >+ "MA" : 6, >+ "OM" : 6, >+ "QA" : 6, >+ "SA" : 6, >+ "SD" : 6, >+ "SO" : 6, >+ "TN" : 6, >+ "YE" : 6, >+ "AS" : 0, // sunday >+ "AU" : 0, >+ "AZ" : 0, >+ "BW" : 0, >+ "CA" : 0, >+ "CN" : 0, >+ "FO" : 0, >+ "GE" : 0, >+ "GL" : 0, >+ "GU" : 0, >+ "HK" : 0, >+ "IE" : 0, >+ "IL" : 0, >+ "IS" : 0, >+ "JM" : 0, >+ "JP" : 0, >+ "KG" : 0, >+ "KR" : 0, >+ "LA" : 0, >+ "MH" : 0, >+ "MN" : 0, >+ "MO" : 0, >+ "MP" : 0, >+ "MT" : 0, >+ "NZ" : 0, >+ "PH" : 0, >+ "PK" : 0, >+ "SG" : 0, >+ "TH" : 0, >+ "TT" : 0, >+ "TW" : 0, >+ "UM" : 0, >+ "US" : 0, >+ "UZ" : 0, >+ "VI" : 0, >+ "ZA" : 0, >+ "ZW" : 0, >+ "MW" : 0, >+ "NG" : 0, >+ "TJ" : 0 >+ }; >+ >+ var territory = this.__getTerritory(locale); >+ >+ // default is monday >+ return weekStart[territory] != null ? weekStart[territory] : 1; >+ }, >+ >+ /** >+ * Return the day the weekend starts with >+ * >+ * Reference: Common Locale Data Repository (cldr) supplementalData.xml >+ * >+ * @type member >+ * @param locale {String} optional locale to be used >+ * @return {Integer} index of the first day of the weekend. 0=sunday, 1=monday, ... >+ */ >+ __getWeekendStart : function(locale) { >+ var weekendStart = { >+ // default is saturday >+ "EG" : 5, // friday >+ "IL" : 5, >+ "SY" : 5, >+ "IN" : 0, // sunday >+ "AE" : 4, // thursday >+ "BH" : 4, >+ "DZ" : 4, >+ "IQ" : 4, >+ "JO" : 4, >+ "KW" : 4, >+ "LB" : 4, >+ "LY" : 4, >+ "MA" : 4, >+ "OM" : 4, >+ "QA" : 4, >+ "SA" : 4, >+ "SD" : 4, >+ "TN" : 4, >+ "YE" : 4 >+ }; >+ >+ var territory = this.__getTerritory(locale); >+ >+ // default is saturday >+ return weekendStart[territory] != null ? weekendStart[territory] : 6; >+ }, >+ >+ /** >+ * Return the day the weekend ends with >+ * >+ * Reference: Common Locale Data Repository (cldr) supplementalData.xml >+ * >+ * @type member >+ * @param locale {String} optional locale to be used >+ * @return {Integer} index of the last day of the weekend. 0=sunday, 1=monday, ... >+ */ >+ __getWeekendEnd : function(locale) { >+ var weekendEnd = { >+ // default is sunday >+ "AE" : 5, // friday >+ "BH" : 5, >+ "DZ" : 5, >+ "IQ" : 5, >+ "JO" : 5, >+ "KW" : 5, >+ "LB" : 5, >+ "LY" : 5, >+ "MA" : 5, >+ "OM" : 5, >+ "QA" : 5, >+ "SA" : 5, >+ "SD" : 5, >+ "TN" : 5, >+ "YE" : 5, >+ "AF" : 5, >+ "IR" : 5, >+ "EG" : 6, // saturday >+ "IL" : 6, >+ "SY" : 6 >+ }; >+ >+ var territory = this.__getTerritory(locale); >+ >+ // default is sunday >+ return weekendEnd[territory] != null ? weekendEnd[territory] : 0; >+ }, >+ >+ /** >+ * Returns whether a certain day of week belongs to the week end. >+ * >+ * @type member >+ * @param day {Integer} index of the day. 0=sunday, 1=monday, ... >+ * @param locale {String} optional locale to be used >+ * @return {Boolean} whether the given day is a weekend day >+ */ >+ __isWeekend : function(day, locale) { >+ var weekendStart = this.__getWeekendStart(locale); >+ var weekendEnd = this.__getWeekendEnd(locale); >+ >+ if (weekendEnd > weekendStart) { >+ return ((day >= weekendStart) && (day <= weekendEnd)); >+ } else { >+ return ((day >= weekendStart) || (day <= weekendEnd)); >+ } >+ }, >+ >+ /** >+ * Extract the territory part from a locale >+ * >+ * @type member >+ * @param locale {String} the locale >+ * @return {String} territory >+ */ >+ __getTerritory : function(locale) { >+ if (locale) { >+ var territory = locale.split("_")[1] || locale; >+ } else { >+ territory = qx.locale.Manager.getInstance().getTerritory() || qx.locale.Manager.getInstance().getLanguage(); >+ } >+ >+ return territory.toUpperCase(); >+ } >+ }, >+ >+ /* >+ ***************************************************************************** >+ DESTRUCTOR >+ ***************************************************************************** >+ */ >+ >+ destruct : function() { >+ qx.locale.Manager.getInstance().removeEventListener("changeLocale", this._updateDatePane, this); >+ >+ this._disposeObjects("_lastMonthBt", "_nextMonthBt", "_monthYearLabel"); >+ >+ this._disposeObjectDeep("_weekdayLabelArr", 1); >+ this._disposeObjectDeep("_dayLabelArr", 1); >+ } >+}); >Index: js/org/eclipse/swt/widgets/DateTimeCalendar.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/DateTimeCalendar.js >diff -N js/org/eclipse/swt/widgets/DateTimeCalendar.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/DateTimeCalendar.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+qx.Class.define( "org.eclipse.swt.widgets.DateTimeCalendar", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function( style, monthNames, weekdayNames ) { >+ this.base( arguments ); >+ this.setAppearance( "datetime-calendar" ); >+ >+ // Has selection listener >+ this._hasSelectionListener = false; >+ >+ // Get names of weekdays and months >+ qx.ui.component.DateChooser.MONTH_NAMES = monthNames; >+ qx.ui.component.DateChooser.WEEKDAY_NAMES = weekdayNames; >+ >+ // The DateChooser >+ this._calendar = new qx.ui.component.DateChooser; >+ this._calendar.addEventListener( "changeDate", this._onChangeDate, this ); >+ this._calendar.setDate( new Date( 74, 5, 6 ) ); >+ this.add( this._calendar ); >+ >+ this.addEventListener( "contextmenu", this._onContextMenu, this ); >+ }, >+ >+ destruct : function() { >+ this._calendar.removeEventListener( "changeDate", this._onChangeDate, this ); >+ this.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._disposeObjects( "_calendar" ); >+ }, >+ >+ members : { >+ _onChangeDate : function() { >+ var date = this._calendar.getDate(); >+ this._sendChanges( date.getDate(), date.getMonth(), date.getFullYear() ); >+ }, >+ >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _sendChanges : function( date, month, year ) { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var req = org.eclipse.swt.Request.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ req.addParameter( id + ".day", date ); >+ req.addParameter( id + ".month", month ); >+ req.addParameter( id + ".year", year ); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.send(); >+ } >+ } >+ }, >+ >+ setMonth : function( value ) { >+ var date = this._calendar.getDate(); >+ date.setMonth( value ); >+ this._calendar.setDate( date ); >+ }, >+ >+ setDay : function( value ) { >+ var date = this._calendar.getDate(); >+ date.setDate( value ); >+ this._calendar.setDate( date ); >+ }, >+ >+ setYear : function( value ) { >+ var date = this._calendar.getDate(); >+ date.setYear( value ); >+ this._calendar.setDate( date ); >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ } >+ } >+} ); >Index: js/org/eclipse/swt/widgets/DateTimeTime.js >=================================================================== >RCS file: js/org/eclipse/swt/widgets/DateTimeTime.js >diff -N js/org/eclipse/swt/widgets/DateTimeTime.js >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ js/org/eclipse/swt/widgets/DateTimeTime.js 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,461 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Innoopract Informationssysteme GmbH - initial API and implementation >+ ******************************************************************************/ >+ >+qx.Class.define( "org.eclipse.swt.widgets.DateTimeTime", { >+ extend : qx.ui.layout.CanvasLayout, >+ >+ construct : function( style ) { >+ this.base( arguments ); >+ this.setAppearance( "datetime-date" ); >+ >+ // Get styles >+ this._short = qx.lang.String.contains( style, "short" ); >+ this._medium = qx.lang.String.contains( style, "medium" ); >+ this._long = qx.lang.String.contains( style, "long" ); >+ >+ // Has selection listener >+ this._hasSelectionListener = false; >+ >+ // Flag that indicates that the next request can be sent >+ this._readyToSendChanges = true; >+ >+ // Add listeners for font, background and foregraund color change >+ this.addEventListener( "changeFont", this._rwt_onChangeFont, this ); >+ this.addEventListener( "changeTextColor", this._rwt_onChangeTextColor, this ); >+ this.addEventListener( "changeBackgroundColor", this._rwt_onChangeBackgoundColor, this ); >+ >+ // Background color >+ this._backgroundColor = "white"; >+ // Foreground color >+ this._foregroundColor = "black"; >+ >+ // Focused text field >+ this._focusedTextField = null; >+ // Hours >+ this._hoursTextField = new qx.ui.form.TextField; >+ this._hoursTextField.set({ >+ maxLength: 2, >+ textAlign: "center", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._hoursTextField.setValue( "00" ); >+ this._hoursTextField.addEventListener( "click", this._onClick, this ); >+ this._hoursTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._hoursTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._hoursTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add(this._hoursTextField); >+ // Separator >+ this._separator3 = new qx.ui.basic.Label(":"); >+ this._separator3.set({ >+ paddingTop: 3, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._separator3.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add(this._separator3); >+ // Minutes >+ this._minutesTextField = new qx.ui.form.TextField; >+ this._minutesTextField.set({ >+ maxLength: 2, >+ textAlign: "center", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._minutesTextField.setValue( "00" ); >+ this._minutesTextField.addEventListener( "click", this._onClick, this ); >+ this._minutesTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._minutesTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._minutesTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ this.add(this._minutesTextField); >+ // Separator >+ this._separator4 = new qx.ui.basic.Label(":"); >+ this._separator4.set({ >+ paddingTop: 3, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._separator4.addEventListener( "contextmenu", this._onContextMenu, this ); >+ if( this._medium || this._long ) { >+ this.add(this._separator4); >+ } >+ // Seconds >+ this._secondsTextField = new qx.ui.form.TextField; >+ this._secondsTextField.set({ >+ maxLength: 2, >+ textAlign: "center", >+ selectable: false, >+ readOnly: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._secondsTextField.setValue( "00" ); >+ this._secondsTextField.addEventListener( "click", this._onClick, this ); >+ this._secondsTextField.addEventListener( "keypress", this._onKeyPress, this ); >+ this._secondsTextField.addEventListener( "keyup", this._onKeyUp, this ); >+ this._secondsTextField.addEventListener( "contextmenu", this._onContextMenu, this ); >+ if( this._medium || this._long ) { >+ this.add(this._secondsTextField); >+ } >+ // Spinner >+ this._spinner = new qx.ui.form.Spinner; >+ this._spinner.set({ >+ wrap: true, >+ border: null, >+ backgroundColor: this._backgroundColor, >+ textColor : this._foregroundColor >+ }); >+ this._spinner.setMin( 0 ); >+ this._spinner.setMax( 23 ); >+ this._spinner.setValue( 0 ); >+ this._spinner.addEventListener( "change", this._onSpinnerChange, this ); >+ this._spinner.addEventListener( "mousedown", this._onSpinnerMouseDown, this ); >+ this._spinner.addEventListener( "mouseup", this._onSpinnerMouseUp, this ); >+ this._spinner.addEventListener( "keypress", this._onKeyPress, this ); >+ this._spinner.addEventListener( "keyup", this._onKeyUp, this ); >+ this.add( this._spinner ); >+ // Set the default focused text field >+ this._focusedTextField = this._hoursTextField; >+ }, >+ >+ destruct : function() { >+ this.removeEventListener( "changeFont", this._rwt_onChangeFont, this ); >+ this.removeEventListener( "changeTextColor", this._rwt_onChangeTextColor, this ); >+ this.removeEventListener( "changeBackgroundColor", this._rwt_onChangeBackgoundColor, this ); >+ this._hoursTextField.removeEventListener( "click", this._onClick, this ); >+ this._hoursTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._hoursTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._hoursTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._minutesTextField.removeEventListener( "click", this._onClick, this ); >+ this._minutesTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._minutesTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._minutesTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._secondsTextField.removeEventListener( "click", this._onClick, this ); >+ this._secondsTextField.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._secondsTextField.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._secondsTextField.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._spinner.removeEventListener( "change", this._onSpinnerChange, this ); >+ this._spinner.removeEventListener( "mousedown", this._onSpinnerMouseDown, this ); >+ this._spinner.removeEventListener( "mouseup", this._onSpinnerMouseUp, this ); >+ this._spinner.removeEventListener( "keypress", this._onKeyPress, this ); >+ this._spinner.removeEventListener( "keyup", this._onKeyUp, this ); >+ this._separator3.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._separator4.removeEventListener( "contextmenu", this._onContextMenu, this ); >+ this._disposeObjects( "_hoursTextField", >+ "_minutesTextField", >+ "_secondsTextField", >+ "_focusedTextField", >+ "_spinner", >+ "_separator3", >+ "_separator4" ); >+ }, >+ >+ statics : { >+ HOURS_TEXTFIELD : 8, >+ MINUTES_TEXTFIELD : 9, >+ SECONDS_TEXTFIELD : 10, >+ HOURS_MINUTES_SEPARATOR : 11, >+ MINUTES_SECONDS_SEPARATOR : 12, >+ SPINNER : 7, >+ >+ _isNoModifierPressed : function( evt ) { >+ return !evt.isCtrlPressed() >+ && !evt.isShiftPressed() >+ && !evt.isAltPressed() >+ && !evt.isMetaPressed(); >+ } >+ }, >+ >+ members : { >+ _rwt_onChangeFont : function( evt ) { >+ var value = evt.getData(); >+ this._hoursTextField.setFont( value ); >+ this._minutesTextField.setFont( value ); >+ this._secondsTextField.setFont( value ); >+ }, >+ >+ _rwt_onChangeTextColor : function( evt ) { >+ var value = evt.getData(); >+ this._foregroundColor = value; >+ this._hoursTextField.setTextColor( value ); >+ this._minutesTextField.setTextColor( value ); >+ this._secondsTextField.setTextColor( value ); >+ this._separator3.setTextColor( value ); >+ this._separator4.setTextColor( value ); >+ }, >+ >+ _rwt_onChangeBackgoundColor : function( evt ) { >+ var value = evt.getData(); >+ this._backgroundColor = value; >+ this._hoursTextField.setBackgroundColor( value ); >+ this._minutesTextField.setBackgroundColor( value ); >+ this._secondsTextField.setBackgroundColor( value ); >+ this._separator3.setBackgroundColor( value ); >+ this._separator4.setBackgroundColor( value ); >+ this._spinner.setBackgroundColor( value ); >+ }, >+ >+ _onContextMenu : function( evt ) { >+ var menu = this.getContextMenu(); >+ if( menu != null ) { >+ menu.setLocation( evt.getPageX(), evt.getPageY() ); >+ menu.setOpener( this ); >+ menu.show(); >+ evt.stopPropagation(); >+ } >+ }, >+ >+ _onClick : function( evt ) { >+ this._setFocusedTextField( evt.getTarget() ); >+ }, >+ >+ _setFocusedTextField : function( textField ) { >+ var tmpValue; >+ this._focusedTextField.setBackgroundColor( this._backgroundColor ); >+ this._focusedTextField.setTextColor( this._foregroundColor ); >+ // Set focused text field to null >+ this._focusedTextField = null; >+ if( textField === this._hoursTextField ) { >+ this._spinner.setMin( 0 ); >+ this._spinner.setMax( 23 ); >+ tmpValue = this._removeLeadingZero( this._hoursTextField.getValue() ); >+ this._spinner.setValue( parseInt( tmpValue ) ); >+ } else if( textField === this._minutesTextField ) { >+ this._spinner.setMin( 0 ); >+ this._spinner.setMax( 59 ); >+ tmpValue = this._removeLeadingZero( this._minutesTextField.getValue() ); >+ this._spinner.setValue( parseInt( tmpValue ) ); >+ } else if( textField === this._secondsTextField ) { >+ this._spinner.setMin( 0 ); >+ this._spinner.setMax( 59 ); >+ tmpValue = this._removeLeadingZero( this._secondsTextField.getValue() ); >+ this._spinner.setValue( parseInt( tmpValue ) ); >+ } >+ // Set focused text field >+ this._focusedTextField = textField; >+ // Set highlight on focused text field >+ this._focusedTextField.setBackgroundColor( "#0A246A" ); >+ this._focusedTextField.setTextColor( "white" ); >+ // Request focus >+ this._focusedTextField.setFocused( true ); >+ }, >+ >+ _onSpinnerChange : function( evt ) { >+ if( this._focusedTextField != null ) { >+ var oldValue = this._focusedTextField.getValue(); >+ var newValue = this._addLeadingZero( this._spinner.getValue() ); >+ this._focusedTextField.setValue( newValue ); >+ if( oldValue != newValue && this._readyToSendChanges ) { >+ this._readyToSendChanges = false; >+ // Send changes >+ qx.client.Timer.once( this._sendChanges, this, 500 ); >+ } >+ } >+ }, >+ >+ _onSpinnerMouseDown : function( evt ) { >+ // Set highlight on focused text field >+ this._focusedTextField.setBackgroundColor( "#0A246A" ); >+ this._focusedTextField.setTextColor( "white" ); >+ }, >+ >+ _onSpinnerMouseUp : function( evt ) { >+ this._focusedTextField.setFocused( true ); >+ }, >+ >+ _onKeyPress : function( evt ) { >+ var keyIdentifier = evt.getKeyIdentifier(); >+ if( org.eclipse.swt.widgets.DateTimeTime._isNoModifierPressed( evt ) ) { >+ switch( keyIdentifier ) { >+ case "Left": >+ if( this._focusedTextField === this._hoursTextField ) { >+ if( this._short ) { >+ this._setFocusedTextField( this._minutesTextField ); >+ } else { >+ this._setFocusedTextField( this._secondsTextField ); >+ } >+ } else if( this._focusedTextField === this._minutesTextField ) { >+ this._setFocusedTextField( this._hoursTextField ); >+ } else if( this._focusedTextField === this._secondsTextField ) { >+ this._setFocusedTextField( this._minutesTextField ); >+ } >+ break; >+ case "Right": >+ if( this._focusedTextField === this._hoursTextField ) { >+ this._setFocusedTextField( this._minutesTextField ); >+ } else if( this._focusedTextField === this._minutesTextField ) { >+ if( this._short ) { >+ this._setFocusedTextField( this._hoursTextField ); >+ } else { >+ this._setFocusedTextField( this._secondsTextField ); >+ } >+ } else if( this._focusedTextField === this._secondsTextField ) { >+ this._setFocusedTextField( this._hoursTextField ); >+ } >+ break; >+ case "Up": >+ var value = this._spinner.getValue(); >+ if( value == this._spinner.getMax() ) { >+ this._spinner.setValue( this._spinner.getMin() ); >+ } else { >+ this._spinner.setValue( value + 1 ); >+ } >+ break; >+ case "Down": >+ var value = this._spinner.getValue(); >+ if( value == this._spinner.getMin() ) { >+ this._spinner.setValue( this._spinner.getMax() ); >+ } else { >+ this._spinner.setValue( value - 1 ); >+ } >+ break; >+ } >+ } >+ }, >+ >+ _onKeyUp : function( evt ) { >+ var keypress = evt.getKeyIdentifier(); >+ var value = this._focusedTextField.getComputedValue(); >+ value = this._removeLeadingZero( value ); >+ if( org.eclipse.swt.widgets.DateTimeTime._isNoModifierPressed( evt ) ) { >+ switch( keypress ) { >+ case "Tab": >+ this._focusedTextField.setBackgroundColor( this._backgroundColor ); >+ this._focusedTextField.setTextColor( this._foregroundColor ); >+ break; >+ case "0": case "1": case "2": case "3": case "4": >+ case "5": case "6": case "7": case "8": case "9": >+ this._focusedTextField.setFocused( true ); >+ var maxChars = this._focusedTextField.getMaxLength(); >+ var newValue = keypress; >+ if( value.length < maxChars ) { >+ newValue = value + keypress; >+ } >+ var intValue = parseInt( newValue ); >+ if( intValue >= this._spinner.getMin() && >+ intValue <= this._spinner.getMax() ) { >+ this._spinner.setValue( intValue ); >+ } else { >+ newValue = keypress; >+ intValue = parseInt( newValue ); >+ if( intValue >= this._spinner.getMin() && >+ intValue <= this._spinner.getMax() ) { >+ this._spinner.setValue( intValue ); >+ } >+ } >+ break; >+ case "Home": >+ var newValue = this._spinner.getMin(); >+ this._spinner.setValue( newValue ); >+ break; >+ case "End": >+ var newValue = this._spinner.getMax(); >+ this._spinner.setValue( newValue ); >+ break; >+ } >+ } >+ }, >+ >+ _addLeadingZero : function( value ) { >+ return value < 10 ? "0" + value : value; >+ }, >+ >+ _removeLeadingZero : function( value ) { >+ var result = value; >+ if( value.length == 2 ) { >+ var firstChar = value.substring( 0, 1 ); >+ if( firstChar == "0" ) result = value.substring( 1 ); >+ } >+ return result; >+ }, >+ >+ _sendChanges : function() { >+ if( !org_eclipse_rap_rwt_EventUtil_suspend ) { >+ var widgetManager = org.eclipse.swt.WidgetManager.getInstance(); >+ var req = org.eclipse.swt.Request.getInstance(); >+ var id = widgetManager.findIdByWidget( this ); >+ req.addParameter( id + ".hours", >+ this._removeLeadingZero( this._hoursTextField.getValue() ) ); >+ req.addParameter( id + ".minutes", >+ this._removeLeadingZero( this._minutesTextField.getValue() ) ); >+ req.addParameter( id + ".seconds", >+ this._removeLeadingZero( this._secondsTextField.getValue() ) ); >+ if( this._hasSelectionListener ) { >+ req.addEvent( "org.eclipse.swt.events.widgetSelected", id ); >+ req.send(); >+ } >+ this._readyToSendChanges = true; >+ } >+ }, >+ >+ setHours : function( value ) { >+ this._hoursTextField.setValue( this._addLeadingZero( value ) ); >+ if( this._focusedTextField === this._hoursTextField ) { >+ this._spinner.setValue( value ); >+ } >+ }, >+ >+ setMinutes : function( value ) { >+ this._minutesTextField.setValue( this._addLeadingZero( value ) ); >+ if( this._focusedTextField === this._minutesTextField ) { >+ this._spinner.setValue( value ); >+ } >+ }, >+ >+ setSeconds : function( value ) { >+ this._secondsTextField.setValue( this._addLeadingZero( value ) ); >+ if( this._focusedTextField === this._secondsTextField ) { >+ this._spinner.setValue( value ); >+ } >+ }, >+ >+ setHasSelectionListener : function( value ) { >+ this._hasSelectionListener = value; >+ }, >+ >+ setBounds : function( ind, x, y, width, height ) { >+ var widget; >+ switch( ind ) { >+ case org.eclipse.swt.widgets.DateTimeTime.HOURS_TEXTFIELD: >+ widget = this._hoursTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeTime.MINUTES_TEXTFIELD: >+ widget = this._minutesTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeTime.SECONDS_TEXTFIELD: >+ widget = this._secondsTextField; >+ break; >+ case org.eclipse.swt.widgets.DateTimeTime.HOURS_MINUTES_SEPARATOR: >+ widget = this._separator3; >+ break; >+ case org.eclipse.swt.widgets.DateTimeTime.MINUTES_SECONDS_SEPARATOR: >+ widget = this._separator4; >+ break; >+ case org.eclipse.swt.widgets.DateTimeTime.SPINNER: >+ widget = this._spinner; >+ break; >+ } >+ widget.set({ >+ left: x, >+ top: y, >+ width: width, >+ height: height >+ }); >+ } >+ } >+} ); >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeCalendarLCA.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeCalendarLCA.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeCalendarLCA.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeCalendarLCA.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2008 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import java.io.IOException; >+ >+import org.eclipse.rwt.lifecycle.*; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.DateTime; >+ >+public class DateTimeCalendarLCA extends AbstractDateTimeLCADelegate { >+ >+ static final String TYPE_POOL_ID = DateTimeCalendarLCA.class.getName(); >+ //Property names for preserveValues >+ static final String PROP_DAY = "day"; >+ static final String PROP_MONTH = "month"; >+ static final String PROP_YEAR = "year"; >+ >+ // Property names for preserveValues >+ void preserveValues( final DateTime dateTime ) { >+ ControlLCAUtil.preserveValues( dateTime ); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ boolean hasListeners = SelectionEvent.hasListener( dateTime ); >+ adapter.preserve( Props.SELECTION_LISTENERS, >+ Boolean.valueOf( hasListeners ) ); >+ adapter.preserve( PROP_DAY, >+ new Integer( dateTime.getDay() ) ); >+ adapter.preserve( PROP_MONTH, >+ new Integer( dateTime.getMonth() ) ); >+ adapter.preserve( PROP_YEAR, >+ new Integer( dateTime.getYear() ) ); >+ } >+ >+ void readData( final DateTime dateTime ) { >+ String value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_DAY ); >+ if( value != null ) { >+ dateTime.setDay( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_MONTH ); >+ if( value != null ) { >+ dateTime.setMonth( Integer.parseInt( value ) ); >+ } >+ value = WidgetLCAUtil.readPropertyValue( dateTime, PROP_YEAR ); >+ if( value != null ) { >+ dateTime.setYear( Integer.parseInt( value ) ); >+ } >+ ControlLCAUtil.processSelection( dateTime, null, true ); >+ } >+ >+ void renderInitialization( final DateTime dateTime ) >+ throws IOException >+ { >+ IDateTimeAdapter dateTimeAdapter >+ = DateTimeLCAUtil.getDateTimeAdapter( dateTime ); >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ String style = ""; >+ if( ( dateTime.getStyle() & SWT.SHORT ) != 0 ) { >+ style = "short"; >+ } else if( ( dateTime.getStyle() & SWT.MEDIUM ) != 0 ) { >+ style = "medium"; >+ } else if( ( dateTime.getStyle() & SWT.LONG ) != 0 ) { >+ style = "long"; >+ } >+ Object[] args = new Object[]{ >+ style, >+ dateTimeAdapter.getMonthNames(), >+ dateTimeAdapter.getWeekdayNames() >+ }; >+ writer.newWidget( "org.eclipse.swt.widgets.DateTimeCalendar", args ); >+ WidgetLCAUtil.writeCustomVariant( dateTime ); >+ ControlLCAUtil.writeStyleFlags( dateTime ); >+ } >+ >+ void renderChanges( final DateTime dateTime ) throws IOException { >+ ControlLCAUtil.writeChanges( dateTime ); >+ writeDay( dateTime ); >+ writeMonth( dateTime ); >+ writeYear( dateTime ); >+ DateTimeLCAUtil.writeListener( dateTime ); >+ } >+ >+ void renderDispose( final DateTime dateTime ) throws IOException { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.dispose(); >+ } >+ >+ void createResetHandlerCalls( final String typePoolId ) >+ throws IOException >+ { >+ } >+ >+ String getTypePoolId( final DateTime dateTime ) { >+ return null; >+ } >+ >+ // //////////////////////////////////// >+ // Helping methods to write properties >+ private void writeDay( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getDay() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_DAY, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_DAY, newValue ); >+ } >+ } >+ >+ private void writeMonth( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getMonth() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_MONTH, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_MONTH, newValue ); >+ } >+ } >+ >+ private void writeYear( final DateTime dateTime ) throws IOException { >+ Integer newValue = new Integer( dateTime.getYear() ); >+ if( WidgetLCAUtil.hasChanged( dateTime, PROP_YEAR, newValue ) ) { >+ JSWriter writer = JSWriter.getWriterFor( dateTime ); >+ writer.set( PROP_YEAR, newValue ); >+ } >+ } >+} >#P org.eclipse.rap.rwt.q07.test >Index: src/org/eclipse/RWTQ07TestSuite.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.rap/org.eclipse.rap.rwt.q07.test/src/org/eclipse/RWTQ07TestSuite.java,v >retrieving revision 1.5 >diff -u -r1.5 RWTQ07TestSuite.java >--- src/org/eclipse/RWTQ07TestSuite.java 2 Jul 2008 21:19:57 -0000 1.5 >+++ src/org/eclipse/RWTQ07TestSuite.java 10 Jul 2008 20:11:26 -0000 >@@ -25,6 +25,7 @@ > import org.eclipse.swt.internal.widgets.combokit.ComboLCA_Test; > import org.eclipse.swt.internal.widgets.controlkit.ControlLCA_Test; > import org.eclipse.swt.internal.widgets.coolbarkit.CoolBarLCA_Test; >+import org.eclipse.swt.internal.widgets.datetimekit.DateTimeLCA_Test; > import org.eclipse.swt.internal.widgets.displaykit.DisplayLCAFocus_Test; > import org.eclipse.swt.internal.widgets.displaykit.DisplayLCA_Test; > import org.eclipse.swt.internal.widgets.labelkit.LabelLCA_Test; >@@ -109,6 +110,7 @@ > suite.addTestSuite( TabFolderLCA_Test.class ); > suite.addTestSuite( ScrolledCompositeLCA_Test.class ); > suite.addTestSuite( BrowserLCA_Test.class ); >+ suite.addTestSuite( DateTimeLCA_Test.class ); > > return suite; > } >Index: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA_Test.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA_Test.java >diff -N src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/datetimekit/DateTimeLCA_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,246 @@ >+/******************************************************************************* >+ * Copyright (c) 2002-2006 Innoopract Informationssysteme GmbH. All rights >+ * reserved. This program and the accompanying materials are made available >+ * under the terms of the Eclipse Public License v1.0 which accompanies this >+ * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html >+ * Contributors: Innoopract Informationssysteme GmbH - initial API and >+ * implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets.datetimekit; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.rwt.Fixture; >+import org.eclipse.rwt.graphics.Graphics; >+import org.eclipse.rwt.internal.lifecycle.JSConst; >+import org.eclipse.rwt.lifecycle.IWidgetAdapter; >+import org.eclipse.rwt.lifecycle.WidgetUtil; >+import org.eclipse.swt.RWTFixture; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.*; >+import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.internal.widgets.IDateTimeAdapter; >+import org.eclipse.swt.internal.widgets.Props; >+import org.eclipse.swt.widgets.*; >+ >+public class DateTimeLCA_Test extends TestCase { >+ >+ public void testDateTimeDatePreserveValues() { >+ Display display = new Display(); >+ Composite shell = new Shell( display, SWT.NONE ); >+ DateTime dateTime = new DateTime( shell, SWT.DATE | SWT.MEDIUM ); >+ dateTime.setDay( 1 ); >+ dateTime.setMonth( 1 ); >+ dateTime.setYear( 2008 ); >+ RWTFixture.markInitialized( display ); >+ // Test preserved day, month, year >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ Integer day = ( Integer )adapter.getPreserved( DateTimeDateLCA.PROP_DAY ); >+ assertEquals( 1, day.intValue() ); >+ Integer month = ( Integer )adapter.getPreserved( DateTimeDateLCA.PROP_MONTH ); >+ assertEquals( 1, month.intValue() ); >+ Integer year = ( Integer )adapter.getPreserved( DateTimeDateLCA.PROP_YEAR ); >+ assertEquals( 2008, year.intValue() ); >+ RWTFixture.clearPreserved(); >+ // Test preserved control properties >+ testPreserveControlProperties( dateTime ); >+ // Test preserved sub widgets bounds >+ IDateTimeAdapter dateTimeAdapter = DateTimeLCAUtil.getDateTimeAdapter( dateTime ); >+ RWTFixture.preserveWidgets(); >+ Rectangle bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.WEEKDAY_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.WEEKDAY_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.DAY_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.DAY_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.MONTH_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.MONTH_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.YEAR_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.YEAR_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.WEEKDAY_MONTH_SEPARATOR >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.WEEKDAY_MONTH_SEPARATOR ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.MONTH_DAY_SEPARATOR >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.MONTH_DAY_SEPARATOR ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.DAY_YEAR_SEPARATOR >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.DAY_YEAR_SEPARATOR ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.SPINNER >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.SPINNER ), bounds ); >+ RWTFixture.clearPreserved(); >+ // Test preserved selection listeners >+ testPreserveSelectionListener( dateTime ); >+ display.dispose(); >+ } >+ >+ public void testDateTimeTimePreserveValues() { >+ Display display = new Display(); >+ Composite shell = new Shell( display, SWT.NONE ); >+ DateTime dateTime = new DateTime( shell, SWT.TIME | SWT.MEDIUM ); >+ dateTime.setHours( 1 ); >+ dateTime.setMinutes( 2 ); >+ dateTime.setSeconds( 3 ); >+ RWTFixture.markInitialized( display ); >+ // Test preserved hours, minutes, seconds >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ Integer hours = ( Integer )adapter.getPreserved( DateTimeTimeLCA.PROP_HOURS ); >+ assertEquals( 1, hours.intValue() ); >+ Integer minutes = ( Integer )adapter.getPreserved( DateTimeTimeLCA.PROP_MINUTES ); >+ assertEquals( 2, minutes.intValue() ); >+ Integer seconds = ( Integer )adapter.getPreserved( DateTimeTimeLCA.PROP_SECONDS ); >+ assertEquals( 3, seconds.intValue() ); >+ RWTFixture.clearPreserved(); >+ // Test preserved control properties >+ testPreserveControlProperties( dateTime ); >+ // Test preserved sub widgets bounds >+ IDateTimeAdapter dateTimeAdapter = DateTimeLCAUtil.getDateTimeAdapter( dateTime ); >+ RWTFixture.preserveWidgets(); >+ Rectangle bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.HOURS_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.HOURS_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.MINUTES_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.MINUTES_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.SECONDS_TEXTFIELD >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.SECONDS_TEXTFIELD ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.HOURS_MINUTES_SEPARATOR >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.HOURS_MINUTES_SEPARATOR ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.MINUTES_SECONDS_SEPARATOR >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.MINUTES_SECONDS_SEPARATOR ), >+ bounds ); >+ bounds = ( Rectangle )adapter.getPreserved( IDateTimeAdapter.SPINNER >+ + "_BOUNDS" ); >+ assertEquals( dateTimeAdapter.getBounds( IDateTimeAdapter.SPINNER ), bounds ); >+ RWTFixture.clearPreserved(); >+ // Test preserved selection listeners >+ testPreserveSelectionListener( dateTime ); >+ display.dispose(); >+ } >+ >+ public void testSelectionEvent() { >+ // Date >+ Display display = new Display(); >+ Composite shell = new Shell( display, SWT.NONE ); >+ DateTime dateTime = new DateTime( shell, SWT.DATE | SWT.MEDIUM ); >+ testSelectionEvent( dateTime ); >+ // Time >+ dateTime = new DateTime( shell, SWT.TIME | SWT.MEDIUM ); >+ testSelectionEvent( dateTime ); >+ } >+ >+ private void testPreserveControlProperties( final DateTime dateTime ) { >+ // control: enabled >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( Boolean.TRUE, adapter.getPreserved( Props.ENABLED ) ); >+ RWTFixture.clearPreserved(); >+ dateTime.setEnabled( false ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( Boolean.FALSE, adapter.getPreserved( Props.ENABLED ) ); >+ RWTFixture.clearPreserved(); >+ // visible >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( Boolean.TRUE, adapter.getPreserved( Props.VISIBLE ) ); >+ RWTFixture.clearPreserved(); >+ dateTime.setVisible( false ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( Boolean.FALSE, adapter.getPreserved( Props.VISIBLE ) ); >+ RWTFixture.clearPreserved(); >+ // menu >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( null, adapter.getPreserved( Props.MENU ) ); >+ RWTFixture.clearPreserved(); >+ Menu menu = new Menu( dateTime ); >+ MenuItem item = new MenuItem( menu, SWT.NONE ); >+ item.setText( "1 Item" ); >+ dateTime.setMenu( menu ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( menu, adapter.getPreserved( Props.MENU ) ); >+ RWTFixture.clearPreserved(); >+ // foreground background font >+ Color background = Graphics.getColor( 122, 33, 203 ); >+ dateTime.setBackground( background ); >+ Color foreground = Graphics.getColor( 211, 178, 211 ); >+ dateTime.setForeground( foreground ); >+ Font font = Graphics.getFont( "font", 12, SWT.BOLD ); >+ dateTime.setFont( font ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ assertEquals( background, adapter.getPreserved( Props.BACKGROUND ) ); >+ assertEquals( foreground, adapter.getPreserved( Props.FOREGROUND ) ); >+ assertEquals( font, adapter.getPreserved( Props.FONT ) ); >+ RWTFixture.clearPreserved(); >+ } >+ >+ private void testPreserveSelectionListener( final DateTime dateTime ) { >+ RWTFixture.preserveWidgets(); >+ IWidgetAdapter adapter = WidgetUtil.getAdapter( dateTime ); >+ Boolean hasListeners = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); >+ assertEquals( Boolean.FALSE, hasListeners ); >+ RWTFixture.clearPreserved(); >+ SelectionListener selectionListener = new SelectionAdapter() { >+ }; >+ dateTime.addSelectionListener( selectionListener ); >+ RWTFixture.preserveWidgets(); >+ adapter = WidgetUtil.getAdapter( dateTime ); >+ hasListeners = ( Boolean )adapter.getPreserved( Props.SELECTION_LISTENERS ); >+ assertEquals( Boolean.TRUE, hasListeners ); >+ RWTFixture.clearPreserved(); >+ } >+ >+ private void testSelectionEvent( final DateTime dateTime ) { >+ final StringBuffer log = new StringBuffer(); >+ SelectionListener selectionListener = new SelectionAdapter() { >+ >+ public void widgetSelected( SelectionEvent event ) { >+ assertEquals( dateTime, event.getSource() ); >+ assertEquals( null, event.item ); >+ assertEquals( SWT.NONE, event.detail ); >+ assertEquals( 0, event.x ); >+ assertEquals( 0, event.y ); >+ assertEquals( 0, event.width ); >+ assertEquals( 0, event.height ); >+ assertEquals( true, event.doit ); >+ log.append( "widgetSelected" ); >+ } >+ }; >+ dateTime.addSelectionListener( selectionListener ); >+ String dateTimeId = WidgetUtil.getId( dateTime ); >+ Fixture.fakeRequestParam( JSConst.EVENT_WIDGET_SELECTED, dateTimeId ); >+ RWTFixture.readDataAndProcessAction( dateTime ); >+ assertEquals( "widgetSelected", log.toString() ); >+ } >+ >+ protected void setUp() throws Exception { >+ RWTFixture.setUp(); >+ } >+ >+ protected void tearDown() throws Exception { >+ RWTFixture.tearDown(); >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 183177
:
106077
|
107127
|
107128
|
107134
|
107194
|
107578
|
190739