Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2021-02-02 18:48:39 +0000
committerChristian W. Damus2021-03-01 13:55:15 +0000
commit86f53a28e0148ede07254bac51dc97c0bf7b5d15 (patch)
tree3052709c09317cbb33ef815a7d2b828a43433d61
parentf6f10bb6d31b0e0e76e28a33be170bbf276eed4e (diff)
downloadorg.eclipse.papyrus-committers/vlorenzo/568494-initial_Work.tar.gz
org.eclipse.papyrus-committers/vlorenzo/568494-initial_Work.tar.xz
org.eclipse.papyrus-committers/vlorenzo/568494-initial_Work.zip
Bug 570856: [Toolsmiths][AF] Improve messages for command-class constraintscommitters/vlorenzo/568494-initial_Workbugs/568494-toolsmiths-dev
- introduce custom messages for problems in the command class attributes - includes a second step to distinguish diagnosis of missing class versus a class that doesn't implement the expected protocol - requires generation of the plug-in class for the Papyrus Representation model - update existing JUnit tests to accommodate new diagnostic messages Change-Id: I351466b561700fdcda68d23b1385821d4d8fc1a9 Signed-off-by: Christian W. Damus <give.a.damus@gmail.com>
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/plugin.properties6
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java26
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src/org/eclipse/papyrus/infra/core/architecture/util/ArchitectureCommandUtils.java30
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/model/GmfDiagRepresentation.genmodel5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/plugin.properties6
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java13
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/RepresentationPlugin.java104
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/util/RepresentationValidator.java9
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java9
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/AuxProject.java4
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/OverlayFile.java9
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProject.java6
-rw-r--r--tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProjectFixture.java17
14 files changed, 215 insertions, 30 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/plugin.properties b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/plugin.properties
index 6055ab0689f..2ab38948aae 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/plugin.properties
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/plugin.properties
@@ -14,3 +14,9 @@
pluginName = Architecture Model
providerName=Eclipse Modeling Project
+
+_UI_creationCommandClassExists_diagnostic = Model creation command of ''{0}'' is not found in the Java classpath.
+_UI_creationCommandClassConforms_diagnostic = Model creation command of ''{0}'' does not implement the {1} interface.
+_UI_genericRequiredInterface_name = required
+_UI_conversionCommandClassExists_diagnostic = Model conversion command of ''{0}'' is not found in the Java classpath.
+_UI_conversionCommandClassConforms_diagnostic = Model conversion command of ''{0}'' does not implement the {1} interface.
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
index dcfd450eddd..bd2f7121ecd 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src-gen/org/eclipse/papyrus/infra/core/architecture/impl/ArchitectureContextImpl.java
@@ -1,5 +1,5 @@
/**
-* Copyright (c) 2017, 2021 CEA LIST, Christian W. Damus, and others.
+ * Copyright (c) 2017, 2021 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,8 +10,7 @@
*
* Contributors:
* Maged Elaasar - Initial API and implementation
- * Christian W. Damus - bug, 539694
- *
+ * Christian W. Damus - bugs 539694, 570856
*
*/
package org.eclipse.papyrus.infra.core.architecture.impl;
@@ -29,7 +28,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EObjectValidator;
@@ -294,13 +292,19 @@ public abstract class ArchitectureContextImpl extends ADElementImpl implements A
if (!exists) {
if (diagnostics != null) {
+ // Further narrow the problem
+ String problem = ArchitectureCommandUtils.getCommandClassUnconstrained(this, ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CREATION_COMMAND_CLASS) == null
+ ? "_UI_creationCommandClassExists_diagnostic" : "_UI_creationCommandClassConforms_diagnostic"; //$NON-NLS-1$//$NON-NLS-2$
+ String expectedInterface = ArchitectureCommandUtils.getCommandType( ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CREATION_COMMAND_CLASS)
+ .map(Class::getSimpleName).orElse(ArchitecturePlugin.INSTANCE.getString("_UI_genericRequiredInterface_name")); //$NON-NLS-1$
+
diagnostics.add
(new BasicDiagnostic
(Diagnostic.ERROR,
ArchitectureValidator.DIAGNOSTIC_SOURCE,
ArchitectureValidator.ARCHITECTURE_CONTEXT__CEATION_COMMAND_CLASS_EXISTS,
- EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ceationCommandClassExists", EObjectValidator.getObjectLabel(this, context) }), //$NON-NLS-1$ //$NON-NLS-2$
- new Object [] { this }));
+ ArchitecturePlugin.INSTANCE.getString(problem, new Object[] { EObjectValidator.getObjectLabel(this, context), expectedInterface }),
+ new Object [] { this, ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CREATION_COMMAND_CLASS }));
}
return false;
}
@@ -322,13 +326,19 @@ public abstract class ArchitectureContextImpl extends ADElementImpl implements A
if (!exists) {
if (diagnostics != null) {
+ // Further narrow the problem
+ String problem = ArchitectureCommandUtils.getCommandClassUnconstrained(this, ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CONVERSION_COMMAND_CLASS) == null
+ ? "_UI_conversionCommandClassExists_diagnostic" : "_UI_conversionCommandClassConforms_diagnostic"; //$NON-NLS-1$//$NON-NLS-2$
+ String expectedInterface = ArchitectureCommandUtils.getCommandType( ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CONVERSION_COMMAND_CLASS)
+ .map(Class::getSimpleName).orElse(ArchitecturePlugin.INSTANCE.getString("_UI_genericRequiredInterface_name")); //$NON-NLS-1$
+
diagnostics.add
(new BasicDiagnostic
(Diagnostic.ERROR,
ArchitectureValidator.DIAGNOSTIC_SOURCE,
ArchitectureValidator.ARCHITECTURE_CONTEXT__CONVERSION_COMMAND_CLASS_EXISTS,
- EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "conversionCommandClassExists", EObjectValidator.getObjectLabel(this, context) }), //$NON-NLS-1$ //$NON-NLS-2$
- new Object [] { this }));
+ ArchitecturePlugin.INSTANCE.getString(problem, new Object[] { EObjectValidator.getObjectLabel(this, context), expectedInterface }),
+ new Object [] { this, ArchitecturePackage.Literals.ARCHITECTURE_CONTEXT__CONVERSION_COMMAND_CLASS }));
}
return false;
}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src/org/eclipse/papyrus/infra/core/architecture/util/ArchitectureCommandUtils.java b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src/org/eclipse/papyrus/infra/core/architecture/util/ArchitectureCommandUtils.java
index 4f9845b3217..85ce994b604 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src/org/eclipse/papyrus/infra/core/architecture/util/ArchitectureCommandUtils.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core.architecture/src/org/eclipse/papyrus/infra/core/architecture/util/ArchitectureCommandUtils.java
@@ -90,7 +90,8 @@ public class ArchitectureCommandUtils {
}
/**
- * Get the command class referenced by the given feature of an architecture model object.
+ * Get the command class referenced by the given feature of an architecture model object, if it
+ * conforms to constraints (if any) declared in the Ecore model.
*
* @param modelObject
* the architecture model object for which to load a command class
@@ -103,9 +104,17 @@ public class ArchitectureCommandUtils {
* {@code IType}, depending whether JDT is available
*/
public static Object getCommandClass(EObject modelObject, EStructuralFeature commandClassFeature) {
+ return getCommandClass(modelObject, commandClassFeature, getCommandType(commandClassFeature));
+ }
+
+ private static Object getCommandClass(EObject modelObject, EStructuralFeature commandClassFeature, Optional<Class<?>> registeredType) {
if (commandClassFeature.getEType().getInstanceClass() == Class.class) {
// Easy
- return modelObject.eGet(commandClassFeature);
+ Class<?> result = (Class<?>) modelObject.eGet(commandClassFeature);
+ if (result != null && registeredType.isPresent() && !registeredType.get().isAssignableFrom(result)) {
+ result = null;
+ }
+ return result;
}
String className = Optional.ofNullable(modelObject.eGet(commandClassFeature)).map(String::valueOf).orElse(null);
@@ -114,10 +123,25 @@ public class ArchitectureCommandUtils {
return null;
}
- Optional<Class<?>> registeredType = getCommandType(commandClassFeature);
URI context = EcoreUtil.getURI(modelObject).trimFragment();
return ClasspathHelper.INSTANCE.findClass(className, context, registeredType.orElse(null));
}
+ /**
+ * Get the command class referenced by the given feature of an architecture model object, not considering
+ * any constraints imposed on it by the Ecore model.
+ *
+ * @param modelObject
+ * the architecture model object for which to load a command class
+ * @param commandClassFeature
+ * the model feature that names the command class
+ * @return
+ * the referenced class, or {@code null} if the class doesn't exist. The result may be a Java
+ * {@link Class} or a JDT {@code IType}, depending whether JDT is available
+ */
+ public static Object getCommandClassUnconstrained(EObject modelObject, EStructuralFeature commandClassFeature) {
+ return getCommandClass(modelObject, commandClassFeature, Optional.empty());
+ }
+
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/META-INF/MANIFEST.MF
index eee60eb3771..d2b7cdca75b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/META-INF/MANIFEST.MF
@@ -4,6 +4,7 @@ Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.representation;singleton:=true
Bundle-Version: 3.0.0.qualifier
Bundle-ClassPath: .
+Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.representation.impl.RepresentationPlugin$Implementation
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/model/GmfDiagRepresentation.genmodel b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/model/GmfDiagRepresentation.genmodel
index daf57934142..735a11367e1 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/model/GmfDiagRepresentation.genmodel
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/model/GmfDiagRepresentation.genmodel
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
- xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2017 CEA LIST.&#xA;&#xA; All rights reserved. This program and the accompanying materials&#xA; are made available under the terms of the Eclipse Public License 2.0&#xA; which accompanies this distribution, and is available at&#xA; https://www.eclipse.org/legal/epl-2.0/&#xA;&#xA; SPDX-License-Identifier: EPL-2.0&#xA;&#xA; Contributors:&#xA; Maged Elaasar - Initial API and implementation"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" copyrightText="Copyright (c) 2017, 2021 CEA LIST.&#xA;&#xA;All rights reserved. This program and the accompanying materials&#xA;are made available under the terms of the Eclipse Public License 2.0&#xA;which accompanies this distribution, and is available at&#xA;https://www.eclipse.org/legal/epl-2.0/&#xA;&#xA;SPDX-License-Identifier: EPL-2.0&#xA;&#xA;Contributors:&#xA;Maged Elaasar - Initial API and implementation"
modelDirectory="/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen" editDirectory="/org.eclipse.papyrus.infra.gmfdiag.representation.edit/src-gen"
editorDirectory="/org.eclipse.papyrus.infra.gmfdiag.representation.editor/src-gen"
modelPluginID="org.eclipse.papyrus.infra.gmfdiag.representation" modelName="Representation"
+ modelPluginClass="org.eclipse.papyrus.infra.gmfdiag.representation.impl.RepresentationPlugin"
nonNLSMarkers="true" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container"
testsDirectory="/org.eclipse.papyrus.infra.gmfdiag.representation.tests/src-gen"
- importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false"
+ importerID="org.eclipse.emf.importer.ecore" complianceLevel="11.0" copyrightFields="false"
editPluginID="org.eclipse.papyrus.infra.gmfdiag.representation.edit" editorPluginID="org.eclipse.papyrus.infra.gmfdiag.representation.editor"
usedGenPackages="../../org.eclipse.papyrus.infra.core.architecture/model/Architecture.genmodel#//architecture ../../org.eclipse.papyrus.infra.constraints/Model/Constraints.genmodel#//constraints ../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore ../../org.eclipse.papyrus.infra.types/model/ElementTypesConfigurations.genmodel#//types ../../org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration/model/PaletteConfiguration.genmodel#//paletteconfiguration ../../org.eclipse.papyrus.infra.architecture.representation/model/Representation.genmodel#//representation ../../org.eclipse.papyrus.infra.filters/model/filters.genmodel#//filters ../../org.eclipse.uml2.types/model/Types.genmodel#//types"
operationReflection="true" importOrganizing="true">
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/plugin.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/plugin.properties
index a001acc8c50..6848c219d70 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/plugin.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/plugin.properties
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 CEA LIST.
+# Copyright (c) 2017, 2021 CEA LIST, Christian W. Damus, and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License 2.0
@@ -9,8 +9,12 @@
#
# Contributors:
# Maged Elaasar - Initial API and implementation
+# Christian W. Damus - bug 570856
#
#
pluginName = GMF Representation Model
providerName = Eclipse Modeling Project
+
+_UI_creationCommandClassExists_diagnostic = Creation command of ''{0}'' is not found in the Java classpath.
+_UI_creationCommandClassConforms_diagnostic = Creation command of ''{0}'' does not implement the {1} interface.
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
index 8d2176dc087..d49a01a82f7 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/PapyrusDiagramImpl.java
@@ -10,7 +10,7 @@
*
* Contributors:
* Maged Elaasar - Initial API and implementation
- * Christian W. Damus - bug 539694
+ * Christian W. Damus - bugs 539694, 570856
*
*
*/
@@ -29,7 +29,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EObjectValidator;
@@ -261,13 +260,19 @@ public class PapyrusDiagramImpl extends PapyrusRepresentationKindImpl implements
if (!exists) {
if (diagnostics != null) {
+ // Further narrow the problem
+ String problem = ArchitectureCommandUtils.getCommandClassUnconstrained(this, RepresentationPackage.Literals.PAPYRUS_DIAGRAM__CREATION_COMMAND_CLASS) == null
+ ? "_UI_creationCommandClassExists_diagnostic" : "_UI_creationCommandClassConforms_diagnostic"; //$NON-NLS-1$//$NON-NLS-2$
+ String expectedInterface = ArchitectureCommandUtils.getCommandType( RepresentationPackage.Literals.PAPYRUS_DIAGRAM__CREATION_COMMAND_CLASS)
+ .map(Class::getSimpleName).orElse(RepresentationPlugin.INSTANCE.getString("_UI_genericRequiredInterface_name")); //$NON-NLS-1$
+
diagnostics.add
(new BasicDiagnostic
(Diagnostic.ERROR,
RepresentationValidator.DIAGNOSTIC_SOURCE,
RepresentationValidator.PAPYRUS_DIAGRAM__CEATION_COMMAND_CLASS_EXISTS,
- EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ceationCommandClassExists", EObjectValidator.getObjectLabel(this, context) }), //$NON-NLS-1$ //$NON-NLS-2$
- new Object [] { this }));
+ RepresentationPlugin.INSTANCE.getString(problem, new Object[] { EObjectValidator.getObjectLabel(this, context), expectedInterface }),
+ new Object [] { this, RepresentationPackage.Literals.PAPYRUS_DIAGRAM__CREATION_COMMAND_CLASS }));
}
return false;
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/RepresentationPlugin.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/RepresentationPlugin.java
new file mode 100644
index 00000000000..c55c96dbe79
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/impl/RepresentationPlugin.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2021 Christian W. Damus, CEA LIST, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ */
+package org.eclipse.papyrus.infra.gmfdiag.representation.impl;
+
+import org.eclipse.emf.common.EMFPlugin;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.papyrus.infra.core.architecture.impl.ArchitecturePlugin;
+
+/**
+ * This is the central singleton for the Representation model plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public final class RepresentationPlugin extends EMFPlugin {
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final RepresentationPlugin INSTANCE = new RepresentationPlugin();
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Implementation plugin;
+
+ /**
+ * Create the instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ public RepresentationPlugin() {
+ // Customized to delegate look-up of translatable strings to the
+ // Architecture plug-in to get strings defined in its plugin.properties
+ // that are reused in validation problem messages in this model
+ // (e.g., the message for the PapyrusDiagram::ceationCommandClassExists
+ // constraint, cf. bug 570856)
+ super(new ResourceLocator [] { ArchitecturePlugin.INSTANCE });
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Implementation extends EclipsePlugin {
+ /**
+ * Creates an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/util/RepresentationValidator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/util/RepresentationValidator.java
index d80b5fd7cbb..a95800dcc31 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/util/RepresentationValidator.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.representation/src-gen/org/eclipse/papyrus/infra/gmfdiag/representation/util/RepresentationValidator.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2017 CEA LIST.
+ * Copyright (c) 2017, 2021 CEA LIST, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* Maged Elaasar - Initial API and implementation
+ * Christian W. Damus - bug 570856
*
*
*/
@@ -27,6 +28,7 @@ import org.eclipse.emf.ecore.util.EObjectValidator;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.papyrus.infra.gmfdiag.representation.*;
+import org.eclipse.papyrus.infra.gmfdiag.representation.impl.RepresentationPlugin;
/**
* <!-- begin-user-doc -->
@@ -207,10 +209,7 @@ public class RepresentationValidator extends EObjectValidator {
*/
@Override
public ResourceLocator getResourceLocator() {
- // TODO
- // Specialize this to return a resource locator for messages specific to this validator.
- // Ensure that you remove @generated or mark it @generated NOT
- return super.getResourceLocator();
+ return RepresentationPlugin.INSTANCE;
}
} //RepresentationValidator
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
index 9891ce616e0..2d1a33af896 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.architecture.tests/src/org/eclipse/papyrus/toolsmiths/validation/architecture/tests/ArchitectureModelBuilderTest.java
@@ -14,6 +14,7 @@
*****************************************************************************/
package org.eclipse.papyrus.toolsmiths.validation.architecture.tests;
+import static org.eclipse.papyrus.junit.matchers.MoreMatchers.regexContains;
import static org.eclipse.papyrus.junit.matchers.WorkspaceMatchers.isMarkerMessage;
import static org.eclipse.papyrus.junit.matchers.WorkspaceMatchers.isMarkerSeverity;
import static org.eclipse.papyrus.toolsmiths.validation.architecture.constants.ArchitecturePluginValidationConstants.ARCHITECTURE_PLUGIN_VALIDATION_MARKER_TYPE;
@@ -63,7 +64,8 @@ public class ArchitectureModelBuilderTest extends AbstractPapyrusTest {
public void unresolvedCreationCommandClass() {
final List<IMarker> modelMarkers = fixture.getMarkers("resources/BookStore.architecture"); //$NON-NLS-1$
- assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(containsString("ceationCommandClassExists")/* sic */)))); //$NON-NLS-1$
+ assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(
+ regexContains("Model creation command .* not found in the Java classpath"))))); //$NON-NLS-1$
}
/**
@@ -74,7 +76,8 @@ public class ArchitectureModelBuilderTest extends AbstractPapyrusTest {
public void invalidCreationCommandClass() {
final List<IMarker> modelMarkers = fixture.getMarkers("resources/BookStore.architecture"); //$NON-NLS-1$
- assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(containsString("conversionCommandClassExists"))))); //$NON-NLS-1$
+ assertThat(modelMarkers, hasItem(both(isMarkerSeverity(IMarker.SEVERITY_ERROR)).and(isMarkerMessage(
+ regexContains("Model conversion command .* the IModelConversionCommand interface"))))); //$NON-NLS-1$
}
/**
@@ -89,7 +92,7 @@ public class ArchitectureModelBuilderTest extends AbstractPapyrusTest {
public void creationCommandClassBinaryTypeResolved() {
final List<IMarker> modelMarkers = fixture.getMarkers("META-INF/MANIFEST.MF"); //$NON-NLS-1$
- assertThat(modelMarkers, not(hasItem(isMarkerMessage(containsString("ceationCommandClassExists")/* sic */)))); //$NON-NLS-1$
+ assertThat(modelMarkers, not(hasItem(isMarkerMessage(containsString("creation command"))))); //$NON-NLS-1$
}
}
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/AuxProject.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/AuxProject.java
index 9279a806151..de5fe09e1e9 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/AuxProject.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/AuxProject.java
@@ -23,7 +23,9 @@ import java.lang.annotation.Target;
/**
* Annotates a test or test class with an auxiliary project to import after importing
- * the text project (thus it may depend on the test project).
+ * the test project (thus it may depend on the test project). This is useful for tests
+ * that verify validation rules that apply to project dependencies, class paths, or
+ * other scenarios that cannot be tested in just a single project.
*
* @see TestProjectFixture
* @see TestProject
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/OverlayFile.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/OverlayFile.java
index 2a1992b3d00..39a8a0519b0 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/OverlayFile.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/OverlayFile.java
@@ -22,8 +22,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
+ * <p>
* Annotates a test or test class with a file to overlay on the {@link TestProject project content}
- * after that has initially been populated.
+ * after that has initially been populated. The file may already exist in the base project template,
+ * in which case it is replaced with new content, or it may be added as a new file in the project.
+ * </p>
+ * <p>
+ * Note that, currently, only the main test project may
+ * have files added or replaced by this mechanism
+ * </p>
*
* @see TestProjectFixture
*/
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProject.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProject.java
index acdc8229ff4..644ad1f873d 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProject.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProject.java
@@ -21,7 +21,11 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Annotates a test or test class with a path to the content to copy into the project.
+ * Annotates a test or test class with a path to content to copy into the main
+ * test project. That project is created by the {@link TestProjectFixture} with
+ * a name based on the test name, so this annotation does not set the name of
+ * the test project. It just specifies a folder in the bundle resources from
+ * which to copy files into the test project.
*
* @see TestProjectFixture
*/
diff --git a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProjectFixture.java b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProjectFixture.java
index 019d8226a18..64a28eaf453 100644
--- a/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProjectFixture.java
+++ b/tests/junit/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.validation.common.tests/src/org/eclipse/papyrus/toolsmiths/validation/common/tests/rules/TestProjectFixture.java
@@ -64,8 +64,23 @@ import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/**
+ * <p>
* A project fixture that copies initial content into the project and ensures that the project name
- * matches the bundle symbolic name if the project is a bundle project.
+ * matches the bundle symbolic name if the project is a bundle project. The base contents of the
+ * test project are specified by the {@link TestProject @TestProject} annotation. Additional contents
+ * may overlaid* to replace or add files via one or more {@link OverlayFile @OverlayFile} annotations.
+ * Additional projects may be created for the duration of the test via {@link AuxProject @AuxProject}
+ * annotations.
+ * </p>
+ * <p>
+ * The fixture may be configured to build the project before running the test, to prepare problem
+ * markers for verification. Use the {@link Build @Build} annotation for this.
+ * </p>
+ *
+ * @see TestProject
+ * @see OverlayFile
+ * @see AuxProject
+ * @see Build
*/
public class TestProjectFixture extends ProjectFixture {

Back to the top