List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties text
public static IWidgetValueProperty text()
From source file:uk.ac.stfc.isis.ibex.ui.motor.views.MinimalMotorView.java
License:Open Source License
/** * Binds the model to the view.//from w w w . j a v a2 s . c o m */ private void bind() { bindingContext.bindValue(WidgetProperties.text().observe(setpoint), BeanProperties.value("setpoint").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.text().observe(value), BeanProperties.value("value").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.text().observe(motorName), BeanProperties.value("motorName").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.font().observe(motorName), BeanProperties.value("font").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.background().observe(motorName), BeanProperties.value("color").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.background().observe(indicator), BeanProperties.value("color").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.background().observe(value), BeanProperties.value("color").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.background().observe(setpoint), BeanProperties.value("color").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.background().observe(this), BeanProperties.value("color").observe(minimalMotorViewModel)); bindingContext.bindValue(WidgetProperties.tooltipText().observe(this), BeanProperties.value("tooltip").observe(minimalMotorViewModel)); }
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//ww w.j a v a 2 s .c o 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.nicos.NicosView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { GridLayout glParent = new GridLayout(2, true); glParent.marginRight = 10;//ww w.java 2 s.c o m glParent.marginHeight = 10; glParent.marginWidth = 10; parent.setLayout(glParent); // Connection info Composite connectionGrp = new Composite(parent, SWT.NONE); connectionGrp.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false, 2, 1)); GridLayout connLayout = new GridLayout(2, false); connLayout.marginRight = 10; connLayout.marginHeight = 10; connLayout.marginWidth = 10; connectionGrp.setLayout(connLayout); Label lblConnectionStatus = new Label(connectionGrp, SWT.NONE); GridData connStatusLayoutData = new GridData(SWT.BEGINNING, SWT.FILL, false, true, 1, 1); connStatusLayoutData.widthHint = 100; lblConnectionStatus.setLayoutData(connStatusLayoutData); bindingContext.bindValue(WidgetProperties.text().observe(lblConnectionStatus), BeanProperties.value("connectionStatus").observe(model), null, new ConnectionStatusConverter()); Label lblConnectionError = new Label(connectionGrp, SWT.NONE); lblConnectionError.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); bindingContext.bindValue(WidgetProperties.text().observe(lblConnectionError), BeanProperties.value("connectionErrorMessage").observe(model)); Composite currentScriptInfoContainer = new Composite(parent, SWT.NONE); currentScriptInfoContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); currentScriptInfoContainer.setLayout(new GridLayout(2, false)); lblCurrentScriptStatus = new Label(currentScriptInfoContainer, SWT.NONE); lblCurrentScriptStatus.setText("Current script status: "); Label lineNumberIndicator = new Label(currentScriptInfoContainer, SWT.NONE); lineNumberIndicator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); bindingContext.bindValue(WidgetProperties.text().observe(lineNumberIndicator), BeanProperties.value("lineNumber").observe(scriptStatusViewModel)); Label lblOutput = new Label(parent, SWT.NONE); lblOutput.setText("Output"); StyledText txtCurrentScript = new StyledText(parent, SWT.BORDER); txtCurrentScript.setEditable(false); txtCurrentScript.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); final StyledText txtOutput = new StyledText(parent, SWT.V_SCROLL | SWT.BORDER); txtOutput.setEditable(false); txtOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3)); bindingContext.bindValue(WidgetProperties.text().observe(txtCurrentScript), BeanProperties.value("currentlyExecutingScript").observe(model)); bindingContext.bindValue(WidgetProperties.text().observe(txtOutput), BeanProperties.value("log").observe(outputLogViewModel)); txtOutput.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event e) { txtOutput.setTopIndex(txtOutput.getLineCount() - 1); } }); Label lblQueuedScripts = new Label(parent, SWT.NONE); lblQueuedScripts.setText("Queued scripts (double click to see contents):"); ListViewer queuedScriptsViewer = new ListViewer(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); List list = queuedScriptsViewer.getList(); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); queuedScriptsViewer.setContentProvider(new ObservableListContentProvider()); queuedScriptsViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { QueuedScript code = (QueuedScript) element; return code.getName(); } }); queuedScriptsViewer.setInput(BeanProperties.list("queuedScripts").observe(model)); queuedScriptsViewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { QueuedScript selection = (QueuedScript) ((IStructuredSelection) event.getSelection()) .getFirstElement(); ExistingScriptDialog dialog = new ExistingScriptDialog(shell, selection); dialog.open(); } }); Composite scriptSendGrp = new Composite(parent, SWT.NONE); scriptSendGrp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); GridLayout ssgLayout = new GridLayout(3, false); ssgLayout.marginHeight = 10; ssgLayout.marginWidth = 10; scriptSendGrp.setLayout(ssgLayout); Button btnCreateScript = new Button(scriptSendGrp, SWT.NONE); btnCreateScript.setText("Create Script"); btnCreateScript.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1)); Label lblQueueScriptStatus = new Label(scriptSendGrp, SWT.NONE); GridData layoutData = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1); layoutData.widthHint = 80; lblQueueScriptStatus.setLayoutData(layoutData); bindingContext.bindValue(WidgetProperties.text().observe(lblQueueScriptStatus), BeanProperties.value("scriptSendStatus").observe(queueScriptViewModel), null, new ScriptSendStatusConverter()); Label lblQueueScriptError = new Label(scriptSendGrp, SWT.NONE); lblQueueScriptError.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); bindingContext.bindValue(WidgetProperties.text().observe(lblQueueScriptError), BeanProperties.value("scriptSendErrorMessage").observe(queueScriptViewModel)); btnCreateScript.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { QueueScriptDialog dialog = new QueueScriptDialog(shell, queueScriptViewModel); dialog.open(); } }); NicosControlButtonPanel controlPanel = new NicosControlButtonPanel(parent, SWT.NONE, scriptStatusViewModel); controlPanel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); }
From source file:uk.ac.stfc.isis.ibex.ui.perspectives.switcher.AlarmButton.java
License:Open Source License
/** * @param parent where the button is stored * @param perspective the perspective to be used by this button */// w w w . j a v a 2 s. c o m public AlarmButton(Composite parent, final String perspective) { super(parent, perspective); this.buttonPerspective = perspective; flash = new FlashingButton(this, display); flash.setDefaultColour(this.getBackground()); model = new AlarmCountViewModel(alarmCounter); bindingContext.bindValue(WidgetProperties.text().observe(this), BeanProperties.value("text").observe(model)); updateFlashing(); model.addPropertyChangeListener("hasMessages", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { updateFlashing(); } }); // update flashing when count changes so that if the number goes up or // down a new alarm is issued model.addPropertyChangeListener("text", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { updateFlashing(); } }); } }); }
From source file:uk.ac.stfc.isis.ibex.ui.perspectives.switcher.LogButton.java
License:Open Source License
/** * @param parent where the button is stored * @param perspective the perspective to be used by this button *//*from w ww. j ava 2 s . c o m*/ public LogButton(Composite parent, final String perspective) { super(parent, perspective); this.buttonPerspective = perspective; flash = new FlashingButton(this, display); flash.setDefaultColour(this.getBackground()); model = new LogCountViewModel(logCounter); bindingContext.bindValue(WidgetProperties.text().observe(this), BeanProperties.value("text").observe(model)); model.addPropertyChangeListener("hasMessages", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { updateFlashing(); } }); } }); }
From source file:uk.ac.stfc.isis.ibex.ui.synoptic.component.ReadableComponentView.java
License:Open Source License
private void setProperty(ReadableComponentProperty property) { propertyName.setText(property.displayName()); bindingContext.bindValue(WidgetProperties.text().observe(value), BeanProperties.value("value").observe(property.value())); }
From source file:uk.ac.stfc.isis.ibex.ui.synoptic.component.WritableComponentView.java
License:Open Source License
private void bindText(final WritableComponentProperty property) { String value = property.value().getValue(); if (value != null) { text.setText(value);/*from w w w . j a v a 2 s . c o m*/ } bindingContext.bindValue(WidgetProperties.text().observe(text), BeanProperties.value("value").observe(property.value())); }
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//from ww w .j av a 2 s. com 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); } }); }