Commit 4454d37d authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Fix operation viewer operator binding

parent bccb0b83
......@@ -145,7 +145,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
actionExpression.validate();
}
}
public void refreshDatabinding() {
final Operation action = getOperation();
if (action != null) {
......@@ -169,15 +169,18 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
private void bindOperator() {
final UpdateValueStrategy uvsOperator = new UpdateValueStrategy();
uvsOperator.setConverter(new OperatorTypeToStringLinkConverter());
uvsOperator.setConverter(new OperatorTypeToStringLinkConverter(EMFEditObservables.observeValue(getEditingDomain(), getOperation(),
ExpressionPackage.Literals.OPERATION__OPERATOR)));
final IObservableValue operatorExpressionObserveValue = EMFEditObservables.observeValue(getEditingDomain(), getOperation().getOperator(),
ExpressionPackage.Literals.OPERATOR__EXPRESSION);
final IObservableValue operatorObservedValue = EMFEditObservables.observeValue(getEditingDomain(), getOperation().getOperator(),
ExpressionPackage.Literals.OPERATOR__TYPE);
operatorObservedValue.addChangeListener(new RevalidateActionExpressionChangeListener());
context.bindValue(SWTObservables.observeText(getOperatorLink()), operatorObservedValue, null, uvsOperator);
context.bindValue(SWTObservables.observeText(getOperatorLink()), operatorObservedValue, null, uvsOperator);
context.bindValue(SWTObservables.observeText(getOperatorLink()), operatorExpressionObserveValue, null, uvsOperator);
context.bindValue(SWTObservables.observeTooltipText(getOperatorLink()),
EMFEditObservables.observeValue(getEditingDomain(), getOperation().getOperator(), ExpressionPackage.Literals.OPERATOR__EXPRESSION));
operatorExpressionObserveValue);
}
private void bindStorageViewer(final Operation action) {
......
......@@ -14,7 +14,9 @@
*/
package org.bonitasoft.studio.expression.editor.operation;
import org.bonitasoft.studio.model.expression.Operator;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
/**
* This Converter is just adding the <A> tags around the String corresponding the Operator Message in order to be well displayed in Link components.
......@@ -24,16 +26,23 @@ import org.eclipse.core.databinding.conversion.Converter;
public class OperatorTypeToStringLinkConverter extends Converter {
private final OperatorLabelProvider operatorLabelProvider;
private final IObservableValue operatorObservableValue;
public OperatorTypeToStringLinkConverter() {
public OperatorTypeToStringLinkConverter(final IObservableValue operatorObservableValue) {
super(String.class, String.class);
operatorLabelProvider = new OperatorLabelProvider();
this.operatorObservableValue = operatorObservableValue;
}
@Override
public String convert(final Object arg0) {
final Operator operator = (Operator) operatorObservableValue.getValue();;
final String operatorType = (String) arg0;
if (operator != null) {
return "<A>" + operatorLabelProvider.getText(operator) + "</A>";
}
return "<A>" + operatorLabelProvider.getText(operatorType) + "</A>";
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment