Merge branch 'bugfix'
Conflicts:
examples/org.eclipse.emf.parsley.examples.mail.unifiedfoldersview/META-INF/MANIFEST.MF
Change-Id: I4e9444c038446f30f348d4a3e2f0fd455eab23be
diff --git a/doc/org.eclipse.emf.parsley.doc/contents/06-Customization.html b/doc/org.eclipse.emf.parsley.doc/contents/06-Customization.html
index 2c45657..6832b13 100644
--- a/doc/org.eclipse.emf.parsley.doc/contents/06-Customization.html
+++ b/doc/org.eclipse.emf.parsley.doc/contents/06-Customization.html
@@ -1580,5 +1580,24 @@
with the default Guice bindings, upon saving, if validation finds errors, it will
cancel the saving and it will show a dialog with errors.
</p>
+<p>
+Validation is also automatically triggered when editing object's properties in a form
+or in a dialog. The editing field will be decorated with an error
+and a tooltip with the error message. Here's an example based on the Library model.
+</p>
+<p>
+<div class="image" >
+<img src="images/form-validation.png" class=" "
+/>
+<div class="caption">
+</div>
+</div>
+</p>
+<p>
+Please keep in mind that for forms and dialogs the error decorations are based on
+specific features of the object being edited and validated. If you have a custom
+EMF validator you need to make sure to specify the <a class="jdoc" href="http://download.eclipse.org/modeling/emf/emf/javadoc/2.9.0/org/eclipse/emf/ecore/EStructuralFeature.html" title="View JavaDoc"><abbr title="org.eclipse.emf.ecore.EStructuralFeature" >EStructuralFeature</abbr></a> <a class="srcLink" href="https://github.com/eclipse/emf/blob/R2_9_0/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/EStructuralFeature.java" title="View Source Code" >(src)</a>
+when creating a diagnostic error.
+</p>
</body>
</html>
diff --git a/doc/org.eclipse.emf.parsley.doc/contents/images/form-validation.png b/doc/org.eclipse.emf.parsley.doc/contents/images/form-validation.png
new file mode 100644
index 0000000..b9726c8
--- /dev/null
+++ b/doc/org.eclipse.emf.parsley.doc/contents/images/form-validation.png
Binary files differ
diff --git a/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/06-Customization.xdoc b/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/06-Customization.xdoc
index 907b444..a523c02 100644
--- a/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/06-Customization.xdoc
+++ b/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/06-Customization.xdoc
@@ -1235,4 +1235,15 @@
Thus, if you use a codeRef[org.eclipse.emf.parsley.resource.ValidateBeforeSaveStrategy],
with the default Guice bindings, upon saving, if validation finds errors, it will
-cancel the saving and it will show a dialog with errors.
\ No newline at end of file
+cancel the saving and it will show a dialog with errors.
+
+Validation is also automatically triggered when editing object's properties in a form
+or in a dialog. The editing field will be decorated with an error
+and a tooltip with the error message. Here's an example based on the Library model.
+
+img[images/form-validation.png][][ ][]
+
+Please keep in mind that for forms and dialogs the error decorations are based on
+specific features of the object being edited and validated. If you have a custom
+EMF validator you need to make sure to specify the codeRef[org.eclipse.emf.ecore.EStructuralFeature]
+when creating a diagnostic error.
\ No newline at end of file
diff --git a/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/images/form-validation.png b/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/images/form-validation.png
new file mode 100644
index 0000000..b9726c8
--- /dev/null
+++ b/doc/org.eclipse.emf.parsley.doc/xdoc/documentation/images/form-validation.png
Binary files differ
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/model/Model.ecore b/examples/org.eclipse.emf.parsley.examples.rap.model/model/Model.ecore
index 7ecc2d8..deaf8c3 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/model/Model.ecore
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/model/Model.ecore
@@ -9,7 +9,7 @@
eType="#//Item" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Element">
- <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="age" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="items" upperBound="-1"
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Element.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Element.java
index aee2de3..54c137c 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Element.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Element.java
@@ -19,12 +19,12 @@
*
* <p>
* The following features are supported:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Element#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Element#getAge <em>Age</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Element#getItems <em>Items</em>}</li>
* </ul>
- * </p>
*
* @see org.eclipse.emf.parsley.examples.rap.model.ModelPackage#getElement()
* @model
@@ -43,7 +43,7 @@
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see org.eclipse.emf.parsley.examples.rap.model.ModelPackage#getElement_Name()
- * @model default=""
+ * @model default="" required="true"
* @generated
*/
String getName();
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Item.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Item.java
index f08b144..e00edbc 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Item.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Item.java
@@ -18,10 +18,10 @@
*
* <p>
* The following features are supported:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Item#getName <em>Name</em>}</li>
* </ul>
- * </p>
*
* @see org.eclipse.emf.parsley.examples.rap.model.ModelPackage#getItem()
* @model
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Model.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Model.java
index 8368fb5..120df37 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Model.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/Model.java
@@ -19,12 +19,12 @@
*
* <p>
* The following features are supported:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Model#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Model#getElements <em>Elements</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.Model#getItems <em>Items</em>}</li>
* </ul>
- * </p>
*
* @see org.eclipse.emf.parsley.examples.rap.model.ModelPackage#getModel()
* @model
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ElementImpl.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ElementImpl.java
index 06f4d11..fd4b1ca 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ElementImpl.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ElementImpl.java
@@ -29,12 +29,12 @@
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ElementImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ElementImpl#getAge <em>Age</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ElementImpl#getItems <em>Items</em>}</li>
* </ul>
- * </p>
*
* @generated
*/
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ItemImpl.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ItemImpl.java
index 7623772..b162ef8 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ItemImpl.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ItemImpl.java
@@ -25,10 +25,10 @@
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ItemImpl#getName <em>Name</em>}</li>
* </ul>
- * </p>
*
* @generated
*/
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelFactoryImpl.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelFactoryImpl.java
index 0f11e06..69921f6 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelFactoryImpl.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelFactoryImpl.java
@@ -34,7 +34,7 @@
*/
public static ModelFactory init() {
try {
- ModelFactory theModelFactory = (ModelFactory)EPackage.Registry.INSTANCE.getEFactory("http://model/1.0");
+ ModelFactory theModelFactory = (ModelFactory)EPackage.Registry.INSTANCE.getEFactory(ModelPackage.eNS_URI);
if (theModelFactory != null) {
return theModelFactory;
}
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelImpl.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelImpl.java
index 1d2e9c6..ca5f0c1 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelImpl.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelImpl.java
@@ -33,12 +33,12 @@
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
+ * </p>
* <ul>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ModelImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ModelImpl#getElements <em>Elements</em>}</li>
* <li>{@link org.eclipse.emf.parsley.examples.rap.model.impl.ModelImpl#getItems <em>Items</em>}</li>
* </ul>
- * </p>
*
* @generated
*/
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelPackageImpl.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelPackageImpl.java
index 5cdb674..97107f9 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelPackageImpl.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/impl/ModelPackageImpl.java
@@ -279,7 +279,7 @@
initEReference(getModel_Items(), this.getItem(), null, "items", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(elementEClass, Element.class, "Element", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getElement_Name(), ecorePackage.getEString(), "name", "", 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getElement_Name(), ecorePackage.getEString(), "name", "", 1, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getElement_Age(), ecorePackage.getEInt(), "age", null, 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getElement_Items(), this.getItem(), null, "items", null, 0, -1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/util/ModelSwitch.java b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/util/ModelSwitch.java
index ef79a23..32feed9 100644
--- a/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/util/ModelSwitch.java
+++ b/examples/org.eclipse.emf.parsley.examples.rap.model/src/org/eclipse/emf/parsley/examples/rap/model/util/ModelSwitch.java
@@ -54,7 +54,7 @@
* Checks whether this is a switch for the given package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @parameter ePackage the package in question.
+ * @param ePackage the package in question.
* @return whether this is a switch for the given package.
* @generated
*/
diff --git a/plugins/org.eclipse.emf.parsley.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.parsley.common/META-INF/MANIFEST.MF
index cf45d65..44bf91a 100644
--- a/plugins/org.eclipse.emf.parsley.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.parsley.common/META-INF/MANIFEST.MF
@@ -26,6 +26,7 @@
org.eclipse.emf.parsley.edit.ui.dnd,
org.eclipse.emf.parsley.edit.ui.provider,
org.eclipse.emf.parsley.handlers,
+ org.eclipse.emf.parsley.internal.databinding;x-internal:=true,
org.eclipse.emf.parsley.internal.edit.ui.dnd,
org.eclipse.emf.parsley.listeners,
org.eclipse.emf.parsley.menus,
@@ -53,6 +54,7 @@
org.eclipse.jface.action,
org.eclipse.jface.bindings,
org.eclipse.jface.bindings.keys,
+ org.eclipse.jface.databinding.fieldassist,
org.eclipse.jface.databinding.swt,
org.eclipse.jface.databinding.viewers,
org.eclipse.jface.dialogs,
diff --git a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/composite/AbstractControlFactory.java b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/composite/AbstractControlFactory.java
index 40ce302..0b0ce6b 100644
--- a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/composite/AbstractControlFactory.java
+++ b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/composite/AbstractControlFactory.java
@@ -30,6 +30,8 @@
import org.eclipse.emf.parsley.EmfParsleyConstants;
import org.eclipse.emf.parsley.edit.IEditingStrategy;
import org.eclipse.emf.parsley.edit.TextUndoRedo;
+import org.eclipse.emf.parsley.internal.databinding.DatabindingValidationUtil;
+import org.eclipse.emf.parsley.internal.databinding.EmfValidationTargetToModelUpdateValueStrategy;
import org.eclipse.emf.parsley.runtime.util.PolymorphicDispatcherExtensions;
import org.eclipse.emf.parsley.ui.provider.ComboViewerLabelProvider;
import org.eclipse.emf.parsley.ui.provider.FeatureLabelCaptionProvider;
@@ -38,6 +40,7 @@
import org.eclipse.emf.parsley.widgets.IWidgetFactory;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.jface.databinding.fieldassist.ControlDecorationSupport;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
import org.eclipse.jface.fieldassist.ControlDecoration;
@@ -95,6 +98,9 @@
@Inject
private ProposalCreator proposalCreator;
+ @Inject
+ private DatabindingValidationUtil databindingValidationUtil;
+
private EObject owner;
private Resource resource;
private EditingDomain domain;
@@ -278,7 +284,7 @@
Control retVal = retValAndTargetPair.getControl();
IObservableValue target = retValAndTargetPair.getObservableValue();
- Binding binding = edbc.bindValue(target, source);
+ Binding binding = bindValue(feature, target, source);
binding.updateModelToTarget();
return retVal;
}
@@ -332,12 +338,26 @@
.getObservableValue();
if (controlObservable != null) {
- edbc.bindValue(controlObservable, featureObservable, null, null);
+ bindValue(feature, controlObservable, featureObservable);
}
return retVal;
}
+ @SuppressWarnings("rawtypes")
+ private Binding bindValue(EStructuralFeature feature, IObservableValue target,
+ IObservableValue source) {
+ EmfValidationTargetToModelUpdateValueStrategy targetToModelUpdateValueStrategy =
+ new EmfValidationTargetToModelUpdateValueStrategy(
+ owner, feature, databindingValidationUtil);
+
+ Binding bindValue = edbc.bindValue(
+ target, source, targetToModelUpdateValueStrategy,
+ null);
+ ControlDecorationSupport.create(bindValue, SWT.TOP | SWT.LEFT);
+ return bindValue;
+ }
+
protected ControlObservablePair createControlAndObservableValue(
EStructuralFeature feature, boolean withPolymorphicDispatch) {
if (withPolymorphicDispatch) {
@@ -471,7 +491,9 @@
// set default layout data if not already set by a custom
// polymorphic implementation or from the DSL
if (c.getLayoutData()==null) {
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ GridData deafultLayout = new GridData(GridData.FILL_HORIZONTAL);
+ deafultLayout.horizontalIndent=10;
+ c.setLayoutData(deafultLayout);
}
}
}
diff --git a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingSubstitutionLabelProvider.java b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingSubstitutionLabelProvider.java
new file mode 100644
index 0000000..cf05504
--- /dev/null
+++ b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingSubstitutionLabelProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.parsley.internal.databinding;
+
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.parsley.ui.provider.FeatureLabelCaptionProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+
+/**
+ * A substitution label provider for validation error that uses our label and
+ * feature caption provider. This is specific of the passed EObject.
+ *
+ * @author Lorenzo Bettini - initial API and implementation
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DatabindingSubstitutionLabelProvider implements SubstitutionLabelProvider {
+
+ private EObject eObject;
+
+ private ILabelProvider labelProvider;
+
+ private FeatureLabelCaptionProvider featureLabelCaptionProvider;
+
+ public DatabindingSubstitutionLabelProvider(EObject eObject, ILabelProvider labelProvider,
+ FeatureLabelCaptionProvider featureLabelCaptionProvider) {
+ this.eObject = eObject;
+ this.labelProvider = labelProvider;
+ this.featureLabelCaptionProvider = featureLabelCaptionProvider;
+ }
+
+ @Override
+ public String getObjectLabel(EObject eObject) {
+ return labelProvider.getText(eObject);
+ }
+
+ @Override
+ public String getFeatureLabel(EStructuralFeature eStructuralFeature) {
+ return featureLabelCaptionProvider.getText(eObject, eStructuralFeature);
+ }
+
+ @Override
+ public String getValueLabel(EDataType eDataType, Object value) {
+ return EcoreUtil.convertToString(eDataType, value);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingValidationUtil.java b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingValidationUtil.java
new file mode 100644
index 0000000..22a867b
--- /dev/null
+++ b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/DatabindingValidationUtil.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.parsley.internal.databinding;
+
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.filter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.emf.parsley.ui.provider.FeatureLabelCaptionProvider;
+import org.eclipse.emf.parsley.validation.DiagnosticUtil;
+import org.eclipse.jface.viewers.ILabelProvider;
+
+import com.google.common.base.Predicate;
+import com.google.inject.Inject;
+
+/**
+ * Some utilities for validation used in databinding.
+ *
+ * @author Lorenzo Bettini - initial API and implementation
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DatabindingValidationUtil {
+
+ @Inject
+ private Diagnostician diagnostician;
+
+ @Inject
+ private DiagnosticUtil diagnosticUtil;
+
+ @Inject
+ private ILabelProvider labelProvider;
+
+ @Inject
+ private FeatureLabelCaptionProvider featureLabelCaptionProvider;
+
+ /**
+ * Retrieves the {@link Diagnostic} for the specified object and related to
+ * the specified feature.
+ *
+ * @param eObject
+ * @param feature
+ * @param context
+ * @return
+ */
+ public Iterable<Diagnostic> getDiagnostic(final EObject eObject, final EStructuralFeature feature) {
+ Map<Object, Object> context = new HashMap<Object, Object>();
+ context.put(SubstitutionLabelProvider.class,
+ new DatabindingSubstitutionLabelProvider(eObject, labelProvider, featureLabelCaptionProvider));
+ List<Diagnostic> diagnostics = diagnosticUtil.flatten(diagnostician.validate(eObject, context));
+ Iterable<Diagnostic> filtered = filter(diagnostics, new Predicate<Diagnostic>() {
+ @Override
+ public boolean apply(Diagnostic d) {
+ return contains(d.getData(), feature);
+ }
+ });
+ return filtered;
+ }
+}
diff --git a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/EmfValidationTargetToModelUpdateValueStrategy.java b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/EmfValidationTargetToModelUpdateValueStrategy.java
new file mode 100644
index 0000000..58feaca
--- /dev/null
+++ b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/internal/databinding/EmfValidationTargetToModelUpdateValueStrategy.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francesco Guidieri - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.parsley.internal.databinding;
+
+import org.eclipse.core.databinding.UpdateValueStrategy;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A custom {@link UpdateValueStrategy} to decorate controls with possible EMF validation errors.
+ *
+ * @author Francesco Guidieri - initial API and implementation
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class EmfValidationTargetToModelUpdateValueStrategy extends UpdateValueStrategy {
+
+ private EObject owner;
+
+ private EStructuralFeature feature;
+
+ private DatabindingValidationUtil databindingValidationUtil;
+
+ private boolean firstValidateBeforeSet = true;
+
+ public EmfValidationTargetToModelUpdateValueStrategy(EObject owner, EStructuralFeature feature,
+ DatabindingValidationUtil databindingValidationUtil) {
+ this.owner = owner;
+ this.feature = feature;
+ this.databindingValidationUtil = databindingValidationUtil;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected IStatus doSet(IObservableValue observableValue, Object value) {
+ // the modification must go into the model
+ super.doSet(observableValue, (!"".equals(value) ? value : null));
+ // since we delegate validation to the EMF validator
+ return validationStatus();
+ }
+
+ @Override
+ public IStatus validateBeforeSet(Object value) {
+ if (firstValidateBeforeSet) {
+ firstValidateBeforeSet = false;
+ return validationStatus();
+ }
+ return super.validateBeforeSet(value);
+ }
+
+ private IStatus validationStatus() {
+ Iterable<Diagnostic> filtered =
+ databindingValidationUtil.getDiagnostic(owner, feature);
+ for (Diagnostic d : filtered) {
+ int severity = d.getSeverity();
+ if (severity == Diagnostic.ERROR) {
+ return ValidationStatus.error(d.getMessage());
+ }
+ }
+ return ValidationStatus.ok();
+ }
+}
diff --git a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/resource/ValidateBeforeSaveStrategy.java b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/resource/ValidateBeforeSaveStrategy.java
index 6bb51f3..266f55c 100644
--- a/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/resource/ValidateBeforeSaveStrategy.java
+++ b/plugins/org.eclipse.emf.parsley.common/src/org/eclipse/emf/parsley/resource/ValidateBeforeSaveStrategy.java
@@ -29,18 +29,18 @@
@Inject
private ValidationRunner validationRunner;
-
+
@Inject
private IssueReporter issueReporter;
- @Override
+ @Override
public boolean save(Resource resource) throws IOException {
if (!precondition(resource)) {
return false;
}
return super.save(resource);
}
-
+
protected boolean precondition(Resource resource) {
return validationRunner.validate(resource, issueReporter).size() == 0;
}
diff --git a/tests/org.eclipse.emf.parsley.tests.models/model/ParsleyTests.ecore b/tests/org.eclipse.emf.parsley.tests.models/model/ParsleyTests.ecore
index 7b71acc..c1465e1 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/model/ParsleyTests.ecore
+++ b/tests/org.eclipse.emf.parsley.tests.models/model/ParsleyTests.ecore
@@ -16,6 +16,8 @@
eType="#//ClassForValidation" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="multipleContained" upperBound="-1"
eType="#//TestContainer" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="objectsForDefaultValidation"
+ upperBound="-1" eType="#//ClassForDefaultValidation" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="TestEClass">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lowercaseNameFeature" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
@@ -126,6 +128,15 @@
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
<details key="constraints" value="NotEmpty"/>
</eAnnotations>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="notEmpty" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="ClassForDefaultValidation">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="notEmpty" lowerBound="1"
+ eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="canBeEmpty" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="notNullReference" lowerBound="1"
+ eType="#//ClassWithName"/>
+ </eClassifiers>
</ecore:EPackage>
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForDefaultValidation.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForDefaultValidation.java
new file mode 100644
index 0000000..fbdda6f
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForDefaultValidation.java
@@ -0,0 +1,131 @@
+/**
+ */
+package org.eclipse.emf.parsley.tests.models.testmodels;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Class For Default Validation</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * </p>
+ * <ul>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotEmpty <em>Not Empty</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getCanBeEmpty <em>Can Be Empty</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotNullReference <em>Not Null Reference</em>}</li>
+ * </ul>
+ *
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForDefaultValidation()
+ * @model
+ * @generated
+ */
+public interface ClassForDefaultValidation extends EObject {
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForDefaultValidation_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Not Empty</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Not Empty</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Not Empty</em>' attribute.
+ * @see #setNotEmpty(String)
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForDefaultValidation_NotEmpty()
+ * @model required="true"
+ * @generated
+ */
+ String getNotEmpty();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotEmpty <em>Not Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Not Empty</em>' attribute.
+ * @see #getNotEmpty()
+ * @generated
+ */
+ void setNotEmpty(String value);
+
+ /**
+ * Returns the value of the '<em><b>Can Be Empty</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Can Be Empty</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Can Be Empty</em>' attribute.
+ * @see #setCanBeEmpty(String)
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForDefaultValidation_CanBeEmpty()
+ * @model
+ * @generated
+ */
+ String getCanBeEmpty();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getCanBeEmpty <em>Can Be Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Can Be Empty</em>' attribute.
+ * @see #getCanBeEmpty()
+ * @generated
+ */
+ void setCanBeEmpty(String value);
+
+ /**
+ * Returns the value of the '<em><b>Not Null Reference</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Not Null Reference</em>' reference isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Not Null Reference</em>' reference.
+ * @see #setNotNullReference(ClassWithName)
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForDefaultValidation_NotNullReference()
+ * @model required="true"
+ * @generated
+ */
+ ClassWithName getNotNullReference();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotNullReference <em>Not Null Reference</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Not Null Reference</em>' reference.
+ * @see #getNotNullReference()
+ * @generated
+ */
+ void setNotNullReference(ClassWithName value);
+
+} // ClassForDefaultValidation
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForValidation.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForValidation.java
index da53bbd..eefb097 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForValidation.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/ClassForValidation.java
@@ -13,6 +13,7 @@
* The following features are supported:
* </p>
* <ul>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getNotEmpty <em>Not Empty</em>}</li>
* </ul>
*
@@ -22,6 +23,32 @@
*/
public interface ClassForValidation extends EObject {
/**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getClassForValidation_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
* Returns the value of the '<em><b>Not Empty</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestContainer.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestContainer.java
index 9c8d24e..329f5b2 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestContainer.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestContainer.java
@@ -22,6 +22,7 @@
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getClassesForTable <em>Classes For Table</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getObjectsForValidation <em>Objects For Validation</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getMultipleContained <em>Multiple Contained</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getObjectsForDefaultValidation <em>Objects For Default Validation</em>}</li>
* </ul>
*
* @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getTestContainer()
@@ -161,4 +162,20 @@
*/
EList<TestContainer> getMultipleContained();
+ /**
+ * Returns the value of the '<em><b>Objects For Default Validation</b></em>' containment reference list.
+ * The list contents are of type {@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Objects For Default Validation</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Objects For Default Validation</em>' containment reference list.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage#getTestContainer_ObjectsForDefaultValidation()
+ * @model containment="true"
+ * @generated
+ */
+ EList<ClassForDefaultValidation> getObjectsForDefaultValidation();
+
} // TestContainer
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsFactory.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsFactory.java
index 499fa8b..28909ea 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsFactory.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsFactory.java
@@ -155,6 +155,15 @@
ClassForValidation createClassForValidation();
/**
+ * Returns a new object of class '<em>Class For Default Validation</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Class For Default Validation</em>'.
+ * @generated
+ */
+ ClassForDefaultValidation createClassForDefaultValidation();
+
+ /**
* Returns a new object of class '<em>Test Container</em>'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsPackage.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsPackage.java
index 4314de2..9b04c8d 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsPackage.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/TestmodelsPackage.java
@@ -189,13 +189,22 @@
int TEST_CONTAINER__MULTIPLE_CONTAINED = 6;
/**
+ * The feature id for the '<em><b>Objects For Default Validation</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION = 7;
+
+ /**
* The number of structural features of the '<em>Test Container</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int TEST_CONTAINER_FEATURE_COUNT = 7;
+ int TEST_CONTAINER_FEATURE_COUNT = 8;
/**
* The number of operations of the '<em>Test Container</em>' class.
@@ -1062,13 +1071,22 @@
int CLASS_FOR_VALIDATION = 14;
/**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_VALIDATION__NAME = 0;
+
+ /**
* The feature id for the '<em><b>Not Empty</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int CLASS_FOR_VALIDATION__NOT_EMPTY = 0;
+ int CLASS_FOR_VALIDATION__NOT_EMPTY = 1;
/**
* The number of structural features of the '<em>Class For Validation</em>' class.
@@ -1077,7 +1095,7 @@
* @generated
* @ordered
*/
- int CLASS_FOR_VALIDATION_FEATURE_COUNT = 1;
+ int CLASS_FOR_VALIDATION_FEATURE_COUNT = 2;
/**
* The number of operations of the '<em>Class For Validation</em>' class.
@@ -1089,6 +1107,70 @@
int CLASS_FOR_VALIDATION_OPERATION_COUNT = 0;
/**
+ * The meta object id for the '{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl <em>Class For Default Validation</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getClassForDefaultValidation()
+ * @generated
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION = 15;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>Not Empty</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY = 1;
+
+ /**
+ * The feature id for the '<em><b>Can Be Empty</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY = 2;
+
+ /**
+ * The feature id for the '<em><b>Not Null Reference</b></em>' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE = 3;
+
+ /**
+ * The number of structural features of the '<em>Class For Default Validation</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION_FEATURE_COUNT = 4;
+
+ /**
+ * The number of operations of the '<em>Class For Default Validation</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CLASS_FOR_DEFAULT_VALIDATION_OPERATION_COUNT = 0;
+
+ /**
* The meta object id for the '{@link org.eclipse.emf.parsley.tests.models.testmodels.EnumForControls <em>Enum For Controls</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1096,7 +1178,7 @@
* @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getEnumForControls()
* @generated
*/
- int ENUM_FOR_CONTROLS = 15;
+ int ENUM_FOR_CONTROLS = 16;
/**
@@ -1107,7 +1189,7 @@
* @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getBooleanDataType()
* @generated
*/
- int BOOLEAN_DATA_TYPE = 16;
+ int BOOLEAN_DATA_TYPE = 17;
/**
@@ -1117,7 +1199,7 @@
* @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getBooleanPrimitiveDataType()
* @generated
*/
- int BOOLEAN_PRIMITIVE_DATA_TYPE = 17;
+ int BOOLEAN_PRIMITIVE_DATA_TYPE = 18;
/**
@@ -1128,7 +1210,7 @@
* @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getStringDataType()
* @generated
*/
- int STRING_DATA_TYPE = 18;
+ int STRING_DATA_TYPE = 19;
/**
@@ -1139,7 +1221,7 @@
* @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getUnserializableStringDataType()
* @generated
*/
- int UNSERIALIZABLE_STRING_DATA_TYPE = 19;
+ int UNSERIALIZABLE_STRING_DATA_TYPE = 20;
/**
@@ -1756,6 +1838,17 @@
EClass getClassForValidation();
/**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getName()
+ * @see #getClassForValidation()
+ * @generated
+ */
+ EAttribute getClassForValidation_Name();
+
+ /**
* Returns the meta object for the attribute '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation#getNotEmpty <em>Not Empty</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1767,6 +1860,60 @@
EAttribute getClassForValidation_NotEmpty();
/**
+ * Returns the meta object for class '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation <em>Class For Default Validation</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Class For Default Validation</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation
+ * @generated
+ */
+ EClass getClassForDefaultValidation();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getName()
+ * @see #getClassForDefaultValidation()
+ * @generated
+ */
+ EAttribute getClassForDefaultValidation_Name();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotEmpty <em>Not Empty</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Not Empty</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotEmpty()
+ * @see #getClassForDefaultValidation()
+ * @generated
+ */
+ EAttribute getClassForDefaultValidation_NotEmpty();
+
+ /**
+ * Returns the meta object for the attribute '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getCanBeEmpty <em>Can Be Empty</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Can Be Empty</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getCanBeEmpty()
+ * @see #getClassForDefaultValidation()
+ * @generated
+ */
+ EAttribute getClassForDefaultValidation_CanBeEmpty();
+
+ /**
+ * Returns the meta object for the reference '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotNullReference <em>Not Null Reference</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the reference '<em>Not Null Reference</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation#getNotNullReference()
+ * @see #getClassForDefaultValidation()
+ * @generated
+ */
+ EReference getClassForDefaultValidation_NotNullReference();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer <em>Test Container</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1854,6 +2001,17 @@
EReference getTestContainer_MultipleContained();
/**
+ * Returns the meta object for the containment reference list '{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getObjectsForDefaultValidation <em>Objects For Default Validation</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Objects For Default Validation</em>'.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.TestContainer#getObjectsForDefaultValidation()
+ * @see #getTestContainer()
+ * @generated
+ */
+ EReference getTestContainer_ObjectsForDefaultValidation();
+
+ /**
* Returns the meta object for enum '{@link org.eclipse.emf.parsley.tests.models.testmodels.EnumForControls <em>Enum For Controls</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2357,6 +2515,13 @@
*/
EClass CLASS_FOR_VALIDATION = eINSTANCE.getClassForValidation();
/**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute CLASS_FOR_VALIDATION__NAME = eINSTANCE.getClassForValidation_Name();
+ /**
* The meta object literal for the '<em><b>Not Empty</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2364,6 +2529,43 @@
*/
EAttribute CLASS_FOR_VALIDATION__NOT_EMPTY = eINSTANCE.getClassForValidation_NotEmpty();
/**
+ * The meta object literal for the '{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl <em>Class For Default Validation</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.impl.TestmodelsPackageImpl#getClassForDefaultValidation()
+ * @generated
+ */
+ EClass CLASS_FOR_DEFAULT_VALIDATION = eINSTANCE.getClassForDefaultValidation();
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute CLASS_FOR_DEFAULT_VALIDATION__NAME = eINSTANCE.getClassForDefaultValidation_Name();
+ /**
+ * The meta object literal for the '<em><b>Not Empty</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY = eINSTANCE.getClassForDefaultValidation_NotEmpty();
+ /**
+ * The meta object literal for the '<em><b>Can Be Empty</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY = eINSTANCE.getClassForDefaultValidation_CanBeEmpty();
+ /**
+ * The meta object literal for the '<em><b>Not Null Reference</b></em>' reference feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE = eINSTANCE.getClassForDefaultValidation_NotNullReference();
+ /**
* The meta object literal for the '{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.TestContainerImpl <em>Test Container</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2422,6 +2624,13 @@
*/
EReference TEST_CONTAINER__MULTIPLE_CONTAINED = eINSTANCE.getTestContainer_MultipleContained();
/**
+ * The meta object literal for the '<em><b>Objects For Default Validation</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION = eINSTANCE.getTestContainer_ObjectsForDefaultValidation();
+ /**
* The meta object literal for the '{@link org.eclipse.emf.parsley.tests.models.testmodels.EnumForControls <em>Enum For Controls</em>}' enum.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForDefaultValidationImpl.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForDefaultValidationImpl.java
new file mode 100644
index 0000000..400f184
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForDefaultValidationImpl.java
@@ -0,0 +1,333 @@
+/**
+ */
+package org.eclipse.emf.parsley.tests.models.testmodels.impl;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
+
+import org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation;
+import org.eclipse.emf.parsley.tests.models.testmodels.ClassWithName;
+import org.eclipse.emf.parsley.tests.models.testmodels.TestmodelsPackage;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Class For Default Validation</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * </p>
+ * <ul>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl#getName <em>Name</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl#getNotEmpty <em>Not Empty</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl#getCanBeEmpty <em>Can Be Empty</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForDefaultValidationImpl#getNotNullReference <em>Not Null Reference</em>}</li>
+ * </ul>
+ *
+ * @generated
+ */
+public class ClassForDefaultValidationImpl extends MinimalEObjectImpl.Container implements ClassForDefaultValidation {
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getNotEmpty() <em>Not Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getNotEmpty()
+ * @generated
+ * @ordered
+ */
+ protected static final String NOT_EMPTY_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getNotEmpty() <em>Not Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getNotEmpty()
+ * @generated
+ * @ordered
+ */
+ protected String notEmpty = NOT_EMPTY_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getCanBeEmpty() <em>Can Be Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCanBeEmpty()
+ * @generated
+ * @ordered
+ */
+ protected static final String CAN_BE_EMPTY_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getCanBeEmpty() <em>Can Be Empty</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCanBeEmpty()
+ * @generated
+ * @ordered
+ */
+ protected String canBeEmpty = CAN_BE_EMPTY_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getNotNullReference() <em>Not Null Reference</em>}' reference.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getNotNullReference()
+ * @generated
+ * @ordered
+ */
+ protected ClassWithName notNullReference;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ClassForDefaultValidationImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return TestmodelsPackage.Literals.CLASS_FOR_DEFAULT_VALIDATION;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getNotEmpty() {
+ return notEmpty;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setNotEmpty(String newNotEmpty) {
+ String oldNotEmpty = notEmpty;
+ notEmpty = newNotEmpty;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY, oldNotEmpty, notEmpty));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getCanBeEmpty() {
+ return canBeEmpty;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setCanBeEmpty(String newCanBeEmpty) {
+ String oldCanBeEmpty = canBeEmpty;
+ canBeEmpty = newCanBeEmpty;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY, oldCanBeEmpty, canBeEmpty));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ClassWithName getNotNullReference() {
+ if (notNullReference != null && notNullReference.eIsProxy()) {
+ InternalEObject oldNotNullReference = (InternalEObject)notNullReference;
+ notNullReference = (ClassWithName)eResolveProxy(oldNotNullReference);
+ if (notNullReference != oldNotNullReference) {
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE, oldNotNullReference, notNullReference));
+ }
+ }
+ return notNullReference;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ClassWithName basicGetNotNullReference() {
+ return notNullReference;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setNotNullReference(ClassWithName newNotNullReference) {
+ ClassWithName oldNotNullReference = notNullReference;
+ notNullReference = newNotNullReference;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE, oldNotNullReference, notNullReference));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NAME:
+ return getName();
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY:
+ return getNotEmpty();
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY:
+ return getCanBeEmpty();
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE:
+ if (resolve) return getNotNullReference();
+ return basicGetNotNullReference();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NAME:
+ setName((String)newValue);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY:
+ setNotEmpty((String)newValue);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY:
+ setCanBeEmpty((String)newValue);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE:
+ setNotNullReference((ClassWithName)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY:
+ setNotEmpty(NOT_EMPTY_EDEFAULT);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY:
+ setCanBeEmpty(CAN_BE_EMPTY_EDEFAULT);
+ return;
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE:
+ setNotNullReference((ClassWithName)null);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY:
+ return NOT_EMPTY_EDEFAULT == null ? notEmpty != null : !NOT_EMPTY_EDEFAULT.equals(notEmpty);
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY:
+ return CAN_BE_EMPTY_EDEFAULT == null ? canBeEmpty != null : !CAN_BE_EMPTY_EDEFAULT.equals(canBeEmpty);
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE:
+ return notNullReference != null;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ result.append(name);
+ result.append(", notEmpty: ");
+ result.append(notEmpty);
+ result.append(", canBeEmpty: ");
+ result.append(canBeEmpty);
+ result.append(')');
+ return result.toString();
+ }
+
+} //ClassForDefaultValidationImpl
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForValidationImpl.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForValidationImpl.java
index 03b03bd..0a81c69 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForValidationImpl.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/ClassForValidationImpl.java
@@ -20,6 +20,7 @@
* The following features are implemented:
* </p>
* <ul>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForValidationImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.ClassForValidationImpl#getNotEmpty <em>Not Empty</em>}</li>
* </ul>
*
@@ -27,6 +28,26 @@
*/
public class ClassForValidationImpl extends MinimalEObjectImpl.Container implements ClassForValidation {
/**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
* The default value of the '{@link #getNotEmpty() <em>Not Empty</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -70,6 +91,27 @@
* <!-- end-user-doc -->
* @generated
*/
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, TestmodelsPackage.CLASS_FOR_VALIDATION__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public String getNotEmpty() {
return notEmpty;
}
@@ -94,6 +136,8 @@
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_VALIDATION__NAME:
+ return getName();
case TestmodelsPackage.CLASS_FOR_VALIDATION__NOT_EMPTY:
return getNotEmpty();
}
@@ -108,6 +152,9 @@
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_VALIDATION__NAME:
+ setName((String)newValue);
+ return;
case TestmodelsPackage.CLASS_FOR_VALIDATION__NOT_EMPTY:
setNotEmpty((String)newValue);
return;
@@ -123,6 +170,9 @@
@Override
public void eUnset(int featureID) {
switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_VALIDATION__NAME:
+ setName(NAME_EDEFAULT);
+ return;
case TestmodelsPackage.CLASS_FOR_VALIDATION__NOT_EMPTY:
setNotEmpty(NOT_EMPTY_EDEFAULT);
return;
@@ -138,6 +188,8 @@
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
+ case TestmodelsPackage.CLASS_FOR_VALIDATION__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case TestmodelsPackage.CLASS_FOR_VALIDATION__NOT_EMPTY:
return NOT_EMPTY_EDEFAULT == null ? notEmpty != null : !NOT_EMPTY_EDEFAULT.equals(notEmpty);
}
@@ -154,7 +206,9 @@
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
- result.append(" (notEmpty: ");
+ result.append(" (name: ");
+ result.append(name);
+ result.append(", notEmpty: ");
result.append(notEmpty);
result.append(')');
return result.toString();
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestContainerImpl.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestContainerImpl.java
index 545c399..d6de20a 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestContainerImpl.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestContainerImpl.java
@@ -19,6 +19,7 @@
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForControls;
+import org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForTable;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForValidation;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassWithName;
@@ -40,6 +41,7 @@
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.TestContainerImpl#getClassesForTable <em>Classes For Table</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.TestContainerImpl#getObjectsForValidation <em>Objects For Validation</em>}</li>
* <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.TestContainerImpl#getMultipleContained <em>Multiple Contained</em>}</li>
+ * <li>{@link org.eclipse.emf.parsley.tests.models.testmodels.impl.TestContainerImpl#getObjectsForDefaultValidation <em>Objects For Default Validation</em>}</li>
* </ul>
*
* @generated
@@ -126,6 +128,16 @@
protected EList<TestContainer> multipleContained;
/**
+ * The cached value of the '{@link #getObjectsForDefaultValidation() <em>Objects For Default Validation</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getObjectsForDefaultValidation()
+ * @generated
+ * @ordered
+ */
+ protected EList<ClassForDefaultValidation> objectsForDefaultValidation;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -273,6 +285,18 @@
* <!-- end-user-doc -->
* @generated
*/
+ public EList<ClassForDefaultValidation> getObjectsForDefaultValidation() {
+ if (objectsForDefaultValidation == null) {
+ objectsForDefaultValidation = new EObjectContainmentEList<ClassForDefaultValidation>(ClassForDefaultValidation.class, this, TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION);
+ }
+ return objectsForDefaultValidation;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -288,6 +312,8 @@
return ((InternalEList<?>)getObjectsForValidation()).basicRemove(otherEnd, msgs);
case TestmodelsPackage.TEST_CONTAINER__MULTIPLE_CONTAINED:
return ((InternalEList<?>)getMultipleContained()).basicRemove(otherEnd, msgs);
+ case TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION:
+ return ((InternalEList<?>)getObjectsForDefaultValidation()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
@@ -314,6 +340,8 @@
return getObjectsForValidation();
case TestmodelsPackage.TEST_CONTAINER__MULTIPLE_CONTAINED:
return getMultipleContained();
+ case TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION:
+ return getObjectsForDefaultValidation();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -353,6 +381,10 @@
getMultipleContained().clear();
getMultipleContained().addAll((Collection<? extends TestContainer>)newValue);
return;
+ case TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION:
+ getObjectsForDefaultValidation().clear();
+ getObjectsForDefaultValidation().addAll((Collection<? extends ClassForDefaultValidation>)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -386,6 +418,9 @@
case TestmodelsPackage.TEST_CONTAINER__MULTIPLE_CONTAINED:
getMultipleContained().clear();
return;
+ case TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION:
+ getObjectsForDefaultValidation().clear();
+ return;
}
super.eUnset(featureID);
}
@@ -412,6 +447,8 @@
return objectsForValidation != null && !objectsForValidation.isEmpty();
case TestmodelsPackage.TEST_CONTAINER__MULTIPLE_CONTAINED:
return multipleContained != null && !multipleContained.isEmpty();
+ case TestmodelsPackage.TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION:
+ return objectsForDefaultValidation != null && !objectsForDefaultValidation.isEmpty();
}
return super.eIsSet(featureID);
}
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsFactoryImpl.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsFactoryImpl.java
index e6780f1..2cc7e4f 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsFactoryImpl.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsFactoryImpl.java
@@ -79,6 +79,7 @@
case TestmodelsPackage.CLASS_FOR_FEATURE_MAP_ENTRY2: return createClassForFeatureMapEntry2();
case TestmodelsPackage.CLASS_FOR_TABLE: return createClassForTable();
case TestmodelsPackage.CLASS_FOR_VALIDATION: return createClassForValidation();
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION: return createClassForDefaultValidation();
default:
throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
}
@@ -271,6 +272,16 @@
* <!-- end-user-doc -->
* @generated
*/
+ public ClassForDefaultValidation createClassForDefaultValidation() {
+ ClassForDefaultValidationImpl classForDefaultValidation = new ClassForDefaultValidationImpl();
+ return classForDefaultValidation;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public TestContainer createTestContainer() {
TestContainerImpl testContainer = new TestContainerImpl();
return testContainer;
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsPackageImpl.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsPackageImpl.java
index 9a5ef85..f59d3c7 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsPackageImpl.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/impl/TestmodelsPackageImpl.java
@@ -23,6 +23,7 @@
import org.eclipse.emf.parsley.tests.models.testmodels.BaseClass;
import org.eclipse.emf.parsley.tests.models.testmodels.BaseClassForFeatureMapEntry;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForControls;
+import org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForFeatureMapEntry1;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForFeatureMapEntry2;
import org.eclipse.emf.parsley.tests.models.testmodels.ClassForTable;
@@ -148,6 +149,13 @@
* <!-- end-user-doc -->
* @generated
*/
+ private EClass classForDefaultValidationEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
private EClass testContainerEClass = null;
/**
@@ -773,7 +781,7 @@
* <!-- end-user-doc -->
* @generated
*/
- public EAttribute getClassForValidation_NotEmpty() {
+ public EAttribute getClassForValidation_Name() {
return (EAttribute)classForValidationEClass.getEStructuralFeatures().get(0);
}
@@ -782,6 +790,60 @@
* <!-- end-user-doc -->
* @generated
*/
+ public EAttribute getClassForValidation_NotEmpty() {
+ return (EAttribute)classForValidationEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getClassForDefaultValidation() {
+ return classForDefaultValidationEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getClassForDefaultValidation_Name() {
+ return (EAttribute)classForDefaultValidationEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getClassForDefaultValidation_NotEmpty() {
+ return (EAttribute)classForDefaultValidationEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getClassForDefaultValidation_CanBeEmpty() {
+ return (EAttribute)classForDefaultValidationEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getClassForDefaultValidation_NotNullReference() {
+ return (EReference)classForDefaultValidationEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getTestContainer() {
return testContainerEClass;
}
@@ -854,6 +916,15 @@
* <!-- end-user-doc -->
* @generated
*/
+ public EReference getTestContainer_ObjectsForDefaultValidation() {
+ return (EReference)testContainerEClass.getEStructuralFeatures().get(7);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EEnum getEnumForControls() {
return enumForControlsEEnum;
}
@@ -930,6 +1001,7 @@
createEReference(testContainerEClass, TEST_CONTAINER__CLASSES_FOR_TABLE);
createEReference(testContainerEClass, TEST_CONTAINER__OBJECTS_FOR_VALIDATION);
createEReference(testContainerEClass, TEST_CONTAINER__MULTIPLE_CONTAINED);
+ createEReference(testContainerEClass, TEST_CONTAINER__OBJECTS_FOR_DEFAULT_VALIDATION);
testEClassEClass = createEClass(TEST_ECLASS);
createEAttribute(testEClassEClass, TEST_ECLASS__LOWERCASE_NAME_FEATURE);
@@ -1001,8 +1073,15 @@
createEReference(classForTableEClass, CLASS_FOR_TABLE__CLASS_WITH_NAME2);
classForValidationEClass = createEClass(CLASS_FOR_VALIDATION);
+ createEAttribute(classForValidationEClass, CLASS_FOR_VALIDATION__NAME);
createEAttribute(classForValidationEClass, CLASS_FOR_VALIDATION__NOT_EMPTY);
+ classForDefaultValidationEClass = createEClass(CLASS_FOR_DEFAULT_VALIDATION);
+ createEAttribute(classForDefaultValidationEClass, CLASS_FOR_DEFAULT_VALIDATION__NAME);
+ createEAttribute(classForDefaultValidationEClass, CLASS_FOR_DEFAULT_VALIDATION__NOT_EMPTY);
+ createEAttribute(classForDefaultValidationEClass, CLASS_FOR_DEFAULT_VALIDATION__CAN_BE_EMPTY);
+ createEReference(classForDefaultValidationEClass, CLASS_FOR_DEFAULT_VALIDATION__NOT_NULL_REFERENCE);
+
// Create enums
enumForControlsEEnum = createEEnum(ENUM_FOR_CONTROLS);
@@ -1058,6 +1137,7 @@
initEReference(getTestContainer_ClassesForTable(), this.getClassForTable(), null, "classesForTable", null, 0, -1, TestContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getTestContainer_ObjectsForValidation(), this.getClassForValidation(), null, "objectsForValidation", null, 0, -1, TestContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getTestContainer_MultipleContained(), this.getTestContainer(), null, "multipleContained", null, 0, -1, TestContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getTestContainer_ObjectsForDefaultValidation(), this.getClassForDefaultValidation(), null, "objectsForDefaultValidation", null, 0, -1, TestContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(testEClassEClass, TestEClass.class, "TestEClass", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getTestEClass_LowercaseNameFeature(), ecorePackage.getEString(), "lowercaseNameFeature", null, 0, 1, TestEClass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
@@ -1129,8 +1209,15 @@
initEReference(getClassForTable_ClassWithName2(), this.getClassWithName(), null, "classWithName2", null, 0, 1, ClassForTable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(classForValidationEClass, ClassForValidation.class, "ClassForValidation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getClassForValidation_Name(), ecorePackage.getEString(), "name", null, 0, 1, ClassForValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEAttribute(getClassForValidation_NotEmpty(), ecorePackage.getEString(), "notEmpty", null, 0, 1, ClassForValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEClass(classForDefaultValidationEClass, ClassForDefaultValidation.class, "ClassForDefaultValidation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getClassForDefaultValidation_Name(), ecorePackage.getEString(), "name", null, 0, 1, ClassForDefaultValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getClassForDefaultValidation_NotEmpty(), ecorePackage.getEString(), "notEmpty", null, 1, 1, ClassForDefaultValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getClassForDefaultValidation_CanBeEmpty(), ecorePackage.getEString(), "canBeEmpty", null, 0, 1, ClassForDefaultValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getClassForDefaultValidation_NotNullReference(), this.getClassWithName(), null, "notNullReference", null, 1, 1, ClassForDefaultValidation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
// Initialize enums and add enum literals
initEEnum(enumForControlsEEnum, EnumForControls.class, "EnumForControls");
addEEnumLiteral(enumForControlsEEnum, EnumForControls.FIRST);
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsAdapterFactory.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsAdapterFactory.java
index 336c0eb..454329d 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsAdapterFactory.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsAdapterFactory.java
@@ -135,6 +135,10 @@
return createClassForValidationAdapter();
}
@Override
+ public Adapter caseClassForDefaultValidation(ClassForDefaultValidation object) {
+ return createClassForDefaultValidationAdapter();
+ }
+ @Override
public Adapter defaultCase(EObject object) {
return createEObjectAdapter();
}
@@ -351,6 +355,20 @@
}
/**
+ * Creates a new adapter for an object of class '{@link org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation <em>Class For Default Validation</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see org.eclipse.emf.parsley.tests.models.testmodels.ClassForDefaultValidation
+ * @generated
+ */
+ public Adapter createClassForDefaultValidationAdapter() {
+ return null;
+ }
+
+ /**
* Creates a new adapter for an object of class '{@link org.eclipse.emf.parsley.tests.models.testmodels.TestContainer <em>Test Container</em>}'.
* <!-- begin-user-doc -->
* This default implementation returns null so that we can easily ignore cases;
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsSwitch.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsSwitch.java
index e6918f9..fb2b2d9 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsSwitch.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsSwitch.java
@@ -173,6 +173,12 @@
if (result == null) result = defaultCase(theEObject);
return result;
}
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION: {
+ ClassForDefaultValidation classForDefaultValidation = (ClassForDefaultValidation)theEObject;
+ T result = caseClassForDefaultValidation(classForDefaultValidation);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
default: return defaultCase(theEObject);
}
}
@@ -388,6 +394,21 @@
}
/**
+ * Returns the result of interpreting the object as an instance of '<em>Class For Default Validation</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of '<em>Class For Default Validation</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseClassForDefaultValidation(ClassForDefaultValidation object) {
+ return null;
+ }
+
+ /**
* Returns the result of interpreting the object as an instance of '<em>Test Container</em>'.
* <!-- begin-user-doc -->
* This implementation returns null;
diff --git a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsValidator.java b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsValidator.java
index 3b1c32e..a4ac7d1 100644
--- a/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsValidator.java
+++ b/tests/org.eclipse.emf.parsley.tests.models/src/org/eclipse/emf/parsley/tests/models/testmodels/util/TestmodelsValidator.java
@@ -117,6 +117,8 @@
return validateClassForTable((ClassForTable)value, diagnostics, context);
case TestmodelsPackage.CLASS_FOR_VALIDATION:
return validateClassForValidation((ClassForValidation)value, diagnostics, context);
+ case TestmodelsPackage.CLASS_FOR_DEFAULT_VALIDATION:
+ return validateClassForDefaultValidation((ClassForDefaultValidation)value, diagnostics, context);
case TestmodelsPackage.ENUM_FOR_CONTROLS:
return validateEnumForControls((EnumForControls)value, diagnostics, context);
case TestmodelsPackage.BOOLEAN_DATA_TYPE:
@@ -288,20 +290,13 @@
if (notEmpty == null || notEmpty.length() == 0) {
if (diagnostics != null) {
diagnostics.add
- (new BasicDiagnostic
- (Diagnostic.ERROR,
- DIAGNOSTIC_SOURCE,
- 0,
- "the field 'notEmpty' cannot be empty",
- null));
-// (createDiagnostic
-// (Diagnostic.ERROR,
-// DIAGNOSTIC_SOURCE,
-// 0,
-// "_UI_GenericConstraint_diagnostic",
-// new Object[] { "NotEmpty", getObjectLabel(classForValidation, context) },
-// new Object[] { classForValidation },
-// context));
+ (new BasicDiagnostic(
+ Diagnostic.ERROR,
+ DIAGNOSTIC_SOURCE,
+ 0,
+ "the field 'notEmpty' cannot be empty",
+ new Object[] { classForValidation, TestmodelsPackage.Literals.CLASS_FOR_VALIDATION__NOT_EMPTY }
+ ));
}
return false;
} else {
@@ -309,21 +304,23 @@
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic
- (Diagnostic.WARNING,
- DIAGNOSTIC_SOURCE,
- 0,
- "the field 'notEmpty' should be more than one character",
- null));
+ (Diagnostic.WARNING,
+ DIAGNOSTIC_SOURCE,
+ 0,
+ "the field 'notEmpty' should be more than one character",
+ new Object[] { classForValidation, TestmodelsPackage.Literals.CLASS_FOR_VALIDATION__NOT_EMPTY }
+ ));
}
} else if (notEmpty.length() == 2) {
if (diagnostics != null) {
diagnostics.add
(new BasicDiagnostic
- (Diagnostic.INFO,
- DIAGNOSTIC_SOURCE,
- 0,
- "the field 'notEmpty' is two characters long",
- null));
+ (Diagnostic.INFO,
+ DIAGNOSTIC_SOURCE,
+ 0,
+ "the field 'notEmpty' is two characters long",
+ new Object[] { classForValidation, TestmodelsPackage.Literals.CLASS_FOR_VALIDATION__NOT_EMPTY }
+ ));
}
}
}
@@ -335,6 +332,15 @@
* <!-- end-user-doc -->
* @generated
*/
+ public boolean validateClassForDefaultValidation(ClassForDefaultValidation classForDefaultValidation, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ return validate_EveryDefaultConstraint(classForDefaultValidation, diagnostics, context);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public boolean validateEnumForControls(EnumForControls enumForControls, DiagnosticChain diagnostics, Map<Object, Object> context) {
return true;
}
diff --git a/tests/org.eclipse.emf.parsley.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.emf.parsley.tests/.settings/org.eclipse.jdt.core.prefs
index 5c994ac..a430548 100644
--- a/tests/org.eclipse.emf.parsley.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/org.eclipse.emf.parsley.tests/.settings/org.eclipse.jdt.core.prefs
@@ -2,8 +2,11 @@
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
@@ -16,7 +19,7 @@
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
@@ -45,12 +48,14 @@
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
diff --git a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingSubstitutionLabelProviderTest.xtend b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingSubstitutionLabelProviderTest.xtend
new file mode 100644
index 0000000..419ea73
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingSubstitutionLabelProviderTest.xtend
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - Initial contribution and API
+ *******************************************************************************/
+package org.eclipse.emf.parsley.tests
+
+import com.google.inject.Inject
+import org.eclipse.emf.ecore.EcorePackage
+import org.eclipse.emf.parsley.internal.databinding.DatabindingSubstitutionLabelProvider
+import org.eclipse.emf.parsley.junit4.AbstractEmfParsleyTest
+import org.eclipse.emf.parsley.tests.util.EmfParsleyFixturesAndUtilitiesTestRule
+import org.eclipse.emf.parsley.ui.provider.FeatureLabelCaptionProvider
+import org.eclipse.jface.viewers.ILabelProvider
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+
+import static extension org.junit.Assert.*
+
+class DatabindingSubstitutionLabelProviderTest extends AbstractEmfParsleyTest {
+
+ @Rule public extension EmfParsleyFixturesAndUtilitiesTestRule fixtures = new EmfParsleyFixturesAndUtilitiesTestRule()
+
+ @Inject
+ var ILabelProvider labelProvider
+
+ @Inject
+ var FeatureLabelCaptionProvider featureLabelCaptionProvider;
+
+ val objectForValidation = testFactory.createClassForDefaultValidation
+
+ @Before
+ def void setupUtil() {
+ getOrCreateInjector.injectMembers(this)
+ }
+
+ @Test def void testObjectLabel() {
+ val prov = new DatabindingSubstitutionLabelProvider(objectForValidation, labelProvider,
+ featureLabelCaptionProvider)
+ "Class For Default Validation".assertEquals(prov.getObjectLabel(objectForValidation))
+ }
+
+ @Test def void testFeatureLabel() {
+ val prov = new DatabindingSubstitutionLabelProvider(objectForValidation, labelProvider,
+ featureLabelCaptionProvider)
+ "Not Empty".assertEquals(prov.getFeatureLabel(testPackage.classForDefaultValidation_NotEmpty))
+ }
+
+ @Test def void testValueLabel() {
+ val prov = new DatabindingSubstitutionLabelProvider(objectForValidation, labelProvider,
+ featureLabelCaptionProvider)
+ "0".assertEquals(prov.getValueLabel(EcorePackage.eINSTANCE.EInt, "0"))
+ }
+
+}
diff --git a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingValidationUtilTest.xtend b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingValidationUtilTest.xtend
new file mode 100644
index 0000000..cc0f0d8
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DatabindingValidationUtilTest.xtend
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - Initial contribution and API
+ *******************************************************************************/
+package org.eclipse.emf.parsley.tests
+
+import com.google.inject.Inject
+import org.eclipse.emf.common.util.Diagnostic
+import org.eclipse.emf.parsley.internal.databinding.DatabindingValidationUtil
+import org.eclipse.emf.parsley.junit4.AbstractEmfParsleyTest
+import org.eclipse.emf.parsley.tests.util.EmfParsleyFixturesAndUtilitiesTestRule
+import org.eclipse.emf.parsley.validation.DiagnosticUtil
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+
+import static extension org.junit.Assert.*
+
+class DatabindingValidationUtilTest extends AbstractEmfParsleyTest {
+
+ @Rule public extension EmfParsleyFixturesAndUtilitiesTestRule fixtures = new EmfParsleyFixturesAndUtilitiesTestRule()
+
+ @Inject
+ var DatabindingValidationUtil fixture
+
+ /**
+ * Used only for formatting errors
+ */
+ @Inject
+ var DiagnosticUtil diagnosticUtil
+
+ @Before
+ def void setupUtil() {
+ getOrCreateInjector.injectMembers(this)
+ }
+
+ @Test
+ def void testDiagnosticForObjectAndFeature() {
+ val objectForValidation = testFactory.createClassForDefaultValidation
+ fixture.getDiagnostic(objectForValidation, testPackage.classForDefaultValidation_NotEmpty).
+ assertDiagnostic('''ERROR: The required feature 'Not Empty' of 'Class For Default Validation' must be set''')
+ }
+
+ @Test
+ def void testDiagnosticForObjectAndFeatureForDifferentFeature() {
+ val objectForValidation = testFactory.createClassForDefaultValidation
+ fixture.getDiagnostic(objectForValidation, testPackage.classForDefaultValidation_CanBeEmpty).
+ assertDiagnostic("")
+ }
+
+ @Test
+ def void testDiagnosticForObjectAndFeatureForSeveralObjects() {
+ val container = testFactory.createTestContainer => [
+ objectsForDefaultValidation += testFactory.createClassForDefaultValidation // this will issue an error
+ objectsForDefaultValidation += testFactory.createClassForDefaultValidation => [
+ notEmpty = "foo"
+ ]
+ ]
+ fixture.getDiagnostic(container.objectsForDefaultValidation.last,
+ testPackage.classForDefaultValidation_NotEmpty).assertDiagnostic("")
+ fixture.getDiagnostic(container.objectsForDefaultValidation.head,
+ testPackage.classForDefaultValidation_NotEmpty).
+ assertDiagnostic('''ERROR: The required feature 'Not Empty' of 'Class For Default Validation' must be set''')
+ }
+
+ @Test
+ def void testDiagnosticForObjectAndFeatureWithCustomValidator() {
+ val objectForValidation = testFactory.createClassForValidation
+ fixture.getDiagnostic(objectForValidation, testPackage.classForValidation_NotEmpty).
+ assertDiagnostic('''ERROR: the field 'notEmpty' cannot be empty''')
+ }
+
+ @Test
+ def void testDiagnosticWarningForObjectAndFeatureWithCustomValidator() {
+ val objectForValidation = testFactory.createClassForValidation => [
+ notEmpty = "a"
+ ]
+ fixture.getDiagnostic(objectForValidation, testPackage.classForValidation_NotEmpty).
+ assertDiagnostic('''WARNING: the field 'notEmpty' should be more than one character''')
+ }
+
+ @Test
+ def void testDiagnosticInfoForObjectAndFeatureWithCustomValidator() {
+ val objectForValidation = testFactory.createClassForValidation => [
+ notEmpty = "ab"
+ ]
+ fixture.getDiagnostic(objectForValidation, testPackage.classForValidation_NotEmpty).
+ assertDiagnostic('''INFO: the field 'notEmpty' is two characters long''')
+ }
+
+ def private assertDiagnostic(Iterable<Diagnostic> diagnostic, CharSequence expected) {
+ expected.toString.assertEquals(
+ diagnostic.map[diagnosticUtil.format(it)].join(System.getProperty("line.separator"))
+ )
+ }
+
+}
diff --git a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DiagnosticUtilTest.xtend b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DiagnosticUtilTest.xtend
new file mode 100644
index 0000000..efbb8b1
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/DiagnosticUtilTest.xtend
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - Initial contribution and API
+ *******************************************************************************/
+package org.eclipse.emf.parsley.tests
+
+import org.eclipse.emf.common.util.Diagnostic
+import org.eclipse.emf.parsley.junit4.AbstractEmfParsleyTest
+import org.eclipse.emf.parsley.tests.util.EmfParsleyFixturesAndUtilitiesTestRule
+import org.eclipse.emf.parsley.validation.DiagnosticUtil
+import org.eclipse.emf.parsley.validation.ValidationRunner
+import org.junit.Rule
+import org.junit.Test
+
+import static org.junit.Assert.*
+import com.google.inject.Inject
+import org.junit.Before
+import org.eclipse.emf.parsley.tests.models.testmodels.TestContainer
+
+class DiagnosticUtilTest extends AbstractEmfParsleyTest {
+
+ @Rule public extension EmfParsleyFixturesAndUtilitiesTestRule fixtures = new EmfParsleyFixturesAndUtilitiesTestRule()
+
+ @Inject
+ var DiagnosticUtil diagnosticUtil
+
+ @Inject
+ var ValidationRunner validationRunner
+
+ var TestContainer testContainer
+
+ @Before
+ def void setupDiagnostic() {
+ getOrCreateInjector.injectMembers(this)
+ testContainer = testFactory.createTestContainer => [
+ objectsForValidation += testFactory.createClassForValidation // this will issue an error
+ objectsForValidation += testFactory.createClassForValidation => [
+ notEmpty = "a" // this will issue a warning
+ ]
+ ]
+ }
+
+ @Test
+ def void testFilterErrors() {
+ val diagnostic = validationRunner.validate(testContainer)
+ assertEquals(2, diagnosticUtil.flatten(diagnostic).size)
+ val errors = diagnosticUtil.errors(diagnostic)
+ assertEquals(1, errors.size)
+ assertTrue(errors.head.severity == Diagnostic.ERROR)
+ }
+
+ @Test
+ def void testFormat() {
+ val diagnostic = validationRunner.validate(testContainer)
+ val errors = diagnosticUtil.errors(diagnostic)
+ assertEquals("ERROR: the field 'notEmpty' cannot be empty", diagnosticUtil.format(errors.head))
+ }
+
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/EmfValidationTargetToModelUpdateValueStrategyTest.xtend b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/EmfValidationTargetToModelUpdateValueStrategyTest.xtend
new file mode 100644
index 0000000..1a419be
--- /dev/null
+++ b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/EmfValidationTargetToModelUpdateValueStrategyTest.xtend
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2016 RCP Vision (http://www.rcp-vision.com) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lorenzo Bettini - Initial contribution and API
+ *******************************************************************************/
+package org.eclipse.emf.parsley.tests
+
+import com.google.inject.Inject
+import org.eclipse.emf.databinding.EMFDataBindingContext
+import org.eclipse.emf.databinding.edit.EMFEditProperties
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.EStructuralFeature
+import org.eclipse.emf.edit.domain.EditingDomain
+import org.eclipse.emf.parsley.internal.databinding.DatabindingValidationUtil
+import org.eclipse.emf.parsley.internal.databinding.EmfValidationTargetToModelUpdateValueStrategy
+import org.eclipse.emf.parsley.junit4.AbstractEmfParsleyControlBasedTest
+import org.eclipse.emf.parsley.tests.util.EmfParsleyFixturesAndUtilitiesTestRule
+import org.eclipse.emf.parsley.util.DatabindingUtil
+import org.eclipse.swt.SWT
+import org.eclipse.swt.widgets.Control
+import org.eclipse.swt.widgets.Text
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+
+import static org.junit.Assert.*
+
+/**
+ * This verifies that our custom databinding update value strategy does not interfere
+ * with model updates.
+ *
+ * @author Lorenzo Bettini
+ */
+class EmfValidationTargetToModelUpdateValueStrategyTest extends AbstractEmfParsleyControlBasedTest {
+
+ @Rule public extension EmfParsleyFixturesAndUtilitiesTestRule fixtures = new EmfParsleyFixturesAndUtilitiesTestRule()
+
+ @Inject
+ var EditingDomain editingDomain
+
+ @Inject
+ var DatabindingValidationUtil databindingValidationUtil
+
+ var EMFDataBindingContext edbc;
+
+ @Before
+ def void setupFields() {
+ getOrCreateInjector.injectMembers(this)
+ edbc = new EMFDataBindingContext();
+ }
+
+ @Test
+ def void testUpdateModelWithErrors() {
+ val o = testFactory.createClassForDefaultValidation // error: notEmpty must be set
+ val text = new Text(shell, SWT.NONE)
+ initializeDatabinding(o, text, testPackage.classForDefaultValidation_NotEmpty)
+ text.assertText("")
+ o.notEmpty = "test"
+ text.assertText("test")
+ }
+
+ @Test
+ def void testUpdateModelWithIssuesNotErrors() {
+ val o = testFactory.createClassForValidation => [
+ notEmpty = "a" // this issues a warning
+ ]
+ val text = new Text(shell, SWT.NONE)
+ initializeDatabinding(o, text, testPackage.classForValidation_NotEmpty)
+ text.assertText("a")
+ o.notEmpty = "test"
+ text.assertText("test")
+ }
+
+ @Test
+ def void testUpdateTargetWithStringUpdatesModel() {
+ val o = testFactory.createClassForDefaultValidation
+ val text = new Text(shell, SWT.NONE)
+ initializeDatabinding(o, text, testPackage.classForDefaultValidation_NotEmpty)
+ text.assertText("")
+ text.modifyText("test")
+ assertEquals("test", o.notEmpty)
+ }
+
+ @Test
+ def void testUpdateTargetWithEmptyStringUpdatesModelWithNull() {
+ val o = testFactory.createClassForDefaultValidation => [
+ notEmpty = "test"
+ ]
+ val text = new Text(shell, SWT.NONE)
+ initializeDatabinding(o, text, testPackage.classForDefaultValidation_NotEmpty)
+ text.assertText("test")
+ text.modifyText("")
+ assertNull(o.notEmpty)
+ }
+
+ def private initializeDatabinding(EObject o, Control control, EStructuralFeature feature) {
+ val target = DatabindingUtil.observeText(control, SWT.Modify)
+ val source = EMFEditProperties.value(editingDomain, feature).observe(o);
+ val targetToModelUpdateValueStrategy =
+ new EmfValidationTargetToModelUpdateValueStrategy(
+ o, feature, databindingValidationUtil);
+
+ edbc.bindValue(
+ target, source, targetToModelUpdateValueStrategy,
+ null);
+ }
+}
\ No newline at end of file
diff --git a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/ValidationRunnerTest.xtend b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/ValidationRunnerTest.xtend
index d7fa11b..0906c87 100644
--- a/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/ValidationRunnerTest.xtend
+++ b/tests/org.eclipse.emf.parsley.tests/src/org/eclipse/emf/parsley/tests/ValidationRunnerTest.xtend
@@ -8,10 +8,8 @@
import org.eclipse.emf.parsley.validation.ValidationRunner
import org.junit.Rule
import org.junit.Test
-import org.eclipse.emf.parsley.validation.DiagnosticUtil
import static extension org.junit.Assert.*
-import org.eclipse.emf.common.util.Diagnostic
class ValidationRunnerTest extends AbstractEmfParsleyTest {
@@ -27,6 +25,25 @@
}
@Test
+ def void testValidateObjectDefault() {
+ // standard Ecore validation
+ val objectForValidation = testFactory.createClassForDefaultValidation
+ createValidationRunner.validate(objectForValidation, createLogIssueReporter)
+ logAppender.assertContainsMessage("The required feature 'notEmpty'")
+ }
+
+ @Test
+ def void testValidateObjectDefaultOk() {
+ // standard Ecore validation
+ val objectForValidation = testFactory.createClassForDefaultValidation => [
+ notEmpty = "foo"
+ notNullReference = testFactory.createClassWithName
+ ]
+ createValidationRunner.validate(objectForValidation, createLogIssueReporter)
+ logAppender.assertEmpty
+ }
+
+ @Test
def void testValidateContents() {
val container = testFactory.createTestContainer => [
objectsForValidation += testFactory.createClassForValidation
@@ -93,22 +110,6 @@
createValidationRunner.validate(objectForValidation, createLogIssueReporter).size)
}
- @Test
- def void testFilterErrors() {
- val container = testFactory.createTestContainer => [
- objectsForValidation += testFactory.createClassForValidation // this will issue an error
- objectsForValidation += testFactory.createClassForValidation => [
- notEmpty = "a" // this will issue a warning
- ]
- ]
- val diagnostic = createValidationRunner.validate(container)
- val diagnosticUtil = createDiagnosticUtil
- assertEquals(2, diagnosticUtil.flatten(diagnostic).size)
- val errors = diagnosticUtil.errors(diagnostic)
- assertEquals(1, errors.size)
- assertTrue(errors.head.severity == Diagnostic.ERROR)
- }
-
def private createValidationRunner() {
getOrCreateInjector.getInstance(ValidationRunner)
}
@@ -116,8 +117,4 @@
def private createLogIssueReporter() {
getOrCreateInjector.getInstance(LogIssueReporter)
}
-
- def private createDiagnosticUtil() {
- getOrCreateInjector.getInstance(DiagnosticUtil)
- }
}
\ No newline at end of file