Search in sources :

Example 6 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_setBackgroundAlphaCalendarDateTime.

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

Example 7 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 setUp.

protected void setUp(int style) {
    super.setUp();
    datetime = new DateTime(shell, style);
    setWidget(datetime);
}
Also used : DateTime(org.eclipse.swt.widgets.DateTime)

Example 8 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_setBackgroundAlphaDateDateTime.

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

Example 9 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 setUp.

@Override
@Before
public void setUp() {
    super.setUp();
    datetime = new DateTime(shell, style);
    setWidget(datetime);
}
Also used : DateTime(org.eclipse.swt.widgets.DateTime) Before(org.junit.Before)

Example 10 with DateTime

use of org.eclipse.swt.widgets.DateTime in project yamcs-studio by yamcs.

the class AddManualEventDialog method createDialogArea.

// private void validate() {
// String errorMessage = null;
// Calendar start = RCPUtils.toCalendar(startDate, startTime);
// Calendar stop = RCPUtils.toCalendar(stopDate, stopTime);
// if (start.after(stop))
// errorMessage = "Stop has to be greater than start";
// 
// setErrorMessage(errorMessage);
// getButton(IDialogConstants.OK_ID).setEnabled(errorMessage == null);
// }
@Override
protected Control createDialogArea(Composite parent) {
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    layout.verticalSpacing = 5;
    container.setLayout(layout);
    Label lbl = new Label(container, SWT.NONE);
    lbl.setText("Generation Time:");
    Composite startComposite = new Composite(container, SWT.NONE);
    RowLayout rl = new RowLayout();
    rl.marginLeft = 0;
    rl.marginTop = 0;
    rl.marginBottom = 0;
    rl.center = true;
    startComposite.setLayout(rl);
    generationDatePicker = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    // generationDatePicker.addListener(SWT.Selection, e -> validate());
    // generationDatePicker.addListener(SWT.FocusOut, e -> validate());
    generationTimePicker = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    // generationTimePicker.addListener(SWT.FocusOut, e -> validate());
    if (generationTimeValue != null) {
        generationDatePicker.setDate(generationTimeValue.get(Calendar.YEAR), generationTimeValue.get(Calendar.MONTH), generationTimeValue.get(Calendar.DAY_OF_MONTH));
        generationTimePicker.setTime(generationTimeValue.get(Calendar.HOUR_OF_DAY), generationTimeValue.get(Calendar.MINUTE), generationTimeValue.get(Calendar.SECOND));
    }
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Source:");
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Manual");
    lbl = new Label(container, SWT.NONE);
    lbl.setText("User:");
    if (YamcsAuthorizations.getInstance().isAuthorizationEnabled()) {
        userLbl = new Label(container, SWT.NONE);
        userLbl.setText(YamcsAuthorizations.getInstance().getUsername());
    } else {
        userText = new Text(container, SWT.SINGLE);
        userText.setLayoutData(new GridData(GridData.FILL_BOTH));
        userText.setText("");
    }
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Message:");
    messageText = new Text(container, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.verticalAlignment = SWT.CENTER;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    messageText.setLayoutData(data);
    GC gc = new GC(messageText);
    try {
        gc.setFont(messageText.getFont());
        FontMetrics fm = gc.getFontMetrics();
        /* Set the height to 5 rows of characters */
        data.heightHint = 5 * fm.getHeight();
    } finally {
        gc.dispose();
    }
    messageText.setText("");
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Severity:");
    severityCombo = new Combo(container, SWT.DROP_DOWN);
    severityCombo.add(EventSeverity.INFO.name(), EventSeverity.INFO_VALUE);
    severityCombo.add(EventSeverity.WARNING.name(), EventSeverity.WARNING_VALUE);
    severityCombo.add(EventSeverity.ERROR.name(), EventSeverity.ERROR_VALUE);
    severityCombo.add(EventSeverity.WATCH.name(), EventSeverity.WATCH_VALUE);
    // TODO use index,
    severityCombo.add(EventSeverity.DISTRESS.name(), EventSeverity.DISTRESS_VALUE - 1);
    // the value skips 4
    severityCombo.add(EventSeverity.CRITICAL.name(), EventSeverity.CRITICAL_VALUE - 1);
    severityCombo.add(EventSeverity.SEVERE.name(), EventSeverity.SEVERE_VALUE - 1);
    severityCombo.select(EventSeverity.INFO_VALUE);
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) FontMetrics(org.eclipse.swt.graphics.FontMetrics) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GC(org.eclipse.swt.graphics.GC) DateTime(org.eclipse.swt.widgets.DateTime)

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