use of org.eclipse.core.databinding.UpdateValueStrategy in project statecharts by Yakindu.
the class StatechartPropertySection method bindDomainCombo.
protected void bindDomainCombo(EMFDataBindingContext context) {
IEMFValueProperty property = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject), BasePackage.Literals.DOMAIN_ELEMENT__DOMAIN_ID);
IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(domainCombo);
UpdateValueStrategy modelToTarget = new UpdateValueStrategy() {
@Override
public Object convert(Object value) {
return ((IDomain) value).getDomainID();
}
};
UpdateValueStrategy targetToModel = new UpdateValueStrategy() {
@Override
public Object convert(Object value) {
return DomainRegistry.getDomain((String) value);
}
};
context.bindValue(observeSingleSelection, property.observe(eObject), modelToTarget, targetToModel);
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project statecharts by Yakindu.
the class StatechartPropertySection method bindSpecificationControl.
protected void bindSpecificationControl(EMFDataBindingContext context) {
IEMFValueProperty modelProperty = EMFEditProperties.value(TransactionUtil.getEditingDomain(eObject), SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
ISWTObservableValue uiProperty = WidgetProperties.text(SWT.FocusOut).observe(textControl);
context.bindValue(uiProperty, modelProperty.observe(eObject), null, new UpdateValueStrategy() {
@Override
protected IStatus doSet(IObservableValue observableValue, Object value) {
if (getCompletionProposalAdapter() != null && !getCompletionProposalAdapter().isProposalPopupOpen())
return super.doSet(observableValue, value);
return Status.OK_STATUS;
}
});
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project portfolio by buchen.
the class BindingHelper method bindDatePicker.
public final void bindDatePicker(Composite editArea, String label, String property) {
Label l = new Label(editArea, SWT.NONE);
l.setText(label);
DatePicker boxDate = new DatePicker(editArea);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(boxDate.getControl());
context.bindValue(new SimpleDateTimeDateSelectionProperty().observe(boxDate.getControl()), BeanProperties.value(property).observe(model), //
new UpdateValueStrategy().setAfterConvertValidator(value -> {
return value != null ? ValidationStatus.ok() : ValidationStatus.error(MessageFormat.format(Messages.MsgDialogInputRequired, label));
}), null);
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project portfolio by buchen.
the class BindingHelper method bindComboViewer.
public final ComboViewer bindComboViewer(Composite editArea, String label, String property, IBaseLabelProvider labelProvider, IValidator validator, Object input) {
Label l = new Label(editArea, SWT.NONE);
l.setText(label);
ComboViewer combo = new ComboViewer(editArea, SWT.READ_ONLY);
combo.setContentProvider(ArrayContentProvider.getInstance());
combo.setLabelProvider(labelProvider);
combo.setInput(input);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(combo.getControl());
UpdateValueStrategy strategy = new UpdateValueStrategy();
if (validator != null)
strategy.setAfterConvertValidator(validator);
//
context.bindValue(//
ViewersObservables.observeSingleSelection(combo), BeanProperties.value(property).observe(model), strategy, null);
return combo;
}
use of org.eclipse.core.databinding.UpdateValueStrategy in project portfolio by buchen.
the class BindingHelper method bindMandatoryStringInput.
public final Control bindMandatoryStringInput(Composite editArea, final String label, String property) {
Text txtValue = createTextInput(editArea, label);
//
context.bindValue(//
WidgetProperties.text(SWT.Modify).observe(txtValue), //
BeanProperties.value(property).observe(model), new UpdateValueStrategy().setAfterConvertValidator(new IValidator() {
@Override
public IStatus validate(Object value) {
String v = (String) value;
return v != null && v.trim().length() > 0 ? ValidationStatus.ok() : ValidationStatus.error(MessageFormat.format(Messages.MsgDialogInputRequired, label));
}
}), null);
return txtValue;
}
Aggregations