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

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

Introduction

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

Prototype

public Label(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:org.eclipse.swt.examples.clipboard.ClipboardExample.java

void createRTFTransfer(Composite copyParent, Composite pasteParent) {
    //   RTF Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("RTFTransfer:"); //$NON-NLS-1$
    final Text copyRtfText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyRtfText.setText("some\nrtf\ntext");
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = HSIZE;//from   w  w w . j  ava2 s.c o  m
    data.heightHint = VSIZE;
    copyRtfText.setLayoutData(data);
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        String textData = copyRtfText.getText();
        if (textData.length() > 0) {
            status.setText("");
            StringBuilder buffer = new StringBuilder();
            buffer.append("{\\rtf1\\ansi\\uc1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i ");
            for (int i = 0; i < textData.length(); i++) {
                char ch = textData.charAt(i);
                if (ch > 0xFF) {
                    buffer.append("\\u");
                    buffer.append(Integer.toString((short) ch));
                    buffer.append('?');
                } else {
                    if (ch == '}' || ch == '{' || ch == '\\') {
                        buffer.append('\\');
                    }
                    buffer.append(ch);
                    if (ch == '\n')
                        buffer.append("\\par ");
                    if (ch == '\r' && (i - 1 == textData.length() || textData.charAt(i + 1) != '\n')) {
                        buffer.append("\\par ");
                    }
                }
            }
            buffer.append("}");
            clipboard.setContents(new Object[] { buffer.toString() },
                    new Transfer[] { RTFTransfer.getInstance() });
        } else {
            status.setText("No RTF to copy");
        }
    }));

    l = new Label(pasteParent, SWT.NONE);
    l.setText("RTFTransfer:"); //$NON-NLS-1$
    final Text pasteRtfText = new Text(pasteParent,
            SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = HSIZE;
    data.heightHint = VSIZE;
    pasteRtfText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        String textData = (String) clipboard.getContents(RTFTransfer.getInstance());
        if (textData != null && textData.length() > 0) {
            status.setText("");
            pasteRtfText.setText("start paste>" + textData + "<end paste");
        } else {
            status.setText("No RTF to paste");
        }
    }));
}

From source file:SWTImageViewer.java

public void open() {
    shell = new Shell(viewer.shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
    shell.setText("Print preview");
    shell.setLayout(new GridLayout(4, false));

    final Button buttonSelectPrinter = new Button(shell, SWT.PUSH);
    buttonSelectPrinter.setText("Select a printer");
    buttonSelectPrinter.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            PrintDialog dialog = new PrintDialog(shell);
            // Prompts the printer dialog to let the user select a printer.
            PrinterData printerData = dialog.open();

            if (printerData == null) // the user cancels the dialog
                return;
            // Loads the printer.
            final Printer printer = new Printer(printerData);
            setPrinter(printer, Double.parseDouble(combo.getItem(combo.getSelectionIndex())));
        }//from   www . j av a2  s  .c  o  m
    });

    new Label(shell, SWT.NULL).setText("Margin in inches: ");
    combo = new Combo(shell, SWT.READ_ONLY);
    combo.add("0.5");
    combo.add("1.0");
    combo.add("1.5");
    combo.add("2.0");
    combo.add("2.5");
    combo.add("3.0");
    combo.select(1);
    combo.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            double value = Double.parseDouble(combo.getItem(combo.getSelectionIndex()));
            setPrinter(printer, value);
        }
    });

    final Button buttonPrint = new Button(shell, SWT.PUSH);
    buttonPrint.setText("Print");
    buttonPrint.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            if (printer == null)
                viewer.print();
            else
                viewer.print(printer, margin);
            shell.dispose();
        }
    });

    canvas = new Canvas(shell, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 4;
    canvas.setLayoutData(gridData);
    canvas.addPaintListener(new PaintListener() {
        public void paintControl(PaintEvent e) {
            int canvasBorder = 20;

            if (printer == null || printer.isDisposed())
                return;
            Rectangle rectangle = printer.getBounds();
            Point canvasSize = canvas.getSize();

            double viewScaleFactor = (canvasSize.x - canvasBorder * 2) * 1.0 / rectangle.width;
            viewScaleFactor = Math.min(viewScaleFactor,
                    (canvasSize.y - canvasBorder * 2) * 1.0 / rectangle.height);

            int offsetX = (canvasSize.x - (int) (viewScaleFactor * rectangle.width)) / 2;
            int offsetY = (canvasSize.y - (int) (viewScaleFactor * rectangle.height)) / 2;

            e.gc.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            // draws the page layout
            e.gc.fillRectangle(offsetX, offsetY, (int) (viewScaleFactor * rectangle.width),
                    (int) (viewScaleFactor * rectangle.height));

            // draws the margin.
            e.gc.setLineStyle(SWT.LINE_DASH);
            e.gc.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));

            int marginOffsetX = offsetX + (int) (viewScaleFactor * margin.left);
            int marginOffsetY = offsetY + (int) (viewScaleFactor * margin.top);
            e.gc.drawRectangle(marginOffsetX, marginOffsetY,
                    (int) (viewScaleFactor * (margin.right - margin.left)),
                    (int) (viewScaleFactor * (margin.bottom - margin.top)));

            if (viewer.image != null) {
                int imageWidth = viewer.image.getBounds().width;
                int imageHeight = viewer.image.getBounds().height;

                double dpiScaleFactorX = printer.getDPI().x * 1.0 / shell.getDisplay().getDPI().x;
                double dpiScaleFactorY = printer.getDPI().y * 1.0 / shell.getDisplay().getDPI().y;

                double imageSizeFactor = Math.min(1,
                        (margin.right - margin.left) * 1.0 / (dpiScaleFactorX * imageWidth));
                imageSizeFactor = Math.min(imageSizeFactor,
                        (margin.bottom - margin.top) * 1.0 / (dpiScaleFactorY * imageHeight));

                e.gc.drawImage(viewer.image, 0, 0, imageWidth, imageHeight, marginOffsetX, marginOffsetY,
                        (int) (dpiScaleFactorX * imageSizeFactor * imageWidth * viewScaleFactor),
                        (int) (dpiScaleFactorY * imageSizeFactor * imageHeight * viewScaleFactor));

            }

        }
    });

    shell.setSize(400, 400);
    shell.open();
    setPrinter(null, 1.0);

    // Set up the event loop.
    while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) {
            // If no more entries in event queue
            shell.getDisplay().sleep();
        }
    }
}

From source file:AddressBookDemo.java

public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);//from  ww w.  ja  v  a 2  s. c o m
    layout.numColumns = 2;
    layout.verticalSpacing = 9;

    Label label = new Label(container, SWT.NULL);
    label.setText("&Address Line 1:");

    addressLine1Text = new Text(container, SWT.BORDER | SWT.MULTI);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    addressLine1Text.setLayoutData(gd);
    addressLine1Text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    label = new Label(container, SWT.NULL);
    label.setText("&Address Line 2:");

    addressLine2Text = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    addressLine2Text.setLayoutData(gd);
    addressLine2Text.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });

    label = new Label(container, SWT.NULL);
    label.setText("&City:");

    cityText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    cityText.setLayoutData(gd);

    label = new Label(container, SWT.NULL);
    label.setText("&State:");

    stateCombo = new Combo(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    stateCombo.setLayoutData(gd);
    stateCombo.setItems(STATES);

    label = new Label(container, SWT.NULL);
    label.setText("&Zip Code:");

    zipCodeText = new Text(container, SWT.BORDER | SWT.SINGLE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    zipCodeText.setLayoutData(gd);

    // dialogChanged();
    setControl(container);
}

From source file:org.pentaho.di.ui.spoon.trans.TransPerfDelegate.java

public void setupContent() {
    // there is a potential infinite loop below if this method
    // is called when the transgraph is not running, so we check
    // early to make sure it won't happen (see PDI-5009)
    if (!transGraph.isRunning() || transGraph.trans == null
            || !transGraph.trans.getTransMeta().isCapturingStepPerformanceSnapShots()) {
        showEmptyGraph();/*from   www  .  j a  v a  2s  .co  m*/
        return; // TODO: display help text and rerty button
    }

    if (perfComposite.isDisposed()) {
        return;
    }

    // Remove anything on the perf composite, like an empty page message
    //
    for (Control control : perfComposite.getChildren()) {
        if (!control.isDisposed()) {
            control.dispose();
        }
    }

    emptyGraph = false;

    this.title = transGraph.trans.getTransMeta().getName();
    this.timeDifference = transGraph.trans.getTransMeta().getStepPerformanceCapturingDelay();
    this.stepPerformanceSnapShots = transGraph.trans.getStepPerformanceSnapShots();

    // Wait a second for the first data to pour in...
    // TODO: make this wait more elegant...
    //
    while (this.stepPerformanceSnapShots == null || stepPerformanceSnapShots.isEmpty()) {
        this.stepPerformanceSnapShots = transGraph.trans.getStepPerformanceSnapShots();
        try {
            Thread.sleep(100L);
        } catch (InterruptedException e) {
            // Ignore errors
        }
    }

    Set<String> stepsSet = stepPerformanceSnapShots.keySet();
    steps = stepsSet.toArray(new String[stepsSet.size()]);
    Arrays.sort(steps);

    // Display 2 lists with the data types and the steps on the left side.
    // Then put a canvas with the graph on the right side
    //
    Label dataListLabel = new Label(perfComposite, SWT.NONE);
    dataListLabel.setText(BaseMessages.getString(PKG, "StepPerformanceSnapShotDialog.Metrics.Label"));
    spoon.props.setLook(dataListLabel);
    FormData fdDataListLabel = new FormData();

    fdDataListLabel.left = new FormAttachment(0, 0);
    fdDataListLabel.right = new FormAttachment(spoon.props.getMiddlePct() / 2, Const.MARGIN);
    fdDataListLabel.top = new FormAttachment(0, Const.MARGIN + 5);
    dataListLabel.setLayoutData(fdDataListLabel);

    dataList = new org.eclipse.swt.widgets.List(perfComposite,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.LEFT | SWT.BORDER);
    spoon.props.setLook(dataList);
    dataList.setItems(dataChoices);
    dataList.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {

            // If there are multiple selections here AND there are multiple selections in the steps list, we only take the
            // first step in the selection...
            //
            if (dataList.getSelectionCount() > 1 && stepsList.getSelectionCount() > 1) {
                stepsList.setSelection(stepsList.getSelectionIndices()[0]);
            }

            updateGraph();
        }
    });

    FormData fdDataList = new FormData();
    fdDataList.left = new FormAttachment(0, 0);
    fdDataList.right = new FormAttachment(spoon.props.getMiddlePct() / 2, Const.MARGIN);
    fdDataList.top = new FormAttachment(dataListLabel, Const.MARGIN);
    fdDataList.bottom = new FormAttachment(40, Const.MARGIN);
    dataList.setLayoutData(fdDataList);

    Label stepsListLabel = new Label(perfComposite, SWT.NONE);
    stepsListLabel.setText(BaseMessages.getString(PKG, "StepPerformanceSnapShotDialog.Steps.Label"));

    spoon.props.setLook(stepsListLabel);

    FormData fdStepsListLabel = new FormData();
    fdStepsListLabel.left = new FormAttachment(0, 0);
    fdStepsListLabel.right = new FormAttachment(spoon.props.getMiddlePct() / 2, Const.MARGIN);
    fdStepsListLabel.top = new FormAttachment(dataList, Const.MARGIN);
    stepsListLabel.setLayoutData(fdStepsListLabel);

    stepsList = new org.eclipse.swt.widgets.List(perfComposite,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.LEFT | SWT.BORDER);
    spoon.props.setLook(stepsList);
    stepsList.setItems(steps);
    stepsList.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {

            // If there are multiple selections here AND there are multiple selections in the data list, we only take the
            // first data item in the selection...
            //
            if (dataList.getSelectionCount() > 1 && stepsList.getSelectionCount() > 1) {
                dataList.setSelection(dataList.getSelectionIndices()[0]);
            }

            updateGraph();
        }
    });
    FormData fdStepsList = new FormData();
    fdStepsList.left = new FormAttachment(0, 0);
    fdStepsList.right = new FormAttachment(spoon.props.getMiddlePct() / 2, Const.MARGIN);
    fdStepsList.top = new FormAttachment(stepsListLabel, Const.MARGIN);
    fdStepsList.bottom = new FormAttachment(100, Const.MARGIN);
    stepsList.setLayoutData(fdStepsList);

    canvas = new Canvas(perfComposite, SWT.NONE);
    spoon.props.setLook(canvas);
    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(spoon.props.getMiddlePct() / 2, Const.MARGIN);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.top = new FormAttachment(0, Const.MARGIN);
    fdCanvas.bottom = new FormAttachment(100, 0);
    canvas.setLayoutData(fdCanvas);

    perfComposite.addControlListener(new ControlAdapter() {
        public void controlResized(ControlEvent event) {
            updateGraph();
        }
    });

    perfComposite.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent event) {
            if (image != null) {
                image.dispose();
            }
        }
    });

    canvas.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent event) {
            if (image != null && !image.isDisposed()) {
                event.gc.drawImage(image, 0, 0);
            }
        }
    });

    // Refresh automatically every 5 seconds as well.
    //
    final Timer timer = new Timer("TransPerfDelegate Timer");
    timer.schedule(new TimerTask() {
        public void run() {
            updateGraph();
        }
    }, 0, 5000);

    // When the tab is closed, we remove the update timer
    //
    transPerfTab.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent arg0) {
            timer.cancel();
        }
    });
}

From source file:ClipboardExample.java

void createHTMLTransfer(Composite copyParent, Composite pasteParent) {
    // HTML Transfer
    Label l = new Label(copyParent, SWT.NONE);
    l.setText("HTMLTransfer:"); //$NON-NLS-1$
    copyHtmlText = new Text(copyParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    copyHtmlText.setText("<b>Hello World</b>");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    copyHtmlText.setLayoutData(data);/*from ww w. j a  v a 2s  .com*/
    Button b = new Button(copyParent, SWT.PUSH);
    b.setText("Copy");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String data = copyHtmlText.getText();
            if (data.length() > 0) {
                status.setText("");
                clipboard.setContents(new Object[] { data }, new Transfer[] { HTMLTransfer.getInstance() });
            } else {
                status.setText("nothing to copy");
            }
        }
    });

    l = new Label(pasteParent, SWT.NONE);
    l.setText("HTMLTransfer:"); //$NON-NLS-1$
    pasteHtmlText = new Text(pasteParent, SWT.READ_ONLY | SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = data.widthHint = SIZE;
    pasteHtmlText.setLayoutData(data);
    b = new Button(pasteParent, SWT.PUSH);
    b.setText("Paste");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String data = (String) clipboard.getContents(HTMLTransfer.getInstance());
            if (data != null && data.length() > 0) {
                status.setText("");
                pasteHtmlText.setText("start paste>" + data + "<end paste");
            } else {
                status.setText("nothing to paste");
            }
        }
    });
}

From source file:org.eclipse.swt.examples.controlexample.ShellTab.java

/**
 * Creates the "Control" widget children.
 *//*from  w  w w  .j  a v  a2 s.  co  m*/
@Override
void createControlWidgets() {

    /* Create the parent style buttons */
    noParentButton = new Button(parentStyleGroup, SWT.RADIO);
    noParentButton.setText(ControlExample.getResourceString("No_Parent"));
    parentButton = new Button(parentStyleGroup, SWT.RADIO);
    parentButton.setText(ControlExample.getResourceString("Parent"));

    /* Create the decoration style buttons */
    noTrimButton = new Button(styleGroup, SWT.CHECK);
    noTrimButton.setText("SWT.NO_TRIM");
    noMoveButton = new Button(styleGroup, SWT.CHECK);
    noMoveButton.setText("SWT.NO_MOVE");
    closeButton = new Button(styleGroup, SWT.CHECK);
    closeButton.setText("SWT.CLOSE");
    titleButton = new Button(styleGroup, SWT.CHECK);
    titleButton.setText("SWT.TITLE");
    minButton = new Button(styleGroup, SWT.CHECK);
    minButton.setText("SWT.MIN");
    maxButton = new Button(styleGroup, SWT.CHECK);
    maxButton.setText("SWT.MAX");
    borderButton = new Button(styleGroup, SWT.CHECK);
    borderButton.setText("SWT.BORDER");
    resizeButton = new Button(styleGroup, SWT.CHECK);
    resizeButton.setText("SWT.RESIZE");
    onTopButton = new Button(styleGroup, SWT.CHECK);
    onTopButton.setText("SWT.ON_TOP");
    toolButton = new Button(styleGroup, SWT.CHECK);
    toolButton.setText("SWT.TOOL");
    sheetButton = new Button(styleGroup, SWT.CHECK);
    sheetButton.setText("SWT.SHEET");
    Label separator = new Label(styleGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    shellTrimButton = new Button(styleGroup, SWT.CHECK);
    shellTrimButton.setText("SWT.SHELL_TRIM");
    dialogTrimButton = new Button(styleGroup, SWT.CHECK);
    dialogTrimButton.setText("SWT.DIALOG_TRIM");

    /* Create the modal style buttons */
    modelessButton = new Button(modalStyleGroup, SWT.RADIO);
    modelessButton.setText("SWT.MODELESS");
    primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
    primaryModalButton.setText("SWT.PRIMARY_MODAL");
    applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
    applicationModalButton.setText("SWT.APPLICATION_MODAL");
    systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
    systemModalButton.setText("SWT.SYSTEM_MODAL");

    /* Create the 'other' buttons */
    imageButton = new Button(otherGroup, SWT.CHECK);
    imageButton.setText(ControlExample.getResourceString("Image"));
    backgroundImageButton = new Button(otherGroup, SWT.CHECK);
    backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage"));

    createSetGetGroup();

    /* Create the "create" and "closeAll" buttons */
    createButton = new Button(controlGroup, SWT.NONE);
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    createButton.setLayoutData(gridData);
    createButton.setText(ControlExample.getResourceString("Create_Shell"));
    closeAllButton = new Button(controlGroup, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    closeAllButton.setText(ControlExample.getResourceString("Close_All_Shells"));
    closeAllButton.setLayoutData(gridData);

    /* Add the listeners */
    createButton.addSelectionListener(widgetSelectedAdapter(e -> createButtonSelected(e)));
    closeAllButton.addSelectionListener(widgetSelectedAdapter(e -> closeAllShells()));
    SelectionListener decorationButtonListener = widgetSelectedAdapter(
            event -> decorationButtonSelected(event));
    noTrimButton.addSelectionListener(decorationButtonListener);
    noMoveButton.addSelectionListener(decorationButtonListener);
    closeButton.addSelectionListener(decorationButtonListener);
    titleButton.addSelectionListener(decorationButtonListener);
    minButton.addSelectionListener(decorationButtonListener);
    maxButton.addSelectionListener(decorationButtonListener);
    borderButton.addSelectionListener(decorationButtonListener);
    resizeButton.addSelectionListener(decorationButtonListener);
    dialogTrimButton.addSelectionListener(decorationButtonListener);
    shellTrimButton.addSelectionListener(decorationButtonListener);
    applicationModalButton.addSelectionListener(decorationButtonListener);
    systemModalButton.addSelectionListener(decorationButtonListener);

    /* Set the default state */
    noParentButton.setSelection(true);
    modelessButton.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;/*from w  w  w  .j  av  a2 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());

    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:com.android.ddmuilib.SysinfoPanel.java

/**
 * Create our controls for the UI panel.
 *///w  w w.  j a  v a 2 s  . com
@Override
protected Control createControl(Composite parent) {
    Composite top = new Composite(parent, SWT.NONE);
    top.setLayout(new GridLayout(1, false));
    top.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite buttons = new Composite(top, SWT.NONE);
    buttons.setLayout(new RowLayout());

    mDisplayMode = new Combo(buttons, SWT.PUSH);
    for (String mode : CAPTIONS) {
        mDisplayMode.add(mode);
    }
    mDisplayMode.select(mMode);
    mDisplayMode.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            mMode = mDisplayMode.getSelectionIndex();
            if (mDataFile != null) {
                generateDataset(mDataFile);
            } else if (getCurrentDevice() != null) {
                loadFromDevice();
            }
        }
    });

    final Button loadButton = new Button(buttons, SWT.PUSH);
    loadButton.setText("Load from File");
    loadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog fileDialog = new FileDialog(loadButton.getShell(), SWT.OPEN);
            fileDialog.setText("Load bugreport");
            String filename = fileDialog.open();
            if (filename != null) {
                mDataFile = new File(filename);
                generateDataset(mDataFile);
            }
        }
    });

    mFetchButton = new Button(buttons, SWT.PUSH);
    mFetchButton.setText("Update from Device");
    mFetchButton.setEnabled(false);
    mFetchButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            loadFromDevice();
        }
    });

    mLabel = new Label(top, SWT.NONE);
    mLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    mDataset = new DefaultPieDataset();
    JFreeChart chart = ChartFactory.createPieChart("", mDataset, false
    /* legend */, true/* tooltips */, false /* urls */);

    ChartComposite chartComposite = new ChartComposite(top, SWT.BORDER, chart, ChartComposite.DEFAULT_HEIGHT,
            ChartComposite.DEFAULT_HEIGHT, ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 3000,
            // max draw width. We don't want it to zoom, so we put a big number
            3000,
            // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            false, // zoom
            true);
    chartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    return top;
}

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 . j a 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());

    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.eclipse.swt.examples.ole.win32.OleBrowserView.java

/**
 * Creates the Web browser status area.//from  ww  w .  j a v a 2s .  com
 */
private void createStatusArea() {
    // Add a progress bar to display downloading progress information
    webProgress = new ProgressBar(displayArea, SWT.BORDER);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.BEGINNING;
    gridData.verticalAlignment = GridData.FILL;
    webProgress.setLayoutData(gridData);

    // Add a label for displaying status messages as they are received from the control
    webStatus = new Label(displayArea, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    webStatus.setLayoutData(gridData);
    webStatus.setFont(OlePlugin.browserFont);
}