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

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

Introduction

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

Prototype

public static IWidgetValueProperty text() 

Source Link

Document

Returns a value property for observing the text of a Button , CCombo , CLabel , Combo , Item , Label , Link , Shell , Group , StyledText or Text .

Usage

From source file:uk.ac.gda.ui.components.NumberEditorControl.java

License:Open Source License

private void bind() {
    IObservableValue objectValue = BeanProperties.value(propertyName).observe(targetObject);
    ISWTObservableValue textValue = WidgetProperties.text().observe(numberLabel);
    UpdateValueStrategy modelToTargetUpdateValueStrategy = new UpdateValueStrategy() {
        @Override//from   w  ww.  ja va 2 s .c om
        public Object convert(Object value) {
            if (modelToTargetConverter != null) {
                value = modelToTargetConverter.convert(value);
            }
            return getFormattedText(value);
        }
    };
    if (modelToTargetValidator != null) {
        modelToTargetUpdateValueStrategy.setBeforeSetValidator(modelToTargetValidator);
    }
    numberLabelValueBinding = ctx.bindValue(textValue, objectValue, null, modelToTargetUpdateValueStrategy);
    if (useSpinner) {
        incrementLabelBinding = ctx.bindValue(WidgetProperties.text().observe(incrementText),
                BeanProperties.value(NumberEditorWidgetModel.INCREMENT_PROP_NAME).observe(controlModel),
                new UpdateValueStrategy() {
                    @Override
                    public Object convert(Object value) {
                        if (targetToModelConverter != null) {
                            value = targetToModelConverter.convert(value);
                        }
                        if (controlModel.getBindingPropertyType().equals(double.class)) {
                            return (((Number) value).doubleValue()
                                    * (int) Math.pow(10, controlModel.getDigits()));
                        }
                        return super.convert(value);
                    }
                }, new UpdateValueStrategy() {
                    @Override
                    public Object convert(Object value) {
                        if (modelToTargetConverter != null) {
                            value = modelToTargetConverter.convert(value);
                        }
                        if (controlModel.getBindingPropertyType().equals(double.class)) {
                            double incrementValue = controlModel.getIncrement()
                                    / Math.pow(10, controlModel.getDigits());
                            return roundDoubletoString(incrementValue, controlModel.getDigits());
                        }

                        return Integer.toString((int) Math.round((Double) value));
                    }
                });

        decrementButtonEditableBinding = ctx.bindValue(WidgetProperties.enabled().observe(decrementButton),
                BeanProperties.value(EDITABLE_PROP_NAME).observe(controlModel));

        incrementButtonEditableBinding = ctx.bindValue(WidgetProperties.enabled().observe(incrementButton),
                BeanProperties.value(EDITABLE_PROP_NAME).observe(controlModel));

        incrementText.addListener(SWT.MouseUp, openStepEditorListener);
        incrementText.addMouseTrackListener(editableMouseListener);
        incrementText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));

        incrementButton.addListener(SWT.MouseUp, incrementStepListener);
        incrementButton.addMouseListener(incrementEnabledListener);
        incrementButton.addMouseTrackListener(editableIncrementMouseListener);

        decrementButton.addListener(SWT.MouseUp, decrementStepListener);
        decrementButton.addMouseListener(incrementEnabledListener);
        decrementButton.addMouseTrackListener(editableIncrementMouseListener);
    }
    numberLabel.addMouseTrackListener(editableMouseListener);
    numberLabel.addListener(SWT.MouseUp, openEditorListener);
    numberLabel.setBackground(enabledColor);

    binded = true;
}

From source file:uk.ac.stfc.isis.ibex.ui.banner.widgets.Indicator.java

License:Open Source License

private void bind(IndicatorModel model) {
    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text().observe(text),
            BeanProperties.value("value").observe(model.text()));
    bindingContext.bindValue(WidgetProperties.foreground().observe(text),
            BeanProperties.value("value").observe(model.color()));
    bindingContext.bindValue(WidgetProperties.visible().observe(text),
            BeanProperties.value("value").observe(model.availability()));
}

From source file:uk.ac.stfc.isis.ibex.ui.beamstatus.views.SynchrotronPanel.java

License:Open Source License

private void bind(SynchrotronObservables sync) {
    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text().observe(beamCurrent),
            BeanProperties.value("value").observe(sync.beamCurrent));
    bindingContext.bindValue(WidgetProperties.text().observe(beamFrequency),
            BeanProperties.value("value").observe(sync.beamFrequency));
}

From source file:uk.ac.stfc.isis.ibex.ui.beamstatus.views.TargetStationOnePanel.java

License:Open Source License

private void bind(TS1Observables ts) {
    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text().observe(beam),
            BeanProperties.value("value").observe(ts.beam()));
    bindingContext.bindValue(WidgetProperties.text().observe(pps),
            BeanProperties.value("value").observe(ts.pps()));
    bindingContext.bindValue(WidgetProperties.text().observe(current),
            BeanProperties.value("value").observe(ts.beamCurrent()));
    bindingContext.bindValue(WidgetProperties.text().observe(uAhSince0830),
            BeanProperties.value("value").observe(ts.uAHToday()));
    bindingContext.bindValue(WidgetProperties.text().observe(lastOff),
            BeanProperties.value("value").observe(ts.lastBeamOff()));
    bindingContext.bindValue(WidgetProperties.text().observe(lastOn),
            BeanProperties.value("value").observe(ts.lastBeamOn()));

    bindingContext.bindValue(WidgetProperties.text().observe(methaneTemperature),
            BeanProperties.value("value").observe(ts.methaneTemperature));
    bindingContext.bindValue(WidgetProperties.text().observe(hydrogenTemperature),
            BeanProperties.value("value").observe(ts.hydrogenTemperature));
    bindingContext.bindValue(WidgetProperties.text().observe(muonKicker),
            BeanProperties.value("value").observe(ts.muonKicker));
}

From source file:uk.ac.stfc.isis.ibex.ui.beamstatus.views.TargetStationTwoPanel.java

License:Open Source License

private void bind(TS2Observables ts) {
    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text().observe(beam),
            BeanProperties.value("value").observe(ts.beam()));
    bindingContext.bindValue(WidgetProperties.text().observe(pps),
            BeanProperties.value("value").observe(ts.pps()));
    bindingContext.bindValue(WidgetProperties.text().observe(current),
            BeanProperties.value("value").observe(ts.beamCurrent()));
    bindingContext.bindValue(WidgetProperties.text().observe(uAhSince0830),
            BeanProperties.value("value").observe(ts.uAHToday()));
    bindingContext.bindValue(WidgetProperties.text().observe(lastOff),
            BeanProperties.value("value").observe(ts.lastBeamOff()));
    bindingContext.bindValue(WidgetProperties.text().observe(lastOn),
            BeanProperties.value("value").observe(ts.lastBeamOn()));

    bindingContext.bindValue(WidgetProperties.text().observe(coupledMethaneTemperature),
            BeanProperties.value("value").observe(ts.coupledMethaneTemperature));
    bindingContext.bindValue(WidgetProperties.text().observe(coupledHydrogenTemperature),
            BeanProperties.value("value").observe(ts.coupledHydrogenTemperature));
    bindingContext.bindValue(WidgetProperties.text().observe(decoupledMethaneTemperature),
            BeanProperties.value("value").observe(ts.decoupledMethaneTemperature));
    bindingContext.bindValue(WidgetProperties.text().observe(decoupledModeratorRuntime),
            BeanProperties.value("value").observe(ts.decoupledModeratorRuntime));
    bindingContext.bindValue(WidgetProperties.text().observe(decoupledModeratorRuntimeLimit),
            BeanProperties.value("value").observe(ts.decoupledModeratorRuntimeLimit));
    bindingContext.bindValue(WidgetProperties.text().observe(decoupledModeratorAnnealPressure),
            BeanProperties.value("value").observe(ts.decoupledModeratorAnnealPressure));
    bindingContext.bindValue(WidgetProperties.text().observe(decoupledModeratoruAhBeam),
            BeanProperties.value("value").observe(ts.decoupledModeratorUAHBeam));
}

From source file:uk.ac.stfc.isis.ibex.ui.blocks.groups.Group.java

License:Open Source License

/**
 * Provides the display of groups./*from ww  w. j a v  a  2  s  . c o  m*/
 * 
 * @param parent a widget which will be the parent of the new instance
 * @param style the style of widget to construct
 * @param group the group to be displayed
 * @param panel The panel that shows the groups and blocks. 
 */
public Group(Composite parent, int style, DisplayGroup group, GroupsPanel panel) {
    super(parent, style | SWT.BORDER);

    // Add the blocks to the list if they are visible, or if
    // showHiddenBlocks is true
    List<DisplayBlock> blocksList = new ArrayList<>();
    for (DisplayBlock block : group.blocks()) {
        if (block.getIsVisible() || panel.showHiddenBlocks()) {
            blocksList.add(block);
        }
    }

    // Calculate number of columns we need, each column holding one block
    // with a name and value
    int numberOfColumns = (blocksList.size() - 1) / NUMBER_OF_ROWS + 1;

    // For each block we need three columns in the grid layout, one for
    // name, one for value, one for
    // run control status, and for every column but the last we need a
    // divider label column
    GridLayout layout = new GridLayout(NUMBER_OF_FIELDS * numberOfColumns + (numberOfColumns - 1), false);
    layout.verticalSpacing = 5;
    this.setLayout(layout);
    this.setBackground(WHITE);

    // In the first column put the title in
    title = labelMaker(this, SWT.NONE, group.name(), "", null);
    Font titleFont = getEditedLabelFont(title, 10, SWT.BOLD);
    title.setFont(titleFont);

    // For the title row, fill with blanks
    for (int i = 0; i < (NUMBER_OF_FIELDS + 1) * numberOfColumns - 2; i++) {
        labelMaker(this, SWT.NONE, "", "", titleFont);
    }

    DataBindingContext bindingContext = new DataBindingContext();

    // Loop over the rows and columns. The GridLayout is filled with labels
    // across rows first, then moving on to
    // the next column. So blank labels need to be inserted so that columns
    // are always filled.
    for (int i = 0; i < NUMBER_OF_ROWS; i++) {
        for (int j = 0; j < numberOfColumns; j++) {
            int position = i + j * NUMBER_OF_ROWS;

            if (position >= blocksList.size()) {
                // put blank labels in these name and value columns
                for (int k = 0; k < NUMBER_OF_FIELDS; k++) {
                    labelMaker(this, SWT.NONE, "", "", null);
                }
                break;
            }

            DisplayBlock currentBlock = blocksList.get(position);

            GroupsMenu fullMenu = new GroupsMenu(panel, new BlocksMenu(currentBlock));

            Label blockName = labelMaker(this, SWT.NONE, currentBlock.getName() + ": ",
                    currentBlock.getDescription(), null);
            blockName.setMenu(fullMenu.get());
            blockName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

            // additional container to hold value label to draw a border around it
            Composite valueContainer = new Composite(this, SWT.CENTER);
            GridLayout valueContainerLayout = new GridLayout(1, false);
            valueContainerLayout.marginWidth = 2;
            valueContainerLayout.marginHeight = 2;
            valueContainerLayout.verticalSpacing = 0;
            valueContainerLayout.horizontalSpacing = 0;
            valueContainer.setLayout(valueContainerLayout);

            GridData gdValueContainer = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
            gdValueContainer.widthHint = 79;
            gdValueContainer.heightHint = 19;
            valueContainer.setLayoutData(gdValueContainer);

            Label blockValue = labelMaker(valueContainer, SWT.RIGHT, currentBlock.getValue(),
                    currentBlock.getDescription(), null);
            blockValue.setMenu(fullMenu.get());
            GridData gdValue = new GridData(SWT.CENTER, SWT.NONE, false, false, 1, 1);
            gdValue.widthHint = 75;
            blockValue.setLayoutData(gdValue);
            blockValue.setVisible(true);
            valueContainer.pack();

            Label blockStatus = labelMaker(this, SWT.CENTER, "", "Run Control Status", null);
            FontDescriptor boldDescriptor = FontDescriptor.createFrom(blockStatus.getFont()).setStyle(SWT.BOLD);
            Font boldFont = boldDescriptor.createFont(blockStatus.getDisplay());
            blockStatus.setFont(boldFont);
            GridData gdStatus = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1);
            gdStatus.widthHint = 17;
            blockStatus.setLayoutData(gdStatus);

            if (j < numberOfColumns - 1) {
                // insert divider label
                labelMaker(this, SWT.NONE, "   |   ", "", null);
            }

            bindingContext.bindValue(WidgetProperties.text().observe(blockValue),
                    BeanProperties.value("value").observe(currentBlock));

            bindingContext.bindValue(WidgetProperties.visible().observe(blockStatus),
                    BeanProperties.value("enabled").observe(currentBlock));

            UpdateValueStrategy symbolStrategy = new UpdateValueStrategy();
            symbolStrategy.setConverter(new RunControlSymbolConverter());

            bindingContext.bindValue(WidgetProperties.text().observe(blockStatus),
                    BeanProperties.value("runcontrolState").observe(currentBlock), null, symbolStrategy);

            UpdateValueStrategy fgColourStrategy = new UpdateValueStrategy();
            fgColourStrategy.setConverter(new RunControlForegroundColourConverter());

            bindingContext.bindValue(WidgetProperties.foreground().observe(blockStatus),
                    BeanProperties.value("runcontrolState").observe(currentBlock), null, fgColourStrategy);

            UpdateValueStrategy bgColourStrategy = new UpdateValueStrategy();
            bgColourStrategy.setConverter(new RunControlBackgroundColourConverter());

            bindingContext.bindValue(WidgetProperties.background().observe(blockStatus),
                    BeanProperties.value("runcontrolState").observe(currentBlock), null, bgColourStrategy);

            UpdateValueStrategy borderStrategy = new UpdateValueStrategy();
            borderStrategy.setConverter(new BlockStatusBorderColourConverter());

            bindingContext.bindValue(WidgetProperties.background().observe(valueContainer),
                    BeanProperties.value("blockState").observe(currentBlock), null, borderStrategy);
        }
    }
}

From source file:uk.ac.stfc.isis.ibex.ui.configserver.editing.blocks.BlockLogSettingsPanel.java

License:Open Source License

public void setModel(BlockLogSettingsViewModel viewModel) {
    DataBindingContext bindingContext = new DataBindingContext();

    bindingContext.bindValue(WidgetProperties.selection().observe(btnEnabled),
            BeanProperties.value("enabled").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(cmboType),
            BeanProperties.value("enabled").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(txtSettings),
            BeanProperties.value("enabled").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(cmboType),
            BeanProperties.value("comboText").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.text().observe(lblSettings),
            BeanProperties.value("labelText").observe(viewModel));

    bindingContext.bindValue(SWTObservables.observeText(txtSettings, SWT.Modify),
            BeanProperties.value("textBoxText").observe(viewModel));

}

From source file:uk.ac.stfc.isis.ibex.ui.dae.DaeView.java

License:Open Source License

/**
 * Create contents of the view part./*w  w  w . j ava2s.  co m*/
 * @param parent
 */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new FillLayout(SWT.VERTICAL));

    model = DaeUI.getDefault().viewModel();

    ScrolledComposite scrolledComposite = new ScrolledComposite(parent,
            SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    Composite container = new Composite(scrolledComposite, SWT.NONE);
    scrolledComposite.setContent(container);

    GridData gdContainer = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    container.setLayoutData(gdContainer);
    GridLayout glContainer = new GridLayout(1, false);
    glContainer.horizontalSpacing = 0;
    glContainer.verticalSpacing = 0;
    glContainer.marginWidth = 0;
    glContainer.marginHeight = 0;
    container.setLayout(glContainer);

    Composite titleComposite = new Composite(container, SWT.NONE);
    titleComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    titleComposite.setLayout(new GridLayout(1, false));

    Label lblTitle = new Label(titleComposite, SWT.NONE);
    lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    lblTitle.setAlignment(SWT.LEFT);
    lblTitle.setFont(SWTResourceManager.getFont("Arial", 16, SWT.NORMAL));
    lblTitle.setText(""); // Bound below.

    DataBindingContext bindingContext = new DataBindingContext();
    bindingContext.bindValue(WidgetProperties.text().observe(lblTitle),
            BeanProperties.value("value").observe(model.title()));

    CTabFolder tabFolder = new CTabFolder(container, SWT.BORDER);
    tabFolder.setSelectionBackground(
            Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
    TabIsShownListener.createAndRegister(this, tabFolder, this);

    CTabItem tbtmRunSummary = new CTabItem(tabFolder, SWT.NONE);
    tbtmRunSummary.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/play.png"));
    tbtmRunSummary.setText("Run Summary");

    Composite runSummaryComposite = new Composite(tabFolder, SWT.NONE);
    tbtmRunSummary.setControl(runSummaryComposite);
    runSummaryComposite.setLayout(new GridLayout(1, false));
    runSummary = new RunSummary(runSummaryComposite, SWT.NONE, model.runSummary());
    runSummary.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    CTabItem tbtmExperimentSetup = new CTabItem(tabFolder, SWT.NONE);
    tbtmExperimentSetup
            .setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/setup.png"));
    tbtmExperimentSetup.setText("Experiment Setup");

    Composite experimentalSetupComposite = new Composite(tabFolder, SWT.NONE);
    tbtmExperimentSetup.setControl(experimentalSetupComposite);
    experimentalSetupComposite.setLayout(new GridLayout(1, false));
    experimentSetup = new ExperimentSetup(experimentalSetupComposite, SWT.NONE);
    experimentSetup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    CTabItem tbtmRunInformation = new CTabItem(tabFolder, SWT.NONE);
    tbtmRunInformation
            .setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/info.png"));
    tbtmRunInformation.setText("Run Information");

    Composite runInformationComposite = new Composite(tabFolder, SWT.NONE);
    tbtmRunInformation.setControl(runInformationComposite);
    runInformationComposite.setLayout(new FillLayout(SWT.HORIZONTAL));
    runInformation = new RunInformationPanel(runInformationComposite, SWT.NONE);

    CTabItem tbtmSpectraPlots = new CTabItem(tabFolder, SWT.NONE);
    tbtmSpectraPlots.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/plot.png"));
    tbtmSpectraPlots.setText("Spectra Plots");

    Composite spectraComposite = new Composite(tabFolder, SWT.NONE);
    tbtmSpectraPlots.setControl(spectraComposite);
    spectraComposite.setLayout(new FillLayout(SWT.HORIZONTAL));

    spectraPanel = new SpectraPlotsPanel(spectraComposite, SWT.NONE);

    tbtmDiagnostics = new CTabItem(tabFolder, SWT.NONE);
    tbtmDiagnostics
            .setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/monitor.png"));
    tbtmDiagnostics.setText("Detector Diagnostics");

    Composite diagnosticsComposite = new Composite(tabFolder, SWT.NONE);
    tbtmDiagnostics.setControl(diagnosticsComposite);
    diagnosticsComposite.setLayout(new FillLayout(SWT.HORIZONTAL));

    detectorDiagnosticsPanel = new DetectorDiagnosticsPanel(diagnosticsComposite, SWT.NONE);

    CTabItem tbtmVetos = new CTabItem(tabFolder, SWT.NONE);
    tbtmVetos.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui.dae", "icons/veto.png"));
    tbtmVetos.setText("Vetos");

    Composite vetosComposite = new Composite(tabFolder, SWT.NONE);
    tbtmVetos.setControl(vetosComposite);
    vetosComposite.setLayout(new GridLayout(1, false));

    vetosPanel = new VetosPanel(vetosComposite, SWT.NONE);
    vetosPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    createActions();
    initializeToolBar();
    initializeMenu();

    setModel(DaeUI.getDefault().viewModel());
    tabFolder.setSelection(0);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Point tabSize = tabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Point titleSize = titleComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    Point compositeSize = new Point(tabSize.x + titleSize.x, tabSize.y + titleSize.y);
    scrolledComposite.setMinSize(compositeSize);
}

From source file:uk.ac.stfc.isis.ibex.ui.dae.experimentsetup.DataAcquisitionPanel.java

License:Open Source License

/**
 * Binds model data to the relevant UI elements for automatic update.
 * //from ww  w.j  a  v a2s  .  com
 * @param viewModel the model holding the DAE settings.
 */
public void setModel(DataAcquisitionViewModel viewModel) {
    bindingContext = new DataBindingContext();

    bindingContext.bindList(WidgetProperties.items().observe(wiringTableSelector),
            BeanProperties.list("wiringTableList").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text().observe(wiringTableRB),
            BeanProperties.value("wiringTable").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(wiringTableSelector),
            BeanProperties.value("newWiringTable").observe(viewModel));

    bindingContext.bindList(WidgetProperties.items().observe(detectorTableSelector),
            BeanProperties.list("detectorTableList").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text().observe(detectorTableRB),
            BeanProperties.value("detectorTable").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(detectorTableSelector),
            BeanProperties.value("newDetectorTable").observe(viewModel));

    bindingContext.bindList(WidgetProperties.items().observe(spectraTableSelector),
            BeanProperties.list("spectraTableList").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text().observe(spectraTableRB),
            BeanProperties.value("spectraTable").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(spectraTableSelector),
            BeanProperties.value("newSpectraTable").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(monitorSpectrum),
            BeanProperties.value("monitorSpectrum").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(from),
            BeanProperties.value("from").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(to),
            BeanProperties.value("to").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(btnVeto0),
            BeanProperties.value("veto0").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnVeto1),
            BeanProperties.value("veto1").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnVeto2),
            BeanProperties.value("veto2").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnVeto3),
            BeanProperties.value("veto3").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(btnSMP),
            BeanProperties.value("smpVeto").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnFermiChopper),
            BeanProperties.value("fermiChopperVeto").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnTs2Pulse),
            BeanProperties.value("ts2PulseVeto").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.selection().observe(btnIsisHz),
            BeanProperties.value("isis50HzVeto").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.text().observe(fcDelay),
            BeanProperties.value("fcDelay").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text().observe(fcWidth),
            BeanProperties.value("fcWidth").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(btnMuonMsMode),
            BeanProperties.value("muonMsMode").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(daeTimingSource),
            BeanProperties.value("timingSource").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.selection().observe(btnMuonPulseFirst),
            BeanProperties.value("muonCerenkovPulse").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(autosaveFrequency),
            BeanProperties.value("autosaveFrequency").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(autosaveUnits),
            BeanProperties.value("autosaveUnits").observe(viewModel));
}

From source file:uk.ac.stfc.isis.ibex.ui.dae.experimentsetup.periods.PeriodsPanel.java

License:Open Source License

/**
 * Binds model data to the relevant UI elements for automatic update.
 * /*from   ww w .  j a v a  2s .  c  om*/
 * @param viewModel the model holding the period settings.
 */
public void setModel(final PeriodsViewModel viewModel) {
    this.model = viewModel;

    bindingContext = new DataBindingContext();

    bindingContext.bindList(WidgetProperties.items().observe(cmbPeriodFile),
            BeanProperties.list("periodFilesList").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text().observe(lblPeriodFileRB),
            BeanProperties.value("periodFile").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(cmbPeriodType),
            BeanProperties.value("periodType").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtSoftwarePeriods),
            BeanProperties.value("softwarePeriods").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtHardwarePeriods),
            BeanProperties.value("hardwarePeriods").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtOutputDelay),
            BeanProperties.value("outputDelay").observe(viewModel));

    bindingContext.bindValue(WidgetProperties.enabled().observe(txtHardwarePeriods),
            BeanProperties.value("internalPeriod").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(radioSpecifyParameters),
            BeanProperties.value("hardwarePeriod").observe(viewModel));
    bindingContext.bindValue(WidgetProperties.enabled().observe(radioUsePeriodFile),
            BeanProperties.value("hardwarePeriod").observe(viewModel));

    viewModel.addPropertyChangeListener("internalPeriod", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            lblNote.setVisible(!model.isInternalPeriod());
        }
    });

    viewModel.addPropertyChangeListener("periods", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            setPeriods(viewModel.periods());
        }
    });

    viewModel.addPropertyChangeListener("periodType", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updateTypeStack(matchType((PeriodControlType) evt.getNewValue()));
        }

    });

    viewModel.addPropertyChangeListener("setupSource", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            updateSourceStack(matchSource((PeriodSetupSource) evt.getNewValue()));
        }
    });

    setPeriods(viewModel.periods());
    updateTypeStack(matchType(PeriodControlType.values()[model.getPeriodType()]));
    updateSourceStack(matchSource(model.getSetupSource()));
}