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

BS-10996

Initiliaze input type in gmfmap
parent 592e416e
......@@ -2945,6 +2945,15 @@
href="../form.ecore#//FileWidget"/>
<domainInitializer
xsi:type="gmfmap:FeatureSeqInitializer">
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EAttribute"
href="../form.ecore#//FileWidget/inputType"/>
<value
body="return org.bonitasoft.studio.common.emf.tools.ModelHelper.getDefaultFileWidgetInputType(self);"
language="java"/>
</initializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
......@@ -3116,6 +3125,14 @@
body="return org.bonitasoft.studio.common.emf.tools.WidgetModifiersSwitch.ENGINE_DOCUMENT_QUALIFIED_NAME;"
language="java"/>
</initializers>
<initializers
xsi:type="gmfmap:FeatureValueSpec">
<feature
xsi:type="ecore:EAttribute"
href="../form.ecore#//FileWidget/initialResourcePath"/>
<value
body="''"/>
</initializers>
</domainInitializer>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
......
......@@ -34,6 +34,8 @@ import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.bonitasoft.studio.model.form.Duplicable;
import org.bonitasoft.studio.model.form.FileWidget;
import org.bonitasoft.studio.model.form.FileWidgetInputType;
import org.bonitasoft.studio.model.form.Form;
import org.bonitasoft.studio.model.form.FormField;
import org.bonitasoft.studio.model.form.FormPackage;
......@@ -145,6 +147,13 @@ public class ModelHelper {
return res;
}
public static FileWidgetInputType getDefaultFileWidgetInputType(final FileWidget widget) {
if (ModelHelper.isAnEntryPageFlowOnAPool(ModelHelper.getParentForm(widget))) {
return FileWidgetInputType.RESOURCE;
}
return FileWidgetInputType.DOCUMENT;
}
private static List<AbstractProcess> findAllProcesses(final Element element, final List<AbstractProcess> processes) {
// List<URI> newwayFindProcesses = newwayFindProcesses(element, processes);
......@@ -597,7 +606,7 @@ public class ModelHelper {
final AbstractProcess process = (AbstractProcess) element;
containsResources = process.getResourceFolders().size() > 0 || process.getResourceFiles().size() > 0 || process.getLogInPage() != null
|| process.getProcessTemplate() != null || process.getConfirmationTemplate() != null || process.getErrorTemplate() != null
|| (process.getWelcomePage() != null && !process.getWelcomePageInternal());
|| process.getWelcomePage() != null && !process.getWelcomePageInternal();
if (containsResources) {
return true;
}
......@@ -990,7 +999,7 @@ public class ModelHelper {
if (!expr.getReferencedElements().isEmpty()) {
for (final EObject o : expr.getReferencedElements()) {
if (element instanceof Element && o instanceof Element && ((Element) element).getName().equals(((Element) o).getName())) {
return (true && !isAExpressionReferencedElement(expr));
return true && !isAExpressionReferencedElement(expr);
} else {
if (element instanceof Parameter && o instanceof Parameter && ((Parameter) element).getName().equals(((Parameter) o).getName())) {
return true && !isAExpressionReferencedElement(expr);
......@@ -1854,7 +1863,7 @@ public class ModelHelper {
final List<EObject> refs = expr.getReferencedElements();
for (final EObject ref : refs) {
if (ref instanceof Document && ((Document) ref).getName().equals(expr.getContent())) {
return ((Document) ref);
return (Document) ref;
}
}
return null;
......
......@@ -121,11 +121,10 @@ public class FileGridPropertySectionContribution implements IExtensibleGridPrope
radioComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL,SWT.CENTER).grab(true, false).span(3, 1).create());
radioComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(col).margins(0, 0).create()) ;
final FileWidgetInputType initialInputType = createUseDocumentButton(
final FileWidgetInputType initialInputType = element.getInputType();
createUseDocumentButton(
widgetFactory, radioComposite);
//createURLButton(widgetFactory, radioComposite);
createUseResourceButton(radioComposite);
// InitialValueComposite created to check initial values in SWTBot tests
......@@ -138,11 +137,9 @@ public class FileGridPropertySectionContribution implements IExtensibleGridPrope
initialValueSection.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());
initialValueSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
if(initialInputType == FileWidgetInputType.DOCUMENT){
if (initialInputType == FileWidgetInputType.DOCUMENT) {
initialValueSection.setClient(createInputExpressionComposite(initialValueSection, widgetFactory));
/*}else if(initialInputType == FileWidgetInputType.URL){
initialValueSection.setClient(createInputExpressionComposite(initialValueSection, widgetFactory));*/
}else if(initialInputType == FileWidgetInputType.RESOURCE){
} else if (initialInputType == FileWidgetInputType.RESOURCE) {
if(element.isDuplicate()){
initialValueSection.setClient(createMultipleResourceComposite(initialValueSection, widgetFactory));
}else{
......@@ -151,20 +148,13 @@ public class FileGridPropertySectionContribution implements IExtensibleGridPrope
}
bindFields();
if(initialInputType == FileWidgetInputType.DOCUMENT){
if (initialInputType == FileWidgetInputType.DOCUMENT) {
useDocumentButton.setSelection(true);
useDocumentButton.notifyListeners(SWT.Selection, new Event());
/*}else if(initialInputType == FileWidgetInputType.URL){
useURLButton.setSelection(true);*/
}else {
} else if (initialInputType == FileWidgetInputType.RESOURCE) {
useResourceButton.setSelection(true);
useResourceButton.notifyListeners(SWT.Selection,new Event());
}
}
private void createUseResourceButton(final Composite radioComposite) {
......@@ -227,42 +217,11 @@ public class FileGridPropertySectionContribution implements IExtensibleGridPrope
}
});
}else{
initialInputType = FileWidgetInputType.URL;
initialInputType = FileWidgetInputType.RESOURCE;
}
return initialInputType;
}
private void createURLButton(
final TabbedPropertySheetWidgetFactory widgetFactory,
final Composite radioComposite) {
// useURLButton = widgetFactory.createButton(radioComposite, Messages.useUrl, SWT.RADIO) ;
// useResourceButton = widgetFactory.createButton(radioComposite, Messages.useResource, SWT.RADIO) ;
//
// useURLButton.addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
// if(initialValueSection != null && !initialValueSection.isDisposed()){
// if(useURLButton.getSelection() && (element.getInputType() != FileWidgetInputType.URL || element.isDuplicate() != multiple || initialValueSection.getClient() == null)){
// boolean recreate = false;
// if(initialValueSection.getClient() == null || element.getInputType() == FileWidgetInputType.RESOURCE){
// recreate = true;
// }
// editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, element, FormPackage.Literals.FILE_WIDGET__INPUT_TYPE, FileWidgetInputType.URL));
// if(recreate){
// if(initialValueSection.getClient() != null){
// initialValueSection.getClient().dispose() ;
// }
// multiple = element.isDuplicate();
// initialValueSection.setClient(createInputExpressionComposite(initialValueSection,FileGridPropertySectionContribution.this.widgetFactory)) ;
// initialValueSection.setExpanded(true) ;
// bindFields();
// }
// }
// }
// }
// });
}
protected Control createResourceComposite(final Section section, final TabbedPropertySheetWidgetFactory widgetFactory) {
final Composite client = widgetFactory.createComposite(section);
client.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
......@@ -394,8 +353,6 @@ public class FileGridPropertySectionContribution implements IExtensibleGridPrope
public void handleValueChange(final ValueChangeEvent arg0) {
if(useDocumentButton != null &&!useDocumentButton.isDisposed() && element.getInputType() == FileWidgetInputType.DOCUMENT){
useDocumentButton.notifyListeners(SWT.Selection,new Event());
/*}else if(!useResourceButton.isDisposed() && element.getInputType() == FileWidgetInputType.URL){
useURLButton.notifyListeners(SWT.Selection,new Event());*/
}else if(!useResourceButton.isDisposed() && element.getInputType() == FileWidgetInputType.RESOURCE){
useResourceButton.notifyListeners(SWT.Selection,new Event());
}
......
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