Commit 7e407d5e authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Merge remote-tracking branch 'origin/master' into MasterBugFixing

Conflicts:
	bundles/plugins/org.bonitasoft.studio.condition.ui/src/org/bonitasoft/studio/condition/ui/expression/ComparisonExpressionEditor.java
	bundles/plugins/org.bonitasoft.studio.diagram.form.properties/src/org/bonitasoft/studio/properties/form/sections/actions/contributions/FileGridPropertySectionContribution.java
	bundles/plugins/org.bonitasoft.studio.exporter/src-test/java/org/bonitasoft/studio/exporter/form/FormsExporterTest.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/ActivityBuilder.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/BusinessObjectDataBuilder.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/DataBuilder.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/JavaObjectDataBuilder.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/TaskBuilder.java
	bundles/plugins/org.bonitasoft.studio.tests-utils/src/org/bonitasoft/studio/model/process/builders/XMLDataBuilder.java
	tests/org.bonitasoft.studio.util.tests/src/org/bonitasoft/studio/util/test/conditions/ShellIsActiveWithThreadSTacksOnFailure.java
parents 8c19d197 ee8ec659
......@@ -237,6 +237,7 @@
eType="ecore:EClass expression.ecore#//Expression" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="intialResourceList" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="downloadType" eType="#//FileWidgetDownloadType"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Column">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="width" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
......@@ -387,4 +388,9 @@
<eClassifiers xsi:type="ecore:EClass" name="GroupIterator" eSuperTypes="process.ecore#//Element">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="className" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="FileWidgetDownloadType">
<eLiterals name="Both" literal="Both"/>
<eLiterals name="URL" value="1" literal="URL"/>
<eLiterals name="Browse" value="2" literal="Browse"/>
</eClassifiers>
</ecore:EPackage>
......@@ -153,6 +153,11 @@
<genEnumLiterals ecoreEnumLiteral="form.ecore#//FileWidgetInputType/URL"/>
<genEnumLiterals ecoreEnumLiteral="form.ecore#//FileWidgetInputType/Resource"/>
</genEnums>
<genEnums typeSafeEnumCompatible="false" ecoreEnum="form.ecore#//FileWidgetDownloadType">
<genEnumLiterals ecoreEnumLiteral="form.ecore#//FileWidgetDownloadType/Both"/>
<genEnumLiterals ecoreEnumLiteral="form.ecore#//FileWidgetDownloadType/URL"/>
<genEnumLiterals ecoreEnumLiteral="form.ecore#//FileWidgetDownloadType/Browse"/>
</genEnums>
<genClasses ecoreClass="form.ecore#//Form">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference form.ecore#//Form/widgets"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute form.ecore#//Form/nColumn"/>
......@@ -276,6 +281,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute form.ecore#//FileWidget/updateDocument"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference form.ecore#//FileWidget/outputDocumentListExpression"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute form.ecore#//FileWidget/intialResourceList"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute form.ecore#//FileWidget/downloadType"/>
</genClasses>
<genClasses ecoreClass="form.ecore#//Column">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute form.ecore#//Column/width"/>
......
......@@ -8711,5 +8711,40 @@
featureName="defaultValueLiteral" dataValue="NONE" oldDataValue="0"/>
</changes>
</releases>
<releases date="2014-10-28T10:45:10.092+0100" label="6.4.0-004">
<changes xsi:type="history:Create" target="form.ecore#/" referenceName="eClassifiers"
element="form.ecore#//FileWidgetDownloadType"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType"
featureName="name" dataValue="FileWidgetDownloadType"/>
<changes xsi:type="history:Create" target="form.ecore#//FileWidgetDownloadType"
referenceName="eLiterals" element="form.ecore#//FileWidgetDownloadType/Both"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/Both"
featureName="literal" dataValue="Both"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/Both"
featureName="name" dataValue="Both"/>
<changes xsi:type="history:Create" target="form.ecore#//FileWidgetDownloadType"
referenceName="eLiterals" element="form.ecore#//FileWidgetDownloadType/URL"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/URL"
featureName="literal" dataValue="URL"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/URL"
featureName="name" dataValue="URL"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/URL"
featureName="value" dataValue="1" oldDataValue="0"/>
<changes xsi:type="history:Create" target="form.ecore#//FileWidgetDownloadType"
referenceName="eLiterals" element="form.ecore#//FileWidgetDownloadType/Browse"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/Browse"
featureName="literal" dataValue="Browse"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/Browse"
featureName="name" dataValue="Browse"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidgetDownloadType/Browse"
featureName="value" dataValue="2" oldDataValue="0"/>
<changes xsi:type="history:Create" target="form.ecore#//FileWidget" referenceName="eStructuralFeatures"
element="form.ecore#//FileWidget/downloadType"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidget/downloadType"
featureName="name" dataValue="downloadType"/>
<changes xsi:type="history:Set" element="form.ecore#//FileWidget/downloadType"
featureName="eType" referenceValue="form.ecore#//FileWidgetDownloadType"/>
<changes xsi:type="history:MigrationChange" migration="org.bonitasoft.studio.migration.custom.migration.form.FileWidgetResourceMigration"/>
</releases>
<releases/>
</history:History>
......@@ -17,6 +17,7 @@
package org.bonitasoft.studio.actors.ui.section;
import org.bonitasoft.studio.actors.i18n.Messages;
import org.bonitasoft.studio.common.emf.converter.BooleanInverserConverter;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.jface.BonitaStudioFontRegistry;
import org.bonitasoft.studio.model.process.Actor;
......@@ -64,30 +65,17 @@ public class AssignableActorsPropertySection extends AbstractActorsPropertySecti
useLaneActorButton.setEnabled(current instanceof Lane) ;
final IObservableValue value = EMFEditObservables.observeValue(getEditingDomain(), assignable, ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE) ;
emfDatabindingContext.bindValue(SWTObservables.observeSelection(taskActorButton), value) ;
emfDatabindingContext.bindValue(SWTObservables.observeSelection(useLaneActorButton), value,new UpdateValueStrategy(),new UpdateValueStrategy().setConverter(new Converter(Boolean.class,Boolean.class){
@Override
public Object convert(Object from) {
return !(Boolean) from;
}
})) ;
final UpdateValueStrategy updateValueStrategy = new UpdateValueStrategy().setConverter(new Converter(Boolean.class,Boolean.class){
@Override
public Object convert(Object from) {
return !(Boolean) from;
}
});
emfDatabindingContext.bindValue(SWTObservables.observeEnabled(actorComboViewer.getControl()), SWTObservables.observeSelection(useLaneActorButton),new UpdateValueStrategy(),updateValueStrategy);
emfDatabindingContext.bindValue(SWTObservables.observeSelection(useLaneActorButton), value, new UpdateValueStrategy(),
new UpdateValueStrategy().setConverter(new BooleanInverserConverter()));
final UpdateValueStrategy updateValueStrategy = new UpdateValueStrategy().setConverter(new BooleanInverserConverter());
emfDatabindingContext.bindValue(SWTObservables.observeEnabled(actorComboViewer.getControl()), SWTObservables.observeSelection(useLaneActorButton),new UpdateValueStrategy(),updateValueStrategy);
databindactorDefinedInLaneLabel(assignable);
}
}
private void databindactorDefinedInLaneLabel(Assignable assignable) {
private void databindactorDefinedInLaneLabel(final Assignable assignable) {
final Lane parentLane = ModelHelper.getParentLane(assignable);
if(parentLane != null){
......@@ -102,7 +90,7 @@ public class AssignableActorsPropertySection extends AbstractActorsPropertySecti
new UpdateValueStrategy().setConverter(new Converter(Object.class, String.class) {
@Override
public String convert(Object fromObject) {
public String convert(final Object fromObject) {
if(fromObject != null){
return "("+((Actor)fromObject).getName()+")";
} else {
......@@ -115,7 +103,7 @@ public class AssignableActorsPropertySection extends AbstractActorsPropertySecti
}
@Override
protected void createRadioComposite(TabbedPropertySheetWidgetFactory widgetFactory,Composite mainComposite) {
protected void createRadioComposite(final TabbedPropertySheetWidgetFactory widgetFactory,final Composite mainComposite) {
radioComposite = widgetFactory.createComposite(mainComposite, SWT.NONE) ;
radioComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).span(3, 1).create()) ;
radioComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).create()) ;
......
......@@ -64,6 +64,7 @@ Export-Package: org.bonitasoft.studio.common,
org.bonitasoft.studio.common.dialog,
org.bonitasoft.studio.common.editingdomain,
org.bonitasoft.studio.common.editor,
org.bonitasoft.studio.common.emf.converter,
org.bonitasoft.studio.common.emf.tools,
org.bonitasoft.studio.common.exporter,
org.bonitasoft.studio.common.extension,
......
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.emf.converter;
import org.assertj.core.api.Assertions;
import org.junit.Test;
public class BooleanInverserConverterTest {
@Test
public void testGetToType() {
Assertions.assertThat(new BooleanInverserConverter().getToType()).isEqualTo(Boolean.class);
}
@Test
public void testGetFromType() {
Assertions.assertThat(new BooleanInverserConverter().getFromType()).isEqualTo(Boolean.class);
}
@Test
public void testConvert() {
Assertions.assertThat(new BooleanInverserConverter().convert(true)).isEqualTo(Boolean.FALSE);
Assertions.assertThat(new BooleanInverserConverter().convert(false)).isEqualTo(Boolean.TRUE);
}
}
......@@ -20,7 +20,7 @@ package org.bonitasoft.studio.common;
public class ModelVersion {
public static final String VERSION_6_0_0_ALPHA = "6.0.0-Alpha";
public static final String CURRENT_VERSION = "6.4.0-003";
public static final String CURRENT_VERSION = "6.4.0-004";
public static boolean sameVersion(final String version) {
return CURRENT_VERSION.equals(version);
......
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.common.emf.converter;
import org.eclipse.core.databinding.conversion.Converter;
public class BooleanInverserConverter extends Converter {
public BooleanInverserConverter() {
super(Boolean.class, Boolean.class);
}
@Override
public Object convert(final Object arg0) {
return !((Boolean) arg0);
}
}
......@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bonitasoft.studio.common.emf.converter.BooleanInverserConverter;
import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.jface.BonitaStudioFontRegistry;
......@@ -44,7 +45,6 @@ import org.bonitasoft.studio.expression.editor.viewer.SelectDependencyDialog;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
......@@ -118,11 +118,14 @@ public class ComparisonExpressionEditor extends SelectionAwareExpressionEditor i
private XtextResource resource;
private boolean isPageFlowContext = false;
private final XtextComparisonExpressionLoader xtextComparisonExpressionLoader;
public ComparisonExpressionEditor(final EObject context) {
this.context = context;
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
......@@ -299,7 +302,6 @@ public class ComparisonExpressionEditor extends SelectionAwareExpressionEditor i
return dep;
}
protected void createReturnTypeComposite(final Composite parent) {
final Composite returnTypeComposite = new Composite(parent, SWT.NONE);
returnTypeComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
......@@ -347,13 +349,8 @@ public class ComparisonExpressionEditor extends SelectionAwareExpressionEditor i
dataBindingContext.bindValue(ViewersObservables.observeInput(dependenciesViewer), dependenciesModelObservable);
final UpdateValueStrategy opposite = new UpdateValueStrategy();
opposite.setConverter(new Converter(Boolean.class, Boolean.class) {
opposite.setConverter(new BooleanInverserConverter());
@Override
public Object convert(final Object fromObject) {
return !((Boolean) fromObject);
}
});
dataBindingContext.bindValue(SWTObservables.observeSelection(automaticResolutionButton), autoDepsModelObservable);
dataBindingContext.bindValue(SWTObservables.observeSelection(automaticResolutionButton), SWTObservables.observeEnabled(addDependencyButton), opposite,
......
......@@ -40,7 +40,8 @@ Require-Bundle: org.eclipse.ui,
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.tests-utils;bundle-version="6.3.0";resolution:=optional,
org.bonitasoft.studio.refactoring;bundle-version="6.3.0",
org.bonitasoft.studio.document
org.bonitasoft.studio.document,
org.mockito;bundle-version="1.9.5"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Localization: plugin
......
......@@ -176,3 +176,10 @@ widgetNameAllreadyExistError={0} already exists. Please provide another widget n
widgetEditMessage=When you click OK, if the current name is used in Groovy scripts, \nthe refactor window is displayed and you can validate the changes.
editWidgetNameTitle=Choose a new name
removingWidgetReferences=Removing widget references...
documentPickerLabel=File widget type
both=Both, with radio buttons for user to choose
BrowseRadio=Button, to browse for file
urlRadio=Text field, for URL
resourceToolTip=Is a file from Bonita BPM Studio repository and embedded in the Process Archive (.bar)
documentToolTip=Content is either a file or a URL
fileWidgetTypeToolTip=Not available if document is download only. Cannot be a URL if initial value is a resource.
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.properties.form.sections.actions.contributions;
import org.assertj.core.api.Assertions;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.expression.editor.filter.AvailableExpressionTypeFilter;
import org.bonitasoft.studio.form.properties.i18n.Messages;
import org.bonitasoft.studio.model.form.FormFactory;
import org.bonitasoft.studio.model.form.Group;
import org.bonitasoft.studio.model.form.Widget;
import org.junit.Test;
public class DefaultValueContributionTest {
@Test
public void testGetExpressionViewerFilterContainsGroupIterator() {
final DefaultValueContribution defaultValueContribution = new DefaultValueContribution();
final Group group = FormFactory.eINSTANCE.createGroup();
final Widget widget = FormFactory.eINSTANCE.createListFormField();
group.getWidgets().add(widget);
defaultValueContribution.setEObject(widget);
final AvailableExpressionTypeFilter filter = defaultValueContribution.getExpressionViewerFilter();
Assertions.assertThat(filter.getContentTypes()).contains(ExpressionConstants.GROUP_ITERATOR_TYPE);
}
@Test
public void testGetExpressionViewerFilterNotContainGroupIterator() {
final DefaultValueContribution defaultValueContribution = new DefaultValueContribution();
final Widget widget = FormFactory.eINSTANCE.createListFormField();
defaultValueContribution.setEObject(widget);
final AvailableExpressionTypeFilter filter = defaultValueContribution.getExpressionViewerFilter();
Assertions.assertThat(filter.getContentTypes()).doesNotContain(ExpressionConstants.GROUP_ITERATOR_TYPE);
}
@Test
public void testInitialInformationMessage() {
final DefaultValueContribution defaultValueContribution = new DefaultValueContribution();
final Widget[] widgets = new Widget[] {
FormFactory.eINSTANCE.createRadioFormField(),
FormFactory.eINSTANCE.createComboFormField(),
FormFactory.eINSTANCE.createSelectFormField()
};
for (final Widget widget : widgets) {
defaultValueContribution.setEObject(widget);
Assertions.assertThat(defaultValueContribution.getInitialInformationMessage()).isEqualTo(Messages.data_tooltip_text);
}
final Widget[] widgetForList = new Widget[] {
FormFactory.eINSTANCE.createCheckBoxMultipleFormField(),
FormFactory.eINSTANCE.createListFormField(),
FormFactory.eINSTANCE.createSuggestBox(),
FormFactory.eINSTANCE.createTable()
};
for (final Widget widget : widgetForList) {
defaultValueContribution.setEObject(widget);
Assertions.assertThat(defaultValueContribution.getInitialInformationMessage()).isEqualTo(Messages.data_tooltip_list);
}
}
}
/**
* Copyright (C) 2014 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.properties.form.sections.actions.contributions;
import org.assertj.core.api.Assertions;
import org.bonitasoft.studio.model.form.FileWidget;
import org.bonitasoft.studio.model.form.FileWidgetInputType;
import org.bonitasoft.studio.model.form.FormFactory;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.junit.Test;
public class FileWidgetDocumentPickerContributionTest {
@Test
public void testCreateEnabledUrlWhenInputIsResourceStrategyTargetToModel() {
final FileWidgetDocumentPickerContribution fileWidgetDocumentPickerContribution = new FileWidgetDocumentPickerContribution();
final FileWidget fileWidget = FormFactory.eINSTANCE.createFileWidget();
fileWidgetDocumentPickerContribution.setEObject(fileWidget);
final UpdateValueStrategy strategy = fileWidgetDocumentPickerContribution.createEnabledUrlWhenInputIsResourceStrategyTargetToModel();
Assertions.assertThat((Boolean) strategy.convert(FileWidgetInputType.RESOURCE)).isFalse();
Assertions.assertThat((Boolean) strategy.convert(FileWidgetInputType.DOCUMENT)).isTrue();
fileWidget.setDownloadOnly(true);
Assertions.assertThat((Boolean) strategy.convert(FileWidgetInputType.DOCUMENT)).isFalse();
}
@Test
public void testCreateEnabledStrategyForDownloadOnlyURLCase() {
final FileWidgetDocumentPickerContribution fileWidgetDocumentPickerContribution = new FileWidgetDocumentPickerContribution();
final FileWidget fileWidget = FormFactory.eINSTANCE.createFileWidget();
fileWidgetDocumentPickerContribution.setEObject(fileWidget);
final UpdateValueStrategy strategy = fileWidgetDocumentPickerContribution.createEnabledStrategyForDownloadOnlyURLCase();
fileWidget.setInputType(FileWidgetInputType.RESOURCE);
Assertions.assertThat((Boolean) strategy.convert(true)).isFalse();
Assertions.assertThat((Boolean) strategy.convert(false)).isFalse();
fileWidget.setInputType(FileWidgetInputType.DOCUMENT);
Assertions.assertThat((Boolean) strategy.convert(true)).isFalse();
Assertions.assertThat((Boolean) strategy.convert(false)).isTrue();
}
@Test
public void testCreateEnabledStrategy() {
final FileWidgetDocumentPickerContribution fileWidgetDocumentPickerContribution = new FileWidgetDocumentPickerContribution();
final UpdateValueStrategy strategy = fileWidgetDocumentPickerContribution.createEnabledStrategy();
Assertions.assertThat((Boolean) strategy.convert(true)).isFalse();
Assertions.assertThat((Boolean) strategy.convert(false)).isTrue();
}
}
......@@ -19,6 +19,8 @@ package org.bonitasoft.studio.properties.form.sections.actions.contributions;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.expression.assertions.ExpressionAssert.assertThat;
import java.util.List;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.model.expression.Expression;
......@@ -30,6 +32,11 @@ import org.bonitasoft.studio.model.form.TextFormField;
import org.bonitasoft.studio.model.form.Widget;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.workspace.WorkspaceEditingDomainFactory;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -49,7 +56,7 @@ public class WidgetModifierContributionTest {
*/
@Before
public void setUp() throws Exception {
Form form = FormFactory.eINSTANCE.createForm();
final Form form = FormFactory.eINSTANCE.createForm();
textFormField = FormFactory.eINSTANCE.createTextFormField();
textFormField.setName("name");
textFormField.setReturnTypeModifier(String.class.getName());
......@@ -67,26 +74,55 @@ public class WidgetModifierContributionTest {
@Test
public void shouldUpdateWidgetReferences_Update_Widget_References_WithNewModifierType_ForFormFieldExpressionType() throws Exception {
Operation operation= ExpressionFactory.eINSTANCE.createOperation();
Expression actionExp = ExpressionFactory.eINSTANCE.createExpression();
final Operation operation= ExpressionFactory.eINSTANCE.createOperation();
final Expression actionExp = ExpressionFactory.eINSTANCE.createExpression();
actionExp.setReturnType(String.class.getName());
actionExp.setType(ExpressionConstants.FORM_FIELD_TYPE);
actionExp.setContent("field_name");
operation.setRightOperand(actionExp);
textFormField.setAction(operation);
widgetModifierContribution.updateWidgetReferences(textFormField, Integer.class.getName());
widgetModifierContribution.setEObject(textFormField);
widgetModifierContribution.selectionChanged(new SelectionChangedEvent(new ISelectionProvider() {
public void setSelection(final ISelection arg0) {
}
public void removeSelectionChangedListener(final ISelectionChangedListener arg0) {
}
public ISelection getSelection() {
return null;
}
public void addSelectionChangedListener(final ISelectionChangedListener arg0) {
}
}, new StructuredSelection(Integer.class.getName())));
assertThat(actionExp).hasReturnType(Integer.class.getName());
}
@Test
public void shouldUpdateWidgetReferences_Update_Widget_References_WithNewModifierType_ForDuplicatedFormFieldExpressionType() throws Exception {
final Operation operation = ExpressionFactory.eINSTANCE.createOperation();
final Expression actionExp = ExpressionFactory.eINSTANCE.createExpression();
actionExp.setReturnType(String.class.getName());
actionExp.setType(ExpressionConstants.FORM_FIELD_TYPE);
actionExp.setContent("field_name");
operation.setRightOperand(actionExp);
textFormField.setAction(operation);
textFormField.setDuplicate(true);
widgetModifierContribution.updateWidgetReferences(textFormField, Integer.class.getName());