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

BS-8971

New expression
parent 8da20678
......@@ -318,7 +318,7 @@
<eStructuralFeatures xsi:type="ecore:EReference" name="loopMaximum" eType="ecore:EClass expression.ecore#//Expression"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="useCardinality" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
defaultValueLiteral="true"/>
defaultValueLiteral="false"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="cardinalityExpression"
eType="ecore:EClass expression.ecore#//Expression" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="collectionDataToMultiInstantiate"
......@@ -330,6 +330,8 @@
eType="#//Data"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="completionCondition" eType="ecore:EClass expression.ecore#//Expression"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="storeOutput" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
defaultValueLiteral="false"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="NonInterruptingBoundaryTimerEvent" eSuperTypes="#//BoundaryTimerEvent"/>
<eClassifiers xsi:type="ecore:EClass" name="OperationContainer">
......
......@@ -659,6 +659,7 @@
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference process.ecore#//MultiInstantiable/outputData"/>
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference process.ecore#//MultiInstantiable/listDataContainingOutputResults"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference process.ecore#//MultiInstantiable/completionCondition"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute process.ecore#//MultiInstantiable/storeOutput"/>
</genClasses>
<genClasses ecoreClass="process.ecore#//NonInterruptingBoundaryTimerEvent"/>
<genClasses ecoreClass="process.ecore#//OperationContainer">
......
......@@ -10349,7 +10349,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10383,7 +10383,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10415,7 +10415,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10437,7 +10437,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10457,7 +10457,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10479,7 +10479,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......@@ -10513,7 +10513,7 @@
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.generateConstantExpression(&quot;&quot;,Boolean.class.getName(),true);"/>
<expressions
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"/>
<expressions
body="return org.bonitasoft.studio.common.NamingUtils.getInstance(self).generateName(self, self);"/>
<expressions
......
......@@ -340,7 +340,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -646,7 +646,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -1129,7 +1129,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -1279,7 +1279,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -1394,7 +1394,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -1544,7 +1544,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......@@ -1843,7 +1843,7 @@
xsi:type="ecore:EReference"
href="process.ecore#//MultiInstantiable/iteratorExpression"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;&quot;,&quot;&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
body="return org.bonitasoft.studio.common.emf.tools.ExpressionHelper.createExpression(&quot;multiInstanceIterator&quot;,&quot;multiInstanceIterator&quot;,org.bonitasoft.studio.common.ExpressionConstants.MULTIINSTANCE_ITERATOR_TYPE,Object.class.getName(),false);"
language="java"/>
</initializers>
</domainInitializer>
......
......@@ -8523,6 +8523,37 @@
</parameters>
</operation>
</changes>
<changes xsi:type="history:OperationChange">
<changes xsi:type="history:Create" target="process.ecore#//MultiInstantiable"
referenceName="eStructuralFeatures" element="process.ecore#//MultiInstantiable/storeOutput">
<changes xsi:type="history:Set" element="process.ecore#//MultiInstantiable/storeOutput"
featureName="name" dataValue="storeOutput"/>
<changes xsi:type="history:Set" element="process.ecore#//MultiInstantiable/storeOutput"
featureName="defaultValueLiteral" dataValue="false"/>
<changes xsi:type="history:Set" element="process.ecore#//MultiInstantiable/storeOutput"
featureName="eType" referenceValue="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</changes>
<operation name="newAttribute">
<parameters name="eClass">
<referenceValue element="process.ecore#//MultiInstantiable"/>
</parameters>
<parameters name="name">
<dataValue>storeOutput</dataValue>
</parameters>
<parameters name="type">
<referenceValue element="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</parameters>
<parameters name="lowerBound">
<dataValue>0</dataValue>
</parameters>
<parameters name="upperBound">
<dataValue>1</dataValue>
</parameters>
<parameters name="defaultValue">
<dataValue>false</dataValue>
</parameters>
</operation>
</changes>
</changes>
<changes xsi:type="history:CompositeChange">
<changes xsi:type="history:Set" element="process.ecore#//PageFlow/entryPageFlowType"
......@@ -8537,6 +8568,8 @@
featureName="defaultValueLiteral" dataValue="CONSTANT" oldDataValue="0"/>
<changes xsi:type="history:Set" element="simulation.ecore#//SimulationNumberRange/repartitionType"
featureName="defaultValueLiteral" dataValue="CONSTANT" oldDataValue="0"/>
<changes xsi:type="history:Set" element="process.ecore#//MultiInstantiable/useCardinality"
featureName="defaultValueLiteral" dataValue="false" oldDataValue="true"/>
</changes>
</releases>
<releases/>
......
......@@ -83,4 +83,5 @@ public class CustomEMFEditObservables extends EMFEditObservables {
}
};
}
}
/**
* 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.jface;
/**
* @author Romain Bioteau
*
*/
public class RecursiveControlEnablement {
}
......@@ -19,8 +19,11 @@ package org.bonitasoft.studio.common.properties;
import java.util.ArrayList;
import java.util.List;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.model.process.Pool;
import org.eclipse.core.databinding.beans.PojoObservables;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.viewers.ISelection;
......@@ -42,14 +45,23 @@ public abstract class EObjectSelectionProviderSection extends AbstractBonitaDesc
private final List<ISelectionChangedListener> listeners = new ArrayList<ISelectionChangedListener>();
private IObservableValue selectionObservable;
private IObservableValue editingDomainObservable;
private IObservableValue containerObservable;
private Pool poolContainer;
protected IObservableValue getEObjectMasterObservable() {
protected IObservableValue getEObjectObservable() {
if (selectionObservable == null) {
selectionObservable = ViewersObservables.observeSingleSelection(this);
}
return selectionObservable;
}
protected IObservableValue getPoolObservable() {
if (containerObservable == null) {
containerObservable = PojoObservables.observeValue(this, "poolContainer");
}
return containerObservable;
}
protected IObservableValue getEditingDomainObservable() {
if (editingDomainObservable == null) {
editingDomainObservable = PojoObservables.observeValue(this, "EditingDomain");
......@@ -92,7 +104,17 @@ public abstract class EObjectSelectionProviderSection extends AbstractBonitaDesc
@Override
public void setInput(final IWorkbenchPart part, final ISelection selection) {
super.setInput(part, selection);
setSelection(new StructuredSelection(((IGraphicalEditPart) ((IStructuredSelection) selection).getFirstElement()).resolveSemanticElement()));
final EObject semanticElement = ((IGraphicalEditPart) ((IStructuredSelection) selection).getFirstElement()).resolveSemanticElement();
setSelection(new StructuredSelection(semanticElement));
setPoolContainer((Pool) ModelHelper.getParentProcess(semanticElement));
}
public Pool getPoolContainer() {
return poolContainer;
}
public void setPoolContainer(final Pool poolContainer) {
this.poolContainer = poolContainer;
}
}
......@@ -139,8 +139,7 @@ public class PageComponentSwitchBuilder {
private ExpressionViewer buildExpressionViewer(final Composite composite, final Text object, final IExpressionNatureProvider expressionProvider,
final Input input, final ConnectorParameter parameter, final LabelProvider autoCompletionLabelProvider) {
final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER,
ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION);
final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER);
viewer.setIsPageFlowContext(isPageFlowContext);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
viewer.setContext(container);
......@@ -606,8 +605,7 @@ public class PageComponentSwitchBuilder {
if (parameter != null) {
createFieldLabel(composite, SWT.CENTER, object.getId(), input.isMandatory());
final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER | SWT.PASSWORD,
ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION);
final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER | SWT.PASSWORD);
viewer.setIsPageFlowContext(isPageFlowContext);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
viewer.setContext(container);
......
/**
* Copyright (C) 2012 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
......@@ -32,13 +32,23 @@ import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionFactory;
import org.bonitasoft.studio.model.form.Form;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.BusinessObjectType;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.DataType;
import org.bonitasoft.studio.model.process.FlowElement;
import org.bonitasoft.studio.model.process.JavaObjectData;
import org.bonitasoft.studio.model.process.JavaType;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.MultiInstantiable;
import org.bonitasoft.studio.model.process.PageFlow;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.StringType;
import org.bonitasoft.studio.model.process.ViewPageFlow;
import org.bonitasoft.studio.model.process.util.ProcessSwitch;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.swt.graphics.Image;
......@@ -49,106 +59,186 @@ import org.eclipse.swt.graphics.Image;
*/
public class DataExpressionProvider implements IExpressionProvider {
private final ComposedAdapterFactory adapterFactory;
private final AdapterFactoryLabelProvider adapterLabelProvider;
public DataExpressionProvider(){
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterLabelProvider = new AdapterFactoryLabelProvider(adapterFactory) ;
}
@Override
public Set<Expression> getExpressions(EObject context) {
Set<Expression> result = new HashSet<Expression>() ;
Form form = null ;
PageFlow pf= null;
if(context instanceof Widget){
form = ModelHelper.getForm((Widget) context) ;
}else if(context instanceof Form){
form = (Form) context ;
}else if(context instanceof PageFlow){
pf = (PageFlow) context ;
}
if(form != null){
final EObject formContainer = form.eContainer();
if(formContainer != null){
if(form.eContainmentFeature() != null && (formContainer instanceof PageFlow || formContainer instanceof ViewPageFlow) ){
for(Data d : getDataInForm(form, formContainer)){
result.add(createExpression(d)) ;
}
}
}
} else if(pf!= null){
for(Data d : ModelHelper.getAccessibleData(pf)){
result.add(createExpression(d)) ;
}
} else if(context instanceof EObject){
for(Data d : ModelHelper.getAccessibleData(context,true) ){
result.add(createExpression(d)) ;
}
}
return result;
}
protected List<Data> getDataInForm(Form form, final EObject formContainer) {
return ModelHelper.getAccessibleDataInForms(formContainer, form.eContainmentFeature());
}
@Override
public String getExpressionType() {
return ExpressionConstants.VARIABLE_TYPE;
}
@Override
public Image getIcon(Expression expression) {
if(expression.getReferencedElements().isEmpty()){
return null ;
}
EObject reference = expression.getReferencedElements().get(0);
return adapterLabelProvider.getImage(reference) ;
}
@Override
public String getProposalLabel(Expression expression) {
return expression.getName();
}
private Expression createExpression(Data d) {
Expression exp = ExpressionFactory.eINSTANCE.createExpression() ;
exp.setType(getExpressionType()) ;
exp.setContent(d.getName()) ;
exp.setName(d.getName()) ;
exp.setReturnType(org.bonitasoft.studio.common.DataUtil.getTechnicalTypeFor(d)) ;
exp.getReferencedElements().add(ExpressionHelper.createDependencyFromEObject(d)) ;
return exp;
}
@Override
public boolean isRelevantFor(EObject context) {
return true;
}
@Override
public Image getTypeIcon() {
return Pics.getImage(PicsConstants.data);
}
@Override
public String getTypeLabel() {
return Messages.variableType;
}
@Override
public IExpressionEditor getExpressionEditor(Expression expression,EObject context) {
return new DataExpressionEditor();
}
private final ComposedAdapterFactory adapterFactory;
private final AdapterFactoryLabelProvider adapterLabelProvider;
public DataExpressionProvider() {
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
adapterLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
}
@Override
public Set<Expression> getExpressions(final EObject context) {
final Set<Expression> result = new HashSet<Expression>();
Form form = null;
PageFlow pf = null;
if (context instanceof Widget) {
form = ModelHelper.getForm((Widget) context);
} else if (context instanceof Form) {
form = (Form) context;
} else if (context instanceof PageFlow) {
pf = (PageFlow) context;
}
if (form != null) {
final EObject formContainer = form.eContainer();
if (formContainer != null) {
if (form.eContainmentFeature() != null && (formContainer instanceof PageFlow || formContainer instanceof ViewPageFlow)) {
for (final Data d : getDataInForm(form, formContainer)) {
result.add(createExpression(d));
}
}
}
} else if (pf != null) {
for (final Data d : ModelHelper.getAccessibleData(pf)) {
result.add(createExpression(d));
}
} else if (context instanceof EObject) {
for (final Data d : ModelHelper.getAccessibleData(context, true)) {
result.add(createExpression(d));
}
}
final FlowElement parentFlowElement = ModelHelper.getParentFlowElement(context);
if (parentFlowElement instanceof MultiInstantiable) {
final Expression iteratorExpression = ((MultiInstantiable) parentFlowElement).getIteratorExpression();
if (iteratorExpression != null
&& iteratorExpression.getName() != null
&& !iteratorExpression.getName().isEmpty()) {
final Data d = dataFromIteratorExpression(iteratorExpression);
result.add(createExpression(d));
}
}
return result;
}
private Data dataFromIteratorExpression(final Expression iteratorExpression) {
final String returnType = iteratorExpression.getReturnType();
Data d = null;
if (returnType != null) {
final DataType dt = getDataTypeFrom(returnType, iteratorExpression);
if (dt instanceof BusinessObjectType) {
d = ProcessFactory.eINSTANCE.createBusinessObjectData();
((BusinessObjectData) d).setClassName(returnType);
} else if (dt instanceof JavaType) {
d = ProcessFactory.eINSTANCE.createJavaObjectData();
((JavaObjectData) d).setClassName(returnType);
} else {
d = ProcessFactory.eINSTANCE.createData();
}
d.setName(iteratorExpression.getName());
d.setDataType(dt);
}
return d;
}
private DataType getDataTypeFrom(final String returnType, final Expression iteratorExpression) {
final MainProcess diagram = ModelHelper.getMainProcess(iteratorExpression);
for (final DataType dt : diagram.getDatatypes()) {
return new ProcessSwitch<DataType>() {
@Override
public DataType caseStringType(final StringType object) {
return object;
}
@Override
public DataType caseBooleanType(final org.bonitasoft.studio.model.process.BooleanType object) {
return object;
}
@Override
public DataType caseFloatType(final org.bonitasoft.studio.model.process.FloatType object) {
return object;
}
@Override
public DataType caseLongType(final org.bonitasoft.studio.model.process.LongType object) {
return object;
}
@Override
public DataType caseDoubleType(final org.bonitasoft.studio.model.process.DoubleType object) {
return object;
}
@Override
public DataType caseIntegerType(final org.bonitasoft.studio.model.process.IntegerType object) {
return object;
}
@Override
public DataType caseBusinessObjectType(final BusinessObjectType object) {
return object;
}
@Override
public DataType caseJavaType(final JavaType object) {
return object;
}