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:au.gov.ansto.bragg.kakadu.ui.plot.FitPlotPropertiesComposite.java

private void initialise() {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;/*from  w ww  .ja  v  a 2s  .c  om*/
    gridLayout.marginHeight = 3;
    gridLayout.marginWidth = 3;
    gridLayout.horizontalSpacing = 3;
    gridLayout.verticalSpacing = 3;
    setLayout(gridLayout);

    fitEnabledButton = new Button(this, SWT.CHECK);
    fitEnabledButton.setText("Fitting Enabled");
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    fitEnabledButton.setLayoutData(data);

    fitFunctionCombo = new Combo(this, SWT.READ_ONLY);
    fitFunctionCombo.setEnabled(false);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.verticalIndent = 3;
    data.grabExcessHorizontalSpace = true;
    fitFunctionCombo.setLayoutData(data);

    //      inverseLabel = new Label(this, SWT.NONE);
    //      inverseLabel.setText("inverse function");
    //      data = new GridData ();
    //      data.verticalAlignment = GridData.BEGINNING;
    //      data.verticalIndent = 3;
    //      inverseLabel.setLayoutData(data);
    //      inverseLabel.setEnabled(false);

    inverseButton = new Button(this, SWT.CHECK);
    inverseButton.setText("Inverted Model");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalIndent = 3;
    data.grabExcessHorizontalSpace = true;
    inverseButton.setLayoutData(data);
    inverseButton.setEnabled(false);
    //      fitFunctionCombo.setLayoutData (data);

    Composite xComposite = new Composite(this, SWT.NULL);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 4;
    //      gridLayout.marginHeight = 3;
    gridLayout.marginWidth = 0;
    //      gridLayout.horizontalSpacing = 3;
    //      gridLayout.verticalSpacing = 3;
    xComposite.setLayout(gridLayout);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    xComposite.setLayoutData(data);

    minXButton = new Button(xComposite, SWT.TOGGLE);
    minXButton.setText("X min");
    minXButton.setToolTipText("Click to enable grabing a point from the plot as the beginning of fitting data");
    data = new GridData();
    //      data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    //      data.grabExcessHorizontalSpace = true;
    //      data.grabExcessVerticalSpace = true;
    minXButton.setLayoutData(data);
    minXButton.setEnabled(false);

    minXText = new Text(xComposite, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    //      data.grabExcessVerticalSpace = true;
    minXText.setLayoutData(data);
    minXText.setEnabled(false);

    maxXButton = new Button(xComposite, SWT.TOGGLE);
    maxXButton.setText("X max");
    maxXButton.setToolTipText("Click to enable grabing a point from the plot as the end of fitting data");
    data = new GridData();
    //      data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    //      data.grabExcessHorizontalSpace = true;
    //      data.grabExcessVerticalSpace = true;
    maxXButton.setLayoutData(data);
    maxXButton.setEnabled(false);

    maxXText = new Text(xComposite, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    //      data.grabExcessVerticalSpace = true;
    maxXText.setLayoutData(data);
    maxXText.setEnabled(false);

    doFitButton = new Button(this, SWT.PUSH);
    doFitButton.setText("Fit");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    //      data.grabExcessVerticalSpace = true;
    doFitButton.setLayoutData(data);
    doFitButton.setEnabled(false);

    resetButton = new Button(this, SWT.PUSH);
    resetButton.setText("Reset");
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    data.grabExcessHorizontalSpace = true;
    resetButton.setLayoutData(data);
    resetButton.setEnabled(false);

    parameterGroup = new Group(this, SWT.NONE);
    parameterGroup.setText("Parameters");
    GridLayout propertiesGridLayout = new GridLayout();
    propertiesGridLayout.numColumns = 2;
    propertiesGridLayout.marginHeight = 3;
    propertiesGridLayout.marginWidth = 3;
    propertiesGridLayout.horizontalSpacing = 3;
    propertiesGridLayout.verticalSpacing = 3;
    parameterGroup.setLayout(propertiesGridLayout);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    data.verticalAlignment = GridData.BEGINNING;
    parameterGroup.setLayoutData(data);

}

From source file:org.eclipse.swt.snippets.SnippetExplorer.java

/** Initialize the SnippetExplorer controls.
 *
 * @param shell parent shell/* ww  w.j a  v  a 2 s  .  c  o  m*/
 */
private void createControls(Shell shell) {
    shell.setLayout(new FormLayout());

    if (listUpdater == null) {
        listUpdater = new ListUpdater();
        listUpdater.start();
    }

    final Composite leftContainer = new Composite(shell, SWT.NONE);
    leftContainer.setLayout(new GridLayout());

    final Sash splitter = new Sash(shell, SWT.BORDER | SWT.VERTICAL);
    final int splitterWidth = 3;
    splitter.addListener(SWT.Selection, e -> splitter.setBounds(e.x, e.y, e.width, e.height));

    final Composite rightContainer = new Composite(shell, SWT.NONE);
    rightContainer.setLayout(new GridLayout());

    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(splitter, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(100, 0);
    leftContainer.setLayoutData(formData);

    formData = new FormData();
    formData.left = new FormAttachment(50, 0);
    formData.right = new FormAttachment(50, splitterWidth);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(100, 0);
    splitter.setLayoutData(formData);
    splitter.addListener(SWT.Selection, event -> {
        final FormData splitterFormData = (FormData) splitter.getLayoutData();
        splitterFormData.left = new FormAttachment(0, event.x);
        splitterFormData.right = new FormAttachment(0, event.x + splitterWidth);
        shell.layout();
    });

    formData = new FormData();
    formData.left = new FormAttachment(splitter, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(100, 0);
    rightContainer.setLayoutData(formData);

    filterField = new Text(leftContainer,
            SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
    filterField.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    filterField.setMessage(FILTER_HINT);
    filterField.addListener(SWT.Modify, event -> {
        listUpdater.updateInMs(FILTER_DELAY_MS);
    });
    snippetTable = new Table(leftContainer, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    snippetTable.setLinesVisible(true);
    snippetTable.setHeaderVisible(true);
    final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 500;
    snippetTable.setLayoutData(data);
    snippetTable.addListener(SWT.MouseDoubleClick, event -> {
        final Point clickPoint = new Point(event.x, event.y);
        launchSnippet(snippetTable.getItem(clickPoint));
    });
    snippetTable.addListener(SWT.KeyUp, event -> {
        if (event.keyCode == '\r' || event.keyCode == '\n') {
            launchSnippet(snippetTable.getSelection());
        }
    });

    final Composite buttonRow = new Composite(leftContainer, SWT.NONE);
    buttonRow.setLayout(new GridLayout(3, false));
    buttonRow.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    startSelectedButton = new Button(buttonRow, SWT.LEAD);
    startSelectedButton.setText("  Start &selected Snippets");
    snippetTable.addListener(SWT.Selection, event -> {
        startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0);
        updateInfoTab(snippetTable.getSelection());
    });
    startSelectedButton.setEnabled(snippetTable.getSelectionCount() > 0);
    startSelectedButton.addListener(SWT.Selection, event -> {
        launchSnippet(snippetTable.getSelection());
    });

    final Label runnerLabel = new Label(buttonRow, SWT.NONE);
    runnerLabel.setText("Snippet Runner:");
    runnerLabel.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));

    runnerCombo = new Combo(buttonRow, SWT.TRAIL | SWT.DROP_DOWN | SWT.READ_ONLY);
    runnerMapping.clear();
    if (multiDisplaySupport) {
        runnerCombo.add("Thread");
        runnerMapping.add(THREAD_RUNNER);
    }
    if (javaCommand != null) {
        runnerCombo.add("Process");
        runnerMapping.add(PROCESS_RUNNER);
    }
    runnerCombo.add("Serial");
    runnerMapping.add(null);
    runnerCombo.setData(runnerMapping);
    runnerCombo.addListener(SWT.Modify, event -> {
        if (runnerMapping.size() > runnerCombo.getSelectionIndex()) {
            snippetRunner = runnerMapping.get(runnerCombo.getSelectionIndex());
        } else {
            System.err.println("Unknown runner index " + runnerCombo.getSelectionIndex());
        }
    });
    runnerCombo.select(0);

    infoTabs = new TabFolder(rightContainer, SWT.TOP);
    infoTabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    descriptionView = new StyledText(infoTabs, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);

    sourceView = new StyledText(infoTabs, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
    setMonospaceFont(sourceView);

    final ScrolledComposite previewContainer = new ScrolledComposite(infoTabs, SWT.V_SCROLL | SWT.H_SCROLL);
    previewImageLabel = new Label(previewContainer, SWT.NONE);
    previewContainer.setContent(previewImageLabel);

    final TabItem descriptionTab = new TabItem(infoTabs, SWT.NONE);
    descriptionTab.setText("Description");
    descriptionTab.setControl(descriptionView);
    final TabItem sourceTab = new TabItem(infoTabs, SWT.NONE);
    sourceTab.setText("Source");
    sourceTab.setControl(sourceView);
    final TabItem previewTab = new TabItem(infoTabs, SWT.NONE);
    previewTab.setText("Preview");
    previewTab.setControl(previewContainer);

    updateInfoTab(null, true);
    updateInfoTab(snippetTable.getSelection());
}

From source file:DNDExample.java

private void createDropTypes(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    Button b = new Button(parent, SWT.CHECK);
    b.setText("Text Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDropTransfer(TextTransfer.getInstance());
            } else {
                removeDropTransfer(TextTransfer.getInstance());
            }//from w  w  w.j  a va  2  s .co  m
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("RTF Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDropTransfer(RTFTransfer.getInstance());
            } else {
                removeDropTransfer(RTFTransfer.getInstance());
            }
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("HTML Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDropTransfer(HTMLTransfer.getInstance());
            } else {
                removeDropTransfer(HTMLTransfer.getInstance());
            }
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("File Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDropTransfer(FileTransfer.getInstance());
            } else {
                removeDropTransfer(FileTransfer.getInstance());
            }
        }
    });
}

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;/*from  w w  w .j  a va2  s.  c o m*/
    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:DNDExample.java

private void createDropWidget(Composite parent) {
    parent.setLayout(new FormLayout());
    Combo combo = new Combo(parent, SWT.READ_ONLY);
    combo.setItems(new String[] { "Toggle Button", "Radio Button", "Checkbox", "Canvas", "Label", "List",
            "Table", "Tree", "Text" });
    combo.select(LABEL);/*  w  ww  .j a  v a  2s . com*/
    dropControlType = combo.getSelectionIndex();
    dropControl = createWidget(dropControlType, parent, "Drop Target");
    combo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Object data = dropControl.getLayoutData();
            Composite parent = dropControl.getParent();
            dropControl.dispose();
            Combo c = (Combo) e.widget;
            dropControlType = c.getSelectionIndex();
            dropControl = createWidget(dropControlType, parent, "Drop Target");
            dropControl.setLayoutData(data);
            if (dropEnabled)
                createDropTarget();
            parent.layout();
        }
    });

    Button b = new Button(parent, SWT.CHECK);
    b.setText("DropTarget");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            dropEnabled = b.getSelection();
            if (dropEnabled) {
                createDropTarget();
            } else {
                if (dropTarget != null) {
                    dropTarget.dispose();
                }
                dropTarget = null;
            }
        }
    });

    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.bottom = new FormAttachment(combo, -10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(100, -10);
    dropControl.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(0, 10);
    combo.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(combo, 10);
    b.setLayoutData(data);
}

From source file:DNDExample.java

private void createDragWidget(Composite parent) {
    parent.setLayout(new FormLayout());
    Combo combo = new Combo(parent, SWT.READ_ONLY);
    combo.setItems(new String[] { "Toggle Button", "Radio Button", "Checkbox", "Canvas", "Label", "List",
            "Table", "Tree" });
    combo.select(LABEL);//from   ww  w . j a  v a2s. co  m
    dragControlType = combo.getSelectionIndex();
    dragControl = createWidget(dragControlType, parent, "Drag Source");

    combo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Object data = dragControl.getLayoutData();
            Composite parent = dragControl.getParent();
            dragControl.dispose();
            Combo c = (Combo) e.widget;
            dragControlType = c.getSelectionIndex();
            dragControl = createWidget(dragControlType, parent, "Drag Source");
            dragControl.setLayoutData(data);
            if (dragEnabled)
                createDragSource();
            parent.layout();
        }
    });

    Button b = new Button(parent, SWT.CHECK);
    b.setText("DragSource");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            dragEnabled = b.getSelection();
            if (dragEnabled) {
                createDragSource();
            } else {
                if (dragSource != null) {
                    dragSource.dispose();
                }
                dragSource = null;
            }
        }
    });

    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.bottom = new FormAttachment(combo, -10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(100, -10);
    dragControl.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(0, 10);
    combo.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(combo, 10);
    b.setLayoutData(data);
}

From source file:DNDExample.java

private void createDragOperations(Composite parent) {
    parent.setLayout(new RowLayout(SWT.VERTICAL));
    final Button moveButton = new Button(parent, SWT.CHECK);
    moveButton.setText("DND.DROP_MOVE");
    moveButton.setSelection(true);//from  ww w .j  a  v  a2  s  .com
    dragOperation = DND.DROP_MOVE;
    moveButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                dragOperation |= DND.DROP_MOVE;
            } else {
                dragOperation = dragOperation & ~DND.DROP_MOVE;
                if (dragOperation == 0) {
                    dragOperation = DND.DROP_MOVE;
                    moveButton.setSelection(true);
                }
            }
            if (dragEnabled) {
                createDragSource();
            }
        }
    });

    Button b = new Button(parent, SWT.CHECK);
    b.setText("DND.DROP_COPY");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                dragOperation |= DND.DROP_COPY;
            } else {
                dragOperation = dragOperation & ~DND.DROP_COPY;
                if (dragOperation == 0) {
                    dragOperation = DND.DROP_MOVE;
                    moveButton.setSelection(true);
                }
            }
            if (dragEnabled) {
                createDragSource();
            }
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("DND.DROP_LINK");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                dragOperation |= DND.DROP_LINK;
            } else {
                dragOperation = dragOperation & ~DND.DROP_LINK;
                if (dragOperation == 0) {
                    dragOperation = DND.DROP_MOVE;
                    moveButton.setSelection(true);
                }
            }
            if (dragEnabled) {
                createDragSource();
            }
        }
    });
}

From source file:DNDExample.java

private void createDragTypes(Composite parent) {
    parent.setLayout(new GridLayout());
    Button b = new Button(parent, SWT.CHECK);
    b.setText("Text Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDragTransfer(TextTransfer.getInstance());
            } else {
                removeDragTransfer(TextTransfer.getInstance());
            }/*from w w w  .  j  av  a  2 s  . c  om*/
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("RTF Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDragTransfer(RTFTransfer.getInstance());
            } else {
                removeDragTransfer(RTFTransfer.getInstance());
            }
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("HTML Transfer");
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDragTransfer(HTMLTransfer.getInstance());
            } else {
                removeDragTransfer(HTMLTransfer.getInstance());
            }
        }
    });

    b = new Button(parent, SWT.CHECK);
    b.setText("File Transfer");
    b.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            Button b = (Button) e.widget;
            if (b.getSelection()) {
                addDragTransfer(FileTransfer.getInstance());
            } else {
                removeDragTransfer(FileTransfer.getInstance());
            }
        }
    });
    b = new Button(parent, SWT.PUSH);
    b.setText("Select File(s)");
    b.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    b.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(fileList.getShell(), SWT.OPEN | SWT.MULTI);
            String result = dialog.open();
            if (result != null && result.length() > 0) {
                fileList.removeAll();
                String separator = System.getProperty("file.separator");
                String path = dialog.getFilterPath();
                String[] names = dialog.getFileNames();
                for (int i = 0; i < names.length; i++) {
                    fileList.add(path + separator + names[i]);
                }
            }
        }
    });
    fileList = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData data = new GridData();
    data.grabExcessHorizontalSpace = true;
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.BEGINNING;
    fileList.setLayoutData(data);
}

From source file:org.eclipse.swt.examples.dnd.DNDExample.java

private void createDragWidget(Composite parent) {
    parent.setLayout(new FormLayout());
    Combo combo = new Combo(parent, SWT.READ_ONLY);
    combo.setItems("Toggle Button", "Radio Button", "Checkbox", "Canvas", "Label", "List", "Table", "Tree",
            "Text", "StyledText", "Combo");
    combo.select(LABEL);//from   www . java  2s . co  m
    dragControlType = combo.getSelectionIndex();
    dragControl = createWidget(dragControlType, parent, "Drag Source");

    combo.addSelectionListener(widgetSelectedAdapter(e -> {
        Object data = dragControl.getLayoutData();
        Composite dragParent = dragControl.getParent();
        dragControl.dispose();
        Combo c = (Combo) e.widget;
        dragControlType = c.getSelectionIndex();
        dragControl = createWidget(dragControlType, dragParent, "Drag Source");
        dragControl.setLayoutData(data);
        if (dragEnabled)
            createDragSource();
        dragParent.layout();
    }));

    Button b = new Button(parent, SWT.CHECK);
    b.setText("DragSource");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button b1 = (Button) e.widget;
        dragEnabled = b1.getSelection();
        if (dragEnabled) {
            createDragSource();
        } else {
            if (dragSource != null) {
                dragSource.dispose();
            }
            dragSource = null;
        }
    }));
    b.setSelection(true);
    dragEnabled = true;

    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.bottom = new FormAttachment(combo, -10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(100, -10);
    dragControl.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(0, 10);
    combo.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(combo, 10);
    b.setLayoutData(data);
}

From source file:org.eclipse.swt.examples.dnd.DNDExample.java

private void createDropWidget(Composite parent) {
    parent.setLayout(new FormLayout());
    Combo combo = new Combo(parent, SWT.READ_ONLY);
    combo.setItems("Toggle Button", "Radio Button", "Checkbox", "Canvas", "Label", "List", "Table", "Tree",
            "Text", "StyledText", "Combo");
    combo.select(LABEL);//from  www  .  j  a  v a  2  s.co  m
    dropControlType = combo.getSelectionIndex();
    dropControl = createWidget(dropControlType, parent, "Drop Target");
    combo.addSelectionListener(widgetSelectedAdapter(e -> {
        Object data = dropControl.getLayoutData();
        Composite dropParent = dropControl.getParent();
        dropControl.dispose();
        Combo c = (Combo) e.widget;
        dropControlType = c.getSelectionIndex();
        dropControl = createWidget(dropControlType, dropParent, "Drop Target");
        dropControl.setLayoutData(data);
        if (dropEnabled)
            createDropTarget();
        dropParent.layout();
    }));

    Button b = new Button(parent, SWT.CHECK);
    b.setText("DropTarget");
    b.addSelectionListener(widgetSelectedAdapter(e -> {
        Button eb = (Button) e.widget;
        dropEnabled = eb.getSelection();
        if (dropEnabled) {
            createDropTarget();
        } else {
            if (dropTarget != null) {
                dropTarget.dispose();
            }
            dropTarget = null;
        }
    }));
    // initialize state
    b.setSelection(true);
    dropEnabled = true;

    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.bottom = new FormAttachment(combo, -10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(100, -10);
    dropControl.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(0, 10);
    combo.setLayoutData(data);

    data = new FormData();
    data.bottom = new FormAttachment(100, -10);
    data.left = new FormAttachment(combo, 10);
    b.setLayoutData(data);
}