Example usage for org.eclipse.swt.widgets Label setLayoutData

List of usage examples for org.eclipse.swt.widgets Label setLayoutData

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Label setLayoutData.

Prototype

public void setLayoutData(Object layoutData) 

Source Link

Document

Sets the layout data associated with the receiver to the argument.

Usage

From source file:org.mwc.debrief.dis.views.DisListenerView.java

@Override
public void createPartControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    composite.setLayoutData(gd);//ww w  . j a  v a 2 s  . c o m
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);

    Composite buttonComposite = new Composite(composite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.widthHint = 300;
    buttonComposite.setLayoutData(gd);
    layout = new GridLayout(4, false);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    buttonComposite.setLayout(layout);

    connectButton = createButton(buttonComposite, "Connect", 2);
    connectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME connect
        }

    });
    disconnectButton = createButton(buttonComposite, "Disconnect", 2);
    disconnectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME disconnect
        }

    });

    final Link link = new Link(buttonComposite, SWT.NONE);
    gd = new GridData(SWT.END, SWT.FILL, false, false);
    gd.horizontalSpan = 4;
    link.setLayoutData(gd);
    link.setText("<a href=\"id\">Server Prefs</a>");
    link.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(link.getShell(), DisPrefs.ID,
                    null, null);
            dialog.open();
        }
    });
    link.setToolTipText("Dis Preferences");

    stopButton = createButton(buttonComposite, "Stop");
    stopButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME stop
        }

    });

    pauseButton = createButton(buttonComposite, "Pause");
    pauseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME pause
        }

    });

    resumeButton = createButton(buttonComposite, "Resume");
    resumeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME resume
        }

    });

    playButton = createButton(buttonComposite, "Play");
    playButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME play
        }

    });

    stopButton.setEnabled(false);
    pauseButton.setEnabled(false);
    resumeButton.setEnabled(false);
    disconnectButton.setEnabled(false);

    Label label = new Label(buttonComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    label.setLayoutData(gd);
    label.setText("Path to input file:");

    Text text = new Text(buttonComposite, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    gd.horizontalSpan = 2;
    gd.widthHint = 150;
    text.setLayoutData(gd);

    final Button browseButton = new Button(buttonComposite, SWT.PUSH);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    browseButton.setLayoutData(gd);
    browseButton.setText("Browse...");
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getSite().getShell(), SWT.SINGLE);
            String value = pathText.getText();
            if (value.trim().length() == 0) {
                value = Platform.getLocation().toOSString();
            }
            dialog.setFilterPath(value);

            String result = dialog.open();
            if (result == null || result.trim().length() == 0) {
                return;
            }
            pathText.setText(result);

        }

    });

    Composite chartWrapperComposite = new Composite(composite, SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    chartWrapperComposite.setLayoutData(gd);
    layout = new GridLayout(1, false);
    chartWrapperComposite.setLayout(layout);

    chartComposite = new ChartComposite(chartWrapperComposite, SWT.NONE, null, 400, 600, 300, 200, 1800, 1800,
            true, true, true, true, true, true) {
        @Override
        public void mouseUp(MouseEvent event) {
            super.mouseUp(event);
            JFreeChart c = getChart();
            if (c != null) {
                c.setNotify(true); // force redraw
            }
        }
    };

    Composite checkboxComposite = new Composite(composite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    checkboxComposite.setLayoutData(gd);
    layout = new GridLayout(2, false);
    layout.marginWidth = 5;
    layout.marginHeight = 5;
    checkboxComposite.setLayout(layout);

    newPlotButton = new Button(checkboxComposite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    newPlotButton.setLayoutData(gd);
    newPlotButton.setText("New plot per replication");
    newPlotButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME new plot ...
        }

    });
    liveUpdatesButton = new Button(checkboxComposite, SWT.CHECK);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    liveUpdatesButton.setLayoutData(gd);
    liveUpdatesButton.setText("Live updates");
    liveUpdatesButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // FIXME Live updates.
        }

    });
    liveUpdatesButton.setSelection(true);

}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.DistributionView.java

private void addOptionConfiguration(DistributionChartOptionConfigData config) {
    assert (config != null);
    assert (config.getAttributes() != null);

    if (config.getAttributes().getData().size() == 0) {
        return;/*  w w w .  ja  va2s  . co m*/
    }

    if (optionCount > 0) {
        Helper.separator(optionComposite, 3);
    }

    ChartIdentifier identifier = new ChartIdentifier(config.getConfig(), optionCount);
    identifiers.add(identifier);

    Label lblTitle = new Label(optionComposite, SWT.NONE);
    lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Helper.setLabelStyle(lblTitle, SWT.BOLD);
    lblTitle.setText(config.getName());

    Iterator<DropDownData> filterIter = config.getFilter().iterator();
    if (filterIter.hasNext()) {
        Combo filterCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
        filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        fillCombo(filterCombo, filterIter.next(), identifier);
        identifier.filter.add(filterCombo);
    } else {
        new Label(optionComposite, SWT.NONE);
    }

    Combo attCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    fillAttributeCombo(attCombo, config.getAttributes(), identifier);
    attCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    identifier.attributes = attCombo;

    while (filterIter.hasNext()) {
        new Label(optionComposite, SWT.NONE);
        Combo filterCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
        filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        new Label(optionComposite, SWT.NONE);

        fillCombo(filterCombo, filterIter.next(), identifier);
        identifier.filter.add(filterCombo);
    }

    identifier.paint = drawingSupplier.getNextPaint();
    optionCount++;
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.DistributionChart.java

private void addOptionConfiguration(DistributionChartOptionConfigData config, List<String> flags) {
    assert (config != null);
    assert (config.getAttributes() != null);

    if (config.getAttributes().getData().size() == 0) {
        return;//from w w  w  .ja  va 2  s . co  m
    }

    if (optionCount > 0) {
        Helper.separator(optionComposite, 3);
    }

    ChartIdentifier identifier = new ChartIdentifier(config.getConfig(), optionCount);
    identifiers.add(identifier);

    Label lblTitle = new Label(optionComposite, SWT.NONE);
    lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    Helper.setLabelStyle(lblTitle, SWT.BOLD);
    lblTitle.setText(config.getName());

    DropDownData firstDropdownData = null;
    Iterator<DropDownData> filterIter = config.getFilter().iterator();
    while (filterIter.hasNext()) {
        DropDownData data = filterIter.next();
        if (data.getConfig().show(flags)) {
            firstDropdownData = data;
            break;
        }
    }

    if (firstDropdownData != null) {
        Combo filterCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
        filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        fillCombo(filterCombo, firstDropdownData, identifier);
        identifier.filter.add(filterCombo);
    } else {
        new Label(optionComposite, SWT.NONE);
    }

    Combo attCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    fillAttributeCombo(attCombo, config.getAttributes(), flags, identifier);
    attCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    identifier.attributes = attCombo;

    while (filterIter.hasNext()) {
        DropDownData iterValue = filterIter.next();
        if (iterValue.getConfig().show(flags)) {
            new Label(optionComposite, SWT.NONE);
            Combo filterCombo = new Combo(optionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
            filterCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
            new Label(optionComposite, SWT.NONE);

            fillCombo(filterCombo, iterValue, identifier);
            identifier.filter.add(filterCombo);
        }
    }

    identifier.paint = drawingSupplier.getNextPaint();
    optionCount++;
}

From source file:org.gumtree.vis.plot1d.Plot1D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;/*from w  w  w . ja v  a  2  s .  c  o  m*/
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYChartMouseEvent) event).getY());
                //                  panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (!composite.isFocusControl()) {
                        composite.setFocus();
                    }
                }
            });
        }
    });
}

From source file:BrowserExample.java

/**
 * Creates an instance of a ControlExample embedded inside the supplied
 * parent Composite./*from  w  w  w .j ava  2 s . c  om*/
 * 
 * @param parent
 *            the container of the example
 */
public BrowserExample(Composite parent) {

    final Display display = parent.getDisplay();
    FormLayout layout = new FormLayout();
    parent.setLayout(layout);
    ToolBar toolbar = new ToolBar(parent, SWT.NONE);
    final ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
    itemBack.setText(getResourceString("Back"));
    final ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
    itemForward.setText(getResourceString("Forward"));
    final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
    itemStop.setText(getResourceString("Stop"));
    final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
    itemRefresh.setText(getResourceString("Refresh"));
    final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
    itemGo.setText(getResourceString("Go"));

    location = new Text(parent, SWT.BORDER);

    images = new Image[] { new Image(display, "java2s.gif") };

    final Canvas canvas = new Canvas(parent, SWT.NO_BACKGROUND);
    final Rectangle rect = images[0].getBounds();
    canvas.addListener(SWT.Paint, new Listener() {
        public void handleEvent(Event e) {
            Point pt = canvas.getSize();
            e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
        }
    });
    canvas.addListener(SWT.MouseDown, new Listener() {
        public void handleEvent(Event e) {
            browser.setUrl(getResourceString("Startup"));
        }
    });

    display.asyncExec(new Runnable() {
        public void run() {
            if (canvas.isDisposed())
                return;
            if (busy) {
                index++;
                if (index == images.length)
                    index = 0;
                canvas.redraw();
            }
            display.timerExec(150, this);
        }
    });

    final Label status = new Label(parent, SWT.NONE);
    final ProgressBar progressBar = new ProgressBar(parent, SWT.NONE);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 5);
    toolbar.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(canvas, 5, SWT.DEFAULT);
    data.bottom = new FormAttachment(status, -5, SWT.DEFAULT);
    try {
        browser = new Browser(parent, SWT.NONE);
        browser.setLayoutData(data);
    } catch (SWTError e) {
        /* Browser widget could not be instantiated */
        Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
        label.setText(getResourceString("BrowserNotCreated"));
        label.setLayoutData(data);
    }

    data = new FormData();
    data.width = 24;
    data.height = 24;
    data.top = new FormAttachment(0, 5);
    data.right = new FormAttachment(100, -5);
    canvas.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(toolbar, 0, SWT.TOP);
    data.left = new FormAttachment(toolbar, 5, SWT.RIGHT);
    data.right = new FormAttachment(canvas, -5, SWT.DEFAULT);
    location.setLayoutData(data);

    data = new FormData();
    data.left = new FormAttachment(0, 5);
    data.right = new FormAttachment(progressBar, 0, SWT.DEFAULT);
    data.bottom = new FormAttachment(100, -5);
    status.setLayoutData(data);

    data = new FormData();
    data.right = new FormAttachment(100, -5);
    data.bottom = new FormAttachment(100, -5);
    progressBar.setLayoutData(data);

    if (browser != null) {
        itemBack.setEnabled(browser.isBackEnabled());
        itemForward.setEnabled(browser.isForwardEnabled());

        Listener listener = new Listener() {
            public void handleEvent(Event event) {
                ToolItem item = (ToolItem) event.widget;
                if (item == itemBack)
                    browser.back();
                else if (item == itemForward)
                    browser.forward();
                else if (item == itemStop)
                    browser.stop();
                else if (item == itemRefresh)
                    browser.refresh();
                else if (item == itemGo)
                    browser.setUrl(location.getText());
            }
        };
        browser.addLocationListener(new LocationListener() {
            public void changed(LocationEvent event) {
                busy = true;
                if (event.top)
                    location.setText(event.location);
            }

            public void changing(LocationEvent event) {
            }
        });
        browser.addProgressListener(new ProgressListener() {
            public void changed(ProgressEvent event) {
                if (event.total == 0)
                    return;
                int ratio = event.current * 100 / event.total;
                progressBar.setSelection(ratio);
                busy = event.current != event.total;
                if (!busy) {
                    index = 0;
                    canvas.redraw();
                }
            }

            public void completed(ProgressEvent event) {
                itemBack.setEnabled(browser.isBackEnabled());
                itemForward.setEnabled(browser.isForwardEnabled());
                progressBar.setSelection(0);
                busy = false;
                index = 0;
                canvas.redraw();
            }
        });
        browser.addStatusTextListener(new StatusTextListener() {
            public void changed(StatusTextEvent event) {
                status.setText(event.text);
            }
        });
        if (parent instanceof Shell) {
            final Shell shell = (Shell) parent;
            browser.addTitleListener(new TitleListener() {
                public void changed(TitleEvent event) {
                    shell.setText(event.title + " - " + getResourceString("window.title"));
                }
            });
        }
        itemBack.addListener(SWT.Selection, listener);
        itemForward.addListener(SWT.Selection, listener);
        itemStop.addListener(SWT.Selection, listener);
        itemRefresh.addListener(SWT.Selection, listener);
        itemGo.addListener(SWT.Selection, listener);
        location.addListener(SWT.DefaultSelection, new Listener() {
            public void handleEvent(Event e) {
                browser.setUrl(location.getText());
            }
        });

        initialize(display, browser);
        browser.setUrl(getResourceString("Startup"));
    }
}

From source file:org.eclipse.swt.examples.ole.win32.OleBrowserView.java

/**
 * Creates the Web browser toolbar.//from ww w .  j  a v a  2s . c o m
 */
private void createToolbar() {
    // Add a toolbar
    ToolBar bar = new ToolBar(displayArea, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    bar.setLayoutData(gridData);

    // Add a button to navigate backwards through previously visited web sites
    webCommandBackward = new ToolItem(bar, SWT.NONE);
    webCommandBackward.setToolTipText(OlePlugin.getResourceString("browser.Back.tooltip"));
    webCommandBackward.setText(OlePlugin.getResourceString("browser.Back.text"));
    webCommandBackward.setImage(OlePlugin.images[OlePlugin.biBack]);
    webCommandBackward.setEnabled(false);
    webCommandBackward.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoBack();
    });

    // Add a button to navigate forward through previously visited web sites
    webCommandForward = new ToolItem(bar, SWT.NONE);
    webCommandForward.setToolTipText(OlePlugin.getResourceString("browser.Forward.tooltip"));
    webCommandForward.setText(OlePlugin.getResourceString("browser.Forward.text"));
    webCommandForward.setImage(OlePlugin.images[OlePlugin.biForward]);
    webCommandForward.setEnabled(false);
    webCommandForward.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoForward();
    });

    // Add a separator
    new ToolItem(bar, SWT.SEPARATOR);

    // Add a button to navigate to the Home page
    webCommandHome = new ToolItem(bar, SWT.NONE);
    webCommandHome.setToolTipText(OlePlugin.getResourceString("browser.Home.tooltip"));
    webCommandHome.setText(OlePlugin.getResourceString("browser.Home.text"));
    webCommandHome.setImage(OlePlugin.images[OlePlugin.biHome]);
    webCommandHome.setEnabled(false);
    webCommandHome.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoHome();
    });

    // Add a button to abort web page loading
    webCommandStop = new ToolItem(bar, SWT.NONE);
    webCommandStop.setToolTipText(OlePlugin.getResourceString("browser.Stop.tooltip"));
    webCommandStop.setText(OlePlugin.getResourceString("browser.Stop.text"));
    webCommandStop.setImage(OlePlugin.images[OlePlugin.biStop]);
    webCommandStop.setEnabled(false);
    webCommandStop.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.Stop();
    });

    // Add a button to refresh the current web page
    webCommandRefresh = new ToolItem(bar, SWT.NONE);
    webCommandRefresh.setToolTipText(OlePlugin.getResourceString("browser.Refresh.tooltip"));
    webCommandRefresh.setText(OlePlugin.getResourceString("browser.Refresh.text"));
    webCommandRefresh.setImage(OlePlugin.images[OlePlugin.biRefresh]);
    webCommandRefresh.setEnabled(false);
    webCommandRefresh.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.Refresh();
    });

    // Add a separator
    new ToolItem(bar, SWT.SEPARATOR);

    // Add a button to search the web
    webCommandSearch = new ToolItem(bar, SWT.NONE);
    webCommandSearch.setToolTipText(OlePlugin.getResourceString("browser.Search.tooltip"));
    webCommandSearch.setText(OlePlugin.getResourceString("browser.Search.text"));
    webCommandSearch.setImage(OlePlugin.images[OlePlugin.biSearch]);
    webCommandSearch.setEnabled(false);
    webCommandSearch.addListener(SWT.Selection, e -> {
        if (webBrowser == null)
            return;
        webBrowser.GoSearch();
    });

    // Add a text area for Users to enter a url
    Composite addressBar = new Composite(displayArea, SWT.NONE);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    gridData.horizontalSpan = 3;
    addressBar.setLayoutData(gridData);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    addressBar.setLayout(gridLayout);

    Label addressLabel = new Label(addressBar, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    addressLabel.setLayoutData(gridData);
    addressLabel.setText(OlePlugin.getResourceString("browser.Address.label"));
    addressLabel.setFont(OlePlugin.browserFont);

    webUrl = new Text(addressBar, SWT.SINGLE | SWT.BORDER);
    webUrl.setFont(OlePlugin.browserFont);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    webUrl.setLayoutData(gridData);
    webUrl.addFocusListener(FocusListener
            .focusGainedAdapter(e -> webNavigateButton.getShell().setDefaultButton(webNavigateButton)));

    // Add a button to navigate to the web site specified in the Text area defined above
    webNavigateButton = new Button(addressBar, SWT.PUSH);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    webNavigateButton.setLayoutData(gridData);
    webNavigateButton.setText(OlePlugin.getResourceString("browser.Go.text"));
    webNavigateButton.setFont(OlePlugin.browserFont);
    webNavigateButton.addListener(SWT.Selection, event -> {
        if (webBrowser == null)
            return;
        webBrowser.Navigate(webUrl.getText());
    });
}

From source file:org.gumtree.vis.hist2d.Hist2D.java

private void createStatusBar() {
    Composite statusComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(6, false);
    layout.marginLeft = 6;/*w  ww .  j a v  a2 s. c o  m*/
    layout.marginRight = 6;
    layout.marginTop = 1;
    layout.marginBottom = 1;
    layout.horizontalSpacing = 3;
    layout.verticalSpacing = 1;
    statusComposite.setLayout(layout);

    GridData gridData = new GridData(SWT.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = false;
    statusComposite.setLayoutData(gridData);

    final Label xLabel = new Label(statusComposite, SWT.NONE);
    xLabel.setText("X:");
    gridData = new GridData(SWT.DEFAULT);
    xLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(xLabel);
    final Text xText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    xText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(xText);
    xText.setEditable(false);

    final Label yLabel = new Label(statusComposite, SWT.NONE);
    yLabel.setText("Y:");
    gridData = new GridData(SWT.DEFAULT);
    yLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(yLabel);
    final Text yText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    yText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(yText);
    yText.setEditable(false);

    final Label zLabel = new Label(statusComposite, SWT.NONE);
    zLabel.setText("Z:");
    gridData = new GridData(SWT.DEFAULT);
    zLabel.setLayoutData(gridData);
    //      GridDataFactory.swtDefaults().applyTo(zLabel);
    final Text zText = new Text(statusComposite, SWT.BORDER);
    gridData = new GridData(SWT.FILL);
    gridData.widthHint = 50;
    zText.setLayoutData(gridData);
    //      GridDataFactory.fillDefaults().hint(50, SWT.DEFAULT).applyTo(zText);
    zText.setEditable(false);

    final Composite composite = this;
    panel.addChartMouseListener(new ChartMouseListener() {

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            if (event instanceof XYZChartMouseEvent) {
                final String xString = String.format("%.2f", ((XYZChartMouseEvent) event).getX());
                final String yString = String.format("%.2f", ((XYZChartMouseEvent) event).getY());
                final String zString = String.format("%.2f", ((XYZChartMouseEvent) event).getZ());
                panel.requestFocus();

                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        xText.setText(xString);
                        yText.setText(yString);
                        zText.setText(zString);
                        if (!composite.isFocusControl()) {
                            composite.setFocus();
                        }
                    }
                });
            }
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:org.eclipse.swt.examples.graphics.GradientDialog.java

/**
 * Creates the controls of the dialog.// ww  w. ja  v  a  2s  . c om
 * */
public void createDialogControls(final Shell parent) {
    final Display display = parent.getDisplay();

    // message
    Label message = new Label(parent, SWT.NONE);
    message.setText(GraphicsExample.getResourceString("GradientDlgMsg"));
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    message.setLayoutData(gridData);

    // default colors are white and black
    if (rgb1 == null || rgb2 == null) {
        rgb1 = display.getSystemColor(SWT.COLOR_WHITE).getRGB();
        rgb2 = display.getSystemColor(SWT.COLOR_BLACK).getRGB();
    }

    // canvas
    canvas = new Canvas(parent, SWT.NONE);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = 200;
    gridData.heightHint = 100;
    canvas.setLayoutData(gridData);
    canvas.addListener(SWT.Paint, e -> {
        Image preview = null;
        Point size = canvas.getSize();
        Color color1 = new Color(display, rgb1);
        Color color2 = new Color(display, rgb2);
        preview = GraphicsExample.createImage(display, color1, color2, size.x, size.y);
        if (preview != null) {
            e.gc.drawImage(preview, 0, 0);
        }
        preview.dispose();
        color1.dispose();
        color2.dispose();
    });

    // composite used for both color buttons
    Composite colorButtonComp = new Composite(parent, SWT.NONE);

    // layout buttons
    RowLayout layout = new RowLayout();
    layout.type = SWT.VERTICAL;
    layout.pack = false;
    colorButtonComp.setLayout(layout);

    // position composite
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    colorButtonComp.setLayoutData(gridData);

    ColorMenu colorMenu = new ColorMenu();

    // color controls: first color
    colorButton1 = new Button(colorButtonComp, SWT.PUSH);
    colorButton1.setText(GraphicsExample.getResourceString("GradientDlgButton1"));
    Color color1 = new Color(display, rgb1);
    Image img1 = GraphicsExample.createImage(display, color1);
    color1.dispose();
    colorButton1.setImage(img1);
    resources.add(img1);
    menu1 = colorMenu.createMenu(parent.getParent(), gb -> {
        rgb1 = gb.getBgColor1().getRGB();
        colorButton1.setImage(gb.getThumbNail());
        if (canvas != null)
            canvas.redraw();
    });
    colorButton1.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu1.setLocation(point.x, point.y + bounds.height);
        menu1.setVisible(true);
    });

    // color controls: second color
    colorButton2 = new Button(colorButtonComp, SWT.PUSH);
    colorButton2.setText(GraphicsExample.getResourceString("GradientDlgButton2"));
    Color color2 = new Color(display, rgb2);
    Image img2 = GraphicsExample.createImage(display, color2);
    color2.dispose();
    colorButton2.setImage(img2);
    resources.add(img2);
    menu2 = colorMenu.createMenu(parent.getParent(), gb -> {
        rgb2 = gb.getBgColor1().getRGB();
        colorButton2.setImage(gb.getThumbNail());
        if (canvas != null)
            canvas.redraw();
    });
    colorButton2.addListener(SWT.Selection, event -> {
        final Button button = (Button) event.widget;
        final Composite parent1 = button.getParent();
        Rectangle bounds = button.getBounds();
        Point point = parent1.toDisplay(new Point(bounds.x, bounds.y));
        menu2.setLocation(point.x, point.y + bounds.height);
        menu2.setVisible(true);
    });

    // composite used for ok and cancel buttons
    Composite okCancelComp = new Composite(parent, SWT.NONE);

    // layout buttons
    RowLayout rowLayout = new RowLayout();
    rowLayout.pack = false;
    rowLayout.marginTop = 5;
    okCancelComp.setLayout(rowLayout);

    // position composite
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gridData.horizontalSpan = 2;
    okCancelComp.setLayoutData(gridData);

    // OK button
    okButton = new Button(okCancelComp, SWT.PUSH);
    okButton.setText("&OK");
    okButton.addListener(SWT.Selection, event -> {
        returnVal = SWT.OK;
        parent.close();
    });

    // cancel button
    cancelButton = new Button(okCancelComp, SWT.PUSH);
    cancelButton.setText("&Cancel");
    cancelButton.addListener(SWT.Selection, event -> parent.close());
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendView.java

public void addConfiguration(TrendChartConfigData config) {
    assert (config != null);

    LinkedList<Combo> combos = new LinkedList<Combo>();

    // Title Row:
    Label lblGrpTitle = new Label(optionComposite, SWT.NONE);
    lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Helper.setLabelStyle(lblGrpTitle, SWT.BOLD);
    lblGrpTitle.setText(config.getName());

    Composite topOptions = new Composite(optionComposite, SWT.NONE);
    topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true));

    for (DropDownData dropData : config.getDropDowns()) {
        Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
        comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
        comboDropDown.setData(dropData);
        combos.add(comboDropDown);//from   w  ww  . ja v a2 s .co m

        for (DropDownData.Pair data : dropData.getData()) {
            comboDropDown.add(data.name);
        }

        comboDropDown.select(0);

        comboDropDown.addSelectionListener(this.comboListener);
    }

    // Separator:
    Helper.separator(optionComposite, 3);

    // Left Option Labels:
    new Label(optionComposite, SWT.NONE);

    Composite leftOptions = new Composite(optionComposite, SWT.NONE);
    leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    leftOptions.setLayout(new GridLayout(1, true));
    for (OptionListConfigData.Pair pair : config.getOptionList().getData()) {
        Label lblOpt = new Label(leftOptions, SWT.NONE);
        lblOpt.setText(pair.name);
    }

    // Check Boxes:
    Composite selectionComposite = new Composite(optionComposite, SWT.NONE);
    selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    selectionComposite.setLayout(new GridLayout(combos.size(), true));

    OptionListConfig leftConfig = config.getOptionList().getConfig();
    int x = 0;

    for (Combo combo : combos) {
        TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig();

        for (OptionListConfigData.Pair pair : config.getOptionList().getData()) {
            Button button = new Button(selectionComposite, SWT.CHECK);
            button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
            button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++));
            button.addSelectionListener(boxListener);
        }

        x++;
    }

    // Scrolling area size update:
    scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}

From source file:at.ac.tuwien.inso.subcat.ui.widgets.TrendChart.java

public void addConfiguration(TrendChartConfigData config, List<String> flags) {
    assert (config != null);

    ArrayList<Combo> combos = new ArrayList<Combo>();

    // Title Row:
    Label lblGrpTitle = new Label(optionComposite, SWT.NONE);
    lblGrpTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Helper.setLabelStyle(lblGrpTitle, SWT.BOLD);
    lblGrpTitle.setText(config.getName());

    Composite topOptions = new Composite(optionComposite, SWT.NONE);
    topOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    topOptions.setLayout(new GridLayout(config.getDropDowns().size(), true));

    for (DropDownData dropData : config.getDropDowns()) {
        if (dropData.getConfig().show(flags)) {
            Combo comboDropDown = new Combo(topOptions, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
            comboDropDown.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
            comboDropDown.setData(dropData);
            combos.add(comboDropDown);/*from   www . j  a  v  a  2 s.  c  o  m*/

            for (DropDownData.Pair data : dropData.getData()) {
                comboDropDown.add(data.name);
            }

            comboDropDown.select(0);

            comboDropDown.addSelectionListener(this.comboListener);
        }
    }

    // Separator:
    Helper.separator(optionComposite, 3);

    // Left Option Labels:
    new Label(optionComposite, SWT.NONE);

    Composite leftOptions = new Composite(optionComposite, SWT.NONE);
    leftOptions.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));

    leftOptions.setLayout(new GridLayout(1, true));
    for (OptionListConfigData.Pair pair : config.getOptionList().getData()) {
        Label lblOpt = new Label(leftOptions, SWT.NONE);
        lblOpt.setText(pair.name);
    }

    // Check Boxes:
    Composite selectionComposite = new Composite(optionComposite, SWT.NONE);
    selectionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    selectionComposite.setLayout(new GridLayout(combos.size(), true));

    OptionListConfig leftConfig = config.getOptionList().getConfig();

    for (OptionListConfigData.Pair pair : config.getOptionList().getData()) {
        int x = 0;
        for (Combo combo : combos) {
            TrendChartPlotConfig topConfig = (TrendChartPlotConfig) config.getDropDowns().get(x).getConfig();

            Button button = new Button(selectionComposite, SWT.CHECK);
            button.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
            button.setData(new ChartIdentifier(topConfig, combo, leftConfig, pair.id, boxWeight++));
            button.addSelectionListener(boxListener);
            x++;
        }
    }

    // Scrolling area size update:
    scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}