Example usage for org.eclipse.swt.widgets Button getShell

List of usage examples for org.eclipse.swt.widgets Button getShell

Introduction

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

Prototype

public Shell getShell() 

Source Link

Document

Returns the receiver's shell.

Usage

From source file:com.android.ddmuilib.SysinfoPanel.java

/**
 * Create our controls for the UI panel.
 *///from   w  w w .ja  v  a 2 s  . c  o  m
@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;
}