Search in sources :

Example 16 with DateTime

use of org.eclipse.swt.widgets.DateTime in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_DateTime method test_setForegroundAlphaCalendarDateTime.

@Test
public void test_setForegroundAlphaCalendarDateTime() {
    DateTime calendar = new DateTime(shell, SWT.CALENDAR);
    assumeTrue("Alpha support for foreground colors does not exist on GTK2 or Win32", SwtTestUtil.isCocoa || SwtTestUtil.isGTK3());
    Color color = new Color(calendar.getDisplay(), 255, 0, 0, 0);
    calendar.setForeground(color);
    assertEquals(color, calendar.getForeground());
    Color bg = new Color(calendar.getDisplay(), 0, 255, 0, 0);
    calendar.setBackground(bg);
    assertEquals(color, calendar.getForeground());
    color.dispose();
    bg.dispose();
    calendar.dispose();
}
Also used : Color(org.eclipse.swt.graphics.Color) DateTime(org.eclipse.swt.widgets.DateTime) Test(org.junit.Test)

Example 17 with DateTime

use of org.eclipse.swt.widgets.DateTime in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_DateTime method test_setBackgroundCalendarDateTime.

@Test
public void test_setBackgroundCalendarDateTime() {
    DateTime calendar = new DateTime(shell, SWT.CALENDAR);
    Color color = new Color(calendar.getDisplay(), 255, 0, 0);
    calendar.setBackground(color);
    assertEquals("getBackground not equal after setBackground for SWT.CALENDAR DateTime", color, calendar.getBackground());
    calendar.setBackground(null);
    assertTrue("getBackground unchanged after setBackground(null) for SWT.CALENDAR DateTime", !calendar.getBackground().equals(color));
    color.dispose();
    color = new Color(calendar.getDisplay(), 255, 0, 0, 0);
    calendar.setBackground(color);
    assertEquals("getBackground not equal after setBackground with 0 alpha for SWT.CALENDAR DateTime", color, calendar.getBackground());
    calendar.setBackground(null);
    assertTrue("getBackground unchanged after setBackground(null) with 0 alpha for SWT.CALENDAR DateTime", !calendar.getBackground().equals(color));
    if ("gtk".equals(SWT.getPlatform())) {
        Color fg = new Color(calendar.getDisplay(), 0, 255, 0);
        calendar.setBackground(color);
        calendar.setForeground(fg);
        assertEquals("Setting a foreground disrupted the background color for SWT.CALENDAR DateTime", color, calendar.getBackground());
        assertEquals("Setting a foreground onto an SWT.CALENDAR DateTime with a background failed", fg, calendar.getForeground());
        fg.dispose();
    }
    color.dispose();
    calendar.dispose();
}
Also used : Color(org.eclipse.swt.graphics.Color) DateTime(org.eclipse.swt.widgets.DateTime) Test(org.junit.Test)

Example 18 with DateTime

use of org.eclipse.swt.widgets.DateTime in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_DateTime method test_setForegroundAlphaDateDateTime.

@Test
public void test_setForegroundAlphaDateDateTime() {
    DateTime date = new DateTime(shell, SWT.DATE);
    assumeTrue("Alpha support for foreground colors does not exist on GTK2 or Win32", SwtTestUtil.isCocoa || SwtTestUtil.isGTK3());
    Color color = new Color(date.getDisplay(), 255, 0, 0, 0);
    date.setForeground(color);
    assertEquals(color, date.getForeground());
    Color bg = new Color(date.getDisplay(), 0, 255, 0, 0);
    date.setBackground(bg);
    assertEquals(color, date.getForeground());
    color.dispose();
    bg.dispose();
    date.dispose();
}
Also used : Color(org.eclipse.swt.graphics.Color) DateTime(org.eclipse.swt.widgets.DateTime) Test(org.junit.Test)

Example 19 with DateTime

use of org.eclipse.swt.widgets.DateTime in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_DateTime method test_setForegroundDateDateTime.

@Test
public void test_setForegroundDateDateTime() {
    DateTime date = new DateTime(shell, SWT.DATE);
    Color color = new Color(date.getDisplay(), 255, 0, 0);
    date.setForeground(color);
    assertEquals(color, date.getForeground());
    date.setForeground(null);
    assertFalse(date.getForeground().equals(color));
    if ("gtk".equals(SWT.getPlatform())) {
        Color bg = new Color(date.getDisplay(), 0, 255, 0);
        date.setForeground(color);
        date.setBackground(bg);
        assertEquals("Setting a background disrupted the foreground color for SWT.DATE DateTime", color, date.getForeground());
        assertEquals("Setting a background onto an SWT.DATE DateTime with a foreground failed", bg, date.getBackground());
        bg.dispose();
    }
    color.dispose();
    date.dispose();
}
Also used : Color(org.eclipse.swt.graphics.Color) DateTime(org.eclipse.swt.widgets.DateTime) Test(org.junit.Test)

Example 20 with DateTime

use of org.eclipse.swt.widgets.DateTime in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_DateTime method test_setBackgroundAlphaTimeDateTime.

@Test
public void test_setBackgroundAlphaTimeDateTime() {
    DateTime time = new DateTime(shell, SWT.TIME);
    Color color = new Color(time.getDisplay(), 255, 0, 0, 0);
    time.setBackground(color);
    assertEquals(color, time.getBackground());
    Color fg = new Color(time.getDisplay(), 0, 255, 0, 0);
    time.setForeground(fg);
    assertEquals(color, time.getBackground());
    color.dispose();
    fg.dispose();
    time.dispose();
}
Also used : Color(org.eclipse.swt.graphics.Color) DateTime(org.eclipse.swt.widgets.DateTime) Test(org.junit.Test)

Aggregations

DateTime (org.eclipse.swt.widgets.DateTime)27 GridData (org.eclipse.swt.layout.GridData)13 Color (org.eclipse.swt.graphics.Color)12 GridLayout (org.eclipse.swt.layout.GridLayout)12 Composite (org.eclipse.swt.widgets.Composite)12 Test (org.junit.Test)12 Label (org.eclipse.swt.widgets.Label)9 Button (org.eclipse.swt.widgets.Button)7 RowLayout (org.eclipse.swt.layout.RowLayout)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Text (org.eclipse.swt.widgets.Text)4 Calendar (java.util.Calendar)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Dimension (java.awt.Dimension)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 SimpleDateFormat (java.text.SimpleDateFormat)1 LocalResourceManager (org.eclipse.jface.resource.LocalResourceManager)1 ResourceManager (org.eclipse.jface.resource.ResourceManager)1