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

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

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Composite 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:SWTTreeExample.java

private void createContents(Composite composite) {
    // Set the single-selection tree in the upper left,
    // the multi-selection tree in the upper right,
    // and the checkbox tree across the bottom.
    // To do this, create a 1x2 grid, and in the top
    // cell, a 2x1 grid.
    composite.setLayout(new GridLayout(1, true));
    Composite top = new Composite(composite, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    top.setLayoutData(data);

    top.setLayout(new GridLayout(2, true));
    Tree single = new Tree(top, SWT.SINGLE | SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    single.setLayoutData(data);/*ww  w  .  j  a  va 2  s.co m*/
    fillTree(single);

    Tree multi = new Tree(top, SWT.MULTI | SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    multi.setLayoutData(data);
    fillTree(multi);

    Tree check = new Tree(composite, SWT.CHECK | SWT.BORDER);
    data = new GridData(GridData.FILL_BOTH);
    check.setLayoutData(data);
    fillTree(check);
}

From source file:MainClass.java

protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);//from  w ww  .  j  ava  2  s . c o  m
    Composite composite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setLayout(new FillLayout());

    label = new Label(composite, SWT.LEFT);
    return composite;
}

From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java

private void createControlButtons() {
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from   w ww. j  a  v  a2  s .  c  o m
    composite.setLayout(layout);

    Button okButton = new Button(composite, SWT.PUSH);
    okButton.setText(resAddressBook.getString("OK"));
    okButton.addSelectionListener(widgetSelectedAdapter(e -> shell.close()));

    Button cancelButton = new Button(composite, SWT.PUSH);
    cancelButton.setText(resAddressBook.getString("Cancel"));
    cancelButton.addSelectionListener(widgetSelectedAdapter(e -> {
        values = null;
        shell.close();
    }));

    shell.setDefaultButton(okButton);
}

From source file:org.eclipse.swt.examples.addressbook.DataEntryDialog.java

private void createTextWidgets() {
    if (labels == null)
        return;/*from w w w  . j ava  2s  .co  m*/

    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    composite.setLayout(layout);

    if (values == null)
        values = new String[labels.length];

    for (int i = 0; i < labels.length; i++) {
        Label label = new Label(composite, SWT.RIGHT);
        label.setText(labels[i]);
        Text text = new Text(composite, SWT.BORDER);
        GridData gridData = new GridData();
        gridData.widthHint = 400;
        text.setLayoutData(gridData);
        if (values[i] != null) {
            text.setText(values[i]);
        }
        text.setData("index", Integer.valueOf(i));
        addTextListener(text);
    }
}

From source file:SashFormAdvanced.java

/**
 * Creates the main window's contents/*from  w  w w  .j a  v  a  2 s.  c o m*/
 * 
 * @param parent the parent window
 */
private void createContents(Composite parent) {
    // Our layout will have a row of buttons, and
    // then a SashForm below it.
    parent.setLayout(new GridLayout(1, false));

    // Create the row of buttons
    Composite buttonBar = new Composite(parent, SWT.NONE);
    buttonBar.setLayout(new RowLayout());
    Button flip = new Button(buttonBar, SWT.PUSH);
    flip.setText("Switch Orientation");
    Button weights = new Button(buttonBar, SWT.PUSH);
    weights.setText("Restore Weights");

    // Create the SashForm
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new FillLayout());
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);

    // Change the width of the sashes
    sashForm.SASH_WIDTH = 20;

    // Change the color used to paint the sashes
    sashForm.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GREEN));

    // Create the buttons and their event handlers
    final Button one = new Button(sashForm, SWT.PUSH);
    one.setText("One");
    one.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            maximizeHelper(one, sashForm);
        }
    });

    final Button two = new Button(sashForm, SWT.PUSH);
    two.setText("Two");
    two.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            maximizeHelper(two, sashForm);
        }
    });

    final Button three = new Button(sashForm, SWT.PUSH);
    three.setText("Three");
    three.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            maximizeHelper(three, sashForm);
        }
    });

    // Set the relative weights for the buttons
    sashForm.setWeights(new int[] { 1, 2, 3 });

    // Add the Switch Orientation functionality
    flip.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            switch (sashForm.getOrientation()) {
            case SWT.HORIZONTAL:
                sashForm.setOrientation(SWT.VERTICAL);
                break;
            case SWT.VERTICAL:
                sashForm.setOrientation(SWT.HORIZONTAL);
                break;
            }
        }
    });

    // Add the Restore Weights functionality
    weights.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            sashForm.setWeights(new int[] { 1, 2, 3 });
        }
    });
}

From source file:DumbUser.java

/**
 * Creates the dialog area/*w ww.j  a v a  2s . c o m*/
 * 
 * @param parent the parent composite
 * @return Control
 */
protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);

    // Create a composite to hold the label
    Composite composite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setLayout(new FillLayout());

    // Create the label for the "hidden" message
    label = new Label(composite, SWT.LEFT);

    return composite;
}

From source file:org.jcryptool.visual.verifiablesecretsharing.views.ReconstructionChartComposite.java

/**
 * Generates the head of the tab. The head has a title and a description.
 *//*from w  ww .  ja  v  a 2s  .co  m*/
private void createHead() {
    final Composite head = new Composite(this, SWT.NONE);
    head.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    head.setLayout(new GridLayout());

    final Label label = new Label(head, SWT.NONE);
    label.setFont(FontService.getHeaderFont());
    label.setText(Messages.VerifiableSecretSharingComposite_tab_title);
    stDescription = new StyledText(head, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
    stDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    if (reconstructedPolynom.toString().compareTo("0") == 0) {
        stDescription.setText(Messages.ChartComposite_noGraph);
    } else {
        stDescription.setText(reconstructedPolynom.toString());
    }
}

From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditor.java

/**
 * Creates a new editor.// w  w  w  .ja va  2  s  .  co  m
 * 
 * @param shell2 the display.
 * @param chart2edit the chart to edit.
 */
public SWTChartEditor(Shell shell2, JFreeChart chart2edit) {

    this.shell = new Shell(Display.getDefault(), SWT.DIALOG_TRIM);
    this.shell.setSize(400, 500);
    this.chart = chart2edit;
    this.shell.setText(
            ResourceBundle.getBundle("org.jfree.chart.LocalizationBundle").getString("Chart_Properties"));
    GridLayout layout = new GridLayout(2, true);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
    this.shell.setLayout(layout);
    Composite main = new Composite(this.shell, SWT.NONE);
    main.setLayout(new FillLayout());
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    TabFolder tab = new TabFolder(main, SWT.BORDER);
    // build first tab
    TabItem item1 = new TabItem(tab, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Title") + " ");
    this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle());
    item1.setControl(this.titleEditor);
    // build second tab
    TabItem item2 = new TabItem(tab, SWT.NONE);
    item2.setText(" " + localizationResources.getString("Plot") + " ");
    this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot());
    item2.setControl(this.plotEditor);
    // build the third tab
    TabItem item3 = new TabItem(tab, SWT.NONE);
    item3.setText(" " + localizationResources.getString("Other") + " ");
    this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart);
    item3.setControl(this.otherEditor);

    // ok and cancel buttons
    Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ok.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });
    Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    cancel.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
}

From source file:com.rcp.wbw.demo.editor.SWTChartEditor.java

/**
 * Creates a new editor.//from w w  w . j  a  v a2s.  c om
 * 
 * @param display
 *            the display.
 * @param chart2edit
 *            the chart to edit.
 */
public SWTChartEditor(Display display, JFreeChart chart2edit) {
    this.shell = new Shell(display, SWT.DIALOG_TRIM);
    this.shell.setSize(400, 500);
    this.chart = chart2edit;
    this.shell.setText(ResourceBundleWrapper.getBundle("org.jfree.chart.LocalizationBundle")
            .getString("Chart_Properties"));
    GridLayout layout = new GridLayout(2, true);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
    this.shell.setLayout(layout);
    Composite main = new Composite(this.shell, SWT.NONE);
    main.setLayout(new FillLayout());
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    TabFolder tab = new TabFolder(main, SWT.BORDER);
    // build first tab
    TabItem item1 = new TabItem(tab, SWT.NONE);
    item1.setText(" " + localizationResources.getString("Title") + " ");
    this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, this.chart.getTitle());
    item1.setControl(this.titleEditor);
    // build second tab
    TabItem item2 = new TabItem(tab, SWT.NONE);
    item2.setText(" " + localizationResources.getString("Plot") + " ");
    this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, this.chart.getPlot());
    item2.setControl(this.plotEditor);
    // build the third tab
    TabItem item3 = new TabItem(tab, SWT.NONE);
    item3.setText(" " + localizationResources.getString("Other") + " ");
    this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart);
    item3.setControl(this.otherEditor);

    // ok and cancel buttons
    Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ok.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });
    Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    cancel.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
}

From source file:org.jfree.experimental.chart.swt.editor.SWTChartEditorDialog.java

/**
 * Creates a new editor.//from   w  ww . j  av a 2  s .c  om
 * 
 * @param shell2 the display.
 * @param chart2edit the chart to edit.
 */
public SWTChartEditorDialog(Shell shell2, final JFreeChart chart2edit) {

    this.dialog = new Dialog(shell2) {
        @Override
        protected Control createDialogArea(Composite parent) {
            SWTChartEditorDialog.this.chart = chart2edit;
            GridLayout layout = new GridLayout(2, true);
            layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
            parent.setLayout(layout);

            Composite main = new Composite(parent, SWT.NONE);
            main.setLayout(new FillLayout());
            main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
            main.setSize(400, 500);

            TabFolder tab = new TabFolder(main, SWT.BORDER);
            // build first tab
            TabItem item1 = new TabItem(tab, SWT.NONE);
            item1.setText(" " + localizationResources.getString("Title") + " ");
            SWTChartEditorDialog.this.titleEditor = new SWTTitleEditor(tab, SWT.NONE,
                    SWTChartEditorDialog.this.chart.getTitle());
            item1.setControl(SWTChartEditorDialog.this.titleEditor);
            // build second tab
            TabItem item2 = new TabItem(tab, SWT.NONE);
            item2.setText(" " + localizationResources.getString("Plot") + " ");
            SWTChartEditorDialog.this.plotEditor = new SWTPlotEditor(tab, SWT.NONE,
                    SWTChartEditorDialog.this.chart.getPlot());
            item2.setControl(SWTChartEditorDialog.this.plotEditor);
            // build the third tab
            TabItem item3 = new TabItem(tab, SWT.NONE);
            item3.setText(" " + localizationResources.getString("Other") + " ");
            SWTChartEditorDialog.this.otherEditor = new SWTOtherEditor(tab, SWT.NONE,
                    SWTChartEditorDialog.this.chart);
            item3.setControl(SWTChartEditorDialog.this.otherEditor);

            return super.createDialogArea(parent);
        }

        @Override
        protected void buttonPressed(int buttonId) {
            if (buttonId == 0) {
                updateChart(SWTChartEditorDialog.this.chart);
            }
            this.close();
        }
    };

}