Example usage for org.eclipse.jface.viewers ComboViewer ComboViewer

List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboViewer ComboViewer.

Prototype

public ComboViewer(Composite parent, int style) 

Source Link

Document

Creates a combo viewer on a newly-created combo control under the given parent.

Usage

From source file:de.metadocks.lambdaui.snippets.swt.HelloWorld.java

License:Open Source License

public void createUIConventional(Composite parent) {
    parent.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());

    Label label = new Label(parent, SWT.NONE);
    label.setText("Selection");

    ComboViewer viewer = new ComboViewer(parent, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
    customizeComboViewer(viewer);/* w  ww. j  av a2s.com*/
    viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Button button = new Button(parent, SWT.NONE);
    button.setText("Apply");
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            text.setText("Selection:  " + viewer.getCombo().getText());
        }
    });

    text = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
    text.setLayoutData(
            GridDataFactory.swtDefaults().span(3, 1).grab(true, true).align(SWT.FILL, SWT.FILL).create());
}

From source file:de.quamoco.adaptation.wizard.util.modelattributes.ModelAttributesComposite.java

License:Apache License

/**
 * Creates the visual controls embedded in this composite,
 * depending on the {@link #style} attribute.
 *///from   ww w  . j  a  v  a  2  s.c  o  m
protected void createControls() {

    this.setLayout(new GridLayout(3, false));

    /* Name row */
    Label lblName = new Label(this, SWT.NONE);
    lblName.setText("Name:");
    txtName = new Text(this, SWT.NONE);
    txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    btnFilterName = createFilterButton();

    /* Description row */
    Label lblDescription = new Label(this, SWT.NONE);
    lblDescription.setText("Description:");
    txtDescription = new Text(this, SWT.MULTI | SWT.V_SCROLL);
    lblDescription.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    GridData layoutTxtDescription = new GridData(SWT.FILL, SWT.FILL, true, false);
    layoutTxtDescription.heightHint = 55;
    txtDescription.setLayoutData(layoutTxtDescription);
    btnFilterDescription = createFilterButton();

    /* Object row */
    Label lblObject = new Label(this, SWT.NONE);
    lblObject.setText("Object:");
    cbObject = new ComboViewer(this, SWT.NONE);
    cbObject.setContentProvider(new ObjectContentProvider(wizard.getAttributesSettingPage()));
    cbObject.setLabelProvider(new NamedElementLabelProvider());
    cbObject.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbObject.setSorter(new ViewerSorter()); // default sorter (by name)
    btnFilterObject = createFilterButton();

    /* Viewpoint row */
    Label lblViewpoint = new Label(this, SWT.NONE);
    lblViewpoint.setText("Viewpoint:");
    cbViewpoint = new ComboViewer(this, SWT.NONE);
    cbViewpoint.setContentProvider(new ViewpointContentProvider(wizard.getAttributesSettingPage()));
    cbViewpoint.setLabelProvider(new NamedElementLabelProvider());
    cbViewpoint.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbViewpoint.setSorter(new ViewerSorter());
    btnFilterViewpoint = createFilterButton();

    /* Quality Focus row */
    Label lblQualityFocus = new Label(this, SWT.NONE);
    lblQualityFocus.setText("Quality Focus:");
    cbQualityFocus = new ComboViewer(this, SWT.NONE);
    cbQualityFocus.setContentProvider(
            new QualityFocusContentProvider(wizard.getAttributesSettingPage(), cbViewpoint));
    cbQualityFocus.setLabelProvider(new NamedElementLabelProvider());
    cbQualityFocus.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbQualityFocus.setSorter(new ViewerSorter());
    btnFilterQualityFocus = createFilterButton();
    // Call update method when viewpoint has changed
    cbViewpoint.addPostSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            cbQualityFocus.refresh();
        }
    });

    /* Purpose row */
    Label lblPurpose = new Label(this, SWT.NONE);
    lblPurpose.setText("Purpose:");
    cbPurpose = new ComboViewer(this, SWT.READ_ONLY);
    cbPurpose.setContentProvider(new PurposeContentProvider(wizard));
    cbPurpose.setLabelProvider(new NamedElementLabelProvider());
    cbPurpose.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbPurpose.setSorter(new ViewerSorter());
    btnFilterPurpose = createFilterButton();

    /* Context row */
    Label lblContext = new Label(this, SWT.NONE);
    lblContext.setText("Context:");
    lblContext.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

    Composite contextComposite = new Composite(this, SWT.NONE);
    contextComposite.setLayout(SWTUtil.createNoMarginGridLayout(1, false));
    contextComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    lwContext = new ListViewer(contextComposite);
    lwContext.setContentProvider(new ContextListContentProvider());
    lwContext.setLabelProvider(new NamedElementLabelProvider());
    lwContext.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    lwContext.setSorter(new ViewerSorter());
    lwContext.setInput(context);
    lwContext.getList().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                IStructuredSelection selection = (IStructuredSelection) lwContext.getSelection();
                if (selection != null && !selection.isEmpty()) {
                    for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
                        Object next = iterator.next();
                        context.remove(next);
                        cbContext.add(next);
                    }
                    lwContext.refresh();
                    notifyListener();
                }
            }
        }
    });

    Composite cbContextComposite = new Composite(contextComposite, SWT.NONE);
    cbContextComposite.setLayout(SWTUtil.createNoMarginGridLayout(2, false));
    cbContextComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbContext = new ComboViewer(cbContextComposite, SWT.NONE);
    cbContext.setContentProvider(new ContextComboContentProvider(context));
    cbContext.setLabelProvider(new NamedElementLabelProvider());
    cbContext.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    cbContext.setSorter(new ViewerSorter());
    Button btnContextAdd = new Button(cbContextComposite, SWT.PUSH);
    btnContextAdd.setText("Add");
    btnContextAdd.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            addContext();
        }
    });
    cbContext.getCombo().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                addContext();
            }
        }
    });

    btnFilterContext = createFilterButton();
}

From source file:de.tobject.findbugs.properties.FindbugsPropertyPage.java

License:Open Source License

private void createGlobalElements(Composite parent) {
    if (getProject() != null) {
        createWorkspaceButtons(parent);/* ww w.ja va2 s.  co  m*/
    }

    Composite globalGroup = new Composite(parent, SWT.TOP);
    GridLayout layout = new GridLayout(3, false);
    //layout.marginHeight = 0;
    //layout.marginWidth = 0;
    globalGroup.setLayout(layout);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    //layoutData.verticalIndent = -2;

    globalGroup.setLayoutData(layoutData);

    natureEnabled = ProjectUtilities.hasFindBugsNature(getProject());

    if (getProject() != null) {
        chkEnableFindBugs = new Button(globalGroup, SWT.CHECK);
        chkEnableFindBugs.setText(getMessage("property.runAuto"));
        chkEnableFindBugs.setSelection(natureEnabled);
        chkEnableFindBugs.setToolTipText(getMessage("property.runAuto.tip"));

        chkEnableFindBugs.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean enabled = chkEnableFindBugs.getSelection();
                chkRunAtFullBuild.setEnabled(enabled);
            }
        });

        chkRunAtFullBuild = new Button(globalGroup, SWT.CHECK);
        chkRunAtFullBuild.setText(getMessage("property.runFull"));
        chkRunAtFullBuild.setSelection(origUserPreferences.isRunAtFullBuild());
        chkRunAtFullBuild.setToolTipText(getMessage("property.runFull.tip"));
        chkRunAtFullBuild.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent event) {
                boolean selection = chkRunAtFullBuild.getSelection();
                currentUserPreferences.setRunAtFullBuild(selection);
            }
        });
        chkRunAtFullBuild.setEnabled(chkEnableFindBugs.getSelection());
    }

    Composite prioGroup = new Composite(globalGroup, SWT.NONE);
    GridLayout prioLayout = new GridLayout(2, false);
    prioGroup.setLayout(prioLayout);
    layoutData = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    layoutData.horizontalIndent = -5;
    //layoutData.verticalIndent = -5;
    prioGroup.setLayoutData(layoutData);

    // effort
    Label effortLabel = new Label(prioGroup, SWT.NULL);
    effortLabel.setText(getMessage("property.effort"));
    effortViewer = new ComboViewer(prioGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    effortViewer.add(Effort.values());

    String effortLevel = currentUserPreferences.getEffort();
    effortViewer.setSelection(new StructuredSelection(Effort.getEffort(effortLevel)), true);
    effortViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            Effort placeHolder = (Effort) ((IStructuredSelection) event.getSelection()).getFirstElement();
            currentUserPreferences.setEffort(placeHolder.getEffortLevel());
        }
    });
    effortLabel.setToolTipText("Set FindBugs analysis effort (minimal is faster but less precise)");
    effortViewer.getCombo().setToolTipText("Set FindBugs analysis effort (minimal is faster but less precise)");

    cloudLabel = new Label(globalGroup, SWT.NONE);
    cloudCombo = new Combo(globalGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    cloudCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    enableOrDisableCloudControls();
    String cloudid = getCloudId();

    clouds = new ArrayList<CloudPlugin>();
    populateCloudsCombo(cloudid);
}

From source file:de.walware.docmlet.tex.internal.ui.preferences.TexEditorPreferencePage.java

License:Open Source License

private Composite createSmartInsertOptions(final Composite pageComposite) {
    final Group composite = new Group(pageComposite, SWT.NONE);
    composite.setText(Messages.EditorOptions_SmartInsert_label + ':');
    final int n = 4;
    composite.setLayout(LayoutUtil.createGroupGrid(n));
    fSmartInsertControl = new Button(composite, SWT.CHECK);
    fSmartInsertControl.setText(Messages.EditorOptions_SmartInsert_AsDefault_label);
    fSmartInsertControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, n, 1));
    {/*from   w w w  .  j  a v a  2  s  . co m*/
        final Link link = addLinkControl(composite, Messages.EditorOptions_SmartInsert_description);
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false, n, 1);
        gd.widthHint = 300;
        link.setLayoutData(gd);
    }

    {
        final Label label = new Label(composite, SWT.NONE);
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        label.setText(Messages.EditorOptions_SmartInsert_TabAction_label);
        fSmartInsertTabActionControl = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        fSmartInsertTabActionControl.getControl()
                .setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, n - 2, 1));
        fSmartInsertTabActionControl.setContentProvider(new ArrayContentProvider());
        fSmartInsertTabActionControl.setLabelProvider(new SmartInsertSettingsUI.SettingsLabelProvider());
        fSmartInsertTabActionControl
                .setInput(new TabAction[] { TabAction.INSERT_TAB_CHAR, TabAction.INSERT_INDENT_LEVEL, });
        LayoutUtil.addGDDummy(composite);
    }

    LayoutUtil.addSmallFiller(composite, true);
    //      {   Label label = new Label(composite, SWT.CENTER);
    //         label.setText(Messages.REditorOptions_SmartInsert_ForEditor_header);
    //         label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    //         label = new Label(composite, SWT.CENTER);
    //         label.setText(Messages.REditorOptions_SmartInsert_ForConsole_header);
    //         label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    //      }
    //      fSmartInsertOnPasteControl = createOption(composite, Messages.REditorOptions_SmartInsert_OnPaste_label, null, false);
    fSmartInsertCloseBracketsControl = createSmartInsertOption(composite,
            Messages.EditorOptions_SmartInsert_CloseAuto_label,
            Messages.EditorOptions_SmartInsert_CloseBrackets_label, true);
    {
        final Label dummy = new Label(composite, SWT.NONE);
        dummy.setVisible(false);
        dummy.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 4));
    }
    fSmartInsertCloseParenthesisControl = createSmartInsertOption(composite, null,
            Messages.EditorOptions_SmartInsert_CloseParentheses_label, true);
    fSmartInsertCloseMathDollarControl = createSmartInsertOption(composite, null,
            Messages.EditorOptions_SmartInsert_CloseMathDollar_label, true);
    fSmartInsertHardWrapTextControl = createSmartInsertOption(composite,
            Messages.EditorOptions_SmartInsert_HardWrapAuto_label,
            Messages.EditorOptions_SmartInsert_HardWrapText_label, true);

    //      fSmartInsertCloseSquareBracketsControl = createOption(composite, null, Messages.REditorOptions_SmartInsert_CloseSquare_label, true);
    //      fSmartInsertCloseSpecialControl = createOption(composite, null, Messages.REditorOptions_SmartInsert_ClosePercent_label, true);
    //      fSmartInsertCloseStringsControl = createOption(composite, null, Messages.REditorOptions_SmartInsert_CloseString_label, true);

    return composite;
}

From source file:de.walware.ecommons.emf.ui.forms.DropDownProperty.java

License:Open Source License

@Override
public void create(final Composite parent, final IEFFormPage page) {
    final EFToolkit toolkit = page.getToolkit();

    toolkit.createPropLabel(parent, getLabel(), getTooltip());

    fComposite = new Composite(parent, SWT.NULL);
    toolkit.adapt(fComposite);//  w ww  . j av a  2s  . c om
    fComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    fComposite.setLayout(LayoutUtil.createCompositeGrid(3));

    {
        final ComboViewer viewer = new ComboViewer(fComposite, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
        fComboViewer = viewer;

        final ILabelProvider labelProvider = createLabelProvider(page);

        viewer.setLabelProvider(labelProvider);
        viewer.setContentProvider(ArrayContentProvider.getInstance());

        final GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
        gd.widthHint = LayoutUtil.hintWidth(getCombo(), fInitialInput, labelProvider);
        viewer.getControl().setLayoutData(gd);
    }

    fDetailStack = createDetails(fComposite, page);
    fDetailStack.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
}

From source file:de.walware.eutils.autorun.internal.AutoRunPreferencePage.java

License:Open Source License

@Override
protected Control createContents(final Composite parent) {
    this.launchManager = DebugPlugin.getDefault().getLaunchManager();

    final Composite composite = new Composite(parent, SWT.NONE);
    {//  ww  w  . j  av a  2s .  c om
        final GridLayout gd = new GridLayout();
        gd.marginWidth = 0;
        gd.marginHeight = 0;
        gd.numColumns = 3;
        composite.setLayout(gd);
    }
    {
        this.enableButton = new Button(composite, SWT.CHECK);
        this.enableButton.setText("Enable &launch at startup of:");
        this.enableButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    }
    {
        this.entryViewer = new TreeViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
        final Tree tree = this.entryViewer.getTree();
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
        Dialog.applyDialogFont(this.entryViewer.getControl());
        gd.heightHint = tree.getItemHeight() * 10;
        this.entryViewer.getControl().setLayoutData(gd);

        this.entryViewer.setLabelProvider(DebugUITools.newDebugModelPresentation());
        this.entryViewer.setContentProvider(
                new LaunchConfigurationTreeContentProvider(ILaunchManager.RUN_MODE, getShell()) {
                    @Override
                    public Object[] getElements(final Object parentElement) {
                        final Object[] children = super.getChildren(parentElement);
                        final List<Object> filtered = new ArrayList<>(children.length);
                        for (int i = 0; i < children.length; i++) {
                            if (super.hasChildren(children[i])) {
                                filtered.add(children[i]);
                            }
                        }
                        return filtered.toArray();
                    }
                });
        this.entryViewer.setComparator(new LaunchConfigurationComparator());
    }
    {
        this.viewButton = new Button(composite, SWT.PUSH);
        this.viewButton.setText("View/&Edit...");
        final GridData gd = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
        Dialog.applyDialogFont(this.viewButton);
        gd.widthHint = Math.max(this.viewButton.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
                convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH));
        this.viewButton.setLayoutData(gd);
        this.viewButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                final Object element = ((IStructuredSelection) AutoRunPreferencePage.this.entryViewer
                        .getSelection()).getFirstElement();
                if (element instanceof ILaunchConfiguration) {
                    DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(),
                            (ILaunchConfiguration) element, IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
                }
            }
        });
    }
    {
        this.modeLabel = new Label(composite, SWT.NONE);
        this.modeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        this.modeLabel.setText("Launch &Mode:");

        this.modeViewer = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        this.modeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        this.modeViewer.setContentProvider(new ArrayContentProvider());
        this.modeViewer.setLabelProvider(new LabelProvider() {

            private final StringBuilder fStringBuilder = new StringBuilder();

            @Override
            public String getText(final Object element) {
                this.fStringBuilder.setLength(0);
                final Iterator<String> iter = ((Set<String>) element).iterator();
                if (iter.hasNext()) {
                    append(AutoRunPreferencePage.this.launchManager.getLaunchMode(iter.next()));
                    while (iter.hasNext()) {
                        this.fStringBuilder.append("+");
                        append(AutoRunPreferencePage.this.launchManager.getLaunchMode(iter.next()));
                    }
                }
                return this.fStringBuilder.toString();
            }

            private void append(final ILaunchMode mode) {
                final String s = mode.getLabel();
                for (int i = 0; i < s.length(); i++) {
                    final char c = s.charAt(i);
                    if (c == '&') {
                        i++;
                        if (i < s.length()) {
                            this.fStringBuilder.append(s.charAt(i));
                        }
                    } else {
                        this.fStringBuilder.append(c);
                    }
                }
            }
        });

        this.entryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                updateModes();
            }
        });
        this.modeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
            @Override
            public void selectionChanged(final SelectionChangedEvent event) {
                final Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
                if (element != null) {
                    AutoRunPreferencePage.this.lastMode = (Set<String>) element;
                }
            }
        });
    }

    Dialog.applyDialogFont(composite);

    loadConfigs();
    loadPrefs();

    return composite;
}

From source file:de.walware.eutils.yaml.internal.ui.config.YamlEditorPreferencePage.java

License:Open Source License

private Composite createSmartInsertOptions(final Composite pageComposite) {
    final Group composite = new Group(pageComposite, SWT.NONE);
    composite.setText(Messages.EditorOptions_SmartInsert_label + ':');
    final int n = 4;
    composite.setLayout(LayoutUtil.createGroupGrid(n));
    this.smartInsertControl = new Button(composite, SWT.CHECK);
    this.smartInsertControl.setText(Messages.EditorOptions_SmartInsert_AsDefault_label);
    this.smartInsertControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, n, 1));
    {//  w w  w  . j a va2s.co  m
        final Link link = addLinkControl(composite, Messages.EditorOptions_SmartInsert_description);
        final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false, n, 1);
        gd.widthHint = 300;
        link.setLayoutData(gd);
    }

    {
        final Label label = new Label(composite, SWT.NONE);
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
        label.setText(Messages.EditorOptions_SmartInsert_TabAction_label);
        this.smartInsertTabActionControl = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        this.smartInsertTabActionControl.getControl()
                .setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, n - 2, 1));
        this.smartInsertTabActionControl.setContentProvider(new ArrayContentProvider());
        this.smartInsertTabActionControl.setLabelProvider(new SmartInsertSettingsUI.SettingsLabelProvider());
        this.smartInsertTabActionControl.setInput(new TabAction[] { TabAction.INSERT_TAB_CHAR,
                TabAction.INSERT_TAB_LEVEL, TabAction.INSERT_INDENT_LEVEL, });
        LayoutUtil.addGDDummy(composite, true);
    }

    LayoutUtil.addSmallFiller(composite, true);

    this.smartInsertCloseBracketsControl = createSmartInsertOption(composite,
            Messages.EditorOptions_SmartInsert_CloseAuto_label,
            Messages.EditorOptions_SmartInsert_CloseBrackets_label);
    this.smartInsertCloseQuotesControl = createSmartInsertOption(composite, null,
            Messages.EditorOptions_SmartInsert_CloseQuotes_label);

    return composite;
}

From source file:de.walware.rj.eclient.graphics.RGraphicsPreferencePage.java

License:Open Source License

protected Group createFontGroup(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setText("Fonts:");
    group.setLayout(LayoutUtil.applyGroupDefaults(new GridLayout(), 3));

    addFont(group, fSerifPref, "Default &Serif Font ('serif'):");
    addFont(group, fSansPref, "Default S&ansserif Font ('sans'):");
    addFont(group, fMonoPref, "Default &Monospace Font ('mono'):");

    LayoutUtil.addSmallFiller(group, false);

    fSymbolUseControl = new Button(group, SWT.CHECK);
    fSymbolUseControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
    fSymbolUseControl.setText("Use special S&ymbol Font");
    final List<Control> symbolControls = new ArrayList<Control>();
    addFont(group, fSymbolFontPref, "Symbol &Font:", LayoutUtil.defaultIndent(), symbolControls);
    {//from   w w w.  j a va2 s.  co  m
        final Label label = new Label(group, SWT.NONE);
        final GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
        gd.horizontalIndent = LayoutUtil.defaultIndent();
        label.setLayoutData(gd);
        label.setText("Encoding:");
        symbolControls.add(label);
    }
    {
        fSymbolEncodingControl = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
        final GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
        gd.widthHint = LayoutUtil.hintWidth(fSymbolEncodingControl.getCombo(), 15);
        fSymbolEncodingControl.getControl().setLayoutData(gd);
        fSymbolEncodingControl.setContentProvider(new ArrayContentProvider());
        fSymbolEncodingControl.setInput(SYMBOL_ENCODINGS);
        symbolControls.add(fSymbolEncodingControl.getControl());
    }
    fSymbolChildControls = symbolControls.toArray(new Control[symbolControls.size()]);
    fSymbolUseControl.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            updateSymbolControls();
        }
    });

    return group;
}

From source file:de.walware.statet.r.internal.cmd.ui.launching.RCmdMainTab.java

License:Open Source License

private void createCommandControls(final Composite container) {
    for (final ILaunchConfigurationTab tab : getLaunchConfigurationDialog().getTabs()) {
        if (tab instanceof REnvTab) {
            fREnvTab = tab;/*from   w  w  w . jav  a 2s. c  o  m*/
            break;
        }
    }
    fWithHelp = (fREnvTab != null) && (getLaunchConfigurationDialog() instanceof TrayDialog);

    container.setLayout(LayoutUtil.applyGroupDefaults(new GridLayout(), 3));

    final String[] names = new String[fCommands.length];
    for (int i = 0; i < fCommands.length; i++) {
        names[i] = fCommands[i].getName();
    }
    fCmdCombo = new ComboViewer(container, SWT.DROP_DOWN | SWT.READ_ONLY);
    fCmdCombo.setContentProvider(new ArrayContentProvider());
    fCmdCombo.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            final Cmd cmd = (Cmd) element;
            return cmd.getName();
        }
    });
    fCmdCombo.setInput(fCommands);
    fCmdCombo.getCombo().setVisibleItemCount(names.length);
    fCmdCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

    fCmdText = new Text(container, SWT.BORDER | SWT.SINGLE);
    fCmdText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, fWithHelp ? 1 : 2, 1));

    if (fWithHelp) {
        fHelpButton = new Button(container, SWT.PUSH);
        fHelpButton.setText(RCmdMessages.RCmd_MainTab_RunHelp_label);
        fHelpButton.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                queryHelp();
            }
        });
        final GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
        gd.widthHint = LayoutUtil.hintWidth(fHelpButton);
        fHelpButton.setLayoutData(gd);
    }

    LayoutUtil.addSmallFiller(container, false);
    fArgumentsControl = new InputArgumentsComposite(container);
    fArgumentsControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));

    fResourceControl = new ResourceInputComposite(container,
            ResourceInputComposite.STYLE_LABEL | ResourceInputComposite.STYLE_TEXT,
            ResourceInputComposite.MODE_FILE | ResourceInputComposite.MODE_OPEN, ""); //$NON-NLS-1$
    fResourceControl.setShowInsertVariable(true,
            new ConstArrayList<VariableFilter>(DialogUtil.EXCLUDE_JAVA_FILTER), null);
    fResourceControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
}

From source file:de.walware.statet.r.internal.console.ui.launching.RConsoleMainTab.java

License:Open Source License

@Override
public void createControl(final Composite parent) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    setControl(mainComposite);/*from  w ww.  ja va2  s.c  o  m*/
    mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    mainComposite.setLayout(new GridLayout());

    { // Type
        final Composite composite = new Composite(mainComposite, SWT.NONE);
        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        composite.setLayout(LayoutUtil.applyCompositeDefaults(new GridLayout(), 2));

        final Label label = new Label(composite, SWT.LEFT);
        label.setText(RConsoleMessages.RConsole_MainTab_LaunchType_label + ':');
        label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));

        final String[] names = new String[fTypes.length];
        for (int i = 0; i < fTypes.length; i++) {
            names[i] = fTypes[i].getName();
        }
        fTypesCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
        fTypesCombo.setContentProvider(new ArrayContentProvider());
        fTypesCombo.setLabelProvider(new LabelProvider() {
            @Override
            public String getText(final Object element) {
                final RConsoleType type = (RConsoleType) element;
                return type.getName();
            }
        });
        fTypesCombo.setInput(fTypes);
        fTypesCombo.getCombo().setVisibleItemCount(names.length);
        fTypesCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        fTypesCombo.getControl().setEnabled(fTypes.length > 1);
    }

    final Composite detailGroup = createTypeDetailGroup(mainComposite);
    if (detailGroup != null) {
        detailGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    }

    final Composite commandGroup = createROptionsGroup(mainComposite);
    commandGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    LayoutUtil.addSmallFiller(mainComposite, true);
    createFooter(mainComposite);

    Dialog.applyDialogFont(parent);
    initBindings();

    PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IRConsoleHelpContextIds.R_CONSOLE_LAUNCH);
}