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

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

Introduction

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

Prototype

public void setContent(Control content) 

Source Link

Document

Set the content that will be scrolled.

Usage

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

/** Initialize the SnippetExplorer controls.
 *
 * @param shell parent shell/*from   ww  w.j  a  v a2 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:edu.isistan.carcha.plugin.editors.TraceabilityEditor.java

/**
 * Creates the impact list page./*from  w w w.ja va  2  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:DNDExample.java

public void open(Display display) {
    Shell shell = new Shell(display);
    shell.setText("Drag and Drop Example");
    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);
    parent.setLayout(new FormLayout());

    Label dragLabel = new Label(parent, SWT.LEFT);
    dragLabel.setText("Drag Source:");

    Group dragWidgetGroup = new Group(parent, SWT.NONE);
    dragWidgetGroup.setText("Widget");
    createDragWidget(dragWidgetGroup);/*w w  w. j a  v  a  2s  .  co  m*/

    Composite cLeft = new Composite(parent, SWT.NONE);
    cLeft.setLayout(new GridLayout(2, false));

    Group dragOperationsGroup = new Group(cLeft, SWT.NONE);
    dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
    dragOperationsGroup.setText("Allowed Operation(s):");
    createDragOperations(dragOperationsGroup);

    Group dragTypesGroup = new Group(cLeft, SWT.NONE);
    dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    dragTypesGroup.setText("Transfer Type(s):");
    createDragTypes(dragTypesGroup);

    dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    Menu menu = new Menu(shell, SWT.POP_UP);
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText("Clear");
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            dragConsole.setText("");
        }
    });
    item = new MenuItem(menu, SWT.CHECK);
    item.setText("Show Event detail");
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            MenuItem item = (MenuItem) e.widget;
            dragEventDetail = item.getSelection();
        }
    });
    dragConsole.setMenu(menu);

    Label dropLabel = new Label(parent, SWT.LEFT);
    dropLabel.setText("Drop Target:");

    Group dropWidgetGroup = new Group(parent, SWT.NONE);
    dropWidgetGroup.setText("Widget");
    createDropWidget(dropWidgetGroup);

    Composite cRight = new Composite(parent, SWT.NONE);
    cRight.setLayout(new GridLayout(2, false));

    Group dropOperationsGroup = new Group(cRight, SWT.NONE);
    dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2));
    dropOperationsGroup.setText("Allowed Operation(s):");
    createDropOperations(dropOperationsGroup);

    Group dropTypesGroup = new Group(cRight, SWT.NONE);
    dropTypesGroup.setText("Transfer Type(s):");
    createDropTypes(dropTypesGroup);

    Group feedbackTypesGroup = new Group(cRight, SWT.NONE);
    feedbackTypesGroup.setText("Feedback Type(s):");
    createFeedbackTypes(feedbackTypesGroup);

    dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    menu = new Menu(shell, SWT.POP_UP);
    item = new MenuItem(menu, SWT.PUSH);
    item.setText("Clear");
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            dropConsole.setText("");
        }
    });
    item = new MenuItem(menu, SWT.CHECK);
    item.setText("Show Event detail");
    item.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            MenuItem item = (MenuItem) e.widget;
            dropEventDetail = item.getSelection();
        }
    });
    dropConsole.setMenu(menu);

    int height = 200;
    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.left = new FormAttachment(0, 10);
    dragLabel.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dragLabel, 10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(50, -10);
    data.height = height;
    dragWidgetGroup.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dragWidgetGroup, 10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(50, -10);
    data.bottom = new FormAttachment(100, -10);
    cLeft.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.left = new FormAttachment(cLeft, 10);
    dropLabel.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dropLabel, 10);
    data.left = new FormAttachment(cLeft, 10);
    data.right = new FormAttachment(100, -10);
    data.height = height;
    dropWidgetGroup.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dropWidgetGroup, 10);
    data.left = new FormAttachment(cLeft, 10);
    data.right = new FormAttachment(100, -10);
    data.bottom = new FormAttachment(100, -10);
    cRight.setLayoutData(data);

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

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

public void open(Display display) {
    Shell shell = new Shell(display);
    shell.setText("Drag and Drop Example");
    shell.setLayout(new FillLayout());

    itemImage = new Image(display, DNDExample.class.getResourceAsStream("openFolder.gif"));

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL);
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setContent(parent);
    parent.setLayout(new FormLayout());

    Label dragLabel = new Label(parent, SWT.LEFT);
    dragLabel.setText("Drag Source:");

    Group dragWidgetGroup = new Group(parent, SWT.NONE);
    dragWidgetGroup.setText("Widget");
    createDragWidget(dragWidgetGroup);//from w  w  w  .ja v a  2  s.  c om

    Composite cLeft = new Composite(parent, SWT.NONE);
    cLeft.setLayout(new GridLayout(2, false));

    Group dragOperationsGroup = new Group(cLeft, SWT.NONE);
    dragOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
    dragOperationsGroup.setText("Allowed Operation(s):");
    createDragOperations(dragOperationsGroup);

    Group dragTypesGroup = new Group(cLeft, SWT.NONE);
    dragTypesGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    dragTypesGroup.setText("Transfer Type(s):");
    createDragTypes(dragTypesGroup);

    dragConsole = new Text(cLeft, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    dragConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    Menu menu = new Menu(shell, SWT.POP_UP);
    MenuItem item = new MenuItem(menu, SWT.PUSH);
    item.setText("Clear");
    item.addSelectionListener(widgetSelectedAdapter(e -> dragConsole.setText("")));
    item = new MenuItem(menu, SWT.CHECK);
    item.setText("Show Event detail");
    item.addSelectionListener(widgetSelectedAdapter(e -> {
        MenuItem eItem = (MenuItem) e.widget;
        dragEventDetail = eItem.getSelection();
    }));
    dragConsole.setMenu(menu);

    Label dropLabel = new Label(parent, SWT.LEFT);
    dropLabel.setText("Drop Target:");

    Group dropWidgetGroup = new Group(parent, SWT.NONE);
    dropWidgetGroup.setText("Widget");
    createDropWidget(dropWidgetGroup);

    Composite cRight = new Composite(parent, SWT.NONE);
    cRight.setLayout(new GridLayout(2, false));

    Group dropOperationsGroup = new Group(cRight, SWT.NONE);
    dropOperationsGroup.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2));
    dropOperationsGroup.setText("Allowed Operation(s):");
    createDropOperations(dropOperationsGroup);

    Group dropTypesGroup = new Group(cRight, SWT.NONE);
    dropTypesGroup.setText("Transfer Type(s):");
    createDropTypes(dropTypesGroup);

    Group feedbackTypesGroup = new Group(cRight, SWT.NONE);
    feedbackTypesGroup.setText("Feedback Type(s):");
    createFeedbackTypes(feedbackTypesGroup);

    dropConsole = new Text(cRight, SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    dropConsole.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    menu = new Menu(shell, SWT.POP_UP);
    item = new MenuItem(menu, SWT.PUSH);
    item.setText("Clear");
    item.addSelectionListener(widgetSelectedAdapter(e -> dropConsole.setText("")));
    item = new MenuItem(menu, SWT.CHECK);
    item.setText("Show Event detail");
    item.addSelectionListener(widgetSelectedAdapter(e -> {
        MenuItem eItem = (MenuItem) e.widget;
        dropEventDetail = eItem.getSelection();
    }));
    dropConsole.setMenu(menu);

    if (dragEnabled)
        createDragSource();
    if (dropEnabled)
        createDropTarget();

    int height = 200;
    FormData data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.left = new FormAttachment(0, 10);
    dragLabel.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dragLabel, 10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(50, -10);
    data.height = height;
    dragWidgetGroup.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dragWidgetGroup, 10);
    data.left = new FormAttachment(0, 10);
    data.right = new FormAttachment(50, -10);
    data.bottom = new FormAttachment(100, -10);
    cLeft.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.left = new FormAttachment(cLeft, 10);
    dropLabel.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dropLabel, 10);
    data.left = new FormAttachment(cLeft, 10);
    data.right = new FormAttachment(100, -10);
    data.height = height;
    dropWidgetGroup.setLayoutData(data);

    data = new FormData();
    data.top = new FormAttachment(dropWidgetGroup, 10);
    data.left = new FormAttachment(cLeft, 10);
    data.right = new FormAttachment(100, -10);
    data.bottom = new FormAttachment(100, -10);
    cRight.setLayoutData(data);

    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();
    }
    itemImage.dispose();
}

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);// w w  w.j a va  2  s .co m
    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: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 ww  .  j ava  2 s . c om*/
    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.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//  w  w 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);
            }
        }
    });

    // 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.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   w w w.j  a  v a2 s .c om*/
        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//from w w w. j  a  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 ww  w. j a v  a 2 s .co  m*/

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