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

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

Introduction

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

Prototype

public static IWidgetValueProperty enabled() 

Source Link

Document

Returns a value property for observing the enablement state of a Control , Menu (since 1.5), MenuItem (since 1.5), ScrollBar (since 1.5) or ToolItem (since 1.5).

Usage

From source file:uk.ac.stfc.isis.ibex.ui.nicos.NicosControlButtonPanel.java

License:Open Source License

private void bind() {
    bindingContext.bindValue(WidgetProperties.text().observe(btnTogglePause),
            BeanProperties.value("toggleButtonText").observe(statusModel));
    bindingContext.bindValue(WidgetProperties.image().observe(btnTogglePause),
            BeanProperties.value("toggleButtonIcon").observe(statusModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(btnTogglePause),
            BeanProperties.value("enableButtons").observe(statusModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(btnStop),
            BeanProperties.value("enableButtons").observe(statusModel));
    bindingContext.bindValue(WidgetProperties.text().observe(lblStatusReadback),
            BeanProperties.value("statusReadback").observe(statusModel));

    btnTogglePause.addSelectionListener(new SelectionAdapter() {
        @Override/* w ww .  j  a v  a 2 s .  co  m*/
        public void widgetSelected(SelectionEvent e) {
            statusModel.toggleExecution();
        }
    });

    btnStop.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            statusModel.stopExecution();
        }
    });
}

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.synoptic.editor.dialogs.SaveSynopticDialog.java

License:Open Source License

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

    model.addPropertyChangeListener("error", new PropertyChangeListener() {

        @Override/*from w  w w.  j a  va  2 s  . c om*/
        public void propertyChange(PropertyChangeEvent evt) {
            setErrorMessage(model.getError().getMessage());
        }
    });

    setErrorMessage(model.getError().getMessage());

    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtName),
            BeanProperties.value("synopticName").observe(model));

    bindingContext.bindValue(WidgetProperties.enabled().observe(okButton),
            BeanProperties.value("savingAllowed").observe(model));
}

From source file:uk.ac.stfc.isis.ibex.ui.synoptic.editor.pv.PVList.java

License:Open Source License

/**
 * Bind the controls to the view model.//w  ww  .  j a va 2 s .c  o m
 * 
 * @param viewModel
 *            The view model to bind to.
 */
private void bind(PvListViewModel viewModel) {
    DataBindingContext bindingContext = new DataBindingContext();

    bindingContext.bindValue(WidgetProperties.enabled().observe(btnDelete),
            BeanProperties.value("deleteEnabled").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(btnUp),
            BeanProperties.value("upEnabled").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(btnDown),
            BeanProperties.value("downEnabled").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(btnAdd),
            BeanProperties.value("addEnabled").observe(viewModel));
}

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

License:Open Source License

private void setModel(final NavigationPresenter navigator) {
    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.enabled().observe(previous),
            BeanProperties.value("hasPrevious").observe(navigator));
    bindingContext.bindValue(WidgetProperties.enabled().observe(up),
            BeanProperties.value("hasUp").observe(navigator));
    bindingContext.bindValue(WidgetProperties.enabled().observe(next),
            BeanProperties.value("hasNext").observe(navigator));

    bindingContext.bindList(WidgetProperties.items().observe(gotoCombo),
            BeanProperties.list("targets").observe(presenter));

    previous.setToolTipText(navigator.nameOfPrevious());
    up.setToolTipText(navigator.nameOfUp());
    next.setToolTipText(navigator.nameOfNext());

    navigator.addPropertyChangeListener("currentNode", new PropertyChangeListener() {
        @Override// w ww .  ja v  a  2 s.c  om
        public void propertyChange(PropertyChangeEvent e) {
            previous.setToolTipText(navigator.nameOfPrevious());
            up.setToolTipText(navigator.nameOfUp());

            // Next button has text direction right to left in order to place
            // image on the right hand side. This causes parentheses to be 
            // incorrectly formatted.
            next.setToolTipText(navigator.nameOfNext().replace("(", "- ").replace(')', ' '));
        }
    });

    previous.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            navigator.previous();
        }
    });

    up.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            navigator.up();
        }
    });

    next.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            navigator.next();
        }
    });
}

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.ac.stfc.isis.ibex.ui.widgets.observable.WritableObservingTextBox.java

License:Open Source License

private void bind(final StringWritableObservableAdapter adapter) {
    bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.enabled().observe(setButton),
            BeanProperties.value("value").observe(adapter.canSetText()));
    bindingContext.bindValue(WidgetProperties.enabled().observe(textbox),
            BeanProperties.value("value").observe(adapter.canSetText()));
    bindingContext.bindValue(WidgetProperties.text().observe(textbox),
            BeanProperties.value("value").observe(adapter.text()));

    textbox.addListener(SWT.Traverse, new Listener() {
        @Override/*  w  w w.  j  ava  2  s .co m*/
        public void handleEvent(Event event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                uncheckedSetText(adapter);
            }
        }
    });

    setButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            uncheckedSetText(adapter);
        }
    });
}