Search in sources :

Example 21 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_setForegroundAlphaTimeDateTime.

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

Example 22 with DateTime

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

the class ImportPastCommandsDialog 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());
    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));
    }
    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());
    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));
    }
    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)

Example 23 with DateTime

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

the class ArchiveView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
    seekImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/seek.png"));
    playImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/play.png"));
    pauseImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/pause.png"));
    forwardImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward.png"));
    forward2xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward2x.png"));
    forward4xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward4x.png"));
    forward8xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward8x.png"));
    forward16xImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/forward16x.png"));
    leaveReplayImage = resourceManager.createImage(RCPUtils.getImageDescriptor(ArchiveView.class, "icons/redo.png"));
    createActions();
    indexReceiver = new ArchiveIndexReceiver();
    parent.setLayout(new FillLayout());
    Composite contentArea = new Composite(parent, SWT.NONE);
    contentArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout gl = new GridLayout();
    gl.marginWidth = 0;
    gl.marginHeight = 0;
    contentArea.setLayout(gl);
    Composite locationComp = new Composite(contentArea, SWT.EMBEDDED);
    locationComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    java.awt.Frame frame = SWT_AWT.new_Frame(locationComp);
    archivePanel = new ArchivePanel(this);
    archivePanel.setPreferredSize(new Dimension(300, 400));
    frame.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            archivePanel.onWindowResized();
        }
    });
    frame.add(archivePanel);
    replayComposite = new Composite(contentArea, SWT.NONE);
    replayCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    replayComposite.setLayoutData(replayCompositeGridData);
    gl = new GridLayout(4, false);
    gl.marginHeight = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    replayComposite.setLayout(gl);
    // current time / jump date / jump time / jump button
    Composite timeComposite = new Composite(replayComposite, SWT.NONE);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.LEFT;
    // gd.widthHint = 140;
    // gd.grabExcessHorizontalSpace = true;
    timeComposite.setLayoutData(gd);
    gl = new GridLayout(4, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    timeComposite.setLayout(gl);
    replayTimeLabel = new Label(timeComposite, SWT.NONE);
    FontData[] fd = replayTimeLabel.getFont().getFontData();
    fd[0].setHeight(fd[0].getHeight() - 2);
    // TODO dispose this font!
    replayTimeLabel.setFont(new Font(parent.getDisplay(), fd));
    // ugh...
    replayTimeLabel.setText("                             ");
    seekDate = new DateTime(timeComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
    seekTime = new DateTime(timeComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    seekButton = new Button(timeComposite, SWT.PUSH);
    seekButton.setImage(seekImage);
    seekButton.setToolTipText("Seek Specified Time");
    seekButton.addListener(SWT.Selection, evt -> {
        long seekInstant = TimeEncoding.fromCalendar(RCPUtils.toCalendar(seekDate, seekTime));
        archivePanel.seekReplay(seekInstant);
    });
    // play / pause / forward
    Composite controlsComposite = new Composite(replayComposite, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.CENTER;
    gd.grabExcessHorizontalSpace = true;
    controlsComposite.setLayoutData(gd);
    gl = new GridLayout(3, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    gl.verticalSpacing = 0;
    gl.horizontalSpacing = 0;
    controlsComposite.setLayout(gl);
    playButton = new Button(controlsComposite, SWT.PUSH);
    playButton.setImage(playImage);
    playButton.setToolTipText("Play");
    playButton.addListener(SWT.Selection, evt -> {
        if (playButton.getImage().equals(playImage))
            RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.playCommand");
        else
            RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.pauseCommand");
    });
    forwardButton = new Button(controlsComposite, SWT.PUSH);
    forwardButton.setImage(forwardImage);
    forwardButton.setToolTipText("Forward");
    forwardButton.addListener(SWT.Selection, evt -> {
        RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.forwardCommand");
    });
    Composite buttonWrapper = new Composite(replayComposite, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.widthHint = 140;
    buttonWrapper.setLayoutData(gd);
    gl = new GridLayout();
    gl.horizontalSpacing = 0;
    gl.verticalSpacing = 0;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    buttonWrapper.setLayout(gl);
    leaveReplayButton = new Button(buttonWrapper, SWT.PUSH);
    leaveReplayButton.setImage(leaveReplayImage);
    leaveReplayButton.setToolTipText("Back to Realtime");
    leaveReplayButton.addListener(SWT.Selection, evt -> {
        RCPUtils.runCommand("org.yamcs.studio.core.ui.processor.leaveReplay");
    });
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    buttonWrapper.setLayoutData(gd);
    ISourceProviderService service = (ISourceProviderService) getSite().getService(ISourceProviderService.class);
    processorState = (ProcessorStateProvider) service.getSourceProvider(ProcessorStateProvider.STATE_KEY_PROCESSING);
    processorState.addSourceProviderListener(this);
    connectionState = (ConnectionStateProvider) service.getSourceProvider(ConnectionStateProvider.STATE_KEY_CONNECTED);
    connectionState.addSourceProviderListener(this);
    indexReceiver.setIndexListener(this);
    TimeCatalogue.getInstance().addTimeListener(this);
    YamcsPlugin.getDefault().addYamcsConnectionListener(this);
    ManagementCatalogue.getInstance().addInstanceListener(this);
    updateState();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) FontData(org.eclipse.swt.graphics.FontData) Label(org.eclipse.swt.widgets.Label) ResourceManager(org.eclipse.jface.resource.ResourceManager) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) FillLayout(org.eclipse.swt.layout.FillLayout) Dimension(java.awt.Dimension) Font(org.eclipse.swt.graphics.Font) DateTime(org.eclipse.swt.widgets.DateTime) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter) ISourceProviderService(org.eclipse.ui.services.ISourceProviderService)

Example 24 with DateTime

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

the class CreateAnnotationDialog 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("Name");
    Composite tagAndColorWrapper = new Composite(container, SWT.NONE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    tagAndColorWrapper.setLayoutData(gd);
    GridLayout gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    tagAndColorWrapper.setLayout(gl);
    tag = new Text(tagAndColorWrapper, SWT.BORDER);
    tag.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tag.setText(tagValue);
    // Some ugly tricks to get a border around a label, which should have been a button in the first place
    // but at least OSX doesn't support buttons with custom backgrounds. May be getting time to draw GC ourselves..
    Composite labelBorder = new Composite(tagAndColorWrapper, SWT.BORDER);
    labelBorder.setLayout(new FillLayout());
    colorSelector = new Label(labelBorder, SWT.NONE);
    colorSelector.setText("         ");
    colorSelector.setCursor(handCursor);
    colorSelector.setBackground(resourceManager.createColor(colorValue));
    colorSelector.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            ColorDialog colorDialog = new ColorDialog(colorSelector.getShell());
            colorDialog.setRGB(colorSelector.getBackground().getRGB());
            RGB newColor = colorDialog.open();
            if (newColor != null)
                colorSelector.setBackground(resourceManager.createColor(newColor));
        }
    });
    lbl = new Label(container, SWT.NONE);
    lbl.setText("Description");
    gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    lbl.setLayoutData(gd);
    description = new Text(container, SWT.MULTI | SWT.BORDER);
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = description.getLineHeight() * 3;
    description.setLayoutData(gd);
    description.setText(descriptionValue);
    Composite startLabelWrapper = new Composite(container, SWT.NONE);
    gl = new GridLayout(2, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    startLabelWrapper.setLayout(gl);
    lbl = new Label(startLabelWrapper, SWT.NONE);
    lbl.setText("Start");
    startClosed = new Button(startLabelWrapper, SWT.CHECK | SWT.NONE);
    startClosed.setSelection(true);
    startClosed.addListener(SWT.Selection, e -> {
        startDate.setVisible(startClosed.getSelection());
        startTime.setVisible(startClosed.getSelection());
        validate();
    });
    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));
    }
    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.setSelection(true);
    stopClosed.addListener(SWT.Selection, e -> {
        stopDate.setVisible(stopClosed.getSelection());
        stopTime.setVisible(stopClosed.getSelection());
        validate();
    });
    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));
    }
    return container;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) RGB(org.eclipse.swt.graphics.RGB) DateTime(org.eclipse.swt.widgets.DateTime) GridLayout(org.eclipse.swt.layout.GridLayout) ColorDialog(org.eclipse.swt.widgets.ColorDialog) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData)

Example 25 with DateTime

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

the class CreateReplayDialog 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 At:");
    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);
    startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
    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("Name:");
    name = new Text(container, SWT.BORDER);
    name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    name.setText(nameValue);
    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) Text(org.eclipse.swt.widgets.Text) 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