Example usage for org.eclipse.swt.custom ScrolledComposite setExpandVertical

List of usage examples for org.eclipse.swt.custom ScrolledComposite setExpandVertical

Introduction

In this page you can find the example usage for org.eclipse.swt.custom ScrolledComposite setExpandVertical.

Prototype

public void setExpandVertical(boolean expand) 

Source Link

Document

Configure the ScrolledComposite to resize the content object to be as tall as the ScrolledComposite when the height of the ScrolledComposite is greater than the minimum height specified in setMinHeight.

Usage

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

/**
 * Creates the impact list page.//  ww w. j  a  v a2  s.  c  om
 */
void impactListPage() {
    final Composite composite = new Composite(getContainer(), SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
    composite.setLayout(new GridLayout());

    Label concernLabel = new Label(composite, SWT.BORDER);
    concernLabel.setText("Crosccuting Concerns(CCC)");
    concernLabel.setToolTipText("This are the concern detected on the requierement document.");
    GridData gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    concernLabel.setLayoutData(gridData);

    /////////////////////
    ScrolledComposite sc = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    parent.setLayout(new GridLayout());

    topViewLink = new TableViewer(parent, SWT.BORDER);
    createColumns(parent, topViewLink);

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

    topViewLink.setContentProvider(new ArrayContentProvider());

    getSite().setSelectionProvider(topViewLink);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.heightHint = 10 * table.getItemHeight();
    table.setLayoutData(data);

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

    /////////////////////

    Button button = new Button(composite, SWT.PUSH);
    button.setText("Remove");
    button.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent event) {
        }

        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection topSelection = (IStructuredSelection) topViewLink.getSelection();
            IStructuredSelection bottomSelection = (IStructuredSelection) bottomViewLink.getSelection();

            String[] crosscuttingConcern = (String[]) topSelection.getFirstElement();
            String[] designDecision = (String[]) bottomSelection.getFirstElement();
            if (topSelection.size() > 1) {
                MessageDialog.openError(composite.getShell(), "Error",
                        "Please select one crosscutting concern");
            } else {
                if ((crosscuttingConcern != null) && (designDecision != null)) {
                    // create dialog with ok and cancel button and info icon
                    MessageBox dialog = new MessageBox(composite.getShell(),
                            SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
                    dialog.setText("Link confirmation");
                    dialog.setMessage("Do you want to remove the link between the selected items?");

                    // open dialog and await user selection
                    int response = dialog.open();
                    if (response == SWT.OK) {
                        PluginUtil.removeLink(crosscuttingConcern, designDecision, cp);
                        dirty = true;
                        firePropertyChange(IEditorPart.PROP_DIRTY);
                        // update the list after the remove
                        generateLinkViewData();
                        bottomViewLink.getTable().clearAll();
                    }
                } else {
                    MessageDialog.openError(composite.getShell(), "Error",
                            "Please select a crosscutting concern and a design decision to remove a traceability link");
                }
            }
        }
    });
    gridData = new GridData(SWT.CENTER, SWT.TOP, false, false, 2, 1);
    button.setLayoutData(gridData);

    Label ddsLabel = new Label(composite, SWT.BORDER);
    ddsLabel.setText("Architectural design decisions");
    ddsLabel.setToolTipText("This are the design decisions detected on the architectural document");

    gridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    ddsLabel.setLayoutData(gridData);

    bottomViewLink = new TableViewer(composite,
            SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    createColumns(composite, bottomViewLink);
    Table table2 = bottomViewLink.getTable();
    table2.setHeaderVisible(true);
    table2.setLinesVisible(true);
    bottomViewLink.setContentProvider(new ArrayContentProvider());
    topViewLink.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                String[] cccs = (String[]) selection.getFirstElement();
                List<DesignDecision> dds = PluginUtil.getDesignDecisionsForCrossCuttingConcern(cp, cccs[1],
                        cccs[0]);
                logger.info("Impact List for CCC (" + dds.size() + " DDD): " + cccs[0] + " - " + cccs[1]);
                List<String[]> designDecisions = new ArrayList<String[]>();

                for (DesignDecision dd : dds) {
                    String[] designDecision = { dd.getKind(), dd.getName() };
                    designDecisions.add(designDecision);
                }
                bottomViewLink.setInput(designDecisions);
            }
        }
    });
    getSite().setSelectionProvider(bottomViewLink);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    bottomViewLink.getControl().setLayoutData(gridData);

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

From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java

private void initAnalystContributionsGroup(Composite parent) {
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;

    Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
    group.setLayout(new GridLayout(1, false));
    group.setLayoutData(gridData);/*from  w ww. j  a  v  a2 s . com*/
    group.setText("Analyst Contributions");
    fillAnalystContributionsGroup(group);

    final ScrolledComposite scrolled = new ScrolledComposite(group, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolled.setLayoutData(new GridData(GridData.FILL_BOTH));
    contList = UIUtils.createScrolledBody(scrolled, SWT.NONE);
    contList.setLayout(new GridLayout(1, false));

    scrolled.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            scrolled.setMinSize(contList.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    });
    scrolled.setAlwaysShowScrollBars(true);
    scrolled.setContent(contList);
    scrolled.setMinSize(contList.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);
}

From source file: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);/*from  ww  w .  j av a2 s.c  o  m*/
    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_BOTH);
    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_BOTH);
    data.horizontalSpan = 2;
    typesGroup.setLayoutData(data);
    typesGroup.setLayout(new GridLayout(2, false));

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

    createTextTransfer(copyGroup, pasteGroup);
    createRTFTransfer(copyGroup, pasteGroup);
    createHTMLTransfer(copyGroup, pasteGroup);
    createFileTransfer(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:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_IndependentField, EMPTY, image, 1);
    cboXField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_DependentField, EMPTY, image, 1);
    cboYField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, null, null, 1);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1);
    chkPearson = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_Pearson, null, 1);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override/*from w  w w. j a  v a 2 s. c o  m*/
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboXField, inputLayer.getSchema(), FieldType.Number);
                fillFields(cboYField, inputLayer.getSchema(), FieldType.Number);
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:com.planetmayo.debrief.satc_rcp.views.MaintainContributionsView.java

private void initPreferencesGroup(Composite parent) {
    GridData gridData = new GridData();
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;

    Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
    GridLayout layout = new GridLayout(1, false);
    group.setLayoutData(gridData);//from  w w  w.j  a va 2s  .c o  m
    group.setLayout(layout);
    group.setText("Preferences");

    final ScrolledComposite scrolled = new ScrolledComposite(group, SWT.H_SCROLL);
    scrolled.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Composite preferencesComposite = UIUtils.createScrolledBody(scrolled, SWT.NONE);
    preferencesComposite.setLayout(new GridLayout(6, false));

    scrolled.addListener(SWT.Resize, new Listener() {

        @Override
        public void handleEvent(Event e) {
            scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
        }
    });
    scrolled.setAlwaysShowScrollBars(true);
    scrolled.setContent(preferencesComposite);
    scrolled.setMinSize(preferencesComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);

    liveConstraints = new Button(preferencesComposite, SWT.TOGGLE);
    liveConstraints.setText("Auto-Recalc of Constraints");
    liveConstraints.setEnabled(false);
    liveConstraints
            .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER));

    recalculate = new Button(preferencesComposite, SWT.DEFAULT);
    recalculate.setText("Calculate Solution");
    recalculate.setEnabled(false);
    recalculate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (activeSolver != null) {
                // ok - make sure the performance tab is open
                graphTabs.setSelection(performanceTab);

                activeSolver.run(true, true);
                main.setSize(0, 0);
                main.getParent().layout(true, true);
            }
        }
    });
    recalculate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER));

    cancelGeneration = new Button(preferencesComposite, SWT.PUSH);
    cancelGeneration.setText("Cancel");
    cancelGeneration.setVisible(false);
    cancelGeneration.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (activeSolver != null) {
                activeSolver.cancel();
            }
        }
    });

    suppressCuts = new Button(preferencesComposite, SWT.CHECK);
    suppressCuts.setText("Suppress Cuts");
    suppressCuts.setVisible(true);
    suppressCuts.setEnabled(false);
    suppressCuts.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (activeSolver != null) {
                boolean doSuppress = suppressCuts.getSelection();
                activeSolver.setAutoSuppress(doSuppress);
            }
        }
    });

    showOSCourse = new Button(preferencesComposite, SWT.CHECK);
    showOSCourse.setText("Plot O/S Course");
    showOSCourse.setVisible(true);
    showOSCourse.setEnabled(false);
    showOSCourse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (activeSolver != null) {
                redoOwnshipStates();
            }
        }
    });

    Composite precisionPanel = new Composite(preferencesComposite, SWT.NONE);
    precisionPanel.setLayoutData(new GridData(
            GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));

    GridLayout precisionLayout = new GridLayout(2, false);
    precisionLayout.horizontalSpacing = 5;
    precisionPanel.setLayout(precisionLayout);

    Label precisionLabel = new Label(precisionPanel, SWT.NONE);
    precisionLabel.setText("Precision:");
    precisionLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER));

    precisionsCombo = new ComboViewer(precisionPanel);
    precisionsCombo.getCombo().setEnabled(false);
    precisionsCombo.setContentProvider(new ArrayContentProvider());
    precisionsCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((Precision) element).getLabel();
        }
    });
    precisionsCombo.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = precisionsCombo.getSelection();
            IStructuredSelection cSel = (IStructuredSelection) sel;
            Precision precision = (Precision) cSel.getFirstElement();
            if (activeSolver != null) {
                activeSolver.setPrecision(precision);
            }
        }
    });
}

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);/*from  ww  w . j av  a 2s . com*/
    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:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_XField, EMPTY, image, 1);
    cboXField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_YField, EMPTY, image, 1);
    cboYField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.BubbleChartDialog_SizeField, EMPTY, image, 1);
    cboSize = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, null, null, 1);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override//from   ww  w .  j  a  v  a2 s. c o m
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboXField, inputLayer.getSchema(), FieldType.Number);
                fillFields(cboYField, inputLayer.getSchema(), FieldType.Number);
                fillFields(cboSize, inputLayer.getSchema(), FieldType.Number);
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.ScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.BoxPlotDialog_Fields, EMPTY, image, 1);
    schemaTable = uiBuilder.createTable(container, new String[] { Messages.General_Name }, 1);
    schemaTable.addSelectionListener(new SelectionAdapter() {
        @Override//www. ja va 2s .c  o  m
        public void widgetSelected(SelectionEvent event) {
            StringBuffer buffer = new StringBuffer();
            for (TableItem item : schemaTable.getItems()) {
                if (item.getChecked()) {
                    if (buffer.length() > 0) {
                        buffer.append(",").append(item.getText()); //$NON-NLS-1$
                    } else {
                        buffer.append(item.getText());
                    }
                }
            }
            selectedFields = buffer.toString();
        }
    });

    uiBuilder.createLabel(container, null, null, 1);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 1);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            schemaTable.removeAll();
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                for (AttributeDescriptor dsc : inputLayer.getSchema().getAttributeDescriptors()) {
                    Class<?> binding = dsc.getType().getBinding();
                    if (Number.class.isAssignableFrom(binding)) {
                        TableItem item = new TableItem(schemaTable, SWT.NULL);
                        item.setText(dsc.getLocalName());
                    }
                }
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.HistogramDialog_InputLayer, EMPTY, image, 2);
    cboLayer = uiBuilder.createCombo(container, 2, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.HistogramDialog_InputField, EMPTY, image, 2);
    cboField = uiBuilder.createCombo(container, 2, true);

    uiBuilder.createLabel(container, Messages.HistogramDialog_BinCount, EMPTY, image, 2);
    spinner = uiBuilder.createSpinner(container, 10, 1, 50, 0, 1, 5, 2);

    // yXais Type
    uiBuilder.createLabel(container, Messages.HistogramDialog_YAxisType, EMPTY, image, 1);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;/*from   w  ww  .  ja v a 2 s  . com*/

    Composite subCon = new Composite(container, SWT.NONE);
    subCon.setLayout(layout);
    subCon.setLayoutData(new GridData(SWT.LEFT_TO_RIGHT, SWT.CENTER, false, false, 1, 1));
    final Button chkRatio = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Ratio, null, 1);
    final Button chkFrequency = uiBuilder.createRadioButton(subCon, Messages.HistogramDialog_Frequency, null,
            1);
    chkFrequency.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkFrequency.getSelection()) {
                histogramType = HistogramType.FREQUENCY;
            }
        }
    });
    chkRatio.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (chkRatio.getSelection()) {
                histogramType = HistogramType.RELATIVE_FREQUENCY;
            }
        }
    });
    chkRatio.setSelection(true);

    uiBuilder.createLabel(container, null, null, 2);
    chkStatistics = uiBuilder.createCheckbox(container, Messages.ScatterPlotDialog_BasicStatistics, null, 2);

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer != null) {
                fillFields(cboField, inputLayer.getSchema(), FieldType.Number);
            }
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}

From source file:org.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

private void createInputTab(final CTabFolder parentTabFolder) {
    inputTab = new CTabItem(parentTabFolder, SWT.NONE);
    inputTab.setText(Messages.ProcessExecutionDialog_tabparameters);

    ScrolledComposite scroller = new ScrolledComposite(parentTabFolder, SWT.NONE | SWT.V_SCROLL | SWT.H_SCROLL);
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Composite container = new Composite(scroller, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    // local moran's i
    Image image = ToolboxPlugin.getImageDescriptor("icons/public_co.gif").createImage(); //$NON-NLS-1$
    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputLayer, EMPTY, image, 1);
    cboLayer = uiBuilder.createCombo(container, 1, true);
    fillLayers(map, cboLayer, VectorLayerType.ALL);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_InputField, EMPTY, image, 1);
    cboField = uiBuilder.createCombo(container, 1, true);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Conceptualization, EMPTY, 1);
    cboConcept = uiBuilder.createCombo(container, 1, true);
    cboConcept.addModifyListener(new ModifyListener() {
        @Override// ww  w. j  a va  2  s .  c om
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : SpatialConcept.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboConcept.getText())) {
                    params.put(GlobalMoransIProcessFactory.spatialConcept.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboConcept, SpatialConcept.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceMethod, EMPTY, 1);
    cboDistance = uiBuilder.createCombo(container, 1, true);
    cboDistance.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : DistanceMethod.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboDistance.getText())) {
                    params.put(GlobalMoransIProcessFactory.distanceMethod.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboDistance, DistanceMethod.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_Standardization, EMPTY, 1);
    cboStandard = uiBuilder.createCombo(container, 1, true);
    cboStandard.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            for (Object enumVal : StandardizationMethod.class.getEnumConstants()) {
                if (enumVal.toString().equalsIgnoreCase(cboStandard.getText())) {
                    params.put(GlobalMoransIProcessFactory.standardization.key, enumVal);
                    break;
                }
            }
        }
    });
    fillEnum(cboStandard, StandardizationMethod.class);

    uiBuilder.createLabel(container, Messages.MoranScatterPlotDialog_DistanceBand, EMPTY, 1);
    final Text txtDistance = uiBuilder.createText(container, EMPTY, 1, true);
    txtDistance.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            Object obj = Converters.convert(txtDistance.getText(), Double.class);
            if (obj == null) {
                params.put(GlobalMoransIProcessFactory.searchDistance.key, Double.valueOf(0d));
            } else {
                params.put(GlobalMoransIProcessFactory.searchDistance.key, obj);
            }
        }
    });

    // register events
    cboLayer.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            inputLayer = MapUtils.getLayer(map, cboLayer.getText());
            if (inputLayer == null) {
                return;
            }
            SimpleFeatureCollection features = MapUtils.getFeatures(inputLayer);
            params.put(GlobalMoransIProcessFactory.inputFeatures.key, features);
            fillFields(cboField, inputLayer.getSchema(), FieldType.Number);
        }
    });

    cboField.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            params.put(GlobalMoransIProcessFactory.inputField.key, cboField.getText());
        }
    });

    // finally
    scroller.setContent(container);
    inputTab.setControl(scroller);

    scroller.setMinSize(450, container.getSize().y - 2);
    scroller.setExpandVertical(true);
    scroller.setExpandHorizontal(true);

    scroller.pack();
    container.pack();
}