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:org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseDnComposite.java

License:Apache License

public Composite createComposite(Composite parent) {
    Composite composite = BaseWidgetUtils.createColumnContainer(parent, 3, 1);

    // DN//from  w  ww  .  ja  v  a 2  s.c om
    BaseWidgetUtils.createLabel(composite, "DN:", 1);
    entryWidget = new EntryWidget();
    entryWidget.createWidget(composite);
    entryWidget.addWidgetModifyListener(modifyListener);

    // Type
    BaseWidgetUtils.createLabel(composite, "Type:", 1);
    ComboViewer whatClauseDnTypeComboViewer = new ComboViewer(
            BaseWidgetUtils.createReadonlyCombo(composite, new String[0], -1, 1));
    whatClauseDnTypeComboViewer.getCombo().setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false, 2, 1));
    whatClauseDnTypeComboViewer.setContentProvider(new ArrayContentProvider());
    whatClauseDnTypeComboViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            if (element instanceof AclWhatClauseDnTypeEnum) {
                AclWhatClauseDnTypeEnum value = (AclWhatClauseDnTypeEnum) element;
                switch (value) {
                case BASE:
                    return "Base";
                case EXACT:
                    return "Exact";
                case ONE:
                    return "One";
                case SUBTREE:
                    return "Subtree";
                case CHILDREN:
                    return "Children";
                case REGEX:
                    return "Regex";
                }
            }

            return super.getText(element);
        }
    });
    whatClauseDnTypeComboViewer.setInput(aclWhoClauseDnTypes);

    return composite;
}

From source file:org.apache.directory.studio.openldap.config.acl.widgets.composites.WhoClauseGroupComposite.java

License:Apache License

public Composite createComposite(Composite parent) {
    Composite composite = BaseWidgetUtils.createColumnContainer(parent, 3, 1);

    // Group DN/*from  ww  w. j a  v a  2  s  .c o m*/
    BaseWidgetUtils.createLabel(composite, "Group DN:", 1);
    EntryWidget entryWidget = new EntryWidget();
    entryWidget.createWidget(composite);

    ExpandableComposite optionsExpandableComposite = new ExpandableComposite(composite, SWT.NONE,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    optionsExpandableComposite.setLayout(new GridLayout());
    optionsExpandableComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 3, 1));
    optionsExpandableComposite.setText("Options");
    Composite clientComposite = BaseWidgetUtils.createColumnContainer(optionsExpandableComposite, 1, 1);
    ((GridLayout) clientComposite.getLayout()).marginRight = 15;
    optionsExpandableComposite.setClient(clientComposite);
    optionsExpandableComposite.addExpansionListener(expansionListener);

    Group optionsGroup = BaseWidgetUtils.createGroup(clientComposite, "", 1);
    optionsGroup.setLayout(new GridLayout(2, false));
    optionsGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 3, 1));

    // Group Object Class
    BaseWidgetUtils.createLabel(optionsGroup, "Group Object Class", 1);
    ComboViewer groupObjectClassComboViewer = new ComboViewer(
            BaseWidgetUtils.createCombo(optionsGroup, new String[0], -1, 1));
    groupObjectClassComboViewer.setContentProvider(new ArrayContentProvider());
    groupObjectClassComboViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            if (element instanceof ObjectClass) {
                // TODO
            }

            return super.getText(element);
        }
    });
    //        groupObjectClassComboViewer.setInput( dqsdq ); // TODO
    groupObjectClassComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    // Group Attribute Class
    BaseWidgetUtils.createLabel(optionsGroup, "Group Attribute Type", 1);
    ComboViewer groupAttributeTypeComboViewer = new ComboViewer(
            BaseWidgetUtils.createCombo(optionsGroup, new String[0], -1, 1));
    groupAttributeTypeComboViewer.setContentProvider(new ArrayContentProvider());
    groupAttributeTypeComboViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            if (element instanceof ObjectClass) {
                // TODO
            }

            return super.getText(element);
        }
    });
    //        groupObjectClassComboViewer.setInput( dqsdq ); // TODO
    groupAttributeTypeComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));

    return composite;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.MemberOfOverlayConfigurationBlock.java

License:Apache License

/**
 * Gets the text selection of the combo viewer.
 *
 * @param viewer the viewer//from  w  ww. j  a va  2 s. co  m
 * @return the text selection of the viewer
 */
private String getComboViewerText(ComboViewer viewer) {
    return viewer.getCombo().getText();
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.MemberOfOverlayConfigurationBlock.java

License:Apache License

/**
 * Sets the text selection of the combo viewer.
 *
 * @param viewer the viewer//www .j av  a2 s.com
 * @param text the text
 */
private void setComboViewerText(ComboViewer viewer, String text) {
    if (text != null) {
        viewer.getCombo().setText(text);
    } else {
        viewer.getCombo().setText("");
    }
}

From source file:org.bbaw.pdr.ae.view.control.templates.aspectsemantic.controller.config.MarkupTemplateConfigEditor.java

License:Open Source License

/**
 * Sets the combo viewer by string.//from  w  ww. j a va  2 s  .com
 * @param cv the cv
 * @param s the s
 */
private void setComboViewerByString(ComboViewer cv, String s) {
    boolean notincl = false;
    boolean add = false;
    if (cv.getInput() == null || !(cv.getInput() instanceof HashMap<?, ?>)) {
        cv.setInput(new HashMap<String, ConfigData>());
    }
    if (cv.getInput() instanceof HashMap<?, ?>) {
        @SuppressWarnings("unchecked")
        HashMap<String, ConfigData> inputs = (HashMap<String, ConfigData>) cv.getInput();
        if (add && !inputs.containsKey(s)) {
            notincl = true;
            ConfigItem ci = new ConfigItem();
            ci.setValue(s);
            ci.setLabel(s);
            inputs.put(s, ci);
            cv.setInput(inputs);
            cv.refresh();
        }
        if (inputs.containsKey(s)) {
            // System.out.println("contains key s " + s);
            for (String key : inputs.keySet()) {
                if (key.equals(s)) {
                    ConfigData cd = inputs.get(key);
                    if (cd instanceof ConfigItem && ((ConfigItem) cd).isIgnore()) {
                        ((ConfigItem) cd).setReadAlthoughIgnored(true);
                        cv.setInput(inputs);
                    }
                    StructuredSelection sel = new StructuredSelection(cd);
                    cv.setSelection(sel, true);
                    break;
                }
            }
        }
        if (notincl) {
            cv.getCombo().select(0);
        }
    }

}

From source file:org.bbaw.pdr.ae.view.identifiers.view.IdentifierSearchView.java

License:Open Source License

/**
 * Create contents of the view part./* ww w . ja  v a 2  s.co m*/
 */
@Override
public void createPartControl(Composite parent) {
    createSelectionListener();
    IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    ISelectionService selService = ww.getSelectionService();
    selService.addSelectionListener(AEPluginIDs.VIEW_TREEVIEW, _mainSelectionListener);
    _facade.addObserver(this);
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(1, false));
    _resultMap = new HashMap<PdrId, ConcurrenceDataHead>();
    Composite compositeHead = new Composite(container, SWT.NONE);
    compositeHead.setLayout(new GridLayout(5, false));
    compositeHead.setLayoutData(new GridData());
    ((GridData) compositeHead.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) compositeHead.getLayoutData()).grabExcessHorizontalSpace = true;
    SelectionAdapter radioSelAdapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            _searchTarget = (Integer) ((Button) e.getSource()).getData();
        }
    };
    Label lblPersonsToProcess = new Label(compositeHead, SWT.NONE);
    lblPersonsToProcess.setText("Persons:");

    Button btnRadioButton = new Button(compositeHead, SWT.RADIO);
    btnRadioButton.setData(0);

    btnRadioButton.addSelectionListener(radioSelAdapter);
    btnRadioButton.setText("All Persons");

    Button btnRadioButton_1 = new Button(compositeHead, SWT.RADIO);
    btnRadioButton_1.setText("Selected Tree");
    btnRadioButton_1.setData(1);
    btnRadioButton_1.addSelectionListener(radioSelAdapter);

    Button btnRadioButton_2 = new Button(compositeHead, SWT.RADIO);
    btnRadioButton_2.setText("Selected Persons");
    btnRadioButton_2.setData(2);
    btnRadioButton_2.addSelectionListener(radioSelAdapter);
    btnRadioButton_2.setSelection(_searchTarget == 2);

    Button chaine2Selection = new Button(compositeHead, SWT.CHECK);
    chaine2Selection.setText("Chain2Selection");
    chaine2Selection.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            _chain2Selection = !_chain2Selection;
        }

    });
    chaine2Selection.setSelection(_chain2Selection);

    Composite composite_2 = new Composite(compositeHead, SWT.NONE);
    composite_2.setLayout(new GridLayout(4, false));
    composite_2.setLayoutData(new GridData());
    ((GridData) composite_2.getLayoutData()).horizontalSpan = 5;
    ((GridData) composite_2.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) composite_2.getLayoutData()).grabExcessHorizontalSpace = true;

    Label lblWebservice = new Label(composite_2, SWT.NONE);
    lblWebservice.setText("Webservice");

    ComboViewer comboViewer = new ComboViewer(composite_2, SWT.READ_ONLY);
    Combo combo_1 = comboViewer.getCombo();
    combo_1.setLayoutData(new GridData());
    ((GridData) combo_1.getLayoutData()).horizontalSpan = 2;
    ((GridData) combo_1.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) combo_1.getLayoutData()).grabExcessHorizontalSpace = true;
    comboViewer.setContentProvider(new AEConfigPresentableContentProvider());
    comboViewer.setLabelProvider(new AEConfigPresentableLabelProvider());
    if (IdentifiersExtension.getConcurrenceSearchServices() != null) {
        comboViewer.setInput(IdentifiersExtension.getConcurrenceSearchServices());
    }
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection iSelection = event.getSelection();
            Object obj = ((IStructuredSelection) iSelection).getFirstElement();
            _concurrenceSearchService = (IConcurrenceSearchService) obj;

        }
    });

    Object in = comboViewer.getInput();
    if (in instanceof Map<?, ?>) {
        Map<String, IConcurrenceSearchService> map = (Map<String, IConcurrenceSearchService>) in;
        String pdrKey = null;
        for (String s : map.keySet()) {
            if (s.toLowerCase().contains("pdr")) {
                pdrKey = s;
                break;
            }
        }
        if (pdrKey != null) {
            IConcurrenceSearchService service = map.get(pdrKey);
            comboViewer.setSelection(new StructuredSelection(service));
        } else if (comboViewer.getElementAt(0) != null) {
            comboViewer.setSelection(new StructuredSelection(comboViewer.getElementAt(0)));
        }
    }

    Button btnGo = new Button(composite_2, SWT.NONE);
    btnGo.setText("GO");
    btnGo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (_selectedPerson != null) {
                if (_resultMap == null) {
                    _resultMap = new HashMap<PdrId, ConcurrenceDataHead>();
                }
                if (!_resultMap.containsKey(_selectedPerson.getPdrId())) {
                    searchConcurringPersons(_searchTarget, _concurrenceSearchService);
                } else if (_resultMap.containsKey(_selectedPerson.getPdrId())
                        && !_resultMap.get(_selectedPerson.getPdrId()).getServices()
                                .contains(_concurrenceSearchService.getLabel())) {
                    searchConcurringPersons(_searchTarget, _concurrenceSearchService);
                } else {
                    loadConcurrenceData(_selectedPerson, _resultMap.get(_selectedPerson.getPdrId()));
                }
            } else if (_searchTarget < 2) {
                searchConcurringPersons(_searchTarget, _concurrenceSearchService);
            }
        }

    });

    _scrolledComposite = new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    _scrolledComposite.setLayoutData(new GridData());
    ((GridData) _scrolledComposite.getLayoutData()).horizontalSpan = 1;
    ((GridData) _scrolledComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _scrolledComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _scrolledComposite.getLayoutData()).verticalAlignment = SWT.FILL;
    ((GridData) _scrolledComposite.getLayoutData()).grabExcessVerticalSpace = true;
    _scrolledComposite.setExpandHorizontal(true);
    _scrolledComposite.setExpandVertical(true);
    _scrolledComposite.setBackground(AEVIEWConstants.VIEW_BACKGROUND_SELECTED_COLOR);

    _contentComposite = new Composite(_scrolledComposite, SWT.NONE);
    _contentComposite.setLayout(new GridLayout(1, false));
    _scrolledComposite.setContent(_contentComposite);
    _contentComposite.setLayoutData(new GridData());
    ((GridData) _contentComposite.getLayoutData()).horizontalSpan = 1;
    ((GridData) _contentComposite.getLayoutData()).horizontalAlignment = SWT.FILL;
    ((GridData) _contentComposite.getLayoutData()).grabExcessHorizontalSpace = true;
    ((GridData) _contentComposite.getLayoutData()).verticalAlignment = SWT.FILL;
    ((GridData) _contentComposite.getLayoutData()).grabExcessVerticalSpace = true;
    _contentComposite.setBackground(AEVIEWConstants.VIEW_BACKGROUND_DESELECTED_COLOR);

}

From source file:org.bonitasoft.studio.actors.ui.wizard.page.SelectOrganizationWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite/*from w ww.j  a  v  a 2s. c  om*/
            .setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(5, 5).equalWidth(false).create());

    Label organizationLabel = new Label(mainComposite, SWT.NONE);
    organizationLabel.setText(Messages.selectOrganization);

    final ComboViewer organizationCombo = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER);
    organizationCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    organizationCombo.setContentProvider(new ArrayContentProvider());
    organizationCombo.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((Organization) ((IRepositoryFileStore) element).getContent()).getName();
        }
    });

    organizationCombo.addSelectionChangedListener(this);
    organizationCombo.setInput(organizationStore.getChildren());
    String id = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
            .getString(ActorsPreferenceConstants.DEFAULT_ORGANIZATION);
    IRepositoryFileStore defaultOrganization = organizationStore
            .getChild(id + "." + OrganizationRepositoryStore.ORGANIZATION_EXT);
    if (defaultOrganization == null) {
        List<OrganizationFileStore> orga = organizationStore.getChildren();
        if (!orga.isEmpty()) {
            defaultOrganization = orga.get(0);
        }
    }
    if (defaultOrganization != null) {
        organizationCombo.setSelection(new StructuredSelection(defaultOrganization));
        refreshOrganization((Organization) defaultOrganization.getContent());
    }
    Label separator = new Label(mainComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());

    setControl(mainComposite);
}

From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite//from  www  . j av a2s.co m
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(400, SWT.DEFAULT).create());
    mainComposite
            .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 10).spacing(15, 5).create());

    context = new DataBindingContext();
    if (component == null) {
        component = ConnectorDefinitionFactory.eINSTANCE.createText();
    }
    final Label idLabel = new Label(mainComposite, SWT.NONE);
    idLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    idLabel.setText(Messages.widgetId + "*");

    final Text idText = new Text(mainComposite, SWT.BORDER);
    idText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    idTextObservable = SWTObservables.observeText(idText, SWT.Modify);
    bindComponentId(idText);

    final Label widgetTypeLabel = new Label(mainComposite, SWT.NONE);
    widgetTypeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    widgetTypeLabel.setText(Messages.widgetType);

    final ComboViewer typeViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY);
    typeViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    typeViewer.setContentProvider(new ArrayContentProvider());
    typeViewer.setLabelProvider(new WidgetLabelProvider());
    typeViewer.setInput(widgetTypes);

    typeViewer.setSelection(new StructuredSelection(component.eClass()));

    final Label inputLabel = new Label(mainComposite, SWT.NONE);
    inputLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    inputLabel.setText(Messages.input + " *");

    final ComboViewer inputViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY);
    inputViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    inputViewer.setContentProvider(new ArrayContentProvider());
    inputViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            Input input = (Input) element;
            return super.getText(input.getName() + " (" + input.getType() + ")");
        }
    });
    inputViewer.setInput(inputs);
    inputSelectionObservable = ViewersObservables.observeSingleSelection(inputViewer);
    bindComponentInput(inputViewer);

    final Label displayNameLabel = new Label(mainComposite, SWT.NONE);
    displayNameLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    displayNameLabel.setText(Messages.displayName);

    final Text displayNameText = new Text(mainComposite, SWT.BORDER);
    displayNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    context.bindValue(SWTObservables.observeText(displayNameText, SWT.Modify),
            PojoProperties.value(SelectPageWidgetDialog.class, "displayName").observe(this));

    final Label descriptionLabel = new Label(mainComposite, SWT.NONE);
    descriptionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create());
    descriptionLabel.setText(Messages.description);

    final Text descriptionText = new Text(mainComposite, SWT.BORDER | SWT.MULTI);
    descriptionText
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 60).create());

    context.bindValue(SWTObservables.observeText(descriptionText, SWT.Modify),
            PojoProperties.value(SelectPageWidgetDialog.class, "description").observe(this));

    section = new Section(parent, Section.NO_TITLE);
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).create());
    section.setClient(createSectionClient(component));
    section.setExpanded(isExpanded(component));

    typeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            EClass eClass = (EClass) ((IStructuredSelection) event.getSelection()).getFirstElement();
            String id = null;
            if (component != null) {
                id = component.getId();
            }
            String input = null;
            if (component instanceof WidgetComponent) {
                input = ((WidgetComponent) component).getInputName();
            }
            component = (Component) ConnectorDefinitionFactory.eINSTANCE.create(eClass);
            component.setId(id);
            if (component instanceof WidgetComponent) {
                ((WidgetComponent) component).setInputName(input);
            }
            bindComponentId(idText);
            bindComponentInput(inputViewer);

            section.setClient(createSectionClient(component));
            section.setExpanded(isExpanded(component));
            Shell shell = section.getShell();
            Point defaultSize = shell.getSize();
            Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
            shell.setSize(defaultSize.x, size.y);
            shell.layout(true, true);
        }
    });

    dialogSupport = DialogSupport.create(this, context);

    return mainComposite;
}

From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java

License:Open Source License

protected void bindComponentInput(final ComboViewer inputViewer) {
    inputViewer.getCombo().setEnabled(component instanceof WidgetComponent);
    Iterator it = context.getBindings().iterator();
    Binding toRemove = null;/*w w  w.ja  v a2 s .  com*/
    while (it.hasNext()) {
        Binding object = (Binding) it.next();
        if (object.getTarget().equals(inputSelectionObservable)) {
            toRemove = object;
        }
    }
    if (toRemove != null) {
        toRemove.validateTargetToModel();
        context.removeBinding(toRemove);
    }
    if (component instanceof WidgetComponent) {
        UpdateValueStrategy targetToModel = new UpdateValueStrategy();
        targetToModel.setConverter(new Converter(Input.class, String.class) {

            @Override
            public Object convert(Object from) {
                if (from != null) {
                    return ((Input) from).getName();
                }
                return null;
            }
        });

        targetToModel.setBeforeSetValidator(new IValidator() {

            @Override
            public IStatus validate(Object value) {
                if (!(component instanceof WidgetComponent)) {
                    return Status.OK_STATUS;
                }
                if (value == null || value.toString().isEmpty()) {
                    return ValidationStatus.error(Messages.inputIsEmpty);
                }
                if (alreadyBoundInputs.contains(value.toString())) {
                    return ValidationStatus.error(Messages.inputAlreadyUseInAnotherWidget);
                }
                return Status.OK_STATUS;
            }
        });

        UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
        modelToTarget.setConverter(new Converter(String.class, Input.class) {

            @Override
            public Object convert(Object from) {
                for (Input input : inputs) {
                    if (input.getName().equals(from)) {
                        return input;
                    }
                }
                return null;
            }
        });

        ControlDecorationSupport.create(context.bindValue(inputSelectionObservable,
                EMFObservables.observeValue(component,
                        ConnectorDefinitionPackage.Literals.WIDGET_COMPONENT__INPUT_NAME),
                targetToModel, modelToTarget), SWT.LEFT);
    }
}

From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java

License:Open Source License

private Control createScriptEditorComposite(ScriptEditor widget) {
    final Composite mainComposite = new Composite(section, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create());

    final Label interpreterLabel = new Label(mainComposite, SWT.NONE);
    interpreterLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
    interpreterLabel.setText(Messages.interpreter + " *");

    final ComboViewer interpreterViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY);
    interpreterViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    interpreterViewer.setContentProvider(new ArrayContentProvider());
    interpreterViewer.setLabelProvider(new LabelProvider());
    List<String> interpreters = new ArrayList<String>();
    for (IScriptLanguageProvider provider : ScriptLanguageService.getInstance().getScriptLanguageProviders()) {
        interpreters.add(provider.getLanguageName());
    }//  w  w w . ja  v a  2  s.c  om
    interpreterViewer.setInput(interpreters);
    context.bindValue(ViewersObservables.observeSingleSelection(interpreterViewer), EMFObservables
            .observeValue(widget, ConnectorDefinitionPackage.Literals.SCRIPT_EDITOR__INTERPRETER));

    return mainComposite;
}