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

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

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Button 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: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);/*  w  w  w .jav 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();
    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 w ww.j  a va  2  s  . com

            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));
}

From source file:CalculatorMichaelSchmidt.java

@Override
protected Control createDialogArea(final Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout calculatorGridLayout = new GridLayout();
    calculatorGridLayout.marginRight = 5;
    calculatorGridLayout.marginLeft = 5;
    calculatorGridLayout.marginBottom = 5;
    calculatorGridLayout.marginTop = 5;//from  ww  w  . j av a  2  s  .  com
    calculatorGridLayout.marginWidth = 10;
    calculatorGridLayout.marginHeight = 2;
    calculatorGridLayout.numColumns = 4;
    calculatorGridLayout.verticalSpacing = 2;
    calculatorGridLayout.makeColumnsEqualWidth = true;
    calculatorGridLayout.horizontalSpacing = 2;
    container.setLayout(calculatorGridLayout);

    // The display.  Note that it has a limit of 30 characters, 
    // much greater than the length of a double-precision number. 
    displayText = new Text(container, SWT.RIGHT | SWT.BORDER);
    displayText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    displayText.setEditable(false);
    displayText.setDoubleClickEnabled(false);
    displayText.setTextLimit(30);
    displayText.setText(displayString);
    displayText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 4, 1));

    final Button msButton = new Button(container, SWT.NONE);
    msButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('S');
        }
    });
    msButton.setToolTipText("Save value to Memory");
    msButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    msButton.setText("MS");

    final Button mcButton = new Button(container, SWT.NONE);
    mcButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('D');
        }
    });
    mcButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mcButton.setToolTipText("Clear Memory");
    mcButton.setText("MC");

    final Button clearButton = new Button(container, SWT.NONE);
    clearButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('C');
        }
    });
    clearButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    clearButton.setToolTipText("Clear all Calculator Registers");
    clearButton.setText("C");

    final Button ceButton = new Button(container, SWT.NONE);
    ceButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('E');
        }
    });
    ceButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ceButton.setToolTipText("Clear Entry");
    ceButton.setText("CE");

    final Button memAddButton = new Button(container, SWT.NONE);
    memAddButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('+');
        }
    });
    memAddButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memAddButton.setToolTipText("Add value to Memory");
    memAddButton.setText("M+");

    final Button mrButton = new Button(container, SWT.NONE);
    mrButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('R');
        }
    });
    mrButton.setToolTipText("Recall value in Memory");
    mrButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mrButton.setText("MR");

    final Button backButton = new Button(container, SWT.NONE);
    backButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('B');
        }
    });
    backButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    backButton.setToolTipText("Backspace");
    backButton.setText("BACK");

    final Button divideButton = new Button(container, SWT.NONE);
    divideButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('/');
        }
    });
    divideButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    divideButton.setToolTipText("Divide");
    divideButton.setText("/");

    final Button memSubtractButton = new Button(container, SWT.NONE);
    memSubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('-');
        }
    });
    memSubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memSubtractButton.setToolTipText("Subtract value from Memory");
    memSubtractButton.setText("M-");

    final Button inverseButton = new Button(container, SWT.NONE);
    inverseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('I');
        }
    });
    inverseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    inverseButton.setToolTipText("Inverse of value");
    inverseButton.setText("1/X");

    final Button sqrtButton = new Button(container, SWT.NONE);
    sqrtButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('Q');
        }
    });
    sqrtButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    sqrtButton.setToolTipText("Square Root of value");
    sqrtButton.setText("SQRT");

    final Button multiplyButton = new Button(container, SWT.NONE);
    multiplyButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('*');
        }
    });
    multiplyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    multiplyButton.setToolTipText("Multiply");
    multiplyButton.setText("*");

    final Button num7Button = new Button(container, SWT.NONE);
    num7Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('7');
        }
    });
    num7Button.setToolTipText("Numeric Pad");
    num7Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num7Button.setText("7");

    final Button num8Button = new Button(container, SWT.NONE);
    num8Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('8');
        }
    });
    num8Button.setToolTipText("Numeric Pad");
    num8Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num8Button.setText("8");

    final Button num9Button = new Button(container, SWT.NONE);
    num9Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('9');
        }
    });
    num9Button.setToolTipText("Numeric Pad");
    num9Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num9Button.setText("9");

    final Button SubtractButton = new Button(container, SWT.NONE);
    SubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('-');
        }
    });
    SubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    SubtractButton.setToolTipText("Subtract");
    SubtractButton.setText("-");

    final Button num4Button = new Button(container, SWT.NONE);
    num4Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('4');
        }
    });
    num4Button.setToolTipText("Numeric Pad");
    num4Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num4Button.setText("4");

    final Button num5Button = new Button(container, SWT.NONE);
    num5Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('5');
        }
    });
    num5Button.setToolTipText("Numeric Pad");
    num5Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num5Button.setText("5");

    final Button num6Button = new Button(container, SWT.NONE);
    num6Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('6');
        }
    });
    num6Button.setToolTipText("Numeric Pad");
    num6Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num6Button.setText("6");

    final Button AdditionButton = new Button(container, SWT.NONE);
    AdditionButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('+');
        }
    });
    AdditionButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    AdditionButton.setToolTipText("Add");
    AdditionButton.setText("+");

    final Button num1Button = new Button(container, SWT.NONE);
    num1Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('1');
        }
    });
    num1Button.setCapture(true);
    num1Button.setToolTipText("Numeric Pad");
    num1Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num1Button.setText("1");

    final Button num2Button = new Button(container, SWT.NONE);
    num2Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('2');
        }
    });
    num2Button.setToolTipText("Numeric Pad");
    num2Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num2Button.setText("2");

    final Button num3Button = new Button(container, SWT.NONE);
    num3Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('3');
        }
    });
    num3Button.setToolTipText("Numeric Pad");
    num3Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num3Button.setText("3");

    final Button equalsButton = new Button(container, SWT.NONE);
    equalsButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('=');
        }
    });
    equalsButton.setToolTipText("Equals (get result)");
    equalsButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 2));
    equalsButton.setText("=");

    final Button num0Button = new Button(container, SWT.NONE);
    num0Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('0');
        }
    });
    num0Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num0Button.setToolTipText("Numeric Pad");
    num0Button.setText("0");

    final Button decimalButton = new Button(container, SWT.NONE);
    decimalButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('.');
        }
    });
    decimalButton.setToolTipText("Numeric Pad");
    decimalButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    decimalButton.setText(".");

    final Button signButton = new Button(container, SWT.NONE);
    signButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('-');
        }
    });
    signButton.setToolTipText("Change sign of value");
    signButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    signButton.setText("+/-");
    new Label(container, SWT.NONE);
    //
    return container;
}

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

/**
 * Tell the user that the transformation is not running or that there is no monitoring configured.
 *///w ww . j a  va  2 s  .  co  m
private void showEmptyGraph() {
    if (perfComposite.isDisposed()) {
        return;
    }

    emptyGraph = true;

    Label label = new Label(perfComposite, SWT.CENTER);
    label.setText(BaseMessages.getString(PKG, "TransLog.Dialog.PerformanceMonitoringNotEnabled.Message"));
    label.setBackground(perfComposite.getBackground());
    label.setFont(GUIResource.getInstance().getFontMedium());

    FormData fdLabel = new FormData();
    fdLabel.left = new FormAttachment(5, 0);
    fdLabel.right = new FormAttachment(95, 0);
    fdLabel.top = new FormAttachment(5, 0);
    label.setLayoutData(fdLabel);

    Button button = new Button(perfComposite, SWT.CENTER);
    button.setText(BaseMessages.getString(PKG, "TransLog.Dialog.PerformanceMonitoring.Button"));
    button.setBackground(perfComposite.getBackground());
    button.setFont(GUIResource.getInstance().getFontMedium());

    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            TransGraph.editProperties(spoon.getActiveTransformation(), spoon, spoon.rep, true,
                    TransDialog.Tabs.MONITOR_TAB);
        }
    });

    FormData fdButton = new FormData();
    fdButton.left = new FormAttachment(40, 0);
    fdButton.right = new FormAttachment(60, 0);
    fdButton.top = new FormAttachment(label, 5);
    button.setLayoutData(fdButton);

    perfComposite.layout(true, true);
}

From source file:SWTAddressBook.java

/**
 * Class constructor that sets the parent shell and the table widget that
 * the dialog will search.//  w w  w  .  j  a  v  a2 s . c  om
 * 
 * @param parent
 *            Shell The shell that is the parent of the dialog.
 */
public SearchDialog(Shell parent) {
    shell = new Shell(parent, SWT.CLOSE | SWT.BORDER | SWT.TITLE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    shell.setLayout(layout);
    shell.setText("Search");
    shell.addShellListener(new ShellAdapter() {
        public void shellClosed(ShellEvent e) {
            // don't dispose of the shell, just hide it for later use
            e.doit = false;
            shell.setVisible(false);
        }
    });

    Label label = new Label(shell, SWT.LEFT);
    label.setText("Dialog_find_what");
    searchText = new Text(shell, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 200;
    searchText.setLayoutData(gridData);
    searchText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            boolean enableFind = (searchText.getCharCount() != 0);
            findButton.setEnabled(enableFind);
        }
    });

    searchAreaLabel = new Label(shell, SWT.LEFT);
    searchArea = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 200;
    searchArea.setLayoutData(gridData);

    matchCase = new Button(shell, SWT.CHECK);
    matchCase.setText("Dialog_match_case");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    matchCase.setLayoutData(gridData);

    matchWord = new Button(shell, SWT.CHECK);
    matchWord.setText("Dialog_match_word");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    matchWord.setLayoutData(gridData);

    Group direction = new Group(shell, SWT.NONE);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    direction.setLayoutData(gridData);
    direction.setLayout(new FillLayout());
    direction.setText("Dialog_direction");

    Button up = new Button(direction, SWT.RADIO);
    up.setText("Dialog_dir_up");
    up.setSelection(false);

    down = new Button(direction, SWT.RADIO);
    down.setText("Dialog_dir_down");
    down.setSelection(true);

    Composite composite = new Composite(shell, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gridData.horizontalSpan = 2;
    composite.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    composite.setLayout(layout);

    findButton = new Button(composite, SWT.PUSH);
    findButton.setText("Dialog_find");
    findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    findButton.setEnabled(false);
    findButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (!findHandler.find()) {
                MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.PRIMARY_MODAL);
                box.setText(shell.getText());
                box.setMessage("Cannot_find" + "\"" + searchText.getText() + "\"");
                box.open();
            }
        }
    });

    Button cancelButton = new Button(composite, SWT.PUSH);
    cancelButton.setText("Cancel");
    cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    cancelButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            shell.setVisible(false);
        }
    });

    shell.pack();
}

From source file:ummisco.gama.ui.views.displays.SWTChartEditor.java

/**
 * Creates a new editor.//from  w  w  w  .  j a v a 2s.c o m
 *
 * @param display
 *            the display.
 * @param chart2edit
 *            the chart to edit.
 */
public SWTChartEditor(final Display display, final JFreeChart chart2edit, final Point position) {
    this.shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.NO_TRIM);
    this.shell.setSize(400, 500);
    this.shell.setBackground(WorkbenchHelper.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    // this.shell.setAlpha(140);
    this.chart = chart2edit;
    this.shell.setText("Chart properties");
    this.shell.setLocation(position);
    final GridLayout layout = new GridLayout(2, false);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 5;
    this.shell.setLayout(layout);
    final Composite main = new Composite(this.shell, SWT.NONE);
    main.setLayout(new FillLayout());
    main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

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

    // ok and cancel buttons
    final Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
    cancel.pack();
    cancel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
    final Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
    ok.pack();
    ok.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });

}

From source file:org.eclipse.swt.examples.layoutexample.Tab.java

/**
 * Creates the "control" group. This is the group on the
 * right half of each example tab. It contains controls
 * for adding new children to the layoutComposite, and
 * for modifying the children's layout data.
 *//*from   ww w.  ja  v  a  2s  .com*/
void createControlGroup() {
    controlGroup = new Group(sash, SWT.NONE);
    controlGroup.setText(LayoutExample.getResourceString("Parameters"));
    GridLayout layout = new GridLayout(2, true);
    layout.horizontalSpacing = 10;
    controlGroup.setLayout(layout);
    final Button preferredButton = new Button(controlGroup, SWT.CHECK);
    preferredButton.setText(LayoutExample.getResourceString("Preferred_Size"));
    preferredButton.setSelection(false);
    preferredButton.addSelectionListener(widgetSelectedAdapter(e -> {
        resetEditors();
        GridData data = (GridData) layoutComposite.getLayoutData();
        if (preferredButton.getSelection()) {
            data.heightHint = data.widthHint = SWT.DEFAULT;
            data.verticalAlignment = data.horizontalAlignment = 0;
            data.grabExcessVerticalSpace = data.grabExcessHorizontalSpace = false;
        } else {
            data.verticalAlignment = data.horizontalAlignment = SWT.FILL;
            data.grabExcessVerticalSpace = data.grabExcessHorizontalSpace = true;
        }
        layoutComposite.setLayoutData(data);
        layoutGroup.layout(true);
    }));
    preferredButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    createControlWidgets();
}

From source file:msi.gama.gui.swt.controls.SWTChartEditor.java

/**
 * Creates a new editor.//  w  ww  .  ja v a2s. com
 * 
 * @param display the display.
 * @param chart2edit the chart to edit.
 */
public SWTChartEditor(final Display display, final JFreeChart chart2edit, final Point position) {
    this.shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.NO_TRIM);
    this.shell.setSize(400, 500);
    this.shell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
    // this.shell.setAlpha(140);
    this.chart = chart2edit;
    this.shell.setText("Chart properties");
    this.shell.setLocation(position);
    GridLayout layout = new GridLayout(2, false);
    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(" " + "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(" " + "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(" " + "Other" + " ");
    this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart);
    item3.setControl(this.otherEditor);

    // ok and cancel buttons
    Button cancel = new Button(this.shell, SWT.PUSH);
    cancel.setText(" Cancel ");
    cancel.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
    cancel.pack();
    cancel.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            SWTChartEditor.this.shell.dispose();
        }
    });
    Button ok = new Button(this.shell, SWT.PUSH | SWT.OK);
    ok.setText(" Ok ");
    ok.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
    ok.pack();
    ok.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            updateChart(SWTChartEditor.this.chart);
            SWTChartEditor.this.shell.dispose();
        }
    });

}

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

/**
 * Append the Set/Get API controls to the "Other" group.
 *//* w ww  .jav  a 2 s . c  o m*/
void createSetGetGroup() {
    /*
     * Create the button to access set/get API functionality.
     */
    final String[] methodNames = getMethodNames();
    if (methodNames != null) {
        final Button setGetButton = new Button(otherGroup, SWT.PUSH);
        setGetButton.setText(ControlExample.getResourceString("Set_Get"));
        setGetButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        setGetButton.addSelectionListener(widgetSelectedAdapter(e -> {
            if (getExampleWidgets().length > 0) {
                if (setGetDialog == null) {
                    setGetDialog = createSetGetDialog(methodNames);
                }
                Point pt = setGetButton.getLocation();
                pt = display.map(setGetButton.getParent(), null, pt);
                setGetDialog.setLocation(pt.x, pt.y);
                setGetDialog.open();
            }
        }));
    }
}

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

/**
 * Creates the "Colors and Fonts" group. This is typically
 * a child of the "Control" group. Subclasses override
 * this method to customize color and font settings.
 */// w w w.  j  a v  a  2s  .co  m
void createColorAndFontGroup() {
    /* Create the group. */
    colorGroup = new Group(controlGroup, SWT.NONE);
    colorGroup.setLayout(new GridLayout(2, true));
    colorGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    colorGroup.setText(ControlExample.getResourceString("Colors"));
    colorAndFontTable = new Table(colorGroup, SWT.BORDER | SWT.V_SCROLL);
    colorAndFontTable.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    TableItem item = new TableItem(colorAndFontTable, SWT.None);
    item.setText(ControlExample.getResourceString("Foreground_Color"));
    colorAndFontTable.setSelection(0);
    item = new TableItem(colorAndFontTable, SWT.None);
    item.setText(ControlExample.getResourceString("Background_Color"));
    item = new TableItem(colorAndFontTable, SWT.None);
    item.setText(ControlExample.getResourceString("Font"));
    Button changeButton = new Button(colorGroup, SWT.PUSH);
    changeButton.setText(ControlExample.getResourceString("Change"));
    changeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    Button defaultsButton = new Button(colorGroup, SWT.PUSH);
    defaultsButton.setText(ControlExample.getResourceString("Defaults"));
    defaultsButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    /* Add listeners to set/reset colors and fonts. */
    colorDialog = new ColorDialog(shell);
    fontDialog = new FontDialog(shell);
    colorAndFontTable.addSelectionListener(
            widgetDefaultSelectedAdapter(event -> changeFontOrColor(colorAndFontTable.getSelectionIndex())));
    changeButton.addSelectionListener(
            widgetSelectedAdapter(event -> changeFontOrColor(colorAndFontTable.getSelectionIndex())));
    defaultsButton.addSelectionListener(widgetSelectedAdapter(e -> resetColorsAndFonts()));
    shell.addDisposeListener(event -> {
        if (foregroundColor != null)
            foregroundColor.dispose();
        if (backgroundColor != null)
            backgroundColor.dispose();
        if (font != null)
            font.dispose();
        foregroundColor = null;
        backgroundColor = null;
        font = null;
        if (colorAndFontTable != null && !colorAndFontTable.isDisposed()) {
            TableItem[] items = colorAndFontTable.getItems();
            for (TableItem currentItem : items) {
                Image image = currentItem.getImage();
                if (image != null)
                    image.dispose();
            }
        }
    });
}