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

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

Introduction

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

Prototype

public void setLayout(Layout layout) 

Source Link

Document

Sets the layout which is associated with the receiver to be the argument which may be null.

Usage

From source file:org.talend.dataprofiler.chart.util.HideSeriesChartDialog.java

private Composite createUtilityControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.BORDER);
    comp.setLayout(new RowLayout());
    comp.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));

    if (isCountAvgNull) {
        XYDataset dataset = chart.getXYPlot().getDataset();
        int count = dataset.getSeriesCount();

        for (int i = 0; i < count; i++) {

            Button checkBtn = new Button(comp, SWT.CHECK);
            checkBtn.setText(dataset.getSeriesKey(i).toString());
            checkBtn.setSelection(true);
            checkBtn.addSelectionListener(listener);
            checkBtn.setData(SERIES_KEY_ID, i);
        }//from ww  w.  j a va  2 s  . c  o  m
    }

    if (isMinMaxDate) {
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        CategoryDataset dataset = plot.getDataset();
        int count = dataset.getRowCount();

        for (int i = 0; i < count; i++) {

            Button checkBtn = new Button(comp, SWT.CHECK);
            checkBtn.setText(dataset.getRowKey(i).toString());
            checkBtn.setSelection(true);
            checkBtn.addSelectionListener(listener);
            checkBtn.setData(SERIES_KEY_ID, i);
        }
    }

    return comp;
}

From source file:DumbUser.java

/**
 * Creates the main window's contents/*www . j  a  v  a 2  s . c om*/
 * 
 * @param parent the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));

    // Create the button
    Button show = new Button(composite, SWT.NONE);
    show.setText("Show");

    final Shell shell = parent.getShell();

    // Display the dialog
    show.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create and show the dialog
            DumbMessageDialog dlg = new DumbMessageDialog(shell);
            dlg.open();
        }
    });

    parent.pack();
    return composite;
}

From source file:ShowMyTitleAreaDialog.java

/**
 * Creates the main window's contents//  w  w  w .  j  a  va 2s  .c om
 * 
 * @param parent the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));

    // Create the button
    Button show = new Button(composite, SWT.NONE);
    show.setText("Show");

    final Shell shell = parent.getShell();

    // Display the TitleAreaDialog
    show.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create and show the dialog
            MyTitleAreaDialog dlg = new MyTitleAreaDialog(shell);
            dlg.open();
        }
    });

    parent.pack();
    return composite;
}

From source file:CoolBarTest.java

/**
 * Creates the Combo/*www  .j  a  va  2  s . co m*/
 * 
 * @param composite the parent composite
 * @return Control
 */
private Control createCombo(Composite composite) {
    // A bug with Windows causes the Combo not to drop
    // down if you add it directly to the CoolBar.
    // To work around this, create a Composite, add the
    // Combo to it, and add the Composite to the CoolBar.
    // This should work both on Windows and on all other
    // platforms.
    Composite c = new Composite(composite, SWT.NONE);
    c.setLayout(new FillLayout());
    Combo combo = new Combo(c, SWT.DROP_DOWN);
    combo.add("Option One");
    combo.add("Option Two");
    combo.add("Option Three");
    return c;
}

From source file:WordOLE.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FillLayout());

    oleFrame = new OleFrame(composite, SWT.NULL);

    if (getMenuBarManager() != null) {
        MenuItem windowMenu = new MenuItem(getMenuBarManager().getMenu(), SWT.CASCADE);
        windowMenu.setText("[Window]");

        MenuItem containerMenu = new MenuItem(getMenuBarManager().getMenu(), SWT.CASCADE);
        containerMenu.setText("[Container]");

        MenuItem fileMenu = new MenuItem(getMenuBarManager().getMenu(), SWT.CASCADE);
        fileMenu.setText("[File]");

        oleFrame.setWindowMenus(new MenuItem[] { windowMenu });
        oleFrame.setContainerMenus(new MenuItem[] { containerMenu });
        oleFrame.setFileMenus(new MenuItem[] { fileMenu });

        System.out.println("menu set");
    }//from   w w  w .  ja  va  2s  .  c  o m

    clientSite = new OleClientSite(oleFrame, SWT.NULL, new File("test.doc"));
    // clientSite = new OleClientSite(oleFrame, SWT.NONE,
    // "Word.Document.8");

    //    clientSite = new OleControlSite(oleFrame, SWT.NONE,
    //    "Word.Document.8");

    System.out.println(clientSite.getProgramID() + ", " + clientSite);
    clientSite.doVerb(OLE.OLEIVERB_SHOW);

    return composite;
}

From source file:CustomWidgets.java

protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new FillLayout());

    // Sets up the toolkit.
    toolkit = new FormToolkit(getShell().getDisplay());

    // Creates a form instance.
    form = toolkit.createForm(composite);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Sets title.
    form.setText("Custom Form Widgets Demo");

    // demoHyperlinks();

    // demoFormTextNormal();
    // demoFormTextURL();
    // demoFormTextXML();

    // demoExpandableComposite();
    demoSections();// w ww .  j  ava  2 s .  c  o m

    return composite;
}

From source file:net.sf.smbt.ui.btc.views.AbstractBlockchainView.java

@Override
public void createPartControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout());
    addCharts(container);//from w  w w .  j  a  va 2s  .  c  o m
}

From source file:ShowCTabFolder.java

/**
 * Creates the window's contents/*from  www  .j  a va  2  s.  co m*/
 * 
 * @param shell the parent shell
 */
private void createContents(Shell shell) {
    shell.setLayout(new GridLayout(1, true));

    // Create the buttons to create tabs
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setLayout(new RowLayout());
    createButtons(composite);

    // Create the tabs
    tabFolder = new CTabFolder(shell, SWT.TOP);
    tabFolder.setBorderVisible(true);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    Display display = shell.getDisplay();

    // Set up a gradient background for the selected tab
    tabFolder.setSelectionBackground(new Color[] { display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
            display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW) }, new int[] { 50, 100 });

    // Add a listener to get the close button on each tab
    tabFolder.addCTabFolderListener(new CTabFolderAdapter() {
        public void itemClosed(CTabFolderEvent event) {
        }
    });
}

From source file:SendMessage.java

/**
 * Creates the main window's contents/*from   w  ww  .j  a  v a  2s  .c  o  m*/
 * 
 * @param parent the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(5, true));

    // Create a big text box for the message text
    final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 5;
    text.setLayoutData(data);

    // Create the Confirm button
    Button confirm = new Button(composite, SWT.PUSH);
    confirm.setText("Confirm");
    confirm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Error button
    Button error = new Button(composite, SWT.PUSH);
    error.setText("Error");
    error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Information button
    Button information = new Button(composite, SWT.PUSH);
    information.setText("Information");
    information.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Question button
    Button question = new Button(composite, SWT.PUSH);
    question.setText("Question");
    question.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Warning button
    Button warning = new Button(composite, SWT.PUSH);
    warning.setText("Warning");
    warning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the label to display the return value
    final Label label = new Label(composite, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 5;
    label.setLayoutData(data);

    // Save ourselves some typing
    final Shell shell = parent.getShell();

    // Display a Confirmation dialog
    confirm.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean b = MessageDialog.openConfirm(shell, "Confirm", text.getText());
            label.setText("Returned " + Boolean.toString(b));
        }
    });

    // Display an Error dialog
    error.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openError(shell, "Error", text.getText());
            label.setText("Returned void");
        }
    });

    // Display an Information dialog
    information.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openInformation(shell, "Information", text.getText());
            label.setText("Returned void");
        }
    });

    // Display a Question dialog
    question.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean b = MessageDialog.openQuestion(shell, "Question", text.getText());
            label.setText("Returned " + Boolean.toString(b));
        }
    });

    // Display a Warning dialog
    warning.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openWarning(shell, "Warning", text.getText());
            label.setText("Returned void");
        }
    });

    return composite;
}

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

@Override
public void createControlPanel(Composite parent) {

    // create drop down combo for choosing clipping
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    new Label(comp, SWT.CENTER).setText(GraphicsExample.getResourceString("LineJoin")); //$NON-NLS-1$
    joinCb = new Combo(comp, SWT.DROP_DOWN);
    joinCb.add(GraphicsExample.getResourceString("bevel")); //$NON-NLS-1$
    joinCb.add(GraphicsExample.getResourceString("miter")); //$NON-NLS-1$
    joinCb.add(GraphicsExample.getResourceString("round")); //$NON-NLS-1$
    joinCb.select(1);//  w  w  w . jav a2  s .  co m
    joinCb.addListener(SWT.Selection, event -> example.redraw());

    // color menu
    ColorMenu cm = new ColorMenu();
    cm.setPatternItems(example.checkAdvancedGraphics());
    menu = cm.createMenu(parent.getParent(), gb -> {
        shapeColor = gb;
        colorButton.setImage(gb.getThumbNail());
        example.redraw();
    });

    // initialize the shape color to the 4th item in the menu (green)
    shapeColor = (GraphicsBackground) menu.getItem(3).getData();

    // color button
    comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(2, false));

    colorButton = new Button(comp, SWT.PUSH);
    colorButton.setText(GraphicsExample.getResourceString("Color")); //$NON-NLS-1$
    colorButton.setImage(shapeColor.getThumbNail());
    colorButton.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));
        menu.setLocation(point.x, point.y + bounds.height);
        menu.setVisible(true);
    });

}