Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 126724 Details for
Bug 255786
Investigate support for Constraints directly annotated to Ecore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
improvements and new management of constraint
constraintsDelegator5.patch (text/plain), 30.04 KB, created by
Tristan Faure
on 2009-02-25 09:46:56 EST
(
hide
)
Description:
improvements and new management of constraint
Filename:
MIME Type:
Creator:
Tristan Faure
Created:
2009-02-25 09:46:56 EST
Size:
30.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.ecore >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.xml,v >retrieving revision 1.22 >diff -u -r1.22 plugin.xml >--- plugin.xml 27 Apr 2008 20:27:23 -0000 1.22 >+++ plugin.xml 25 Feb 2009 14:44:54 -0000 >@@ -10,6 +10,7 @@ > <extension-point id="content_handler" name="%_UI_ContentHandlerRegistry_extensionpoint" schema="schema/content_handler.exsd"/> > <extension-point id="uri_mapping" name="%_UI_URIMappingRegistry_extensionpoint" schema="schema/uri_mapping.exsd"/> > <extension-point id="package_registry_implementation" name="%_UI_PackageRegistryImplementation_extensionpoint" schema="schema/package_registry_implementation.exsd"/> >+ <extension-point id="constraints_delegator_registry" name="%_UI_ConstraintsDelegatorRegistry_extensionpoint" schema="schema/constraints_delegator_registry.exsd"/> > > <extension point="org.eclipse.emf.ecore.generated_package"> > <package >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/plugin.properties,v >retrieving revision 1.33 >diff -u -r1.33 plugin.properties >--- plugin.properties 20 Feb 2009 12:44:50 -0000 1.33 >+++ plugin.properties 25 Feb 2009 14:44:54 -0000 >@@ -116,6 +116,8 @@ > _UI_ContentHandler_extensionpoint = Content Handler Registry > _UI_URIMappingRegistry_extensionpoint = URI Converter Mapping Registry > _UI_PackageRegistryImplementation_extensionpoint = Ecore Package Registry Implementation >+_UI_ConstraintsDelegatorRegistry_extensionpoint = Constraints Delegator Registry >+ > > _UI_GenericInvariant_diagnostic = The ''{0}'' invariant is violated on ''{1}'' > _UI_GenericConstraint_diagnostic = The ''{0}'' constraint is violated on ''{1}'' >Index: src/org/eclipse/emf/ecore/plugin/EcorePlugin.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/EcorePlugin.java,v >retrieving revision 1.23 >diff -u -r1.23 EcorePlugin.java >--- src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 2 Aug 2008 13:40:51 -0000 1.23 >+++ src/org/eclipse/emf/ecore/plugin/EcorePlugin.java 25 Feb 2009 14:44:54 -0000 >@@ -55,7 +55,7 @@ > * A collection of platform-neutral static utilities > * as well as Eclipse support utilities. > */ >-public class EcorePlugin extends EMFPlugin >+public class EcorePlugin extends EMFPlugin > { > /** > * The singleton instance of the plugin. >@@ -67,7 +67,7 @@ > */ > private EcorePlugin() > { >- super(new ResourceLocator[] {}); >+ super(new ResourceLocator []{}); > } > > @Override >@@ -162,7 +162,7 @@ > * @param arguments an array of "command line" options. > * @return the arguments stripped of those recognized as platform resource options. > */ >- public static String [] handlePlatformResourceOptions(String [] arguments) >+ public static String[] handlePlatformResourceOptions(String[] arguments) > { > getPlatformResourceMap(); > >@@ -204,7 +204,7 @@ > } > } > >- String [] remainingArguments = new String [arguments.length - (i - start)]; >+ String[] remainingArguments = new String [arguments.length - (i - start)]; > System.arraycopy(arguments, 0, remainingArguments, 0, start); > System.arraycopy(arguments, i, remainingArguments, start, arguments.length - i); > return remainingArguments; >@@ -213,7 +213,7 @@ > > return arguments; > } >- >+ > /** > * Returns a map from {@link EPackage#getNsURI() package namespace URI} (represented as a String) > * to the location of the GenModel containing a GenPackage for the package (represented as a {@link URI URI}). >@@ -258,10 +258,10 @@ > } > return result; > } >- >+ > private static Pattern bundleSymbolNamePattern; >- private static byte [] NO_BYTES = new byte [0]; >- >+ private static byte[] NO_BYTES = new byte [0]; >+ > /** > * Computes a map from <code>platform:/plugin/<plugin-id>/</code> {@link URI} to > * <code>platform:/resource/<plugin-location>/</code> URI >@@ -277,12 +277,12 @@ > Map<URI, URI> result = new HashMap<URI, URI>(); > IWorkspaceRoot root = getWorkspaceRoot(); > if (root != null) >- { >- IProject [] projects = root.getProjects(); >+ { >+ IProject[] projects = root.getProjects(); > if (projects != null) > { > String pluginID = null; >- >+ > class Handler extends DefaultHandler > { > public String pluginID; >@@ -298,11 +298,11 @@ > } > } > Handler handler = new Handler(); >- >- SAXParserFactory parserFactory= SAXParserFactory.newInstance(); >+ >+ SAXParserFactory parserFactory = SAXParserFactory.newInstance(); > parserFactory.setNamespaceAware(true); > SAXParser parser = null; >- >+ > try > { > parser = parserFactory.newSAXParser(); >@@ -311,14 +311,14 @@ > { > INSTANCE.log(exception); > } >- >+ > if (bundleSymbolNamePattern == null) > { > bundleSymbolNamePattern = Pattern.compile("^\\s*Bundle-SymbolicName\\s*:\\s*([^\\s;]*)\\s*(;.*)?$", Pattern.MULTILINE); > } >- >- byte [] bytes = NO_BYTES; >- >+ >+ byte[] bytes = NO_BYTES; >+ > for (int i = 0, size = projects.length; i < size; ++i) > { > IProject project = projects[i]; >@@ -331,7 +331,7 @@ > InputStream inputStream = null; > try > { >- inputStream = manifest.getContents(); >+ inputStream = manifest.getContents(); > int available = inputStream.available(); > if (bytes.length < available) > { >@@ -386,21 +386,21 @@ > } > } > } >- >+ > if (pluginID != null) > { > URI platformPluginURI = URI.createPlatformPluginURI(pluginID + "/", false); >- URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); >+ URI platformResourceURI = URI.createPlatformResourceURI(project.getName() + "/", true); > result.put(platformPluginURI, platformResourceURI); > } > } > } > } > } >- >+ > return result; > } >- >+ > /** > * Computes a map so that plugins in the workspace will override those in the environment > * and so that plugins with Ecore and GenModels will look like projects in the workspace. >@@ -425,13 +425,13 @@ > result.putAll(computePlatformResourceToPlatformPluginMap(new HashSet<URI>(EcorePlugin.getEPackageNsURIToGenModelLocationMap().values()))); > return result; > } >- >+ > /** > * The platform resource map. > * @see #getPlatformResourceMap > */ > private static Map<String, URI> platformResourceMap; >- >+ > /** > * The map from package namespace URIs to the location of the GenModel for that package. > * @see #getPlatformResourceMap >@@ -452,7 +452,7 @@ > super(); > plugin = this; > } >- >+ > /** > * Starts up this plugin by reading some extensions and populating the relevant registries. > * <p> >@@ -520,52 +520,53 @@ > workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); > } > >- new RegistryReader >- (Platform.getExtensionRegistry(), >- EcorePlugin.getPlugin().getBundle().getSymbolicName(), >- PACKAGE_REGISTRY_IMPLEMENTATION_PPID) >- { >- IConfigurationElement previous; >- >- @Override >- protected boolean readElement(IConfigurationElement element) >+ new RegistryReader( >+ Platform.getExtensionRegistry(), >+ EcorePlugin.getPlugin().getBundle().getSymbolicName(), >+ PACKAGE_REGISTRY_IMPLEMENTATION_PPID) > { >- if (element.getName().equals("registry")) >+ IConfigurationElement previous; >+ >+ @Override >+ protected boolean readElement(IConfigurationElement element) > { >- String implementationClass = element.getAttribute("class"); >- if (implementationClass == null) >+ if (element.getName().equals("registry")) > { >- logMissingAttribute(element, "class"); >- } >- else >- { >- if (defaultRegistryImplementation != null) >+ String implementationClass = element.getAttribute("class"); >+ if (implementationClass == null) >+ { >+ logMissingAttribute(element, "class"); >+ } >+ else > { >- if (previous != null) >+ if (defaultRegistryImplementation != null) > { >- log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() + "' register a package registry implementation"); >+ if (previous != null) >+ { >+ log("Both '" + previous.getContributor().getName() + "' and '" + element.getContributor().getName() >+ + "' register a package registry implementation"); >+ } >+ if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) >+ { >+ return false; >+ } > } >- if (defaultRegistryImplementation instanceof EPackageRegistryImpl.Delegator) >+ try > { >- return false; >+ defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); >+ previous = element; > } >+ catch (CoreException exception) >+ { >+ log(exception); >+ } >+ return true; > } >- try >- { >- defaultRegistryImplementation = (EPackage.Registry)element.createExecutableExtension("class"); >- previous = element; >- } >- catch (CoreException exception) >- { >- log(exception); >- } >- return true; > } >+ return false; > } >- return false; >- } >- >- }.readRegistry(); >+ >+ }.readRegistry(); > > new GeneratedPackageRegistryReader(getEPackageNsURIToGenModelLocationMap()).readRegistry(); > new DynamicPackageRegistryReader().readRegistry(); >@@ -575,13 +576,14 @@ > new ContentParserRegistryReader().readRegistry(); > new ContentHandlerRegistryReader().readRegistry(); > new URIMappingRegistryReader().readRegistry(); >+ new ConstraintsDelegatorFactoryRegistryReader().readRegistry(); > } > } > > /** > * The default registry implementation singleton. > */ >- private static EPackage.Registry defaultRegistryImplementation; >+ private static EPackage.Registry defaultRegistryImplementation; > > /** > * Returns the default registry implementation singleton. >@@ -631,4 +633,5 @@ > public static final String SCHEME_PARSER_PPID = "scheme_parser"; > public static final String URI_MAPPING_PPID = "uri_mapping"; > public static final String PACKAGE_REGISTRY_IMPLEMENTATION_PPID = "package_registry_implementation"; >+ public static final String CONSTRAINTS_DELEGATOR_FACTORY = "constraints_delegator_registry"; > } >\ No newline at end of file >Index: src/org/eclipse/emf/ecore/util/EObjectValidator.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/EObjectValidator.java,v >retrieving revision 1.30 >diff -u -r1.30 EObjectValidator.java >--- src/org/eclipse/emf/ecore/util/EObjectValidator.java 20 Feb 2009 12:44:50 -0000 1.30 >+++ src/org/eclipse/emf/ecore/util/EObjectValidator.java 25 Feb 2009 14:44:54 -0000 >@@ -16,7 +16,8 @@ > */ > package org.eclipse.emf.ecore.util; > >- >+import java.lang.reflect.Array; >+import java.math.BigDecimal; > import java.util.ArrayList; > import java.util.Collection; > import java.util.HashMap; >@@ -25,33 +26,27 @@ > import java.util.ListIterator; > import java.util.Map; > >-import java.lang.reflect.Array; >-import java.math.BigDecimal; >- > import org.eclipse.emf.common.util.BasicDiagnostic; > import org.eclipse.emf.common.util.BasicEList; > import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.DiagnosticChain; > import org.eclipse.emf.common.util.EMap; > import org.eclipse.emf.common.util.ResourceLocator; >- >-import org.eclipse.emf.ecore.EValidator; >- >+import org.eclipse.emf.ecore.EAnnotation; > import org.eclipse.emf.ecore.EAttribute; >-import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EClass; >-import org.eclipse.emf.ecore.EReference; >-import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.EDataType; >+import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.EPackage; >+import org.eclipse.emf.ecore.EReference; > import org.eclipse.emf.ecore.EStructuralFeature; >+import org.eclipse.emf.ecore.EValidator; >+import org.eclipse.emf.ecore.EcorePackage; > import org.eclipse.emf.ecore.InternalEObject; >- > import org.eclipse.emf.ecore.plugin.EcorePlugin; >- > import org.eclipse.emf.ecore.resource.Resource; > import org.eclipse.emf.ecore.resource.ResourceSet; >- >+import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory; > import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; > > >@@ -82,6 +77,15 @@ > > static final int EOBJECT_DIAGNOSTIC_CODE_COUNT = EOBJECT__NO_CIRCULAR_CONTAINMENT; > >+ // constants for user validation >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY = "factory"; >+ private static final String USER_CONSTRAINT_VALIDATION_NAME = "name"; >+ private static final String USER_CONSTRAINT_VALIDATION_MESSAGE = "message"; >+ private static final String USER_CONSTRAINT_VALIDATION_SEVERITY = "severity"; >+ private static final String USER_CONSTRAINT_VALIDATION_CONSTRAINT = "constraint"; >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE = "inheritsConstraints"; >+ private static final String USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE = "http://www.eclipse.org/emf/2002/Ecore"; >+ > /** > * A key to be used in <code>context</code> maps to indicate the root object at which validation started. > * It's used to detect {@link #EOBJECT__NO_CIRCULAR_CONTAINMENT circular containment} >@@ -1417,7 +1421,124 @@ > } > } > } >- >+ return result; >+ } >+ >+ /** >+ * @since 2.5 >+ * @param theEClass the eclass of the eobject >+ * @param objectn the eobject to check >+ * @param theDiagnostics the diagnostic chain to modify if problems >+ * @param context the context >+ * @return true if user constraint ok false else >+ */ >+ protected boolean validate_UserConstraintsByEClass( >+ EClass theEClass, >+ EObject object, >+ DiagnosticChain theDiagnostics, >+ Map<Object, Object> context) >+ { >+ // we check if the factory is declared in EPackage if it 's not the case. Constraints can't be checked >+ Collection<EAnnotation> annotations = theEClass.getEAnnotations(); >+ EAnnotation annotationPackage = theEClass.getEPackage().getEAnnotation(USER_CONSTRAINT_VALIDATION_EANNOTATION_ECORE); >+ boolean result = true; >+ boolean inheritsConstraints = true; >+ if (annotationPackage != null && annotationPackage.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY)) >+ { >+ String factoryName = ""; >+ String keyName = ""; >+ // for validation >+ String rule = ""; >+ String ruleName = ""; >+ String message = ""; >+ int severity = Diagnostic.WARNING; >+ String strFactory = annotationPackage.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_FACTORY); >+ String[] strs = strFactory.split("#"); >+ if (strs != null && strs.length == 2) >+ { >+ factoryName = strs[0]; >+ keyName = strs[1]; >+ } >+ else >+ { >+ factoryName = strFactory; >+ keyName = strFactory; >+ } >+ Factory factory = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(factoryName); >+ if (factory != null) >+ { >+ for (EAnnotation e : annotations) >+ { >+ if (keyName.equals(e.getSource()) || factoryName.equals(e.getSource())) >+ { >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE)) >+ { >+ String value = e.getDetails().get(USER_CONSTRAINT_VALIDATION_EANNOTATION_INHERITANCE); >+ if (value != null && ("true".equals(value.trim().toLowerCase()) || "false".equals(value.trim().toLowerCase()))) >+ { >+ inheritsConstraints = Boolean.valueOf(value); >+ } >+ } >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_CONSTRAINT)) >+ { >+ rule = e.getDetails().get(USER_CONSTRAINT_VALIDATION_CONSTRAINT); >+ // default value >+ ruleName = rule; >+ message = "problem with rule " + rule; >+ // we need at least a constraint to work >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_MESSAGE)) >+ { >+ message = e.getDetails().get(USER_CONSTRAINT_VALIDATION_MESSAGE); >+ } >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_NAME)) >+ { >+ ruleName = e.getDetails().get(USER_CONSTRAINT_VALIDATION_NAME); >+ } >+ if (e.getDetails().containsKey(USER_CONSTRAINT_VALIDATION_SEVERITY)) >+ { >+ String severityS = e.getDetails().get(USER_CONSTRAINT_VALIDATION_SEVERITY); >+ severityS = severityS.toLowerCase().trim(); >+ if ("warning".equals(severityS)) >+ { >+ severity = Diagnostic.WARNING; >+ } >+ else if ("error".equals(severityS)) >+ { >+ severity = Diagnostic.ERROR; >+ } >+ } >+ ConstraintsDelegator constraintDelegator = factory.createConstraintDelegator(); >+ if (constraintDelegator != null) >+ { >+ result &= constraintDelegator.validate(rule, ruleName, severity, message, object, theDiagnostics, context); >+ } >+ } >+ } >+ } >+ // we check inherited constraints >+ if (inheritsConstraints) >+ { >+ for (EClass c : theEClass.getESuperTypes()) >+ { >+ result &= validate_UserConstraintsByEClass(c, object, theDiagnostics, context); >+ } >+ } >+ } >+ } >+ return result; >+ } >+ >+ /** >+ * @since 2.5 >+ * @param object the eobject to check >+ * @param theDiagnostics the diagnostic to modify if problem >+ * @param context the context >+ * @return true if user constraint is ok false else >+ */ >+ protected boolean validate_UserConstraints(EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context) >+ { >+ EClass theclass = object.eClass(); >+ boolean result = validate_UserConstraintsByEClass(theclass, object, theDiagnostics, context); > return result; > } > >Index: src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >diff -N src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/plugin/ConstraintsDelegatorFactoryRegistryReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id: EMF_codetemplates.xml,v 1.1 2008/05/06 20:12:20 nickb Exp $ >+ */ >+package org.eclipse.emf.ecore.plugin; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.common.util.WrappedException; >+import org.eclipse.emf.ecore.util.ConstraintsDelegator; >+import org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory; >+ >+/** >+ * A plugin extension reader that populates the >+ * {@link org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory.Registry#INSTANCE global} resource factory's >+ * Clients are not expected to use this class directly. >+ */ >+public class ConstraintsDelegatorFactoryRegistryReader extends RegistryReader >+{ >+ static final String TAG_FACTORY = "factory"; >+ static final String ATT_URI = "uri"; >+ static final String ATT_CLASS = "class"; >+ >+ public ConstraintsDelegatorFactoryRegistryReader() >+ { >+ super >+ (Platform.getExtensionRegistry(), >+ EcorePlugin.getPlugin().getBundle().getSymbolicName(), >+ EcorePlugin.CONSTRAINTS_DELEGATOR_FACTORY); >+ } >+ >+ @Override >+ protected boolean readElement(IConfigurationElement element, boolean add) >+ { >+ if (element.getName().equals(TAG_FACTORY)) >+ { >+ String packageURI = element.getAttribute(ATT_URI); >+ if (packageURI == null) >+ { >+ logMissingAttribute(element, ATT_URI); >+ } >+ else if (element.getAttribute(ATT_CLASS) == null) >+ { >+ logMissingAttribute(element, ATT_CLASS); >+ } >+ else >+ { >+ try >+ { >+ Object o = element.createExecutableExtension(ATT_CLASS); >+ if (o instanceof ConstraintsDelegator.Factory) >+ { >+ Factory tmp = ConstraintsDelegator.Factory.Registry.INSTANCE.getFactory(packageURI); >+ if (tmp != null) >+ { >+ EcorePlugin.INSTANCE.log >+ ("factory '" + o.getClass().getName() + "'tries to override '" + packageURI + "' instead of factor '" + tmp.getClass().getName()+"'"); >+ } >+ else >+ { >+ ConstraintsDelegator.Factory.Registry.INSTANCE.putFactory(packageURI, (Factory)o); >+ } >+ } >+ return true; >+ } >+ catch (CoreException e) >+ { >+ throw new WrappedException(e); >+ } >+ } >+ } >+ return false; >+ } >+} >Index: schema/constraints_delegator_registry.exsd >=================================================================== >RCS file: schema/constraints_delegator_registry.exsd >diff -N schema/constraints_delegator_registry.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/constraints_delegator_registry.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.emf.ecore" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.emf.ecore" id="constraints_delegator_registry" name="%_UI_ConstraintsDelegatorRegistry_extensionpoint"/> >+ </appinfo> >+ <documentation> >+ Adds a ConstraintDelegatorFactory to check constraints in Ecore models >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="factory"/> >+ </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="factory"> >+ <complexType> >+ <attribute name="uri" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the uri which will be inserted by user to check constraints >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A fully qualified name of the Java class implementing <samp>org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory >+</samp>. >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.util.ConstraintsDelegator.Factory"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ 2.5.0 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ Following is an example of implementation >+<pre> >+<extension >+ point="org.eclipse.emf.ecore.constraints_delegator_regstry"> >+ <factory >+ class="ocl.test.ConstraintsDelegator.MyFactory" >+ uri="org.eclipse.emf.ocl"> >+ </factory> >+ </extension> >+</pre> >+ </documentation> >+ </annotation> >+ >+ >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="copyright"/> >+ </appinfo> >+ <documentation> >+ Copyright (c) 2002, 2004 IBM Corporation and others.<br> >+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 <a >+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> >+ </documentation> >+ </annotation> >+ >+</schema> >Index: src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >=================================================================== >RCS file: src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >diff -N src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/ecore/util/ConstraintsDelegator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,85 @@ >+/** >+ * <copyright> >+ * >+ * Copyright (c) 2005 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * </copyright> >+ * >+ * $Id: ConstraintsDelegator.java,v 1.0 2008/11/19 16:37:42 tfaure Exp $ >+ */ >+package org.eclipse.emf.ecore.util; >+ >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.emf.common.util.DiagnosticChain; >+import org.eclipse.emf.ecore.EObject; >+ >+ >+/** >+ * An interface to validate a constraint >+ * The only method to implement is {@link #validate(String, EObject, DiagnosticChain, Map) >+ * To add a factory please see extension point : constraints_delegator_regstry >+ */ >+public interface ConstraintsDelegator >+{ >+ interface Factory >+ { >+ interface Registry >+ { >+ Registry INSTANCE = new Impl(); >+ >+ /** >+ * Returns the factory identified by the key >+ * @param key the factory id >+ * @return the factory or null if it doesn't exist >+ */ >+ Factory getFactory(String key); >+ >+ /** >+ * Registers a factory and associates it to an id >+ * @param key the id >+ * @param value the factory >+ */ >+ void putFactory(String key, Factory value); >+ >+ class Impl extends HashMap<String, Factory> implements Registry >+ { >+ private static final long serialVersionUID = 1L; >+ >+ public Factory getFactory(String key) >+ { >+ return get(key); >+ } >+ >+ public void putFactory(String key, Factory value) >+ { >+ put(key, value); >+ } >+ } >+ } >+ >+ /** >+ * Create a constraint delegator which is able to check a constraint >+ * @return the constraint Delegator >+ */ >+ ConstraintsDelegator createConstraintDelegator(); >+ } >+ >+ /** >+ * Validate a constraint and add to the diagnostic chain the evaluation's diagnostic >+ * @param value the expression to manage >+ * @param object the current EObject >+ * @param theDiagnostics the diagnostic's chain >+ * @param context the context of the current validation >+ * @return true if it's OK else false >+ */ >+ boolean validate(String constraint,String name, int severity, String message, EObject object, DiagnosticChain theDiagnostics, Map<Object, Object> context); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 255786
:
118244
|
118245
|
118338
|
123880
|
123881
|
123883
|
123885
|
126724
|
126725
|
126726
|
126727
|
126729
|
146761
|
146762
|
146778
|
146787
|
147341
|
147449
|
147455
|
147479