Search in sources :

Example 26 with DateTime

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

the class CustomizeRangeDialog method createDialogArea.

@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 = 2;
    container.setLayout(layout);
    Composite startLabelWrapper = new Composite(container, SWT.NONE);
    GridLayout gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    startLabelWrapper.setLayout(gl);
    Label lbl = new Label(startLabelWrapper, SWT.NONE);
    lbl.setText("Start");
    startClosed = new Button(startLabelWrapper, SWT.CHECK | SWT.NONE);
    startClosed.addListener(SWT.Selection, e -> {
        startDate.setVisible(startClosed.getSelection());
        startTime.setVisible(startClosed.getSelection());
        validate();
    });
    startClosed.setSelection(startClosedValue);
    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);
    startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    startDate.addListener(SWT.Selection, e -> validate());
    startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    startTime.addListener(SWT.Selection, e -> validate());
    if (startTimeValue != null) {
        startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
        startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
    }
    startDate.setVisible(startClosedValue);
    startTime.setVisible(startClosedValue);
    Composite stopLabelWrapper = new Composite(container, SWT.NONE);
    gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    stopLabelWrapper.setLayout(gl);
    lbl = new Label(stopLabelWrapper, SWT.NONE);
    lbl.setText("Stop");
    stopClosed = new Button(stopLabelWrapper, SWT.CHECK | SWT.NONE);
    stopClosed.addListener(SWT.Selection, e -> {
        stopDate.setVisible(stopClosed.getSelection());
        stopTime.setVisible(stopClosed.getSelection());
        validate();
    });
    stopClosed.setSelection(stopClosedValue);
    Composite stopComposite = new Composite(container, SWT.NONE);
    rl = new RowLayout();
    rl.marginLeft = 0;
    rl.marginTop = 0;
    rl.marginBottom = 0;
    rl.center = true;
    rl.fill = true;
    stopComposite.setLayout(rl);
    stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    stopDate.addListener(SWT.Selection, e -> validate());
    stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    stopTime.addListener(SWT.Selection, e -> validate());
    if (stopTimeValue != null) {
        stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
        stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
    }
    stopDate.setVisible(stopClosedValue);
    stopTime.setVisible(stopClosedValue);
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) DateTime(org.eclipse.swt.widgets.DateTime)

Example 27 with DateTime

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

the class ImportPastEventsDialog method createDialogArea.

@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 = 2;
    container.setLayout(layout);
    Label lbl = new Label(container, SWT.NONE);
    lbl.setText("Start:");
    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);
    startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    startDate.addListener(SWT.Selection, e -> validate());
    startDate.addListener(SWT.FocusOut, e -> validate());
    startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    startTime.addListener(SWT.Selection, e -> validate());
    startTime.addListener(SWT.FocusOut, e -> validate());
    if (startTimeValue != null) {
        startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
        startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
    }
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Stop:");
    Composite stopComposite = new Composite(container, SWT.NONE);
    rl = new RowLayout();
    rl.marginLeft = 0;
    rl.marginTop = 0;
    rl.marginBottom = 0;
    rl.center = true;
    rl.fill = true;
    stopComposite.setLayout(rl);
    stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    stopDate.addListener(SWT.Selection, e -> validate());
    stopDate.addListener(SWT.FocusOut, e -> validate());
    stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    stopTime.addListener(SWT.Selection, e -> validate());
    stopTime.addListener(SWT.FocusOut, e -> validate());
    if (stopTimeValue != null) {
        stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
        stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
    }
    return container;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) 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