Example usage for org.eclipse.jface.databinding.swt WidgetProperties selection

List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties selection

Introduction

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

Prototype

public static IWidgetValueProperty selection() 

Source Link

Document

Returns a value property for observing the selection state of a Button , CCombo , Combo , DateTime , List , MenuItem (since 1.5), Scale , Slider (since 1.5) or Spinner .

Usage

From source file:uk.ac.stfc.isis.ibex.ui.journalviewer.JournalViewerView.java

License:Open Source License

private void bind() {
    bindingContext.bindValue(WidgetProperties.text().observe(lblError),
            BeanProperties.value("message").observe(model));
    bindingContext.bindValue(WidgetProperties.text().observe(lblLastUpdate),
            BeanProperties.value("lastUpdate").observe(model));
    bindingContext.bindValue(WidgetProperties.selection().observe(spinnerPageNumber),
            BeanProperties.value("pageNumber").observe(model));
    bindingContext.bindValue(WidgetProperties.maximum().observe(spinnerPageNumber),
            BeanProperties.value("pageNumberMax").observe(model));

    btnRefresh.addSelectionListener(new SelectionAdapter() {
        @Override/*ww  w .j a va2  s  . c om*/
        public void widgetSelected(SelectionEvent e) {
            model.refresh();
        }
    });

    model.addPropertyChangeListener("runs", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    changeTableColumns();
                    table.setRows(model.getRuns());
                }
            });
        }
    });

    // Add a listener to refresh the page whenever it becomes visible
    try {
        getSite().getPage().addPartListener(new PartAdapter() {
            /**
            * {@inheritDoc}
            */
            @Override
            public void partVisible(IWorkbenchPartReference partRef) {
                super.partVisible(partRef);
                model.refresh();
            }
        });
    } catch (NullPointerException e) {
        // If getSite or getPage return null then log the error but carry on.
        IsisLog.getLogger(getClass()).info("Couldn't add visibility listener to Journal view");
    }
}

From source file:uk.ac.stfc.isis.ibex.ui.runcontrol.dialogs.RunControlEditorPanel.java

License:Open Source License

private void setModel(RunControlViewModel viewModel) {
    DataBindingContext bindingContext = new DataBindingContext();

    bindingContext.bindValue(WidgetProperties.enabled().observe(btnSend),
            BeanProperties.value("sendEnabled").observe(viewModel));

    bindingContext.bindValue(SWTObservables.observeText(txtLowLimit, SWT.Modify),
            BeanProperties.value("txtLowLimit").observe(viewModel));
    bindingContext.bindValue(SWTObservables.observeText(txtHighLimit, SWT.Modify),
            BeanProperties.value("txtHighLimit").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(chkEnabled),
            BeanProperties.value("rcEnabled").observe(viewModel));
}

From source file:uk.ac.stfc.isis.ibex.ui.scriptgenerator.SettingsPanel.java

License:Open Source License

/**
  * The databinding of all settings between SettingsPanel and Settings.
  * // ww w.ja  v a  2 s . c  om
  * @param settings the settings to be displayed
  */
public void bind(final SansSettings settings) {
    final DataBindingContext bindingContext = new DataBindingContext();
    IValidator validator = new NumbersOnlyValidator();

    UpdateValueStrategy strategy = new UpdateValueStrategy();
    strategy.setAfterGetValidator(validator);

    IObservableValue targetOrder = ViewersObservables.observeSingleSelection(comboOrder);
    IObservableValue modelOrder = BeanProperties.value("order").observe(settings);
    bindingContext.bindValue(targetOrder, modelOrder);

    IObservableValue targetDoSans = WidgetProperties.text(SWT.Modify).observe(txtDoSans);
    IObservableValue modelDoSans = BeanProperties.value("doSans").observe(settings);
    Binding bindValueDoSans = bindingContext.bindValue(targetDoSans, modelDoSans, strategy, null);

    ControlDecorationSupport.create(bindValueDoSans, SWT.TOP | SWT.RIGHT);

    IObservableValue targetDoTrans = WidgetProperties.text(SWT.Modify).observe(txtDoTrans);
    IObservableValue modelDoTrans = BeanProperties.value("doTrans").observe(settings);
    Binding bindValueDoTrans = bindingContext.bindValue(targetDoTrans, modelDoTrans, strategy, null);

    ControlDecorationSupport.create(bindValueDoTrans, SWT.TOP | SWT.RIGHT);

    IObservableValue targetLoopOver = WidgetProperties.selection().observe(btnLoopOver);
    IObservableValue modelLoopOver = BeanProperties.value("loopOver").observe(settings);
    bindingContext.bindValue(targetLoopOver, modelLoopOver);

    IObservableValue targetApertureSans = ViewersObservables.observeSingleSelection(comboApertureSans);
    IObservableValue modelApertureSans = BeanProperties.value("sansSize").observe(settings);
    bindingContext.bindValue(targetApertureSans, modelApertureSans);

    IObservableValue targetApertureTrans = ViewersObservables.observeSingleSelection(comboApertureTrans);
    IObservableValue modelApertureTrans = BeanProperties.value("transSize").observe(settings);
    bindingContext.bindValue(targetApertureTrans, modelApertureTrans);

    IObservableValue targetGeometry = ViewersObservables.observeSingleSelection(comboSampleGeometry);
    IObservableValue modelGeometry = BeanProperties.value("geometry").observe(settings);
    bindingContext.bindValue(targetGeometry, modelGeometry);

    IObservableValue targetSampleHeight = WidgetProperties.text(SWT.Modify).observe(txtSampleHeight);
    IObservableValue modelSampleHeight = BeanProperties.value("sampleHeight").observe(settings);
    Binding bindValueSampleHeight = bindingContext.bindValue(targetSampleHeight, modelSampleHeight, strategy,
            null);

    ControlDecorationSupport.create(bindValueSampleHeight, SWT.TOP | SWT.RIGHT);

    IObservableValue targetSampleWidth = WidgetProperties.text(SWT.Modify).observe(txtSampleWidth);
    IObservableValue modelSampleWidth = BeanProperties.value("sampleWidth").observe(settings);
    Binding bindValueSampleWidth = bindingContext.bindValue(targetSampleWidth, modelSampleWidth, strategy,
            null);

    ControlDecorationSupport.create(bindValueSampleWidth, SWT.TOP | SWT.RIGHT);

    IObservableValue targetCollection = ViewersObservables.observeSingleSelection(comboCollectionMode);
    IObservableValue modelCollection = BeanProperties.value("collection").observe(settings);
    bindingContext.bindValue(targetCollection, modelCollection);

    settings.addPropertyChangeListener("geometry", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            txtSampleWidth.setEnabled(true);
            bindingContext.bindValue(WidgetProperties.text().observe(txtSampleWidth),
                    BeanProperties.value("sampleWidth").observe(settings));
            if (settings.getGeometry() == SampleGeometry.DISC) {
                txtSampleWidth.setEnabled(false);
                bindingContext.bindValue(WidgetProperties.text().observe(txtSampleWidth),
                        BeanProperties.value("sampleHeight").observe(settings));
            }
        }
    });
}

From source file:uk.ac.stfc.isis.ibex.ui.synoptic.widgets.SynopticSelection.java

License:Open Source License

private void bind(SynopticSelectionViewModel model) {
    DataBindingContext bindingContext = new DataBindingContext();

    bindingContext.bindList(SWTObservables.observeItems(synopticCombo),
            BeanProperties.list(SynopticSelectionViewModel.SYNOPTIC_LIST).observe(model));
    bindingContext.bindValue(WidgetProperties.selection().observe(synopticCombo),
            BeanProperties.value(SynopticSelectionViewModel.SELECTED).observe(model));
    bindingContext.bindValue(WidgetProperties.enabled().observe(synopticCombo),
            BeanProperties.value(SynopticSelectionViewModel.ENABLED).observe(model));
    bindingContext.bindValue(WidgetProperties.enabled().observe(refreshButton),
            BeanProperties.value(SynopticSelectionViewModel.ENABLED).observe(model));

}

From source file:uk.co.saiman.eclipse.model.ui.provider.editor.CellEditor.java

License:Open Source License

protected void createRenderingControls(Composite parent, EMFDataBindingContext context) {
    createVisibleWhenControl(parent, context);

    ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_Visible, getMaster(), context,
            WidgetProperties.selection(),
            EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__VISIBLE));

    ControlFactory.createCheckBox(parent, Messages.ModelTooling_UIElement_ToBeRendered, getMaster(), context,
            WidgetProperties.selection(),
            EMFEditProperties.value(getEditingDomain(), UiPackageImpl.Literals.UI_ELEMENT__TO_BE_RENDERED));

}

From source file:uk.co.saiman.eclipse.model.ui.provider.editor.TreeEditor.java

License:Open Source License

private void createEditableControl(Composite parent, EMFDataBindingContext context) {
    ControlFactory.createCheckBox(parent, getString("_UI_Tree_editable_feature"), getMaster(), context,
            WidgetProperties.selection(),
            EMFEditProperties.value(getEditingDomain(), eINSTANCE.getTree_Editable()));
}