Example usage for org.eclipse.jface.databinding.swt SWTObservables observeSingleSelectionIndex

List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSingleSelectionIndex

Introduction

In this page you can find the example usage for org.eclipse.jface.databinding.swt SWTObservables observeSingleSelectionIndex.

Prototype

@Deprecated
public static ISWTObservableValue observeSingleSelectionIndex(Control control) 

Source Link

Document

Returns an observable observing the single selection index attribute of the provided control.

Usage

From source file:com.jaspersoft.studio.server.properties.DataTypeSection.java

License:Open Source License

protected void bind() {
    bindingContext.bindValue(SWTObservables.observeText(tpattern, SWT.Modify),
            PojoObservables.observeValue(res.getValue(), "pattern"));
    bindingContext.bindValue(SWTObservables.observeText(tmin, SWT.Modify),
            PojoObservables.observeValue(res.getValue(), "minValue"));
    bindingContext.bindValue(SWTObservables.observeText(tmax, SWT.Modify),
            PojoObservables.observeValue(res.getValue(), "maxValue"));
    bindingContext.bindValue(SWTObservables.observeSelection(bmin),
            PojoObservables.observeValue(res.getValue(), "strictMin"));
    bindingContext.bindValue(SWTObservables.observeSelection(bmax),
            PojoObservables.observeValue(res.getValue(), "strictMax"));

    bindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(ttype),
            PojoObservables.observeValue(getProxy(res.getValue()), "dataType"));
}

From source file:com.jaspersoft.studio.server.properties.InputControlSection.java

License:Open Source License

@Override
protected void bind() {
    bindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(ctype),
            PojoObservables.observeValue(getProxy(res.getValue()), "controlType"));

    bindingContext.bindValue(SWTObservables.observeSelection(bmand),
            PojoObservables.observeValue(res.getValue(), "mandatory"));
    bindingContext.bindValue(SWTObservables.observeSelection(bread),
            PojoObservables.observeValue(res.getValue(), "readOnly"));
    bindingContext.bindValue(SWTObservables.observeSelection(bvisible),
            PojoObservables.observeValue(res.getValue(), "visible"));
}

From source file:com.jaspersoft.studio.server.properties.ReportUnitSection.java

License:Open Source License

@Override
protected void bind() {
    ReportProxy v = getProxy(res.getValue());
    bindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(cictype),
            PojoObservables.observeValue(v, "layoutControl"));
    bindingContext.bindValue(SWTObservables.observeText(jspview, SWT.Modify),
            PojoObservables.observeValue(v, "jspView"));
    bindingContext.bindValue(SWTObservables.observeText(jspic, SWT.Modify),
            PojoObservables.observeValue(v, "jspIC"));
    bindingContext.bindValue(SWTObservables.observeSelection(ispromp),
            PojoObservables.observeValue(v, "allowPrompt"));
}

From source file:gov.nasa.ensemble.core.detail.emf.binding.ComboBindingFactory.java

License:Open Source License

public Binding createBinding(DetailProviderParameter p, List<EStructuralFeature> dependsOn) {
    DataBindingContext dbc = p.getDataBindingContext();
    FormToolkit toolkit = p.getDetailFormToolkit();
    Composite parent = p.getParent();
    EObject target = p.getTarget();// w  w  w.j  a  va  2 s . c om
    IItemPropertyDescriptor pd = p.getPropertyDescriptor();
    List<Object> choices = getComboChoices(p);
    LabelProvider labeler = getEditLabelProvider(pd, target);
    String items[];
    if (pd.isSortChoices(target)) {
        items = sort(choices, labeler);
    } else {
        items = label(choices, labeler);
    }
    boolean isEditable = pd.canSetProperty(target);
    Label label = EMFDetailUtils.createLabel(parent, toolkit, target, pd);
    final Combo combo = buildCombo(parent);
    combo.setItems(items);
    if (dependsOn != null) {
        setupComboUpdater(combo, label, p, labeler, dependsOn);
    }
    EMFDetailUtils.addDescriptionTooltip(pd, target, combo);
    combo.setLayoutData(Activator.createStandardGridData());
    combo.setEnabled(isEditable);
    toolkit.adapt(combo, true, true);
    EMFDetailUtils.bindValidatorDecoration(p, combo);
    EMFDetailUtils.bindControlViability(p, new Control[] { combo });
    targetToModelUpdateValueStrategy = new FiniteOrderedSetUpdateValueStrategy(
            UpdateValueStrategy.POLICY_UPDATE, choices);
    modelToTargetUpdateValueStrategy = new FiniteOrderedSetUpdateValueStrategy(
            UpdateValueStrategy.POLICY_UPDATE, choices);
    IObservableValue targetObservableValue = null;
    if (combo instanceof TypableCombo && !updateOnSelection) {
        targetObservableValue = new ComboNonSelectionValueProperty().observe(combo);
    } else {
        targetObservableValue = SWTObservables.observeSingleSelectionIndex(combo);
    }
    return dbc.bindValue(targetObservableValue, new UndoableObservableValue(target, pd),
            targetToModelUpdateValueStrategy, modelToTargetUpdateValueStrategy);
}

From source file:net.wedjaa.jasper.elasticsearch.adapter.ESAdapterComposite.java

License:Apache License

@Override
protected void bindWidgets(DataAdapter dataAdapter) {
    bindingContext.bindValue(SWTObservables.observeText(esHostField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchHost"));
    bindingContext.bindValue(SWTObservables.observeText(esPortField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchPort"));
    bindingContext.bindValue(SWTObservables.observeText(esClusterField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchCluster"));
    bindingContext.bindValue(SWTObservables.observeText(esIndexesField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchIndexes"));
    bindingContext.bindValue(SWTObservables.observeText(esTypesField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchTypes"));
    bindingContext.bindValue(SWTObservables.observeText(esUsernameField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchUsername"));
    bindingContext.bindValue(SWTObservables.observeText(esPasswordField, SWT.Modify),
            PojoObservables.observeValue(dataAdapter, "elasticSearchPassword"));
    bindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(esSearchModeField),
            PojoObservables.observeValue(dataAdapter, "elasticSearchMode"));
}

From source file:net.wedjaa.jasper.elasticsearch.server.DatasourceESPageContent.java

License:Apache License

@Override
protected void rebind() {

    ResourceProperty resprop = ResourceDescriptorUtil.getProperty(
            MRDatasourceCustom.PROP_DATASOURCE_CUSTOM_PROPERTY_MAP, res.getValue().getProperties());

    ResourceProperty rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_INDEX_PARAM,
            resprop.getProperties());/*from  www. j  a v  a 2 s  .c  o m*/
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esIndexesField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_TYPE_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esTypesField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_HOST_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esHostField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_PORT_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esPortField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_CLUSTER_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esClusterField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_USER_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esUsernameField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_PASSWORD_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeText(esPasswordField, SWT.Modify),
            PojoObservables.observeValue(rsp, "value"));

    rsp = ResourceDescriptorUtil.getProperty(ESAdapterService.ES_MODE_PARAM, resprop.getProperties());
    rsp.setValue(Misc.nvl(rsp.getValue()));
    bindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(esSearchModeField),
            PojoObservables.observeValue(rsp, "value"));

}

From source file:org.objectstyle.wolips.wooeditor.editor.DisplayGroupDetailsPage.java

License:Open Source License

private void bind() {
    // XXX This method is too long
    if (myDisplayGroup == null) {
        return;/*  w  ww. ja v a2  s.c  o  m*/
    }
    myBindingContext = new DataBindingContext();

    myBindingContext.bindValue(SWTObservables.observeText(myNameText, SWT.Modify),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.NAME), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myClassNameCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.CLASS_NAME_LIST),
            null, null);
    myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myClassNameCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.CLASS_NAME_INDEX), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myEntityCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null,
            null);
    myBindingContext.bindValue(SWTObservables.observeEnabled(myMasterDetailGroup),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);

    UpdateValueStrategy booleanInverse = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) {
        @Override
        protected IStatus doSet(final IObservableValue observableValue, final Object value) {
            Boolean newValue = !(Boolean) value;
            return super.doSet(observableValue, newValue);
        }
    };

    myBindingContext.bindValue(SWTObservables.observeEnabled(myEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse);
    myBindingContext.bindValue(CustomSWTObservables.observeText(myEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTITY_NAME), null, null);

    myBindingContext.bindValue(SWTObservables.observeEnabled(myEditingContextText),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), booleanInverse);
    myBindingContext.bindValue(SWTObservables.observeText(myEditingContextText, SWT.Modify),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.EDITING_CONTEXT), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myHasDetailButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myMasterEntityCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.ENTITY_LIST), null,
            null);
    myBindingContext.bindValue(CustomSWTObservables.observeText(myMasterEntityCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.MASTER_ENTITY_NAME), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myDetailKeyCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.DETAIL_KEY_LIST),
            null, null);

    myBindingContext.bindValue(CustomSWTObservables.observeText(myDetailKeyCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.DETAIL_KEY_NAME), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myEntriesPerBatchSpinner),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.ENTRIES_PER_BATCH), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(mySelectsFirstObjectButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SELECTS_FIRST_OBJECT), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(myQualificationCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.QUALIFICATION_LIST),
            null, null);
    myBindingContext.bindValue(SWTObservables.observeSingleSelectionIndex(myQualificationCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.QUALIFICATION_INDEX), null, null);

    myBindingContext.bindValue(SWTObservables.observeSelection(myFetchOnLoadButton),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCHES_ON_LOAD), null, null);

    myBindingContext.bindList(SWTObservables.observeItems(mySortAttributeCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.SORT_LIST), null,
            null);

    myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortAttributeCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER_KEY), null, null);

    myBindingContext.bindValue(CustomSWTObservables.observeSelection(mySortRadioGroup),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.SORT_ORDER), null, null);

    UpdateValueStrategy fetchSpecEmpty = new UpdateValueStrategy();
    fetchSpecEmpty.setConverter(new IConverter() {
        public Object convert(final Object fromObject) {
            boolean result = fromObject != null && ((List<?>) fromObject).size() > 0;
            if (!myHasDetailButton.getSelection()) {
                return result;
            }
            return false;
        }

        public Object getFromType() {
            return new ArrayList<String>();
        }

        public Object getToType() {
            return true;
        }
    });

    UpdateValueStrategy fetchSpecEnabled = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE) {
        @Override
        protected IStatus doSet(final IObservableValue observableValue, final Object value) {
            Boolean newValue = false;
            if (myFetchSpecCombo.getItemCount() > 0) {
                newValue = !(Boolean) value;
            }
            return super.doSet(observableValue, newValue);
        }
    };
    myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.HAS_MASTER_DETAIL),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEnabled);

    myBindingContext.bindValue(SWTObservables.observeEnabled(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), fetchSpecEmpty);

    myBindingContext.bindList(SWTObservables.observeItems(myFetchSpecCombo),
            BeansObservables.observeList(Realm.getDefault(), myDisplayGroup, DisplayGroup.FETCH_SPEC_LIST),
            null, null);

    UpdateValueStrategy fetchSpecSelection = new UpdateValueStrategy() {
        @Override
        protected IStatus doSet(IObservableValue observableValue, Object value) {
            if (value == null || value.equals("")) {
                value = DisplayGroup.FETCH_SPEC_NONE;
            }
            return super.doSet(observableValue, value);
        }
    };
    myBindingContext.bindValue(CustomSWTObservables.observeSelection(myFetchSpecCombo),
            BeansObservables.observeValue(myDisplayGroup, DisplayGroup.FETCH_SPEC_NAME), null,
            fetchSpecSelection);

    myEntityCombo.addModifyListener(myEntityModifyListener);
    myMasterEntityCombo.addModifyListener(myMasterEntityListener);
    mySortAttributeCombo.addSelectionListener(mySortEntityListener);

}

From source file:org.reap.internal.core.binding.BindingManager.java

License:Open Source License

private IObservable createSWTObservable(final Control control, final BindingConfig binding) {
    IObservable obs = null;/*ww  w .  j  a  v  a 2 s .com*/
    switch (binding.getType()) {
    case BACKGROUND:
        obs = SWTObservables.observeBackground(control);
        break;
    case EDITABLE:
        obs = SWTObservables.observeEditable(control);
        break;
    case ENABLED:
        obs = SWTObservables.observeEnabled(control);
        break;
    case FONT:
        obs = SWTObservables.observeFont(control);
        break;
    case FOREGROUND:
        obs = SWTObservables.observeForeground(control);
        break;
    case ITEMS:
        obs = SWTObservables.observeItems(control);
        break;
    case MAX:
        obs = SWTObservables.observeMax(control);
        break;
    case MIN:
        obs = SWTObservables.observeMin(control);
        break;
    case SELECTION:
        obs = SWTObservables.observeSelection(control);
        break;
    case SINGLESELECTIONINDEX:
        obs = SWTObservables.observeSingleSelectionIndex(control);
        break;
    case TEXT:
        obs = SWTObservables.observeText(control);
        break;
    case TEXTFOCUSOUT:
        obs = SWTObservables.observeText(control, SWT.FocusOut);
        break;
    case TEXTMODIFY:
        obs = SWTObservables.observeText(control, SWT.Modify);
        break;
    case TEXTNONE:
        obs = SWTObservables.observeText(control, SWT.None);
        break;
    case TOOLTIPTEXT:
        obs = SWTObservables.observeTooltipText(control);
        break;
    case VISIBLE:
        obs = SWTObservables.observeVisible(control);
        break;
    default:
        throw new IllegalArgumentException();
    }
    return obs;
}