Java Code Examples for org.eclipse.core.databinding.UpdateValueStrategy#setAfterConvertValidator()
The following examples show how to use
org.eclipse.core.databinding.UpdateValueStrategy#setAfterConvertValidator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageComponentSwitchBuilder.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public PatternExpressionViewer createTextAreaControl(final Composite composite, final TextArea object) { final Input input = getConnectorInput(object.getInputName()); final ConnectorParameter parameter = connectorConfigurationSupport.getConnectorParameter(object.getInputName(), object, input); if (parameter != null) { createFieldLabel(composite, SWT.TOP, object.getId(), input.isMandatory()); final PatternExpressionViewer viewer = new PatternExpressionViewer(composite, SWT.NONE); viewer.addFilter(connectorExpressionContentTypeFilter); viewer.setExpressionNameResolver(new ConnectorInputNameResolver(parameter.getKey())); final Expression exp = (Expression) parameter.getExpression(); final String desc = getDescription(object.getId()); if (desc != null && !desc.isEmpty()) { viewer.setHint(desc); } viewer.setInput(parameter); viewer.setContextInput(container); final UpdateValueStrategy startegy = new UpdateValueStrategy(); if (input.isMandatory()) { startegy.setAfterConvertValidator(new EmptyInputValidator(getLabel(object.getId()))); } viewer.setEMFBindingContext(context); if (input.isMandatory()) { viewer.setMandatoryField(getLabel(object.getId())); } if(ExpressionConstants.PATTERN_TYPE.equals(exp.getType())){ viewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 300).create()); }else { viewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); } viewer.setExpression(exp); return viewer; } return null; }
Example 2
Source File: PatternExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void bindPatternExpression() { final UpdateValueStrategy startegy = new UpdateValueStrategy(); if (mandatoryFieldLabel != null) { startegy.setAfterConvertValidator(new EmptyInputValidator(mandatoryFieldLabel)); } if (patternBinding != null) { patternBinding.dispose(); patternBinding = null; } configurePatternExpressionModelBuilder(); patternBinding = context.bindValue(SWTObservables.observeText(viewer.getTextWidget(), SWT.Modify), EMFObservables.observeValue(expression, ExpressionPackage.Literals.EXPRESSION__CONTENT), startegy, null); fireDocumentChanged(); }
Example 3
Source File: ScriptExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void bindExpression(final EMFDataBindingContext dataBindingContext, final EObject context, final Expression inputExpression, final ViewerFilter[] filters, final ExpressionViewer viewer) { this.inputExpression = inputExpression; final IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME); final UpdateValueStrategy opposite = new UpdateValueStrategy(); opposite.setConverter(new BooleanInverserConverter()); IObservableValue nameTextObservable = SWTObservables.observeText(expressionNameText, SWT.Modify); final UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setAfterConvertValidator(new EmptyInputValidator(Messages.name)); bindValue = dataBindingContext.bindValue(nameTextObservable, nameModelObservable, targetToModel, null); nameTextObservable.addValueChangeListener(handleValidationStatusChanged()); nameModelObservable.addValueChangeListener(event -> fireSelectionChanged()); editor.bindExpression(dataBindingContext, context, inputExpression, filters, viewer); if (inputExpression.getReturnType() != null) { typeCombo.setInput(inputExpression.getReturnType()); } else { typeCombo.setInput(new Object()); } returnTypeModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE); final String defaultReturnType = viewer.getDefaultReturnType(); if (defaultReturnType != null && !inputExpression.isReturnTypeFixed() && shouldChangeReturnType(inputExpression.getReturnType(), defaultReturnType)) { returnTypeModelObservable.setValue(defaultReturnType); } dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(typeCombo), returnTypeModelObservable); dataBindingContext.bindValue(SWTObservables.observeText(typeCombo.getCombo()), returnTypeModelObservable, updateValueStrategy().withConverter(ConverterBuilder.<String, String> newConverter() .withConvertFunction(this::toClassName) .create()) .create(), updateValueStrategy().withConverter(ConverterBuilder.<String, String> newConverter() .withConvertFunction(this::toDisplayName) .create()) .create()); typeCombo.getCombo().setEnabled(!inputExpression.isReturnTypeFixed()); browseClassesButton.setEnabled(!inputExpression.isReturnTypeFixed()); }