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 ...@@ -145,7 +145,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
actionExpression.validate(); actionExpression.validate();
} }
} }
public void refreshDatabinding() { public void refreshDatabinding() {
final Operation action = getOperation(); final Operation action = getOperation();
if (action != null) { if (action != null) {
...@@ -169,15 +169,18 @@ public class OperationViewer extends Composite implements IBonitaVariableContext ...@@ -169,15 +169,18 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
private void bindOperator() { private void bindOperator() {
final UpdateValueStrategy uvsOperator = new UpdateValueStrategy(); 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(), final IObservableValue operatorObservedValue = EMFEditObservables.observeValue(getEditingDomain(), getOperation().getOperator(),
ExpressionPackage.Literals.OPERATOR__TYPE); ExpressionPackage.Literals.OPERATOR__TYPE);
operatorObservedValue.addChangeListener(new RevalidateActionExpressionChangeListener()); 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()), context.bindValue(SWTObservables.observeTooltipText(getOperatorLink()),
EMFEditObservables.observeValue(getEditingDomain(), getOperation().getOperator(), ExpressionPackage.Literals.OPERATOR__EXPRESSION)); operatorExpressionObserveValue);
} }
private void bindStorageViewer(final Operation action) { private void bindStorageViewer(final Operation action) {
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
*/ */
package org.bonitasoft.studio.expression.editor.operation; 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.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. * 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; ...@@ -24,16 +26,23 @@ import org.eclipse.core.databinding.conversion.Converter;
public class OperatorTypeToStringLinkConverter extends Converter { public class OperatorTypeToStringLinkConverter extends Converter {
private final OperatorLabelProvider operatorLabelProvider; private final OperatorLabelProvider operatorLabelProvider;
private final IObservableValue operatorObservableValue;
public OperatorTypeToStringLinkConverter() { public OperatorTypeToStringLinkConverter(final IObservableValue operatorObservableValue) {
super(String.class, String.class); super(String.class, String.class);
operatorLabelProvider = new OperatorLabelProvider(); operatorLabelProvider = new OperatorLabelProvider();
this.operatorObservableValue = operatorObservableValue;
} }
@Override @Override
public String convert(final Object arg0) { public String convert(final Object arg0) {
final Operator operator = (Operator) operatorObservableValue.getValue();;
final String operatorType = (String) arg0; final String operatorType = (String) arg0;
if (operator != null) {
return "<A>" + operatorLabelProvider.getText(operator) + "</A>";
}
return "<A>" + operatorLabelProvider.getText(operatorType) + "</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