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

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

Introduction

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

Prototype

public Combo getCombo() 

Source Link

Document

Returns this list viewer's list control.

Usage

From source file:com.ebmwebsourcing.petals.common.internal.provisional.emf.EObjectUIHelper.java

License:Open Source License

/**
 * Produces the widgets.//from  w  w  w . j a  va  2  s.  co  m
 * @param toolkit
 * @param parent
 * @param featuresToLabels
 * @return
 */
private static List<EntryDescription> produceWidgets(FormToolkit toolkit, Color labelColor, Composite parent,
        Map<EStructuralFeature, String> featuresToLabels) {

    List<EntryDescription> entries = new ArrayList<EntryDescription>();
    for (Map.Entry<EStructuralFeature, String> entry : featuresToLabels.entrySet()) {
        Object widget = null;
        EAttribute attr = (EAttribute) entry.getKey();
        String label = entry.getValue();

        // The label
        // TODO leverage ExtendedMetaData.INSTANCE for tool tip and label
        if (label == null) {
            label = StringUtils.camelCaseToHuman(attr.getName());
            label = StringUtils.capitalize(label);
            if (attr.getLowerBound() > 0)
                label += " *";
            label += ":";
        }

        Label labelWidget = toolkit.createLabel(parent, label);
        labelWidget.setBackground(parent.getBackground());
        if (labelColor != null)
            labelWidget.setForeground(labelColor);

        // The widget
        Class<?> instanceClass = attr.getEType().getInstanceClass();
        if (instanceClass.equals(String.class)) {

            String lowered = label.toLowerCase();
            if (lowered.contains("password") || lowered.contains("passphrase"))
                widget = SwtFactory.createPasswordField(parent, false).getText();

            else if (lowered.contains("folder") || lowered.contains("directory"))
                widget = SwtFactory.createDirectoryBrowser(parent).getText();

            else
                widget = toolkit.createText(parent, "", SWT.BORDER);

            ((Text) widget).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        } else if (instanceClass.equals(Integer.class) || instanceClass.equals(int.class)) {
            widget = new Spinner(parent, SWT.BORDER);
            GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).minSize(100, SWT.DEFAULT)
                    .applyTo((Spinner) widget);
            ((Spinner) widget).setMaximum(Integer.MAX_VALUE);

        } else if (instanceClass.isEnum()) {
            widget = new ComboViewer(parent, SWT.READ_ONLY | SWT.FLAT);
            ComboViewer viewer = (ComboViewer) widget;
            viewer.setContentProvider(new EEnumLiteralsProvider());
            viewer.setLabelProvider(new EEnumNameLabelProvider());
            viewer.setInput(attr.getEType());
            viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        } else if (instanceClass.equals(Boolean.class) || instanceClass.equals(boolean.class)) {
            widget = new ComboViewer(parent, SWT.READ_ONLY | SWT.FLAT);
            ComboViewer viewer = (ComboViewer) widget;
            viewer.setContentProvider(new ArrayContentProvider());
            viewer.setLabelProvider(new LabelProvider());
            viewer.setInput(new Boolean[] { Boolean.TRUE, Boolean.FALSE });

            Combo combo = ((ComboViewer) widget).getCombo();
            GridDataFactory.swtDefaults().hint(100, SWT.DEFAULT).minSize(100, SWT.DEFAULT).applyTo(combo);
        }

        if (widget != null)
            entries.add(new EntryDescription(widget, attr));
    }

    return entries;
}

From source file:com.ebmwebsourcing.petals.common.internal.provisional.utils.SwtFactory.java

License:Open Source License

/**
 * Creates a combo viewer with a default label provider and an array content provider.
 * @param parent the parent// w ww. ja  va  2s . co  m
 * @param useWholeSpace true to use the whole space horizontally
 * @param values the values to put in the viewer
 * @return the viewer
 */
public static ComboViewer createDefaultComboViewer(Composite parent, boolean useWholeSpace, boolean readOnly,
        Object[] values) {

    int style = SWT.SINGLE | SWT.BORDER;
    if (readOnly)
        style |= SWT.READ_ONLY;

    final ComboViewer viewer = new ComboViewer(parent, style);
    if (useWholeSpace)
        viewer.getCombo().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(values);

    return viewer;
}

From source file:com.ebmwebsourcing.petals.services.cdk.editor.CDK5JBIEndpointUIHelper.java

License:Open Source License

/**
 * Creates the specific UI for "consume" blocks in the JBI editor (with CDK 5 fields).
 * @param endpoint/*from  ww w.j  a va  2 s .  c o  m*/
 * @param toolkit
 * @param cdkComposite
 * @param ise
 * @param parent
 * @param commonUiBean
 */
public static void createConsumesUI(final AbstractEndpoint endpoint, final FormToolkit toolkit,
        final Composite parent, final ISharedEdition ise, final CommonUIBean commonUiBean) {

    Color blueFont = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_BLUE);

    // The controls
    SwtFactory
            .createLabel(parent, "Operation Namespace:",
                    "The QName of the operation (should match an operation declared in a WSDL)")
            .setForeground(blueFont);
    final Text opNamespaceText = SwtFactory.createSimpleTextField(parent, true);

    SwtFactory
            .createLabel(parent, "Operation Name:",
                    "The QName of the operation (should match an operation declared in a WSDL)")
            .setForeground(blueFont);
    final Text opNameText = SwtFactory.createSimpleTextField(parent, true);

    SwtFactory
            .createLabel(parent, "Invocation MEP *:", "The Message Exchange Pattern to use for the invocation")
            .setForeground(blueFont);
    ComboViewer mepViewer = SwtFactory.createDefaultComboViewer(parent, false, true, Mep.values());
    toolkit.adapt(mepViewer.getCombo());

    // Add the helpers
    toolkit.createLabel(parent, "");
    Hyperlink selectLink = toolkit.createHyperlink(parent, "Select a Petals service and an operation to invoke",
            SWT.NONE);
    selectLink.setToolTipText("Select the service and the operation to invoke from the known Petals services");

    // The data-binding
    ise.getDataBindingContext().bindValue(SWTObservables.observeText(opNameText),
            EObjectUIHelper.createCustomEmfEditObservable(ise.getEditingDomain(), endpoint,
                    Cdk5Package.Literals.CDK5_CONSUMES__OPERATION),
            null, new UpdateValueStrategy().setConverter(new LocalQNameToStringConverter()));

    ise.getDataBindingContext().bindValue(SWTObservables.observeText(opNamespaceText),
            EObjectUIHelper.createCustomEmfEditObservable(ise.getEditingDomain(), endpoint,
                    Cdk5Package.Literals.CDK5_CONSUMES__OPERATION),
            null, new UpdateValueStrategy().setConverter(new NamespaceQNameToStringConverter()));

    ise.getDataBindingContext().bindValue(ViewersObservables.observeSingleSelection(mepViewer),
            EObjectUIHelper.createCustomEmfEditObservable(ise.getEditingDomain(), endpoint,
                    Cdk5Package.Literals.CDK5_CONSUMES__MEP),
            new UpdateValueStrategy().setConverter(new MepToStringConverter()),
            new UpdateValueStrategy().setConverter(new StringToMepConverter()));

    // The data-binding handles the "model to target (widget)" parts. But not ALL the "widget to model" parts.
    // For QNames, in fact, the data-binding cannot be applied in this sense. We have to use a modify listener for this.
    final ActivableListener activableListener = JBIEndpointUIHelpers.createModifyListenerForQname(
            ise.getEditingDomain(), endpoint, opNamespaceText, opNameText,
            Cdk5Package.Literals.CDK5_CONSUMES__OPERATION, true);

    // Deal with the helper listener
    selectLink.addHyperlinkListener(new PetalsHyperlinkListener() {
        @Override
        public void linkActivated(HyperlinkEvent e) {

            final EnhancedConsumeDialog dlg = new EnhancedConsumeDialog(parent.getShell(), toolkit);
            if (dlg.open() == Window.OK) {

                // Prepare the model update
                CompoundCommand compositeCommand = new CompoundCommand();
                EditingDomain editDomain = ise.getEditingDomain();

                QName q = dlg.getItfToInvoke();
                Command command = new SetCommand(editDomain, endpoint,
                        JbiPackage.Literals.ABSTRACT_ENDPOINT__INTERFACE_NAME, q);
                compositeCommand.append(command);

                q = dlg.getSrvToInvoke();
                command = new SetCommand(editDomain, endpoint,
                        JbiPackage.Literals.ABSTRACT_ENDPOINT__SERVICE_NAME, q);
                compositeCommand.append(command);

                String edpt = dlg.getEdptToInvoke();
                command = new SetCommand(editDomain, endpoint,
                        JbiPackage.Literals.ABSTRACT_ENDPOINT__ENDPOINT_NAME, edpt);
                compositeCommand.append(command);

                command = EObjectUIHelper.createCustomSetCommand(editDomain, endpoint,
                        Cdk5Package.Literals.CDK5_CONSUMES__OPERATION, dlg.getOperationToInvoke());
                compositeCommand.append(command);

                String mep = dlg.getInvocationMep() == Mep.UNKNOWN ? null : dlg.getInvocationMep().toString();
                command = EObjectUIHelper.createCustomSetCommand(editDomain, endpoint,
                        Cdk5Package.Literals.CDK5_CONSUMES__MEP, mep);
                compositeCommand.append(command);

                // Identify the listeners to disable, so that all the fields are correctly set
                List<ActivableListener> theListeners = new ArrayList<ActivableListener>();
                theListeners.add(activableListener);
                for (Text t : new Text[] { commonUiBean.itfNameText, commonUiBean.srvNameText }) {
                    for (Listener ml : t.getListeners(SWT.Modify)) {
                        if (ml instanceof ActivableListener)
                            theListeners.add((ActivableListener) ml);
                    }
                }

                // Perform the update carefully
                for (ActivableListener ml : theListeners)
                    ml.setEnabled(false);

                editDomain.getCommandStack().execute(compositeCommand);
                for (ActivableListener ml : theListeners)
                    ml.setEnabled(true);
            }
        }
    });
}

From source file:com.ebmwebsourcing.petals.services.su.wizards.pages.ChoicePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {

    // Create the composite container and define its layout
    final Composite container = SwtFactory.createComposite(parent);
    setControl(container);//w  w w. j  a  v a2s  .com
    SwtFactory.applyNewGridLayout(container, 2, false, 15, 0, 0, 15);
    SwtFactory.applyHorizontalGridData(container);

    // Add a tool tip to display in case of problem
    this.helpTooltip = new FixedShellTooltip(getShell(), true, 90) {
        @Override
        public void populateTooltip(Composite parent) {

            GridLayout layout = new GridLayout();
            layout.verticalSpacing = 2;
            parent.setLayout(layout);
            parent.setLayoutData(new GridData(GridData.FILL_BOTH));
            parent.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

            try {
                ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(
                        PetalsConstants.PETALS_COMMON_PLUGIN_ID, "icons/petals/thinking_hard.png");

                if (desc != null)
                    ChoicePage.this.helpImg = desc.createImage();

                parent.setBackgroundMode(SWT.INHERIT_DEFAULT);
                Label imgLabel = new Label(parent, SWT.NONE);
                imgLabel.setImage(ChoicePage.this.helpImg);
                imgLabel.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true));

            } catch (Exception e) {
                PetalsServicesPlugin.log(e, IStatus.WARNING);
            }

            FontData[] fd = PlatformUtils.getModifiedFontData(getFont().getFontData(), SWT.BOLD);
            ChoicePage.this.boldFont = new Font(getShell().getDisplay(), fd);
            Label titleLabel = new Label(parent, SWT.NONE);
            titleLabel.setFont(ChoicePage.this.boldFont);
            GridData layoutData = new GridData(SWT.CENTER, SWT.DEFAULT, true, true);
            layoutData.verticalIndent = 5;
            titleLabel.setLayoutData(layoutData);
            titleLabel.setText("What does this error mean?");

            Label l = new Label(parent, SWT.WRAP);
            l.setText("This wizard will generate, among other things, Maven artifacts.");
            layoutData = new GridData();
            layoutData.verticalIndent = 8;
            l.setLayoutData(layoutData);

            RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
            rowLayout.marginLeft = 0;
            rowLayout.marginTop = 0;
            rowLayout.marginRight = 0;
            rowLayout.marginBottom = 0;
            rowLayout.spacing = 0;

            Composite rowComposite = new Composite(parent, SWT.NONE);
            rowComposite.setLayout(rowLayout);
            rowComposite.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true, true));

            new Label(rowComposite, SWT.WRAP).setText("Unfortunately, there is a problem with the ");
            Link link = new Link(rowComposite, SWT.WRAP | SWT.NO_FOCUS);
            link.setText("<A>the Petals Maven preferences</A>");
            new Label(rowComposite, SWT.WRAP).setText(".");
            new Label(parent, SWT.WRAP).setText("Please, make them correct.");

            link.addSelectionListener(new DefaultSelectionListener() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    try {
                        PreferencesUtil.createPreferenceDialogOn(new Shell(),
                                "com.ebmwebsourcing.petals.services.prefs.maven", null, null).open();

                    } catch (Exception e1) {
                        PetalsServicesPlugin.log(e1, IStatus.ERROR);
                    }
                }
            });
        }
    };

    // Prepare the input
    Comparator<AbstractServiceUnitWizard> comparator = new Comparator<AbstractServiceUnitWizard>() {
        @Override
        public int compare(AbstractServiceUnitWizard o1, AbstractServiceUnitWizard o2) {
            String v1 = o1.getComponentVersionDescription().getComponentVersion();
            String v2 = o2.getComponentVersionDescription().getComponentVersion();
            return -v1.compareTo(v2); // negative so that the most recent is first
        }
    };

    final Map<String, Collection<AbstractServiceUnitWizard>> componentNameToHandler = new TreeMap<String, Collection<AbstractServiceUnitWizard>>();
    final Map<PetalsKeyWords, Set<String>> keywordToComponentName = new TreeMap<PetalsKeyWords, Set<String>>();
    for (AbstractServiceUnitWizard handler : ExtensionManager.INSTANCE.findComponentWizards(this.petalsMode)) {
        for (PetalsKeyWords keyword : handler.getComponentVersionDescription().getKeyWords()) {
            Set<String> list = keywordToComponentName.get(keyword);
            if (list == null)
                list = new TreeSet<String>();

            String componentName = handler.getComponentVersionDescription().getComponentName();
            list.add(componentName);
            keywordToComponentName.put(keyword, list);

            Collection<AbstractServiceUnitWizard> handlers = componentNameToHandler.get(componentName);
            if (handlers == null)
                handlers = new TreeSet<AbstractServiceUnitWizard>(comparator);

            handlers.add(handler);
            componentNameToHandler.put(componentName, handlers);
        }
    }

    // Add the selection area
    final PhantomText searchText = new PhantomText(container, SWT.SINGLE | SWT.BORDER);
    searchText.setDefaultValue("Search...");
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).span(2, 1).applyTo(searchText);

    final TreeViewer componentsViewer = new TreeViewer(container, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    GridDataFactory.fillDefaults().span(2, 1).hint(380, 300).applyTo(componentsViewer.getTree());
    componentsViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {

            String result;
            if (element instanceof String) {
                IComponentDescription desc = componentNameToHandler.get(element).iterator().next()
                        .getComponentVersionDescription();
                String componentName = desc.getComponentName();
                String componentAlias = desc.getComponentAlias();
                String annotation = desc.getComponentAnnotation();

                StringBuilder sb = new StringBuilder();
                if (StringUtils.isEmpty(componentName))
                    sb.append(componentAlias); // Generic component
                else
                    sb.append(componentAlias + "    -  " + componentName);

                if (!StringUtils.isEmpty(annotation))
                    sb.append("    ( " + annotation + " )");

                result = sb.toString();

            } else {
                result = super.getText(element);
            }

            return result;
        }

        @Override
        public Image getImage(Object element) {

            Image result = null;
            if (element instanceof PetalsKeyWords) {
                result = ChoicePage.this.keywordToImage.get(element);
            } else {
                IComponentDescription desc = componentNameToHandler.get(element).iterator().next()
                        .getComponentVersionDescription();
                result = desc.isBc() ? ChoicePage.this.bcImg : ChoicePage.this.seImg;
            }

            return result;
        }
    });

    componentsViewer.setContentProvider(new DefaultTreeContentProvider() {
        @Override
        public Object[] getElements(Object inputElement) {
            return keywordToComponentName.keySet().toArray();
        }

        @Override
        public Object[] getChildren(Object parentElement) {

            Object[] result;
            if (parentElement instanceof PetalsKeyWords) {
                Collection<String> componentNames = keywordToComponentName.get(parentElement);
                result = componentNames == null ? new Object[0] : componentNames.toArray();

            } else {
                result = new Object[0];
            }

            return result;
        }

        @Override
        public boolean hasChildren(Object element) {
            return element instanceof PetalsKeyWords;
        }
    });

    componentsViewer.addFilter(new ViewerFilter() {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {

            boolean result = false;
            String filter = searchText.getTextValue().trim().toLowerCase();
            if (filter.length() == 0)
                result = true;

            else if (element instanceof PetalsKeyWords) {
                Set<String> names = keywordToComponentName.get(element);
                if (names != null) {
                    for (String s : names) {
                        if (select(viewer, null, s)) {
                            result = true;
                            break;
                        }
                    }
                }
            }

            else if (element instanceof String)
                result = ((String) element).toLowerCase().contains(filter);

            return result;
        }
    });

    componentsViewer.setInput(new Object());
    if (keywordToComponentName.size() > 0)
        componentsViewer.expandToLevel(keywordToComponentName.keySet().iterator().next(), 1);

    // Display the available versions
    new Label(container, SWT.NONE).setText("Component Version:");
    final ComboViewer versionCombo = new ComboViewer(container, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    GridData layoutData = new GridData();
    layoutData.widthHint = 130;
    versionCombo.getCombo().setLayoutData(layoutData);
    versionCombo.setContentProvider(new ArrayContentProvider());
    versionCombo.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((AbstractServiceUnitWizard) element).getComponentVersionDescription().getComponentVersion();
        }
    });

    final Label descriptionLabel = new Label(container, SWT.NONE);
    GridDataFactory.swtDefaults().span(2, 1).indent(0, 10).applyTo(descriptionLabel);

    // Selection listeners
    searchText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            componentsViewer.refresh();
            if (searchText.getTextValue().trim().length() == 0)
                componentsViewer.collapseAll();
            else
                componentsViewer.expandAll();
        }
    });

    componentsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {

            // Get the selection
            Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
            Collection<?> input;
            if (o == null || o instanceof PetalsKeyWords)
                input = Collections.emptyList();
            else
                input = componentNameToHandler.get(o);

            // Default selection - there is always one
            versionCombo.setInput(input);
            versionCombo.getCombo().setVisibleItemCount(input.size() > 0 ? input.size() : 1);
            if (!input.isEmpty()) {
                versionCombo.setSelection(new StructuredSelection(input.iterator().next()));
                versionCombo.getCombo().notifyListeners(SWT.Selection, new Event());
            } else {
                setPageComplete(false);
                setSelectedNode(null);
                descriptionLabel.setText("");
                descriptionLabel.getParent().layout();
            }
        }
    });

    versionCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            AbstractServiceUnitWizard suWizard = (AbstractServiceUnitWizard) ((IStructuredSelection) event
                    .getSelection()).getFirstElement();
            if (suWizard == null)
                return;

            setPageComplete(true);
            setSelectedNode(getWizardNode(suWizard));

            String desc = ChoicePage.this.petalsMode == PetalsMode.provides
                    ? suWizard.getComponentVersionDescription().getProvideDescription()
                    : suWizard.getComponentVersionDescription().getConsumeDescription();
            descriptionLabel.setText(desc);
            descriptionLabel.getParent().layout();
        }
    });

    // Initialize
    if (PreferencesManager.isMavenTemplateConfigurationValid())
        this.helpTooltip.hide();

    componentsViewer.getTree().setFocus();
}

From source file:com.ecfeed.ui.dialogs.AddTestCaseDialog.java

License:Open Source License

private void createTestSuiteComposite(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label testSuiteLabel = new Label(composite, SWT.NONE);
    testSuiteLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    testSuiteLabel.setText("Test suite");

    ComboViewer testSuiteViewer = new ComboViewer(composite, SWT.NONE);
    fTestSuiteCombo = testSuiteViewer.getCombo();
    fTestSuiteCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fTestSuiteCombo.setItems(fMethod.getTestSuites().toArray(new String[] {}));
    fTestSuiteCombo.addModifyListener(new ModifyListener() {
        @Override/*ww w  . j  a  va  2 s .  c  om*/
        public void modifyText(ModifyEvent e) {
            validateTestSuiteName();
        }
    });
    fTestSuiteCombo.setText(Constants.DEFAULT_NEW_TEST_SUITE_NAME);
}

From source file:com.ecfeed.ui.dialogs.GeneratorSetupDialog.java

License:Open Source License

private void createTestSuiteComposite(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label testSuiteLabel = new Label(composite, SWT.NONE);
    testSuiteLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    testSuiteLabel.setText("Test suite");

    ComboViewer testSuiteViewer = new ComboViewer(composite, SWT.NONE);
    fTestSuiteCombo = testSuiteViewer.getCombo();
    fTestSuiteCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fTestSuiteCombo.setItems(fMethod.getTestSuites().toArray(new String[] {}));
    fTestSuiteCombo.addModifyListener(new ModifyListener() {
        @Override//from   w ww  . ja va2  s.co  m
        public void modifyText(ModifyEvent e) {
            updateOkButtonAndErrorMsg();
        }
    });
    fTestSuiteCombo.setText(CommonConstants.DEFAULT_NEW_TEST_SUITE_NAME);
}

From source file:com.ecfeed.ui.dialogs.GeneratorSetupDialog.java

License:Open Source License

private void createGeneratorViewer(final Composite parent) {
    final GeneratorFactory<ChoiceNode> generatorFactory = new GeneratorFactory<>();
    ComboViewer generatorViewer = new ComboViewer(parent, SWT.READ_ONLY);
    fGeneratorCombo = generatorViewer.getCombo();
    fGeneratorCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fGeneratorCombo.addModifyListener(new ModifyListener() {
        @Override/*from  ww  w.  java2 s. c o  m*/
        public void modifyText(ModifyEvent e) {
            try {
                fSelectedGenerator = generatorFactory.getGenerator(fGeneratorCombo.getText());
                correctionForMethodWithOneParam(fGeneratorCombo.getText());

                createParametersComposite(parent, fSelectedGenerator.parameters());
                fMainContainer.layout();
            } catch (GeneratorException exception) {
                exception.printStackTrace();
                fGeneratorCombo.setText("");
            }
        }
    });
    if (fGeneratorFactory.availableGenerators().size() > 0) {
        String[] availableGenerators = generatorFactory.availableGenerators().toArray(new String[] {});
        for (String generator : availableGenerators) {
            fGeneratorCombo.add(generator);
        }
        fGeneratorCombo.select(0);
        setOkButtonStatus(true);
    }
}

From source file:com.ecfeed.ui.dialogs.SetupDialogGenerator.java

License:Open Source License

private void createTestSuiteComposite(Composite container) {
    Composite composite = new Composite(container, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label testSuiteLabel = new Label(composite, SWT.NONE);
    testSuiteLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    testSuiteLabel.setText("Test suite");

    ComboViewer testSuiteViewer = new ComboViewer(composite, SWT.NONE);
    fTestSuiteCombo = testSuiteViewer.getCombo();
    fTestSuiteCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    fTestSuiteCombo.setItems(fMethod.getTestSuites().toArray(new String[] {}));
    fTestSuiteCombo.addModifyListener(new ModifyListener() {
        @Override//  w ww .j a  va  2 s .  c  o  m
        public void modifyText(ModifyEvent e) {
            updateOkButtonAndErrorMsg();
        }
    });
    fTestSuiteCombo.setText(Constants.DEFAULT_NEW_TEST_SUITE_NAME);
}

From source file:com.foglyn.ui.FoglynAdvancedSearchPage.java

License:Open Source License

private void configureCombo(ComboViewer combo) {
    combo.setInput(Collections.emptyList());
    combo.setSelection(HelperConstants.NULL_VALUE_SELECTION);
    combo.getCombo().setVisibleItemCount(Constants.NUMBER_OF_ENTRIES_IN_COMBOBOX);
    combo.getCombo().setLayoutData("width 10%:pref:50%");
    combo.addSelectionChangedListener(searchOptionsListener);
}

From source file:com.google.gdt.eclipse.suite.preferences.ui.ErrorsWarningsPage.java

License:Open Source License

private void addProblemTypeRow(Composite categoryProblemsPanel, IGdtProblemType problemType) {
    GridData problemLabelLayout = new GridData(SWT.FILL, SWT.CENTER, true, false);

    Label problemLabel = new Label(categoryProblemsPanel, SWT.NONE);
    problemLabel.setLayoutData(problemLabelLayout);
    problemLabel.setText(problemType.getDescription());

    ComboViewer severityCombo = new ComboViewer(categoryProblemsPanel, SWT.READ_ONLY);
    GridData severityComboLayout = new GridData(SWT.FILL, SWT.CENTER, false, false);
    severityCombo.getCombo().setLayoutData(severityComboLayout);
    severityCombo.setContentProvider(new ArrayContentProvider());
    severityCombo.setLabelProvider(severityLabelProvider);
    severityCombo.setSorter(severityViewerSorter);
    severityCombo.setInput(GdtProblemSeverity.values());

    // Save the association between the problem type and this combo
    problemSeverityCombos.put(problemType, severityCombo);
}