Commit 3c6de7bf authored by Aurelien Pupier's avatar Aurelien Pupier
Browse files

Merge pull request #312 from bonitasoft/fix/BS-14227_TooltipErrorFormEntry

BS-14227 Errors in tooltip of error decorator for invalid form entry
parents d4d549ed 40942b97
......@@ -6,7 +6,8 @@ widgetRepository=Custom Widgets
externalURL=External URL
targetForm=Target form
url=URL
pageDoesntExists=Form with id "{0}" does not exist.
pageDoesntExist=Page with id \"{0}\" does not exist.
formDoesntExist=Form with id \"{0}\" does not exist.
caseStartFormMappingDescription=Select the type of form used to instantiate the process. Subscription edition: With "Live Update", you can update your process live to map a different form after deployment.
entryFormMappingDescription=Select the type of form used to fulfill the contract. Subscription edition: With "Live Update", you can update your process live to map a different form after deployment.
caseOverviewFormMappingDescription=The overview page is displayed in Bonita BPM Portal when you click the Overview button in the Case details page. There are no restrictions on the information that this page can include. If you do not specify a page, a default overview page is provided.
......
......@@ -24,7 +24,7 @@ import org.bonitasoft.studio.common.emf.tools.ExpressionHelper;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.designer.core.repository.WebPageFileStore;
import org.bonitasoft.studio.designer.core.repository.WebPageRepositoryStore;
import org.bonitasoft.studio.designer.ui.property.section.control.FormReferenceExpressionValidator;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.core.runtime.IStatus;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -42,7 +42,8 @@ public class FormReferenceExpressionValidatorTest {
@Test
public void is_relevant_for_FORM_REFERENCE_TYPE() throws Exception {
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor);
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
ProcessPackage.Literals.PAGE_FLOW__FORM_MAPPING);
final boolean isRelevant = formReferenceExpressionValidator.isRelevantForExpressionType(ExpressionConstants.FORM_REFERENCE_TYPE);
......@@ -51,7 +52,8 @@ public class FormReferenceExpressionValidatorTest {
@Test
public void is_not_relevant_for_other_expression_type_than_FORM_REFERENCE_TYPE() throws Exception {
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor);
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
ProcessPackage.Literals.PAGE_FLOW__FORM_MAPPING);
final boolean isRelevant = formReferenceExpressionValidator.isRelevantForExpressionType(ExpressionConstants.CONSTANT_TYPE);
......@@ -60,7 +62,20 @@ public class FormReferenceExpressionValidatorTest {
@Test
public void return_an_error_status_if_page_id_is_not_in_the_repository() throws Exception {
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor);
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
ProcessPackage.Literals.PAGE_FLOW__FORM_MAPPING);
formReferenceExpressionValidator.setInputExpression(ExpressionHelper.createFormReferenceExpression("Step1", "step1-id"));
doReturn(aWebPageStoreMockContaining()).when(repositoryAccessor).getRepositoryStore(WebPageRepositoryStore.class);
final IStatus status = formReferenceExpressionValidator.validate("Step1");
assertThat(status).isNotOK();
}
@Test
public void return_an_error_status_if_page_id_is_not_in_the_repository_for_overviewPageFlow() throws Exception {
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
ProcessPackage.Literals.RECAP_FLOW__OVERVIEW_FORM_MAPPING);
formReferenceExpressionValidator.setInputExpression(ExpressionHelper.createFormReferenceExpression("Step1", "step1-id"));
doReturn(aWebPageStoreMockContaining()).when(repositoryAccessor).getRepositoryStore(WebPageRepositoryStore.class);
......@@ -71,7 +86,8 @@ public class FormReferenceExpressionValidatorTest {
@Test
public void return_a_valid_status_if_page_id_is_present_in_the_repository() throws Exception {
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor);
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
ProcessPackage.Literals.PAGE_FLOW__FORM_MAPPING);
formReferenceExpressionValidator.setInputExpression(ExpressionHelper.createFormReferenceExpression("Step1", "step1-id"));
doReturn(aWebPageStoreMockContaining("step1-id", "step2-id")).when(repositoryAccessor).getRepositoryStore(WebPageRepositoryStore.class);
......
......@@ -29,7 +29,7 @@ public class Messages extends NLS {
public static String externalURL;
public static String targetForm;
public static String url;
public static String pageDoesntExists;
public static String pageDoesntExist;
public static String caseStartFormMappingDescription;
public static String entryFormMappingDescription;
public static String caseOverviewFormMappingDescription;
......@@ -65,6 +65,7 @@ public class Messages extends NLS {
public static String noFormMessageOnTask;
public static String noFormMessageOnProcess;
public static String urlNotDefined;
public static String formDoesntExist;
static {
NLS.initializeMessages("messages", Messages.class);
......
......@@ -53,9 +53,6 @@ public class EntryFormMappingPropertySection extends AbstractBonitaDescriptionSe
@Inject
private RepositoryAccessor repositoryAccessor;
@Inject
private FormReferenceExpressionValidator formReferenceExpressionValidator;
@Inject
private CreateOrEditFormProposalListener createOrEditListener;
......@@ -64,6 +61,8 @@ public class EntryFormMappingPropertySection extends AbstractBonitaDescriptionSe
@Override
protected void createContent(final Composite parent) {
context = new EMFDataBindingContext();
final FormReferenceExpressionValidator formReferenceExpressionValidator = new FormReferenceExpressionValidator(repositoryAccessor,
getFormMappingFeature());
formMappingRadioGroup = new FormMappingRadioGroup(parent, getWidgetFactory(), preferenceStore,
repositoryAccessor, formReferenceExpressionValidator, createOrEditListener);
final IObservableValue formMappingObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
......
......@@ -14,18 +14,18 @@
*/
package org.bonitasoft.studio.designer.ui.property.section.control;
import javax.inject.Inject;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.designer.core.repository.WebPageRepositoryStore;
import org.bonitasoft.studio.designer.i18n.Messages;
import org.bonitasoft.studio.expression.editor.provider.IExpressionValidator;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.e4.core.di.annotations.Creatable;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
/**
......@@ -38,9 +38,11 @@ public class FormReferenceExpressionValidator implements IExpressionValidator {
private final RepositoryAccessor repositoryAccessor;
@Inject
public FormReferenceExpressionValidator(final RepositoryAccessor repositoryAccessor) {
private final EStructuralFeature feature;
public FormReferenceExpressionValidator(final RepositoryAccessor repositoryAccessor, final EStructuralFeature feature) {
this.repositoryAccessor = repositoryAccessor;
this.feature = feature;
}
/*
......@@ -51,8 +53,13 @@ public class FormReferenceExpressionValidator implements IExpressionValidator {
public IStatus validate(final Object value) {
final String content = inputExpression.getContent();
final WebPageRepositoryStore repositoryStore = repositoryAccessor.getRepositoryStore(WebPageRepositoryStore.class);
return repositoryStore.getChild(content) == null ? ValidationStatus.error(Messages.bind(Messages.pageDoesntExists,
String.format("%s (%s)", inputExpression.getName(), content))) : ValidationStatus.ok();
String errorMessage = null;
if (ProcessPackage.Literals.RECAP_FLOW__OVERVIEW_FORM_MAPPING.equals(feature)) {
errorMessage = Messages.bind(Messages.pageDoesntExist, content);
} else {
errorMessage = Messages.bind(Messages.formDoesntExist, content);
}
return repositoryStore.getChild(content) == null ? ValidationStatus.error(errorMessage) : ValidationStatus.ok();
}
/*
......@@ -79,7 +86,6 @@ public class FormReferenceExpressionValidator implements IExpressionValidator {
*/
@Override
public void setContext(final EObject context) {
}
/*
......
Supports Markdown
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