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

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

Introduction

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

Prototype

public Composite(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:Ch11WizardComposite.java

public void createControl(Composite parent) {
    Composite topLevel = new Composite(parent, SWT.NONE);
    topLevel.setLayout(new GridLayout(2, false));

    Label l = new Label(topLevel, SWT.CENTER);
    l.setText("Use default directory?");

    button = new Button(topLevel, SWT.CHECK);

    setControl(topLevel);// w  ww. j a  v a 2s .co  m
    setPageComplete(true);
}

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 w w  .  j  a va  2s  . c om
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.eclipse.swt.examples.addressbook.SearchDialog.java

/**
 * Class constructor that sets the parent shell and the table widget that
 * the dialog will search./*www . j  a v  a 2 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(resAddressBook.getString("Search_dialog_title"));
    shell.addShellListener(ShellListener.shellClosedAdapter(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(resAddressBook.getString("Dialog_find_what"));
    searchText = new Text(shell, SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.widthHint = 200;
    searchText.setLayoutData(gridData);
    searchText.addModifyListener(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(resAddressBook.getString("Dialog_match_case"));
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    matchCase.setLayoutData(gridData);

    matchWord = new Button(shell, SWT.CHECK);
    matchWord.setText(resAddressBook.getString("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(resAddressBook.getString("Dialog_direction"));

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

    down = new Button(direction, SWT.RADIO);
    down.setText(resAddressBook.getString("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(resAddressBook.getString("Dialog_find"));
    findButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    findButton.setEnabled(false);
    findButton.addSelectionListener(widgetSelectedAdapter(e -> {
        if (!findHandler.find()) {
            MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK | SWT.PRIMARY_MODAL);
            box.setText(shell.getText());
            box.setMessage(resAddressBook.getString("Cannot_find") + "\"" + searchText.getText() + "\"");
            box.open();
        }
    }));

    Button cancelButton = new Button(composite, SWT.PUSH);
    cancelButton.setText(resAddressBook.getString("Cancel"));
    cancelButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    cancelButton.addSelectionListener(widgetSelectedAdapter(e -> shell.setVisible(false)));
    shell.pack();
}

From source file:net.bioclipse.chembl.moss.ui.wizard.ChemblMossWizardPage2.java

@Override
public void createControl(Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    final GridLayout layout = new GridLayout(4, false);
    layout.marginRight = 2;// ww  w  . j av a2s  . c  om
    layout.marginLeft = 2;
    layout.marginBottom = -2;
    layout.marginTop = 10;
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    layout.verticalSpacing = 5;
    layout.horizontalSpacing = 5;
    container.setLayout(layout);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(container, "net.bioclipse.moss.business.helpmessage");
    setControl(container);
    setMessage("Select the first protein family to compare with substructure mining.");
    setPageComplete(true);

    label = new Label(container, SWT.NONE);
    gridData = new GridData(GridData.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    label.setText("Choose Kinase Protein Familes");

    cbox = new Combo(container, SWT.READ_ONLY);
    cbox.setToolTipText("Kinase family");
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    gridData.widthHint = 100;
    cbox.setLayoutData(gridData);
    String[] items = { "TK", "TKL", "STE", "CK1", "CMGC", "AGC", "CAMK" };
    cbox.setItems(items);
    cbox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            final String selected = cbox.getItem(cbox.getSelectionIndex());

            try {
                table.clearAll();
                table.removeAll();
                setErrorMessage(null);
                List<String> list = chembl.mossAvailableActivities(selected);
                if (list.size() > 0) {
                    String[] item = new String[list.size()];
                    for (int i = 0; i < list.size(); i++) {
                        item[i] = list.get(i);
                    }
                    if (cboxAct.isEnabled()) {
                        if (cboxAct.getSelection().x == cboxAct.getSelection().y) {
                            cboxAct.setItems(item);
                        } else {
                            //Solves the problem involving changing the protein family...
                            //Brings the current activities to an array
                            String oldItems[] = cboxAct.getItems();
                            // Takes that array and makes it a list
                            for (int i = 0; i < list.size(); i++) {
                                cboxAct.add(item[i]);
                            }

                            //Remove the old items in the combobox
                            int oldlistsize = cboxAct.getItemCount() - list.size();
                            index = cboxAct.getText();//cboxAct.getItem(cboxAct.getSelectionIndex());
                            cboxAct.remove(0, oldlistsize - 1);
                            //Adds new items to the comboboxlist
                            List<String> oldItemsList = new ArrayList<String>();
                            for (int i = 0; i < oldItems.length; i++) {
                                oldItemsList.add(oldItems[i]);
                            }

                            //New query with the given settings
                            //if(oldItemsList.contains((index))==true){
                            if (list.contains((index)) == true) {

                                spinn.setSelection(50);
                                IStringMatrix matrix, matrix2;
                                try {
                                    matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity(selected,
                                            index, spinn.getSelection());
                                    matrix2 = chembl.mossGetCompoundsFromProteinFamily(selected, index);
                                    cboxAct.setText(index);
                                    info.setText("Distinct compunds: " + matrix2.getRowCount());
                                    addToTable(matrix);
                                } catch (BioclipseException e1) {
                                    // TODO Auto-generated catch block
                                    e1.printStackTrace();
                                }

                            } else {
                                setErrorMessage("The activity " + index
                                        + " does not exist for the protein family " + selected + ".");
                                info.setText("Total compund hit:");
                                setPageComplete(false);

                            }
                        }
                    } else {
                        cboxAct.setItems(item);
                        cboxAct.setEnabled(true);
                    }
                }
            } catch (BioclipseException e1) {
                e1.printStackTrace();
            }
        }
    });

    /*Returns the available compunds for the family*/
    label = new Label(container, SWT.NONE);
    gridData = new GridData(GridData.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    label.setText("Choose one available activity");

    cboxAct = new Combo(container, SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    gridData.widthHint = 100;
    String[] item = { "No available activity" };
    cboxAct.setItems(item);
    cboxAct.setLayoutData(gridData);
    cboxAct.setEnabled(false);
    cboxAct.setToolTipText("These activities are only accurate for chosen protein");
    //Listener for available activities(IC50, Ki etc)
    cboxAct.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            String selected = cboxAct.getItem(cboxAct.getSelectionIndex());
            try {
                setErrorMessage(null);
                table.clearAll();
                table.removeAll();
                spinn.setSelection(50);
                check.setSelection(false);
                spinnLow.setEnabled(false);
                spinnHigh.setEnabled(false);
                spinnLow.setSelection(0);
                spinnHigh.setSelection(1000);

                //SPARQL queries for fetching compounds and activities
                IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity(
                        cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection());
                addToTable(matrix);
                //Count the amount of compounds there is for one hit, i.e. same query without limit.
                IStringMatrix matrix2 = chembl.mossGetCompoundsFromProteinFamily(
                        cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()));
                info.setText("Distinct compounds: " + matrix2.getRowCount());
                //Query for activities. Adds them to the plot series.
                matrixAct = chembl.mossGetCompoundsFromProteinFamilyWithActivity(
                        cbox.getItem(cbox.getSelectionIndex()), selected);
                //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected,50);
                //IStringMatrix matrix = chembl.MossProtFamilyCompounds(cbox.getItem(cbox.getSelectionIndex()), selected, spinn.getSelection());

                //Adds activity to histogram series
                series = new XYSeries("Activity for compounds");
                histogramSeries = new HistogramDataset();
                histogramSeries.setType(HistogramType.FREQUENCY);
                ArrayList<Double> activites = new ArrayList<Double>();
                double value;
                int cnt = 1;
                double[] histact = new double[matrixAct.getRowCount() + 1];
                for (int i = 1; i < matrixAct.getRowCount() + 1; i++) {
                    if (matrixAct.get(i, "actval").equals("")) {
                        value = 0;
                    } else {
                        value = Double.parseDouble(matrixAct.get(i, "actval"));
                    }
                    activites.add(value);
                }
                //Sort list to increasing order of activities and adds them to histogram
                Collections.sort(activites);
                for (int i = 0; i < activites.size(); i++) {
                    double d = activites.get(i);
                    histact[i] = d;
                    int t = activites.size() - 1;
                    if (i == t) {
                        series.add(d, cnt);
                    } else {
                        double dd = activites.get(i + 1);

                        if (d == dd) {
                            cnt++;
                        } else {
                            histact[i] = d;
                            series.add(d, cnt);
                            cnt = 1;
                        }
                    }
                }
                histogramSeries.addSeries("Histogram", histact, matrixAct.getRowCount());
                button.setEnabled(true);
                spinn.setEnabled(true);
                check.setEnabled(true);
                //cboxAct.setEnabled(true);
                //buttonH.setEnabled(true);

            } catch (BioclipseException e1) {
                e1.printStackTrace();
            }
            setPageComplete(true);
        }
    });

    label = new Label(container, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    label.setText("Limit");

    spinn = new Spinner(container, SWT.BORDER);
    gridData = new GridData();
    spinn.setLayoutData(gridData);
    spinn.setSelection(50);
    spinn.setMaximum(10000000);
    spinn.setIncrement(50);
    spinn.setEnabled(false);
    gridData.widthHint = 100;
    gridData.horizontalSpan = 1;
    spinn.setToolTipText("Limits the search, increases by 50");
    spinn.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            int selected = spinn.getSelection();
            try {
                table.clearAll();
                table.removeAll();
                IStringMatrix matrix = chembl.mossGetCompounds(cbox.getItem(cbox.getSelectionIndex()),
                        cboxAct.getItem(cboxAct.getSelectionIndex()), selected);
                table.setVisible(true);
                addToTable(matrix);
            } catch (BioclipseException e1) {
                e1.printStackTrace();
            }
        }
    });

    //Button that adds all hits to the limit
    button = new Button(container, SWT.PUSH);
    button.setToolTipText("Add all compounds to the table");
    button.setText("Display all");
    button.setEnabled(false);
    button.setLayoutData(gridData);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            //try {
            table.removeAll();
            //            ProgressMonitorDialog dialog = new ProgressMonitorDialog(container.getShell());
            //            
            //            try {
            //               dialog.run(true, true, new IRunnableWithProgress(){
            //                  public void run(IProgressMonitor monitor) {
            //                     monitor.beginTask("Searching for compounds", IProgressMonitor.UNKNOWN);
            try {
                IStringMatrix matrix = chembl.mossGetCompoundsFromProteinFamilyWithActivity(
                        cbox.getItem(cbox.getSelectionIndex()), cboxAct.getItem(cboxAct.getSelectionIndex()));

                //                        final IStringMatrix matrix = chembl.MossProtFamilyCompoundsAct("TK", "Ki");
                addToTable(matrix);
                info.setText("Total hit(not always distinct compounds): " + matrix.getRowCount());
                spinn.setSelection(matrix.getRowCount());

            } catch (BioclipseException eb) {
                // TODO Auto-generated catch block
                eb.printStackTrace();
            }

            //                     
            //                     monitor.done();
            //                  }
            //               });
            //            } catch (InvocationTargetException e1) {
            //               // TODO Auto-generated catch block
            //               e1.printStackTrace();
            //            } catch (InterruptedException e1) {
            //               // TODO Auto-generated catch block
            //               e1.printStackTrace();
            //            }

            //            } catch (BioclipseException e1) {
            //               // TODO Auto-generated catch block
            //               e1.printStackTrace();
            //            }
        }
    });

    label = new Label(container, SWT.NONE);
    label.setText("Optional: Modify activity values.");
    Font font1 = new Font(container.getDisplay(), "Helvetica", 13, SWT.NONE);
    label.setFont(font1);
    gridData = new GridData();
    gridData.horizontalSpan = 4;
    gridData.verticalSpan = 5;
    label.setLayoutData(gridData);

    check = new Button(container, SWT.CHECK);
    check.setText("Modify activities");
    check.setToolTipText("Modify data by specifying upper and lower activity limit");
    check.setEnabled(false);
    gridData = new GridData(GridData.BEGINNING);
    gridData.horizontalSpan = 2;
    check.setLayoutData(gridData);
    check.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            boolean selected = check.getSelection();
            if (selected == true) {
                spinnLow.setEnabled(true);
                spinnHigh.setEnabled(true);
                buttonUpdate.setEnabled(true);
                labelHigh.setEnabled(true);
                labelLow.setEnabled(true);
                buttonH.setEnabled(true);
            } else if (selected == false) {
                spinnLow.setEnabled(false);
                spinnHigh.setEnabled(false);
                buttonUpdate.setEnabled(false);
                labelHigh.setEnabled(false);
                labelLow.setEnabled(false);
                buttonH.setEnabled(false);
            }
        }
    });
    label = new Label(container, SWT.NONE);
    label.setText("Look at activity span: ");
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    label.setLayoutData(gridData);
    buttonH = new Button(container, SWT.PUSH);
    buttonH.setText("Graph");
    buttonH.setToolTipText("Shows activity in a graph(for all compounds)");
    buttonH.setEnabled(false);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    buttonH.setLayoutData(gridData);
    buttonH.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            JFreeChart jfreechart = ChartFactory.createXYLineChart("Histogram Demo", "Activity values",
                    "Number of compounds", histogramSeries, PlotOrientation.VERTICAL, true, false, false);

            //            final XYSeriesCollection dataset = new XYSeriesCollection(series);
            //            JFreeChart chart = ChartFactory.createXYBarChart(
            //                  "Activity chart",
            //                  "Activity value",
            //                  false,
            //                  "Number of Compounds", 
            //                  dataset,
            //                  PlotOrientation.VERTICAL,
            //                  true,
            //                  true,
            //                  false
            //            );
            ChartFrame frame = new ChartFrame("Activities", jfreechart);
            frame.pack();
            frame.setVisible(true);
        }
    });
    // Lower activity bound for updating table
    labelLow = new Label(container, SWT.NONE);
    labelLow.setText("Lower activity limit");
    labelLow.setEnabled(false);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    labelLow.setLayoutData(gridData);
    spinnLow = new Spinner(container, SWT.NONE);
    spinnLow.setSelection(0);
    spinnLow.setMaximum(10000000);
    spinnLow.setIncrement(50);
    spinnLow.setEnabled(false);
    spinnLow.setToolTipText("Specify lower activity limit");
    gridData = new GridData();
    gridData.widthHint = 100;
    gridData.horizontalSpan = 1;
    spinnLow.setLayoutData(gridData);

    buttonUpdate = new Button(container, SWT.PUSH);
    buttonUpdate.setText("Update table");
    buttonUpdate.setToolTipText("Update the table with the specified activity limits");
    buttonUpdate.setEnabled(false);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    buttonUpdate.setLayoutData(gridData);
    buttonUpdate.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            table.clearAll();
            table.removeAll();
            try {
                IStringMatrix matrix = chembl.mossSetActivityBound(matrixAct, spinnLow.getSelection(),
                        spinnHigh.getSelection());
                addToTable(matrix);
                spinn.setSelection(matrix.getRowCount());
                info.setText("Total compound hit: " + matrix.getRowCount());
            } catch (BioclipseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
    });

    //Upper activity bound for updating table
    labelHigh = new Label(container, SWT.NONE);
    labelHigh.setText("Upper activity limit");
    labelHigh.setEnabled(false);
    gridData = new GridData();
    gridData.horizontalSpan = 1;
    labelHigh.setLayoutData(gridData);
    spinnHigh = new Spinner(container, SWT.BORDER);
    spinnHigh.setSelection(1000);
    spinnHigh.setMaximum(1000000000);
    spinnHigh.setIncrement(50);
    spinnHigh.setEnabled(false);
    spinnHigh.setToolTipText("Specify upper activity limit");
    gridData = new GridData();
    gridData.widthHint = 100;
    gridData.horizontalSpan = 3;
    spinnHigh.setLayoutData(gridData);

    //Label for displaying compound hits
    info = new Label(container, SWT.NONE);
    gridData = new GridData();
    info.setLayoutData(gridData);
    gridData.horizontalSpan = 4;
    gridData.verticalSpan = 6;
    gridData.widthHint = 350;
    info.setText("Total compound hit:");

    //Table displaying contents
    table = new Table(container, SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.widthHint = 300;
    gridData.heightHint = 300;
    gridData.horizontalSpan = 4;
    table.setLayoutData(gridData);
    column1 = new TableColumn(table, SWT.NONE);
    column1.setText("Index");
    column2 = new TableColumn(table, SWT.NONE);
    column2.setText("Activity value");
    column3 = new TableColumn(table, SWT.NONE);
    column3.setText("Compounds (SMILES)");
}

From source file:MainClass.java

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));

    new Label(composite, SWT.LEFT).setText("E-mail Address:");
    final Text ea = new Text(composite, SWT.BORDER);
    ea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    ea.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent event) {
            email = ea.getText();//from  ww  w . j  av a  2  s  .co m
            setPageComplete(email.length() > 0);
        }
    });

    setControl(composite);
}

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

public void open(Display display) {
    clipboard = new Clipboard(display);
    shell = new Shell(display);
    shell.setText("SWT Clipboard");
    shell.setLayout(new FillLayout());

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setContent(parent);//  w  w  w  .  ja  v a 2  s  .c  om
    parent.setLayout(new GridLayout(2, true));

    Group copyGroup = new Group(parent, SWT.NONE);
    copyGroup.setText("Copy From:");
    GridData data = new GridData(GridData.FILL_BOTH);
    copyGroup.setLayoutData(data);
    copyGroup.setLayout(new GridLayout(3, false));

    Group pasteGroup = new Group(parent, SWT.NONE);
    pasteGroup.setText("Paste To:");
    data = new GridData(GridData.FILL_BOTH);
    pasteGroup.setLayoutData(data);
    pasteGroup.setLayout(new GridLayout(3, false));

    Group controlGroup = new Group(parent, SWT.NONE);
    controlGroup.setText("Control API:");
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    controlGroup.setLayoutData(data);
    controlGroup.setLayout(new GridLayout(5, false));

    Group typesGroup = new Group(parent, SWT.NONE);
    typesGroup.setText("Available Types");
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    typesGroup.setLayoutData(data);
    typesGroup.setLayout(new GridLayout(2, false));

    status = new Label(parent, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);

    createTextTransfer(copyGroup, pasteGroup);
    createRTFTransfer(copyGroup, pasteGroup);
    createHTMLTransfer(copyGroup, pasteGroup);
    createFileTransfer(copyGroup, pasteGroup);
    createImageTransfer(copyGroup, pasteGroup);
    createMyTransfer(copyGroup, pasteGroup);
    createControlTransfer(controlGroup);
    createAvailableTypes(typesGroup);

    sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);

    Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Rectangle monitorArea = shell.getMonitor().getClientArea();
    shell.setSize(Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20));
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    clipboard.dispose();
}

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

/**
 * Creates a new editor./* w w  w .  j  a  va  2 s.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(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:CheckFileTree.java

/**
 * Creates the main window's contents//from   w w  w. 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, false));

    // Add a checkbox to toggle whether the labels preserve case
    Button preserveCase = new Button(composite, SWT.CHECK);
    preserveCase.setText("&Preserve case");

    // Create the tree viewer to display the file tree
    final TreeViewer tv = new TreeViewer(composite);
    tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    tv.setContentProvider(new FileTreeContentProvider());
    tv.setLabelProvider(new FileTreeLabelProvider());
    tv.setInput("root"); // pass a non-null that will be ignored

    // When user checks the checkbox, toggle the preserve case attribute
    // of the label provider
    preserveCase.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean preserveCase = ((Button) event.widget).getSelection();
            FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider();
            ftlp.setPreserveCase(preserveCase);
        }
    });
    return composite;
}

From source file:gov.redhawk.statistics.ui.views.StatisticsView.java

/**
 * This is a callback that will allow us to create the viewer and initialize it.
 *//*from   w w  w. j a  v a 2  s .  c o  m*/
@Override
public void createPartControl(Composite comp) {

    parent = comp;
    parent.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(1).create());

    // Custom Action for the View's Menu
    CustomAction customAction = new CustomAction() {

        @Override
        public void run() {
            SettingsDialog dialog = new SettingsDialog(parent.getShell(), datalist.length, curIndex, numBars);
            dialog.create();
            if (dialog.open() == Window.OK) {
                numBars = dialog.getNumBars();
                curIndex = dialog.getSelectedIndex();
                refreshJob.schedule();
            }
        }
    };
    customAction.setText("Settings");
    getViewSite().getActionBars().getMenuManager().add(customAction);

    // creation of chart composite and selection of associated options
    Composite chartComposite = new Composite(parent, SWT.EMBEDDED);
    chartComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    chart = ChartFactory.createXYBarChart(null, null, false, null, dataSet, PlotOrientation.VERTICAL, false,
            true, false);

    org.eclipse.swt.graphics.Color backgroundColor = chartComposite.getBackground();
    chart.setBackgroundPaint(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chart.getXYPlot().setBackgroundPaint(ChartColor.WHITE);

    Frame chartFrame = SWT_AWT.new_Frame(chartComposite);
    chartFrame.setBackground(
            new Color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue()));
    chartFrame.setLayout(new GridLayout());

    ChartPanel jFreeChartPanel = new ChartPanel(chart);
    chartFrame.add(jFreeChartPanel);

    ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setMargin(0.05);
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        @Override
        public String generateLabel(XYDataset dataset, int series, int item) {
            return String.valueOf((int) (dataset.getYValue(series, item)));
        }
    });
    renderer.setBasePaint(new Color(139, 0, 0));
    renderer.setLegendItemLabelGenerator(new XYSeriesLabelGenerator() {

        @Override
        public String generateLabel(XYDataset ds, int i) {
            if (ds.getSeriesCount() == 2) {
                if (i == 0) {
                    return "Real";
                } else if (i == 1) {
                    return "Imaginary";
                } else {
                    return "Complex";
                }
            } else if (ds.getSeriesCount() > 1) {
                return "Dimension " + i;
            }

            return null;
        }
    });
    chart.getXYPlot().setRenderer(renderer);

    dataSet.addChangeListener(new DatasetChangeListener() {

        @Override
        public void datasetChanged(DatasetChangeEvent event) {
            chart.getPlot().datasetChanged(event);

        }
    });

    // creation of the statistics composite
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    section = toolkit.createSection(parent, Section.DESCRIPTION | Section.NO_TITLE | Section.CLIENT_INDENT);
    section.setBackground(parent.getBackground());
    section.setDescription("");
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent

    // Composite for storing the data
    Composite composite = toolkit.createComposite(section, SWT.WRAP);
    composite.setBackground(parent.getBackground());
    composite.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(4).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); // layout within parent
    toolkit.paintBordersFor(composite);
    section.setClient(composite);

    for (int j = 0; j < STAT_PROPS.length; j++) {
        Label label = new Label(composite, SWT.None);
        label.setText(STAT_PROPS[j] + ":");
        labels[j] = new Label(composite, SWT.None);
        labels[j].setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    }

}

From source file:edu.isistan.carcha.plugin.editors.DXMIEditor.java

/**
 * Creates the DDD list page./*from w ww . jav  a  2s . c o  m*/
 */
void createListPage() {
    final Composite composite = new Composite(getContainer(), SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 4));
    composite.setLayout(new GridLayout());
    Label concernLabel = new Label(composite, SWT.BORDER);
    concernLabel.setText("Design Decisions");
    concernLabel.setToolTipText("This are the Design Decisions detected in the architectural document");
    GridData gridData = new GridData(SWT.LEFT, SWT.LEFT, false, false);
    concernLabel.setLayoutData(gridData);

    ddsViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    createColumns(composite, ddsViewer);

    final Table table = ddsViewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    ddsViewer.setContentProvider(new ArrayContentProvider());

    getSite().setSelectionProvider(ddsViewer);
    // define layout for the viewer
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    ddsViewer.getControl().setLayoutData(gridData);

    int index = addPage(composite);
    setPageText(index, "List");
}