Commit e99b8217 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

fix(data) classcast in DataWizardPage

Closes STUDIO-3609
parent 5399fa85
......@@ -79,6 +79,8 @@ import org.bonitasoft.studio.model.process.XMLType;
import org.bonitasoft.studio.model.process.util.ProcessSwitch;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.bonitasoft.studio.ui.converter.ConverterBuilder;
import org.bonitasoft.studio.ui.databinding.UpdateStrategyFactory;
import org.bonitasoft.studio.xml.repository.XSDFileStore;
import org.bonitasoft.studio.xml.repository.XSDRepositoryStore;
import org.eclipse.core.databinding.UpdateValueStrategy;
......@@ -229,7 +231,7 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
private boolean isOverviewContext = false;
final private Set<String> availableDataNames = new HashSet<>();
private final Set<String> availableDataNames = new HashSet<>();
private final ViewerFilter typeViewerFilter = new ViewerFilter() {
......@@ -252,6 +254,7 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
@Override
public void handleValueChange(final ValueChangeEvent event) {
if (updateDataType) {
final DataType newType = (DataType) event.diff.getNewValue();
if (newType instanceof JavaType && !(data instanceof JavaObjectData)) {
final JavaObjectData javaData = ProcessFactory.eINSTANCE.createJavaObjectData();
......@@ -285,6 +288,8 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
parent.layout(true, true);
}
updateDatabinding();
updateDataType = false;
}
}
};
......@@ -300,6 +305,8 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
private CLabel transientDataWarning;
private boolean updateDataType;
public DataWizardPage(final Data data, final EObject container, final boolean allowXML, final boolean allowEnum,
final boolean showIsTransient,
final boolean showAutoGenerateform, final Set<EStructuralFeature> featureToCheckForUniqueID,
......@@ -659,7 +666,19 @@ public class DataWizardPage extends WizardPage implements IBonitaVariableContext
modelObservable.addValueChangeListener(typeChangeListener);
observeSingleSelectionTypeCombo = ViewersObservables.observeSingleSelection(typeCombo);
emfDatabindingContext.bindValue(observeSingleSelectionTypeCombo, modelObservable, null, null);
emfDatabindingContext.bindValue(observeSingleSelectionTypeCombo,
modelObservable,
UpdateStrategyFactory.updateValueStrategy()
.withConverter(ConverterBuilder.<DataType, DataType> newConverter()
.fromType(DataType.class)
.toType(DataType.class)
.withConvertFunction(dataType -> {
updateDataType = true;
return dataType;
})
.create())
.create(),
null);
}
protected void bindDefaultValueViewer() {
......
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