List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties enabled
public static IWidgetValueProperty enabled()
From source file:uk.ac.stfc.isis.ibex.ui.dae.experimentsetup.ExperimentSetup.java
License:Open Source License
/** * The constructor for the panel.//from ww w . j a v a 2s . co m * * @param parent * The parent composite which this panel belongs to. * @param style * The SWT style flags for this panel. */ @SuppressWarnings("checkstyle:magicnumber") public ExperimentSetup(Composite parent, int style) { super(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginHeight = 0; gridLayout.verticalSpacing = 5; gridLayout.marginWidth = 0; gridLayout.horizontalSpacing = 0; setLayout(gridLayout); CTabFolder tabFolder = new CTabFolder(this, SWT.BORDER); tabFolder.setSelectionBackground( Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); CTabItem tbtmTimeChannels = new CTabItem(tabFolder, SWT.NONE); tbtmTimeChannels.setText("Time Channels"); Composite timeChannelsComposite = new Composite(tabFolder, SWT.NONE); tbtmTimeChannels.setControl(timeChannelsComposite); timeChannelsComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); timeChannels = new TimeChannelsPanel(timeChannelsComposite, SWT.NONE); CTabItem tbtmDataAcquisition = new CTabItem(tabFolder, SWT.NONE); tbtmDataAcquisition.setText("Data Acquisition"); Composite dataAcquisitionComposite = new Composite(tabFolder, SWT.NONE); tbtmDataAcquisition.setControl(dataAcquisitionComposite); dataAcquisitionComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); dataAcquisition = new DataAcquisitionPanel(dataAcquisitionComposite, SWT.NONE); CTabItem tbtmPeriods = new CTabItem(tabFolder, SWT.NONE); tbtmPeriods.setText("Periods"); Composite periodsComposite = new Composite(tabFolder, SWT.NONE); tbtmPeriods.setControl(periodsComposite); periodsComposite.setLayout(new FillLayout(SWT.HORIZONTAL)); periods = new PeriodsPanel(periodsComposite, SWT.NONE); tabFolder.setSelection(0); GridData tabFolderGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); // Don't let the tab folder shrink vertically or controls can start // disappearing tabFolderGridData.minimumHeight = tabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; tabFolder.setLayoutData(tabFolderGridData); Button btnSendChanges = new Button(this, SWT.NONE); btnSendChanges.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { viewModel.updateDae(); sendingChanges.open(); } catch (Exception err) { // Top level error handler. Catch anything and log it, and bring up an error dialog informing the user of the error. IsisLog.getLogger(this.getClass()).error(err); MessageDialog.openError(getShell(), "Internal IBEX Error", "Please report this error to the IBEX team.\n\nException was: " + err.getMessage()); } } }); btnSendChanges.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnSendChanges.setText("Apply Changes"); //Bind the send changes button to the begin action so that it is only available when write enabled and in SETUP RunSummaryViewModel rsvm = DaeUI.getDefault().viewModel().runSummary(); bindingContext.bindValue(WidgetProperties.enabled().observe(btnSendChanges), BeanProperties.value("canExecute").observe(rsvm.actions().begin)); }
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 va 2s. co m*/ * @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())); }
From source file:uk.ac.stfc.isis.ibex.ui.dae.run.ActionButton.java
License:Open Source License
private void bind(final Action action) { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.enabled().observe(this), BeanProperties.value("canExecute").observe(action)); addSelectionListener(new SelectionAdapter() { @Override//from w ww . java2s.co m public void widgetSelected(SelectionEvent e) { action.execute(); } }); }
From source file:uk.ac.stfc.isis.ibex.ui.dae.run.RunSummary.java
License:Open Source License
/** * Binds run model properties to GUI elements. * /*from w ww . ja va 2 s . c o m*/ * @param viewModel the model containing the run information */ public void setModel(RunSummaryViewModel viewModel) { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.text().observe(instrument), BeanProperties.value("value").observe(viewModel.instrument())); bindingContext.bindValue(WidgetProperties.text().observe(runStatus), BeanProperties.value("value").observe(viewModel.runStatus())); bindingContext.bindValue(WidgetProperties.text().observe(runNumber), BeanProperties.value("value").observe(viewModel.runNumber())); bindingContext.bindValue(WidgetProperties.text().observe(isisCycle), BeanProperties.value("value").observe(viewModel.isisCycle())); bindingContext.bindValue(WidgetProperties.selection().observe(btnDisplayTitle), BeanProperties.value("value").observe(viewModel.displayTitle().value())); bindingContext.bindValue(WidgetProperties.enabled().observe(btnDisplayTitle), BeanProperties.value("value").observe(viewModel.displayTitle().canSetValue())); messageBox.setModel(viewModel.logMessageSource()); }
From source file:uk.ac.stfc.isis.ibex.ui.devicescreens.dialogs.ConfigureDeviceScreensTargetPanel.java
License:Open Source License
/** * Creates the target details part of the display. * /*from www. jav a 2 s . c o m*/ * @param mainComposite the parent composite */ @SuppressWarnings("unused") private void createTargetGroup(Composite mainComposite) { Group grpDetails = new Group(mainComposite, SWT.NONE); grpDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); grpDetails.setText("Target"); grpDetails.setLayout(new GridLayout(1, false)); Composite detailsComposite = new Composite(grpDetails, SWT.NONE); detailsComposite.setLayout(new GridLayout(2, false)); detailsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); Label lblName = new Label(detailsComposite, SWT.NONE); lblName.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblName.setText("Name"); Text txtName = new Text(detailsComposite, SWT.BORDER); txtName.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); // Target of IOC Label lblTarget = new Label(detailsComposite, SWT.NONE); lblTarget.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblTarget.setText("Target"); TargetNameWidget targetSelect = new TargetNameWidget(detailsComposite, viewModel); targetSelect.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // Description Label lblDescription = new Label(detailsComposite, SWT.NONE); lblDescription.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblDescription.setText("Description"); Text txtDescription = new Text(detailsComposite, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.MULTI); GridData gdDescription = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); gdDescription.heightHint = 70; txtDescription.setLayoutData(gdDescription); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtDescription), BeanProperties.value("description").observe(viewModel), null, null); Composite propertiesComposite = new Composite(detailsComposite, SWT.NONE); propertiesComposite.setLayout(new GridLayout(2, false)); propertiesComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); TargetPropertiesViewModel propsViewModel = new TargetPropertiesViewModel(viewModel); TargetPropertiesWidget propertiesView = new TargetPropertiesWidget(propertiesComposite, propsViewModel); YesNoRadioButtons yesNoRadioButtons = new YesNoRadioButtons(detailsComposite, "Save this device screen", "Remove this device screen when IBEX is closed"); bindingContext.bindValue(BeanProperties.value("selected").observe(yesNoRadioButtons), BeanProperties.value("persistence").observe(viewModel)); bindingContext.bindValue(BeanProperties.value("enabled").observe(yesNoRadioButtons), BeanProperties.value("persistenceEnabled").observe(viewModel)); bindingContext.bindValue(WidgetProperties.enabled().observe(txtName), BeanProperties.value("enabled").observe(viewModel)); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtName), BeanProperties.value("name").observe(viewModel)); bindingContext.bindValue(WidgetProperties.enabled().observe(grpDetails), BeanProperties.value("enabled").observe(viewModel)); }
From source file:uk.ac.stfc.isis.ibex.ui.devicescreens.dialogs.TargetNameWidget.java
License:Open Source License
/** * Create the controls./*ww w . j ava2 s . co m*/ * * @param parent the parent composite */ private void createControls(Composite parent) { GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; setLayout(gridLayout); ComboViewer cmboOpiName = new ComboViewer(parent, SWT.READ_ONLY); Combo combo = cmboOpiName.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); cmboOpiName.setContentProvider(new ArrayContentProvider()); cmboOpiName.setInput(availableOPIs); cmboOpiName.getCombo().select(-1); DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.selection().observe(cmboOpiName.getCombo()), BeanProperties.value("key").observe(viewModel)); bindingContext.bindValue(WidgetProperties.enabled().observe(cmboOpiName.getCombo()), BeanProperties.value("enabled").observe(viewModel)); }
From source file:uk.ac.stfc.isis.ibex.ui.experimentdetails.ExperimentDetailsPanel.java
License:Open Source License
private void bind() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.enabled().observe(btnRBLookup), BeanProperties.value("value").observe(viewModel.rbNumber.canSetText())); bindingContext.bindValue(WidgetProperties.enabled().observe(btnAddUserDetails), BeanProperties.value("value").observe(viewModel.rbNumber.canSetText())); bindingContext.bindValue(WidgetProperties.enabled().observe(btnClearUserDetails), BeanProperties.value("value").observe(viewModel.rbNumber.canSetText())); bindingContext.bindValue(WidgetProperties.enabled().observe(btnUpdateUserDetails), BeanProperties.value("value").observe(viewModel.rbNumber.canSetText())); viewModel.rbNumber.canSetText().addPropertyChangeListener(new PropertyChangeListener() { @Override/*from ww w .j a v a2s.c o m*/ public void propertyChange(PropertyChangeEvent event) { boolean canSet = (boolean) event.getNewValue(); beamParameters.enableEditing(canSet); sampleParameters.enableEditing(canSet); } }); }
From source file:uk.ac.stfc.isis.ibex.ui.ioccontrol.IocButtonPanel.java
License:Open Source License
private void bindStart(final IocState ioc) { IConverter startConverter = new Converter(Boolean.class, Boolean.class) { @Override/*from w w w. jav a 2 s. c o m*/ public Object convert(Object arg0) { return control.startIoc().getCanSend() && !ioc.getIsRunning(); } }; UpdateValueStrategy startStrategy = new UpdateValueStrategy(); startStrategy.setConverter(startConverter); bindingContext.bindValue(WidgetProperties.enabled().observe(start), BeanProperties.value("canSend").observe(control.startIoc()), null, startStrategy); bindingContext.bindValue(WidgetProperties.enabled().observe(start), BeanProperties.value("isRunning").observe(ioc), null, startStrategy); }
From source file:uk.ac.stfc.isis.ibex.ui.ioccontrol.IocButtonPanel.java
License:Open Source License
private void bindStop(final IocState ioc) { IConverter stopConverter = new Converter(Boolean.class, Boolean.class) { @Override// w w w.ja va2 s . com public Object convert(Object arg0) { return control.stopIoc().getCanSend() && ioc.getIsRunning(); } }; UpdateValueStrategy stopStrategy = new UpdateValueStrategy(); stopStrategy.setConverter(stopConverter); bindingContext.bindValue(WidgetProperties.enabled().observe(stop), BeanProperties.value("canSend").observe(control.stopIoc()), null, stopStrategy); bindingContext.bindValue(WidgetProperties.enabled().observe(stop), BeanProperties.value("isRunning").observe(ioc), null, stopStrategy); }
From source file:uk.ac.stfc.isis.ibex.ui.ioccontrol.IocButtonPanel.java
License:Open Source License
private void bindRestart(final IocState ioc) { IConverter restartConverter = new Converter(Boolean.class, Boolean.class) { @Override/* ww w . j a v a2 s .co m*/ public Object convert(Object arg0) { return control.restartIoc().getCanSend() && ioc.getIsRunning(); } }; UpdateValueStrategy restartStrategy = new UpdateValueStrategy(); restartStrategy.setConverter(restartConverter); bindingContext.bindValue(WidgetProperties.enabled().observe(restart), BeanProperties.value("canSend").observe(control.restartIoc()), null, restartStrategy); bindingContext.bindValue(WidgetProperties.enabled().observe(restart), BeanProperties.value("isRunning").observe(ioc), null, restartStrategy); }