Example usage for org.eclipse.jface.databinding.viewers.typed ViewerProperties singleSelection

List of usage examples for org.eclipse.jface.databinding.viewers.typed ViewerProperties singleSelection

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.viewers.typed ViewerProperties singleSelection.

Prototype

public static <S extends ISelectionProvider, E> IViewerValueProperty<S, E> singleSelection() 

Source Link

Document

Returns a value property for observing the single selection of a ISelectionProvider .

Usage

From source file:org.eclipse.jface.examples.databinding.snippets.Snippet026AnonymousBeanProperties.java

License:Open Source License

private void bindUI() {
    ISetProperty<Object, Object> treeChildrenProperty = new DelegatingSetProperty<Object, Object>() {
        ISetProperty<ApplicationModel, ContactGroup> modelGroups = BeanProperties.set(ApplicationModel.class,
                "groups", ContactGroup.class);
        ISetProperty<ContactGroup, Contact> groupContacts = BeanProperties.set(ContactGroup.class, "contacts",
                Contact.class);

        @SuppressWarnings("unchecked")
        @Override/* www.  ja v a2s. c  o  m*/
        protected ISetProperty<Object, Object> doGetDelegate(Object source) {
            if (source instanceof ApplicationModel)
                return (ISetProperty<Object, Object>) (Object) modelGroups;
            if (source instanceof ContactGroup)
                return (ISetProperty<Object, Object>) (Object) groupContacts;
            return null;
        }
    };

    ViewerSupport.bind(contactViewer, model, treeChildrenProperty, BeanProperties.values("name", "status"));

    contactViewer.expandAll();

    final IObservableValue<Object> selection = ViewerProperties.singleSelection().observe(contactViewer);

    DataBindingContext dbc = new DataBindingContext();

    dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(nameText),
            BeanProperties.value("name").observeDetail(selection));

    statusViewer.setContentProvider(new ArrayContentProvider());
    statusViewer.setInput(statuses);

    dbc.bindValue(ViewerProperties.singleSelection().observe(statusViewer),
            BeanProperties.value("status").observeDetail(selection));

    dbc.bindValue(WidgetProperties.enabled().observe(statusViewer.getControl()),
            ComputedValue.create(() -> selection.getValue() instanceof Contact));
}

From source file:org.eclipse.n4js.ui.wizard.project.N4JSNewProjectWizardCreationPage.java

License:Open Source License

private void initProjectTypeBinding(final DataBindingContext dbc, final ComboViewer projectType) {
    dbc.bindValue(ViewerProperties.singleSelection().observe(projectType),
            PojoProperties.value(N4JSProjectInfo.class, PROJECT_TYPE_PROP_NAME).observe(projectInfo));
}