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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeEditable(Control control) 

Source Link

Document

Returns an observable observing the editable attribute of the provided control.

Usage

From source file:com.rcpcompany.uibindings.internal.uiAttributeFactories.TextEditableUIAttributeFactory.java

License:Open Source License

@Override
public IUIAttribute create(Widget widget, String attribute) {
    return new SimpleUIAttribute(widget, attribute, SWTObservables.observeEditable((Control) widget));
}

From source file:gov.nasa.ensemble.core.detail.emf.util.EMFDetailUtils.java

License:Open Source License

/**
 * Bind the control's enabled state and editability (for Text controls) with respect to the target object's feature value. If equalityCheck is true, the control is editable and enabled if
 * target.eGet(feature).equals(value), otherwise if the equalityCheeck is false, then the control is editable and enabled if !target.eGet(feature).equals(value)
 * //from  w ww  . ja v a 2  s . co  m
 * @param dbc
 *            data binding context
 * @param control
 *            to control editability and enabled state
 * @param target
 *            model to observe
 * @param feature
 *            to observe
 * @param value
 *            to check for equality
 * @param equalityCheck
 *            true if equality implies enabled/editable
 */
public static void bindControlViability(DataBindingContext dbc, Control control, EObject target,
        EStructuralFeature feature, Object value, boolean equalityCheck) {
    bindControlViability(dbc, target, feature, value, SWTObservables.observeEnabled(control), equalityCheck);
    if (control instanceof Text) {
        bindControlViability(dbc, target, feature, value, SWTObservables.observeEditable(control),
                equalityCheck);
    }
}

From source file:gov.nasa.ensemble.core.detail.emf.util.EMFDetailUtils.java

License:Open Source License

public static void bindControlViability(DataBindingContext dbc, IObservableValue observable,
        Control[] controls) {/*from  ww w  .j  a v  a2 s . co m*/
    for (Control control : controls) {
        try {
            Binding binding = dbc.bindValue(SWTObservables.observeEditable(control), observable);
            dbc.addBinding(binding);
            binding.updateModelToTarget();
        } catch (IllegalArgumentException e) { /* some controls just cannot be controlled as such */
        } catch (Exception e) {
            LogUtil.error("cannot create binding", e);
        }
        try {
            Binding binding = dbc.bindValue(SWTObservables.observeEnabled(control), observable);
            dbc.addBinding(binding);
            binding.updateModelToTarget();
        } catch (IllegalArgumentException e) { /* some controls just cannot be controlled as such */
        } catch (Exception e) {
            LogUtil.error("cannot create binding", e);
        }
    }
}

From source file:org.bonitasoft.studio.expression.editor.viewer.ExpressionViewer.java

License:Open Source License

protected void bindEditableText(IObservableValue typeObservable) {
    UpdateValueStrategy modelToTargetTypeStrategy = new UpdateValueStrategy();
    modelToTargetTypeStrategy.setConverter(new Converter(String.class, Boolean.class) {

        @Override/*from w  w  w .jav a  2  s .  co  m*/
        public Object convert(Object from) {
            final boolean isScriptType = ExpressionConstants.SCRIPT_TYPE.equals(from.toString());
            final boolean isConnectorType = from.toString().equals(ExpressionConstants.CONNECTOR_TYPE);
            final boolean isXPathType = from.toString().equals(ExpressionConstants.XPATH_TYPE);
            final boolean isJavaType = from.toString().equals(ExpressionConstants.JAVA_TYPE);
            if (isScriptType) {
                textTooltip.setText(Messages.editScriptExpressionTooltip);
            } else if (isXPathType) {
                textTooltip.setText(Messages.editXpathExpressionTooltip);
            } else if (isJavaType) {
                textTooltip.setText(Messages.editJavaExpressionTooltip);
            } else if (isConnectorType) {
                textTooltip.setText(Messages.editConnectorExpressionTooltip);
            } else {
                textTooltip.setText(null);
            }
            return !(isScriptType || isConnectorType || isJavaType || isXPathType);
        }

    });

    internalDataBindingContext.bindValue(SWTObservables.observeEditable(textControl), typeObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), modelToTargetTypeStrategy);
}

From source file:org.kalypso.model.wspm.tuhh.ui.imports.sobek.SobekImportFilePage.java

License:Open Source License

private void createStationControls(final Composite panel) {
    final Group group = new Group(panel, SWT.NONE);
    group.setText(Messages.getString("SobekImportFilePage.6")); //$NON-NLS-1$
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(group);

    new Label(group, SWT.NONE).setText(Messages.getString("SobekImportFilePage.7")); //$NON-NLS-1$

    final ComboViewer combo = new ComboViewer(group);
    combo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    combo.setContentProvider(new ArrayContentProvider());
    combo.setLabelProvider(new LabelProvider());
    combo.setInput(GUESS_STATION_STRATEGY.values());

    final IViewerObservableValue targetStrategy = ViewersObservables.observeSinglePostSelection(combo);
    final IObservableValue modelStrategy = BeansObservables.observeValue(m_data,
            SobekImportData.PROPERTY_STATION_STRATEGY);
    m_binding.bindValue(targetStrategy, modelStrategy);

    new Label(group, SWT.NONE);

    /* Pattern control */
    final Label patternLabel = new Label(group, SWT.NONE);
    patternLabel.setText(Messages.getString("SobekImportFilePage.8")); //$NON-NLS-1$

    final Text patternField = new Text(group, SWT.BORDER);
    patternField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    patternField.setMessage(Messages.getString("SobekImportFilePage.9")); //$NON-NLS-1$
    patternField.setToolTipText(Messages.getString("SobekImportFilePage.10")); //$NON-NLS-1$

    final GuessStationPatternReplacer replacer = new GuessStationPatternReplacer();
    replacer.createPatternButton(group, patternField);

    final ISWTObservableValue targetPattern = SWTObservables.observeText(patternField, SWT.Modify);
    final IObservableValue modelPattern = BeansObservables.observeValue(m_data,
            SobekImportData.PROPERTY_STATION_PATTERN);
    final DataBinder binderPattern = new DataBinder(targetPattern, modelPattern);
    binderPattern.addTargetAfterGetValidator(new GuessStationPatternValidator());
    m_binding.bindValue(binderPattern);/*from w  w w .  j a  va2 s  . c om*/

    final ISWTObservableValue targetEnablement = SWTObservables.observeEditable(patternField);
    final IObservableValue modelEnablement = BeansObservables.observeValue(m_data,
            SobekImportData.PROPERTY_STATION_PATTERN_ENABLED);
    m_binding.bindValue(targetEnablement, modelEnablement);

    final ISWTObservableValue targetLabelEnablement = SWTObservables.observeEnabled(patternLabel);
    final IObservableValue modelLabelEnablement = BeansObservables.observeValue(m_data,
            SobekImportData.PROPERTY_STATION_PATTERN_ENABLED);
    m_binding.bindValue(targetLabelEnablement, modelLabelEnablement);
}

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;/*from  www .j ava 2 s.c  o m*/
    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;
}