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

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

Introduction

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

Prototype

@Deprecated
public static ISWTObservableValue observeSelection(Control control) 

Source Link

Document

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

Usage

From source file:org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.ScalingBlock.java

License:Open Source License

public Control createContents(Composite parent) {
    final Realm realm = bindings.getValidationRealm();

    Composite result = group(parent, DiagramUIPrintingMessages.JPSPrintDialog_Scaling);
    layout(result, 5);//from  w w  w.  j  a  v a2  s  . com

    Button adjustRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_Adjust);
    layoutSpanHorizontal(adjustRadio, 2);
    Text textScale = text(result, 20);
    layoutSpanHorizontal(blank(result), 2);

    final IObservableValue scalingValue = BeansObservables.observeValue(realm, options,
            PrintOptions.PROPERTY_PERCENT_SCALING);

    bindings.bindValue(SWTObservables.observeSelection(adjustRadio), scalingValue, null, null);

    bindings.bindValue(SWTObservables.observeText(textScale, SWT.Modify),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_SCALE_FACTOR), null, null);
    bindings.bindValue(SWTObservables.observeEnabled(textScale), scalingValue, null, null);

    Button fitToRadio = radio(result, DiagramUIPrintingMessages.JPSPrintDialog_FitTo);

    IObservableValue fitToValue = new ComputedValue(realm) {
        protected Object calculate() {
            return Boolean.valueOf(!((Boolean) scalingValue.getValue()).booleanValue());
        }
    };

    bindings.bindValue(SWTObservables.observeSelection(fitToRadio), fitToValue, null, null);

    layoutHorizontalIndent(layoutAlignRight(label(result, DiagramUIPrintingMessages.JPSPrintDialog_PagesWide)));

    Text textWide = text(result, 20);

    layoutHorizontalIndent(layoutAlignRight(label(result, DiagramUIPrintingMessages.JPSPrintDialog_PagesTall)));
    Text textTall = text(result, 20);

    bindings.bindValue(SWTObservables.observeText(textWide, SWT.Modify),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_FIT_TO_WIDTH), null, null);

    bindings.bindValue(SWTObservables.observeEnabled(textWide), fitToValue, null, null);

    bindings.bindValue(SWTObservables.observeText(textTall, SWT.Modify),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_FIT_TO_HEIGHT), null, null);

    bindings.bindValue(SWTObservables.observeEnabled(textTall), fitToValue, null, null);

    return result;
}

From source file:org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.SidesBlock.java

License:Open Source License

public Control createContents(Composite parent) {
    final Realm realm = bindings.getValidationRealm();

    Composite result = group(parent, DiagramUIPrintingMessages.JPSOptionsDialog_Sides);
    layout(result, 2);/*from w  w  w.jav  a 2  s. c  o m*/

    Button oneSideRadio = radio(result, DiagramUIPrintingMessages.JPSOptionsDialog_SidesOneSided);
    layoutSpanHorizontal(oneSideRadio, 4);

    Button tumbleRadio = radio(result, DiagramUIPrintingMessages.JPSOptionsDialog_SidesTumble);
    layoutSpanHorizontal(tumbleRadio, 4);

    Button duplexRadio = radio(result, DiagramUIPrintingMessages.JPSOptionsDialog_SidesDuplex);
    layoutSpanHorizontal(duplexRadio, 4);

    oneSidedBinding = bindings.bindValue(SWTObservables.observeSelection(oneSideRadio),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_SIDES_ONESIDED), null, null);

    tumbleBinding = bindings.bindValue(SWTObservables.observeSelection(tumbleRadio),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_SIDES_TUMBLE), null, null);

    duplexBinding = bindings.bindValue(SWTObservables.observeSelection(duplexRadio),
            BeansObservables.observeValue(realm, options, PrintOptions.PROPERTY_SIDES_DUPLEX), null, null);

    return result;
}

From source file:org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletChangePage.java

License:Open Source License

private void initDefaultSuffixButton(final Composite parent) {
    _chgDefaultSuffix = new Button(parent, SWT.CHECK);
    _chgDefaultSuffix.setText(getTextForChangeType() + " '.xhtml' DEFAULT_SUFFIX parameter");
    _chgDefaultSuffix.setSelection(_dataModel.isChgDefaultSuffix());
    _chgDefaultSuffix.setLayoutData(new RowData());
    IObservableValue modelObservable = BeansObservables.observeValue(_dataModel, "chgDefaultSuffix");

    _bindingContext.bindValue(SWTObservables.observeSelection(_chgDefaultSuffix), modelObservable, null, null);
}

From source file:org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletChangePage.java

License:Open Source License

private void initViewHandlerButton(final Composite parent) {
    _chgViewHandler = new Button(parent, SWT.CHECK);
    _chgViewHandler.setText(getTextForChangeType() + " Facelet view handler");
    _chgViewHandler.setSelection(_dataModel.isChgViewHandler());
    _chgViewHandler.setLayoutData(new RowData());
    IObservableValue modelObservable = BeansObservables.observeValue(_dataModel, "chgViewHandler");

    _bindingContext.bindValue(SWTObservables.observeSelection(_chgViewHandler), modelObservable, null, null);
}

From source file:org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletChangePage.java

License:Open Source License

private void initConfigureListener(final Composite parent) {
    _chgConfigureListener = new Button(parent, SWT.CHECK);
    _chgConfigureListener//from   w w  w . ja  va2s . co  m
            .setText(getTextForChangeType() + " configure listener (needed by some Tomcat containers)");
    _chgConfigureListener.setSelection(_dataModel.isChgConfigureListener());
    _chgConfigureListener.setLayoutData(new RowData());
    IObservableValue modelObservable = BeansObservables.observeValue(_dataModel, "chgConfigureListener");

    _bindingContext.bindValue(SWTObservables.observeSelection(_chgConfigureListener), modelObservable, null,
            null);
}

From source file:org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletChangePage.java

License:Open Source License

private void initWebappLifecycleListener(final Composite parent) {
    _chgWebappLifecycleListener = new Button(parent, SWT.CHECK);
    _chgWebappLifecycleListener.setText(
            getTextForChangeType() + " web application lifecycle listener (needed by some Tomcat containers)");
    _chgWebappLifecycleListener.setSelection(_dataModel.isChgConfigureListener());
    _chgWebappLifecycleListener.setLayoutData(new RowData());
    IObservableValue modelObservable = BeansObservables.observeValue(_dataModel, "chgWebAppLifecycleListener");

    _bindingContext.bindValue(SWTObservables.observeSelection(_chgWebappLifecycleListener), modelObservable,
            null, null);//from w ww. j  a v a 2  s. co m
}

From source file:org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingConfigComponent.java

License:Open Source License

/**
 * /*  ww w  .ja  v a2 s .  c  o  m*/
 * @param boundProperty The model property to use for databinding for
 *                      the created UI elements.
 * @param bindingContext The context to use for databinding for the created
 *                       UI elements.
 * @param factorScale Slider to bind.
 * @param factorText Label to bind.
 * @param lockCheckbox Checkbox to bind.
 * @param masterObservable Observable for the master element for which these
 *                         UI elements serve as detail. Essentially, the
 *                         created UI elements represent detailed
 *                         information about this element.
 * @param editor The editor containing the factor UI elements.
 */
private void bindFactor(String boundProperty, final DataBindingContext bindingContext, final Scale factorScale,
        Label factorText, Button lockCheckbox, IObservableValue masterObservable, IJBEditor editor) {

    IObservableValue uiElement = SWTObservables.observeSelection(factorScale);
    IObservableValue modelElement = BeansObservables.observeDetailValue(masterObservable, boundProperty,
            double.class);

    bindingContext.bindValue(uiElement, modelElement,
            new JBEditorUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST)
                    .setConverter(m_sliderToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToSliderConverter));
    uiElement = SWTObservables.observeText(factorText);
    bindingContext.bindValue(uiElement, modelElement,
            new UpdateValueStrategy().setConverter(m_labelToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToLabelConverter));

    IObservableValue checkboxSelection = SWTObservables.observeSelection(lockCheckbox);

    uiElement = SWTObservables.observeEnabled(factorScale);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));
    bindingContext.bindValue(uiElement, checkboxSelection,
            new UpdateValueStrategy().setConverter(m_inverseBooleanConverter),
            new UpdateValueStrategy().setConverter(m_inverseBooleanConverter));

    uiElement = SWTObservables.observeEnabled(factorText);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));
    bindingContext.bindValue(uiElement, checkboxSelection,
            new UpdateValueStrategy().setConverter(m_inverseBooleanConverter),
            new UpdateValueStrategy().setConverter(m_inverseBooleanConverter));

    uiElement = SWTObservables.observeEnabled(lockCheckbox);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));

}

From source file:org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingConfigComponent.java

License:Open Source License

/**
 * Updates the binding between the given scale and its corresponding model
 * value. This is done by removing the old bindings and creating new ones.
 * /*from   ww w.  j a v a 2  s.co  m*/
 * @param boundProperty the property for the binding
 * @param bindingContext the binding context
 * @param factorScale the scale
 * @param masterObservable the observable
 */
private void updateBindFactor(String boundProperty, final DataBindingContext bindingContext,
        final Scale factorScale, IObservableValue masterObservable) {

    IObservableValue uiElement = SWTObservables.observeSelection(factorScale);
    IObservableValue modelElement = BeansObservables.observeDetailValue(masterObservable, boundProperty,
            double.class);

    removeBinding(uiElement, modelElement);
    bindingContext.bindValue(uiElement, modelElement,
            new JBEditorUpdateValueStrategy(UpdateValueStrategy.POLICY_ON_REQUEST)
                    .setConverter(m_sliderToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToSliderConverter));

    Label factorText = m_factorLabels.get(factorScale);
    uiElement = SWTObservables.observeText(factorText);
    removeBinding(uiElement, modelElement);
    bindingContext.bindValue(uiElement, modelElement,
            new UpdateValueStrategy().setConverter(m_labelToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToLabelConverter));

    uiElement = SWTObservables.observeEnabled(factorScale);
    removeBinding(uiElement, masterObservable);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));
}

From source file:org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingConfigComponent.java

License:Open Source License

/**
 * Updates the binding for the threshold
 * @param bindingContext the binding context
 * @param masterObservable the model observable
 *///from  w  ww. j a va 2s.  co m
private void updateThresholdBind(final DataBindingContext bindingContext, IObservableValue masterObservable) {
    IObservableValue uiElement;
    IObservableValue modelElement;
    String boundProperty = IObjectMappingProfilePO.PROP_THRESHOLD;
    uiElement = SWTObservables.observeSelection(m_threshold);
    modelElement = BeansObservables.observeDetailValue(masterObservable, boundProperty, double.class);
    removeBinding(uiElement, masterObservable);
    bindingContext.bindValue(uiElement, modelElement,
            new UpdateValueStrategy().setConverter(m_sliderToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToSliderConverter));

    uiElement = SWTObservables.observeText(m_thresholdText);
    removeBinding(uiElement, masterObservable);
    bindingContext.bindValue(uiElement, modelElement, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToLabelConverter));
}

From source file:org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingConfigComponent.java

License:Open Source License

/**
 * Creates the labels and slider for the Threshold property as
 * well as the corresponding data bindings.
 * /*from  w w w  . j a  va 2s.co m*/
 * @param parent Parent of the created components.
 * @param bindingContext The data binding context.
 * @param masterObservable Observable value used to determine
 *                         which model object is currently
 *                         being observed in detail.
 */
private void createThresholdSlider(Composite parent, DataBindingContext bindingContext,
        IObservableValue masterObservable) {

    String boundProperty = IObjectMappingProfilePO.PROP_THRESHOLD;
    // create Widget
    Label label = new Label(parent, SWT.NONE);
    label.setText(Messages.ObjectMappingPreferencePageThreshold);
    m_threshold = new Scale(parent, SWT.NONE);
    m_threshold.setMinimum(0);
    m_threshold.setMaximum(HUNDRED_PERCENT);
    m_threshold.setIncrement(STEP);
    m_threshold.setPageIncrement(STEP);
    m_threshold.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    m_thresholdText = new Label(parent, SWT.NONE);
    setLabelWidth(m_thresholdText);
    new Label(parent, SWT.NONE);

    ISWTObservableValue uiElement = SWTObservables.observeSelection(m_threshold);
    IObservableValue modelElement = BeansObservables.observeDetailValue(masterObservable, boundProperty,
            double.class);
    bindingContext.bindValue(uiElement, modelElement,
            new UpdateValueStrategy().setConverter(m_sliderToModelConverter),
            new UpdateValueStrategy().setConverter(m_modelToSliderConverter));

    uiElement = SWTObservables.observeText(m_thresholdText);
    bindingContext.bindValue(uiElement, modelElement, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToLabelConverter));

    uiElement = SWTObservables.observeEnabled(m_threshold);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));

    uiElement = SWTObservables.observeEnabled(m_thresholdText);
    bindingContext.bindValue(uiElement, masterObservable,
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            new UpdateValueStrategy().setConverter(m_modelToEnablementConverter));
}