Commit 26459cf1 authored by Adrien's avatar Adrien Committed by Romain Bioteau

fix(expression editor) return type set at null (#690)

* in Parameter editor, DataExpressionEditor and contractInputEditor,
when the viewer didn't have any element selected, return type was set at
null because of some databinding. It had consequences on other editors,
especially if return type is fixed. 
-> when viewer doesn't have any element selected, we don't do anything
now, so returnTypeObservable is preserved

closes [BS-17093](https://bonitasoft.atlassian.net/browse/BS-17093)
parent 09638a5d
......@@ -44,7 +44,8 @@ Require-Bundle: org.eclipse.ui,
com.google.guava;bundle-version="11.0.1",
org.bonitasoft.studio.common.diagram,
org.bonitasoft.studio.diagram.custom;bundle-version="7.1.0",
org.eclipse.e4.core.di
org.eclipse.e4.core.di,
org.bonitasoft.studio.ui;bundle-version="7.6.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.data.i18n;
......
......@@ -14,6 +14,8 @@
*/
package org.bonitasoft.studio.data.provider;
import static org.bonitasoft.studio.ui.databinding.UpdateStrategyFactory.neverUpdateValueStrategy;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
......@@ -53,7 +55,7 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFObservables;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.layout.GridDataFactory;
......@@ -96,7 +98,7 @@ public class DataExpressionEditor extends SelectionAwareExpressionEditor
private Text typeText;
private IObservableValue returnTypeObservable = null;
private IObservableValue<String> returnTypeObservable = null;
private Button addExpressionButton;
......@@ -276,18 +278,6 @@ public class DataExpressionEditor extends SelectionAwareExpressionEditor
};
selectionToContent.setConverter(contentConverter);
final UpdateValueStrategy selectionToReturnType = new UpdateValueStrategy();
final IConverter returnTypeConverter = new Converter(Data.class, String.class) {
@Override
public Object convert(final Object data) {
return data != null ? org.bonitasoft.studio.common.DataUtil
.getTechnicalTypeFor((Data) data) : null;
}
};
selectionToReturnType.setConverter(returnTypeConverter);
final UpdateValueStrategy selectionToReferencedData = new UpdateValueStrategy();
final IConverter referenceConverter = new Converter(Data.class, List.class) {
......@@ -326,25 +316,22 @@ public class DataExpressionEditor extends SelectionAwareExpressionEditor
};
referencedDataToSelection.setConverter(referencetoDataConverter);
dataBindingContext.bindValue(ViewersObservables
.observeSingleSelection(viewer), nameObservable,
selectionToName, new UpdateValueStrategy(
UpdateValueStrategy.POLICY_NEVER));
dataBindingContext.bindValue(ViewersObservables
.observeSingleSelection(viewer), contentObservable,
selectionToContent, new UpdateValueStrategy(
UpdateValueStrategy.POLICY_NEVER));
dataBindingContext.bindValue(
ViewersObservables.observeSingleSelection(viewer),
returnTypeObservable, selectionToReturnType,
new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER));
dataBindingContext.bindValue(
ViewersObservables.observeSingleSelection(viewer),
IObservableValue<Data> observeSingleSelection = ViewersObservables.observeSingleSelection(viewer);
dataBindingContext.bindValue(observeSingleSelection, nameObservable,
selectionToName, neverUpdateValueStrategy().create());
dataBindingContext.bindValue(observeSingleSelection, contentObservable,
selectionToContent, neverUpdateValueStrategy().create());
observeSingleSelection.addValueChangeListener(e -> {
if (e.getObservableValue().getValue() != null) {
returnTypeObservable.setValue(
org.bonitasoft.studio.common.DataUtil.getTechnicalTypeFor(e.getObservableValue().getValue()));
}
});
dataBindingContext.bindValue(observeSingleSelection,
referenceObservable, selectionToReferencedData,
referencedDataToSelection);
dataBindingContext.bindValue(
SWTObservables.observeText(typeText, SWT.Modify),
returnTypeObservable);
dataBindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(typeText), returnTypeObservable);
if (context instanceof DateFormField) {
handleDateFormFieldBinding();
......
......@@ -30,7 +30,8 @@ Require-Bundle: org.eclipse.ui,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0",
org.eclipse.jdt.groovy.core;bundle-version="2.9.1",
org.junit;bundle-version="4.11.0";resolution:=optional,
assertj-core;bundle-version="1.5.0";resolution:=optional
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.ui;bundle-version="7.6.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.parameters.action,org.bonitasoft
......
This diff is collapsed.
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