Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2016-01-13 14:25:31 +0000
committerAnsgar Radermacher2016-01-13 15:58:21 +0000
commit3741892d2df4b5c60f977d87e2008f271b6d00cb (patch)
tree620cac4767bcf48ad9943d846bf7db00d6ff84a3 /plugins/infra/services
parent4bd8d77dc28c0a26398a4b7419968ea234754d95 (diff)
downloadorg.eclipse.papyrus-3741892d2df4b5c60f977d87e2008f271b6d00cb.tar.gz
org.eclipse.papyrus-3741892d2df4b5c60f977d87e2008f271b6d00cb.tar.xz
org.eclipse.papyrus-3741892d2df4b5c60f977d87e2008f271b6d00cb.zip
Bug 408215 - [OCL] Loaded Complete OCL resource does not contribute to validation
Move some classes to internal sub-package Add UML specific validation commands (avoid exposure to UMLDiagnostician) Use registry to associate a suitable diagnostician for a given model Change-Id: I1f1ec6999dff3e8585b10aacea44f1769352f3f8
Diffstat (limited to 'plugins/infra/services')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF1
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/build.properties3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml1
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/schema/diagnosticians.exsd76
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java8
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AsyncValidateSubtreeCommand.java12
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java14
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateSubtreeCommand.java18
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromModelCommand.java18
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromSubtreeCommand.java18
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java15
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateSubtreeCommand.java12
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateModelHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateSubtreeHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromModelHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromSubtreeHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateModelHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateSubtreeHandler.java3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EValidatorAdapter.java (renamed from plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java)2
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EcoreDiagnostician.java (renamed from plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EcoreDiagnostician.java)3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/ValidationRegistry.java92
21 files changed, 288 insertions, 23 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
index 32278da8e01..6de36ac057f 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/META-INF/MANIFEST.MF
@@ -2,6 +2,7 @@ Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.infra.services.validation,
org.eclipse.papyrus.infra.services.validation.commands,
org.eclipse.papyrus.infra.services.validation.handler,
+ org.eclipse.papyrus.infra.services.validation.internal;x-friends:="org.eclipse.papyrus.uml.service.validation",
org.eclipse.papyrus.infra.services.validation.preferences
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/build.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/build.properties
index 0b6402711a2..8e1f07ccf86 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/build.properties
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/build.properties
@@ -5,7 +5,8 @@ bin.includes = META-INF/,\
about.html,\
plugin.properties,\
plugin.xml,\
- icons/
+ icons/,\
+ schema/
output..=bin/
src.includes = about.html
source..=src/
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
index 40a43ec339c..8e66ac2ee45 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/plugin.xml
@@ -2,6 +2,7 @@
<?eclipse version="3.4"?>
<plugin>
+ <extension-point id="diagnosticians" name="Registered diagnostician" schema="schema/diagnostician.exsd"/>
<extension
point="org.eclipse.ui.preferencePages">
<page
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/schema/diagnosticians.exsd b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/schema/diagnosticians.exsd
new file mode 100644
index 00000000000..31b2c056fa1
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/schema/diagnosticians.exsd
@@ -0,0 +1,76 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.services.validation" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.services.validation" id="diagnostician" name="Registered diagnostician"/>
+ </appinfo>
+ <documentation>
+ Manage the relation between a language (such as UML) and the associated diagnostician
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="diagnostician" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="diagnostician">
+ <annotation>
+ <documentation>
+ Specifies a diagnostician for a given language ID
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="class" type="string">
+ <annotation>
+ <documentation>
+ The name of a class implementing the interface IPapyrusDiagnostician.
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.services.validation.IPapyrusDiagnostician"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ An unique identifier for the language. Must match the ID of the language that is configured via the language service from papyrus.infra.core
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+</schema>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
index 9358abb41e3..e027ba2866c 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AbstractValidateCommand.java
@@ -35,11 +35,11 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.IPapyrusDiagnostician;
import org.eclipse.papyrus.infra.services.validation.Messages;
import org.eclipse.papyrus.infra.services.validation.ValidationTool;
import org.eclipse.papyrus.infra.services.validation.ValidationUtils;
+import org.eclipse.papyrus.infra.services.validation.internal.ValidationRegistry;
import org.eclipse.papyrus.infra.services.validation.preferences.PreferenceUtils;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -83,7 +83,7 @@ abstract public class AbstractValidateCommand extends AbstractTransactionalComma
* the selected element
*/
public AbstractValidateCommand(String label, TransactionalEditingDomain domain, EObject selectedElement) {
- this(label, domain, selectedElement, new EcoreDiagnostician());
+ this(label, domain, selectedElement, null);
}
/**
@@ -130,6 +130,9 @@ abstract public class AbstractValidateCommand extends AbstractTransactionalComma
protected void runValidation(final EObject validateElement) {
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ if (diagnostician == null) {
+ diagnostician = ValidationRegistry.getDiagnostician(selectedElement);
+ }
ValidationOperation runValidationWithProgress = new ValidationOperation(validateElement, this);
@@ -138,7 +141,6 @@ abstract public class AbstractValidateCommand extends AbstractTransactionalComma
public void run(final IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
handleDiagnostic(progressMonitor, diagnostic, validateElement, shell);
-
} finally {
progressMonitor.done();
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AsyncValidateSubtreeCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AsyncValidateSubtreeCommand.java
index f6bd310f794..a0caa963e01 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AsyncValidateSubtreeCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/AsyncValidateSubtreeCommand.java
@@ -30,12 +30,22 @@ import org.eclipse.swt.widgets.Display;
public class AsyncValidateSubtreeCommand extends ValidateSubtreeCommand {
/**
+ * Constructor for validation with EcoreDiagnostician
+ *
+ * @param selectedElement
+ * the element from which on a subtree should be validated
+ */
+ public AsyncValidateSubtreeCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
* Constructor based on selected element and diagnostician
*
* @param selectedElement
* the element from which on a subtree should be validated
* @param diagnostician
- * the diagnostician (e.g. UMLDiagnostician)
+ * the diagnostician (e.g. EcoreDiagnostician)
*/
public AsyncValidateSubtreeCommand(EObject selectedElement,
IPapyrusDiagnostician diagnostician) {
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
index bf4059efece..7c59a9d8beb 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
@@ -33,10 +33,22 @@ import org.eclipse.ui.dialogs.PreferencesUtil;
public class SelectAndValidateModelCommand extends AbstractValidateCommand {
/**
+ * Constructor for validation with EcoreDiagnostician
*
- * Constructor.
+ * @param selectedElement
+ * an element of the model to validate
+ */
+ public SelectAndValidateModelCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
+ * Constructor based on selected element and diagnostician
*
* @param selectedElement
+ * an element of the model to validate
+ * @param diagnostician
+ * the diagnostician (e.g. EcoreDiagnostician)
*/
public SelectAndValidateModelCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateModelCommand_ValidateModel, TransactionUtil.getEditingDomain(selectedElement), getTopOwner(selectedElement), diagnostician);
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateSubtreeCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateSubtreeCommand.java
index 3f9d3d780e5..c0468afafea 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateSubtreeCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateSubtreeCommand.java
@@ -29,6 +29,24 @@ import org.eclipse.ui.dialogs.PreferencesUtil;
public class SelectAndValidateSubtreeCommand extends AbstractValidateCommand {
+ /**
+ * Constructor for validation with EcoreDiagnostician
+ *
+ * @param selectedElement
+ * the element from which on a subtree should be validated
+ */
+ public SelectAndValidateSubtreeCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
+ * Constructor based on selected element and diagnostician
+ *
+ * @param selectedElement
+ * the element from which on a subtree should be validated
+ * @param diagnostician
+ * the diagnostician (e.g. EcoreDiagnostician)
+ */
public SelectAndValidateSubtreeCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateSubtreeCommand_ValidateSubtree, TransactionUtil.getEditingDomain(selectedElement), selectedElement, diagnostician);
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromModelCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromModelCommand.java
index 4c46bd17e92..011038d8916 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromModelCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromModelCommand.java
@@ -32,6 +32,24 @@ import org.eclipse.papyrus.infra.services.validation.Messages;
public class ValidateDelMarkersFromModelCommand extends AbstractValidateCommand {
+ /**
+ * Constructor with EcoreDiagnostician
+ *
+ * @param selectedElement
+ * an element of the model from which to remove markers
+ */
+ public ValidateDelMarkersFromModelCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param selectedElement
+ * an element of the model from which to remove markers
+ * @param diagnostician
+ * the diagnostician (e.g. EcoreDiagnostician)
+ */
public ValidateDelMarkersFromModelCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateDelMarkersFromModelCommand_DeleteMarkersFromModel, TransactionUtil.getEditingDomain(selectedElement), selectedElement, diagnostician);
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromSubtreeCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromSubtreeCommand.java
index 06d89578b70..ae69586918d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromSubtreeCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateDelMarkersFromSubtreeCommand.java
@@ -27,6 +27,24 @@ import org.eclipse.papyrus.infra.services.validation.ValidationTool;
public class ValidateDelMarkersFromSubtreeCommand extends AbstractValidateCommand {
+ /**
+ * Constructor with EcoreDiagnostician
+ *
+ * @param selectedElement
+ * the root of the subtree from which to remove markers
+ */
+ public ValidateDelMarkersFromSubtreeCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param selectedElement
+ * the root of the subtree from which to remove markers
+ * @param diagnostician
+ * the diagnostician (e.g. EcoreDiagnostician)
+ */
public ValidateDelMarkersFromSubtreeCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateDelMarkersFromSubtreeCommand_DelMarkersFromSubtree, TransactionUtil.getEditingDomain(selectedElement), selectedElement, diagnostician);
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
index 84f3f5adbfe..876db37c98d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
@@ -31,16 +31,27 @@ import org.eclipse.papyrus.infra.services.validation.Messages;
public class ValidateModelCommand extends AbstractValidateCommand {
/**
+ * Constructor for validation with EcoreDiagnostician
*
- * Constructor.
+ * @param selectedElement
+ * an element of the model to validate
+ */
+ public ValidateModelCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
+ * Constructor based on selected element and diagnostician
*
* @param selectedElement
+ * an element of the model to validate
+ * @param diagnostician
+ * the diagnostician (e.g. EcoreDiagnostician)
*/
public ValidateModelCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateModelCommand_ValidateModel, TransactionUtil.getEditingDomain(selectedElement), getTopOwner(selectedElement), diagnostician);
}
-
/**
* get the root element
*
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateSubtreeCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateSubtreeCommand.java
index 60932297b29..1f5526adb1d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateSubtreeCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateSubtreeCommand.java
@@ -30,12 +30,22 @@ import org.eclipse.papyrus.infra.services.validation.Messages;
public class ValidateSubtreeCommand extends AbstractValidateCommand {
/**
+ * Constructor for validation with EcoreDiagnostician
+ *
+ * @param selectedElement
+ * the element from which on a subtree should be validated
+ */
+ public ValidateSubtreeCommand(EObject selectedElement) {
+ this(selectedElement, null);
+ }
+
+ /**
* Constructor based on selected element and diagnostician
*
* @param selectedElement
* the element from which on a subtree should be validated
* @param diagnostician
- * the diagnostician (e.g. UMLDiagnostician)
+ * the diagnostician (e.g. EcoreDiagnostician)
*/
public ValidateSubtreeCommand(EObject selectedElement, IPapyrusDiagnostician diagnostician) {
super(Messages.ValidateSubtreeCommand_ValidateSubtree, TransactionUtil.getEditingDomain(selectedElement), selectedElement, diagnostician);
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateModelHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateModelHandler.java
index 94612988ff2..4358b6994b8 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateModelHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateModelHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.SelectAndValidateModelCommand;
/**
@@ -33,6 +32,6 @@ public class SelectAndValidateModelHandler extends AbstractCommandHandler {
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new SelectAndValidateModelCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new SelectAndValidateModelCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateSubtreeHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateSubtreeHandler.java
index b7eff0cacc9..ca5e78123af 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateSubtreeHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/SelectAndValidateSubtreeHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.SelectAndValidateSubtreeCommand;
/**
@@ -33,6 +32,6 @@ public class SelectAndValidateSubtreeHandler extends AbstractCommandHandler {
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new SelectAndValidateSubtreeCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new SelectAndValidateSubtreeCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromModelHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromModelHandler.java
index a42810f815f..7d69aaa6643 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromModelHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromModelHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.ValidateDelMarkersFromModelCommand;
/**
@@ -33,6 +32,6 @@ public class ValidateDelMarkersFromModelHandler extends AbstractCommandHandler {
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new ValidateDelMarkersFromModelCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new ValidateDelMarkersFromModelCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromSubtreeHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromSubtreeHandler.java
index 8ab71ca52b3..59c757fc08d 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromSubtreeHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateDelMarkersFromSubtreeHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.ValidateDelMarkersFromSubtreeCommand;
/**
@@ -33,6 +32,6 @@ public class ValidateDelMarkersFromSubtreeHandler extends AbstractCommandHandler
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new ValidateDelMarkersFromSubtreeCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new ValidateDelMarkersFromSubtreeCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateModelHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateModelHandler.java
index 286451a52d9..d63ee52585e 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateModelHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateModelHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.ValidateModelCommand;
/**
@@ -33,6 +32,6 @@ public class ValidateModelHandler extends AbstractCommandHandler {
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new ValidateModelCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new ValidateModelCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateSubtreeHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateSubtreeHandler.java
index 6965c9c645b..e1033a6a421 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateSubtreeHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/handler/ValidateSubtreeHandler.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.commands.ValidateSubtreeCommand;
/**
@@ -33,6 +32,6 @@ public class ValidateSubtreeHandler extends AbstractCommandHandler {
if (selectedElement == null) {
return UnexecutableCommand.INSTANCE;
}
- return new GMFtoEMFCommandWrapper(new ValidateSubtreeCommand(selectedElement, new EcoreDiagnostician()));
+ return GMFtoEMFCommandWrapper.wrap(new ValidateSubtreeCommand(selectedElement));
}
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EValidatorAdapter.java
index d5c4f2fc060..5258e04411b 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EValidatorAdapter.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EValidatorAdapter.java
@@ -14,7 +14,7 @@
*****************************************************************************/
-package org.eclipse.papyrus.infra.services.validation;
+package org.eclipse.papyrus.infra.services.validation.internal;
import java.util.Collection;
import java.util.Iterator;
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EcoreDiagnostician.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EcoreDiagnostician.java
index 5338d5e6edf..24f1da5cb70 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/EcoreDiagnostician.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/EcoreDiagnostician.java
@@ -11,7 +11,7 @@
* Ed Willink, Klaas Gadeyne, A. Radermacher - Remove hard-coded UML dependency - Bug 408215
*
*****************************************************************************/
-package org.eclipse.papyrus.infra.services.validation;
+package org.eclipse.papyrus.infra.services.validation.internal;
import java.util.Map;
@@ -25,6 +25,7 @@ import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EObjectValidator;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
+import org.eclipse.papyrus.infra.services.validation.IPapyrusDiagnostician;
/**
* This is a generic diagnostician to validate Ecore model in Papyrus
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/ValidationRegistry.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/ValidationRegistry.java
new file mode 100644
index 00000000000..63007824acb
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/internal/ValidationRegistry.java
@@ -0,0 +1,92 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.services.validation.internal;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.infra.core.language.ILanguage;
+import org.eclipse.papyrus.infra.core.language.ILanguageService;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.validation.Activator;
+import org.eclipse.papyrus.infra.services.validation.IPapyrusDiagnostician;
+
+/**
+ * A simple registry for language and diagnosticians pairs
+ *
+ */
+public class ValidationRegistry {
+
+ public static final String ID_DIAGNOSTICIANS = Activator.PLUGIN_ID + ".diagnosticians"; //$NON-NLS-1$
+
+ /**
+ * Return a diagnostician for an element of a model.
+ * TODO: It is possible that multiple languages are registered with a model.
+ * This function currently returns the diagnostician for the first matching language.
+ *
+ * @param element
+ * an element of a model (that must be contained in an eResource)
+ * @return
+ */
+ public static IPapyrusDiagnostician getDiagnostician(EObject element) {
+ try {
+ final ServicesRegistry serviceRegistry = ServiceUtilsForEObject.getInstance().getServiceRegistry(element);
+ ILanguageService languageService = serviceRegistry.getService(ILanguageService.class);
+ if (languageService != null) {
+ Set<ILanguage> languages = languageService.getLanguages(element.eResource().getURI(), true);
+ for (ILanguage language : languages) {
+ IPapyrusDiagnostician diagnostician = getDiagnostician(language.getID());
+ if (diagnostician != null) {
+ return diagnostician;
+ }
+ }
+ }
+ } catch (ServiceException e) {
+ }
+ // fall back to ecore diagnostician
+ return new EcoreDiagnostician();
+ }
+
+ /**
+ * Obtain a diagnostician for a given language
+ *
+ * @param languageID
+ * the id of the language for which we want to obtain the diagnostician
+ * @return the associated diagnostician
+ */
+ public static IPapyrusDiagnostician getDiagnostician(String languageID) {
+ IExtensionRegistry reg = Platform.getExtensionRegistry();
+ IConfigurationElement[] configElements = reg.getConfigurationElementsFor(ID_DIAGNOSTICIANS);
+ for (IConfigurationElement configElement : configElements) {
+ try {
+ final String iConfiguratorIDext = configElement.getAttribute("id"); //$NON-NLS-1$
+ if ((iConfiguratorIDext != null) && iConfiguratorIDext.equals(languageID)) {
+ final Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$
+ if (obj instanceof IPapyrusDiagnostician) {
+ return (IPapyrusDiagnostician) obj;
+ }
+ }
+ } catch (CoreException exception) {
+ Activator.log.error(exception);
+ }
+ }
+ return null;
+ }
+}

Back to the top