Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206808 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/validation/examples/internal/wizard/AbstractExampleWizard.java (-6 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-30 Link Here
24
import java.lang.reflect.InvocationTargetException;
24
import java.lang.reflect.InvocationTargetException;
25
import java.net.URL;
25
import java.net.URL;
26
import java.util.Collection;
26
import java.util.Collection;
27
import java.util.Iterator;
28
import java.util.zip.ZipEntry;
27
import java.util.zip.ZipEntry;
29
import java.util.zip.ZipInputStream;
28
import java.util.zip.ZipInputStream;
30
29
Lines 115-121 Link Here
115
	}
114
	}
116
115
117
	public boolean performFinish() {
116
	public boolean performFinish() {
118
		final Collection projectDescriptors = getProjectDescriptors();
117
		final Collection<ProjectDescriptor> projectDescriptors = getProjectDescriptors();
119
		
118
		
120
		try {
119
		try {
121
			getContainer().run(true, false, new IRunnableWithProgress() {
120
			getContainer().run(true, false, new IRunnableWithProgress() {
Lines 128-135 Link Here
128
							throws CoreException, InvocationTargetException, InterruptedException {
127
							throws CoreException, InvocationTargetException, InterruptedException {
129
							m.beginTask("Unzipping Projects", projectDescriptors.size());
128
							m.beginTask("Unzipping Projects", projectDescriptors.size());
130
							
129
							
131
							for (Iterator i = projectDescriptors.iterator(); i.hasNext();) {
130
							for (ProjectDescriptor next : projectDescriptors) {
132
								unzipProject((ProjectDescriptor)i.next(), m);
131
								unzipProject(next, m);
133
								m.worked(1);
132
								m.worked(1);
134
							}
133
							}
135
						}
134
						}
Lines 157-163 Link Here
157
	 * @return The collection of project descriptors that should be
156
	 * @return The collection of project descriptors that should be
158
	 *  unzipped into the workspace.
157
	 *  unzipped into the workspace.
159
	 */
158
	 */
160
	protected abstract Collection getProjectDescriptors();
159
	protected abstract Collection<ProjectDescriptor> getProjectDescriptors();
161
	
160
	
162
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
161
	private void unzipProject(ProjectDescriptor descriptor, IProgressMonitor monitor) {
163
		String bundleName = descriptor.getBundleName();
162
		String bundleName = descriptor.getBundleName();
(-)src/org/eclipse/emf/validation/examples/internal/wizard/GeneralExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class GeneralExampleWizard
30
public class GeneralExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the general example to be unzipped along with the
35
		// We need the general example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
	
45
	
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-)src/org/eclipse/emf/validation/examples/internal/wizard/AdapterExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class AdapterExampleWizard
30
public class AdapterExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the adapter example to be unzipped along with the
35
		// We need the adapter example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
	
45
	
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-)src/org/eclipse/emf/validation/examples/internal/wizard/OCLExampleWizard.java (-3 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-39 Link Here
30
public class OCLExampleWizard
30
public class OCLExampleWizard
31
	extends AbstractExampleWizard {
31
	extends AbstractExampleWizard {
32
	
32
	
33
	protected Collection getProjectDescriptors() {
33
	@Override
34
	protected Collection<ProjectDescriptor> getProjectDescriptors() {
34
		// We need the OCL example to be unzipped along with the
35
		// We need the OCL example to be unzipped along with the
35
		// EMF library example model, edit and editor examples
36
		// EMF library example model, edit and editor examples
36
		List projects = new ArrayList(4);
37
		List<ProjectDescriptor> projects = new ArrayList<ProjectDescriptor>(4);
37
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/library.zip", "org.eclipse.emf.examples.library"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
38
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEdit.zip", "org.eclipse.emf.examples.library.edit")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
39
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
40
		projects.add(new ProjectDescriptor("org.eclipse.emf.validation.examples", "zips/libraryEditor.zip", "org.eclipse.emf.examples.library.editor"));  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
Lines 42-47 Link Here
42
		return projects;
43
		return projects;
43
	}
44
	}
44
	
45
	
46
	@Override
45
	protected void log(Exception e) {
47
	protected void log(Exception e) {
46
		if (e instanceof CoreException) {
48
		if (e instanceof CoreException) {
47
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
49
			ValidationExamplesPlugin.getDefault().getLog().log(((CoreException)e).getStatus());
(-)build.properties (-2 / +2 lines)
Lines 25-30 Link Here
25
               zips/*.zip,\
25
               zips/*.zip,\
26
               icons/
26
               icons/
27
src.includes = about.html
27
src.includes = about.html
28
javacSource = 1.4
28
javacSource = 1.5
29
javacTarget = 1.4
29
javacTarget = 1.5
30
30
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:45:30 EST 2006
1
#Mon Nov 05 21:48:43 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples;singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples;singleton:=true
5
Bundle-Version: 1.1.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.examples.internal.ValidationExamplesPlugin
6
Bundle-Activator: org.eclipse.emf.validation.examples.internal.ValidationExamplesPlugin
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 13-16 Link Here
13
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)"
14
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)"
15
Eclipse-LazyStart: true
15
Eclipse-LazyStart: true
16
Bundle-RequiredExecutionEnvironment: J2SE-1.4
16
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/validation/examples/adapter/EValidatorAdapter.java (-10 / +12 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 54-76 Link Here
54
	public EValidatorAdapter() {
54
	public EValidatorAdapter() {
55
		super();
55
		super();
56
		
56
		
57
		batchValidator =
57
		batchValidator = ModelValidationService.getInstance().newValidator(
58
			(IBatchValidator) ModelValidationService.getInstance().newValidator(
59
				EvaluationMode.BATCH);
58
				EvaluationMode.BATCH);
60
		batchValidator.setIncludeLiveConstraints(true);
59
		batchValidator.setIncludeLiveConstraints(true);
61
		batchValidator.setReportSuccesses(false);
60
		batchValidator.setReportSuccesses(false);
62
	}
61
	}
63
62
63
	@Override
64
	public boolean validate(EObject eObject, DiagnosticChain diagnostics,
64
	public boolean validate(EObject eObject, DiagnosticChain diagnostics,
65
			Map context) {
65
			Map<Object, Object> context) {
66
		return validate(eObject.eClass(), eObject, diagnostics, context);
66
		return validate(eObject.eClass(), eObject, diagnostics, context);
67
	}
67
	}
68
68
69
	/**
69
	/**
70
	 * Implements validation by delegation to the EMF validation framework.
70
	 * Implements validation by delegation to the EMF validation framework.
71
	 */
71
	 */
72
	@Override
72
	public boolean validate(EClass eClass, EObject eObject,
73
	public boolean validate(EClass eClass, EObject eObject,
73
			DiagnosticChain diagnostics, Map context) {
74
			DiagnosticChain diagnostics, Map<Object, Object> context) {
74
		// first, do whatever the basic EcoreValidator does
75
		// first, do whatever the basic EcoreValidator does
75
		super.validate(eClass, eObject, diagnostics, context);
76
		super.validate(eClass, eObject, diagnostics, context);
76
		
77
		
Lines 102-109 Link Here
102
	 * validation framework; they are validated indirectly via the
103
	 * validation framework; they are validated indirectly via the
103
	 * {@link EObject}s that hold their values.
104
	 * {@link EObject}s that hold their values.
104
	 */
105
	 */
106
	@Override
105
	public boolean validate(EDataType eDataType, Object value,
107
	public boolean validate(EDataType eDataType, Object value,
106
			DiagnosticChain diagnostics, Map context) {
108
			DiagnosticChain diagnostics, Map<Object, Object> context) {
107
		return super.validate(eDataType, value, diagnostics, context);
109
		return super.validate(eDataType, value, diagnostics, context);
108
	}
110
	}
109
	
111
	
Lines 115-121 Link Here
115
	 * @param context the context (may be <code>null</code>)
117
	 * @param context the context (may be <code>null</code>)
116
	 * @param status the element's validation status
118
	 * @param status the element's validation status
117
	 */
119
	 */
118
	private void processed(EObject eObject, Map context, IStatus status) {
120
	private void processed(EObject eObject, Map<Object, Object> context, IStatus status) {
119
		if (context != null) {
121
		if (context != null) {
120
			context.put(eObject, status);
122
			context.put(eObject, status);
121
		}
123
		}
Lines 132-138 Link Here
132
	 *     the <code>eObject</code> or one of its containers has already been
134
	 *     the <code>eObject</code> or one of its containers has already been
133
	 *     validated;  <code>false</code>, otherwise
135
	 *     validated;  <code>false</code>, otherwise
134
	 */
136
	 */
135
	private boolean hasProcessed(EObject eObject, Map context) {
137
	private boolean hasProcessed(EObject eObject, Map<Object, Object> context) {
136
		boolean result = false;
138
		boolean result = false;
137
		
139
		
138
		if (context != null) {
140
		if (context != null) {
Lines 160-167 Link Here
160
		if (status.isMultiStatus()) {
162
		if (status.isMultiStatus()) {
161
			IStatus[] children = status.getChildren();
163
			IStatus[] children = status.getChildren();
162
			
164
			
163
			for (int i = 0; i < children.length; i++) {
165
			for (IStatus element : children) {
164
				appendDiagnostics(children[i], diagnostics);
166
				appendDiagnostics(element, diagnostics);
165
			}
167
			}
166
		} else if (status instanceof IConstraintStatus) {
168
		} else if (status instanceof IConstraintStatus) {
167
			diagnostics.add(new BasicDiagnostic(
169
			diagnostics.add(new BasicDiagnostic(
(-)src/org/eclipse/emf/validation/examples/adapter/constraints/ExampleConstraint.java (-1 / +2 lines)
Lines 41-47 Link Here
41
	/**
41
	/**
42
	 * I fail on every object that I see.
42
	 * I fail on every object that I see.
43
	 */
43
	 */
44
	@Override
44
	public IStatus validate(IValidationContext ctx) {
45
	public IStatus validate(IValidationContext ctx) {
45
		return ctx.createFailureStatus(new Object[] {ctx.getTarget()});
46
		return ctx.createFailureStatus(ctx.getTarget());
46
	}
47
	}
47
}
48
}
(-)build.properties (-2 / +2 lines)
Lines 19-23 Link Here
19
               .,\
19
               .,\
20
               about.html
20
               about.html
21
src.includes = about.html
21
src.includes = about.html
22
javacSource = 1.4
22
javacSource = 1.5
23
javacTarget = 1.4
23
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.adapter; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.adapter; singleton:=true
5
Bundle-Version: 1.0.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.examples.adapter.ValidationExamplePlugin
6
Bundle-Activator: org.eclipse.emf.validation.examples.adapter.ValidationExamplePlugin
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 12-18 Link Here
12
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
12
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
13
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.emf.examples.library;bundle-version="[2.2.0,3.0.0)",
15
 org.eclipse.emf.examples.library;bundle-version="[2.3.0,3.0.0)",
16
 org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)"
16
 org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)"
17
Eclipse-LazyStart: true
17
Eclipse-LazyStart: true
18
Bundle-RequiredExecutionEnvironment: J2SE-1.4
18
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:46:27 EST 2006
1
#Tue Oct 30 22:14:54 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)feature.xml (-6 / +8 lines)
Lines 18-24 Link Here
18
<feature
18
<feature
19
      id="org.eclipse.emf.validation.examples"
19
      id="org.eclipse.emf.validation.examples"
20
      label="%featureName"
20
      label="%featureName"
21
      version="1.1.100.qualifier"
21
      version="1.2.0.qualifier"
22
      provider-name="%providerName"
22
      provider-name="%providerName"
23
      image="modeling32.png">
23
      image="modeling32.png">
24
24
Lines 52-64 Link Here
52
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
52
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
53
      <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
53
      <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
54
      <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
54
      <import plugin="org.eclipse.ui.ide" version="3.2.0" match="compatible"/>
55
      <import plugin="org.eclipse.emf.validation" version="1.0.0" match="compatible"/>
56
      <import plugin="org.eclipse.emf.examples.library" version="2.2.0" match="compatible"/>
57
      <import plugin="org.eclipse.emf.examples.library.edit" version="2.2.0" match="compatible"/>
58
      <import plugin="org.eclipse.emf.examples.library.editor" version="2.2.0" match="compatible"/>
59
      <import plugin="org.eclipse.ui.console" version="3.1.100" match="compatible"/>
55
      <import plugin="org.eclipse.ui.console" version="3.1.100" match="compatible"/>
60
      <import plugin="org.eclipse.emf.validation.ui" version="1.0.0" match="compatible"/>
61
      <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
56
      <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
57
      <import plugin="org.eclipse.emf.validation" version="1.2.0" match="compatible"/>
58
      <import plugin="org.eclipse.emf.examples.library" version="2.3.0" match="compatible"/>
59
      <import plugin="org.eclipse.emf.examples.library.edit" version="2.3.0" match="compatible"/>
60
      <import plugin="org.eclipse.emf.examples.library.editor" version="2.3.0" match="compatible"/>
61
      <import plugin="org.eclipse.emf.validation.ui" version="1.2.0" match="compatible"/>
62
      <import plugin="org.eclipse.emf.validation.ocl" version="1.1.0" match="compatible"/>
63
      <import plugin="org.eclipse.ocl.ecore" version="1.1.0" match="compatible"/>
62
   </requires>
64
   </requires>
63
65
64
   <plugin
66
   <plugin
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-13 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.ocl; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.ocl; singleton:=true
5
Bundle-Version: 1.1.0.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Vendor: %Plugin.providerName
6
Bundle-Vendor: %Plugin.providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Export-Package: org.eclipse.emf.validation.internal.ocl;x-internal:=true,
8
Export-Package: org.eclipse.emf.validation.internal.ocl;x-internal:=true,
9
 org.eclipse.emf.validation.ocl
9
 org.eclipse.emf.validation.ocl
10
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)",
10
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)",
11
 org.eclipse.emf.ocl;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
11
 org.eclipse.emf.ocl;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
12
 org.eclipse.ocl;bundle-version="[1.1.0,2.0.0)";visibility:=reexport,
12
 org.eclipse.ocl;bundle-version="[1.1.0,2.0.0)";visibility:=reexport,
13
 org.eclipse.ocl.ecore;bundle-version="[1.1.0,2.0.0)",
13
 org.eclipse.ocl.ecore;bundle-version="[1.1.0,2.0.0)",
(-)src/org/eclipse/emf/validation/ocl/AbstractOCLModelConstraint.java (-2 / +4 lines)
Lines 111-118 Link Here
111
	 * @deprecated Override the {@link #createOCLEnvironmentFactory()} method,
111
	 * @deprecated Override the {@link #createOCLEnvironmentFactory()} method,
112
     * instead.
112
     * instead.
113
	 */
113
	 */
114
	@Deprecated
114
	protected org.eclipse.emf.ocl.parser.EnvironmentFactory createEnvironmentFactory() {
115
	protected org.eclipse.emf.ocl.parser.EnvironmentFactory createEnvironmentFactory() {
115
        return org.eclipse.emf.ocl.parser.EcoreEnvironmentFactory.ECORE_INSTANCE;
116
        return org.eclipse.emf.ocl.parser.EnvironmentFactory.ECORE_INSTANCE;
116
    }
117
    }
117
118
118
119
Lines 165-170 Link Here
165
     * 
166
     * 
166
     * @deprecated Use the {@link #getConstraintCondition(EObject)} method, instead.
167
     * @deprecated Use the {@link #getConstraintCondition(EObject)} method, instead.
167
	 */
168
	 */
169
	@Deprecated
168
	public org.eclipse.emf.ocl.query.Query getCondition(EClass eClass) {
170
	public org.eclipse.emf.ocl.query.Query getCondition(EClass eClass) {
169
		org.eclipse.emf.ocl.query.Query result = null;
171
		org.eclipse.emf.ocl.query.Query result = null;
170
		
172
		
Lines 209-215 Link Here
209
			//   variable and result locus, as OCL has no way to provide
211
			//   variable and result locus, as OCL has no way to provide
210
			//   additional extractions.  Also, there is no way for the OCL
212
			//   additional extractions.  Also, there is no way for the OCL
211
			//   to access the context object
213
			//   to access the context object
212
			return ctx.createFailureStatus(new Object[]{target});
214
			return ctx.createFailureStatus(target);
213
		}
215
		}
214
	}
216
	}
215
    
217
    
(-)src/org/eclipse/emf/validation/internal/service/LiveValidator.java (-57 / +59 lines)
Lines 28-33 Link Here
28
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
28
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
29
import org.eclipse.emf.validation.internal.util.Trace;
29
import org.eclipse.emf.validation.internal.util.Trace;
30
import org.eclipse.emf.validation.model.EvaluationMode;
30
import org.eclipse.emf.validation.model.EvaluationMode;
31
import org.eclipse.emf.validation.model.IModelConstraint;
31
import org.eclipse.emf.validation.service.EventTypeService;
32
import org.eclipse.emf.validation.service.EventTypeService;
32
import org.eclipse.emf.validation.service.ILiveValidator;
33
import org.eclipse.emf.validation.service.ILiveValidator;
33
import org.eclipse.emf.validation.service.INotificationGenerator;
34
import org.eclipse.emf.validation.service.INotificationGenerator;
Lines 38-45 Link Here
38
 *
39
 *
39
 * @author Christian W. Damus (cdamus)
40
 * @author Christian W. Damus (cdamus)
40
 */
41
 */
41
public class LiveValidator extends AbstractValidator implements ILiveValidator {
42
public class LiveValidator extends AbstractValidator<Notification> implements ILiveValidator {
42
	private FilteredCollection.Filter notificationFilter;
43
	private FilteredCollection.Filter<Notification> notificationFilter;
43
44
44
	/**
45
	/**
45
	 * Initializes me with the operation <code>executor</code> that I use to
46
	 * Initializes me with the operation <code>executor</code> that I use to
Lines 48-86 Link Here
48
	 * @param executor used by me to execute operations (must not be
49
	 * @param executor used by me to execute operations (must not be
49
	 *      <code>null</code>)
50
	 *      <code>null</code>)
50
	 */
51
	 */
51
	public LiveValidator(IProviderOperationExecutor executor) {
52
	public LiveValidator(IProviderOperationExecutor<Collection<IModelConstraint>> executor) {
52
		super(EvaluationMode.LIVE, executor);
53
		super(EvaluationMode.LIVE, executor);
53
	}
54
	}
54
55
55
	/* (non-Javadoc)
56
	/* (non-Javadoc)
56
	 * Implements the inherited method.
57
	 * Implements the inherited method.
57
	 */
58
	 */
58
	public IStatus validate(Notification notification) {
59
	@Override
59
		return validate((Object)notification);
60
	protected Collection<IStatus> doValidate(Collection<? extends Notification> objects,
60
	}
61
		Set<IClientContext> clientContexts) {
61
62
	/* (non-Javadoc)
63
	 * Implements the inherited method.
64
	 */
65
	protected Collection doValidate(Collection objects, Set clientContexts) {
66
		// Generate notifications for contributed emf event types
62
		// Generate notifications for contributed emf event types
67
		Collection notifications = generateNotifications(objects);
63
		Collection<Notification> notifications = generateNotifications(objects);
68
			
64
			
69
		// Merge similar notifications together to avoid repeated constraint
65
		// Merge similar notifications together to avoid repeated constraint
70
		// evaluations on the same kind of change to the same feature
66
		// evaluations on the same kind of change to the same feature
71
		List events = mergeNotifications(notifications);
67
		List<Notification> events = mergeNotifications(notifications);
72
		Iterator iter = events.iterator();
68
		Iterator<Notification> iter = events.iterator();
73
		
69
		
74
		List result = new java.util.ArrayList(32); // anticipate moderate number
70
		List<IStatus> result = new java.util.ArrayList<IStatus>(32); // anticipate moderate number
75
		
71
		
76
		GetLiveConstraintsOperation operation =
72
		GetLiveConstraintsOperation operation =
77
			new GetLiveConstraintsOperation();
73
			new GetLiveConstraintsOperation();
78
		operation.setAllEvents(new java.util.ArrayList(objects));
74
		operation.setAllEvents(new java.util.ArrayList<Notification>(objects));
79
		AbstractValidationContext ctx = operation.getContext();
75
		AbstractValidationContext ctx = operation.getContext();
80
		ctx.setReportSuccesses(isReportSuccesses());
76
		ctx.setReportSuccesses(isReportSuccesses());
81
		
77
		
82
		while (iter.hasNext()) {
78
		while (iter.hasNext()) {
83
			final Notification event = (Notification)iter.next();
79
			final Notification event = iter.next();
84
			
80
			
85
			Object notifier = event.getNotifier();
81
			Object notifier = event.getNotifier();
86
82
Lines 96-102 Link Here
96
					// set the validation context's client contexts so that we
92
					// set the validation context's client contexts so that we
97
					//    selected the most appropriate constraints to evaluate
93
					//    selected the most appropriate constraints to evaluate
98
					
94
					
99
					Collection contexts = ClientContextManager.getInstance().getClientContextsFor(
95
					Collection<IClientContext> contexts =
96
						ClientContextManager.getInstance().getClientContextsFor(
100
							(EObject) notifier);
97
							(EObject) notifier);
101
					
98
					
102
					ctx.setClientContexts(contexts);
99
					ctx.setClientContexts(contexts);
Lines 123-129 Link Here
123
			AbstractValidationContext ctx,
120
			AbstractValidationContext ctx,
124
			Notification event,
121
			Notification event,
125
			GetLiveConstraintsOperation operation,
122
			GetLiveConstraintsOperation operation,
126
			List results) {
123
			List<IStatus> results) {
127
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
124
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
128
			Trace.entering(getClass(), "validate", //$NON-NLS-1$
125
			Trace.entering(getClass(), "validate", //$NON-NLS-1$
129
					new Object[] {event});
126
					new Object[] {event});
Lines 148-160 Link Here
148
	 * @param notifications the input notifications
145
	 * @param notifications the input notifications
149
	 * @return the merged (possibly fewer) notifications
146
	 * @return the merged (possibly fewer) notifications
150
	 */
147
	 */
151
	private List mergeNotifications(Collection notifications) {
148
	private List<Notification> mergeNotifications(Collection<Notification> notifications) {
152
		// use a linked map to preserve list ordering
149
		// use a linked map to preserve list ordering
153
		Map result = new java.util.LinkedHashMap(notifications.size());
150
		Map<Notification, Notification> result =
151
			new java.util.LinkedHashMap<Notification, Notification>(notifications.size());
154
		
152
		
155
		for (Iterator iter = notifications.iterator(); iter.hasNext();) {
153
		for (Notification next : notifications) {
156
			Notification next = (Notification) iter.next();
157
			
158
			// only triggger constraints on EObjects that are still
154
			// only triggger constraints on EObjects that are still
159
			//  connected to a particular resource. We will filter the
155
			//  connected to a particular resource. We will filter the
160
			//  notification appropriately.
156
			//  notification appropriately.
Lines 172-188 Link Here
172
			}
168
			}
173
		}
169
		}
174
		
170
		
175
		return new java.util.ArrayList(result.keySet());
171
		return new java.util.ArrayList<Notification>(result.keySet());
176
	}
172
	}
177
	
173
	
178
	private Collection generateNotifications(Collection notifications) {
174
	private Collection<Notification> generateNotifications(
179
		Collection generators = EventTypeService.getInstance().getNotificationGenerators();
175
			Collection<? extends Notification> notifications) {
180
		Collection newNotifications = new ArrayList();
176
		
177
		Collection<INotificationGenerator> generators =
178
			EventTypeService.getInstance().getNotificationGenerators();
179
		Collection<Notification> newNotifications = new ArrayList<Notification>();
181
		
180
		
182
		// Add generated notifications for each generator
181
		// Add generated notifications for each generator
183
		for (Iterator iter = generators.iterator(); iter.hasNext();) {
182
		for (INotificationGenerator next : generators) {
184
			INotificationGenerator generator = (INotificationGenerator)iter.next();
183
			newNotifications.addAll(next.generateNotifications(notifications));
185
			newNotifications.addAll(generator.generateNotifications(notifications));
186
		}
184
		}
187
		
185
		
188
		// Add existing notifications
186
		// Add existing notifications
Lines 203-209 Link Here
203
		return getNotificationFilter().accept(notification);
201
		return getNotificationFilter().accept(notification);
204
	}
202
	}
205
	
203
	
206
	public void setNotificationFilter(FilteredCollection.Filter filter) {
204
	public void setNotificationFilter(FilteredCollection.Filter<Notification> filter) {
207
		notificationFilter = filter;
205
		notificationFilter = filter;
208
	}
206
	}
209
	
207
	
Lines 214-220 Link Here
214
	 * <code>AttachedToResourceNotificationFilter</code>.
212
	 * <code>AttachedToResourceNotificationFilter</code>.
215
     * </p>
213
     * </p>
216
	 */
214
	 */
217
	public FilteredCollection.Filter getNotificationFilter() {
215
	public FilteredCollection.Filter<Notification> getNotificationFilter() {
218
		if (notificationFilter == null) {
216
		if (notificationFilter == null) {
219
			notificationFilter = new AttachedToResourceNotificationFilter();
217
			notificationFilter = new AttachedToResourceNotificationFilter();
220
		}
218
		}
Lines 258-273 Link Here
258
			// take a copy to ensure that they are modifiable.  Also, this
256
			// take a copy to ensure that they are modifiable.  Also, this
259
			// avoids destroying the original notification's collection
257
			// avoids destroying the original notification's collection
260
			if (oldValue instanceof Collection) {
258
			if (oldValue instanceof Collection) {
261
				oldValue = new java.util.ArrayList((Collection) oldValue);
259
				oldValue = new java.util.ArrayList<Object>((Collection<?>) oldValue);
262
			}
260
			}
263
			if (newValue instanceof Collection) {
261
			if (newValue instanceof Collection) {
264
				newValue = new java.util.ArrayList((Collection) newValue);
262
				newValue = new java.util.ArrayList<Object>((Collection<?>) newValue);
265
			}
263
			}
266
		}
264
		}
267
		
265
		
268
		/* (non-Javadoc)
266
		/* (non-Javadoc)
269
		 * Redefines the inherited method to return the stored event type.
267
		 * Redefines the inherited method to return the stored event type.
270
		 */
268
		 */
269
		@Override
271
		public int getEventType() {
270
		public int getEventType() {
272
			return eventType;
271
			return eventType;
273
		}
272
		}
Lines 276-281 Link Here
276
		 * Redefines the inherited method to return the stored new feature
275
		 * Redefines the inherited method to return the stored new feature
277
		 * value.
276
		 * value.
278
		 */
277
		 */
278
		@Override
279
		public Object getNewValue() {
279
		public Object getNewValue() {
280
			return newValue;
280
			return newValue;
281
		}
281
		}
Lines 284-289 Link Here
284
		 * Redefines the inherited method to return the stored old feature
284
		 * Redefines the inherited method to return the stored old feature
285
		 * value.
285
		 * value.
286
		 */
286
		 */
287
		@Override
287
		public Object getOldValue() {
288
		public Object getOldValue() {
288
			return oldValue;
289
			return oldValue;
289
		}
290
		}
Lines 295-300 Link Here
295
		 * the same, as well as the "Remove" and "Remove Many", for the purposes
296
		 * the same, as well as the "Remove" and "Remove Many", for the purposes
296
		 * of this comparison.
297
		 * of this comparison.
297
		 */
298
		 */
299
		@Override
298
		public boolean equals(Object o) {
300
		public boolean equals(Object o) {
299
			boolean result = false;
301
			boolean result = false;
300
			
302
			
Lines 334-339 Link Here
334
		 * To be consistent with the {@link #equals(Object)} method, my hash
336
		 * To be consistent with the {@link #equals(Object)} method, my hash
335
		 * code is computed from my notifier, event type, and feature.
337
		 * code is computed from my notifier, event type, and feature.
336
		 */
338
		 */
339
		@Override
337
		public int hashCode() {
340
		public int hashCode() {
338
			int localEventType = getEventType();
341
			int localEventType = getEventType();
339
			
342
			
Lines 354-363 Link Here
354
		 * Redefines the inherited method to implement a merge for singleton and
357
		 * Redefines the inherited method to implement a merge for singleton and
355
		 * list features.
358
		 * list features.
356
		 */
359
		 */
360
		@Override
361
		@SuppressWarnings("unchecked")
357
		public boolean merge(Notification other) {
362
		public boolean merge(Notification other) {
358
			boolean result = false;
363
			boolean result = false;
359
			
364
			
360
			Collection newCollection;
365
			Collection<Object> newCollection;
361
			Object otherValue;
366
			Object otherValue;
362
			
367
			
363
			if (this.equals(other)) {
368
			if (this.equals(other)) {
Lines 366-381 Link Here
366
				case Notification.RESOLVE:
371
				case Notification.RESOLVE:
367
					
372
					
368
					if (newValue instanceof Collection) {
373
					if (newValue instanceof Collection) {
369
						newCollection = (Collection) newValue;
374
						newCollection = (Collection<Object>) newValue;
370
					} else {
375
					} else {
371
						newCollection = new java.util.ArrayList();
376
						newCollection = new java.util.ArrayList<Object>();
372
						newCollection.add(newValue);
377
						newCollection.add(newValue);
373
					}
378
					}
374
					
379
					
375
					otherValue = other.getNewValue();
380
					otherValue = other.getNewValue();
376
					
381
					
377
					if (otherValue instanceof Collection) {
382
					if (otherValue instanceof Collection) {
378
						newCollection.addAll((Collection) otherValue);
383
						newCollection.addAll((Collection<?>) otherValue);
379
					} else {
384
					} else {
380
						newCollection.add(otherValue);
385
						newCollection.add(otherValue);
381
					}
386
					}
Lines 388-403 Link Here
388
				case Notification.ADD_MANY:
393
				case Notification.ADD_MANY:
389
					
394
					
390
					if (newValue instanceof Collection) {
395
					if (newValue instanceof Collection) {
391
						newCollection = (Collection) newValue;
396
						newCollection = (Collection<Object>) newValue;
392
					} else {
397
					} else {
393
						newCollection = new java.util.ArrayList();
398
						newCollection = new java.util.ArrayList<Object>();
394
						newCollection.add(newValue);
399
						newCollection.add(newValue);
395
					}
400
					}
396
					
401
					
397
					otherValue = other.getNewValue();
402
					otherValue = other.getNewValue();
398
					
403
					
399
					if (otherValue instanceof Collection) {
404
					if (otherValue instanceof Collection) {
400
						newCollection.addAll((Collection) otherValue);
405
						newCollection.addAll((Collection<?>) otherValue);
401
					} else {
406
					} else {
402
						newCollection.add(otherValue);
407
						newCollection.add(otherValue);
403
					}
408
					}
Lines 411-426 Link Here
411
				case Notification.REMOVE_MANY:
416
				case Notification.REMOVE_MANY:
412
					
417
					
413
					if (oldValue instanceof Collection) {
418
					if (oldValue instanceof Collection) {
414
						newCollection = (Collection) oldValue;
419
						newCollection = (Collection<Object>) oldValue;
415
					} else {
420
					} else {
416
						newCollection = new java.util.ArrayList();
421
						newCollection = new java.util.ArrayList<Object>();
417
						newCollection.add(oldValue);
422
						newCollection.add(oldValue);
418
					}
423
					}
419
					
424
					
420
					otherValue = other.getOldValue();
425
					otherValue = other.getOldValue();
421
					
426
					
422
					if (otherValue instanceof Collection) {
427
					if (otherValue instanceof Collection) {
423
						newCollection.addAll((Collection) otherValue);
428
						newCollection.addAll((Collection<?>) otherValue);
424
					} else {
429
					} else {
425
						newCollection.add(otherValue);
430
						newCollection.add(otherValue);
426
					}
431
					}
Lines 433-448 Link Here
433
				case Notification.REMOVING_ADAPTER:
438
				case Notification.REMOVING_ADAPTER:
434
					
439
					
435
					if (oldValue instanceof Collection) {
440
					if (oldValue instanceof Collection) {
436
						newCollection = (Collection) oldValue;
441
						newCollection = (Collection<Object>) oldValue;
437
					} else {
442
					} else {
438
						newCollection = new java.util.ArrayList();
443
						newCollection = new java.util.ArrayList<Object>();
439
						newCollection.add(oldValue);
444
						newCollection.add(oldValue);
440
					}
445
					}
441
					
446
					
442
					otherValue = other.getOldValue();
447
					otherValue = other.getOldValue();
443
					
448
					
444
					if (otherValue instanceof Collection) {
449
					if (otherValue instanceof Collection) {
445
						newCollection.addAll((Collection) otherValue);
450
						newCollection.addAll((Collection<?>) otherValue);
446
					} else {
451
					} else {
447
						newCollection.add(otherValue);
452
						newCollection.add(otherValue);
448
					}
453
					}
Lines 477-491 Link Here
477
	 * <code>EObject</code> that is attached to a resource (i.e., it is not
482
	 * <code>EObject</code> that is attached to a resource (i.e., it is not
478
	 * deleted)
483
	 * deleted)
479
	 */
484
	 */
480
	private class AttachedToResourceNotificationFilter implements FilteredCollection.Filter {
485
	private class AttachedToResourceNotificationFilter
481
		public boolean accept(Object element) {
486
			implements FilteredCollection.Filter<Notification> {
482
			if (element instanceof Notification) {
487
		
483
				Notification notification = (Notification)element;
488
		public boolean accept(Notification element) {
484
				return (notification.getNotifier() instanceof EObject) &&
489
			return (element.getNotifier() instanceof EObject) &&
485
					(((EObject)notification.getNotifier()).eResource() != null);
490
				(((EObject) element.getNotifier()).eResource() != null);
486
			}
487
            
488
			return false;
489
		}
491
		}
490
	}
492
	}
491
}
493
}
(-)src/org/eclipse/emf/validation/internal/service/GetBatchConstraintsOperation.java (-10 / +11 lines)
Lines 48-76 Link Here
48
	}
48
	}
49
49
50
	// implements the inherited method
50
	// implements the inherited method
51
	@Override
51
	protected void executeImpl(
52
	protected void executeImpl(
52
			IModelConstraintProvider provider,
53
			IModelConstraintProvider provider,
53
			Collection constraints) {
54
			Collection<IModelConstraint> constraints) {
54
		assert provider != null;
55
		assert provider != null;
55
56
56
		provider.getBatchConstraints(getEObject(), constraints);
57
		provider.getBatchConstraints(getEObject(), constraints);
57
	}
58
	}
58
	
59
	
59
	// implements the inherited method
60
	// implements the inherited method
61
	@Override
60
	protected AbstractValidationContext createContext() {
62
	protected AbstractValidationContext createContext() {
61
		class BatchOnlyFilter implements FilteredCollection.Filter {
63
		class BatchOnlyFilter implements FilteredCollection.Filter<IModelConstraint> {
62
			private final FilteredCollection.Filter delegate;
64
			private final FilteredCollection.Filter<IModelConstraint> delegate;
63
			
65
			
64
			BatchOnlyFilter(FilteredCollection.Filter delegate) {
66
			BatchOnlyFilter(FilteredCollection.Filter<IModelConstraint> delegate) {
65
				this.delegate = delegate;
67
				this.delegate = delegate;
66
			}
68
			}
67
			
69
			
68
			// additionally exclude any live mode constraints
70
			// additionally exclude any live mode constraints
69
			public boolean accept(Object element) {
71
			public boolean accept(IModelConstraint element) {
70
				IModelConstraint constraint = (IModelConstraint)element;
72
				return element.getDescriptor().getEvaluationMode().isBatchOnly()
71
							
73
					&& delegate.accept(element);
72
				return constraint.getDescriptor().getEvaluationMode().isBatchOnly()
73
					&& delegate.accept(constraint);
74
			}
74
			}
75
		}
75
		}
76
		
76
		
Lines 78-84 Link Here
78
			// overrides the inherited method to provide a filter that
78
			// overrides the inherited method to provide a filter that
79
			//    additionally excludes "live" mode constraints if we are
79
			//    additionally excludes "live" mode constraints if we are
80
			//    only looking for batch mode
80
			//    only looking for batch mode
81
			public FilteredCollection.Filter getConstraintFilter() {
81
			@Override
82
			public FilteredCollection.Filter<IModelConstraint> getConstraintFilter() {
82
				if (!batchOnly) {
83
				if (!batchOnly) {
83
					return super.getConstraintFilter();
84
					return super.getConstraintFilter();
84
				} else {
85
				} else {
(-)src/org/eclipse/emf/validation/internal/service/AbstractGetConstraintsOperation.java (-8 / +11 lines)
Lines 18-23 Link Here
18
18
19
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
19
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
20
import org.eclipse.emf.validation.internal.util.Trace;
20
import org.eclipse.emf.validation.internal.util.Trace;
21
import org.eclipse.emf.validation.model.IModelConstraint;
21
import org.eclipse.emf.validation.service.IModelConstraintProvider;
22
import org.eclipse.emf.validation.service.IModelConstraintProvider;
22
import org.eclipse.emf.validation.util.FilteredCollection;
23
import org.eclipse.emf.validation.util.FilteredCollection;
23
24
Lines 30-44 Link Here
30
 * 
31
 * 
31
 * @author Christian W. Damus (cdamus)
32
 * @author Christian W. Damus (cdamus)
32
 */
33
 */
33
public abstract class AbstractGetConstraintsOperation implements IProviderOperation {
34
public abstract class AbstractGetConstraintsOperation
35
		implements IProviderOperation<Collection<IModelConstraint>> {
34
	
36
	
35
	/** The EMF object to be validated. */
37
	/** The EMF object to be validated. */
36
	private EObject eObject;
38
	private EObject eObject;
37
39
38
	/** The constraints which I have gathered from providers. */
40
	/** The constraints which I have gathered from providers. */
39
	private final Collection myConstraints = new java.util.ArrayList();
41
	private final Collection<IModelConstraint> myConstraints =
42
		new java.util.ArrayList<IModelConstraint>();
40
	
43
	
41
	private Collection filteredConstraints;
44
	private Collection<IModelConstraint> filteredConstraints;
42
	
45
	
43
	private AbstractValidationContext context;
46
	private AbstractValidationContext context;
44
47
Lines 86-99 Link Here
86
		// initialize the context now, if necessary
89
		// initialize the context now, if necessary
87
		if (context == null) {
90
		if (context == null) {
88
			context = createContext();
91
			context = createContext();
89
			filteredConstraints = new FilteredCollection(
92
			filteredConstraints = new FilteredCollection<IModelConstraint>(
90
					getUnfilteredConstraints(),
93
					getUnfilteredConstraints(),
91
					context.getConstraintFilter());
94
					context.getConstraintFilter());
92
		}
95
		}
93
	}
96
	}
94
	
97
	
95
	// implements the interface method
98
	// implements the interface method
96
	public final Collection getConstraints() {
99
	public final Collection<IModelConstraint> getConstraints() {
97
		return filteredConstraints;
100
		return filteredConstraints;
98
	}
101
	}
99
102
Lines 104-110 Link Here
104
	 * 
107
	 * 
105
	 * @return my full collection of constraints
108
	 * @return my full collection of constraints
106
	 */
109
	 */
107
	protected Collection getUnfilteredConstraints() {
110
	protected Collection<IModelConstraint> getUnfilteredConstraints() {
108
		return myConstraints;
111
		return myConstraints;
109
	}
112
	}
110
	
113
	
Lines 117-123 Link Here
117
	 * @param provider a constraint provider
120
	 * @param provider a constraint provider
118
	 * @return my unmodifiable constraints collection
121
	 * @return my unmodifiable constraints collection
119
	 */
122
	 */
120
	public Object execute(IModelConstraintProvider provider) {
123
	public Collection<IModelConstraint> execute(IModelConstraintProvider provider) {
121
		Trace.entering(
124
		Trace.entering(
122
				EMFModelValidationDebugOptions.PROVIDERS,
125
				EMFModelValidationDebugOptions.PROVIDERS,
123
				getClass(),
126
				getClass(),
Lines 153-157 Link Here
153
	 */
156
	 */
154
	protected abstract void executeImpl(
157
	protected abstract void executeImpl(
155
			IModelConstraintProvider provider,
158
			IModelConstraintProvider provider,
156
			Collection constraints);
159
			Collection<IModelConstraint> constraints);
157
}
160
}
(-)src/org/eclipse/emf/validation/internal/service/AbstractValidationContext.java (-47 / +48 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 44-50 Link Here
44
 * @author Christian W. Damus (cdamus)
44
 * @author Christian W. Damus (cdamus)
45
 */
45
 */
46
public abstract class AbstractValidationContext implements IValidationContext {
46
public abstract class AbstractValidationContext implements IValidationContext {
47
	private final IProviderOperation operation;
47
	private final IProviderOperation<Collection<IModelConstraint>> operation;
48
	
48
	
49
	// tracks the eObjects that are ignored by a constraint
49
	// tracks the eObjects that are ignored by a constraint
50
	private final ConstraintIgnorement ignoredConstraints =
50
	private final ConstraintIgnorement ignoredConstraints =
Lines 52-71 Link Here
52
	
52
	
53
	private ConstraintFilter filter;  // lazily initialized
53
	private ConstraintFilter filter;  // lazily initialized
54
	
54
	
55
	private final java.util.Map constraintData = new java.util.HashMap();
55
	private final Map<IConstraintDescriptor, Object> constraintData =
56
		new java.util.HashMap<IConstraintDescriptor, Object>();
56
57
57
	private IModelConstraint currentConstraint = null;
58
	private IModelConstraint currentConstraint = null;
58
	private IConstraintDescriptor currentDescriptor = null;
59
	private IConstraintDescriptor currentDescriptor = null;
59
		
60
		
60
	private Set resultLocus = new java.util.HashSet();
61
	private final Set<EObject> resultLocus = new java.util.HashSet<EObject>();
61
	
62
	
62
	private boolean reportSuccesses = false;
63
	private boolean reportSuccesses = false;
63
	
64
	
64
	private Collection clientContexts = Collections.EMPTY_SET;
65
	private Collection<IClientContext> clientContexts = Collections.emptySet();
65
	
66
	
66
	//	filters out all ignored and disabled, as well as constraints
67
	//	filters out all ignored and disabled, as well as constraints
67
	//	   that have already been executed on the current target
68
	//	   that have already been executed on the current target
68
	private class ConstraintFilter implements FilteredCollection.Filter {
69
	private class ConstraintFilter implements FilteredCollection.Filter<IModelConstraint> {
69
		/** Initializes me. */
70
		/** Initializes me. */
70
		ConstraintFilter() {
71
		ConstraintFilter() {
71
			// nothing to initialize.  Just declare the constructor explicitly
72
			// nothing to initialize.  Just declare the constructor explicitly
Lines 75-83 Link Here
75
		 * I filter out any constraint that is disabled, ignored, or has already
76
		 * I filter out any constraint that is disabled, ignored, or has already
76
		 * been evaluated against the current target object.
77
		 * been evaluated against the current target object.
77
		 */
78
		 */
78
		public boolean accept(Object constraint) {
79
		public boolean accept(IModelConstraint constraint) {
79
			IConstraintDescriptor desc =
80
			IConstraintDescriptor desc = constraint.getDescriptor();
80
				((IModelConstraint)constraint).getDescriptor();
81
			
81
			
82
			return (desc.isEnabled() && !isIgnored(desc));
82
			return (desc.isEnabled() && !isIgnored(desc));
83
		}
83
		}
Lines 100-106 Link Here
100
	//    whether they are triggered for specific features (in the live and
100
	//    whether they are triggered for specific features (in the live and
101
	//    feature validation cases) or just by the object type (batch mode)
101
	//    feature validation cases) or just by the object type (batch mode)
102
	private class ConstraintIgnorement {
102
	private class ConstraintIgnorement {
103
		private final Map ignoreMap = new java.util.HashMap();
103
		private final Map<EObject, Collection<IConstraintDescriptor>> ignoreMap =
104
			new java.util.HashMap<EObject, Collection<IConstraintDescriptor>>();
104
		
105
		
105
		/**
106
		/**
106
		 * Ignores the specified <code>constraint</code> for this
107
		 * Ignores the specified <code>constraint</code> for this
Lines 111-117 Link Here
111
		 * @param constraint the constraint
112
		 * @param constraint the constraint
112
		 */
113
		 */
113
		void ignore(EObject eObject, IConstraintDescriptor constraint) {
114
		void ignore(EObject eObject, IConstraintDescriptor constraint) {
114
			Collection ignored = getIgnoredConstraints(eObject);
115
			Collection<IConstraintDescriptor> ignored = getIgnoredConstraints(eObject);
115
			
116
			
116
			if (ignored == null) {
117
			if (ignored == null) {
117
				ignored = initIgnoredConstraints(eObject);
118
				ignored = initIgnoredConstraints(eObject);
Lines 130-136 Link Here
130
		 * @return whether the <code>constraint</code> is ignored
131
		 * @return whether the <code>constraint</code> is ignored
131
		 */
132
		 */
132
		boolean isIgnored(EObject eObject, IConstraintDescriptor constraint) {
133
		boolean isIgnored(EObject eObject, IConstraintDescriptor constraint) {
133
			Collection ignored = getIgnoredConstraints(eObject);
134
			Collection<IConstraintDescriptor> ignored = getIgnoredConstraints(eObject);
134
			
135
			
135
			return (ignored != null) && ignored.contains(constraint);
136
			return (ignored != null) && ignored.contains(constraint);
136
		}
137
		}
Lines 145-152 Link Here
145
		 *    and that are not triggered by a feature, or <code>null</code> if
146
		 *    and that are not triggered by a feature, or <code>null</code> if
146
		 *    no ignored constraints collection exists, yet
147
		 *    no ignored constraints collection exists, yet
147
		 */
148
		 */
148
		private Collection getIgnoredConstraints(EObject target) {
149
		private Collection<IConstraintDescriptor> getIgnoredConstraints(EObject target) {
149
			return (Collection) ignoreMap.get(target);
150
			return ignoreMap.get(target);
150
		}
151
		}
151
	
152
	
152
		/**
153
		/**
Lines 156-163 Link Here
156
		 * @param target a validation target object
157
		 * @param target a validation target object
157
		 * @return the new ignored constraints collection
158
		 * @return the new ignored constraints collection
158
		 */
159
		 */
159
		private Collection initIgnoredConstraints(EObject target) {
160
		private Collection<IConstraintDescriptor> initIgnoredConstraints(EObject target) {
160
			Collection result = new java.util.HashSet();
161
			Collection<IConstraintDescriptor> result = new java.util.HashSet<IConstraintDescriptor>();
161
			
162
			
162
			ignoreMap.put(target, result);
163
			ignoreMap.put(target, result);
163
		
164
		
Lines 171-177 Link Here
171
	 * @param operation the operation for which I provide a validation context
172
	 * @param operation the operation for which I provide a validation context
172
	 */
173
	 */
173
	protected AbstractValidationContext(
174
	protected AbstractValidationContext(
174
			IProviderOperation operation) {
175
			IProviderOperation<Collection<IModelConstraint>> operation) {
175
		this.operation = operation;
176
		this.operation = operation;
176
	}
177
	}
177
178
Lines 180-186 Link Here
180
	 * 
181
	 * 
181
	 * @return my operation
182
	 * @return my operation
182
	 */
183
	 */
183
	protected final IProviderOperation getOperation() {
184
	protected final IProviderOperation<Collection<IModelConstraint>> getOperation() {
184
		return operation;
185
		return operation;
185
	}
186
	}
186
	
187
	
Lines 194-201 Link Here
194
	/**
195
	/**
195
	 * Default implementation simply returns an empty list.
196
	 * Default implementation simply returns an empty list.
196
	 */
197
	 */
197
	public List getAllEvents() {
198
	public List<Notification> getAllEvents() {
198
		return Collections.EMPTY_LIST;
199
		return Collections.emptyList();
199
	}
200
	}
200
201
201
	/**
202
	/**
Lines 225-234 Link Here
225
	}
226
	}
226
	
227
	
227
	// implements the interface method
228
	// implements the interface method
228
	public void skipCurrentConstraintForAll(Collection eObjects) {
229
	public void skipCurrentConstraintForAll(Collection<?> eObjects) {
229
		for (Iterator iter = eObjects.iterator(); iter.hasNext();) {
230
		for (Object next : eObjects) {
230
			Object next = iter.next();
231
			
232
			if (next instanceof EObject) {
231
			if (next instanceof EObject) {
233
				skipCurrentConstraintFor((EObject)next);
232
				skipCurrentConstraintFor((EObject)next);
234
			}
233
			}
Lines 243-249 Link Here
243
	 * 
242
	 * 
244
	 * @return a constraint filter for this context
243
	 * @return a constraint filter for this context
245
	 */
244
	 */
246
	public FilteredCollection.Filter getConstraintFilter() {
245
	public FilteredCollection.Filter<IModelConstraint> getConstraintFilter() {
247
		if (filter == null) {
246
		if (filter == null) {
248
			filter = new ConstraintFilter();
247
			filter = new ConstraintFilter();
249
		}
248
		}
Lines 268-274 Link Here
268
	
267
	
269
	// implements the interface method
268
	// implements the interface method
270
	public final Object putCurrentConstraintData(Object newData) {
269
	public final Object putCurrentConstraintData(Object newData) {
271
		return constraintData.put(getConstraint(), newData);
270
		return constraintData.put(getConstraint().getDescriptor(), newData);
272
	}
271
	}
273
	
272
	
274
	/**
273
	/**
Lines 298-315 Link Here
298
		resultLocus.add(eObject);
297
		resultLocus.add(eObject);
299
	}
298
	}
300
	
299
	
301
	public void addResults(Collection eObjects) {
300
	public void addResults(Collection<? extends EObject> eObjects) {
302
		assert eObjects != null;
301
		assert eObjects != null;
303
		
302
		
304
		// explicitly iterate instead of calling resultLocus.addAll() in order
303
		// explicitly iterate instead of calling resultLocus.addAll() in order
305
		//    to assert the types of the elements by casting
304
		//    to assert the types of the elements by casting
306
		for (Iterator iter = eObjects.iterator(); iter.hasNext();) {
305
		for (EObject next : eObjects) {
307
			addResult((EObject)iter.next());
306
			addResult(next);
308
		}
307
		}
309
	}
308
	}
310
	
309
	
311
	// implements the interface method
310
	// implements the interface method
312
	public Set getResultLocus() {
311
	public Set<EObject> getResultLocus() {
313
		return java.util.Collections.unmodifiableSet(resultLocus);
312
		return java.util.Collections.unmodifiableSet(resultLocus);
314
	}
313
	}
315
	
314
	
Lines 328-334 Link Here
328
	}
327
	}
329
	
328
	
330
	/**
329
	/**
331
	 * Obtains the dscriptor of the constraint currently being evaluated.
330
	 * Obtains the descriptor of the constraint currently being evaluated.
332
	 * 
331
	 * 
333
	 * @return the current constraint'sdescriptor
332
	 * @return the current constraint'sdescriptor
334
	 */
333
	 */
Lines 388-394 Link Here
388
	}
387
	}
389
388
390
	// implements the interface method
389
	// implements the interface method
391
	public IStatus createFailureStatus(Object[] messageArgs) {
390
	public IStatus createFailureStatus(Object... messageArgs) {
392
		
391
		
393
		String message = TextUtils.formatMessage(
392
		String message = TextUtils.formatMessage(
394
				getDescriptor().getMessagePattern(),
393
				getDescriptor().getMessagePattern(),
Lines 412-429 Link Here
412
	 * 
411
	 * 
413
	 * @return my constraints
412
	 * @return my constraints
414
	 */
413
	 */
415
	final Collection getConstraints() {
414
	final Collection<IModelConstraint> getConstraints() {
416
		// use only those constraints that match the client contexts
415
		// use only those constraints that match the client contexts
417
		final Collection delegate = ClientContextManager.getInstance().getBindings(
416
		final Collection<IModelConstraint> delegate = ClientContextManager.getInstance().getBindings(
418
				clientContexts,
417
				clientContexts,
419
				getOperation().getConstraints());
418
				getOperation().getConstraints());
420
		
419
		
421
		// wraps my constraints collection's iterator in order to access
420
		// wraps my constraints collection's iterator in order to access
422
		//    the descriptor of each constraint as it is traversed
421
		//    the descriptor of each constraint as it is traversed
423
		class ConstraintsIterator implements Iterator {
422
		class ConstraintsIterator implements Iterator<IModelConstraint> {
424
			private final Iterator delegateIterator;
423
			private final Iterator<? extends IModelConstraint> delegateIterator;
425
424
426
			ConstraintsIterator(Collection delegateCollection) {
425
			ConstraintsIterator(Collection<? extends IModelConstraint> delegateCollection) {
427
				this.delegateIterator = delegateCollection.iterator();
426
				this.delegateIterator = delegateCollection.iterator();
428
			}
427
			}
429
			
428
			
Lines 435-445 Link Here
435
			// implements the interface method, additionally setting attributes
434
			// implements the interface method, additionally setting attributes
436
			//    of the enclosing context object from the next constraint
435
			//    of the enclosing context object from the next constraint
437
			//    descriptor
436
			//    descriptor
438
			public Object next() {
437
			public IModelConstraint next() {
439
				Object result = delegateIterator.next();
438
				IModelConstraint result = delegateIterator.next();
440
				
439
				
441
				// make this descriptor available in the context
440
				// make this descriptor available in the context
442
				setConstraint((IModelConstraint)result);
441
				setConstraint(result);
443
				
442
				
444
				// set the default result locus for this next constraint
443
				// set the default result locus for this next constraint
445
				AbstractValidationContext.this.initializeResultLocus();
444
				AbstractValidationContext.this.initializeResultLocus();
Lines 452-462 Link Here
452
				throw new UnsupportedOperationException();
451
				throw new UnsupportedOperationException();
453
			}}
452
			}}
454
		
453
		
455
		return new AbstractCollection() {
454
		return new AbstractCollection<IModelConstraint>() {
456
			public Iterator iterator() {
455
			@Override
456
			public Iterator<IModelConstraint> iterator() {
457
				return new ConstraintsIterator(delegate);
457
				return new ConstraintsIterator(delegate);
458
			}
458
			}
459
459
460
			@Override
460
			public int size() {
461
			public int size() {
461
				return delegate.size();
462
				return delegate.size();
462
			}};
463
			}};
Lines 470-478 Link Here
470
	 *    {@link org.eclipse.emf.validation.internal.service.IClientContext}s
471
	 *    {@link org.eclipse.emf.validation.internal.service.IClientContext}s
471
	 *    or <code>null</code> to specify none
472
	 *    or <code>null</code> to specify none
472
	 */
473
	 */
473
	final void setClientContexts(Collection clientContexts) {
474
	final void setClientContexts(Collection<IClientContext> clientContexts) {
474
		if (clientContexts == null) {
475
		if (clientContexts == null) {
475
			clientContexts = Collections.EMPTY_SET;
476
			clientContexts = Collections.emptySet();
476
		}
477
		}
477
		
478
		
478
		this.clientContexts = clientContexts;
479
		this.clientContexts = clientContexts;
Lines 485-491 Link Here
485
	 * @return a collection of
486
	 * @return a collection of
486
	 *    {@link org.eclipse.emf.validation.internal.service.IClientContext}s
487
	 *    {@link org.eclipse.emf.validation.internal.service.IClientContext}s
487
	 */
488
	 */
488
	final Collection getClientContexts() {
489
	final Collection<IClientContext> getClientContexts() {
489
		return clientContexts;
490
		return clientContexts;
490
	}
491
	}
491
	
492
	
Lines 522-529 Link Here
522
		/* (non-Javadoc)
523
		/* (non-Javadoc)
523
		 * Implements the inherited method.
524
		 * Implements the inherited method.
524
		 */
525
		 */
525
		public Set getResultLocus() {
526
		public Set<EObject> getResultLocus() {
526
			return Collections.EMPTY_SET;
527
			return Collections.emptySet();
527
		}
528
		}
528
	}
529
	}
529
}
530
}
(-)src/org/eclipse/emf/validation/internal/service/BatchValidator.java (-30 / +37 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 29-34 Link Here
29
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
29
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
30
import org.eclipse.emf.validation.internal.util.Trace;
30
import org.eclipse.emf.validation.internal.util.Trace;
31
import org.eclipse.emf.validation.model.EvaluationMode;
31
import org.eclipse.emf.validation.model.EvaluationMode;
32
import org.eclipse.emf.validation.model.IModelConstraint;
32
import org.eclipse.emf.validation.service.IBatchValidator;
33
import org.eclipse.emf.validation.service.IBatchValidator;
33
import org.eclipse.emf.validation.service.ITraversalStrategy;
34
import org.eclipse.emf.validation.service.ITraversalStrategy;
34
35
Lines 40-46 Link Here
40
 *
41
 *
41
 * @author Christian W. Damus (cdamus)
42
 * @author Christian W. Damus (cdamus)
42
 */
43
 */
43
public class BatchValidator extends AbstractValidator implements IBatchValidator {
44
public class BatchValidator extends AbstractValidator<EObject> implements IBatchValidator {
44
	private boolean includeLiveConstraints = false;
45
	private boolean includeLiveConstraints = false;
45
	private IProgressMonitor progressMonitor = null;
46
	private IProgressMonitor progressMonitor = null;
46
	
47
	
Lines 54-60 Link Here
54
	 * @param executor used by me to execute operations (must not be
55
	 * @param executor used by me to execute operations (must not be
55
	 *      <code>null</code>)
56
	 *      <code>null</code>)
56
	 */
57
	 */
57
	public BatchValidator(IProviderOperationExecutor executor) {
58
	public BatchValidator(
59
			IProviderOperationExecutor<Collection<IModelConstraint>> executor) {
58
		super(EvaluationMode.BATCH, executor);
60
		super(EvaluationMode.BATCH, executor);
59
	}
61
	}
60
62
Lines 96-102 Link Here
96
98
97
		this.traversalStrategy = strategy;
99
		this.traversalStrategy = strategy;
98
	}
100
	}
99
101
	
100
	/* (non-Javadoc)
102
	/* (non-Javadoc)
101
	 * Implements the inherited method.
103
	 * Implements the inherited method.
102
	 */
104
	 */
Lines 113-119 Link Here
113
	/* (non-Javadoc)
115
	/* (non-Javadoc)
114
	 * Implements the inherited method.
116
	 * Implements the inherited method.
115
	 */
117
	 */
116
	public IStatus validate(Collection objects, IProgressMonitor monitor) {
118
	public IStatus validate(Collection<? extends EObject> objects, IProgressMonitor monitor) {
117
		IStatus result;
119
		IStatus result;
118
		
120
		
119
		progressMonitor = monitor;
121
		progressMonitor = monitor;
Lines 126-133 Link Here
126
	/* (non-Javadoc)
128
	/* (non-Javadoc)
127
	 * Implements the inherited method.
129
	 * Implements the inherited method.
128
	 */
130
	 */
129
	protected Collection doValidate(Collection objects, Set clientContexts) {
131
	@Override
130
		List result = new java.util.ArrayList(64);  // anticipate large scale
132
	protected Collection<IStatus> doValidate(Collection<? extends EObject> objects,
133
			Set<IClientContext> clientContexts) {
134
		
135
		List<IStatus> result = new java.util.ArrayList<IStatus>(64);  // anticipate large scale
131
		
136
		
132
		GetBatchConstraintsOperation operation =
137
		GetBatchConstraintsOperation operation =
133
			new GetBatchConstraintsOperation(!isIncludeLiveConstraints());
138
			new GetBatchConstraintsOperation(!isIncludeLiveConstraints());
Lines 155-165 Link Here
155
	 */
160
	 */
156
	private void validate(
161
	private void validate(
157
			ITraversalStrategy traversal,
162
			ITraversalStrategy traversal,
158
			List evaluationResults,
163
			List<IStatus> evaluationResults,
159
			AbstractValidationContext ctx,
164
			AbstractValidationContext ctx,
160
			Collection objects,
165
			Collection<? extends EObject> objects,
161
			GetBatchConstraintsOperation operation, 
166
			GetBatchConstraintsOperation operation, 
162
			Set clientContexts) {
167
			Set<IClientContext> clientContexts) {
163
		
168
		
164
		IProgressMonitor monitor = progressMonitor;
169
		IProgressMonitor monitor = progressMonitor;
165
		if (monitor == null) {
170
		if (monitor == null) {
Lines 181-187 Link Here
181
				final EObject next = traversal.next();
186
				final EObject next = traversal.next();
182
187
183
				if (recomputeClients) {
188
				if (recomputeClients) {
184
					Collection contexts = ClientContextManager.getInstance()
189
					Collection<IClientContext> contexts = ClientContextManager.getInstance()
185
							.getClientContextsFor(next);
190
							.getClientContextsFor(next);
186
					ctx.setClientContexts(contexts);
191
					ctx.setClientContexts(contexts);
187
					clientContexts.addAll(contexts);
192
					clientContexts.addAll(contexts);
Lines 225-231 Link Here
225
			AbstractValidationContext ctx,
230
			AbstractValidationContext ctx,
226
			EObject eObject,
231
			EObject eObject,
227
			GetBatchConstraintsOperation operation,
232
			GetBatchConstraintsOperation operation,
228
			List results) {
233
			List<IStatus> results) {
229
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
234
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
230
			Trace.entering(getClass(), "validate", //$NON-NLS-1$
235
			Trace.entering(getClass(), "validate", //$NON-NLS-1$
231
					new Object[] {eObject});
236
					new Object[] {eObject});
Lines 248-277 Link Here
248
	}
253
	}
249
	
254
	
250
	private static class DefaultRecursiveTraversalStrategy implements ITraversalStrategy {
255
	private static class DefaultRecursiveTraversalStrategy implements ITraversalStrategy {
251
		private Map delegates;
256
		private Map<ITraversalStrategy, Collection<EObject>> delegates;
252
		private Iterator delegateIterator;
257
		private Map<ITraversalStrategy, IProgressMonitor> monitors;
258
		private Iterator<ITraversalStrategy> delegateIterator;
253
		private ITraversalStrategy current;
259
		private ITraversalStrategy current;
254
		
260
		
255
		/* (non-Javadoc)
261
		/* (non-Javadoc)
256
		 * Redefines/Implements/Extends the inherited method.
262
		 * Redefines/Implements/Extends the inherited method.
257
		 */
263
		 */
258
		public void startTraversal(Collection traversalRoots, IProgressMonitor monitor) {
264
		public void startTraversal(Collection<? extends EObject> traversalRoots,
265
				IProgressMonitor monitor) {
259
			delegates = initDelegates(traversalRoots);
266
			delegates = initDelegates(traversalRoots);
267
			monitors = new java.util.HashMap<ITraversalStrategy, IProgressMonitor>();
260
			
268
			
261
			monitor.beginTask("", delegates.size() * 1024); //$NON-NLS-1$
269
			monitor.beginTask("", delegates.size() * 1024); //$NON-NLS-1$
262
			
270
			
263
			for (Iterator iter = delegates.entrySet().iterator(); iter.hasNext();) {
271
			for (Map.Entry<ITraversalStrategy, Collection<EObject>> next :
264
				Map.Entry next = (Map.Entry)iter.next();
272
					delegates.entrySet()) {
265
				
273
				
266
				SubProgressMonitor sub = new SubProgressMonitor(
274
				SubProgressMonitor sub = new SubProgressMonitor(
267
					monitor,
275
					monitor,
268
					1024,
276
					1024,
269
					SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
277
					SubProgressMonitor.SUPPRESS_SUBTASK_LABEL);
270
				((ITraversalStrategy)next.getKey()).startTraversal(
278
				next.getKey().startTraversal(next.getValue(), sub);
271
					(Collection)next.getValue(),
272
					sub);
273
				
279
				
274
				next.setValue(sub);
280
				monitors.put(next.getKey(), sub);
275
			}
281
			}
276
			
282
			
277
			delegateIterator = delegates.keySet().iterator();
283
			delegateIterator = delegates.keySet().iterator();
Lines 282-288 Link Here
282
		 */
288
		 */
283
		public boolean hasNext() {
289
		public boolean hasNext() {
284
			if ((current == null) && (delegateIterator.hasNext())) {
290
			if ((current == null) && (delegateIterator.hasNext())) {
285
				current = (ITraversalStrategy)delegateIterator.next();
291
				current = delegateIterator.next();
286
			}
292
			}
287
			
293
			
288
			if (current == null) {
294
			if (current == null) {
Lines 290-296 Link Here
290
			}
296
			}
291
			
297
			
292
			if (!current.hasNext()) {
298
			if (!current.hasNext()) {
293
				((IProgressMonitor)delegates.get(current)).done();
299
				monitors.get(current).done();
294
				current = null;
300
				current = null;
295
				
301
				
296
				return hasNext();  // get the next delegate and try it
302
				return hasNext();  // get the next delegate and try it
Lines 328-345 Link Here
328
			current.elementValidated(element, status);
334
			current.elementValidated(element, status);
329
		}
335
		}
330
		
336
		
331
		private Map initDelegates(Collection traversalRoots) {
337
		private Map<ITraversalStrategy, Collection<EObject>> initDelegates(
332
			Map result = new java.util.HashMap();
338
				Collection<? extends EObject> traversalRoots) {
333
			
339
			
334
			for (Iterator iter = traversalRoots.iterator(); iter.hasNext();) {
340
			Map<ITraversalStrategy, Collection<EObject>> result =
335
				EObject next = (EObject)iter.next();
341
				new java.util.HashMap<ITraversalStrategy, Collection<EObject>>();
336
				
342
			
343
			for (EObject next : traversalRoots) {
337
				ITraversalStrategy delegate = TraversalStrategyManager
344
				ITraversalStrategy delegate = TraversalStrategyManager
338
					.getInstance().getTraversalStrategy(next);
345
					.getInstance().getTraversalStrategy(next);
339
				
346
				
340
				Collection delegateRoots = (Collection)result.get(delegate);
347
				Collection<EObject> delegateRoots = result.get(delegate);
341
				if (delegateRoots == null) {
348
				if (delegateRoots == null) {
342
					delegateRoots = new java.util.LinkedList();
349
					delegateRoots = new java.util.ArrayList<EObject>();
343
					result.put(delegate, delegateRoots);
350
					result.put(delegate, delegateRoots);
344
				}
351
				}
345
				
352
				
(-)src/org/eclipse/emf/validation/internal/service/IProviderOperationExecutor.java (-2 / +4 lines)
Lines 20-33 Link Here
20
 * implementations in this package to execute operations
20
 * implementations in this package to execute operations
21
 * in the context of the object that created them.
21
 * in the context of the object that created them.
22
 *
22
 *
23
 * @param <T> the result type of the operation that I execute
24
 *
23
 * @author Christian W. Damus (cdamus)
25
 * @author Christian W. Damus (cdamus)
24
 */
26
 */
25
public interface IProviderOperationExecutor {
27
public interface IProviderOperationExecutor<T> {
26
	/**
28
	/**
27
	 * Executes the specified <code>op</code>eration.
29
	 * Executes the specified <code>op</code>eration.
28
	 * 
30
	 * 
29
	 * @param op the operation to execute.  The execution result must be
31
	 * @param op the operation to execute.  The execution result must be
30
	 *     obtained from it
32
	 *     obtained from it
31
	 */
33
	 */
32
	void execute(IProviderOperation op);
34
	void execute(IProviderOperation<? extends T> op);
33
}
35
}
(-)src/org/eclipse/emf/validation/internal/service/ConstraintCache.java (-40 / +40 lines)
Lines 64-73 Link Here
64
	 * weak map to avoid interfering with garbage-collection of EMF metamodels
64
	 * weak map to avoid interfering with garbage-collection of EMF metamodels
65
	 * (and to clean up the cache when metamodels disappear!).
65
	 * (and to clean up the cache when metamodels disappear!).
66
	 */
66
	 */
67
	private final Map buckets = new java.util.WeakHashMap();
67
	private final Map<EClass, EClassBucket> buckets =
68
		new java.util.WeakHashMap<EClass, EClassBucket>();
68
	
69
	
69
	/** The cacheable providers. */
70
	/** The cacheable providers. */
70
	private final Collection providers = new java.util.ArrayList();
71
	private final Collection<IProviderDescriptor> providers =
72
		new java.util.ArrayList<IProviderDescriptor>();
71
	
73
	
72
	/**
74
	/**
73
	 * A container for the constraints provided by all cacheable providers
75
	 * A container for the constraints provided by all cacheable providers
Lines 76-83 Link Here
76
	 * @author Christian W. Damus (cdamus)
78
	 * @author Christian W. Damus (cdamus)
77
	 */
79
	 */
78
	private static class EClassBucket {
80
	private static class EClassBucket {
79
		private Collection batchConstraints;
81
		private Collection<IModelConstraint> batchConstraints;
80
		private final Map liveConstraints = new java.util.HashMap();
82
		private final Map<EMFEventType, Map<String, Collection<IModelConstraint>>>
83
		liveConstraints = new java.util.HashMap<EMFEventType, Map<String, Collection<IModelConstraint>>>();
81
		
84
		
82
		/**
85
		/**
83
		 * Initializes me.
86
		 * Initializes me.
Lines 92-98 Link Here
92
		 * @return my batch constraints, or <code>null</code> if they have not
95
		 * @return my batch constraints, or <code>null</code> if they have not
93
		 *    yet been retrieved from my registered providers
96
		 *    yet been retrieved from my registered providers
94
		 */
97
		 */
95
		Collection getBatchConstraints() {
98
		Collection<IModelConstraint> getBatchConstraints() {
96
			return batchConstraints;
99
			return batchConstraints;
97
		}
100
		}
98
		
101
		
Lines 101-108 Link Here
101
		 * 
104
		 * 
102
		 * @param constraints the batch constraints
105
		 * @param constraints the batch constraints
103
		 */
106
		 */
104
		void cacheBatchConstraints(Collection constraints) {
107
		void cacheBatchConstraints(Collection<IModelConstraint> constraints) {
105
			batchConstraints = new java.util.ArrayList(constraints);
108
			batchConstraints = new java.util.ArrayList<IModelConstraint>(constraints);
106
		}
109
		}
107
		
110
		
108
		/**
111
		/**
Lines 116-130 Link Here
116
		 * @return the corresponding constraints, or <code>null</code> if they
119
		 * @return the corresponding constraints, or <code>null</code> if they
117
		 *     have not yet been retrieved from my registered providers
120
		 *     have not yet been retrieved from my registered providers
118
		 */
121
		 */
119
		Collection getLiveConstraints(EMFEventType eventType, String featureName) {
122
		Collection<IModelConstraint> getLiveConstraints(EMFEventType eventType, String featureName) {
120
			if (featureName == null) {
123
			if (featureName == null) {
121
				featureName = NOT_A_FEATURE_NAME;
124
				featureName = NOT_A_FEATURE_NAME;
122
			}
125
			}
123
			
126
			
124
			Map constraintMap = (Map)liveConstraints.get(eventType);
127
			Map<String, Collection<IModelConstraint>> constraintMap =
128
				liveConstraints.get(eventType);
125
			
129
			
126
			if (constraintMap != null) {
130
			if (constraintMap != null) {
127
				return (Collection)constraintMap.get(featureName);
131
				return constraintMap.get(featureName);
128
			} else {
132
			} else {
129
				return null;
133
				return null;
130
			}
134
			}
Lines 143-164 Link Here
143
		void cacheLiveConstraints(
147
		void cacheLiveConstraints(
144
				EMFEventType eventType,
148
				EMFEventType eventType,
145
				String featureName,
149
				String featureName,
146
				Collection constraints) {
150
				Collection<IModelConstraint> constraints) {
147
			
151
			
148
			if (featureName == null) {
152
			if (featureName == null) {
149
				featureName = NOT_A_FEATURE_NAME;
153
				featureName = NOT_A_FEATURE_NAME;
150
			}
154
			}
151
	
155
	
152
			Map constraintMap = (Map)liveConstraints.get(eventType);
156
			Map<String, Collection<IModelConstraint>> constraintMap =
157
				liveConstraints.get(eventType);
153
	
158
	
154
			if (constraintMap == null) {
159
			if (constraintMap == null) {
155
				constraintMap = new java.util.HashMap();
160
				constraintMap = new java.util.HashMap<String, Collection<IModelConstraint>>();
156
				liveConstraints.put(eventType, constraintMap);
161
				liveConstraints.put(eventType, constraintMap);
157
			}
162
			}
158
			
163
			
159
			constraintMap.put(
164
			constraintMap.put(
160
					featureName,
165
					featureName,
161
					new java.util.ArrayList(constraints));
166
					new java.util.ArrayList<IModelConstraint>(constraints));
162
		}
167
		}
163
		
168
		
164
		/**
169
		/**
Lines 175-186 Link Here
175
			}
180
			}
176
			
181
			
177
			// replace in the live constraints, if appropriate
182
			// replace in the live constraints, if appropriate
178
			for (Iterator iter = liveConstraints.values().iterator(); iter.hasNext();) {
183
			for (Map<String, Collection<IModelConstraint>> next : liveConstraints.values()) {
179
				Map next = (Map) iter.next();
184
				for (Collection<IModelConstraint> constraints : next.values()) {
180
				
181
				for (Iterator nested = next.values().iterator(); nested.hasNext();) {
182
					Collection constraints = (Collection) nested.next();
183
					
184
					if ((constraints != null) && constraints.remove(oldConstraint)) {
185
					if ((constraints != null) && constraints.remove(oldConstraint)) {
185
						constraints.add(newConstraint);
186
						constraints.add(newConstraint);
186
					}
187
					}
Lines 204-210 Link Here
204
	public IProviderDescriptor getDescriptor() {
205
	public IProviderDescriptor getDescriptor() {
205
		return new IProviderDescriptor() {
206
		return new IProviderDescriptor() {
206
			// the cache is assumed to always have an answer
207
			// the cache is assumed to always have an answer
207
			public boolean provides(IProviderOperation operation) {
208
			public boolean provides(
209
					IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
208
				return true;
210
				return true;
209
			}
211
			}
210
212
Lines 234-240 Link Here
234
	 * 
236
	 * 
235
	 * @return the cached providers
237
	 * @return the cached providers
236
	 */
238
	 */
237
	public Collection getProviders() {
239
	public Collection<IProviderDescriptor> getProviders() {
238
		return providers;
240
		return providers;
239
	}
241
	}
240
242
Lines 258-264 Link Here
258
	 * @return the corresponding bucket
260
	 * @return the corresponding bucket
259
	 */
261
	 */
260
	private EClassBucket getBucket(EClass clazz) {
262
	private EClassBucket getBucket(EClass clazz) {
261
		EClassBucket result = (EClassBucket)buckets.get(clazz);
263
		EClassBucket result = buckets.get(clazz);
262
		
264
		
263
		if (result == null) {
265
		if (result == null) {
264
			result = new EClassBucket();
266
			result = new EClassBucket();
Lines 274-283 Link Here
274
	 * @param operation the operation to execute
276
	 * @param operation the operation to execute
275
	 * @return the constraints retrieved by the operation
277
	 * @return the constraints retrieved by the operation
276
	 */
278
	 */
277
	private Collection execute(AbstractGetConstraintsOperation operation) {
279
	private Collection<IModelConstraint> execute(AbstractGetConstraintsOperation operation) {
278
		for (Iterator iter = getProviders().iterator(); iter.hasNext(); ) {
280
		for (Iterator<IProviderDescriptor> iter = getProviders().iterator(); iter.hasNext(); ) {
279
			IProviderDescriptor next =
281
			IProviderDescriptor next = iter.next();
280
				(IProviderDescriptor)iter.next();
281
282
282
			if (next.provides(operation)) {
283
			if (next.provides(operation)) {
283
				try {
284
				try {
Lines 298-313 Link Here
298
	}
299
	}
299
300
300
	// implements the interface method
301
	// implements the interface method
301
	public Collection getLiveConstraints(
302
	public Collection<IModelConstraint> getLiveConstraints(
302
			Notification notification,
303
			Notification notification,
303
			Collection constraints) {
304
			Collection<IModelConstraint> constraints) {
304
		
305
		
305
		assert notification != null;
306
		assert notification != null;
306
		
307
		
307
		Collection result = constraints;
308
		Collection<IModelConstraint> result = constraints;
308
309
309
		if (result == null) {
310
		if (result == null) {
310
			result = new java.util.ArrayList();
311
			result = new java.util.ArrayList<IModelConstraint>();
311
		}
312
		}
312
313
313
		if (notification.getNotifier() instanceof EObject) {
314
		if (notification.getNotifier() instanceof EObject) {
Lines 322-328 Link Here
322
			}
323
			}
323
			
324
			
324
			EClassBucket bucket = getBucket(eObject.eClass());
325
			EClassBucket bucket = getBucket(eObject.eClass());
325
			Collection cached = bucket.getLiveConstraints(eventType, featureName);
326
			Collection<IModelConstraint> cached = bucket.getLiveConstraints(
327
				eventType, featureName);
326
			
328
			
327
			if (cached == null) {
329
			if (cached == null) {
328
				if (Trace.shouldTrace(EMFModelValidationDebugOptions.CACHE)) {
330
				if (Trace.shouldTrace(EMFModelValidationDebugOptions.CACHE)) {
Lines 354-371 Link Here
354
	}
356
	}
355
357
356
	// implements the interface method
358
	// implements the interface method
357
	public Collection getBatchConstraints(
359
	public Collection<IModelConstraint> getBatchConstraints(
358
			EObject eObject,
360
			EObject eObject,
359
			Collection constraints) {
361
			Collection<IModelConstraint> constraints) {
360
362
361
		Collection result = constraints;
363
		Collection<IModelConstraint> result = constraints;
362
364
363
		if (result == null) {
365
		if (result == null) {
364
			result = new java.util.ArrayList();
366
			result = new java.util.ArrayList<IModelConstraint>();
365
		}
367
		}
366
368
367
		EClassBucket bucket = getBucket(eObject.eClass());
369
		EClassBucket bucket = getBucket(eObject.eClass());
368
		Collection cached = bucket.getBatchConstraints();
370
		Collection<IModelConstraint> cached = bucket.getBatchConstraints();
369
		if (cached == null) {
371
		if (cached == null) {
370
			if (Trace.shouldTrace(EMFModelValidationDebugOptions.CACHE)) {
372
			if (Trace.shouldTrace(EMFModelValidationDebugOptions.CACHE)) {
371
				Trace.trace(
373
				Trace.trace(
Lines 440-448 Link Here
440
		
442
		
441
		// ask each bucket to replace the old constraint with the new, if
443
		// ask each bucket to replace the old constraint with the new, if
442
		// that constraint is in that bucket
444
		// that constraint is in that bucket
443
		for (Iterator iter = buckets.values().iterator(); iter.hasNext();) {
445
		for (EClassBucket next : buckets.values()) {
444
			EClassBucket next = (EClassBucket) iter.next();
445
			
446
			next.replace(oldConstraint, newConstraint);
446
			next.replace(oldConstraint, newConstraint);
447
		}
447
		}
448
	}
448
	}
(-)src/org/eclipse/emf/validation/internal/service/ProviderDescriptor.java (-41 / +40 lines)
Lines 34-39 Link Here
34
import org.eclipse.emf.validation.internal.util.StringMatcher;
34
import org.eclipse.emf.validation.internal.util.StringMatcher;
35
import org.eclipse.emf.validation.internal.util.Trace;
35
import org.eclipse.emf.validation.internal.util.Trace;
36
import org.eclipse.emf.validation.model.EvaluationMode;
36
import org.eclipse.emf.validation.model.EvaluationMode;
37
import org.eclipse.emf.validation.model.IModelConstraint;
37
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
38
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
38
import org.eclipse.emf.validation.service.IModelConstraintProvider;
39
import org.eclipse.emf.validation.service.IModelConstraintProvider;
39
import org.eclipse.emf.validation.service.ModelValidationService;
40
import org.eclipse.emf.validation.service.ModelValidationService;
Lines 52-65 Link Here
52
	private final IConfigurationElement myConfig;
53
	private final IConfigurationElement myConfig;
53
	private IConfigurationElement[] targets;
54
	private IConfigurationElement[] targets;
54
	private String[] nsUris;
55
	private String[] nsUris;
55
	private StringMatcher[] nsUriMatchers;
56
	private final StringMatcher[] nsUriMatchers;
56
	private IModelConstraintProvider provider = null;
57
	private IModelConstraintProvider provider = null;
57
	private final boolean shouldCacheConstraints;
58
	private final boolean shouldCacheConstraints;
58
59
59
	private final EvaluationMode mode;
60
	private final EvaluationMode<?> mode;
60
    
61
    
61
    // map of (String => Boolean) caching whether a namespace is provided
62
    // map of (String => Boolean) caching whether a namespace is provided
62
    private final Map providedNamespaces = new java.util.WeakHashMap();
63
    private final Map<String, Boolean> providedNamespaces =
64
    	new java.util.HashMap<String, Boolean>();
63
65
64
	/**
66
	/**
65
	 * The "null" provider never provides any constraints.  It is used as a
67
	 * The "null" provider never provides any constraints.  It is used as a
Lines 71-87 Link Here
71
			super();
73
			super();
72
		}
74
		}
73
		
75
		
74
		public Collection getBatchConstraints(EObject eObject, Collection constraints) {
76
		@Override
77
		public Collection<IModelConstraint> getBatchConstraints(EObject eObject,
78
			Collection<IModelConstraint> constraints) {
75
			return noOp(constraints);			
79
			return noOp(constraints);			
76
		}
80
		}
77
		
81
		
78
		public Collection getLiveConstraints(Notification notification, Collection constraints) {
82
		@Override
83
		public Collection<IModelConstraint> getLiveConstraints(Notification notification,
84
			Collection<IModelConstraint> constraints) {
79
			return noOp(constraints);
85
			return noOp(constraints);
80
		}
86
		}
81
		
87
		
82
		private Collection noOp(Collection constraints) {
88
		private Collection<IModelConstraint> noOp(Collection<IModelConstraint> constraints) {
83
			return (constraints == null)
89
			return (constraints == null)
84
				? new java.util.ArrayList()
90
				? new java.util.ArrayList<IModelConstraint>()
85
				: constraints;
91
				: constraints;
86
		}		
92
		}		
87
	}
93
	}
Lines 98-105 Link Here
98
104
99
		this.mode = getMode(config);
105
		this.mode = getMode(config);
100
106
101
		Set uriSet = new java.util.HashSet();
107
		Set<String> uriSet = new java.util.HashSet<String>();
102
		Map uriMatcherMap = new java.util.HashMap();
108
		Map<String, StringMatcher> uriMatcherMap = new java.util.HashMap<String, StringMatcher>();
103
		
109
		
104
		// backward compatibility for the namespaceUri attribute
110
		// backward compatibility for the namespaceUri attribute
105
		String uri = config.getAttribute(XmlConfig.A_NAMESPACE_URI);
111
		String uri = config.getAttribute(XmlConfig.A_NAMESPACE_URI);
Lines 118-125 Link Here
118
		}
124
		}
119
		
125
		
120
		IConfigurationElement[] pkgs = config.getChildren(XmlConfig.E_PACKAGE);
126
		IConfigurationElement[] pkgs = config.getChildren(XmlConfig.E_PACKAGE);
121
		for (int i = 0; i < pkgs.length; i++) {
127
		for (IConfigurationElement element : pkgs) {
122
			uri = pkgs[i].getAttribute(XmlConfig.A_NAMESPACE_URI);
128
			uri = element.getAttribute(XmlConfig.A_NAMESPACE_URI);
123
			if (uri != null) {
129
			if (uri != null) {
124
				uri = uri.trim();
130
				uri = uri.trim();
125
				
131
				
Lines 151-159 Link Here
151
			throw e;
157
			throw e;
152
		}
158
		}
153
		
159
		
154
		nsUris = (String[]) uriSet.toArray(new String[uriSet.size()]);
160
		nsUris = uriSet.toArray(new String[uriSet.size()]);
155
		nsUriMatchers = (StringMatcher[]) uriMatcherMap.values().toArray(
161
		nsUriMatchers = uriMatcherMap.values().toArray(new StringMatcher[uriMatcherMap.size()]);
156
			new StringMatcher[uriMatcherMap.size()]);
157
		
162
		
158
		String shouldCache = config.getAttribute(XmlConfig.A_CACHE);
163
		String shouldCache = config.getAttribute(XmlConfig.A_CACHE);
159
		shouldCacheConstraints = (shouldCache == null)
164
		shouldCacheConstraints = (shouldCache == null)
Lines 180-186 Link Here
180
	 * @return the evaluation mode, or {@link EvaluationMode#NULL} if the
185
	 * @return the evaluation mode, or {@link EvaluationMode#NULL} if the
181
	 *     provider provides constraints in mixed modes
186
	 *     provider provides constraints in mixed modes
182
	 */
187
	 */
183
	private EvaluationMode getMode() {
188
	private EvaluationMode<?> getMode() {
184
		return mode;
189
		return mode;
185
	}
190
	}
186
191
Lines 192-198 Link Here
192
	 * @return whether the provider has any chance of providing constraints
197
	 * @return whether the provider has any chance of providing constraints
193
	 *     for this context
198
	 *     for this context
194
	 */
199
	 */
195
	public boolean provides(IProviderOperation operation) {
200
	public boolean provides(
201
			IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
196
		if (operation instanceof GetLiveConstraintsOperation) {
202
		if (operation instanceof GetLiveConstraintsOperation) {
197
			return providesLiveConstraints(operation);
203
			return providesLiveConstraints(operation);
198
		} else if (operation instanceof GetBatchConstraintsOperation) {
204
		} else if (operation instanceof GetBatchConstraintsOperation) {
Lines 294-300 Link Here
294
	 *    <CODE>true</CODE>, otherwise 
300
	 *    <CODE>true</CODE>, otherwise 
295
	 */
301
	 */
296
	private boolean providesLiveConstraints(
302
	private boolean providesLiveConstraints(
297
			IProviderOperation operation) {
303
			IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
298
		
304
		
299
		Trace.entering(
305
		Trace.entering(
300
				EMFModelValidationDebugOptions.PROVIDERS,
306
				EMFModelValidationDebugOptions.PROVIDERS,
Lines 315-323 Link Here
315
			} else {
321
			} else {
316
				EObject eObject = op.getEObject();
322
				EObject eObject = op.getEObject();
317
	
323
	
318
				for (int i = 0; i < targets.length; i++) {
324
				for (IConfigurationElement next : targets) {
319
					IConfigurationElement next = targets[i];
320
	
321
					if (isLive()
325
					if (isLive()
322
							&& providerHandlesEObject(eObject, next)
326
							&& providerHandlesEObject(eObject, next)
323
							&& providerHandlesEvent(op.getEventType(), next)) {
327
							&& providerHandlesEvent(op.getEventType(), next)) {
Lines 344-350 Link Here
344
	 *    <CODE>true</CODE>, otherwise 
348
	 *    <CODE>true</CODE>, otherwise 
345
	 */
349
	 */
346
	private boolean providesBatchConstraints(
350
	private boolean providesBatchConstraints(
347
			IProviderOperation operation) {
351
			IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
348
		
352
		
349
		Trace.entering(
353
		Trace.entering(
350
				EMFModelValidationDebugOptions.PROVIDERS,
354
				EMFModelValidationDebugOptions.PROVIDERS,
Lines 365-373 Link Here
365
			} else {
369
			} else {
366
				EObject eObject = op.getEObject();
370
				EObject eObject = op.getEObject();
367
	
371
	
368
				for (int i = 0; i < targets.length; i++) {
372
				for (IConfigurationElement next : targets) {
369
					IConfigurationElement next = targets[i];
370
	
371
					if (providerHandlesEObject(eObject, next)) {
373
					if (providerHandlesEObject(eObject, next)) {
372
						result = true;
374
						result = true;
373
						break;
375
						break;
Lines 443-461 Link Here
443
		EPackage epkg = eObject.eClass().getEPackage();
445
		EPackage epkg = eObject.eClass().getEPackage();
444
		String targetNsUri = epkg.getNsURI();
446
		String targetNsUri = epkg.getNsURI();
445
		
447
		
446
        Boolean result = (Boolean) providedNamespaces.get(targetNsUri);
448
        Boolean result = providedNamespaces.get(targetNsUri);
447
        if (result == null) {
449
        if (result == null) {
448
            result = providerHandlesNamespace(targetNsUri, targetNsUri);
450
            result = providerHandlesNamespace(targetNsUri, targetNsUri);
449
451
450
            if (result == null) {
452
            if (result == null) {
451
                // look for EPackages that this package extends
453
                // look for EPackages that this package extends
452
                Set extended = getExtendedEPackages(epkg);
454
                Set<EPackage> extended = getExtendedEPackages(epkg);
453
455
454
                if (!extended.isEmpty()) {
456
                if (!extended.isEmpty()) {
455
                    for (Iterator iter = extended.iterator(); iter.hasNext()
457
                    for (Iterator<EPackage> iter = extended.iterator(); iter.hasNext()
456
                        && (result == null);) {
458
                        && (result == null);) {
457
                        
459
                        
458
                        EPackage next = (EPackage) iter.next();
460
                        EPackage next = iter.next();
459
                        result = providerHandlesNamespace(targetNsUri, next
461
                        result = providerHandlesNamespace(targetNsUri, next
460
                            .getNsURI());
462
                            .getNsURI());
461
                    }
463
                    }
Lines 540-547 Link Here
540
     * @return all of the packages containing classifiers extended by this
542
     * @return all of the packages containing classifiers extended by this
541
     *         package's classifiers, not including the original package
543
     *         package's classifiers, not including the original package
542
     */
544
     */
543
    private Set getExtendedEPackages(EPackage epackage) {
545
    private Set<EPackage> getExtendedEPackages(EPackage epackage) {
544
        Set result = new java.util.HashSet();
546
        Set<EPackage> result = new java.util.HashSet<EPackage>();
545
547
546
        getExtendedEPackages(epackage, result);
548
        getExtendedEPackages(epackage, result);
547
        result.remove(epackage);
549
        result.remove(epackage);
Lines 553-567 Link Here
553
     * Recursive helper implementation of
555
     * Recursive helper implementation of
554
     * {@link #getExtendedEPackages(EPackage)}.
556
     * {@link #getExtendedEPackages(EPackage)}.
555
     */
557
     */
556
    private void getExtendedEPackages(EPackage epackage, Set result) {
558
    private void getExtendedEPackages(EPackage epackage, Set<EPackage> result) {
557
        for (Iterator iter = epackage.getEClassifiers().iterator(); iter
559
        for (Object next : epackage.getEClassifiers()) {
558
            .hasNext();) {
559
            Object next = iter.next();
560
561
            if (next instanceof EClass) {
560
            if (next instanceof EClass) {
562
                for (Iterator jter = ((EClass) next).getESuperTypes()
561
                for (EClass zuper : ((EClass) next).getESuperTypes()) {
563
                    .iterator(); jter.hasNext();) {
562
                    EPackage nextPackage = zuper.getEPackage();
564
                    EPackage nextPackage = ((EClass) jter.next()).getEPackage();
565
563
566
                    if ((nextPackage != epackage)
564
                    if ((nextPackage != epackage)
567
                        && !result.contains(nextPackage)) {
565
                        && !result.contains(nextPackage)) {
Lines 601-608 Link Here
601
			// it is implied that all events are supported
599
			// it is implied that all events are supported
602
			result = true;
600
			result = true;
603
		} else {
601
		} else {
604
			for (int i = 0; i < events.length; i++) {
602
			for (IConfigurationElement element : events) {
605
				final String eventName = events[i].getAttribute(
603
				final String eventName = element.getAttribute(
606
						XmlConfig.A_NAME);
604
						XmlConfig.A_NAME);
607
				
605
				
608
				if (eventType.getName().equalsIgnoreCase(eventName)) {
606
				if (eventType.getName().equalsIgnoreCase(eventName)) {
Lines 646-652 Link Here
646
	 * @return the evaluation mode of the constraint provider, or
644
	 * @return the evaluation mode of the constraint provider, or
647
	 *    {@link EvaluationMode#NULL} if it has none
645
	 *    {@link EvaluationMode#NULL} if it has none
648
	 */
646
	 */
649
	private EvaluationMode getMode(IConfigurationElement config) {
647
	private EvaluationMode<?> getMode(IConfigurationElement config) {
650
		String result = config.getAttribute(XmlConfig.A_MODE);
648
		String result = config.getAttribute(XmlConfig.A_MODE);
651
649
652
		if (result == null) {
650
		if (result == null) {
Lines 657-662 Link Here
657
	}
655
	}
658
	
656
	
659
	// redefines the inherited method
657
	// redefines the inherited method
658
	@Override
660
	public String toString() {
659
	public String toString() {
661
		StringBuffer result = new StringBuffer(64);
660
		StringBuffer result = new StringBuffer(64);
662
		
661
		
(-)src/org/eclipse/emf/validation/internal/service/GetLiveConstraintsOperation.java (-5 / +13 lines)
Lines 20-25 Link Here
20
import org.eclipse.emf.ecore.EObject;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.EStructuralFeature;
21
import org.eclipse.emf.ecore.EStructuralFeature;
22
import org.eclipse.emf.validation.EMFEventType;
22
import org.eclipse.emf.validation.EMFEventType;
23
import org.eclipse.emf.validation.model.IModelConstraint;
23
import org.eclipse.emf.validation.service.IModelConstraintProvider;
24
import org.eclipse.emf.validation.service.IModelConstraintProvider;
24
25
25
/**
26
/**
Lines 39-45 Link Here
39
	
40
	
40
	private EMFEventType eventType;
41
	private EMFEventType eventType;
41
	private Notification notification;
42
	private Notification notification;
42
	private List allEvents;
43
	private List<Notification> allEvents;
43
	
44
	
44
	/**
45
	/**
45
	 * Initializes me.
46
	 * Initializes me.
Lines 72-78 Link Here
72
	 * 
73
	 * 
73
	 * @param events the {@link Notification}s
74
	 * @param events the {@link Notification}s
74
	 */
75
	 */
75
	protected void setAllEvents(List events) {
76
	protected void setAllEvents(List<? extends Notification> events) {
76
		this.allEvents = Collections.unmodifiableList(events);
77
		this.allEvents = Collections.unmodifiableList(events);
77
	}
78
	}
78
79
Lines 90-96 Link Here
90
	 * 
91
	 * 
91
	 * @return the events
92
	 * @return the events
92
	 */
93
	 */
93
	public final List getAllEvents() {
94
	public final List<Notification> getAllEvents() {
94
		return allEvents;
95
		return allEvents;
95
	}
96
	}
96
	
97
	
Lines 104-121 Link Here
104
	}
105
	}
105
106
106
	// implements the inherited method
107
	// implements the inherited method
108
	@Override
107
	protected void executeImpl(
109
	protected void executeImpl(
108
			IModelConstraintProvider provider,
110
			IModelConstraintProvider provider,
109
			Collection constraints) {
111
			Collection<IModelConstraint> constraints) {
110
		assert provider != null;
112
		assert provider != null;
111
113
112
		provider.getLiveConstraints(getNotification(), constraints);
114
		provider.getLiveConstraints(getNotification(), constraints);
113
	}
115
	}
114
	
116
	
115
	// implements the inherited method
117
	// implements the inherited method
118
	@Override
116
	protected AbstractValidationContext createContext() {
119
	protected AbstractValidationContext createContext() {
117
		return new AbstractValidationContext(this) {
120
		return new AbstractValidationContext(this) {
118
			// re-implements the inherited method
121
			// re-implements the inherited method
122
			@Override
119
			public EStructuralFeature getFeature() {
123
			public EStructuralFeature getFeature() {
120
				EStructuralFeature result = null;
124
				EStructuralFeature result = null;
121
				
125
				
Lines 129-134 Link Here
129
			/*
133
			/*
130
			 * Redefines the inherited method.
134
			 * Redefines the inherited method.
131
			 */
135
			 */
136
			@Override
132
			public Object getFeatureNewValue() {
137
			public Object getFeatureNewValue() {
133
				Object result = null;
138
				Object result = null;
134
				
139
				
Lines 153-167 Link Here
153
			}
158
			}
154
			
159
			
155
			// re-implements the inherited method
160
			// re-implements the inherited method
161
			@Override
156
			public EMFEventType getEventType() {
162
			public EMFEventType getEventType() {
157
				return GetLiveConstraintsOperation.this.getEventType();
163
				return GetLiveConstraintsOperation.this.getEventType();
158
			}
164
			}
159
			
165
			
160
			// re-implements the inherited method
166
			// re-implements the inherited method
161
			public List getAllEvents() {
167
			@Override
168
			public List<Notification> getAllEvents() {
162
				return GetLiveConstraintsOperation.this.getAllEvents();
169
				return GetLiveConstraintsOperation.this.getAllEvents();
163
			}
170
			}
164
171
172
			@Override
165
			public Notification getNotification() {
173
			public Notification getNotification() {
166
				return GetLiveConstraintsOperation.this.getNotification();
174
				return GetLiveConstraintsOperation.this.getNotification();
167
			}};
175
			}};
(-)src/org/eclipse/emf/validation/internal/service/TraversalStrategyManager.java (-29 / +34 lines)
Lines 52-58 Link Here
52
	private static final TraversalStrategyManager INSTANCE =
52
	private static final TraversalStrategyManager INSTANCE =
53
		new TraversalStrategyManager();
53
		new TraversalStrategyManager();
54
	
54
	
55
	private final Map packageDescriptors = new java.util.HashMap();
55
	private final Map<String, Descriptor> packageDescriptors =
56
	    new java.util.HashMap<String, Descriptor>();
56
	
57
	
57
	/**
58
	/**
58
	 * Not instantiated by clients.
59
	 * Not instantiated by clients.
Lines 144-150 Link Here
144
	 * @return the corresponding descriptor
145
	 * @return the corresponding descriptor
145
	 */
146
	 */
146
	private Descriptor getDescriptor(String nsUri) {
147
	private Descriptor getDescriptor(String nsUri) {
147
		Descriptor result = (Descriptor)packageDescriptors.get(nsUri);
148
		Descriptor result = packageDescriptors.get(nsUri);
148
		
149
		
149
		if (result == null) {
150
		if (result == null) {
150
			result = new Descriptor(nsUri);
151
			result = new Descriptor(nsUri);
Lines 162-169 Link Here
162
	 */
163
	 */
163
	private static class Descriptor {
164
	private static class Descriptor {
164
		private final String nsUri;
165
		private final String nsUri;
165
		private Map eclassMap = new java.util.HashMap();
166
		private Map<Object, ThreadLocal<ITraversalStrategy>> eclassMap =
166
		private ThreadLocalLazyStrategy packageDefaultStrategy;
167
		    new java.util.HashMap<Object, ThreadLocal<ITraversalStrategy>>();
168
		private ThreadLocal<ITraversalStrategy> packageDefaultStrategy;
167
		private boolean isResolved;
169
		private boolean isResolved;
168
		
170
		
169
		/**
171
		/**
Lines 188-201 Link Here
188
		 * Determines whether <code>other</code> is a descriptor for the
190
		 * Determines whether <code>other</code> is a descriptor for the
189
		 * same EPackage as me. 
191
		 * same EPackage as me. 
190
		 */
192
		 */
191
		public boolean equals(Object other) {
193
		@Override
194
        public boolean equals(Object other) {
192
			return (other instanceof Descriptor) && 
195
			return (other instanceof Descriptor) && 
193
				getNamespaceUri().equals(
196
				getNamespaceUri().equals(
194
					((Descriptor)other).getNamespaceUri());
197
					((Descriptor)other).getNamespaceUri());
195
		}
198
		}
196
		
199
		
197
		// overrides the inherited implementation
200
		// overrides the inherited implementation
198
		public int hashCode() {
201
		@Override
202
        public int hashCode() {
199
			return getNamespaceUri().hashCode();
203
			return getNamespaceUri().hashCode();
200
		}
204
		}
201
		
205
		
Lines 208-217 Link Here
208
		 */
212
		 */
209
		void addTraversalStrategy(IConfigurationElement config) {
213
		void addTraversalStrategy(IConfigurationElement config) {
210
			IConfigurationElement[] eclasses = config.getChildren(E_ECLASS);
214
			IConfigurationElement[] eclasses = config.getChildren(E_ECLASS);
215
216
            ThreadLocal<ITraversalStrategy> strategy =
217
                new ThreadLocalLazyStrategy(config);
211
			
218
			
212
			if ((eclasses.length == 0) && (packageDefaultStrategy == null)) {
219
			if ((eclasses.length == 0) && (packageDefaultStrategy == null)) {
213
				// can only have one wildcard strategy
220
				// can only have one wildcard strategy
214
				packageDefaultStrategy = new ThreadLocalLazyStrategy(config);
221
				packageDefaultStrategy = strategy;
215
			} else {
222
			} else {
216
				for (int i = 0; i < eclasses.length; i++) {
223
				for (int i = 0; i < eclasses.length; i++) {
217
					IConfigurationElement next = eclasses[i];
224
					IConfigurationElement next = eclasses[i];
Lines 219-225 Link Here
219
					
226
					
220
					if (!eclassMap.containsKey(eclassName)) {
227
					if (!eclassMap.containsKey(eclassName)) {
221
						// take the first one registered against a name
228
						// take the first one registered against a name
222
						eclassMap.put(eclassName, config);
229
						eclassMap.put(eclassName, strategy);
223
					}
230
					}
224
				}
231
				}
225
			}
232
			}
Lines 234-249 Link Here
234
		private void resolve(EPackage ePackage) {
241
		private void resolve(EPackage ePackage) {
235
			isResolved = true;
242
			isResolved = true;
236
			
243
			
237
			Map newMap = new java.util.HashMap();
244
			Map<Object, ThreadLocal<ITraversalStrategy>> newMap =
245
			    new java.util.HashMap<Object, ThreadLocal<ITraversalStrategy>>();
238
			
246
			
239
			for (Iterator iter = eclassMap.entrySet().iterator(); iter.hasNext();) {
247
			for (Map.Entry<Object, ThreadLocal<ITraversalStrategy>> next : eclassMap.entrySet()) {
240
				Map.Entry next = (Map.Entry)iter.next();
241
				String eclassName = (String)next.getKey();
248
				String eclassName = (String)next.getKey();
242
				
249
				
243
				EClassifier eclass = ePackage.getEClassifier(eclassName);
250
				EClassifier eclass = ePackage.getEClassifier(eclassName);
244
				if (eclass instanceof EClass) {
251
				if (eclass instanceof EClass) {
245
					newMap.put(eclass, new ThreadLocalLazyStrategy(
252
					newMap.put(eclass, next.getValue());
246
					    (IConfigurationElement) next.getValue()));
247
				} else {
253
				} else {
248
					// not a valid eclass
254
					// not a valid eclass
249
					Log.warningMessage(
255
					Log.warningMessage(
Lines 274-287 Link Here
274
    				resolve(eclass.getEPackage());
280
    				resolve(eclass.getEPackage());
275
    			}
281
    			}
276
    			
282
    			
277
				ThreadLocal strategy = (ThreadLocal) eclassMap.get(eclass);
283
    			ThreadLocal<ITraversalStrategy> strategy = eclassMap.get(eclass);
278
				
284
				
279
    			if (strategy == null) {
285
    			if (strategy == null) {
280
    				strategy = inheritStrategy(eclass);
286
    				strategy = inheritStrategy(eclass);
281
    				eclassMap.put(eclass, strategy);
287
    				eclassMap.put(eclass, strategy);
282
    			}
288
    			}
283
                
289
                
284
                return (ITraversalStrategy) strategy.get();
290
                return strategy.get();
285
			}
291
			}
286
		}
292
		}
287
		
293
		
Lines 295-302 Link Here
295
		 * @return the inherited strategy, or the package's default, if none
301
		 * @return the inherited strategy, or the package's default, if none
296
		 *     better is found
302
		 *     better is found
297
		 */
303
		 */
298
		private ThreadLocal inheritStrategy(EClass eclass) {
304
		private ThreadLocal<ITraversalStrategy> inheritStrategy(EClass eclass) {
299
			ThreadLocal result = getInheritedStrategy(eclass);
305
		    ThreadLocal<ITraversalStrategy> result = getInheritedStrategy(eclass);
300
			
306
			
301
			if (result == null) {
307
			if (result == null) {
302
				// use the wildcard strategy
308
				// use the wildcard strategy
Lines 320-335 Link Here
320
		 * @return the inherited strategy, or <code>null</code> if none was
326
		 * @return the inherited strategy, or <code>null</code> if none was
321
		 *     provided by any extension point
327
		 *     provided by any extension point
322
		 */
328
		 */
323
		private ThreadLocal getInheritedStrategy(EClass eclass) {
329
		private ThreadLocal<ITraversalStrategy> getInheritedStrategy(EClass eclass) {
324
			ThreadLocal result = null;
330
		    ThreadLocal<ITraversalStrategy> result = null;
325
			
331
			
326
			for (Iterator iter = eclass.getESuperTypes().iterator();
332
			for (Iterator<EClass> iter = eclass.getESuperTypes().iterator();
327
					(result == null) && iter.hasNext();) {
333
					(result == null) && iter.hasNext();) {
328
				
334
				
329
				EClass next = (EClass)iter.next();
335
				EClass next = iter.next();
330
				
336
				
331
				if (eclassMap.containsKey(next)) {
337
				if (eclassMap.containsKey(next)) {
332
					result = (ThreadLocal) eclassMap.get(next);
338
					result = eclassMap.get(next);
333
				} else {
339
				} else {
334
					result = getInheritedStrategy(next);
340
					result = getInheritedStrategy(next);
335
				}
341
				}
Lines 367-385 Link Here
367
			// replace all ocurrences of the configuration element with the
373
			// replace all ocurrences of the configuration element with the
368
			//   newly instantiated traversal strategy for future look-ups
374
			//   newly instantiated traversal strategy for future look-ups
369
			if (packageDefaultStrategy != null) {
375
			if (packageDefaultStrategy != null) {
370
			    packageDefaultStrategy.preinitialize(result, config);
376
			    ((ThreadLocalLazyStrategy) packageDefaultStrategy).preinitialize(result, config);
371
			}
377
			}
372
			
378
			
373
			for (Iterator iter = eclassMap.values().iterator(); iter.hasNext();) {
379
			for (Object next : eclassMap.values()) {
374
				ThreadLocalLazyStrategy next = (ThreadLocalLazyStrategy) iter.next();
380
				((ThreadLocalLazyStrategy) next).preinitialize(result, config);
375
				
376
				next.preinitialize(result, config);
377
			}
381
			}
378
			
382
			
379
			return result;
383
			return result;
380
		}
384
		}
381
		
385
		
382
		private class ThreadLocalLazyStrategy extends ThreadLocal {
386
		private class ThreadLocalLazyStrategy extends ThreadLocal<ITraversalStrategy> {
383
		    private final IConfigurationElement config;
387
		    private final IConfigurationElement config;
384
            
388
            
385
            ThreadLocalLazyStrategy() {
389
            ThreadLocalLazyStrategy() {
Lines 390-396 Link Here
390
		        this.config = config;
394
		        this.config = config;
391
		    }
395
		    }
392
		    
396
		    
393
		    protected Object initialValue() {
397
		    @Override
398
            protected ITraversalStrategy initialValue() {
394
		        return (config == null)? new ITraversalStrategy.Recursive() :
399
		        return (config == null)? new ITraversalStrategy.Recursive() :
395
		            initializeStrategy(config);
400
		            initializeStrategy(config);
396
		    }
401
		    }
(-)src/org/eclipse/emf/validation/internal/service/ClientContextManager.java (-44 / +45 lines)
Lines 51-60 Link Here
51
	
51
	
52
	private static final ClientContextManager INSTANCE = new ClientContextManager();
52
	private static final ClientContextManager INSTANCE = new ClientContextManager();
53
	
53
	
54
	private final Set clientContexts = new java.util.HashSet();
54
	private final Set<IClientContext> clientContexts = new java.util.HashSet<IClientContext>();
55
	private final Map clientContextMap = new java.util.HashMap();
55
	private final Map<String, IClientContext> clientContextMap = new java.util.HashMap<String, IClientContext>();
56
	
56
	
57
	private final Set defaultContexts = new java.util.HashSet();
57
	private final Set<IClientContext> defaultContexts = new java.util.HashSet<IClientContext>();
58
	
58
	
59
	/**
59
	/**
60
	 * Not instantiable by clients.
60
	 * Not instantiable by clients.
Lines 80-86 Link Here
80
	 *     under this ID
80
	 *     under this ID
81
	 */
81
	 */
82
	public IClientContext getClientContext(String contextId) {
82
	public IClientContext getClientContext(String contextId) {
83
		return (IClientContext) clientContextMap.get(contextId);
83
		return clientContextMap.get(contextId);
84
	}
84
	}
85
	
85
	
86
	/**
86
	/**
Lines 88-94 Link Here
88
	 * 
88
	 * 
89
	 * @return the available {@link IClientContext}s
89
	 * @return the available {@link IClientContext}s
90
	 */
90
	 */
91
	public Set getClientContexts() {
91
	public Set<IClientContext> getClientContexts() {
92
		return clientContexts;
92
		return clientContexts;
93
	}
93
	}
94
94
Lines 100-112 Link Here
100
	 *    <code>eObject</code> belongs.  This may be empty if no context
100
	 *    <code>eObject</code> belongs.  This may be empty if no context
101
	 *    selector matches this element
101
	 *    selector matches this element
102
	 */
102
	 */
103
	public Collection getClientContextsFor(EObject eObject) {
103
	public Collection<IClientContext> getClientContextsFor(EObject eObject) {
104
		Collection result = new java.util.ArrayList();
104
		Collection<IClientContext> result = new java.util.ArrayList<IClientContext>();
105
		
105
		
106
		EvaluationContext ctx = new EvaluationContext(null, eObject);
106
		EvaluationContext ctx = new EvaluationContext(null, eObject);
107
		
107
		
108
		for (Iterator iter = getClientContexts().iterator(); iter.hasNext();) {
108
		for (Iterator<IClientContext> iter = getClientContexts().iterator(); iter.hasNext();) {
109
			IClientContext next = (IClientContext) iter.next();
109
			IClientContext next = iter.next();
110
			IClientSelector selector = next.getSelector();
110
			IClientSelector selector = next.getSelector();
111
			
111
			
112
			final Object toTest = (selector instanceof XmlExpressionSelector)
112
			final Object toTest = (selector instanceof XmlExpressionSelector)
Lines 149-168 Link Here
149
	 * @return the {@link IModelConstraint}s from amongst the specified
149
	 * @return the {@link IModelConstraint}s from amongst the specified
150
	 *     <code>constraints</code> that are bound to the <code>context</code>
150
	 *     <code>constraints</code> that are bound to the <code>context</code>
151
	 */
151
	 */
152
	public Collection getBindings(EObject eObject, Collection constraints) {
152
	public Collection<IModelConstraint> getBindings(EObject eObject,
153
		Collection result;
153
			Collection<? extends IModelConstraint> constraints) {
154
		
154
		
155
		Collection contexts = getClientContextsFor(eObject);
155
		Collection<IModelConstraint> result;
156
		
157
		Collection<IClientContext> contexts = getClientContextsFor(eObject);
156
		
158
		
157
		if (contexts.isEmpty()) {
159
		if (contexts.isEmpty()) {
158
			// no context recognizes this object?  Oh, well, then there are
160
			// no context recognizes this object?  Oh, well, then there are
159
			//   no constraints
161
			//   no constraints
160
			result = Collections.EMPTY_LIST;
162
			result = Collections.emptyList();
161
		} else if (contexts.size() == 1) {
163
		} else if (contexts.size() == 1) {
162
			// easy when there's just one context
164
			// easy when there's just one context
163
			result = getBindings(
165
			result = getBindings(contexts.iterator().next(), constraints); 
164
				(IClientContext) contexts.iterator().next(),
165
				constraints); 
166
		} else {
166
		} else {
167
			// multiple contexts require more looping
167
			// multiple contexts require more looping
168
			result = getBindings(contexts, constraints);
168
			result = getBindings(contexts, constraints);
Lines 180-191 Link Here
180
	 * @return the {@link IModelConstraint}s from amongst the specified
180
	 * @return the {@link IModelConstraint}s from amongst the specified
181
	 *     <code>constraints</code> that are bound to the <code>context</code>
181
	 *     <code>constraints</code> that are bound to the <code>context</code>
182
	 */
182
	 */
183
	public Collection getBindings(IClientContext context, Collection constraints) {
183
	public Collection<IModelConstraint> getBindings(IClientContext context,
184
		Collection result = new java.util.ArrayList(constraints.size());
184
			Collection<? extends IModelConstraint> constraints) {
185
		
185
		
186
		for (Iterator iter = constraints.iterator(); iter.hasNext();) {
186
		Collection<IModelConstraint> result = new java.util.ArrayList<IModelConstraint>(
187
			IModelConstraint constraint = (IModelConstraint) iter.next();
187
				constraints.size());
188
			
188
		
189
		for (IModelConstraint constraint : constraints) {
189
			if (context.includes(constraint)) {
190
			if (context.includes(constraint)) {
190
				result.add(constraint);
191
				result.add(constraint);
191
			} else if (context.isDefault()) {
192
			} else if (context.isDefault()) {
Lines 209-237 Link Here
209
	 * @return the {@link IModelConstraint}s from amongst the specified
210
	 * @return the {@link IModelConstraint}s from amongst the specified
210
	 *     <code>constraints</code> that are bound to the <code>context</code>
211
	 *     <code>constraints</code> that are bound to the <code>context</code>
211
	 */
212
	 */
212
	public Collection getBindings(Collection contexts, Collection constraints) {
213
	public Collection<IModelConstraint> getBindings(
213
		Collection result = new java.util.ArrayList(constraints.size());
214
			Collection<? extends IClientContext> contexts,
215
			Collection<? extends IModelConstraint> constraints) {
216
		
217
		Collection<IModelConstraint> result = new java.util.ArrayList<IModelConstraint>(
218
				constraints.size());
214
		
219
		
215
		// use an array for performance (to avoid creating so many iterators)
220
		// use an array for performance (to avoid creating so many iterators)
216
		IClientContext[] ctxArray = (IClientContext[]) contexts.toArray(
221
		IClientContext[] ctxArray = contexts.toArray(new IClientContext[contexts.size()]);
217
			new IClientContext[contexts.size()]);
218
		
222
		
219
		// in case we don't find an explicit binding, we need to know whether
223
		// in case we don't find an explicit binding, we need to know whether
220
		//   we need to look for default bindings.  This will only be the case
224
		//   we need to look for default bindings.  This will only be the case
221
		//   if any of the current contexts is default
225
		//   if any of the current contexts is default
222
		boolean anyContextIsDefault = false;
226
		boolean anyContextIsDefault = false;
223
		
227
		
224
		for (Iterator iter = constraints.iterator(); iter.hasNext();) {
228
		for (IModelConstraint constraint : constraints) {
225
			IModelConstraint constraint = (IModelConstraint) iter.next();
226
			boolean bound = false;
229
			boolean bound = false;
227
			
230
			
228
			for (int i = 0; i < ctxArray.length; i++) {
231
			for (IClientContext element : ctxArray) {
229
				bound = ctxArray[i].includes(constraint);
232
				bound = element.includes(constraint);
230
				
233
				
231
				if (bound) {
234
				if (bound) {
232
					result.add(constraint);
235
					result.add(constraint);
233
					break;  // needn't look at any more contexts
236
					break;  // needn't look at any more contexts
234
				} else if (ctxArray[i].isDefault()) {
237
				} else if (element.isDefault()) {
235
					// no need to check for default contexts as long as we
238
					// no need to check for default contexts as long as we
236
					//   find explicit bindings
239
					//   find explicit bindings
237
					anyContextIsDefault = true;
240
					anyContextIsDefault = true;
Lines 270-284 Link Here
270
		boolean result = true;
273
		boolean result = true;
271
		String id = constraint.getDescriptor().getId();
274
		String id = constraint.getDescriptor().getId();
272
		
275
		
273
		for (Iterator iter = clientContexts.iterator(); result && iter.hasNext();) {
276
		for (Iterator<IClientContext> iter = clientContexts.iterator();
274
			result = !((IClientContext) iter.next()).includes(constraint);
277
				result && iter.hasNext();) {
278
			
279
			result = !iter.next().includes(constraint);
275
		}
280
		}
276
		
281
		
277
		if (result) {
282
		if (result) {
278
			// add the constraint to all default contexts so that we don't do
283
			// add the constraint to all default contexts so that we don't do
279
			//   this computation again
284
			//   this computation again
280
			for (Iterator iter = defaultContexts.iterator(); iter.hasNext();) {
285
			for (IClientContext next : defaultContexts) {
281
				((ClientContext) iter.next()).bindConstraint(id);
286
				((ClientContext) next).bindConstraint(id);
282
			}
287
			}
283
		}
288
		}
284
		
289
		
Lines 313-321 Link Here
313
	 *     <code>constraintBindings</code> extension point
318
	 *     <code>constraintBindings</code> extension point
314
	 */
319
	 */
315
	private void configureClientContexts(IConfigurationElement[] elements) {
320
	private void configureClientContexts(IConfigurationElement[] elements) {
316
		for (int i = 0; i < elements.length; i++) {
321
		for (IConfigurationElement config : elements) {
317
			IConfigurationElement config = elements[i];
318
			
319
			if (E_CLIENT_CONTEXT.equals(config.getName())) {
322
			if (E_CLIENT_CONTEXT.equals(config.getName())) {
320
				try {
323
				try {
321
					ClientContext context = new ClientContext(config);
324
					ClientContext context = new ClientContext(config);
Lines 345-353 Link Here
345
	 *     <code>constraintBindings</code> extension point
348
	 *     <code>constraintBindings</code> extension point
346
	 */
349
	 */
347
	private void configureBindings(IConfigurationElement[] elements) {
350
	private void configureBindings(IConfigurationElement[] elements) {
348
		for (int i = 0; i < elements.length; i++) {
351
		for (IConfigurationElement config : elements) {
349
			IConfigurationElement config = elements[i];
350
			
351
			if (E_BINDING.equals(config.getName())) {
352
			if (E_BINDING.equals(config.getName())) {
352
				String contextId = config.getAttribute(A_CONTEXT);
353
				String contextId = config.getAttribute(A_CONTEXT);
353
				
354
				
Lines 396-403 Link Here
396
		}
397
		}
397
		
398
		
398
		IConfigurationElement[] children = config.getChildren(A_CONSTRAINT);
399
		IConfigurationElement[] children = config.getChildren(A_CONSTRAINT);
399
		for (int i = 0; i < children.length; i++) {
400
		for (IConfigurationElement element : children) {
400
			final String ref = children[i].getAttribute(A_REF);
401
			final String ref = element.getAttribute(A_REF);
401
			
402
			
402
			if (ref == null) {
403
			if (ref == null) {
403
				Log.warningMessage(
404
				Log.warningMessage(
Lines 412-419 Link Here
412
		}
413
		}
413
		
414
		
414
		children = config.getChildren(A_CATEGORY);
415
		children = config.getChildren(A_CATEGORY);
415
		for (int i = 0; i < children.length; i++) {
416
		for (IConfigurationElement element : children) {
416
			final String ref = children[i].getAttribute(A_REF);
417
			final String ref = element.getAttribute(A_REF);
417
			
418
			
418
			if (ref == null) {
419
			if (ref == null) {
419
				Log.errorMessage(
420
				Log.errorMessage(
(-)src/org/eclipse/emf/validation/internal/service/IProviderDescriptor.java (-1 / +5 lines)
Lines 12-17 Link Here
12
12
13
package org.eclipse.emf.validation.internal.service;
13
package org.eclipse.emf.validation.internal.service;
14
14
15
import java.util.Collection;
16
17
import org.eclipse.emf.validation.model.IModelConstraint;
15
import org.eclipse.emf.validation.service.IModelConstraintProvider;
18
import org.eclipse.emf.validation.service.IModelConstraintProvider;
16
19
17
/**
20
/**
Lines 33-39 Link Here
33
	 * @return whether the provider has any chance of providing constraints
36
	 * @return whether the provider has any chance of providing constraints
34
	 *     for this context
37
	 *     for this context
35
	 */
38
	 */
36
	boolean provides(IProviderOperation operation);
39
	boolean provides(
40
			IProviderOperation<? extends Collection<? extends IModelConstraint>> operation);
37
	
41
	
38
	/**
42
	/**
39
	 * Queries whether the system should cache constraints retrieved from
43
	 * Queries whether the system should cache constraints retrieved from
(-)src/org/eclipse/emf/validation/internal/service/AbstractValidator.java (-34 / +36 lines)
Lines 46-59 Link Here
46
 *
46
 *
47
 * @author Christian W. Damus (cdamus)
47
 * @author Christian W. Damus (cdamus)
48
 */
48
 */
49
abstract class AbstractValidator implements IValidator {
49
abstract class AbstractValidator<T> implements IValidator<T> {
50
	private final EvaluationMode mode;
50
	private final EvaluationMode<T> mode;
51
	private final Map clientData = new java.util.HashMap();
51
	private final Map<String, Object> clientData = new java.util.HashMap<String, Object>();
52
	private final IProviderOperationExecutor executor;
52
	private final IProviderOperationExecutor<Collection<IModelConstraint>> executor;
53
	
53
	
54
	private boolean reportSuccesses = false;
54
	private boolean reportSuccesses = false;
55
	
55
	
56
	private Collection filters = null;
56
	private Collection<IConstraintFilter> filters = null;
57
	
57
	
58
	/**
58
	/**
59
	 * Initializes me with the evaluation <code>mode</code> that I support and
59
	 * Initializes me with the evaluation <code>mode</code> that I support and
Lines 66-73 Link Here
66
	 *      <code>null</code>)
66
	 *      <code>null</code>)
67
	 */
67
	 */
68
	protected AbstractValidator(
68
	protected AbstractValidator(
69
			EvaluationMode mode,
69
			EvaluationMode<T> mode,
70
			IProviderOperationExecutor executor) {
70
			IProviderOperationExecutor<Collection<IModelConstraint>> executor) {
71
		assert mode != null && !mode.isNull();
71
		assert mode != null && !mode.isNull();
72
		assert executor != null;
72
		assert executor != null;
73
		
73
		
Lines 78-84 Link Here
78
	/* (non-Javadoc)
78
	/* (non-Javadoc)
79
	 * Implements the inherited method.
79
	 * Implements the inherited method.
80
	 */
80
	 */
81
	public final EvaluationMode getEvaluationMode() {
81
	public final EvaluationMode<T> getEvaluationMode() {
82
		return mode;
82
		return mode;
83
	}
83
	}
84
84
Lines 116-122 Link Here
116
	 * validation API is also encouraged to delegate to this method after
116
	 * validation API is also encouraged to delegate to this method after
117
	 * first checking that arguments are of or coerced to the correct types.
117
	 * first checking that arguments are of or coerced to the correct types.
118
	 */
118
	 */
119
	public final IStatus validate(Object object) {
119
	public final IStatus validate(T object) {
120
		return validate(Collections.singleton(object));
120
		return validate(Collections.singleton(object));
121
	}
121
	}
122
122
Lines 132-141 Link Here
132
	 * returns an appropriate {@link IStatus#CANCEL} status when it catches one.
132
	 * returns an appropriate {@link IStatus#CANCEL} status when it catches one.
133
	 * </p>
133
	 * </p>
134
	 */
134
	 */
135
	public final IStatus validate(Collection objects) {
135
	public final IStatus validate(Collection<? extends T> objects) {
136
		IStatus result;
136
		IStatus result;
137
		
137
		
138
		Set encounteredClientContexts = new HashSet();
138
		Set<IClientContext> encounteredClientContexts = new HashSet<IClientContext>();
139
		
139
		
140
		try {
140
		try {
141
			result = createStatus(doValidate(objects, encounteredClientContexts));
141
			result = createStatus(doValidate(objects, encounteredClientContexts));
Lines 173-189 Link Here
173
	 * @return The client contexts ids provided to this validator by the last call
173
	 * @return The client contexts ids provided to this validator by the last call
174
	 *  to the {@link #evaluateConstraints(AbstractValidationContext, List) method.
174
	 *  to the {@link #evaluateConstraints(AbstractValidationContext, List) method.
175
	 */
175
	 */
176
	private Collection getClientContextIds(Collection clientContexts) {
176
	private Collection<String> getClientContextIds(Collection<IClientContext> clientContexts) {
177
		List contextIds = new ArrayList();
177
		List<String> contextIds = new ArrayList<String>();
178
		
178
		
179
		if (clientContexts == null) {
179
		if (clientContexts == null) {
180
			return contextIds;
180
			return contextIds;
181
		}
181
		}
182
		
182
		
183
		for (Iterator i = clientContexts.iterator(); i.hasNext();) {
183
		for (IClientContext context : clientContexts) {
184
			IClientContext context = (IClientContext)i.next();
185
			contextIds.add(context.getId());
184
			contextIds.add(context.getId());
186
		}
185
		}
186
		
187
		return contextIds;
187
		return contextIds;
188
	}
188
	}
189
189
Lines 200-206 Link Here
200
	 *     canceled (e.g., when a constraint returns
200
	 *     canceled (e.g., when a constraint returns
201
	 *     {@link IStatus#CANCEL} status)
201
	 *     {@link IStatus#CANCEL} status)
202
	 */
202
	 */
203
	protected abstract Collection doValidate(Collection objects, Set clientContexts);
203
	protected abstract Collection<IStatus> doValidate(Collection<? extends T> objects,
204
		Set<IClientContext> clientContexts);
204
	
205
	
205
	/**
206
	/**
206
	 * Helper method to evaluate a bunch of constraints.  Disabled constraints
207
	 * Helper method to evaluate a bunch of constraints.  Disabled constraints
Lines 220-230 Link Here
220
	 */
221
	 */
221
	protected IStatus evaluateConstraints(
222
	protected IStatus evaluateConstraints(
222
			AbstractValidationContext ctx,
223
			AbstractValidationContext ctx,
223
			List results) {
224
			List<IStatus> results) {
224
		IStatus resultStatus = Status.OK_STATUS;
225
		IStatus resultStatus = Status.OK_STATUS;
225
		
226
		
226
		for (Iterator iter = ctx.getConstraints().iterator(); iter.hasNext();) {
227
		for (Object element : ctx.getConstraints()) {
227
			IModelConstraint next = (IModelConstraint)iter.next();
228
			IModelConstraint next = (IModelConstraint)element;
228
229
229
			if (!acceptConstraint(next.getDescriptor(), ctx.getTarget())) {
230
			if (!acceptConstraint(next.getDescriptor(), ctx.getTarget())) {
230
				continue;
231
				continue;
Lines 282-288 Link Here
282
	 * 
283
	 * 
283
	 * @param operation the operation to execute
284
	 * @param operation the operation to execute
284
	 */
285
	 */
285
	protected final void execute(IProviderOperation operation) {
286
	protected final void execute(
287
			IProviderOperation<Collection<IModelConstraint>> operation) {
286
		getOperationExecutor().execute(operation);
288
		getOperationExecutor().execute(operation);
287
	}
289
	}
288
	
290
	
Lines 291-297 Link Here
291
	 * 
293
	 * 
292
	 * @return my operation executor
294
	 * @return my operation executor
293
	 */
295
	 */
294
	private IProviderOperationExecutor getOperationExecutor() {
296
	private IProviderOperationExecutor<Collection<IModelConstraint>> getOperationExecutor() {
295
		return executor;
297
		return executor;
296
	}
298
	}
297
	
299
	
Lines 305-311 Link Here
305
	 * @return a multi-status if more than one result; a plain {@link IStatus},
307
	 * @return a multi-status if more than one result; a plain {@link IStatus},
306
	 *     otherwise
308
	 *     otherwise
307
	 */
309
	 */
308
	private IStatus createStatus(Collection results) {	
310
	private IStatus createStatus(Collection<IStatus> results) {	
309
		if (results.isEmpty()) {
311
		if (results.isEmpty()) {
310
			return new org.eclipse.core.runtime.Status(
312
			return new org.eclipse.core.runtime.Status(
311
				IStatus.OK,
313
				IStatus.OK,
Lines 314-320 Link Here
314
				EMFModelValidationStatusCodes.NO_CONSTRAINTS_EVALUATED_MSG,
316
				EMFModelValidationStatusCodes.NO_CONSTRAINTS_EVALUATED_MSG,
315
				null);
317
				null);
316
		} else if (results.size() == 1) {
318
		} else if (results.size() == 1) {
317
			return (IStatus)results.iterator().next();
319
			return results.iterator().next();
318
		} else {
320
		} else {
319
			return new AggregateStatus(results);
321
			return new AggregateStatus(results);
320
		}
322
		}
Lines 322-329 Link Here
322
324
323
	private boolean acceptConstraint(IConstraintDescriptor constraint, EObject target) {
325
	private boolean acceptConstraint(IConstraintDescriptor constraint, EObject target) {
324
        if (filters != null) {
326
        if (filters != null) {
325
    		for (Iterator iter = filters.iterator(); iter.hasNext();) {
327
    		for (Object element : filters) {
326
    			IConstraintFilter filter = (IConstraintFilter)iter.next();
328
    			IConstraintFilter filter = (IConstraintFilter)element;
327
                
329
                
328
    			if (!filter.accept(constraint, target)) {
330
    			if (!filter.accept(constraint, target)) {
329
    				return false;
331
    				return false;
Lines 336-342 Link Here
336
338
337
	public void addConstraintFilter(IConstraintFilter filter) {
339
	public void addConstraintFilter(IConstraintFilter filter) {
338
		if (filters == null) {
340
		if (filters == null) {
339
			filters = new BasicEList(4);
341
			filters = new BasicEList<IConstraintFilter>(4);
340
		}
342
		}
341
        
343
        
342
		filters.add(filter);
344
		filters.add(filter);
Lines 348-356 Link Here
348
        }
350
        }
349
    }
351
    }
350
    
352
    
351
	public Collection getConstraintFilters() {
353
	public Collection<IConstraintFilter> getConstraintFilters() {
352
		if (filters == null) {
354
		if (filters == null) {
353
			return Collections.EMPTY_LIST;
355
			return Collections.emptyList();
354
		}
356
		}
355
        
357
        
356
		return Collections.unmodifiableCollection(filters);
358
		return Collections.unmodifiableCollection(filters);
Lines 363-369 Link Here
363
	 * @author Christian W. Damus (cdamus)
365
	 * @author Christian W. Damus (cdamus)
364
	 */
366
	 */
365
	private static class AggregateStatus implements IStatus {
367
	private static class AggregateStatus implements IStatus {
366
		private final Collection children;
368
		private final Collection<? extends IStatus> children;
367
		private final int severity;
369
		private final int severity;
368
		private final int code;
370
		private final int code;
369
		private final String message;
371
		private final String message;
Lines 375-381 Link Here
375
		 * 
377
		 * 
376
		 * @param statuses the statuses that I aggregate
378
		 * @param statuses the statuses that I aggregate
377
		 */
379
		 */
378
		AggregateStatus(Collection statuses) {
380
		AggregateStatus(Collection<? extends IStatus> statuses) {
379
			// aggregate the results into a multi-status
381
			// aggregate the results into a multi-status
380
382
381
			int maxSeverity = getMaximalSeverity(statuses);
383
			int maxSeverity = getMaximalSeverity(statuses);
Lines 413-419 Link Here
413
		
415
		
414
		// implements the interface method
416
		// implements the interface method
415
		public IStatus[] getChildren() {
417
		public IStatus[] getChildren() {
416
			return (IStatus[])children.toArray(new IStatus[children.size()]);
418
			return children.toArray(new IStatus[children.size()]);
417
		}
419
		}
418
420
419
		// implements the interface method
421
		// implements the interface method
Lines 462-474 Link Here
462
		 * @param statuses a collection of {@link IStatus} objects
464
		 * @param statuses a collection of {@link IStatus} objects
463
		 * @return the maximal severity amongst the <code>statuses</code>
465
		 * @return the maximal severity amongst the <code>statuses</code>
464
		 */
466
		 */
465
		private int getMaximalSeverity(Collection statuses) {
467
		private int getMaximalSeverity(Collection<? extends IStatus> statuses) {
466
			int result = IStatus.OK;
468
			int result = IStatus.OK;
467
		
469
		
468
			for (Iterator iter = statuses.iterator();
470
			for (Iterator<? extends IStatus> iter = statuses.iterator();
469
					(result < IStatus.ERROR) && iter.hasNext();) {
471
					(result < IStatus.ERROR) && iter.hasNext();) {
470
			
472
			
471
				IStatus next = (IStatus)iter.next();
473
				IStatus next = iter.next();
472
			
474
			
473
				if (next.getSeverity() > result) {
475
				if (next.getSeverity() > result) {
474
					result = next.getSeverity();
476
					result = next.getSeverity();
(-)src/org/eclipse/emf/validation/internal/service/IProviderOperation.java (-3 / +6 lines)
Lines 16-29 Link Here
16
16
17
import org.eclipse.emf.ecore.EObject;
17
import org.eclipse.emf.ecore.EObject;
18
18
19
import org.eclipse.emf.validation.model.IModelConstraint;
19
import org.eclipse.emf.validation.service.IModelConstraintProvider;
20
import org.eclipse.emf.validation.service.IModelConstraintProvider;
20
21
21
/**
22
/**
22
 * Interface describing an {@link IModelConstraintProvider} operation.
23
 * Interface describing an {@link IModelConstraintProvider} operation.
23
 * 
24
 * 
25
 * @param <T> the result type of the operation
26
 * 
24
 * @author Christian W. Damus (cdamus)
27
 * @author Christian W. Damus (cdamus)
25
 */
28
 */
26
public interface IProviderOperation {
29
public interface IProviderOperation<T> {
27
	/**
30
	/**
28
	 * Obtains the EMF object that is to be validated.
31
	 * Obtains the EMF object that is to be validated.
29
	 * 
32
	 * 
Lines 37-43 Link Here
37
	 * 
40
	 * 
38
	 * @return the constraints
41
	 * @return the constraints
39
	 */
42
	 */
40
	Collection getConstraints();
43
	Collection<IModelConstraint> getConstraints();
41
	
44
	
42
	/**
45
	/**
43
	 * Executes me on the specified constraint <code>provider</code>.
46
	 * Executes me on the specified constraint <code>provider</code>.
Lines 45-49 Link Here
45
	 * @param provider a constraint provider
48
	 * @param provider a constraint provider
46
	 * @return my {@link #getConstraints constraints collection}
49
	 * @return my {@link #getConstraints constraints collection}
47
	 */
50
	 */
48
	Object execute(IModelConstraintProvider provider);
51
	T execute(IModelConstraintProvider provider);
49
}
52
}
(-)src/org/eclipse/emf/validation/internal/service/ValidationCanceledException.java (+2 lines)
Lines 29-34 Link Here
29
 * @author Christian W. Damus (cdamus)
29
 * @author Christian W. Damus (cdamus)
30
 */
30
 */
31
public class ValidationCanceledException extends RuntimeException {
31
public class ValidationCanceledException extends RuntimeException {
32
    private static final long serialVersionUID = -2541909077699487325L;
33
    
32
    private final IStatus status;
34
    private final IStatus status;
33
    
35
    
34
    /**
36
    /**
(-)src/org/eclipse/emf/validation/internal/service/ClientContext.java (-5 / +8 lines)
Lines 55-64 Link Here
55
	private final boolean isDefault;
55
	private final boolean isDefault;
56
	
56
	
57
	// set of String constraint IDs that are bound to me
57
	// set of String constraint IDs that are bound to me
58
	private final Set constraintBindings = new java.util.HashSet();
58
	private final Set<String> constraintBindings = new java.util.HashSet<String>();
59
	
59
	
60
	// set of String category IDs that are bound to me
60
	// set of String category IDs that are bound to me
61
	private final Set categoryBindings = new java.util.HashSet();
61
	private final Set<String> categoryBindings = new java.util.HashSet<String>();
62
	
62
	
63
	/**
63
	/**
64
	 * Initializes me with my XML configuration.
64
	 * Initializes me with my XML configuration.
Lines 266-276 Link Here
266
	 * @return <code>true</code> if any of the <code>categories</code> is bound,
266
	 * @return <code>true</code> if any of the <code>categories</code> is bound,
267
	 *     or if any of their ancestors is bound; <code>false</code>, otherwise
267
	 *     or if any of their ancestors is bound; <code>false</code>, otherwise
268
	 */
268
	 */
269
	private boolean hasCategoryBinding(Collection categories) {
269
	private boolean hasCategoryBinding(Collection<Category> categories) {
270
		boolean result = false;
270
		boolean result = false;
271
		
271
		
272
		for (Iterator iter = categories.iterator(); !result && iter.hasNext();) {
272
		for (Iterator<Category> iter = categories.iterator(); !result && iter.hasNext();) {
273
			Category category = (Category) iter.next();
273
			Category category = iter.next();
274
			
274
			
275
			result = categoryBindings.contains(category.getPath());
275
			result = categoryBindings.contains(category.getPath());
276
			
276
			
Lines 316-321 Link Here
316
	/**
316
	/**
317
	 * The context ID fully determines equality.
317
	 * The context ID fully determines equality.
318
	 */
318
	 */
319
	@Override
319
	public boolean equals(Object obj) {
320
	public boolean equals(Object obj) {
320
		return (obj instanceof ClientContext)
321
		return (obj instanceof ClientContext)
321
			&& ((ClientContext) obj).getId().equals(getId());
322
			&& ((ClientContext) obj).getId().equals(getId());
Lines 324-333 Link Here
324
	/**
325
	/**
325
	 * The context ID fully determines equality.
326
	 * The context ID fully determines equality.
326
	 */
327
	 */
328
	@Override
327
	public int hashCode() {
329
	public int hashCode() {
328
		return getId().hashCode();
330
		return getId().hashCode();
329
	}
331
	}
330
	
332
	
333
	@Override
331
	public String toString() {
334
	public String toString() {
332
		return "ClientContext[" + getId() + ']'; //$NON-NLS-1$
335
		return "ClientContext[" + getId() + ']'; //$NON-NLS-1$
333
	}
336
	}
(-)src/org/eclipse/emf/validation/service/ConstraintChangeEventType.java (-34 / +27 lines)
Lines 16-22 Link Here
16
import java.util.Collections;
16
import java.util.Collections;
17
import java.util.List;
17
import java.util.List;
18
18
19
import org.eclipse.emf.common.util.AbstractEnumerator;
19
import org.eclipse.emf.common.util.Enumerator;
20
20
21
/**
21
/**
22
 * Enumeration for a constraint change event type.
22
 * Enumeration for a constraint change event type.
Lines 25-76 Link Here
25
 * 
25
 * 
26
 * @author David Cummings (dcummin)
26
 * @author David Cummings (dcummin)
27
 */
27
 */
28
public final class ConstraintChangeEventType
28
public enum ConstraintChangeEventType
29
	extends AbstractEnumerator {
29
	implements Enumerator {
30
31
	private static final long serialVersionUID = 1L;
32
33
	/**
34
	 * An internal unique identifier for this enumerated type.
35
	 */
36
	private static int nextOrdinal = 0;
37
30
38
	/**
31
	/**
39
	 * Registered constraint change event type
32
	 * Registered constraint change event type
40
	 */
33
	 */
41
	public static final ConstraintChangeEventType REGISTERED = new ConstraintChangeEventType(
34
	REGISTERED("Registered"), //$NON-NLS-1$
42
		"Registered"); //$NON-NLS-1$
43
35
44
	/**
36
	/**
45
	 * Unregistered constraint change event type
37
	 * Unregistered constraint change event type
46
	 */
38
	 */
47
	public static final ConstraintChangeEventType UNREGISTERED = new ConstraintChangeEventType(
39
	UNREGISTERED ("Unregistered"), //$NON-NLS-1$
48
		"Unregistered"); //$NON-NLS-1$
49
40
50
	/**
41
	/**
51
	 * Enabled constraint change event type
42
	 * Enabled constraint change event type
52
	 */
43
	 */
53
	public static final ConstraintChangeEventType ENABLED = new ConstraintChangeEventType(
44
	ENABLED("Enabled"), //$NON-NLS-1$
54
		"Enabled"); //$NON-NLS-1$
55
	
45
	
56
	/**
46
	/**
57
	 * Disabled constraint change event type
47
	 * Disabled constraint change event type
58
	 */
48
	 */
59
	public static final ConstraintChangeEventType DISABLED = new ConstraintChangeEventType(
49
	DISABLED("Disabled"), //$NON-NLS-1$
60
		"Disabled"); //$NON-NLS-1$
61
	
50
	
62
	/**
51
	/**
63
	 * Added category constraint change event type
52
	 * Added category constraint change event type
64
	 */
53
	 */
65
	public static final ConstraintChangeEventType ADDED_CATEGORY  = new ConstraintChangeEventType(
54
	ADDED_CATEGORY("Added Category"), //$NON-NLS-1$
66
		"Added Category"); //$NON-NLS-1$
67
	
55
	
68
	/**
56
	/**
69
	 * Removed category constraint change event type
57
	 * Removed category constraint change event type
70
	 */
58
	 */
71
	public static final ConstraintChangeEventType REMOVED_CATEGORY = new ConstraintChangeEventType(
59
	REMOVED_CATEGORY ("Removed Category"); //$NON-NLS-1$
72
		"Removed Category"); //$NON-NLS-1$
73
60
61
62
	private static final long serialVersionUID = 1L;
74
	
63
	
75
	private static final ConstraintChangeEventType[] VALUES = { REGISTERED,
64
	private static final ConstraintChangeEventType[] VALUES = { REGISTERED,
76
																UNREGISTERED,
65
																UNREGISTERED,
Lines 79-102 Link Here
79
																ADDED_CATEGORY,
68
																ADDED_CATEGORY,
80
																REMOVED_CATEGORY };
69
																REMOVED_CATEGORY };
81
70
71
	private final String name;
72
	
82
	/**
73
	/**
83
	 * Constructs a new constraint change event type with the specified name and
74
	 * Constructs a new constraint change event type with the specified name and
84
	 * ordinal.
75
	 * ordinal.
85
	 * 
76
	 * 
86
	 * @param name The name of the constraint change event type
77
	 * @param name The name of the constraint change event type
87
	 * @param ordinal The ordinal for the constraint change event type.
88
	 */
89
	private ConstraintChangeEventType(String name, int ordinal) {
90
		super(ordinal, name);
91
	}
92
93
	/**
94
	 * Constructs a new constraint change event type with the specified name.
95
	 * 
96
	 * @param name The name of the new constraint change event type.
97
	 */
78
	 */
98
	private ConstraintChangeEventType(String name) {
79
	private ConstraintChangeEventType(String name) {
99
		this(name, nextOrdinal++);
80
		this.name = name;
100
	}
81
	}
101
82
102
	/**
83
	/**
Lines 104-110 Link Here
104
	 * 
85
	 * 
105
	 * @return an unmodifiable collection of the event types
86
	 * @return an unmodifiable collection of the event types
106
	 */
87
	 */
107
	protected List getValues() {
88
	protected List<ConstraintChangeEventType> getValues() {
108
		return Collections.unmodifiableList(Arrays.asList(VALUES));
89
		return Collections.unmodifiableList(Arrays.asList(VALUES));
109
	}
90
	}
91
	
92
	public int getValue() {
93
		return ordinal();
94
	}
95
	
96
	public String getLiteral() {
97
		return getName();
98
	}
99
	
100
	public String getName() {
101
		return name;
102
	}
110
}
103
}
(-)src/org/eclipse/emf/validation/service/IBatchValidator.java (-7 / +5 lines)
Lines 33-39 Link Here
33
 * 
33
 * 
34
 * @author Christian W. Damus (cdamus)
34
 * @author Christian W. Damus (cdamus)
35
 */
35
 */
36
public interface IBatchValidator extends IValidator {
36
public interface IBatchValidator extends IValidator<EObject> {
37
	/**
37
	/**
38
	 * <p>
38
	 * <p>
39
	 * Queries whether I also evaluate applicable live constraints on each
39
	 * Queries whether I also evaluate applicable live constraints on each
Lines 117-133 Link Here
117
	 * @return the validation status
117
	 * @return the validation status
118
	 * @see IValidator#validate(Object)
118
	 * @see IValidator#validate(Object)
119
	 */
119
	 */
120
	IStatus validate(Collection eObjects, IProgressMonitor monitor);
120
	IStatus validate(Collection<? extends EObject> eObjects, IProgressMonitor monitor);
121
	
121
	
122
	/**
122
	/**
123
	 * Validates a single {@link EObject EMF element} without using any
123
	 * Validates a single {@link EObject EMF element} without using any
124
	 * progress monitor.
124
	 * progress monitor.
125
	 * 
125
	 * 
126
	 * @param object must be an {@link org.eclipse.emf.ecore.EObject}
126
	 * @param object the object to validate
127
	 * @throws ClassCastException if <code>object</code> is not an
128
	 *     {@link org.eclipse.emf.ecore.EObject}
129
	 */
127
	 */
130
	IStatus validate(Object object);
128
	IStatus validate(EObject eobject);
131
	
129
	
132
	/**
130
	/**
133
	 * Validates multiple {@link EObject EMF elements} without using any
131
	 * Validates multiple {@link EObject EMF elements} without using any
Lines 137-141 Link Here
137
	 * @throws ClassCastException if any of the <code>objects</code> is
135
	 * @throws ClassCastException if any of the <code>objects</code> is
138
	 *     not an {@link org.eclipse.emf.ecore.EObject}
136
	 *     not an {@link org.eclipse.emf.ecore.EObject}
139
	 */
137
	 */
140
	IStatus validate(Collection objects);
138
	IStatus validate(Collection<? extends EObject> objects);
141
}
139
}
(-)src/org/eclipse/emf/validation/service/ValidationEvent.java (-30 / +35 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 27-33 Link Here
27
/**
27
/**
28
 * Event notifying {@link IValidationListener}s that a validation operation
28
 * Event notifying {@link IValidationListener}s that a validation operation
29
 * has occurred.
29
 * has occurred.
30
 *
30
 * 
31
 * @author Christian W. Damus (cdamus)
31
 * @author Christian W. Damus (cdamus)
32
 */
32
 */
33
public final class ValidationEvent
33
public final class ValidationEvent
Lines 35-53 Link Here
35
35
36
	private static final long serialVersionUID = -7900125537603879206L;
36
	private static final long serialVersionUID = -7900125537603879206L;
37
	
37
	
38
	private final EvaluationMode mode;
38
	private final EvaluationMode<?> mode;
39
	private final Map clientData;
39
	private final Map<String, ?> clientData;
40
	private final IStatus status;
40
	private final IStatus status;
41
	private final Collection targets;
41
	private final Collection<?> targets;
42
	private List results;
42
	private List<IConstraintStatus> results;
43
	
43
	
44
	private Collection clientContextIds = null;
44
	private Collection<String> clientContextIds = null;
45
	
45
	
46
	/**
46
	/**
47
	 * Initializes me with the evaluation mode, client data, elements or
47
	 * Initializes me with the evaluation mode, client data, elements or
48
	 * notifications validated, and validation results that I will pass along
48
	 * notifications validated, and validation results that I will pass along
49
	 * to listeners.
49
	 * to listeners.
50
	 * 
50
	 * 
51
	 * @param <T> the kind of objects that were validated
52
	 * 
51
	 * @param mode the evaluation mode
53
	 * @param mode the evaluation mode
52
	 * @param clientData data specific to the particular validation client
54
	 * @param clientData data specific to the particular validation client
53
	 *      that performed the validation wishes to make available to listeners
55
	 *      that performed the validation wishes to make available to listeners
Lines 55-64 Link Here
55
	 *      mode) that were validated
57
	 *      mode) that were validated
56
	 * @param status the validation results
58
	 * @param status the validation results
57
	 */
59
	 */
58
	public ValidationEvent(
60
	public <T> ValidationEvent(
59
		EvaluationMode mode,
61
		EvaluationMode<T> mode,
60
		Map clientData,
62
		Map<String, ?> clientData,
61
		Collection targets,
63
		Collection<? extends T> targets,
62
		IStatus status) {
64
		IStatus status) {
63
		
65
		
64
		super(ModelValidationService.getInstance());
66
		super(ModelValidationService.getInstance());
Lines 68-74 Link Here
68
		this.targets = Collections.unmodifiableCollection(targets);
70
		this.targets = Collections.unmodifiableCollection(targets);
69
		
71
		
70
		if (clientData == null) {
72
		if (clientData == null) {
71
			this.clientData = Collections.EMPTY_MAP;
73
			this.clientData = Collections.emptyMap();
72
		} else {
74
		} else {
73
			this.clientData = Collections.unmodifiableMap(clientData);
75
			this.clientData = Collections.unmodifiableMap(clientData);
74
		}
76
		}
Lines 77-85 Link Here
77
	/**
79
	/**
78
	 * Initializes me with the evaluation mode, client data, elements or
80
	 * Initializes me with the evaluation mode, client data, elements or
79
	 * notifications validated, and validation results that I will pass along
81
	 * notifications validated, and validation results that I will pass along
80
	 * to listeners. Also, I will be initialized with the client context Ids
82
	 * to listeners. Also, I will be initialized with the client context IDs
81
	 * that were involved in the validation.
83
	 * that were involved in the validation.
82
	 * 
84
	 * 
85
	 * 
86
	 * @param <T> the kind of objects that were validated
87
	 * 
83
	 * @param mode the evaluation mode
88
	 * @param mode the evaluation mode
84
	 * @param clientData data specific to the particular validation client
89
	 * @param clientData data specific to the particular validation client
85
	 *      that performed the validation wishes to make available to listeners
90
	 *      that performed the validation wishes to make available to listeners
Lines 89-100 Link Here
89
	 * @param clientContextIds the client context Ids that were involved in the
94
	 * @param clientContextIds the client context Ids that were involved in the
90
	 *  validation.
95
	 *  validation.
91
	 */
96
	 */
92
	public ValidationEvent(
97
	public <T> ValidationEvent(
93
		EvaluationMode mode,
98
		EvaluationMode<T> mode,
94
		Map clientData,
99
		Map<String, ?> clientData,
95
		Collection targets,
100
		Collection<? extends T> targets,
96
		IStatus status,
101
		IStatus status,
97
		Collection clientContextIds) {
102
		Collection<String> clientContextIds) {
98
		
103
		
99
		this(mode,clientData,targets,status);
104
		this(mode,clientData,targets,status);
100
		
105
		
Lines 108-116 Link Here
108
	 * @return A collection of the client context ids in String form. These
113
	 * @return A collection of the client context ids in String form. These
109
	 *  ids should not be modified in any way as they may affect other listeners.
114
	 *  ids should not be modified in any way as they may affect other listeners.
110
	 */
115
	 */
111
	public Collection getClientContextIds() {
116
	public Collection<String> getClientContextIds() {
112
		if (clientContextIds == null) {
117
		if (clientContextIds == null) {
113
			clientContextIds = Collections.EMPTY_LIST;
118
			clientContextIds = Collections.emptyList();
114
		}
119
		}
115
		return clientContextIds;
120
		return clientContextIds;
116
	}
121
	}
Lines 121-127 Link Here
121
	 * @return the evaluation mode; never <code>null</code> or
126
	 * @return the evaluation mode; never <code>null</code> or
122
	 *     even {@link EvaluationMode#NULL}
127
	 *     even {@link EvaluationMode#NULL}
123
	 */
128
	 */
124
	public EvaluationMode getEvaluationMode() {
129
	public EvaluationMode<?> getEvaluationMode() {
125
		return mode;
130
		return mode;
126
	}
131
	}
127
	
132
	
Lines 137-143 Link Here
137
	 * 
142
	 * 
138
	 * @return an unmodifiable mapping of client data
143
	 * @return an unmodifiable mapping of client data
139
	 */
144
	 */
140
	public Map getClientData() {
145
	public Map<String, ?> getClientData() {
141
		return clientData;
146
		return clientData;
142
	}
147
	}
143
	
148
	
Lines 150-156 Link Here
150
	 * 
155
	 * 
151
	 * @see #getValidationResults()
156
	 * @see #getValidationResults()
152
	 */
157
	 */
153
	public Collection getValidationTargets() {
158
	public Collection<?> getValidationTargets() {
154
		return targets;
159
		return targets;
155
	}
160
	}
156
	
161
	
Lines 188-209 Link Here
188
	 * 
193
	 * 
189
	 * @see #getValidationTargets()
194
	 * @see #getValidationTargets()
190
	 */
195
	 */
191
	public List getValidationResults() {
196
	public List<IConstraintStatus> getValidationResults() {
192
		if (results == null) {
197
		if (results == null) {
193
			// lazily compute the results
198
			// lazily compute the results
194
			if (status.isMultiStatus()) {
199
			if (status.isMultiStatus()) {
195
				IStatus[] children = status.getChildren();
200
				IStatus[] children = status.getChildren();
196
				results = new java.util.ArrayList(children.length);
201
				results = new java.util.ArrayList<IConstraintStatus>(children.length);
197
				for (int i = 0; i < children.length; i++) {
202
				for (IStatus element : children) {
198
					if (children[i] instanceof IConstraintStatus) {
203
					if (element instanceof IConstraintStatus) {
199
						results.add(children[i]);
204
						results.add((IConstraintStatus) element);
200
					}
205
					}
201
				}
206
				}
202
				results = Collections.unmodifiableList(results);
207
				results = Collections.unmodifiableList(results);
203
			} else if (status instanceof IConstraintStatus) {
208
			} else if (status instanceof IConstraintStatus) {
204
				results = Collections.singletonList(status);
209
				results = Collections.singletonList((IConstraintStatus) status);
205
			} else {
210
			} else {
206
				results = Collections.EMPTY_LIST;
211
				results = Collections.emptyList();
207
			}
212
			}
208
		}
213
		}
209
		
214
		
(-)src/org/eclipse/emf/validation/service/AbstractConstraintProvider.java (-24 / +25 lines)
Lines 14-20 Link Here
14
package org.eclipse.emf.validation.service;
14
package org.eclipse.emf.validation.service;
15
15
16
import java.util.Collection;
16
import java.util.Collection;
17
import java.util.Iterator;
18
import java.util.List;
17
import java.util.List;
19
import java.util.ListIterator;
18
import java.util.ListIterator;
20
import java.util.Set;
19
import java.util.Set;
Lines 62-68 Link Here
62
			IExecutableExtension {
61
			IExecutableExtension {
63
62
64
	private String[] namespaceUris;
63
	private String[] namespaceUris;
65
	private List myConstraints = new java.util.ArrayList();
64
	private final List<IModelConstraint> myConstraints = new java.util.ArrayList<IModelConstraint>();
66
	
65
	
67
	/**
66
	/**
68
	 * A proxy for a lazily instantiated implementation of the
67
	 * A proxy for a lazily instantiated implementation of the
Lines 137-143 Link Here
137
			
136
			
138
			// replace me with my delegate in the list of constraints, to avoid
137
			// replace me with my delegate in the list of constraints, to avoid
139
			//   the delegation in future invocations and to free some memory
138
			//   the delegation in future invocations and to free some memory
140
			for (ListIterator iter = getConstraints().listIterator();
139
			for (ListIterator<IModelConstraint> iter = getConstraints().listIterator();
141
					iter.hasNext();) {
140
					iter.hasNext();) {
142
				
141
				
143
				if (iter.next() == this) {
142
				if (iter.next() == this) {
Lines 206-212 Link Here
206
	 * 
205
	 * 
207
	 * @since 1.1
206
	 * @since 1.1
208
	 */
207
	 */
209
	protected List getConstraints() {
208
	protected List<IModelConstraint> getConstraints() {
210
		return myConstraints;
209
		return myConstraints;
211
	}
210
	}
212
	
211
	
Lines 232-238 Link Here
232
			String propertyName,
231
			String propertyName,
233
			Object data) throws CoreException {
232
			Object data) throws CoreException {
234
		
233
		
235
		Set uris = new java.util.HashSet();
234
		Set<String> uris = new java.util.HashSet<String>();
236
		
235
		
237
		// backwards compatibility to the namespaceUri attribute
236
		// backwards compatibility to the namespaceUri attribute
238
		String uri = config.getAttribute(
237
		String uri = config.getAttribute(
Lines 243-250 Link Here
243
		
242
		
244
		IConfigurationElement[] pkgs = config.getChildren(XmlConfig.E_PACKAGE);
243
		IConfigurationElement[] pkgs = config.getChildren(XmlConfig.E_PACKAGE);
245
		
244
		
246
		for (int i = 0; i < pkgs.length; i++) {
245
		for (IConfigurationElement element : pkgs) {
247
			uri = pkgs[i].getAttribute(XmlConfig.A_NAMESPACE_URI);
246
			uri = element.getAttribute(XmlConfig.A_NAMESPACE_URI);
248
			if (uri != null) {
247
			if (uri != null) {
249
				uris.add(uri.trim());
248
				uris.add(uri.trim());
250
			}
249
			}
Lines 266-280 Link Here
266
			throw e;
265
			throw e;
267
		}
266
		}
268
		
267
		
269
		namespaceUris = (String[]) uris.toArray(new String[uris.size()]);
268
		namespaceUris = uris.toArray(new String[uris.size()]);
270
	}
269
	}
271
	
270
	
272
	/**
271
	/**
273
	 * @since 1.1
272
	 * @since 1.1
274
	 */
273
	 */
275
	public Collection getLiveConstraints(
274
	public Collection<IModelConstraint> getLiveConstraints(
276
			Notification notification,
275
			Notification notification,
277
			Collection constraints) {
276
			Collection<IModelConstraint> constraints) {
278
		
277
		
279
		assert notification != null;
278
		assert notification != null;
280
		
279
		
Lines 282-298 Link Here
282
			Trace.entering(getClass(), "getLiveConstraints"); //$NON-NLS-1$
281
			Trace.entering(getClass(), "getLiveConstraints"); //$NON-NLS-1$
283
		}
282
		}
284
		
283
		
285
		Collection result = constraints;
284
		Collection<IModelConstraint> result = constraints;
286
285
287
		if (result == null) {
286
		if (result == null) {
288
			result = new java.util.ArrayList();
287
			result = new java.util.ArrayList<IModelConstraint>();
289
		}
288
		}
290
		
289
		
291
		if (notification.getNotifier() instanceof EObject) {
290
		if (notification.getNotifier() instanceof EObject) {
292
			EObject eObject = (EObject)notification.getNotifier();
291
			EObject eObject = (EObject)notification.getNotifier();
293
			
292
			
294
			for (Iterator iter = getConstraints().iterator(); iter.hasNext(); ) {
293
			for (IModelConstraint next : getConstraints()) {
295
				IModelConstraint next = (IModelConstraint)iter.next();
296
				IConstraintDescriptor desc = next.getDescriptor();
294
				IConstraintDescriptor desc = next.getDescriptor();
297
	
295
	
298
				if (desc.isLive() && desc.targetsTypeOf(eObject)
296
				if (desc.isLive() && desc.targetsTypeOf(eObject)
Lines 313-334 Link Here
313
	/**
311
	/**
314
	 * @since 1.1
312
	 * @since 1.1
315
	 */
313
	 */
316
	public Collection getBatchConstraints(
314
	public Collection<IModelConstraint> getBatchConstraints(
317
			EObject eObject,
315
			EObject eObject,
318
			Collection constraints) {		
316
			Collection<IModelConstraint> constraints) {		
319
		
317
		
320
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
318
		if (Trace.shouldTraceEntering(EMFModelValidationDebugOptions.PROVIDERS)) {
321
			Trace.entering(getClass(), "getBatchConstraints"); //$NON-NLS-1$
319
			Trace.entering(getClass(), "getBatchConstraints"); //$NON-NLS-1$
322
		}
320
		}
323
		
321
		
324
		Collection result = constraints;
322
		Collection<IModelConstraint> result = constraints;
325
323
326
		if (result == null) {
324
		if (result == null) {
327
			result = new java.util.ArrayList();
325
			result = new java.util.ArrayList<IModelConstraint>();
328
		}
326
		}
329
327
330
		for (Iterator iter = getConstraints().iterator(); iter.hasNext(); ) {
328
		for (IModelConstraint next : getConstraints()) {
331
			IModelConstraint next = (IModelConstraint)iter.next();
332
			IConstraintDescriptor desc = next.getDescriptor();
329
			IConstraintDescriptor desc = next.getDescriptor();
333
330
334
			if (desc.isBatch() && desc.targetsTypeOf(eObject)) {
331
			if (desc.isBatch() && desc.targetsTypeOf(eObject)) {
Lines 355-366 Link Here
355
	 * 
352
	 * 
356
	 * @since 1.2
353
	 * @since 1.2
357
	 */
354
	 */
358
	protected void registerConstraints(Collection constraints) throws ConstraintExistsException {
355
	protected void registerConstraints(
356
	        Collection<? extends IModelConstraint> constraints)
357
	        throws ConstraintExistsException {
358
	    
359
	    if (!constraints.isEmpty()) {
359
	    if (!constraints.isEmpty()) {
360
    	    List descriptors = new java.util.ArrayList(constraints.size());
360
    	    List<IConstraintDescriptor> descriptors =
361
    	        new java.util.ArrayList<IConstraintDescriptor>(constraints.size());
361
    	    
362
    	    
362
    	    for (Iterator iter = constraints.iterator(); iter.hasNext();) {
363
    	    for (IModelConstraint next : constraints) {
363
    	        descriptors.add(((IModelConstraint) iter.next()).getDescriptor());
364
    	        descriptors.add(next.getDescriptor());
364
    	    }
365
    	    }
365
    	    
366
    	    
366
    	    ConstraintRegistry.getInstance().bulkRegister(descriptors);
367
    	    ConstraintRegistry.getInstance().bulkRegister(descriptors);
(-)src/org/eclipse/emf/validation/service/ConstraintRegistry.java (-13 / +13 lines)
Lines 13-19 Link Here
13
package org.eclipse.emf.validation.service;
13
package org.eclipse.emf.validation.service;
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.Iterator;
17
import java.util.Map;
16
import java.util.Map;
18
17
19
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
18
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
Lines 49-55 Link Here
49
public class ConstraintRegistry {
48
public class ConstraintRegistry {
50
	private static final ConstraintRegistry INSTANCE = new ConstraintRegistry();
49
	private static final ConstraintRegistry INSTANCE = new ConstraintRegistry();
51
	
50
	
52
	private final Map descriptors = new java.util.HashMap();
51
	private final Map<String, IConstraintDescriptor> descriptors =
52
	    new java.util.HashMap<String, IConstraintDescriptor>();
53
	
53
	
54
	private volatile IConstraintListener[] constraintListeners;
54
	private volatile IConstraintListener[] constraintListeners;
55
	
55
	
Lines 78-84 Link Here
78
	 *     does not exist
78
	 *     does not exist
79
	 */
79
	 */
80
	public IConstraintDescriptor getDescriptor(String id) {
80
	public IConstraintDescriptor getDescriptor(String id) {
81
		return (IConstraintDescriptor)descriptors.get(id);
81
		return descriptors.get(id);
82
	}
82
	}
83
	
83
	
84
	/**
84
	/**
Lines 92-98 Link Here
92
	 *     does not exist
92
	 *     does not exist
93
	 */
93
	 */
94
	public IConstraintDescriptor getDescriptor(String pluginId, String id) {
94
	public IConstraintDescriptor getDescriptor(String pluginId, String id) {
95
		return (IConstraintDescriptor)descriptors.get(
95
		return descriptors.get(
96
				XmlConstraintDescriptor.normalizedId(pluginId, id));
96
				XmlConstraintDescriptor.normalizedId(pluginId, id));
97
	}
97
	}
98
	
98
	
Lines 104-112 Link Here
104
	 * @return the available constraint descriptors, as an unmodifiable
104
	 * @return the available constraint descriptors, as an unmodifiable
105
	 *     collection
105
	 *     collection
106
	 */
106
	 */
107
	public Collection getAllDescriptors() {
107
	public Collection<IConstraintDescriptor> getAllDescriptors() {
108
	    synchronized (descriptors) {
108
	    synchronized (descriptors) {
109
	        return new java.util.ArrayList(descriptors.values());
109
	        return new java.util.ArrayList<IConstraintDescriptor>(descriptors.values());
110
	    }
110
	    }
111
	}
111
	}
112
	
112
	
Lines 315-327 Link Here
315
	 * @throws ConstraintExistsException if any constraint's ID is already
315
	 * @throws ConstraintExistsException if any constraint's ID is already
316
	 *    registered under a different descriptor
316
	 *    registered under a different descriptor
317
	 */
317
	 */
318
	void bulkRegister(Collection constraints) throws ConstraintExistsException {
318
	void bulkRegister(Collection<? extends IConstraintDescriptor> constraints)
319
	    Collection registered = new java.util.ArrayList(constraints.size());
319
	throws ConstraintExistsException {
320
	    Collection<IConstraintDescriptor> registered =
321
	        new java.util.ArrayList<IConstraintDescriptor>(constraints.size());
320
	    
322
	    
321
	    synchronized (descriptors) {
323
	    synchronized (descriptors) {
322
    	    for (Iterator iter = constraints.iterator(); iter.hasNext();) {
324
    	    for (IConstraintDescriptor next : constraints) {
323
    	        IConstraintDescriptor next = (IConstraintDescriptor) iter.next();
324
    	        
325
    	        if (doRegister(next)) {
325
    	        if (doRegister(next)) {
326
    	            registered.add(next);
326
    	            registered.add(next);
327
    	        }
327
    	        }
Lines 332-339 Link Here
332
	        ConstraintChangeEvent event =
332
	        ConstraintChangeEvent event =
333
	            new ConstraintChangeEvent(null, ConstraintChangeEventType.REGISTERED);
333
	            new ConstraintChangeEvent(null, ConstraintChangeEventType.REGISTERED);
334
	        
334
	        
335
    	    for (Iterator iter = registered.iterator(); iter.hasNext();) {
335
    	    for (IConstraintDescriptor next : registered) {
336
    	        event.setConstraint((IConstraintDescriptor) iter.next());
336
    	        event.setConstraint(next);
337
                broadcastConstraintChangeEvent(event);
337
                broadcastConstraintChangeEvent(event);
338
    	    }
338
    	    }
339
	    }
339
	    }
(-)src/org/eclipse/emf/validation/service/IModelConstraintProvider.java (-3 / +5 lines)
Lines 16-21 Link Here
16
16
17
import org.eclipse.emf.common.notify.Notification;
17
import org.eclipse.emf.common.notify.Notification;
18
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.emf.ecore.EObject;
19
import org.eclipse.emf.validation.model.IModelConstraint;
19
20
20
/**
21
/**
21
 * <p>
22
 * <p>
Lines 62-68 Link Here
62
	 *        <CODE>constraints </CODE> parameter (with additions), or a new
63
	 *        <CODE>constraints </CODE> parameter (with additions), or a new
63
	 *        collection if <CODE>constraints == null</CODE>
64
	 *        collection if <CODE>constraints == null</CODE>
64
	 */
65
	 */
65
	Collection getBatchConstraints(EObject eObject, Collection constraints);
66
	Collection<IModelConstraint> getBatchConstraints(EObject eObject,
67
		Collection<IModelConstraint> constraints);
66
68
67
	/**
69
	/**
68
	 * Obtains a collection of live
70
	 * Obtains a collection of live
Lines 83-89 Link Here
83
	 *        <CODE>constraints </CODE> parameter (with additions), or a new
85
	 *        <CODE>constraints </CODE> parameter (with additions), or a new
84
	 *        collection if <CODE>constraints == null</CODE>
86
	 *        collection if <CODE>constraints == null</CODE>
85
	 */
87
	 */
86
	Collection getLiveConstraints(
88
	Collection<IModelConstraint> getLiveConstraints(
87
			Notification notification,
89
			Notification notification,
88
			Collection constraints);
90
			Collection<IModelConstraint> constraints);
89
}
91
}
(-)src/org/eclipse/emf/validation/service/ILiveValidator.java (-12 / +3 lines)
Lines 31-37 Link Here
31
 * 
31
 * 
32
 * @author Christian W. Damus (cdamus)
32
 * @author Christian W. Damus (cdamus)
33
 */
33
 */
34
public interface ILiveValidator extends IValidator {
34
public interface ILiveValidator extends IValidator<Notification> {
35
	/**
35
	/**
36
	 * Validates the specified {@link Notification EMF event}.  This method is a
36
	 * Validates the specified {@link Notification EMF event}.  This method is a
37
	 * synonym for the inherited {@link IValidator#validate(Object)}.
37
	 * synonym for the inherited {@link IValidator#validate(Object)}.
Lines 42-56 Link Here
42
	 */
42
	 */
43
	IStatus validate(Notification notification);
43
	IStatus validate(Notification notification);
44
	
44
	
45
	/**
46
	 * {@inheritDoc}
47
	 * 
48
	 * @param object must be a {@link Notification}
49
	 * @throws ClassCastException if <code>object</code> is not a
50
	 *      {@link Notification}
51
	 */
52
	IStatus validate(Object object);
53
	
54
    /**
45
    /**
55
     * Obtains a filter that is used to determine which notifications will be
46
     * Obtains a filter that is used to determine which notifications will be
56
     * validated (passed on to constraints to check).  The default filter, if
47
     * validated (passed on to constraints to check).  The default filter, if
Lines 64-70 Link Here
64
     * 
55
     * 
65
     * @since 1.1
56
     * @since 1.1
66
     */
57
     */
67
    FilteredCollection.Filter getNotificationFilter();
58
    FilteredCollection.Filter<Notification> getNotificationFilter();
68
    
59
    
69
	/**
60
	/**
70
	 * Sets the filter that is used to determine which notifications will be
61
	 * Sets the filter that is used to determine which notifications will be
Lines 76-80 Link Here
76
     * 
67
     * 
77
     * @since 1.1
68
     * @since 1.1
78
	 */
69
	 */
79
	void setNotificationFilter(FilteredCollection.Filter filter);
70
	void setNotificationFilter(FilteredCollection.Filter<Notification> filter);
80
}
71
}
(-)src/org/eclipse/emf/validation/service/IConstraintDescriptor.java (-2 / +2 lines)
Lines 94-100 Link Here
94
	 * 
94
	 * 
95
	 * @return my evaluation mode
95
	 * @return my evaluation mode
96
	 */
96
	 */
97
	EvaluationMode getEvaluationMode();
97
	EvaluationMode<?> getEvaluationMode();
98
98
99
	/**
99
	/**
100
	 * Queries whether I target the type (or any supertype) of the specified
100
	 * Queries whether I target the type (or any supertype) of the specified
Lines 196-202 Link Here
196
	 * 
196
	 * 
197
	 * @return an unmodifiable set of {@link Category}s
197
	 * @return an unmodifiable set of {@link Category}s
198
	 */
198
	 */
199
	Set getCategories();
199
	Set<Category> getCategories();
200
	
200
	
201
	/**
201
	/**
202
	 * Adds a category to me.  If, previously, I was in the default category,
202
	 * Adds a category to me.  If, previously, I was in the default category,
(-)src/org/eclipse/emf/validation/service/AbstractConstraintDescriptor.java (-5 / +8 lines)
Lines 30-37 Link Here
30
 * @author Christian W. Damus (cdamus)
30
 * @author Christian W. Damus (cdamus)
31
 */
31
 */
32
public abstract class AbstractConstraintDescriptor implements IConstraintDescriptor {
32
public abstract class AbstractConstraintDescriptor implements IConstraintDescriptor {
33
	private final Set categories = new java.util.HashSet();
33
	private final Set<Category> categories = new java.util.HashSet<Category>();
34
	private final Set unmodCategories =
34
	private final Set<Category> unmodCategories =
35
		java.util.Collections.unmodifiableSet(categories);
35
		java.util.Collections.unmodifiableSet(categories);
36
	
36
	
37
	private Throwable exception;
37
	private Throwable exception;
Lines 109-125 Link Here
109
	private boolean isMandatory() {
109
	private boolean isMandatory() {
110
		boolean result = false;
110
		boolean result = false;
111
		
111
		
112
		for (Iterator iter = getCategories().iterator();
112
		for (Iterator<Category> iter = getCategories().iterator();
113
				!result && iter.hasNext();) {
113
				!result && iter.hasNext();) {
114
			
114
			
115
			result = ((Category) iter.next()).isMandatory();
115
			result = iter.next().isMandatory();
116
		}
116
		}
117
		
117
		
118
		return result;
118
		return result;
119
	}
119
	}
120
	
120
	
121
	// implements the interface method
121
	// implements the interface method
122
	public Set getCategories() {
122
	public Set<Category> getCategories() {
123
		return unmodCategories;
123
		return unmodCategories;
124
	}
124
	}
125
	
125
	
Lines 199-204 Link Here
199
	}
199
	}
200
	
200
	
201
	// redefines the inherited method
201
	// redefines the inherited method
202
	@Override
202
	public int hashCode() {
203
	public int hashCode() {
203
		return (getId() == null) ? 0 : getId().hashCode();
204
		return (getId() == null) ? 0 : getId().hashCode();
204
	}
205
	}
Lines 208-219 Link Here
208
	 * 
209
	 * 
209
	 * @see #getId()
210
	 * @see #getId()
210
	 */
211
	 */
212
	@Override
211
	public boolean equals(Object other) {
213
	public boolean equals(Object other) {
212
		return (other instanceof IConstraintDescriptor)
214
		return (other instanceof IConstraintDescriptor)
213
			&& ((IConstraintDescriptor)other).getId().equals(getId());
215
			&& ((IConstraintDescriptor)other).getId().equals(getId());
214
	}
216
	}
215
	
217
	
216
	// redefines the inherited method
218
	// redefines the inherited method
219
	@Override
217
	public String toString() {
220
	public String toString() {
218
		StringBuffer result = new StringBuffer(64);
221
		StringBuffer result = new StringBuffer(64);
219
		
222
		
(-)src/org/eclipse/emf/validation/service/AbstractTraversalStrategy.java (-5 / +6 lines)
Lines 44-50 Link Here
44
	/** Don't allow client's progress to count more steps than this number. */
44
	/** Don't allow client's progress to count more steps than this number. */
45
	private static final int MAX_PROGRESS_TICKS = 2048;
45
	private static final int MAX_PROGRESS_TICKS = 2048;
46
	
46
	
47
	private Iterator iterator;
47
	private Iterator<? extends EObject> iterator;
48
	private IProgressMonitor monitor;
48
	private IProgressMonitor monitor;
49
	
49
	
50
	/**
50
	/**
Lines 62-68 Link Here
62
	 * updates).
62
	 * updates).
63
	 */
63
	 */
64
	public void startTraversal(
64
	public void startTraversal(
65
		Collection traversalRoots,
65
		Collection<? extends EObject> traversalRoots,
66
		IProgressMonitor progressMonitor) {
66
		IProgressMonitor progressMonitor) {
67
67
68
		int taskSize = countElements(traversalRoots);
68
		int taskSize = countElements(traversalRoots);
Lines 110-116 Link Here
110
	 * @return the total number of elements to be validated within these
110
	 * @return the total number of elements to be validated within these
111
	 *     sub-trees
111
	 *     sub-trees
112
	 */
112
	 */
113
	protected abstract int countElements(Collection traversalRoots);
113
	protected abstract int countElements(Collection<? extends EObject> traversalRoots);
114
	
114
	
115
	/**
115
	/**
116
	 * Implemented by subclasses to return an iterator that provides all of the
116
	 * Implemented by subclasses to return an iterator that provides all of the
Lines 120-126 Link Here
120
	 * @param traversalRoots the roots of the traversal sub-trees
120
	 * @param traversalRoots the roots of the traversal sub-trees
121
	 * @return an iterator that covers all of the elements to be validated
121
	 * @return an iterator that covers all of the elements to be validated
122
	 */
122
	 */
123
	protected abstract Iterator createIterator(Collection traversalRoots);
123
	protected abstract Iterator<? extends EObject> createIterator(
124
		Collection<? extends EObject> traversalRoots);
124
	
125
	
125
	/**
126
	/**
126
	 * Provides subclasses with access to the progress monitor, if they want it
127
	 * Provides subclasses with access to the progress monitor, if they want it
Lines 148-154 Link Here
148
	 * @see #createIterator
149
	 * @see #createIterator
149
	 */
150
	 */
150
	public EObject next() {
151
	public EObject next() {
151
		return (EObject)iterator.next();
152
		return iterator.next();
152
	}
153
	}
153
	
154
	
154
	/**
155
	/**
(-)src/org/eclipse/emf/validation/service/ModelValidationService.java (-41 / +48 lines)
Lines 71-77 Link Here
71
public class ModelValidationService {
71
public class ModelValidationService {
72
	private static final ModelValidationService instance = new ModelValidationService();
72
	private static final ModelValidationService instance = new ModelValidationService();
73
	
73
	
74
	private final Collection constraintProviders = new java.util.HashSet();
74
	private final Collection<IProviderDescriptor> constraintProviders =
75
		new java.util.HashSet<IProviderDescriptor>();
75
	
76
	
76
	// latch to control multiple invocations of loadXmlConstraintDefinitions()
77
	// latch to control multiple invocations of loadXmlConstraintDefinitions()
77
	private boolean xmlConstraintDeclarationsLoaded = false;
78
	private boolean xmlConstraintDeclarationsLoaded = false;
Lines 107-130 Link Here
107
	 * The resulting validator may be retained as long as it is needed, and
108
	 * The resulting validator may be retained as long as it is needed, and
108
	 * reused any number of times.  Each validator has its own separate state.
109
	 * reused any number of times.  Each validator has its own separate state.
109
	 * </p>
110
	 * </p>
111
	 * 
112
	 * @param <T> the kind of validator to return
113
	 * 
110
	 * @param mode the evaluation mode for which to create a new validator.
114
	 * @param mode the evaluation mode for which to create a new validator.
111
	 *       Must not be <code>null</code> or {@link EvaluationMode#NULL}
115
	 *       Must not be <code>null</code> or {@link EvaluationMode#NULL}
116
	 * 
112
	 * @return a new validator
117
	 * @return a new validator
118
	 * 
113
	 * @throws IllegalArgumentException if the <code>mode</code> is not a
119
	 * @throws IllegalArgumentException if the <code>mode</code> is not a
114
	 *       valid evaluation mode
120
	 *       valid evaluation mode
115
	 */
121
	 */
116
	public IValidator newValidator(EvaluationMode mode) {
122
	@SuppressWarnings("unchecked")
123
	public <T, V extends IValidator<T>> V newValidator(EvaluationMode<T> mode) {
117
		assert mode != null && !mode.isNull();
124
		assert mode != null && !mode.isNull();
118
		
125
		
119
		IProviderOperationExecutor executor = new IProviderOperationExecutor() {
126
		IProviderOperationExecutor<Collection<IModelConstraint>> executor =
120
			public void execute(IProviderOperation op) {
127
			new IProviderOperationExecutor<Collection<IModelConstraint>>() {
121
				ModelValidationService.this.execute(op);
128
				public void execute(IProviderOperation<? extends Collection<IModelConstraint>> op) {
122
			}};
129
					ModelValidationService.this.execute(op);
130
				}};
123
		
131
		
124
		if (mode == EvaluationMode.BATCH) {
132
		if (mode == EvaluationMode.BATCH) {
125
			return new BatchValidator(executor);
133
			return (V) new BatchValidator(executor);
126
		} else if (mode == EvaluationMode.LIVE) {
134
		} else if (mode == EvaluationMode.LIVE) {
127
			return new LiveValidator(executor);
135
			return (V) new LiveValidator(executor);
128
		} else {
136
		} else {
129
			throw new IllegalArgumentException();
137
			throw new IllegalArgumentException();
130
		}
138
		}
Lines 213-233 Link Here
213
	 */
221
	 */
214
	public void broadcastValidationEvent(ValidationEvent event) {
222
	public void broadcastValidationEvent(ValidationEvent event) {
215
		// Check if listeners exist
223
		// Check if listeners exist
216
		if (listeners == null)
224
		if (listeners == null) {
217
			return;
225
			return;
226
		}
218
		
227
		
219
		IValidationListener[] array = listeners; // copy the reference
228
		IValidationListener[] array = listeners; // copy the reference
220
		
229
		
221
		for (int i = 0; i < array.length; i++) {
230
		for (IValidationListener element : array) {
222
			try {
231
			try {
223
				array[i].validationOccurred(event);
232
				element.validationOccurred(event);
224
			} catch (Exception e) {
233
			} catch (Exception e) {
225
				Trace.catching(getClass(), "broadcastValidationEvent", e); //$NON-NLS-1$
234
				Trace.catching(getClass(), "broadcastValidationEvent", e); //$NON-NLS-1$
226
				
235
				
227
				if (Trace.shouldTrace(EMFModelValidationDebugOptions.LISTENERS)) {
236
				if (Trace.shouldTrace(EMFModelValidationDebugOptions.LISTENERS)) {
228
					Trace.trace(
237
					Trace.trace(
229
							EMFModelValidationDebugOptions.LISTENERS,
238
							EMFModelValidationDebugOptions.LISTENERS,
230
							"Uncaught exception in listener: " + array[i].getClass().getName()); //$NON-NLS-1$
239
							"Uncaught exception in listener: " + element.getClass().getName()); //$NON-NLS-1$
231
				}
240
				}
232
				
241
				
233
				Log.l7dWarning(
242
				Log.l7dWarning(
Lines 253-262 Link Here
253
	public void configureListeners(IConfigurationElement[] elements) {
262
	public void configureListeners(IConfigurationElement[] elements) {
254
		assert elements != null;
263
		assert elements != null;
255
264
256
		for (int i = 0; i < elements.length; i++) {
265
		for (IConfigurationElement element : elements) {
257
			if (elements[i].getName().equals("listener")) { //$NON-NLS-1$
266
			if (element.getName().equals("listener")) { //$NON-NLS-1$
258
				try {
267
				try {
259
					addValidationListener(new LazyListener(elements[i]));
268
					addValidationListener(new LazyListener(element));
260
				} catch (CoreException e) {
269
				} catch (CoreException e) {
261
					Trace.catching(getClass(), "configureListeners()", e); //$NON-NLS-1$
270
					Trace.catching(getClass(), "configureListeners()", e); //$NON-NLS-1$
262
					
271
					
Lines 283-298 Link Here
283
292
284
		constraintCache = new ConstraintCache();
293
		constraintCache = new ConstraintCache();
285
		
294
		
286
		Collection providers = getProviders();
295
		Collection<IProviderDescriptor> providers = getProviders();
287
296
288
		// include the cache in my collection of providers
297
		// include the cache in my collection of providers
289
		providers.add(constraintCache.getDescriptor());
298
		providers.add(constraintCache.getDescriptor());
290
		
299
		
291
		for (int i = 0; i < elements.length; i++) {
300
		for (IConfigurationElement element : elements) {
292
			if (elements[i].getName().equals(XmlConfig.E_CONSTRAINT_PROVIDER)) {
301
			if (element.getName().equals(XmlConfig.E_CONSTRAINT_PROVIDER)) {
293
				try {
302
				try {
294
					IProviderDescriptor descriptor =
303
					IProviderDescriptor descriptor =
295
						new ProviderDescriptor(elements[i]);
304
						new ProviderDescriptor(element);
296
					
305
					
297
					if (descriptor.isCacheEnabled()) {
306
					if (descriptor.isCacheEnabled()) {
298
						constraintCache.addProvider(descriptor);
307
						constraintCache.addProvider(descriptor);
Lines 338-344 Link Here
338
	 * 
347
	 * 
339
	 * @return a collection of {@link ProviderDescriptor}s
348
	 * @return a collection of {@link ProviderDescriptor}s
340
	 */
349
	 */
341
	private Collection getProviders() {
350
	private Collection<IProviderDescriptor> getProviders() {
342
		return constraintProviders;
351
		return constraintProviders;
343
	}
352
	}
344
353
Lines 347-355 Link Here
347
	 * 
356
	 * 
348
	 * @param operation the operation to execute
357
	 * @param operation the operation to execute
349
	 */
358
	 */
350
	private void execute(IProviderOperation operation) {
359
	private void execute(
351
		for (Iterator iter = getProviders().iterator(); iter.hasNext(); ) {
360
			IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
352
			IProviderDescriptor next = (IProviderDescriptor)iter.next();
361
		
362
		for (Iterator<IProviderDescriptor> iter = getProviders().iterator(); iter.hasNext(); ) {
363
			IProviderDescriptor next = iter.next();
353
364
354
			if (next.provides(operation)) {
365
			if (next.provides(operation)) {
355
				try {
366
				try {
Lines 397-406 Link Here
397
	 * 
408
	 * 
398
	 * @param providers the available providers
409
	 * @param providers the available providers
399
	 */
410
	 */
400
	private void loadXmlConstraintDeclarations(Collection providers) {
411
	private void loadXmlConstraintDeclarations(Collection<IProviderDescriptor> providers) {
401
		for (Iterator iter = providers.iterator(); iter.hasNext();) {
412
		for (IProviderDescriptor next : providers) {
402
			IProviderDescriptor next = (IProviderDescriptor)iter.next();
403
			
404
			if (next.isXmlProvider()) {
413
			if (next.isXmlProvider()) {
405
				// the initialization of this provider is not very expensive
414
				// the initialization of this provider is not very expensive
406
				//    and is guaranteed not to load any other plug-ins
415
				//    and is guaranteed not to load any other plug-ins
Lines 437-443 Link Here
437
		if (epackage != null) {
446
		if (epackage != null) {
438
			EClassifier classifier = null;
447
			EClassifier classifier = null;
439
			
448
			
440
			List packageNames = parsePackageNames(className);
449
			List<String> packageNames = parsePackageNames(className);
441
			if (packageNames == null) {
450
			if (packageNames == null) {
442
				classifier = epackage.getEClassifier(className);
451
				classifier = epackage.getEClassifier(className);
443
			} else if (packageHasName(epackage, packageNames)) {
452
			} else if (packageHasName(epackage, packageNames)) {
Lines 466-472 Link Here
466
	 * @see #findClass(String, String)
475
	 * @see #findClass(String, String)
467
	 */
476
	 */
468
	private static EPackage findPackage(String namespaceUri) {
477
	private static EPackage findPackage(String namespaceUri) {
469
		Map registry = org.eclipse.emf.ecore.EPackage.Registry.INSTANCE;
478
		Map<String, Object> registry = org.eclipse.emf.ecore.EPackage.Registry.INSTANCE;
470
		
479
		
471
		Object result = registry.get(namespaceUri);
480
		Object result = registry.get(namespaceUri);
472
		
481
		
Lines 487-498 Link Here
487
	 * @return the package names in right-to-left order, as a list of
496
	 * @return the package names in right-to-left order, as a list of
488
	 *    strings, or <code>null</code> if the class name is not qualified
497
	 *    strings, or <code>null</code> if the class name is not qualified
489
	 */
498
	 */
490
	private static List parsePackageNames(String qualifiedClassName) {
499
	private static List<String> parsePackageNames(String qualifiedClassName) {
491
		List result = null;
500
		List<String> result = null;
492
		int end = qualifiedClassName.lastIndexOf('.'); // known BMP code point
501
		int end = qualifiedClassName.lastIndexOf('.'); // known BMP code point
493
		
502
		
494
		if (end >= 0) {
503
		if (end >= 0) {
495
			result = new java.util.ArrayList();
504
			result = new java.util.ArrayList<String>();
496
			
505
			
497
			// skip the class name part and collect other parts in
506
			// skip the class name part and collect other parts in
498
			//  reverse order
507
			//  reverse order
Lines 520-529 Link Here
520
	 *    the package from bottom to top of the containment hierarchy;
529
	 *    the package from bottom to top of the containment hierarchy;
521
	 *    <code>false</code>, otherwise
530
	 *    <code>false</code>, otherwise
522
	 */
531
	 */
523
	private static boolean packageHasName(EPackage epackage, List name) {
532
	private static boolean packageHasName(EPackage epackage, List<String> name) {
524
		boolean result = true;
533
		boolean result = true;
525
		EPackage pkg = epackage;
534
		EPackage pkg = epackage;
526
		Iterator iter = name.iterator();
535
		Iterator<String> iter = name.iterator();
527
		
536
		
528
		while (result && iter.hasNext() && (pkg != null)) {
537
		while (result && iter.hasNext() && (pkg != null)) {
529
			result = iter.next().equals(pkg.getName());
538
			result = iter.next().equals(pkg.getName());
Lines 548-554 Link Here
548
	 */
557
	 */
549
	private final class LazyListener implements IValidationListener {
558
	private final class LazyListener implements IValidationListener {
550
		private final IConfigurationElement config;
559
		private final IConfigurationElement config;
551
		private List registeredClientContexts = null;
560
		private List<String> registeredClientContexts = null;
552
		private IValidationListener validationListener = null;
561
		private IValidationListener validationListener = null;
553
		
562
		
554
		private static final String E_CLIENT_CONTEXT = "clientContext"; //$NON-NLS-1$
563
		private static final String E_CLIENT_CONTEXT = "clientContext"; //$NON-NLS-1$
Lines 582-591 Link Here
582
				IConfigurationElement[] children = config.getChildren(E_CLIENT_CONTEXT);
591
				IConfigurationElement[] children = config.getChildren(E_CLIENT_CONTEXT);
583
				
592
				
584
				// Probably a small number of registered client contexts.
593
				// Probably a small number of registered client contexts.
585
				registeredClientContexts = new ArrayList(3);
594
				registeredClientContexts = new ArrayList<String>(4);
586
				
595
				
587
				for (int i=0; i<children.length; i++) {
596
				for (IConfigurationElement element : children) {
588
					registeredClientContexts.add(children[i].getAttribute(A_CLIENT_CONTEXT_ID));
597
					registeredClientContexts.add(element.getAttribute(A_CLIENT_CONTEXT_ID));
589
				}
598
				}
590
			}
599
			}
591
			
600
			
Lines 610-618 Link Here
610
			
619
			
611
			// Otherwise, we will delay the loading of this listener until
620
			// Otherwise, we will delay the loading of this listener until
612
			//  we are certain that they are interested in listening.
621
			//  we are certain that they are interested in listening.
613
			for (Iterator i = registeredClientContexts.iterator(); i.hasNext();) {
622
			for (String clientContextId : registeredClientContexts) {
614
				String clientContextId = (String)i.next();
615
				
616
				if (event.getClientContextIds().contains(clientContextId)) {
623
				if (event.getClientContextIds().contains(clientContextId)) {
617
					try {
624
					try {
618
						if (validationListener == null) {
625
						if (validationListener == null) {
(-)src/org/eclipse/emf/validation/service/ITraversalStrategy.java (-30 / +35 lines)
Lines 61-74 Link Here
61
		/* (non-Javadoc)
61
		/* (non-Javadoc)
62
		 * Implements the inherited method.
62
		 * Implements the inherited method.
63
		 */
63
		 */
64
		protected int countElements(Collection traversalRoots) {
64
		@Override
65
        protected int countElements(Collection<? extends EObject> traversalRoots) {
65
			return traversalRoots.size();
66
			return traversalRoots.size();
66
		}
67
		}
67
68
68
		/* (non-Javadoc)
69
		/* (non-Javadoc)
69
		 * Implements the inherited method.
70
		 * Implements the inherited method.
70
		 */
71
		 */
71
		protected Iterator createIterator(Collection traversalRoots) {
72
		@Override
73
        protected Iterator<? extends EObject> createIterator(
74
                Collection<? extends EObject> traversalRoots) {
72
			return traversalRoots.iterator();
75
			return traversalRoots.iterator();
73
		}
76
		}
74
	}
77
	}
Lines 89-95 Link Here
89
	 * @author Christian W. Damus (cdamus)
92
	 * @author Christian W. Damus (cdamus)
90
	 */
93
	 */
91
	final class Recursive extends AbstractTraversalStrategy {
94
	final class Recursive extends AbstractTraversalStrategy {
92
		private Collection roots;
95
		private Collection<EObject> roots;
93
		private boolean contextChanged = true;
96
		private boolean contextChanged = true;
94
		
97
		
95
		/**
98
		/**
Lines 99-106 Link Here
99
			super();
102
			super();
100
		}
103
		}
101
		
104
		
102
		public void startTraversal(
105
		@Override
103
				Collection traversalRoots,
106
        public void startTraversal(
107
				Collection<? extends EObject> traversalRoots,
104
				IProgressMonitor progressMonitor) {
108
				IProgressMonitor progressMonitor) {
105
			
109
			
106
			roots = makeTargetsDisjoint(traversalRoots);
110
			roots = makeTargetsDisjoint(traversalRoots);
Lines 108-136 Link Here
108
			super.startTraversal(traversalRoots, progressMonitor);
112
			super.startTraversal(traversalRoots, progressMonitor);
109
		}
113
		}
110
		
114
		
111
		private Collection getRoots() {
115
		private Collection<EObject> getRoots() {
112
			return roots;
116
			return roots;
113
		}
117
		}
114
		
118
		
115
		/* (non-Javadoc)
119
		/* (non-Javadoc)
116
		 * Implements the inherited method.
120
		 * Implements the inherited method.
117
		 */
121
		 */
118
		protected int countElements(Collection ignored) {
122
		@Override
123
        protected int countElements(Collection<? extends EObject> ignored) {
119
			return countRecursive(getRoots());
124
			return countRecursive(getRoots());
120
		}
125
		}
121
		
126
		
122
		private int countRecursive(Collection elements) {
127
		private int countRecursive(Collection<? extends EObject> elements) {
123
			int result = 0;
128
			int result = 0;
124
			
129
			
125
			result = elements.size();
130
			result = elements.size();
126
			
131
			
127
			for (Iterator iter = elements.iterator(); iter.hasNext(); ) {
132
			for (EObject next : elements) {
128
				Object next = iter.next();
133
				result = result + countRecursive(next.eContents());
129
				
130
				if (next instanceof EObject) {
131
					result = result + countRecursive(
132
							((EObject)next).eContents());
133
				}
134
			}
134
			}
135
			
135
			
136
			return result;
136
			return result;
Lines 139-159 Link Here
139
		/* (non-Javadoc)
139
		/* (non-Javadoc)
140
		 * Implements the inherited method.
140
		 * Implements the inherited method.
141
		 */
141
		 */
142
		protected Iterator createIterator(Collection ignored) {
142
		@Override
143
			return new EcoreUtil.ContentTreeIterator(getRoots()) {
143
        protected Iterator<? extends EObject> createIterator(
144
                Collection<? extends EObject> ignored) {
145
		    
146
			return new EcoreUtil.ContentTreeIterator<EObject>(getRoots()) {
144
				private static final long serialVersionUID = -5653134989235663973L;
147
				private static final long serialVersionUID = -5653134989235663973L;
145
148
146
				public Iterator getChildren(Object obj) {
149
				@Override
150
                public Iterator<EObject> getChildren(Object obj) {
147
					if (obj == getRoots()) {
151
					if (obj == getRoots()) {
148
						return new Iterator() {
152
						return new Iterator<EObject>() {
149
							private final Iterator delegate =
153
							private final Iterator<EObject> delegate =
150
								getRoots().iterator();
154
								getRoots().iterator();
151
							
155
							
152
							public boolean hasNext() {
156
							public boolean hasNext() {
153
								return delegate.hasNext();
157
								return delegate.hasNext();
154
							}
158
							}
155
159
156
							public Object next() {
160
							public EObject next() {
157
								// if I'm being asked for my next element, then
161
								// if I'm being asked for my next element, then
158
								//    we are stepping to another traversal root
162
								//    we are stepping to another traversal root
159
								contextChanged = true;
163
								contextChanged = true;
Lines 169-175 Link Here
169
					}
173
					}
170
				}
174
				}
171
				
175
				
172
				public Object next() {
176
				@Override
177
                public EObject next() {
173
					// this will be set to true again the next time we test hasNext() at
178
					// this will be set to true again the next time we test hasNext() at
174
					//    the traversal root level
179
					//    the traversal root level
175
					contextChanged = false;
180
					contextChanged = false;
Lines 178-204 Link Here
178
				}};
183
				}};
179
		}
184
		}
180
		
185
		
181
		public boolean isClientContextChanged() {
186
		@Override
187
        public boolean isClientContextChanged() {
182
			return contextChanged;
188
			return contextChanged;
183
		}
189
		}
184
		
190
		
185
		private Set makeTargetsDisjoint(Collection objects) {
191
		private Set<EObject> makeTargetsDisjoint(Collection<? extends EObject> objects) {
186
			Set result = new java.util.HashSet();
192
			Set<EObject> result = new java.util.HashSet<EObject>();
187
			
193
			
188
			// ensure that any contained (descendent) elements of other elements
194
			// ensure that any contained (descendent) elements of other elements
189
			//    that we include are not included, because they will be
195
			//    that we include are not included, because they will be
190
			//    traversed by recursion, anyway
196
			//    traversed by recursion, anyway
191
			
197
			
192
	        for (Iterator it = objects.iterator(); it.hasNext();) {
198
	        for (EObject target : objects) {
193
	            EObject target = (EObject)it.next();
194
	            
195
	            // EcoreUtil uses the InternalEObject interface to check
199
	            // EcoreUtil uses the InternalEObject interface to check
196
	            // containment, so we do the same.  Also, we kip up a level to
200
	            // containment, so we do the same.  Also, we kip up a level to
197
	            // the immediate container for efficiency:  an object is its
201
	            // the immediate container for efficiency:  an object is its
198
	            // own ancestor, so we can "pre-step" up a level to avoid the
202
	            // own ancestor, so we can "pre-step" up a level to avoid the
199
	            // cost of doing it individually for every miss in the collection
203
	            // cost of doing it individually for every miss in the collection
200
	            if (!EcoreUtil.isAncestor(objects,
204
	            if (!EcoreUtil.isAncestor(objects,
201
	                ((InternalEObject) target).eInternalContainer())) {
205
	                    ((InternalEObject) target).eInternalContainer())) {
202
	                result.add(target);
206
	                result.add(target);
203
	            }
207
	            }
204
	        }
208
	        }
Lines 222-228 Link Here
222
	 * @param monitor the progress monitor used to track progress.  The receiver
226
	 * @param monitor the progress monitor used to track progress.  The receiver
223
	 *     may retain this progress monitor for the duration of the traversal
227
	 *     may retain this progress monitor for the duration of the traversal
224
	 */
228
	 */
225
	void startTraversal(Collection traversalRoots, IProgressMonitor monitor);
229
	void startTraversal(Collection<? extends EObject> traversalRoots,
230
	        IProgressMonitor monitor);
226
	
231
	
227
	/**
232
	/**
228
	 * Queries whether there is another element to be validated.
233
	 * Queries whether there is another element to be validated.
(-)src/org/eclipse/emf/validation/service/INotificationGenerator.java (-1 / +4 lines)
Lines 14-19 Link Here
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
16
17
import org.eclipse.emf.common.notify.Notification;
18
17
/**
19
/**
18
 * Interface implemented by clients who wish to define a notification
20
 * Interface implemented by clients who wish to define a notification
19
 * generator.
21
 * generator.
Lines 37-41 Link Here
37
	 * @param notifications that are eligible for validation
39
	 * @param notifications that are eligible for validation
38
	 * @return collection of newly generated notifications
40
	 * @return collection of newly generated notifications
39
	 */
41
	 */
40
	public Collection generateNotifications(Collection notifications);
42
	public Collection<Notification> generateNotifications(
43
		Collection<? extends Notification> notifications);
41
}
44
}
(-)src/org/eclipse/emf/validation/service/IValidator.java (-5 / +7 lines)
Lines 59-76 Link Here
59
 * <b>Note</b> that clients are not intended to implement this interface.
59
 * <b>Note</b> that clients are not intended to implement this interface.
60
 * </p>
60
 * </p>
61
 * 
61
 * 
62
 * @param <T> the kind of target element validated by the validator
63
 * 
62
 * @see ModelValidationService#newValidator(EvaluationMode)
64
 * @see ModelValidationService#newValidator(EvaluationMode)
63
 * 
65
 * 
64
 * @author Christian W. Damus (cdamus)
66
 * @author Christian W. Damus (cdamus)
65
 */
67
 */
66
public interface IValidator {
68
public interface IValidator<T> {
67
	/**
69
	/**
68
	 * Indicates the evaluation mode that I support.  This indicates the kind
70
	 * Indicates the evaluation mode that I support.  This indicates the kind
69
	 * of objects expected by the <code>validate()</code> methods to process.
71
	 * of objects expected by the <code>validate()</code> methods to process.
70
	 * 
72
	 * 
71
	 * @return my evaluation mode
73
	 * @return my evaluation mode
72
	 */
74
	 */
73
	EvaluationMode getEvaluationMode();
75
	EvaluationMode<T> getEvaluationMode();
74
	
76
	
75
	/**
77
	/**
76
	 * Queries whether successful constraint evaluations are reported, in
78
	 * Queries whether successful constraint evaluations are reported, in
Lines 130-136 Link Here
130
	 * @throws ClassCastException if the <code>object</code> is not of
132
	 * @throws ClassCastException if the <code>object</code> is not of
131
	 *    the correct type for this validator
133
	 *    the correct type for this validator
132
	 */
134
	 */
133
	IStatus validate(Object object);
135
	IStatus validate(T object);
134
	
136
	
135
	/**
137
	/**
136
	 * Validates multiple objects, all in the same
138
	 * Validates multiple objects, all in the same
Lines 146-152 Link Here
146
	 *    not of the correct type for this validator
148
	 *    not of the correct type for this validator
147
	 * @see #validate(Object)
149
	 * @see #validate(Object)
148
	 */
150
	 */
149
	IStatus validate(Collection objects);
151
	IStatus validate(Collection<? extends T> objects);
150
	
152
	
151
	/**
153
	/**
152
	 * Adds a constraint filter to this validator.  The validator
154
	 * Adds a constraint filter to this validator.  The validator
Lines 183-187 Link Here
183
     * 
185
     * 
184
     * @since 1.1
186
     * @since 1.1
185
     */
187
     */
186
	Collection getConstraintFilters();
188
	Collection<IConstraintFilter> getConstraintFilters();
187
}
189
}
(-)src/org/eclipse/emf/validation/service/EventTypeService.java (-10 / +12 lines)
Lines 43-55 Link Here
43
	private static final String A_FEATURE_SPECIFIC = "featureSpecific"; //$NON-NLS-1$
43
	private static final String A_FEATURE_SPECIFIC = "featureSpecific"; //$NON-NLS-1$
44
	private static final String A_NOTIFICATION_GENERATOR = "notificationGenerator"; //$NON-NLS-1$
44
	private static final String A_NOTIFICATION_GENERATOR = "notificationGenerator"; //$NON-NLS-1$
45
	
45
	
46
	private final Map notificationGenerators;
46
	private final Map<String, INotificationGenerator> notificationGenerators;
47
	
47
	
48
	/**
48
	/**
49
	 * Cannot be instantiated by clients.
49
	 * Cannot be instantiated by clients.
50
	 */
50
	 */
51
	private EventTypeService() {
51
	private EventTypeService() {
52
		notificationGenerators = new HashMap();
52
		notificationGenerators = new HashMap<String, INotificationGenerator>();
53
	}
53
	}
54
54
55
	/**
55
	/**
Lines 79-96 Link Here
79
	public void configureEventTypes(IConfigurationElement[] elements) {
79
	public void configureEventTypes(IConfigurationElement[] elements) {
80
		assert elements != null;
80
		assert elements != null;
81
81
82
		for (int i = 0; i < elements.length; i++) {
82
		for (IConfigurationElement element : elements) {
83
			if (elements[i].getName().equals("eventType")) { //$NON-NLS-1$
83
			if (element.getName().equals("eventType")) { //$NON-NLS-1$
84
				try {
84
				try {
85
					String name = elements[i].getAttribute(A_NAME);
85
					String name = element.getAttribute(A_NAME);
86
					if ((name != null) && (name.length() > 0)) {
86
					if ((name != null) && (name.length() > 0)) {
87
						EMFEventType.addEventType(name,
87
						EMFEventType.addEventType(name,
88
								Boolean.valueOf(elements[i].getAttribute(A_FEATURE_SPECIFIC)).booleanValue()
88
								Boolean.valueOf(element.getAttribute(A_FEATURE_SPECIFIC)).booleanValue()
89
								);
89
								);
90
						
90
						
91
						String notificationGenerator = elements[i].getAttribute(A_NOTIFICATION_GENERATOR);
91
						String notificationGenerator = element.getAttribute(A_NOTIFICATION_GENERATOR);
92
						if ((notificationGenerator != null) && (notificationGenerator.length() > 0)) {
92
						if ((notificationGenerator != null) && (notificationGenerator.length() > 0)) {
93
							notificationGenerators.put(name, elements[i].createExecutableExtension(A_NOTIFICATION_GENERATOR));
93
							notificationGenerators.put(
94
								name,
95
								(INotificationGenerator) element.createExecutableExtension(A_NOTIFICATION_GENERATOR));
94
						}
96
						}
95
					}
97
					}
96
				} catch (CoreException e) {
98
				} catch (CoreException e) {
Lines 107-113 Link Here
107
	 * 
109
	 * 
108
	 * @return collection of notification generators
110
	 * @return collection of notification generators
109
	 */
111
	 */
110
	public Collection getNotificationGenerators() {
112
	public Collection<INotificationGenerator> getNotificationGenerators() {
111
		return Collections.unmodifiableCollection(notificationGenerators.values());
113
		return Collections.unmodifiableCollection(notificationGenerators.values());
112
	}
114
	}
113
	
115
	
Lines 120-125 Link Here
120
	 *         null otherwise
122
	 *         null otherwise
121
	 */
123
	 */
122
	public INotificationGenerator getNotificationGenerator(String eventName) {
124
	public INotificationGenerator getNotificationGenerator(String eventName) {
123
		return (INotificationGenerator)notificationGenerators.get(eventName);
125
		return notificationGenerators.get(eventName);
124
	}
126
	}
125
}
127
}
(-)src/org/eclipse/emf/validation/util/XmlConfig.java (-9 / +9 lines)
Lines 204-218 Link Here
204
		IConfigurationElement constraint,
204
		IConfigurationElement constraint,
205
		String name) {
205
		String name) {
206
		
206
		
207
		List result = new java.util.ArrayList();
207
		List<String> result = new java.util.ArrayList<String>();
208
		
208
		
209
		IConfigurationElement[] parms = constraint.getChildren(E_PARAM);
209
		IConfigurationElement[] parms = constraint.getChildren(E_PARAM);
210
		for (int i = 0; i < parms.length; i++) {
210
		for (IConfigurationElement element : parms) {
211
			if (name.equals(parms[i].getAttribute(A_NAME))) {
211
			if (name.equals(element.getAttribute(A_NAME))) {
212
				String value = parms[i].getAttribute(A_VALUE);
212
				String value = element.getAttribute(A_VALUE);
213
				
213
				
214
				if (value == null) {
214
				if (value == null) {
215
					value = parms[i].getValue();
215
					value = element.getValue();
216
				}
216
				}
217
				
217
				
218
				if (value != null) {
218
				if (value != null) {
Lines 221-227 Link Here
221
			}
221
			}
222
		}
222
		}
223
		
223
		
224
		return (String[])result.toArray(new String[result.size()]);
224
		return result.toArray(new String[result.size()]);
225
	}
225
	}
226
226
227
	/**
227
	/**
Lines 253-260 Link Here
253
			String path = tokens.nextToken().trim();
253
			String path = tokens.nextToken().trim();
254
			
254
			
255
			if (path.length() > 0) {
255
			if (path.length() > 0) {
256
				for (int i = 0; i < children.length; i++) {
256
				for (IConfigurationElement element : children) {
257
					final String id = children[i].getAttribute(A_ID);
257
					final String id = element.getAttribute(A_ID);
258
					
258
					
259
					IConstraintDescriptor constraint =
259
					IConstraintDescriptor constraint =
260
						ConstraintRegistry.getInstance().getDescriptor(
260
						ConstraintRegistry.getInstance().getDescriptor(
Lines 263-269 Link Here
263
					
263
					
264
					if (constraint == null) {
264
					if (constraint == null) {
265
						try {
265
						try {
266
							constraint = new XmlConstraintDescriptor(children[i]);
266
							constraint = new XmlConstraintDescriptor(element);
267
						} catch (ConstraintExistsException e) {
267
						} catch (ConstraintExistsException e) {
268
							// shouldn't happen because I checked for existence
268
							// shouldn't happen because I checked for existence
269
							continue;
269
							continue;
(-)src/org/eclipse/emf/validation/util/FilteredCollection.java (-16 / +24 lines)
Lines 21-45 Link Here
21
 * Wrapper for a Java 2 {@link Collection} that provides a filtered view of its
21
 * Wrapper for a Java 2 {@link Collection} that provides a filtered view of its
22
 * contents according to a client-specified filter algorithm.
22
 * contents according to a client-specified filter algorithm.
23
 * 
23
 * 
24
 * @param <E> the collection element type
25
 * 
24
 * @author Christian W. Damus (cdamus)
26
 * @author Christian W. Damus (cdamus)
25
 */
27
 */
26
public class FilteredCollection extends AbstractCollection {
28
public class FilteredCollection<E> extends AbstractCollection<E> {
27
	/**
29
	/**
28
	 * Indicates the end of iteration.  Cannot use 'null' for this purpose, as
30
	 * Indicates the end of iteration.  Cannot use 'null' for this purpose, as
29
	 * it may legitimately be present in a collection.
31
	 * it may legitimately be present in a collection.
30
	 */
32
	 */
31
	private static final Object END_TOKEN = new Object();
33
	private static final Object END_TOKEN = new Object();
32
	
34
	
33
	private final Collection filteree;
35
	private final Collection<? extends E> filteree;
34
	private final Filter filter;
36
	private final Filter<? super E> filter;
35
	
37
	
36
	/**
38
	/**
37
	 * Interface for the algorithm that determines which elements are in and
39
	 * Interface for the algorithm that determines which elements are in and
38
	 * which are out of the filtered collection.
40
	 * which are out of the filtered collection.
39
	 * 
41
	 * 
42
	 * @param <E> the collection element type to filter
43
	 * 
40
	 * @author Christian W. Damus (cdamus)
44
	 * @author Christian W. Damus (cdamus)
41
	 */
45
	 */
42
	public static interface Filter {
46
	public static interface Filter<E> {
43
		/**
47
		/**
44
		 * Determines whether to accept or reject the specified
48
		 * Determines whether to accept or reject the specified
45
		 * <code>element</code> from the collection.
49
		 * <code>element</code> from the collection.
Lines 48-54 Link Here
48
		 * @return <CODE>true</CODE> if the <code>element</code> should be
52
		 * @return <CODE>true</CODE> if the <code>element</code> should be
49
		 *     included in the filtered view; <CODE>false</CODE>, otherwise
53
		 *     included in the filtered view; <CODE>false</CODE>, otherwise
50
		 */
54
		 */
51
		boolean accept(Object element);
55
		boolean accept(E element);
52
	}
56
	}
53
	
57
	
54
	/**
58
	/**
Lines 65-71 Link Here
65
	 * @param collection the collection that I am to filter 
69
	 * @param collection the collection that I am to filter 
66
	 * @param filter the filter algorithm to apply
70
	 * @param filter the filter algorithm to apply
67
	 */
71
	 */
68
	public FilteredCollection(Collection collection, Filter filter) {
72
	public FilteredCollection(Collection<? extends E> collection, Filter<? super E> filter) {
69
		this.filteree = collection;
73
		this.filteree = collection;
70
		this.filter = filter;
74
		this.filter = filter;
71
	}
75
	}
Lines 77-83 Link Here
77
	 * 
81
	 * 
78
	 * @return my filter
82
	 * @return my filter
79
	 */
83
	 */
80
	public final Filter getFilter() {
84
	public final Filter<? super E> getFilter() {
81
		return filter;
85
		return filter;
82
	}
86
	}
83
87
Lines 87-95 Link Here
87
	 * 
91
	 * 
88
	 * @author Christian W. Damus (cdamus)
92
	 * @author Christian W. Damus (cdamus)
89
	 */
93
	 */
90
	private class Iter implements Iterator { 
94
	@SuppressWarnings("unchecked")
91
		private final Iterator filteredIterator = filteree.iterator();
95
	private class Iter implements Iterator<E> { 
92
		private Object next = END_TOKEN;
96
		private final Iterator<? extends E> filteredIterator = filteree.iterator();
97
		
98
		private E next = (E) END_TOKEN;
93
		
99
		
94
		/**
100
		/**
95
		 * Queries whether I have another object that matches the
101
		 * Queries whether I have another object that matches the
Lines 105-111 Link Here
105
						break;
111
						break;
106
					} else {
112
					} else {
107
						// try again
113
						// try again
108
						next = END_TOKEN;
114
						next = (E) END_TOKEN;
109
					}
115
					}
110
				}
116
				}
111
			}
117
			}
Lines 116-129 Link Here
116
		/**
122
		/**
117
		 * Retrieves the next object that matches my {@link #getFilter filter}.
123
		 * Retrieves the next object that matches my {@link #getFilter filter}.
118
		 */
124
		 */
119
		public Object next() {
125
		public E next() {
120
			if (!hasNext()) {
126
			if (!hasNext()) {
121
				throw new NoSuchElementException();
127
				throw new NoSuchElementException();
122
			}
128
			}
123
			
129
			
124
			Object result = next;
130
			E result = next;
125
			
131
			
126
			next = END_TOKEN;
132
			next = (E) END_TOKEN;
127
			
133
			
128
			return result;
134
			return result;
129
		}
135
		}
Lines 146-152 Link Here
146
	 * @return an iterator the exposes only the elements of my wrapped
152
	 * @return an iterator the exposes only the elements of my wrapped
147
	 *     collection that match my filter
153
	 *     collection that match my filter
148
	 */
154
	 */
149
	public Iterator iterator() {
155
	@Override
156
	public Iterator<E> iterator() {
150
		return new Iter();
157
		return new Iter();
151
	}
158
	}
152
159
Lines 164-173 Link Here
164
	 * @return the number of elements in my wrapped collection that match my
171
	 * @return the number of elements in my wrapped collection that match my
165
	 *      filter
172
	 *      filter
166
	 */
173
	 */
174
	@Override
167
	public int size() {
175
	public int size() {
168
		int result = 0;
176
		int result = 0;
169
		
177
		
170
		for (Iterator iter = iterator(); iter.hasNext(); iter.next()) {
178
		for (Iterator<E> iter = iterator(); iter.hasNext(); iter.next()) {
171
			result++;
179
			result++;
172
		}
180
		}
173
		
181
		
(-)src/org/eclipse/emf/validation/internal/util/XmlConstraintDescriptor.java (-44 / +35 lines)
Lines 13-19 Link Here
13
package org.eclipse.emf.validation.internal.util;
13
package org.eclipse.emf.validation.internal.util;
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.Iterator;
17
import java.util.Map;
16
import java.util.Map;
18
17
19
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
Lines 24-30 Link Here
24
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EClass;
25
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.ecore.EStructuralFeature;
25
import org.eclipse.emf.ecore.EStructuralFeature;
27
28
import org.eclipse.emf.validation.EMFEventType;
26
import org.eclipse.emf.validation.EMFEventType;
29
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
27
import org.eclipse.emf.validation.internal.EMFModelValidationDebugOptions;
30
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
28
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
Lines 76-88 Link Here
76
	private String name;
74
	private String name;
77
	private String id;
75
	private String id;
78
	private int statusCode;
76
	private int statusCode;
79
	private String pluginId;
77
	private final String pluginId;
80
78
81
	private String description;
79
	private String description;
82
	private ConstraintSeverity severity = ConstraintSeverity.ERROR;
80
	private ConstraintSeverity severity = ConstraintSeverity.ERROR;
83
	private EvaluationMode mode;
81
	private EvaluationMode<?> mode;
84
82
85
	private Map targetMap = new java.util.HashMap();
83
	private Map<Object, TargetDescriptor> targetMap =
84
		new java.util.HashMap<Object, TargetDescriptor>();
86
85
87
	private String messagePattern;
86
	private String messagePattern;
88
87
Lines 243-249 Link Here
243
					new Object[] {key});
242
					new Object[] {key});
244
		}
243
		}
245
244
246
		TargetDescriptor result = (TargetDescriptor)targetMap.get(key);
245
		TargetDescriptor result = targetMap.get(key);
247
246
248
		if (result == null) {
247
		if (result == null) {
249
			result = new TargetDescriptor();
248
			result = new TargetDescriptor();
Lines 263-273 Link Here
263
	}
262
	}
264
263
265
	// implements the interface method
264
	// implements the interface method
266
	public EvaluationMode getEvaluationMode() {
265
	public EvaluationMode<?> getEvaluationMode() {
267
		return mode;
266
		return mode;
268
	}
267
	}
269
268
270
	private void setEvaluationMode(EvaluationMode mode) {
269
	private void setEvaluationMode(EvaluationMode<?> mode) {
271
		this.mode = mode;
270
		this.mode = mode;
272
	}
271
	}
273
272
Lines 282-294 Link Here
282
		
281
		
283
		resolved = true;
282
		resolved = true;
284
		
283
		
285
		Map oldMap = targetMap;
284
		Map<Object, TargetDescriptor> oldMap = targetMap;
286
		targetMap = new java.util.HashMap();
285
		targetMap = new java.util.HashMap<Object, TargetDescriptor>();
287
288
		for (Iterator iter = oldMap.entrySet().iterator(); iter.hasNext(); ) {
289
			Map.Entry next = (Map.Entry)iter.next();
290
286
291
			String typeName = (String)next.getKey();
287
		for (Map.Entry<Object, TargetDescriptor> next : oldMap.entrySet()) {
288
			String typeName = (String) next.getKey();
292
			
289
			
293
			EClass targetEClass = null;
290
			EClass targetEClass = null;
294
			// See if the typeName value from the extension has a qualified
291
			// See if the typeName value from the extension has a qualified
Lines 337-348 Link Here
337
		// that are for ancestor EClasses.  This is an O{n**2) algorithm, but
334
		// that are for ancestor EClasses.  This is an O{n**2) algorithm, but
338
		// there are not expected ever to be more than a handful of targets in
335
		// there are not expected ever to be more than a handful of targets in
339
		// any given constraint
336
		// any given constraint
340
		for (Iterator iter = targetMap.entrySet().iterator(); iter.hasNext();) {
337
		for (Map.Entry<Object, TargetDescriptor> next : targetMap.entrySet()) {
341
			Map.Entry next = (Map.Entry) iter.next();
338
			inheritTriggers((EClass) next.getKey(), next.getValue());
342
			
343
			inheritTriggers(
344
				(EClass) next.getKey(),
345
				(TargetDescriptor) next.getValue());
346
		}
339
		}
347
	}
340
	}
348
	
341
	
Lines 355-366 Link Here
355
	 * @param descriptor its descriptor
348
	 * @param descriptor its descriptor
356
	 */
349
	 */
357
	private void inheritTriggers(EClass target, TargetDescriptor descriptor) {
350
	private void inheritTriggers(EClass target, TargetDescriptor descriptor) {
358
		for (Iterator iter = targetMap.entrySet().iterator(); iter.hasNext();) {
351
		for (Map.Entry<Object, TargetDescriptor> next : targetMap.entrySet()) {
359
			Map.Entry next = (Map.Entry) iter.next();
360
			EClass otherTarget = (EClass) next.getKey();
352
			EClass otherTarget = (EClass) next.getKey();
361
			
353
			
362
			if ((otherTarget != target) && (otherTarget.isSuperTypeOf(target))) {
354
			if ((otherTarget != target) && (otherTarget.isSuperTypeOf(target))) {
363
				descriptor.merge((TargetDescriptor) next.getValue());
355
				descriptor.merge(next.getValue());
364
			}
356
			}
365
		}
357
		}
366
	}
358
	}
Lines 591-599 Link Here
591
583
592
		IConfigurationElement[] targets = extConfig.getChildren(XmlConfig.E_TARGET);
584
		IConfigurationElement[] targets = extConfig.getChildren(XmlConfig.E_TARGET);
593
585
594
		for (int i = 0; i < targets.length; i++) {
586
		for (final IConfigurationElement target : targets) {
595
			final IConfigurationElement target = targets[i];
596
597
			TargetDescriptor targetType = addTargetType(
587
			TargetDescriptor targetType = addTargetType(
598
					target.getAttribute(XmlConfig.A_CLASS));
588
					target.getAttribute(XmlConfig.A_CLASS));
599
			
589
			
Lines 602-623 Link Here
602
				//   to events in the model
592
				//   to events in the model
603
				IConfigurationElement[] events = XmlConfig.getEvents(target);
593
				IConfigurationElement[] events = XmlConfig.getEvents(target);
604
594
605
				for (int j = 0; j < events.length; j++) {
595
				for (IConfigurationElement element : events) {
606
					EMFEventType eventType = EMFEventType.getInstance(
596
					EMFEventType eventType = EMFEventType.getInstance(
607
							events[j].getAttribute(XmlConfig.A_NAME));
597
							element.getAttribute(XmlConfig.A_NAME));
608
598
609
					if (!eventType.isNull()) {
599
					if (!eventType.isNull()) {
610
						// add specific supported features, if any
600
						// add specific supported features, if any
611
						IConfigurationElement[] features =
601
						IConfigurationElement[] features =
612
							events[j].getChildren(XmlConfig.E_FEATURE);
602
							element.getChildren(XmlConfig.E_FEATURE);
613
						
603
						
614
						if ((features == null) || (features.length == 0)) {
604
						if ((features == null) || (features.length == 0)) {
615
							targetType.addEvent(eventType);
605
							targetType.addEvent(eventType);
616
						} else {
606
						} else {
617
							for (int k = 0; k < features.length; k++) {
607
							for (IConfigurationElement element2 : features) {
618
								targetType.addEvent(
608
								targetType.addEvent(
619
										eventType,
609
										eventType,
620
										features[k].getAttribute(
610
										element2.getAttribute(
621
												XmlConfig.A_NAME));
611
												XmlConfig.A_NAME));
622
							}
612
							}
623
						}
613
						}
Lines 652-658 Link Here
652
				EMFModelValidationStatusCodes.CONSTRAINT_NOT_INITED,
642
				EMFModelValidationStatusCodes.CONSTRAINT_NOT_INITED,
653
				EMFModelValidationPlugin.getMessage(
643
				EMFModelValidationPlugin.getMessage(
654
						RULE_INCOMPLETE,
644
						RULE_INCOMPLETE,
655
						new String[]{missingItem}),
645
						missingItem),
656
				null));
646
				null));
657
			
647
			
658
			Trace.throwing(getClass(), "assertNotNull", ce); //$NON-NLS-1$
648
			Trace.throwing(getClass(), "assertNotNull", ce); //$NON-NLS-1$
Lines 685-692 Link Here
685
	 * @author Christian W. Damus (cdamus)
675
	 * @author Christian W. Damus (cdamus)
686
	 */
676
	 */
687
	private static class TargetDescriptor {
677
	private static class TargetDescriptor {
688
		private final Collection nonFeatureSpecificEvents = new java.util.HashSet();
678
		private final Collection<EMFEventType> nonFeatureSpecificEvents =
689
		private final Map featureSpecificEvents = new java.util.HashMap();
679
			new java.util.HashSet<EMFEventType>();
680
		private final Map<EMFEventType, Collection<String>> featureSpecificEvents =
681
			new java.util.HashMap<EMFEventType, Collection<String>>();
690
682
691
		/**
683
		/**
692
		 * Indicates whether I explicitly support my target EClass, or whether
684
		 * Indicates whether I explicitly support my target EClass, or whether
Lines 743-753 Link Here
743
		 */
735
		 */
744
		void addEvent(EMFEventType eventType, String featureName) {
736
		void addEvent(EMFEventType eventType, String featureName) {
745
			if (featureName != null) {
737
			if (featureName != null) {
746
				Collection currentFeatures = (Collection)featureSpecificEvents.get(
738
				Collection<String> currentFeatures = featureSpecificEvents.get(
747
						eventType);
739
						eventType);
748
				
740
				
749
				if (currentFeatures == null) {
741
				if (currentFeatures == null) {
750
					currentFeatures = new java.util.HashSet();
742
					currentFeatures = new java.util.HashSet<String>();
751
					featureSpecificEvents.put(eventType, currentFeatures);
743
					featureSpecificEvents.put(eventType, currentFeatures);
752
				}
744
				}
753
				
745
				
Lines 792-799 Link Here
792
						// see whether the collection of supported event
784
						// see whether the collection of supported event
793
						//   types includes this feature
785
						//   types includes this feature
794
						if (featureSpecificEvents.containsKey(eventType)) {
786
						if (featureSpecificEvents.containsKey(eventType)) {
795
							Collection eventFeatures =
787
							Collection<String> eventFeatures =
796
								(Collection)featureSpecificEvents.get(eventType);
788
								featureSpecificEvents.get(eventType);
797
							
789
							
798
							// if no features are registered and I am supported and
790
							// if no features are registered and I am supported and
799
							//    I have no parents, then it is implied that I
791
							//    I have no parents, then it is implied that I
Lines 827-845 Link Here
827
			
819
			
828
			this.nonFeatureSpecificEvents.addAll(parent.nonFeatureSpecificEvents);
820
			this.nonFeatureSpecificEvents.addAll(parent.nonFeatureSpecificEvents);
829
			
821
			
830
			for (Iterator iter = parent.featureSpecificEvents.entrySet().iterator(); iter.hasNext();) {
822
			for (Map.Entry<EMFEventType, Collection<String>> next : parent.featureSpecificEvents.entrySet()) {
831
				Map.Entry next = (Map.Entry) iter.next();
823
				EMFEventType eventType = next.getKey();
832
				Object eventType = next.getKey();
824
				Collection<String> features = next.getValue();
833
				Collection features = (Collection) next.getValue();
834
				
825
				
835
				Collection myFeatures = (Collection) this.featureSpecificEvents.get(eventType);
826
				Collection<String> myFeatures = this.featureSpecificEvents.get(eventType);
836
				if (myFeatures == null) {
827
				if (myFeatures == null) {
837
					// add all of my parent's features.  Need to create a copy
828
					// add all of my parent's features.  Need to create a copy
838
					// because I might inherit other features from a different
829
					// because I might inherit other features from a different
839
					// parent
830
					// parent
840
					this.featureSpecificEvents.put(
831
					this.featureSpecificEvents.put(
841
						eventType,
832
						eventType,
842
						new java.util.HashSet(features));
833
						new java.util.HashSet<String>(features));
843
				} else {
834
				} else {
844
					myFeatures.addAll(features);
835
					myFeatures.addAll(features);
845
				}
836
				}
(-)src/org/eclipse/emf/validation/internal/util/XmlConfigurationElement.java (-25 / +21 lines)
Lines 14-20 Link Here
14
14
15
import java.net.MalformedURLException;
15
import java.net.MalformedURLException;
16
import java.net.URL;
16
import java.net.URL;
17
import java.util.Iterator;
18
import java.util.List;
17
import java.util.List;
19
import java.util.Map;
18
import java.util.Map;
20
19
Lines 28-38 Link Here
28
import org.eclipse.core.runtime.Path;
27
import org.eclipse.core.runtime.Path;
29
import org.eclipse.core.runtime.Platform;
28
import org.eclipse.core.runtime.Platform;
30
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.Status;
31
import org.osgi.framework.Bundle;
32
33
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
30
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
34
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
31
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
35
import org.eclipse.emf.validation.util.XmlConfig;
32
import org.eclipse.emf.validation.util.XmlConfig;
33
import org.osgi.framework.Bundle;
36
34
37
/**
35
/**
38
 * A custom implementation of the Eclipse configuration element API which is
36
 * A custom implementation of the Eclipse configuration element API which is
Lines 48-55 Link Here
48
	private final URL baseUrl;
46
	private final URL baseUrl;
49
47
50
	private String value;
48
	private String value;
51
	private final Map attributes;
49
	private final Map<String, String> attributes;
52
	private final List children = new java.util.ArrayList();
50
	private final List<IConfigurationElement> children =
51
		new java.util.ArrayList<IConfigurationElement>();
53
	private Object parent;
52
	private Object parent;
54
53
55
	/**
54
	/**
Lines 60-66 Link Here
60
	 * @param baseUrl the base of any relative URL of files that I load
59
	 * @param baseUrl the base of any relative URL of files that I load
61
	 */
60
	 */
62
	XmlConfigurationElement(String name, IExtension extension, URL baseUrl) {
61
	XmlConfigurationElement(String name, IExtension extension, URL baseUrl) {
63
		this(name, new java.util.HashMap(), extension, baseUrl);
62
		this(name, new java.util.HashMap<String, String>(), extension, baseUrl);
64
	}
63
	}
65
64
66
	/**
65
	/**
Lines 74-80 Link Here
74
	 */
73
	 */
75
	XmlConfigurationElement(
74
	XmlConfigurationElement(
76
			String name,
75
			String name,
77
			Map attributes,
76
			Map<String, String> attributes,
78
			IExtension extension,
77
			IExtension extension,
79
			URL baseUrl) {
78
			URL baseUrl) {
80
		this.myName = name;
79
		this.myName = name;
Lines 111-117 Link Here
111
110
112
	// implements the interface method
111
	// implements the interface method
113
	public String getAttribute(String name) {
112
	public String getAttribute(String name) {
114
		return (String)attributes.get(name);
113
		return attributes.get(name);
115
	}
114
	}
116
115
117
	// implements the interface method
116
	// implements the interface method
Lines 121-128 Link Here
121
120
122
	// implements the interface method
121
	// implements the interface method
123
	public String[] getAttributeNames() {
122
	public String[] getAttributeNames() {
124
		return (String[])attributes.keySet()
123
		return attributes.keySet().toArray(new String[attributes.size()]);
125
				.toArray(new String[attributes.size()]);
126
	}
124
	}
127
125
128
	/**
126
	/**
Lines 137-160 Link Here
137
135
138
	// implements the interface method
136
	// implements the interface method
139
	public IConfigurationElement[] getChildren() {
137
	public IConfigurationElement[] getChildren() {
140
		return (IConfigurationElement[])children.toArray(
138
		return children.toArray(new IConfigurationElement[children.size()]);
141
				new IConfigurationElement[children.size()]);
142
	}
139
	}
143
140
144
	// implements the interface method
141
	// implements the interface method
145
	public IConfigurationElement[] getChildren(String name) {
142
	public IConfigurationElement[] getChildren(String name) {
146
		java.util.List result = new java.util.ArrayList(children.size());
143
		java.util.List<IConfigurationElement> result =
147
144
			new java.util.ArrayList<IConfigurationElement>(children.size());
148
		for (Iterator iter = children.iterator(); iter.hasNext(); ) {
149
			IConfigurationElement next = (IConfigurationElement)iter.next();
150
145
146
		for (IConfigurationElement next : children) {
151
			if (next.getName().equals(name)) {
147
			if (next.getName().equals(name)) {
152
				result.add(next);
148
				result.add(next);
153
			}
149
			}
154
		}
150
		}
155
151
156
		return (IConfigurationElement[])result.toArray(
152
		return result.toArray(new IConfigurationElement[result.size()]);
157
				new IConfigurationElement[result.size()]);
158
	}
153
	}
159
154
160
	/**
155
	/**
Lines 217-225 Link Here
217
	 *     constraintses
212
	 *     constraintses
218
	 */
213
	 */
219
	public void flatten(IConfigurationElement[] constraintses) throws CoreException {
214
	public void flatten(IConfigurationElement[] constraintses) throws CoreException {
220
		for (int i = 0; i < constraintses.length; i++) {
215
		for (IConfigurationElement element : constraintses) {
221
			flatten(constraintses[i]);
216
			flatten(element);
222
			removeChild(constraintses[i]);
217
			removeChild(element);
223
		}
218
		}
224
	}
219
	}
225
220
Lines 247-254 Link Here
247
	 *     files
242
	 *     files
248
	 */
243
	 */
249
	public void include(IConfigurationElement[] includes) throws CoreException {
244
	public void include(IConfigurationElement[] includes) throws CoreException {
250
		for (int i = 0; i < includes.length; i++) {
245
		for (IConfigurationElement element : includes) {
251
			include(includes[i]);
246
			include(element);
252
		}
247
		}
253
	}
248
	}
254
249
Lines 322-333 Link Here
322
	private void absorb(IConfigurationElement includedConstraints) {
317
	private void absorb(IConfigurationElement includedConstraints) {
323
		IConfigurationElement[] elements = includedConstraints.getChildren();
318
		IConfigurationElement[] elements = includedConstraints.getChildren();
324
		
319
		
325
		for (int i = 0; i < elements.length; i++) {
320
		for (IConfigurationElement element : elements) {
326
			addChild(elements[i]);
321
			addChild(element);
327
		}
322
		}
328
	}
323
	}
329
324
330
	// redefines the inherited method
325
	// redefines the inherited method
326
	@Override
331
	public String toString() {
327
	public String toString() {
332
		StringBuffer result = new StringBuffer(64);
328
		StringBuffer result = new StringBuffer(64);
333
329
(-)src/org/eclipse/emf/validation/internal/util/StringMatcher.java (-33 / +62 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2006 IBM Corporation and others.
2
 * Copyright (c) 2002, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 60-71 Link Here
60
		/*
60
		/*
61
		 * (Non JavaDoc)
61
		 * (Non JavaDoc)
62
		 */
62
		 */
63
		private int start; //inclusive
63
		private final int start; //inclusive
64
64
65
		/*
65
		/*
66
		 * (Non JavaDoc)
66
		 * (Non JavaDoc)
67
		 */
67
		 */
68
		private int end; //exclusive
68
		private final int end; //exclusive
69
69
70
		/**
70
		/**
71
		 * Creates a new position.
71
		 * Creates a new position.
Lines 124-131 Link Here
124
	 */
124
	 */
125
	public StringMatcher(String pattern, boolean ignoreCase,
125
	public StringMatcher(String pattern, boolean ignoreCase,
126
			boolean ignoreWildCards) {
126
			boolean ignoreWildCards) {
127
		if (pattern == null)
127
		if (pattern == null) {
128
			throw new IllegalArgumentException();
128
			throw new IllegalArgumentException();
129
		}
129
		fIgnoreCase = ignoreCase;
130
		fIgnoreCase = ignoreCase;
130
		fIgnoreWildCards = ignoreWildCards;
131
		fIgnoreWildCards = ignoreWildCards;
131
		fPattern = pattern;
132
		fPattern = pattern;
Lines 153-180 Link Here
153
	 * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
154
	 * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
154
	 */
155
	 */
155
	public StringMatcher.Position find(String text, int start, int end) {
156
	public StringMatcher.Position find(String text, int start, int end) {
156
		if (text == null)
157
		if (text == null) {
157
			throw new IllegalArgumentException();
158
			throw new IllegalArgumentException();
159
		}
158
160
159
		int tlen = text.length();
161
		int tlen = text.length();
160
		if (start < 0)
162
		if (start < 0) {
161
			start = 0;
163
			start = 0;
162
		if (end > tlen)
164
		}
165
		if (end > tlen) {
163
			end = tlen;
166
			end = tlen;
164
		if (end < 0 || start >= end)
167
		}
168
		if (end < 0 || start >= end) {
165
			return null;
169
			return null;
166
		if (fLength == 0)
170
		}
171
		if (fLength == 0) {
167
			return new Position(start, start);
172
			return new Position(start, start);
173
		}
168
		if (fIgnoreWildCards) {
174
		if (fIgnoreWildCards) {
169
			int x = posIn(text, start, end);
175
			int x = posIn(text, start, end);
170
			if (x < 0)
176
			if (x < 0) {
171
				return null;
177
				return null;
178
			}
172
			return new Position(x, x + fLength);
179
			return new Position(x, x + fLength);
173
		}
180
		}
174
181
175
		int segCount = fSegments.length;
182
		int segCount = fSegments.length;
176
		if (segCount == 0)//pattern contains only '*'(s)
183
		if (segCount == 0) {
177
			return new Position(start, end);
184
			return new Position(start, end);
185
		}
178
186
179
		int curPos = start;
187
		int curPos = start;
180
		int matchStart = -1;
188
		int matchStart = -1;
Lines 182-195 Link Here
182
		for (i = 0; i < segCount && curPos < end; ++i) {
190
		for (i = 0; i < segCount && curPos < end; ++i) {
183
			String current = fSegments[i];
191
			String current = fSegments[i];
184
			int nextMatch = regExpPosIn(text, curPos, end, current);
192
			int nextMatch = regExpPosIn(text, curPos, end, current);
185
			if (nextMatch < 0)
193
			if (nextMatch < 0) {
186
				return null;
194
				return null;
187
			if (i == 0)
195
			}
196
			if (i == 0) {
188
				matchStart = nextMatch;
197
				matchStart = nextMatch;
198
			}
189
			curPos = nextMatch + current.length();
199
			curPos = nextMatch + current.length();
190
		}
200
		}
191
		if (i < segCount)
201
		if (i < segCount) {
192
			return null;
202
			return null;
203
		}
193
		return new Position(matchStart, curPos);
204
		return new Position(matchStart, curPos);
194
	}
205
	}
195
206
Lines 221-256 Link Here
221
	 *            substring
232
	 *            substring
222
	 */
233
	 */
223
	public boolean match(String text, int start, int end) {
234
	public boolean match(String text, int start, int end) {
224
		if (null == text)
235
		if (null == text) {
225
			throw new IllegalArgumentException();
236
			throw new IllegalArgumentException();
237
		}
226
238
227
		if (start > end)
239
		if (start > end) {
228
			return false;
240
			return false;
241
		}
229
242
230
		if (fIgnoreWildCards)
243
		if (fIgnoreWildCards) {
231
			return (end - start == fLength)
244
			return (end - start == fLength)
232
				&& fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
245
				&& fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
246
		}
233
		int segCount = fSegments.length;
247
		int segCount = fSegments.length;
234
		if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) // pattern
248
		if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) {
235
			// contains
249
			// contains
236
			// only
250
			// only
237
			// '*'(s)
251
			// '*'(s)
238
			return true;
252
			return true;
239
		if (start == end)
253
		}
254
		if (start == end) {
240
			return fLength == 0;
255
			return fLength == 0;
241
		if (fLength == 0)
256
		}
257
		if (fLength == 0) {
242
			return start == end;
258
			return start == end;
259
		}
243
260
244
		int tlen = text.length();
261
		int tlen = text.length();
245
		if (start < 0)
262
		if (start < 0) {
246
			start = 0;
263
			start = 0;
247
		if (end > tlen)
264
		}
265
		if (end > tlen) {
248
			end = tlen;
266
			end = tlen;
267
		}
249
268
250
		int tCurPos = start;
269
		int tCurPos = start;
251
		int bound = end - fBound;
270
		int bound = end - fBound;
252
		if (bound < 0)
271
		if (bound < 0) {
253
			return false;
272
			return false;
273
		}
254
		int i = 0;
274
		int i = 0;
255
		String current = fSegments[i];
275
		String current = fSegments[i];
256
		int segLength = current.length();
276
		int segLength = current.length();
Lines 276-287 Link Here
276
			int k = current.indexOf(fSingleWildCard); // known BMP code point
296
			int k = current.indexOf(fSingleWildCard); // known BMP code point
277
			if (k < 0) {
297
			if (k < 0) {
278
				currentMatch = textPosIn(text, tCurPos, end, current);
298
				currentMatch = textPosIn(text, tCurPos, end, current);
279
				if (currentMatch < 0)
299
				if (currentMatch < 0) {
280
					return false;
300
					return false;
301
				}
281
			} else {
302
			} else {
282
				currentMatch = regExpPosIn(text, tCurPos, end, current);
303
				currentMatch = regExpPosIn(text, tCurPos, end, current);
283
				if (currentMatch < 0)
304
				if (currentMatch < 0) {
284
					return false;
305
					return false;
306
				}
285
			}
307
			}
286
			tCurPos = currentMatch + current.length();
308
			tCurPos = currentMatch + current.length();
287
			i++;
309
			i++;
Lines 315-322 Link Here
315
	 *            and/or '?'
337
	 *            and/or '?'
316
	 */
338
	 */
317
	private void parseWildCards() {
339
	private void parseWildCards() {
318
		if (fPattern.startsWith("*"))//$NON-NLS-1$
340
		if (fPattern.startsWith("*")) { //$NON-NLS-1$
319
			fHasLeadingStar = true;
341
			fHasLeadingStar = true;
342
		}
320
		// if it is equal to '*', then it clearly is not a UTF-32 surrogate
343
		// if it is equal to '*', then it clearly is not a UTF-32 surrogate
321
		if (UTF16.charAt(fPattern, fLength - 1) == '*') {
344
		if (UTF16.charAt(fPattern, fLength - 1) == '*') {
322
			/* make sure it's not an escaped wildcard */
345
			/* make sure it's not an escaped wildcard */
Lines 327-333 Link Here
327
			}
350
			}
328
		}
351
		}
329
352
330
		Vector temp = new Vector();
353
		Vector<String> temp = new Vector<String>();
331
354
332
		int pos = 0;
355
		int pos = 0;
333
		StringBuffer buf = new StringBuffer();
356
		StringBuffer buf = new StringBuffer();
Lines 397-410 Link Here
397
420
398
		if (!fIgnoreCase) {
421
		if (!fIgnoreCase) {
399
			int i = UTF16.indexOf(text, fPattern, start);
422
			int i = UTF16.indexOf(text, fPattern, start);
400
			if (i == -1 || i > max)
423
			if (i == -1 || i > max) {
401
				return -1;
424
				return -1;
425
			}
402
			return i;
426
			return i;
403
		}
427
		}
404
428
405
		for (int i = start; i <= max; ++i) {
429
		for (int i = start; i <= max; ++i) {
406
			if (text.regionMatches(true, i, fPattern, 0, fLength))
430
			if (text.regionMatches(true, i, fPattern, 0, fLength)) {
407
				return i;
431
				return i;
432
			}
408
		}
433
		}
409
434
410
		return -1;
435
		return -1;
Lines 429-436 Link Here
429
454
430
		int max = end - plen;
455
		int max = end - plen;
431
		for (int i = start; i <= max; ++i) {
456
		for (int i = start; i <= max; ++i) {
432
			if (regExpRegionMatches(text, i, p, 0, plen))
457
			if (regExpRegionMatches(text, i, p, 0, plen)) {
433
				return i;
458
				return i;
459
			}
434
		}
460
		}
435
		return -1;
461
		return -1;
436
	}
462
	}
Lines 475-482 Link Here
475
					continue;
501
					continue;
476
				}
502
				}
477
			}
503
			}
478
			if (pchar == tchar)
504
			if (pchar == tchar) {
479
				continue;
505
				continue;
506
			}
480
			if (fIgnoreCase && Normalizer.compare(
507
			if (fIgnoreCase && Normalizer.compare(
481
					tchar, pchar, Normalizer.COMPARE_IGNORE_CASE) == 0) {
508
					tchar, pchar, Normalizer.COMPARE_IGNORE_CASE) == 0) {
482
				continue;
509
				continue;
Lines 505-518 Link Here
505
532
506
		if (!fIgnoreCase) {
533
		if (!fIgnoreCase) {
507
			int i = UTF16.indexOf(text, p, start);
534
			int i = UTF16.indexOf(text, p, start);
508
			if (i == -1 || i > max)
535
			if (i == -1 || i > max) {
509
				return -1;
536
				return -1;
537
			}
510
			return i;
538
			return i;
511
		}
539
		}
512
540
513
		for (int i = start; i <= max; ++i) {
541
		for (int i = start; i <= max; ++i) {
514
			if (text.regionMatches(true, i, p, 0, plen))
542
			if (text.regionMatches(true, i, p, 0, plen)) {
515
				return i;
543
				return i;
544
			}
516
		}
545
		}
517
546
518
		return -1;
547
		return -1;
(-)src/org/eclipse/emf/validation/internal/util/TextUtils.java (-17 / +19 lines)
Lines 106-117 Link Here
106
				ResourceSet resourceSet = resource.getResourceSet();
106
				ResourceSet resourceSet = resource.getResourceSet();
107
				
107
				
108
				if (resourceSet != null) {
108
				if (resourceSet != null) {
109
					List factories = resourceSet.getAdapterFactories();
109
					List<AdapterFactory> factories = resourceSet.getAdapterFactories();
110
					
110
					
111
					// iterate only as long as we don't find an adapter factory
111
					// iterate only as long as we don't find an adapter factory
112
					//    that successfully adapted the eObject
112
					//    that successfully adapted the eObject
113
					for (Iterator iter = factories.iterator(); iter.hasNext() && (result == null);) {
113
					for (Iterator<AdapterFactory> iter = factories.iterator();
114
						AdapterFactory next = (AdapterFactory) iter.next();
114
							iter.hasNext() && (result == null);) {
115
						
116
						AdapterFactory next = iter.next();
115
						
117
						
116
						if (next.isFactoryForType(type)) {
118
						if (next.isFactoryForType(type)) {
117
							result = next.adapt(eObject, type);
119
							result = next.adapt(eObject, type);
Lines 128-153 Link Here
128
	 * Applies the specified arguments to my message pattern.
130
	 * Applies the specified arguments to my message pattern.
129
	 * 
131
	 * 
130
	 * @param messagePattern the message pattern
132
	 * @param messagePattern the message pattern
131
	 * @param inputArgs the pattern arguments
133
	 * @param inputArg the pattern arguments
132
	 * @return the formatted message string
134
	 * @return the formatted message string
133
	 * 
135
	 * 
134
	 * @since 1.1
136
	 * @since 1.1
135
	 */
137
	 */
136
	public static String formatMessage(String messagePattern, Object[] inputArgs) {
138
	public static String formatMessage(String messagePattern, Object... inputArg) {
137
		Object[] args = new Object[inputArgs.length];
139
		Object[] args = new Object[inputArg.length];
138
140
139
		for (int i = 0; i < args.length; i++) {
141
		for (int i = 0; i < args.length; i++) {
140
			Object inputArg = inputArgs[i];
142
			Object next = inputArg[i];
141
143
142
			if (inputArg instanceof Collection) {
144
			if (next instanceof Collection) {
143
				inputArg = formatMultiValue((Collection)inputArg);
145
				next = formatMultiValue((Collection<?>) next);
144
			} else if (inputArg instanceof Object[]) {
146
			} else if (next instanceof Object[]) {
145
				inputArg = formatMultiValue(Arrays.asList((Object[])inputArg));
147
				next = formatMultiValue(Arrays.asList((Object[]) next));
146
			} else {
148
			} else {
147
				inputArg = formatScalarValue(inputArg);
149
				next = formatScalarValue(next);
148
			}
150
			}
149
151
150
			args[i] = inputArg;
152
			args[i] = next;
151
		}
153
		}
152
154
153
		return NLS.bind(messagePattern, args);
155
		return NLS.bind(messagePattern, args);
Lines 160-169 Link Here
160
	 * @param multiValuedArg the multiple objects
162
	 * @param multiValuedArg the multiple objects
161
	 * @return the string representation of the list
163
	 * @return the string representation of the list
162
	 */
164
	 */
163
	private static String formatMultiValue(Collection multiValuedArg) {
165
	private static String formatMultiValue(Collection<?> multiValuedArg) {
164
		List args = new java.util.ArrayList(multiValuedArg);
166
		List<Object> args = new java.util.ArrayList<Object>(multiValuedArg);
165
167
166
		for (ListIterator iter = args.listIterator(); iter.hasNext(); ) {
168
		for (ListIterator<Object> iter = args.listIterator(); iter.hasNext(); ) {
167
			iter.set(formatScalarValue(iter.next()));
169
			iter.set(formatScalarValue(iter.next()));
168
		}
170
		}
169
171
Lines 180-186 Link Here
180
	 */
182
	 */
181
	private static String formatScalarValue(Object value) {
183
	private static String formatScalarValue(Object value) {
182
		if (value instanceof EObject) {
184
		if (value instanceof EObject) {
183
			return TextUtils.getText((EObject)value);
185
			return TextUtils.getText((EObject) value);
184
		} else {
186
		} else {
185
			return String.valueOf(value);
187
			return String.valueOf(value);
186
		}
188
		}
(-)src/org/eclipse/emf/validation/internal/util/Log.java (-4 / +3 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.Status;
19
20
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
19
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
21
20
22
/**
21
/**
Lines 487-493 Link Here
487
		if (patternArgs instanceof Object[]) {
486
		if (patternArgs instanceof Object[]) {
488
			args = (Object[])patternArgs;
487
			args = (Object[])patternArgs;
489
		} else if (patternArgs instanceof Collection) {
488
		} else if (patternArgs instanceof Collection) {
490
			Collection argsCollection = (Collection)patternArgs;
489
			Collection<?> argsCollection = (Collection<?>) patternArgs;
491
			
490
			
492
			args = argsCollection.toArray(new Object[argsCollection.size()]);
491
			args = argsCollection.toArray(new Object[argsCollection.size()]);
493
		} else {
492
		} else {
Lines 555-561 Link Here
555
		
554
		
556
		log(severity,
555
		log(severity,
557
			code,
556
			code,
558
			EMFModelValidationPlugin.getMessage(messagePattern, patternArgKeys),
557
			EMFModelValidationPlugin.getMessage(messagePattern,
559
			exception);
558
			    (Object[]) patternArgKeys), exception);
560
	}
559
	}
561
}
560
}
(-)src/org/eclipse/emf/validation/internal/util/XmlConstraintFactory.java (-6 / +12 lines)
Lines 47-53 Link Here
47
			"constraintParsers"; //$NON-NLS-1$
47
			"constraintParsers"; //$NON-NLS-1$
48
48
49
	/** Mapping of language names to parser implementations. */
49
	/** Mapping of language names to parser implementations. */
50
	private final java.util.Map parserMap = new java.util.HashMap();
50
	private final java.util.Map<String, IConstraintParser> parserMap =
51
		new java.util.HashMap<String, IConstraintParser>();
51
52
52
	/**
53
	/**
53
	 * Initializes me.  I load my parsers from the <tt>constraintParsers</tt>
54
	 * Initializes me.  I load my parsers from the <tt>constraintParsers</tt>
Lines 60-65 Link Here
60
	}
61
	}
61
62
62
	// implements the inherited method
63
	// implements the inherited method
64
	@Override
65
	@SuppressWarnings("deprecation")
63
	protected IModelConstraint createConstraint(IXmlConstraintDescriptor desc) {
66
	protected IModelConstraint createConstraint(IXmlConstraintDescriptor desc) {
64
		IConfigurationElement config = desc.getConfig();
67
		IConfigurationElement config = desc.getConfig();
65
68
Lines 98-103 Link Here
98
		}
101
		}
99
	}
102
	}
100
	
103
	
104
	@Override
105
	@SuppressWarnings("deprecation")
101
	protected IModelConstraint createConstraint(IConstraintDescriptor descriptor) {
106
	protected IModelConstraint createConstraint(IConstraintDescriptor descriptor) {
102
		if (descriptor instanceof IXmlConstraintDescriptor) {
107
		if (descriptor instanceof IXmlConstraintDescriptor) {
103
			return createConstraint((IXmlConstraintDescriptor) descriptor);
108
			return createConstraint((IXmlConstraintDescriptor) descriptor);
Lines 110-115 Link Here
110
		}
115
		}
111
	}
116
	}
112
	
117
	
118
	@SuppressWarnings("deprecation")
113
	protected IModelConstraint createConstraint(IParameterizedConstraintDescriptor descriptor) {
119
	protected IModelConstraint createConstraint(IParameterizedConstraintDescriptor descriptor) {
114
		final String lang = descriptor.getLanguage();
120
		final String lang = descriptor.getLanguage();
115
		
121
		
Lines 151-156 Link Here
151
	 * 
157
	 * 
152
	 * @param config the Eclipse extension configuration data for the parser
158
	 * @param config the Eclipse extension configuration data for the parser
153
	 */
159
	 */
160
	@SuppressWarnings("deprecation")
154
	void registerParser(IConfigurationElement config) {
161
	void registerParser(IConfigurationElement config) {
155
		assert config != null;
162
		assert config != null;
156
163
Lines 163-169 Link Here
163
170
164
			if (parser instanceof IXmlConstraintParser
171
			if (parser instanceof IXmlConstraintParser
165
					|| parser instanceof IParameterizedConstraintParser) {
172
					|| parser instanceof IParameterizedConstraintParser) {
166
				parserMap.put(UCharacter.toLowerCase(language), parser);
173
				parserMap.put(UCharacter.toLowerCase(language),
174
					(IConstraintParser) parser);
167
				
175
				
168
				Trace.trace(
176
				Trace.trace(
169
						EMFModelValidationDebugOptions.PARSERS,
177
						EMFModelValidationDebugOptions.PARSERS,
Lines 194-200 Link Here
194
	 * @return the parser, or <code>null</code> if it cannot be found
202
	 * @return the parser, or <code>null</code> if it cannot be found
195
	 */
203
	 */
196
	private IConstraintParser getParser(String language) {
204
	private IConstraintParser getParser(String language) {
197
		return (IConstraintParser) parserMap.get(UCharacter.toLowerCase(language));
205
		return parserMap.get(UCharacter.toLowerCase(language));
198
	}
206
	}
199
207
200
	/**
208
	/**
Lines 207-215 Link Here
207
				EMFModelValidationPlugin.getPluginId(),
215
				EMFModelValidationPlugin.getPluginId(),
208
				CONSTRAINT_PARSERS_EXT_P_NAME);
216
				CONSTRAINT_PARSERS_EXT_P_NAME);
209
217
210
		for (int i = 0; i < configs.length; i++) {
218
		for (IConfigurationElement config : configs) {
211
			IConfigurationElement config = configs[i];
212
213
			registerParser(config);
219
			registerParser(config);
214
		}
220
		}
215
	}
221
	}
(-)src/org/eclipse/emf/validation/internal/util/Trace.java (-12 / +12 lines)
Lines 124-130 Link Here
124
	 * @param methodName The name of method that is being entered.
124
	 * @param methodName The name of method that is being entered.
125
	 */
125
	 */
126
	public static void entering(
126
	public static void entering(
127
		Class clazz,
127
		Class<?> clazz,
128
		String methodName) {
128
		String methodName) {
129
	
129
	
130
			EMFModelValidationPlugin.Tracing.entering(
130
			EMFModelValidationPlugin.Tracing.entering(
Lines 142-148 Link Here
142
	 * @param parameter The parameter to the method being entered.
142
	 * @param parameter The parameter to the method being entered.
143
	 */
143
	 */
144
	public static void entering(
144
	public static void entering(
145
		Class clazz,
145
		Class<?> clazz,
146
		String methodName,
146
		String methodName,
147
		Object parameter) {
147
		Object parameter) {
148
	
148
	
Lines 162-168 Link Here
162
	 * @param parameters The parameters to the method being entered.
162
	 * @param parameters The parameters to the method being entered.
163
	 */
163
	 */
164
	public static void entering(
164
	public static void entering(
165
		Class clazz,
165
		Class<?> clazz,
166
		String methodName,
166
		String methodName,
167
		Object[] parameters) {
167
		Object[] parameters) {
168
	
168
	
Lines 183-189 Link Here
183
	 */
183
	 */
184
	public static void entering(
184
	public static void entering(
185
		String option,
185
		String option,
186
		Class clazz,
186
		Class<?> clazz,
187
		String methodName) {
187
		String methodName) {
188
	
188
	
189
		if (shouldTraceEntering()) {
189
		if (shouldTraceEntering()) {
Lines 206-212 Link Here
206
	 */
206
	 */
207
	public static void entering(
207
	public static void entering(
208
		String option,
208
		String option,
209
		Class clazz,
209
		Class<?> clazz,
210
		String methodName,
210
		String methodName,
211
		Object parameter) {
211
		Object parameter) {
212
	
212
	
Lines 231-237 Link Here
231
	 */
231
	 */
232
	public static void entering(
232
	public static void entering(
233
		String option,
233
		String option,
234
		Class clazz,
234
		Class<?> clazz,
235
		String methodName,
235
		String methodName,
236
		Object[] parameters) {
236
		Object[] parameters) {
237
	
237
	
Lines 251-257 Link Here
251
	 * @param methodName The name of method that is being exited.
251
	 * @param methodName The name of method that is being exited.
252
	 */
252
	 */
253
	public static void exiting(
253
	public static void exiting(
254
		Class clazz,
254
		Class<?> clazz,
255
		String methodName) {
255
		String methodName) {
256
	
256
	
257
			EMFModelValidationPlugin.Tracing.exiting(
257
			EMFModelValidationPlugin.Tracing.exiting(
Lines 269-275 Link Here
269
	 * @param returnValue The return value of the method being exited.
269
	 * @param returnValue The return value of the method being exited.
270
	 */
270
	 */
271
	public static void exiting(
271
	public static void exiting(
272
		Class clazz,
272
		Class<?> clazz,
273
		String methodName,
273
		String methodName,
274
		Object returnValue) {
274
		Object returnValue) {
275
	
275
	
Lines 290-296 Link Here
290
	 */
290
	 */
291
	public static void exiting(
291
	public static void exiting(
292
		String option,
292
		String option,
293
		Class clazz,
293
		Class<?> clazz,
294
		String methodName) {
294
		String methodName) {
295
	
295
	
296
		if (shouldTraceExiting()) {
296
		if (shouldTraceExiting()) {
Lines 313-319 Link Here
313
	 */
313
	 */
314
	public static void exiting(
314
	public static void exiting(
315
		String option,
315
		String option,
316
		Class clazz,
316
		Class<?> clazz,
317
		String methodName,
317
		String methodName,
318
		Object returnValue) {
318
		Object returnValue) {
319
	
319
	
Lines 336-342 Link Here
336
	 * @param throwable The throwable that is being caught.
336
	 * @param throwable The throwable that is being caught.
337
	 */
337
	 */
338
	public static void catching(
338
	public static void catching(
339
		Class clazz,
339
		Class<?> clazz,
340
		String methodName,
340
		String methodName,
341
		Throwable throwable) {
341
		Throwable throwable) {
342
	
342
	
Lines 357-363 Link Here
357
	 * @param throwable The throwable that is being thrown.
357
	 * @param throwable The throwable that is being thrown.
358
	 */
358
	 */
359
	public static void throwing(
359
	public static void throwing(
360
		Class clazz,
360
		Class<?> clazz,
361
		String methodName,
361
		String methodName,
362
		Throwable throwable) {
362
		Throwable throwable) {
363
	
363
	
(-)src/org/eclipse/emf/validation/internal/util/JavaConstraintParser.java (-3 / +5 lines)
Lines 49-55 Link Here
49
	 * the single-instance model of {@link AbstractModelConstraint} any class
49
	 * the single-instance model of {@link AbstractModelConstraint} any class
50
	 * implementing one or more ad hoc validation method signatures.
50
	 * implementing one or more ad hoc validation method signatures.
51
	 */
51
	 */
52
	private static final Map constraintImplementationMap = new java.util.HashMap();
52
	private static final Map<Class<?>, Object> constraintImplementationMap =
53
		new java.util.HashMap<Class<?>, Object>();
53
	
54
	
54
	/**
55
	/**
55
	 * Adapts instances of {@link AbstractModelConstraint} to the internal
56
	 * Adapts instances of {@link AbstractModelConstraint} to the internal
Lines 112-117 Link Here
112
				descriptor);
113
				descriptor);
113
	}
114
	}
114
    
115
    
116
	@SuppressWarnings("deprecation")
115
    public IModelConstraint parseConstraint(IXmlConstraintDescriptor descriptor)
117
    public IModelConstraint parseConstraint(IXmlConstraintDescriptor descriptor)
116
        throws ConstraintParserException {
118
        throws ConstraintParserException {
117
        
119
        
Lines 155-161 Link Here
155
		Bundle bundle = Platform.getBundle(bundleName);
157
		Bundle bundle = Platform.getBundle(bundleName);
156
		
158
		
157
		try {
159
		try {
158
			Class resultType = bundle.loadClass(className);
160
			Class<?> resultType = bundle.loadClass(className);
159
161
160
			if (AbstractModelConstraint.class.isAssignableFrom(resultType)) {
162
			if (AbstractModelConstraint.class.isAssignableFrom(resultType)) {
161
				// instantiate the class extending AbstractModelConstraint
163
				// instantiate the class extending AbstractModelConstraint
Lines 212-218 Link Here
212
	 * @throws IllegalAccessException if the instance needs to be created
214
	 * @throws IllegalAccessException if the instance needs to be created
213
	 *     and the default constructor is not accessible
215
	 *     and the default constructor is not accessible
214
	 */
216
	 */
215
	static Object getInstance(Class constraintClass)
217
	static Object getInstance(Class<?> constraintClass)
216
			throws InstantiationException, IllegalAccessException {
218
			throws InstantiationException, IllegalAccessException {
217
		
219
		
218
		Object result = constraintImplementationMap.get(constraintClass);
220
		Object result = constraintImplementationMap.get(constraintClass);
(-)src/org/eclipse/emf/validation/internal/util/ConstraintsContentHandler.java (-13 / +21 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 96-103 Link Here
96
	 * @author Christian W. Damus (cdamus)
96
	 * @author Christian W. Damus (cdamus)
97
	 */
97
	 */
98
	private class Stack {
98
	private class Stack {
99
		private final List contents = new java.util.ArrayList();
99
		private final List<XmlConfigurationElement> contents =
100
		private final List bodies = new java.util.ArrayList();
100
			new java.util.ArrayList<XmlConfigurationElement>();
101
		private final List<StringBuffer> bodies = new java.util.ArrayList<StringBuffer>();
101
		private int lastIndex = -1;
102
		private int lastIndex = -1;
102
		
103
		
103
		/**
104
		/**
Lines 142-149 Link Here
142
				throw se;
143
				throw se;
143
			}
144
			}
144
145
145
			XmlConfigurationElement result =
146
			XmlConfigurationElement result = contents.get(lastIndex);
146
				(XmlConfigurationElement)contents.get(lastIndex);
147
			
147
			
148
			result.setValue(localize(getBody().toString().trim()));
148
			result.setValue(localize(getBody().toString().trim()));
149
149
Lines 172-178 Link Here
172
				throw se;
172
				throw se;
173
			}
173
			}
174
174
175
			return (XmlConfigurationElement)contents.get(lastIndex);
175
			return contents.get(lastIndex);
176
		}
176
		}
177
177
178
		/**
178
		/**
Lines 193-199 Link Here
193
				throw se;
193
				throw se;
194
			}
194
			}
195
195
196
			return (StringBuffer)bodies.get(lastIndex);
196
			return bodies.get(lastIndex);
197
		}
197
		}
198
	}
198
	}
199
	
199
	
Lines 204-210 Link Here
204
	 * @author Christian W. Damus (cdamus)
204
	 * @author Christian W. Damus (cdamus)
205
	 */
205
	 */
206
	private static final class ResourceBundleCache {
206
	private static final class ResourceBundleCache {
207
		private final Map map = new java.util.HashMap();
207
		private final Map<Bundle, Map<String, ResourceBundle>> map =
208
			new java.util.HashMap<Bundle, Map<String, ResourceBundle>>();
208
		
209
		
209
		/**
210
		/**
210
		 * Obtains the resource bundle named <code>baseName</code> in the
211
		 * Obtains the resource bundle named <code>baseName</code> in the
Lines 218-227 Link Here
218
		 */
219
		 */
219
		ResourceBundle get(Bundle osgiBundle, String baseName) {
220
		ResourceBundle get(Bundle osgiBundle, String baseName) {
220
			ResourceBundle result = null;
221
			ResourceBundle result = null;
221
			Map secondLevel = (Map) map.get(osgiBundle);
222
			Map<String, ResourceBundle> secondLevel = map.get(osgiBundle);
222
			
223
			
223
			if (secondLevel != null) {
224
			if (secondLevel != null) {
224
				result = (ResourceBundle) secondLevel.get(baseName);
225
				result = secondLevel.get(baseName);
225
			}
226
			}
226
			
227
			
227
			return result;
228
			return result;
Lines 237-246 Link Here
237
		 * @param rb the resource bundle to cache
238
		 * @param rb the resource bundle to cache
238
		 */
239
		 */
239
		void put(Bundle osgiBundle, String baseName, ResourceBundle rb) {
240
		void put(Bundle osgiBundle, String baseName, ResourceBundle rb) {
240
			Map secondLevel = (Map) map.get(osgiBundle);
241
			Map<String, ResourceBundle> secondLevel = map.get(osgiBundle);
241
			
242
			
242
			if (secondLevel == null) {
243
			if (secondLevel == null) {
243
				secondLevel = new java.util.HashMap();
244
				secondLevel = new java.util.HashMap<String, ResourceBundle>();
244
				map.put(osgiBundle, secondLevel);
245
				map.put(osgiBundle, secondLevel);
245
			}
246
			}
246
			
247
			
Lines 284-296 Link Here
284
	/**
285
	/**
285
	 * Pushes a new element onto the top of the stack.
286
	 * Pushes a new element onto the top of the stack.
286
	 */
287
	 */
288
	@Override
287
	public void startElement(
289
	public void startElement(
288
			String namespaceURI,
290
			String namespaceURI,
289
			String localName,
291
			String localName,
290
			String qName,
292
			String qName,
291
			Attributes atts) {
293
			Attributes atts) {
292
		int attCount = atts.getLength();
294
		int attCount = atts.getLength();
293
		Map attMap = new java.util.HashMap();
295
		Map<String, String> attMap = new java.util.HashMap<String, String>();
294
		
296
		
295
		for (int i = 0; i < attCount; i++) {
297
		for (int i = 0; i < attCount; i++) {
296
			attMap.put(atts.getQName(i), localize(atts.getValue(i)));
298
			attMap.put(atts.getQName(i), localize(atts.getValue(i)));
Lines 307-312 Link Here
307
	 * 
309
	 * 
308
	 * @see #getResult
310
	 * @see #getResult
309
	 */
311
	 */
312
	@Override
310
	public void endElement(
313
	public void endElement(
311
			String namespaceURI,
314
			String namespaceURI,
312
			String localName,
315
			String localName,
Lines 324-329 Link Here
324
	/**
327
	/**
325
	 * Appends text to the body of the top element on the stack.
328
	 * Appends text to the body of the top element on the stack.
326
	 */
329
	 */
330
	@Override
327
	public void characters(char[] ch, int start, int length)
331
	public void characters(char[] ch, int start, int length)
328
			throws SAXException {
332
			throws SAXException {
329
		
333
		
Lines 337-342 Link Here
337
	 * @throws SAXException if a version is indicated in the processing
341
	 * @throws SAXException if a version is indicated in the processing
338
	 *     instruction that is not a supported version 
342
	 *     instruction that is not a supported version 
339
	 */
343
	 */
344
	@Override
340
	public void processingInstruction(String target, String data)
345
	public void processingInstruction(String target, String data)
341
			throws SAXException {
346
			throws SAXException {
342
		if (target.equals(EMF_VALIDATION_INSTRUCTION)) {
347
		if (target.equals(EMF_VALIDATION_INSTRUCTION)) {
Lines 558-563 Link Here
558
	//
563
	//
559
	
564
	
560
	// extends the inherited method
565
	// extends the inherited method
566
	@Override
561
	public void fatalError(SAXParseException e) throws SAXException {
567
	public void fatalError(SAXParseException e) throws SAXException {
562
		Log.errorMessage(
568
		Log.errorMessage(
563
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
569
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
Lines 569-574 Link Here
569
	}
575
	}
570
	
576
	
571
	// extends the inherited method
577
	// extends the inherited method
578
	@Override
572
	public void error(SAXParseException e) throws SAXException {
579
	public void error(SAXParseException e) throws SAXException {
573
		Log.errorMessage(
580
		Log.errorMessage(
574
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
581
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
Lines 580-585 Link Here
580
	}
587
	}
581
	
588
	
582
	// extends the inherited method
589
	// extends the inherited method
590
	@Override
583
	public void warning(SAXParseException e) throws SAXException {
591
	public void warning(SAXParseException e) throws SAXException {
584
		Log.warningMessage(
592
		Log.warningMessage(
585
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
593
				EMFModelValidationStatusCodes.ERROR_PARSING_XML_FILE,
(-)src/org/eclipse/emf/validation/model/CategoryManager.java (-16 / +15 lines)
Lines 13-19 Link Here
13
package org.eclipse.emf.validation.model;
13
package org.eclipse.emf.validation.model;
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.Iterator;
17
import java.util.SortedSet;
16
import java.util.SortedSet;
18
17
19
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.core.runtime.IConfigurationElement;
Lines 76-82 Link Here
76
	 * @return an unmodifiable set of {@link Category}s, sorted by their
75
	 * @return an unmodifiable set of {@link Category}s, sorted by their
77
	 *     names
76
	 *     names
78
	 */
77
	 */
79
	public SortedSet getTopLevelCategories() {
78
	public SortedSet<Category> getTopLevelCategories() {
80
		return globalCategory.getChildren();
79
		return globalCategory.getChildren();
81
	}
80
	}
82
	
81
	
Lines 174-190 Link Here
174
		}
173
		}
175
		
174
		
176
		// first, recursively remove the child categories
175
		// first, recursively remove the child categories
177
		Collection children = new java.util.ArrayList(category.getChildren());
176
		Collection<Category> children = category.getChildren();
178
		for (Iterator iter = children.iterator(); iter.hasNext();) {
177
		Category[] childrenArray = children.toArray(new Category[children.size()]);
179
			removeCategory((Category)iter.next());
178
		for (Category child : childrenArray) {
179
			removeCategory(child);
180
		}
180
		}
181
		
181
		
182
		// purge the constraints from this category, so that they know they
182
		// purge the constraints from this category, so that they know they
183
		//   are no longer in it
183
		//   are no longer in it
184
		Collection constraints = new java.util.ArrayList(
184
		Collection<IConstraintDescriptor> constraints = category.getConstraints();
185
				category.getConstraints());
185
		IConstraintDescriptor[] constraintsArray = constraints.toArray(
186
		for (Iterator iter = constraints.iterator(); iter.hasNext();) {
186
			new IConstraintDescriptor[constraints.size()]);
187
			category.removeConstraint((IConstraintDescriptor)iter.next());
187
		for (IConstraintDescriptor constraint : constraintsArray) {
188
			category.removeConstraint(constraint);
188
		}
189
		}
189
		
190
		
190
		// finally, remove the category from its parent
191
		// finally, remove the category from its parent
Lines 234-242 Link Here
234
				EMFModelValidationPlugin.CONSTRAINT_PROVIDERS_EXT_P_NAME)
235
				EMFModelValidationPlugin.CONSTRAINT_PROVIDERS_EXT_P_NAME)
235
					.getConfigurationElements();
236
					.getConfigurationElements();
236
		
237
		
237
		for (int i = 0; i < elements.length; i++) {
238
		for (IConfigurationElement next : elements) {
238
			IConfigurationElement next = elements[i];
239
			
240
			if (next.getName().equals(XmlConfig.E_CATEGORY)) {
239
			if (next.getName().equals(XmlConfig.E_CATEGORY)) {
241
				loadCategories(globalCategory, next);
240
				loadCategories(globalCategory, next);
242
			}
241
			}
Lines 272-280 Link Here
272
			IConfigurationElement[] subcategories = element.getChildren(
271
			IConfigurationElement[] subcategories = element.getChildren(
273
					XmlConfig.E_CATEGORY);
272
					XmlConfig.E_CATEGORY);
274
		
273
		
275
			for (int i = 0; i < subcategories.length; i++) {
274
			for (IConfigurationElement element2 : subcategories) {
276
				// recursively load the child categories, if any
275
				// recursively load the child categories, if any
277
				loadCategories(category, subcategories[i]);
276
				loadCategories(category, element2);
278
			}
277
			}
279
		} else {
278
		} else {
280
			Trace.trace(
279
			Trace.trace(
Lines 289-296 Link Here
289
	 *  
288
	 *  
290
	 * @return the mandatory categories
289
	 * @return the mandatory categories
291
	 */
290
	 */
292
	public Collection getMandatoryCategories() {
291
	public Collection<Category> getMandatoryCategories() {
293
		Collection result = new java.util.ArrayList();
292
		Collection<Category> result = new java.util.ArrayList<Category>();
294
		
293
		
295
		globalCategory.getMandatoryCategories(result);
294
		globalCategory.getMandatoryCategories(result);
296
		
295
		
(-)src/org/eclipse/emf/validation/model/EvaluationMode.java (-38 / +24 lines)
Lines 15-23 Link Here
15
import java.io.Serializable;
15
import java.io.Serializable;
16
import java.util.Arrays;
16
import java.util.Arrays;
17
import java.util.Collections;
17
import java.util.Collections;
18
import java.util.Iterator;
19
import java.util.List;
18
import java.util.List;
20
19
20
import org.eclipse.emf.common.notify.Notification;
21
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
22
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
22
23
23
/**
24
/**
Lines 31-46 Link Here
31
 * still want critical constraints to be evaluated on batch invocations.
32
 * still want critical constraints to be evaluated on batch invocations.
32
 * </p>
33
 * </p>
33
 * 
34
 * 
35
 * @param <T> the kind of object that is validated in an evaluation mode
36
 * 
34
 * @author Christian W. Damus (cdamus)
37
 * @author Christian W. Damus (cdamus)
35
 */
38
 */
36
public final class EvaluationMode implements Serializable {
39
public final class EvaluationMode<T> implements Serializable {
37
	private static final long serialVersionUID = -2088295328444150344L;
38
	
39
	static final String LIVE_MODE = ValidationMessages.mode_live;
40
	static final String BATCH_MODE = ValidationMessages.mode_batch;
41
	static final String NULL_MODE = ValidationMessages.mode_unknown;
42
	
40
	
43
	private static int nextOrdinal = 0;
41
	private static final long serialVersionUID = 1862313226055912569L;
44
42
45
	/**
43
	/**
46
	 * <p>
44
	 * <p>
Lines 56-92 Link Here
56
	 * contexts.
54
	 * contexts.
57
	 * </b> 
55
	 * </b> 
58
	 */
56
	 */
59
	public static final EvaluationMode LIVE =
57
	public static final EvaluationMode<Notification> LIVE = new EvaluationMode<Notification>("Live", //$NON-NLS-1$
60
		new EvaluationMode("Live", LIVE_MODE); //$NON-NLS-1$
58
		ValidationMessages.mode_live);
61
	
59
	
62
	/**
60
	/**
63
	 * Constraints executed in the "Batch" context are intended to be
61
	 * Constraints executed in the "Batch" context are intended to be
64
	 * constraints that are evaluated on demand (when the user elects to
62
	 * constraints that are evaluated on demand (when the user elects to
65
	 * evaluate them).  These do not, therefore, udually define conditions for
63
	 * evaluate them).  These do not, therefore, usually define conditions for
66
	 * data integrity, but rather semantic rules that guide a user to creating
64
	 * data integrity, but rather semantic rules that guide a user to creating
67
	 * a better model.
65
	 * a better model.
68
	 */
66
	 */
69
	public static final EvaluationMode BATCH =
67
	public static final EvaluationMode<EObject> BATCH = new EvaluationMode<EObject>("Batch", //$NON-NLS-1$
70
		new EvaluationMode("Batch", BATCH_MODE); //$NON-NLS-1$
68
		ValidationMessages.mode_batch);
71
69
72
	/**
70
	/**
73
	 * This special value is a pointer-safe null value according to the
71
	 * This special value is a pointer-safe null value according to the
74
	 * <i>Null Object</i> pattern.  It is not a valid evaluation mode for
72
	 * <i>Null Object</i> pattern.  It is not a valid evaluation mode for
75
	 * a constraint.
73
	 * a constraint.
76
	 */
74
	 */
77
	public static final EvaluationMode NULL =
75
	public static final EvaluationMode<Void> NULL = new EvaluationMode<Void>("none", //$NON-NLS-1$
78
		new EvaluationMode("none", NULL_MODE); //$NON-NLS-1$
76
		ValidationMessages.mode_unknown);
79
77
80
	/** All valid instances. */
78
	/** All valid instances. */
81
	private static final List instances = Collections.unmodifiableList(
79
	private static final List<EvaluationMode<?>> instances = Collections.unmodifiableList(
82
		Arrays.asList(new EvaluationMode[]{
80
		Arrays.asList(new EvaluationMode<?>[] {LIVE, BATCH, NULL}));
83
				LIVE,
84
				BATCH,
85
				NULL,
86
			}));
87
81
88
	private final String name;
82
	private final String name;
89
	private final int ordinal;
90
	private final String localizedName;
83
	private final String localizedName;
91
84
92
	/**
85
	/**
Lines 98-104 Link Here
98
	 */
91
	 */
99
	private EvaluationMode(String name, String localizedName) {
92
	private EvaluationMode(String name, String localizedName) {
100
		this.name = name;
93
		this.name = name;
101
		this.ordinal = nextOrdinal++;
102
		this.localizedName = localizedName;
94
		this.localizedName = localizedName;
103
	}
95
	}
104
96
Lines 111-124 Link Here
111
	 * @param name the name of the instance to retrieve (not case-sensitive)
103
	 * @param name the name of the instance to retrieve (not case-sensitive)
112
	 * @return the named instance, or {@link #NULL} if no such instance exists
104
	 * @return the named instance, or {@link #NULL} if no such instance exists
113
	 */
105
	 */
114
	public static EvaluationMode getInstance(String name) {
106
	@SuppressWarnings("unchecked")
115
		EvaluationMode result = NULL;
107
	public static <T> EvaluationMode<T> getInstance(String name) {
116
108
		EvaluationMode<T> result = (EvaluationMode<T>) NULL;
117
		for (Iterator iter = instances.iterator(); iter.hasNext(); ) {
118
			EvaluationMode next = (EvaluationMode)iter.next();
119
109
110
		for (EvaluationMode<?> next : instances) {
120
			if (next.getName().equalsIgnoreCase(name)) {
111
			if (next.getName().equalsIgnoreCase(name)) {
121
				result = next;
112
				result = (EvaluationMode<T>) next;
122
				break;
113
				break;
123
			}
114
			}
124
		}
115
		}
Lines 131-137 Link Here
131
	 * 
122
	 * 
132
	 * @return all values
123
	 * @return all values
133
	 */
124
	 */
134
	public static final List getAllInstances() {
125
	public static final List<EvaluationMode<?>> getAllInstances() {
135
		return instances;
126
		return instances;
136
	}
127
	}
137
128
Lines 193-209 Link Here
193
	}
184
	}
194
185
195
	// re-implements the inherited method
186
	// re-implements the inherited method
187
	@Override
196
	public String toString() {
188
	public String toString() {
197
		return getName();
189
		return getName();
198
	}
190
	}
199
191
	
200
	/**
201
	 * Implements the instance substitution protocol defined by the Java
202
	 * Serialization Specification.
203
	 * 
204
	 * @return the correct pre-defined instance of the enumeration
205
	 */
206
	private Object readResolve() {
192
	private Object readResolve() {
207
		return getAllInstances().get(ordinal);
193
		return getInstance(getName());
208
	}
194
	}
209
}
195
}
(-)src/org/eclipse/emf/validation/model/IModelConstraint.java (-3 / +3 lines)
Lines 42-48 Link Here
42
	 * <p>
42
	 * <p>
43
	 * <b>Note</b> that it is best to use the
43
	 * <b>Note</b> that it is best to use the
44
	 * {@link IValidationContext#createSuccessStatus()} and
44
	 * {@link IValidationContext#createSuccessStatus()} and
45
	 * {@link IValidationContext#createFailureStatus(Object[])} methods of the context
45
	 * {@link IValidationContext#createFailureStatus(Object...)} methods of the context
46
	 * object to create the status object returned from this method, to ensure
46
	 * object to create the status object returned from this method, to ensure
47
	 * that the status object returned is correctly handled by the validation
47
	 * that the status object returned is correctly handled by the validation
48
	 * system.
48
	 * system.
Lines 51-57 Link Here
51
	 * cases, it can return a
51
	 * cases, it can return a
52
	 * {@link ConstraintStatus#createMultiStatus(IValidationContext, Collection) multi-status} of
52
	 * {@link ConstraintStatus#createMultiStatus(IValidationContext, Collection) multi-status} of
53
	 * multiple results created by the overloaded variants of the
53
	 * multiple results created by the overloaded variants of the
54
	 * {@link ConstraintStatus#createStatus(IValidationContext, org.eclipse.emf.ecore.EObject, Collection, String, Object[])}
54
	 * {@link ConstraintStatus#createStatus(IValidationContext, org.eclipse.emf.ecore.EObject, Collection, String, Object...)}
55
	 * method.  In these cases, also, each resulting status can store a distinct
55
	 * method.  In these cases, also, each resulting status can store a distinct
56
	 * result locus.  For example:
56
	 * result locus.  For example:
57
	 * </p>
57
	 * </p>
Lines 98-104 Link Here
98
	 *         Must not return <code>null</code>
98
	 *         Must not return <code>null</code>
99
	 *         
99
	 *         
100
	 * @see IValidationContext#createSuccessStatus()
100
	 * @see IValidationContext#createSuccessStatus()
101
	 * @see IValidationContext#createFailureStatus(Object[])
101
	 * @see IValidationContext#createFailureStatus(Object...)
102
	 * @see ConstraintStatus#createStatus(IValidationContext, org.eclipse.emf.ecore.EObject, Collection, String, Object[])
102
	 * @see ConstraintStatus#createStatus(IValidationContext, org.eclipse.emf.ecore.EObject, Collection, String, Object[])
103
	 */
103
	 */
104
	IStatus validate(IValidationContext ctx);
104
	IStatus validate(IValidationContext ctx);
(-)src/org/eclipse/emf/validation/model/IConstraintStatus.java (-1 / +1 lines)
Lines 49-53 Link Here
49
	 *     successful validation, the result is an empty collection.  The result
49
	 *     successful validation, the result is an empty collection.  The result
50
	 *     is never <code>null</code>
50
	 *     is never <code>null</code>
51
	 */
51
	 */
52
	Set getResultLocus();
52
	Set<EObject> getResultLocus();
53
}
53
}
(-)src/org/eclipse/emf/validation/model/ConstraintSeverity.java (-33 / +20 lines)
Lines 12-24 Link Here
12
12
13
package org.eclipse.emf.validation.model;
13
package org.eclipse.emf.validation.model;
14
14
15
import java.io.Serializable;
16
import java.util.Arrays;
15
import java.util.Arrays;
17
import java.util.Collections;
16
import java.util.Collections;
18
import java.util.Iterator;
19
import java.util.List;
17
import java.util.List;
20
18
21
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.emf.common.util.Enumerator;
22
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
21
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
23
22
24
/**
23
/**
Lines 32-78 Link Here
32
 * 
31
 * 
33
 * @author Christian W. Damus (cdamus)
32
 * @author Christian W. Damus (cdamus)
34
 */
33
 */
35
public final class ConstraintSeverity implements Serializable {
34
public enum ConstraintSeverity implements Enumerator {
36
	private static final long serialVersionUID = -5310833954198275258L;
37
38
	private static int nextOrdinal = 0;
39
40
	/**
35
	/**
41
	 * Indicates that failure of the constraint should only generate an
36
	 * Indicates that failure of the constraint should only generate an
42
	 * informational message to the user.
37
	 * informational message to the user.
43
	 */
38
	 */
44
	public static final ConstraintSeverity INFO = new ConstraintSeverity(
39
	INFO("INFO", ValidationMessages.severity_info, IStatus.INFO), //$NON-NLS-1$
45
			"INFO", ValidationMessages.severity_info, IStatus.INFO); //$NON-NLS-1$
46
	
40
	
47
	/**
41
	/**
48
	 * Indicates that failure of the constraint constitutes a warning condition.
42
	 * Indicates that failure of the constraint constitutes a warning condition.
49
	 */
43
	 */
50
	public static final ConstraintSeverity WARNING = new ConstraintSeverity(
44
	WARNING("WARNING", ValidationMessages.severity_warning, IStatus.WARNING), //$NON-NLS-1$
51
			"WARNING", ValidationMessages.severity_warning, IStatus.WARNING); //$NON-NLS-1$
52
45
53
	/**
46
	/**
54
	 * Indicates that failure of the constraint constitutes an error condition.
47
	 * Indicates that failure of the constraint constitutes an error condition.
55
	 */
48
	 */
56
	public static final ConstraintSeverity ERROR = new ConstraintSeverity(
49
	ERROR("ERROR", ValidationMessages.severity_error, IStatus.ERROR), //$NON-NLS-1$
57
			"ERROR", ValidationMessages.severity_error, IStatus.ERROR); //$NON-NLS-1$
58
50
59
	/**
51
	/**
60
	 * Indicates that failure of the constraint constitutes an error condition
52
	 * Indicates that failure of the constraint constitutes an error condition
61
	 * that should cancel the validation operation (no further constraints are
53
	 * that should cancel the validation operation (no further constraints are
62
	 * evaluated).
54
	 * evaluated).
63
	 */
55
	 */
64
	public static final ConstraintSeverity CANCEL = new ConstraintSeverity(
56
	CANCEL("CANCEL", ValidationMessages.severity_cancel, IStatus.CANCEL), //$NON-NLS-1$
65
			"CANCEL", ValidationMessages.severity_cancel, IStatus.CANCEL); //$NON-NLS-1$
66
	/**
57
	/**
67
	 * This special value is a pointer-safe null value according to the
58
	 * This special value is a pointer-safe null value according to the
68
	 * <i>Null Object</i> pattern.  It is not a valid severity for
59
	 * <i>Null Object</i> pattern.  It is not a valid severity for
69
	 * a constraint.
60
	 * a constraint.
70
	 */
61
	 */
71
	public static final ConstraintSeverity NULL = new ConstraintSeverity(
62
	NULL("none", ValidationMessages.severity_null, IStatus.OK); //$NON-NLS-1$
72
			"none", ValidationMessages.severity_null, IStatus.OK); //$NON-NLS-1$
63
64
	private static final long serialVersionUID = -5310833954198275258L;
73
65
74
	/** All of my values. */
66
	/** All of my values. */
75
	private static final List instances = Collections.unmodifiableList(
67
	private static final List<ConstraintSeverity> instances = Collections.unmodifiableList(
76
			Arrays.asList(new ConstraintSeverity[]{
68
			Arrays.asList(new ConstraintSeverity[]{
77
					INFO,
69
					INFO,
78
					WARNING,
70
					WARNING,
Lines 83-89 Link Here
83
75
84
	private final String name;
76
	private final String name;
85
	private final String localizedName;
77
	private final String localizedName;
86
	private final int ordinal;
87
	private final int istatusSeverity;
78
	private final int istatusSeverity;
88
79
89
	/**
80
	/**
Lines 96-102 Link Here
96
	 */
87
	 */
97
	private ConstraintSeverity(String name, String localizedName, int istatusSeverity) {
88
	private ConstraintSeverity(String name, String localizedName, int istatusSeverity) {
98
		this.name = name;
89
		this.name = name;
99
		this.ordinal = nextOrdinal++;
100
		this.istatusSeverity = istatusSeverity;
90
		this.istatusSeverity = istatusSeverity;
101
		
91
		
102
		this.localizedName = localizedName;
92
		this.localizedName = localizedName;
Lines 112-120 Link Here
112
	public static ConstraintSeverity getInstance(String name) {
102
	public static ConstraintSeverity getInstance(String name) {
113
		ConstraintSeverity result = NULL;
103
		ConstraintSeverity result = NULL;
114
104
115
		for (Iterator iter = instances.iterator(); iter.hasNext(); ) {
105
		for (ConstraintSeverity next : instances) {
116
			ConstraintSeverity next = (ConstraintSeverity)iter.next();
117
118
			if (next.getName().equalsIgnoreCase(name)) {
106
			if (next.getName().equalsIgnoreCase(name)) {
119
				result = next;
107
				result = next;
120
				break;
108
				break;
Lines 129-135 Link Here
129
	 * 
117
	 * 
130
	 * @return all values
118
	 * @return all values
131
	 */
119
	 */
132
	public static final List getAllInstances() {
120
	public static final List<ConstraintSeverity> getAllInstances() {
133
		return instances;
121
		return instances;
134
	}
122
	}
135
123
Lines 173-189 Link Here
173
	}
161
	}
174
162
175
	// re-implements the inherited method
163
	// re-implements the inherited method
164
	@Override
176
	public String toString() {
165
	public String toString() {
177
		return getName();
166
		return getName();
178
	}
167
	}
179
168
	
180
	/**
169
	public int getValue() {
181
	 * Implements the instance substitution protocol defined by the Java
170
		return ordinal();
182
	 * Serialization Specification.
171
	}
183
	 * 
172
	
184
	 * @return the correct pre-defined instance of the enumeration
173
	public String getLiteral() {
185
	 */
174
		return getName();
186
	private Object readResolve() {
187
		return getAllInstances().get(ordinal);
188
	}
175
	}
189
}
176
}
(-)src/org/eclipse/emf/validation/model/Category.java (-17 / +17 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-20 Link Here
14
14
15
import java.util.Collection;
15
import java.util.Collection;
16
import java.util.Collections;
16
import java.util.Collections;
17
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Set;
18
import java.util.Set;
19
import java.util.SortedSet;
19
import java.util.SortedSet;
20
20
Lines 41-47 Link Here
41
 * 
41
 * 
42
 * @author Christian W. Damus (cdamus)
42
 * @author Christian W. Damus (cdamus)
43
 */
43
 */
44
public class Category implements Comparable {
44
public class Category implements Comparable<Category> {
45
	static final String SLASH = "/"; //$NON-NLS-1$
45
	static final String SLASH = "/"; //$NON-NLS-1$
46
	
46
	
47
	/**
47
	/**
Lines 70-78 Link Here
70
	private boolean mandatory;
70
	private boolean mandatory;
71
	
71
	
72
	private final Category parent;
72
	private final Category parent;
73
	private final java.util.Map children = new java.util.HashMap();
73
	private final Map<String, Category> children =
74
		new java.util.HashMap<String, Category>();
74
	
75
	
75
	private final Set constraints = new java.util.HashSet();
76
	private final Set<IConstraintDescriptor> constraints =
77
		new java.util.HashSet<IConstraintDescriptor>();
76
	
78
	
77
	/**
79
	/**
78
	 * Initializes me with my ID and parent category.
80
	 * Initializes me with my ID and parent category.
Lines 165-171 Link Here
165
	 * @return the {@link IConstraintDescriptor}s that are members of me as an
167
	 * @return the {@link IConstraintDescriptor}s that are members of me as an
166
	 *     unmodifiable set
168
	 *     unmodifiable set
167
	 */
169
	 */
168
	public Set getConstraints() {
170
	public Set<IConstraintDescriptor> getConstraints() {
169
		return Collections.unmodifiableSet(constraints);
171
		return Collections.unmodifiableSet(constraints);
170
	}
172
	}
171
	
173
	
Lines 225-233 Link Here
225
	 * @return an unmodifiable set of the {@link Category}s that are
227
	 * @return an unmodifiable set of the {@link Category}s that are
226
	 *     my children, sorted by {@link #getName name}.  May be an empty set
228
	 *     my children, sorted by {@link #getName name}.  May be an empty set
227
	 */
229
	 */
228
	public SortedSet getChildren() {
230
	public SortedSet<Category> getChildren() {
229
		return Collections.unmodifiableSortedSet(
231
		return Collections.unmodifiableSortedSet(
230
				new java.util.TreeSet(children.values()));
232
				new java.util.TreeSet<Category>(children.values()));
231
	}
233
	}
232
	
234
	
233
	/**
235
	/**
Lines 238-244 Link Here
238
	 * @return the matching category, or <code>null</code> if not found
240
	 * @return the matching category, or <code>null</code> if not found
239
	 */
241
	 */
240
	public Category getChild(String childId) {
242
	public Category getChild(String childId) {
241
		return (Category)children.get(childId);
243
		return children.get(childId);
242
	}
244
	}
243
	
245
	
244
	/**
246
	/**
Lines 363-373 Link Here
363
	}
365
	}
364
	
366
	
365
	// redefines the inherited method
367
	// redefines the inherited method
368
	@Override
366
	public int hashCode() {
369
	public int hashCode() {
367
		return getPath().hashCode();
370
		return getPath().hashCode();
368
	}
371
	}
369
	
372
	
370
	// redefines the inherited method
373
	// redefines the inherited method
374
	@Override
371
	public boolean equals(Object other) {
375
	public boolean equals(Object other) {
372
		return (other instanceof Category)
376
		return (other instanceof Category)
373
			&& ((Category)other).getPath().equals(getPath());
377
			&& ((Category)other).getPath().equals(getPath());
Lines 382-391 Link Here
382
	}
386
	}
383
	
387
	
384
	// implements the interface method
388
	// implements the interface method
385
	public int compareTo(Object o) {
389
	public int compareTo(Category other) {
386
		// this will throw if o has the wrong type.  That's expected
387
		Category other = (Category)o;
388
389
		Collator aCollator = getCollator();
390
		Collator aCollator = getCollator();
390
		
391
		
391
		int result = aCollator.compare(getName(), other.getName());
392
		int result = aCollator.compare(getName(), other.getName());
Lines 400-405 Link Here
400
	}
401
	}
401
	
402
	
402
	// redefines the inherited method
403
	// redefines the inherited method
404
	@Override
403
	public String toString() {
405
	public String toString() {
404
		StringBuffer result = new StringBuffer(32);
406
		StringBuffer result = new StringBuffer(32);
405
		
407
		
Lines 418-431 Link Here
418
	 * 
420
	 * 
419
	 * @param collection the collection of mandatory categories to which I append
421
	 * @param collection the collection of mandatory categories to which I append
420
	 */
422
	 */
421
	void getMandatoryCategories(Collection collection) {
423
	void getMandatoryCategories(Collection<? super Category> collection) {
422
		if (isMandatory()) {
424
		if (isMandatory()) {
423
			collection.add(this);
425
			collection.add(this);
424
		}
426
		}
425
		
427
		
426
		for (Iterator iter = getChildren().iterator(); iter.hasNext(); ) {
428
		for (Category next : getChildren()) {
427
			Category next = (Category)iter.next();
428
			
429
			next.getMandatoryCategories(collection);
429
			next.getMandatoryCategories(collection);
430
		}
430
		}
431
	}
431
	}
(-)src/org/eclipse/emf/validation/model/ConstraintStatus.java (-29 / +30 lines)
Lines 60-66 Link Here
60
	private final IModelConstraint constraint;
60
	private final IModelConstraint constraint;
61
	private EObject target;
61
	private EObject target;
62
	
62
	
63
	private Set resultLocus;
63
	private Set<EObject> resultLocus;
64
64
65
	/**
65
	/**
66
	 * Initializes me as a failure of the specified <code>constraint</code>
66
	 * Initializes me as a failure of the specified <code>constraint</code>
Lines 76-82 Link Here
76
	public ConstraintStatus(IModelConstraint constraint,
76
	public ConstraintStatus(IModelConstraint constraint,
77
							EObject target,
77
							EObject target,
78
							String message,
78
							String message,
79
							Set resultLocus) {
79
							Set<? extends EObject> resultLocus) {
80
		this(
80
		this(
81
			constraint,
81
			constraint,
82
			target,
82
			target,
Lines 123-129 Link Here
123
							int severity,
123
							int severity,
124
							int code,
124
							int code,
125
							String message,
125
							String message,
126
							Set resultLocus) {
126
							Set<? extends EObject> resultLocus) {
127
		super(severity, constraint.getDescriptor().getPluginId(), code, message, null);
127
		super(severity, constraint.getDescriptor().getPluginId(), code, message, null);
128
		
128
		
129
		assert constraint != null;
129
		assert constraint != null;
Lines 135-142 Link Here
135
		
135
		
136
		// unmodifiable defensive copy
136
		// unmodifiable defensive copy
137
		this.resultLocus = (resultLocus != null)
137
		this.resultLocus = (resultLocus != null)
138
			? Collections.unmodifiableSet(new java.util.HashSet(resultLocus))
138
			? Collections.unmodifiableSet(new java.util.HashSet<EObject>(resultLocus))
139
			: Collections.EMPTY_SET;
139
			: Collections.<EObject>emptySet();
140
	}
140
	}
141
	
141
	
142
	/**
142
	/**
Lines 174-182 Link Here
174
	public static ConstraintStatus createStatus(
174
	public static ConstraintStatus createStatus(
175
			IValidationContext ctx,
175
			IValidationContext ctx,
176
			EObject target,
176
			EObject target,
177
			Collection resultLocus,
177
			Collection<? extends EObject> resultLocus,
178
			String messagePattern,
178
			String messagePattern,
179
			Object[] messageArguments) {
179
			Object... messageArguments) {
180
		
180
		
181
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
181
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
182
				ctx.getCurrentConstraintId());
182
				ctx.getCurrentConstraintId());
Lines 224-248 Link Here
224
	public static ConstraintStatus createStatus(
224
	public static ConstraintStatus createStatus(
225
			IValidationContext ctx,
225
			IValidationContext ctx,
226
			EObject target,
226
			EObject target,
227
			Collection resultLocus,
227
			Collection<? extends EObject> resultLocus,
228
			int severity,
228
			int severity,
229
			int errorCode,
229
			int errorCode,
230
			String messagePattern,
230
			String messagePattern,
231
			Object[] messageArguments) {
231
			Object... messageArguments) {
232
		
232
		
233
		// need a prototype status to get certain critical information, such
233
		// need a prototype status to get certain critical information, such
234
		//    as the constraint object and target
234
		//    as the constraint object and target
235
		ConstraintStatus result = (ConstraintStatus) ctx.createFailureStatus(null);
235
		ConstraintStatus result = (ConstraintStatus) ctx.createFailureStatus();
236
		
236
		
237
		if (target != null) {
237
		if (target != null) {
238
			result.target = target;
238
			result.target = target;
239
		}
239
		}
240
		
240
		
241
		Set results;
241
		Set<EObject> results;
242
		if (resultLocus == null) {
242
		if (resultLocus == null) {
243
			results = Collections.singleton(result.getTarget());
243
			results = Collections.singleton(result.getTarget());
244
		} else {
244
		} else {
245
			results = new java.util.HashSet(resultLocus);
245
			results = new java.util.HashSet<EObject>(resultLocus);
246
			if (!results.contains(result.getTarget())) {
246
			if (!results.contains(result.getTarget())) {
247
				results.add(result.getTarget());
247
				results.add(result.getTarget());
248
			}
248
			}
Lines 293-301 Link Here
293
	 */
293
	 */
294
	public static ConstraintStatus createStatus(
294
	public static ConstraintStatus createStatus(
295
			IValidationContext ctx,
295
			IValidationContext ctx,
296
			Collection resultLocus,
296
			Collection<? extends EObject> resultLocus,
297
			String messagePattern,
297
			String messagePattern,
298
			Object[] messageArguments) {
298
			Object... messageArguments) {
299
		
299
		
300
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
300
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
301
				ctx.getCurrentConstraintId());
301
				ctx.getCurrentConstraintId());
Lines 341-351 Link Here
341
	 */
341
	 */
342
	public static ConstraintStatus createStatus(
342
	public static ConstraintStatus createStatus(
343
			IValidationContext ctx,
343
			IValidationContext ctx,
344
			Collection resultLocus,
344
			Collection<? extends EObject> resultLocus,
345
			int severity,
345
			int severity,
346
			int errorCode,
346
			int errorCode,
347
			String messagePattern,
347
			String messagePattern,
348
			Object[] messageArguments) {
348
			Object... messageArguments) {
349
		return createStatus(ctx, null, resultLocus,
349
		return createStatus(ctx, null, resultLocus,
350
				severity, errorCode,
350
				severity, errorCode,
351
				messagePattern, messageArguments);
351
				messagePattern, messageArguments);
Lines 382-399 Link Here
382
	public static IStatus createSuccessStatus(
382
	public static IStatus createSuccessStatus(
383
			IValidationContext ctx,
383
			IValidationContext ctx,
384
			EObject target,
384
			EObject target,
385
			Collection resultLocus) {
385
			Collection<? extends EObject> resultLocus) {
386
		IStatus status = ctx.createSuccessStatus();
386
		IStatus status = ctx.createSuccessStatus();
387
387
388
		if (status instanceof IConstraintStatus) {
388
		if (status instanceof IConstraintStatus) {
389
			IConstraintStatus successStatus = (IConstraintStatus)status;
389
			IConstraintStatus successStatus = (IConstraintStatus)status;
390
			ConstraintStatus constraintStatus = new ConstraintStatus(successStatus.getConstraint(), target);
390
			ConstraintStatus constraintStatus = new ConstraintStatus(successStatus.getConstraint(), target);
391
			
391
			
392
			Set results;
392
			Set<EObject> results;
393
			if (resultLocus == null) {
393
			if (resultLocus == null) {
394
				results = Collections.singleton(target);
394
				results = Collections.singleton(target);
395
			} else {
395
			} else {
396
				results = new java.util.HashSet(resultLocus);
396
				results = new java.util.HashSet<EObject>(resultLocus);
397
				if (!results.contains(target)) {
397
				if (!results.contains(target)) {
398
					results.add(target);
398
					results.add(target);
399
				}
399
				}
Lines 430-436 Link Here
430
	 * 
430
	 * 
431
	 * @see #createMultiStatus(IValidationContext, String, Object[], Collection)
431
	 * @see #createMultiStatus(IValidationContext, String, Object[], Collection)
432
	 */
432
	 */
433
	public static IStatus createMultiStatus(IValidationContext ctx, Collection statuses) {
433
	public static IStatus createMultiStatus(IValidationContext ctx,
434
			Collection<? extends IStatus> statuses) {
434
		return createMultiStatus(
435
		return createMultiStatus(
435
				ctx,
436
				ctx,
436
				ValidationMessages.eval_some_fail_WARN_, null,
437
				ValidationMessages.eval_some_fail_WARN_, null,
Lines 470-481 Link Here
470
	public static IStatus createMultiStatus(
471
	public static IStatus createMultiStatus(
471
			IValidationContext ctx,
472
			IValidationContext ctx,
472
			String messagePattern, Object[] messageArguments,
473
			String messagePattern, Object[] messageArguments,
473
			Collection statuses) {
474
			Collection<? extends IStatus> statuses) {
474
		if (statuses == null || statuses.isEmpty()) {
475
		if (statuses == null || statuses.isEmpty()) {
475
			throw new IllegalArgumentException("no statuses to aggregate"); //$NON-NLS-1$
476
			throw new IllegalArgumentException("no statuses to aggregate"); //$NON-NLS-1$
476
		}
477
		}
477
		
478
		
478
		IStatus[] children = (IStatus[]) statuses.toArray(new IStatus[statuses.size()]);
479
		IStatus[] children = statuses.toArray(new IStatus[statuses.size()]);
479
		
480
		
480
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
481
		IConstraintDescriptor desc = ConstraintRegistry.getInstance().getDescriptor(
481
				ctx.getCurrentConstraintId());
482
				ctx.getCurrentConstraintId());
Lines 518-524 Link Here
518
	 *     successful validation, the result is an empty collection.  The result
519
	 *     successful validation, the result is an empty collection.  The result
519
	 *     is never <code>null</code>
520
	 *     is never <code>null</code>
520
	 */
521
	 */
521
	public final Set getResultLocus() {
522
	public final Set<EObject> getResultLocus() {
522
		return resultLocus;
523
		return resultLocus;
523
	}
524
	}
524
	
525
	
Lines 527-542 Link Here
527
			implements IConstraintStatus {
528
			implements IConstraintStatus {
528
		private final IModelConstraint constraint;
529
		private final IModelConstraint constraint;
529
		private final EObject target;
530
		private final EObject target;
530
		private final Set resultLocus;
531
		private final Set<EObject> resultLocus;
531
		
532
		
532
		Multi(String pluginId, int code, IStatus[] children, String message) {
533
		Multi(String pluginId, int code, IStatus[] children, String message) {
533
			super(pluginId, code, children, message, null);
534
			super(pluginId, code, children, message, null);
534
			
535
			
535
			IConstraintStatus prototype = null;
536
			IConstraintStatus prototype = null;
536
			
537
			
537
			for (int i = 0; i < children.length; i++) {
538
			for (IStatus element : children) {
538
				if (children[i] instanceof IConstraintStatus) {
539
				if (element instanceof IConstraintStatus) {
539
					prototype = (IConstraintStatus) children[i];
540
					prototype = (IConstraintStatus) element;
540
					break;
541
					break;
541
				}
542
				}
542
			}
543
			}
Lines 544-550 Link Here
544
			if (prototype == null) {
545
			if (prototype == null) {
545
				constraint = null;
546
				constraint = null;
546
				target = null;
547
				target = null;
547
				resultLocus = Collections.EMPTY_SET;
548
				resultLocus = Collections.emptySet();
548
			} else {
549
			} else {
549
				constraint = prototype.getConstraint();
550
				constraint = prototype.getConstraint();
550
				target = prototype.getTarget();
551
				target = prototype.getTarget();
Lines 560-566 Link Here
560
			return target;
561
			return target;
561
		}
562
		}
562
		
563
		
563
		public Set getResultLocus() {
564
		public Set<EObject> getResultLocus() {
564
			return resultLocus;
565
			return resultLocus;
565
		}
566
		}
566
	}
567
	}
(-)src/org/eclipse/emf/validation/internal/emfadapter/EMFConstraintParser.java (-2 / +3 lines)
Lines 35-40 Link Here
35
 *
35
 *
36
 * @author Christian W. Damus (cdamus)
36
 * @author Christian W. Damus (cdamus)
37
 */
37
 */
38
@SuppressWarnings("deprecation")
38
public class EMFConstraintParser
39
public class EMFConstraintParser
39
		implements IParameterizedConstraintParser, IXmlConstraintParser {
40
		implements IParameterizedConstraintParser, IXmlConstraintParser {
40
	private static final String PARAMETER_CLASS = "class"; //$NON-NLS-1$
41
	private static final String PARAMETER_CLASS = "class"; //$NON-NLS-1$
Lines 48-54 Link Here
48
	private static final String METHOD_NOT_FOUND = ValidationMessages.emfadapter_methodNotFound_WARN_;
49
	private static final String METHOD_NOT_FOUND = ValidationMessages.emfadapter_methodNotFound_WARN_;
49
	
50
	
50
	/** The signature of validation methods in the EMF API. */
51
	/** The signature of validation methods in the EMF API. */
51
	private static final Class[] VALIDATION_METHOD_SIGNATURE = new Class[] {
52
	private static final Class<?>[] VALIDATION_METHOD_SIGNATURE = new Class<?>[] {
52
			DiagnosticChain.class,
53
			DiagnosticChain.class,
53
			java.util.Map.class,
54
			java.util.Map.class,
54
		};
55
		};
Lines 100-106 Link Here
100
		try {
101
		try {
101
			// use the contributing plug-in's class loader to get the interface
102
			// use the contributing plug-in's class loader to get the interface
102
			//    type (in case the plug-in isn't my own)
103
			//    type (in case the plug-in isn't my own)
103
			Class emfInterface = bundle.loadClass(className);
104
			Class<?> emfInterface = bundle.loadClass(className);
104
			
105
			
105
			// get the method, which we know has always the same signature in
106
			// get the method, which we know has always the same signature in
106
			//    the EMF API
107
			//    the EMF API
(-)src/org/eclipse/emf/validation/internal/emfadapter/EMFConstraintAdapter.java (-10 / +10 lines)
Lines 54-60 Link Here
54
	 * since the EMF APIs have no access to it and there is nothing else in
54
	 * since the EMF APIs have no access to it and there is nothing else in
55
	 * this adapter layer maintains a reference to it.
55
	 * this adapter layer maintains a reference to it.
56
	 */
56
	 */
57
	private static final Map contextMapCache = new java.util.WeakHashMap();
57
	private static final Map<IValidationContext, Map<Object, Object>> contextMapCache =
58
		new java.util.WeakHashMap<IValidationContext, Map<Object,Object>>();
58
	
59
	
59
	private final IConstraintDescriptor descriptor;
60
	private final IConstraintDescriptor descriptor;
60
	private final Method validationMethod;
61
	private final Method validationMethod;
Lines 88-94 Link Here
88
			(EMFValidationContextAdapter)validationArgs[0];
89
			(EMFValidationContextAdapter)validationArgs[0];
89
		
90
		
90
		ctxAdapter.setAdaptedContext(ctx);
91
		ctxAdapter.setAdaptedContext(ctx);
91
		validationArgs[1] = getEmfContextFor(ctx);
92
		validationArgs[1] = getEMFContextFor(ctx);
92
		
93
		
93
		try {
94
		try {
94
			boolean success = ((Boolean)validationMethod.invoke(
95
			boolean success = ((Boolean)validationMethod.invoke(
Lines 131-137 Link Here
131
	private IStatus fail(EMFValidationContextAdapter ctxAdapter) {
132
	private IStatus fail(EMFValidationContextAdapter ctxAdapter) {
132
		final IValidationContext ctx = ctxAdapter.getAdaptedContext();
133
		final IValidationContext ctx = ctxAdapter.getAdaptedContext();
133
		
134
		
134
		List resultLocus = new java.util.ArrayList(ctx.getResultLocus());
135
		List<EObject> resultLocus = new java.util.ArrayList<EObject>(ctx.getResultLocus());
135
		resultLocus.remove(ctx.getTarget());
136
		resultLocus.remove(ctx.getTarget());
136
		
137
		
137
		Diagnostic status = ctxAdapter.getLastStatus();
138
		Diagnostic status = ctxAdapter.getLastStatus();
Lines 142-150 Link Here
142
		//   1 - the result locus minus the target(as a collection of
143
		//   1 - the result locus minus the target(as a collection of
143
		//       model elements)
144
		//       model elements)
144
		return ctx.createFailureStatus(
145
		return ctx.createFailureStatus(
145
			new Object[] {
146
				(status == null) ? null : status.getMessage(),
146
				(status == null) ? null : status.getMessage(),
147
				resultLocus});
147
				resultLocus);
148
	}
148
	}
149
	
149
	
150
	/**
150
	/**
Lines 164-171 Link Here
164
			getDescriptor().getStatusCode(),
164
			getDescriptor().getStatusCode(),
165
			EMFModelValidationPlugin.getMessage(
165
			EMFModelValidationPlugin.getMessage(
166
				ValidationMessages.emfadapter_disabled_WARN_,
166
				ValidationMessages.emfadapter_disabled_WARN_,
167
				new Object[] {getDescriptor().getName()}),
167
				getDescriptor().getName()),
168
			Collections.EMPTY_SET);
168
			Collections.<EObject>emptySet());
169
		
169
		
170
		EMFModelValidationPlugin.getPlugin().getLog().log(
170
		EMFModelValidationPlugin.getPlugin().getLog().log(
171
			new Status(
171
			new Status(
Lines 185-195 Link Here
185
	 * @param ctx our validation context
185
	 * @param ctx our validation context
186
	 * @return the corresponding EMF validation context
186
	 * @return the corresponding EMF validation context
187
	 */
187
	 */
188
	private static Map getEmfContextFor(IValidationContext ctx) {
188
	private static Map<Object, Object> getEMFContextFor(IValidationContext ctx) {
189
		Map result = (Map) contextMapCache.get(ctx);
189
		Map<Object, Object> result = contextMapCache.get(ctx);
190
		
190
		
191
		if (result == null) {
191
		if (result == null) {
192
			result = new java.util.HashMap();
192
			result = new java.util.HashMap<Object, Object>();
193
			
193
			
194
			// add a substitution label provider for good measure
194
			// add a substitution label provider for good measure
195
			result.put(
195
			result.put(
(-)src/org/eclipse/emf/validation/internal/emfadapter/EMFValidationContextAdapter.java (-5 / +3 lines)
Lines 12-18 Link Here
12
12
13
package org.eclipse.emf.validation.internal.emfadapter;
13
package org.eclipse.emf.validation.internal.emfadapter;
14
14
15
import java.util.Iterator;
16
import java.util.List;
15
import java.util.List;
17
16
18
import org.eclipse.emf.common.util.BasicDiagnostic;
17
import org.eclipse.emf.common.util.BasicDiagnostic;
Lines 49-64 Link Here
49
	/* (non-Javadoc)
48
	/* (non-Javadoc)
50
	 * Redefines the inherited method
49
	 * Redefines the inherited method
51
	 */
50
	 */
51
	@Override
52
	public void add(Diagnostic diagnostic) {
52
	public void add(Diagnostic diagnostic) {
53
		if (diagnostic.getSeverity() != Diagnostic.OK) {
53
		if (diagnostic.getSeverity() != Diagnostic.OK) {
54
			List ddata = diagnostic.getData();
54
			List<?> ddata = diagnostic.getData();
55
			
55
			
56
			if (ddata != null) {
56
			if (ddata != null) {
57
				// add any EObjects that we find to our results
57
				// add any EObjects that we find to our results
58
				
58
				
59
				for (Iterator iter = ddata.iterator(); iter.hasNext();) {
59
				for (Object next : ddata) {
60
					Object next = iter.next();
61
					
62
					if (next instanceof EObject) {
60
					if (next instanceof EObject) {
63
						adaptedContext.addResult((EObject) next);
61
						adaptedContext.addResult((EObject) next);
64
					}
62
					}
(-)src/org/eclipse/emf/validation/AbstractModelConstraint.java (-2 / +2 lines)
Lines 54-60 Link Here
54
	 * <p>
54
	 * <p>
55
	 * <b>Note</b> that it is best to use the
55
	 * <b>Note</b> that it is best to use the
56
	 * {@link IValidationContext#createSuccessStatus()} and
56
	 * {@link IValidationContext#createSuccessStatus()} and
57
	 * {@link IValidationContext#createFailureStatus(Object[])} methods of the context
57
	 * {@link IValidationContext#createFailureStatus(Object...)} methods of the context
58
	 * object to create the status object returned from this method, to ensure
58
	 * object to create the status object returned from this method, to ensure
59
	 * that the status object returned is correctly handled by the validation
59
	 * that the status object returned is correctly handled by the validation
60
	 * system.
60
	 * system.
Lines 110-116 Link Here
110
	 *         Must not return <code>null</code>
110
	 *         Must not return <code>null</code>
111
	 *         
111
	 *         
112
	 * @see IValidationContext#createSuccessStatus()
112
	 * @see IValidationContext#createSuccessStatus()
113
	 * @see IValidationContext#createFailureStatus(Object[])
113
	 * @see IValidationContext#createFailureStatus(Object...)
114
	 * @see ConstraintStatus#createStatus(IValidationContext, java.util.Collection, String, Object[])
114
	 * @see ConstraintStatus#createStatus(IValidationContext, java.util.Collection, String, Object[])
115
	 * @see ConstraintStatus#createMultiStatus(IValidationContext, Collection)
115
	 * @see ConstraintStatus#createMultiStatus(IValidationContext, Collection)
116
	 */
116
	 */
(-)src/org/eclipse/emf/validation/EMFEventType.java (-12 / +10 lines)
Lines 16-22 Link Here
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.Arrays;
17
import java.util.Arrays;
18
import java.util.Collections;
18
import java.util.Collections;
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
import java.util.Map;
20
import java.util.Map;
22
21
Lines 47-53 Link Here
47
46
48
	private static int nextNotificationTypeCode = 0;
47
	private static int nextNotificationTypeCode = 0;
49
	
48
	
50
    private static final Map nameToInstance = new java.util.HashMap();
49
    private static final Map<String, EMFEventType> nameToInstance =
50
    	new java.util.HashMap<String, EMFEventType>();
51
    
51
    
52
	/**
52
	/**
53
	 * The EMF "Add" event (corresponds to {@link Notification#ADD}).
53
	 * The EMF "Add" event (corresponds to {@link Notification#ADD}).
Lines 142-148 Link Here
142
			-1);
142
			-1);
143
143
144
	/** All of my values. */
144
	/** All of my values. */
145
	private static final List predefinedInstances = Collections.unmodifiableList(
145
	private static final List<EMFEventType> predefinedInstances = Collections.unmodifiableList(
146
			Arrays.asList(new EMFEventType[]{
146
			Arrays.asList(new EMFEventType[]{
147
					ADD,
147
					ADD,
148
					ADD_MANY,
148
					ADD_MANY,
Lines 157-163 Link Here
157
					NULL,
157
					NULL,
158
				}));
158
				}));
159
159
160
	private static final List instances = new ArrayList(predefinedInstances);
160
	private static final List<EMFEventType> instances = new ArrayList<EMFEventType>(
161
			predefinedInstances);
161
	
162
	
162
	private final String name;
163
	private final String name;
163
	private final boolean featureSpecific;
164
	private final boolean featureSpecific;
Lines 224-232 Link Here
224
	public static EMFEventType getInstance(String name) {
225
	public static EMFEventType getInstance(String name) {
225
		EMFEventType result = NULL;
226
		EMFEventType result = NULL;
226
227
227
		for (Iterator iter = instances.iterator(); iter.hasNext(); ) {
228
		for (EMFEventType next : instances) {
228
			EMFEventType next = (EMFEventType)iter.next();
229
230
			if (next.getName().equalsIgnoreCase(name)) {
229
			if (next.getName().equalsIgnoreCase(name)) {
231
				result = next;
230
				result = next;
232
				break;
231
				break;
Lines 247-255 Link Here
247
	public static EMFEventType getInstance(int code) {
246
	public static EMFEventType getInstance(int code) {
248
		EMFEventType result = NULL;
247
		EMFEventType result = NULL;
249
248
250
		for (Iterator iter = instances.iterator(); iter.hasNext(); ) {
249
		for (EMFEventType next : instances) {
251
			EMFEventType next = (EMFEventType)iter.next();
252
253
			if (next.toNotificationType() == code) {
250
			if (next.toNotificationType() == code) {
254
				result = next;
251
				result = next;
255
				break;
252
				break;
Lines 264-270 Link Here
264
	 * 
261
	 * 
265
	 * @return all values
262
	 * @return all values
266
	 */
263
	 */
267
	public static final List getAllInstances() {
264
	public static final List<EMFEventType> getAllInstances() {
268
		return instances;
265
		return instances;
269
	}
266
	}
270
267
Lines 276-282 Link Here
276
	 * 
273
	 * 
277
	 * @return all predefined values
274
	 * @return all predefined values
278
	 */
275
	 */
279
	public static final List getPredefinedInstances() {
276
	public static final List<EMFEventType> getPredefinedInstances() {
280
		return predefinedInstances;
277
		return predefinedInstances;
281
	}
278
	}
282
	
279
	
Lines 337-342 Link Here
337
	}
334
	}
338
335
339
	// re-implements the inherited method
336
	// re-implements the inherited method
337
	@Override
340
	public String toString() {
338
	public String toString() {
341
		return getName();
339
		return getName();
342
	}
340
	}
(-)src/org/eclipse/emf/validation/IValidationContext.java (-7 / +8 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
import java.util.Set;
17
import java.util.Set;
18
18
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.EObject;
21
import org.eclipse.emf.ecore.EStructuralFeature;
22
import org.eclipse.emf.ecore.EStructuralFeature;
22
import org.eclipse.emf.validation.model.ConstraintStatus;
23
import org.eclipse.emf.validation.model.ConstraintStatus;
Lines 90-96 Link Here
90
	 * @return the raw {@link org.eclipse.emf.common.notify.Notification}s being validated, or an empty
91
	 * @return the raw {@link org.eclipse.emf.common.notify.Notification}s being validated, or an empty
91
	 *    list if this is a batch validation.  This list is not modifiable
92
	 *    list if this is a batch validation.  This list is not modifiable
92
	 */
93
	 */
93
	List getAllEvents();
94
	List<Notification> getAllEvents();
94
	
95
	
95
	/**
96
	/**
96
	 * In the case of a live constraint evaluation, obtains the particular
97
	 * In the case of a live constraint evaluation, obtains the particular
Lines 174-180 Link Here
174
	 * 
175
	 * 
175
	 * @see #skipCurrentConstraintFor(EObject)
176
	 * @see #skipCurrentConstraintFor(EObject)
176
	 */
177
	 */
177
	void skipCurrentConstraintForAll(Collection eObjects);
178
	void skipCurrentConstraintForAll(Collection<?> eObjects);
178
	
179
	
179
	/**
180
	/**
180
	 * <p>
181
	 * <p>
Lines 234-240 Link Here
234
	 * 
235
	 * 
235
	 * @see #addResult(EObject)
236
	 * @see #addResult(EObject)
236
	 */
237
	 */
237
	Set getResultLocus();
238
	Set<EObject> getResultLocus();
238
	
239
	
239
	/**
240
	/**
240
	 * Adds a result to the result locus of the current constraint.  The result
241
	 * Adds a result to the result locus of the current constraint.  The result
Lines 257-263 Link Here
257
	 * 
258
	 * 
258
	 * @see #addResult(EObject)
259
	 * @see #addResult(EObject)
259
	 */
260
	 */
260
	void addResults(Collection eObjects);
261
	void addResults(Collection<? extends EObject> eObjects);
261
	
262
	
262
	/**
263
	/**
263
	 * Creates a status object indicating successful evaluation of the
264
	 * Creates a status object indicating successful evaluation of the
Lines 273-282 Link Here
273
	 * the severity, error code, and message defined in the constraint meta-data
274
	 * the severity, error code, and message defined in the constraint meta-data
274
	 * in the XML.
275
	 * in the XML.
275
	 * 
276
	 * 
276
	 * @param messageArguments the positional {0}, {1}, etc. arguments to
277
	 * @param messageArgument the positional {0}, {1}, etc. arguments to
277
	 *      replace in the message pattern (may by <code>null</code> if none
278
	 *      replace in the message pattern (may by <code>null</code> if none
278
	 *      are needed)
279
	 *      are needed)
279
	 * @return the status indicating a constraint violation
280
	 * @return the status indicating a constraint violation
280
	 */
281
	 */
281
	IStatus createFailureStatus(Object[] messageArguments);
282
	IStatus createFailureStatus(Object... messageArgument);
282
}
283
}
(-)build.properties (-2 / +2 lines)
Lines 29-33 Link Here
29
jars.compile.order = .
29
jars.compile.order = .
30
source.. = src/
30
source.. = src/
31
output.. = bin/
31
output.. = bin/
32
javacSource = 1.4
32
javacSource = 1.5
33
javacTarget = 1.4
33
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/validation/marker/MarkerUtil.java (-6 / +7 lines)
Lines 91-103 Link Here
91
			public void run(IProgressMonitor m)
91
			public void run(IProgressMonitor m)
92
				throws CoreException {
92
				throws CoreException {
93
				
93
				
94
				final Map visitedResources = new HashMap();
94
				final Map<URI, IFile> visitedResources = new HashMap<URI, IFile>();
95
				
95
				
96
				if (validationStatus.isMultiStatus()) {
96
				if (validationStatus.isMultiStatus()) {
97
					IStatus[] children = validationStatus.getChildren();
97
					IStatus[] children = validationStatus.getChildren();
98
					for (int i=0; i<children.length ;i++) {
98
					for (IStatus element : children) {
99
						if (children[i] instanceof IConstraintStatus) {
99
						if (element instanceof IConstraintStatus) {
100
							createMarker((IConstraintStatus)children[i], markerType, configurator, visitedResources);
100
							createMarker((IConstraintStatus)element, markerType, configurator, visitedResources);
101
						}
101
						}
102
					}
102
					}
103
				} else if (validationStatus instanceof IConstraintStatus) {
103
				} else if (validationStatus instanceof IConstraintStatus) {
Lines 110-116 Link Here
110
	}
110
	}
111
111
112
	private static void createMarker(IConstraintStatus status,
112
	private static void createMarker(IConstraintStatus status,
113
			String markerType, IMarkerConfigurator configurator, Map visitedResources) throws CoreException {
113
			String markerType, IMarkerConfigurator configurator,
114
			Map<URI, IFile> visitedResources) throws CoreException {
114
115
115
		Resource r = status.getTarget().eResource();
116
		Resource r = status.getTarget().eResource();
116
		URI uri = r.getURI();
117
		URI uri = r.getURI();
Lines 118-124 Link Here
118
		// Normalize the URI to something that we can deal with like file or platform scheme
119
		// Normalize the URI to something that we can deal with like file or platform scheme
119
		uri = r.getResourceSet().getURIConverter().normalize(uri);
120
		uri = r.getResourceSet().getURIConverter().normalize(uri);
120
121
121
		IFile file = (IFile)visitedResources.get(uri);
122
		IFile file = visitedResources.get(uri);
122
		
123
		
123
		if (file == null) {
124
		if (file == null) {
124
			if (PLATFORM_SCHEME.equals(uri.scheme()) && uri.segmentCount() > 1
125
			if (PLATFORM_SCHEME.equals(uri.scheme()) && uri.segmentCount() > 1
(-)src/org/eclipse/emf/validation/internal/EMFModelValidationPlugin.java (-19 / +21 lines)
Lines 181-186 Link Here
181
	}
181
	}
182
182
183
	// implements the inherited method
183
	// implements the inherited method
184
	@Override
184
	public ResourceLocator getPluginResourceLocator() {
185
	public ResourceLocator getPluginResourceLocator() {
185
		return plugin;
186
		return plugin;
186
	}
187
	}
Lines 221-226 Link Here
221
		}
222
		}
222
223
223
		// extends the inherited method
224
		// extends the inherited method
225
		@Override
224
		public void start(BundleContext context) throws Exception {
226
		public void start(BundleContext context) throws Exception {
225
			super.start(context);
227
			super.start(context);
226
228
Lines 289-295 Link Here
289
    	/**
291
    	/**
290
    	 * The cached debug options (for optimization).
292
    	 * The cached debug options (for optimization).
291
    	 */
293
    	 */
292
    	private static final Map cachedOptions = new HashMap();
294
    	private static final Map<String, Boolean> cachedOptions = new HashMap<String, Boolean>();
293
295
294
    	/**
296
    	/**
295
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
297
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 314-320 Link Here
314
    			Boolean value = null;
316
    			Boolean value = null;
315
    			
317
    			
316
    			synchronized (cachedOptions) {
318
    			synchronized (cachedOptions) {
317
    				value = (Boolean) cachedOptions.get(option);
319
    				value = cachedOptions.get(option);
318
    	
320
    	
319
    				if (null == value) {
321
    				if (null == value) {
320
    					value =
322
    					value =
Lines 431-437 Link Here
431
    	 */
433
    	 */
432
    	public static void changing(
434
    	public static void changing(
433
            String option,
435
            String option,
434
            Class clazz,
436
            Class<?> clazz,
435
            String methodName,
437
            String methodName,
436
            String valueDescription,
438
            String valueDescription,
437
            Object oldValue,
439
            Object oldValue,
Lines 470-476 Link Here
470
    	 */
472
    	 */
471
    	public static void catching(
473
    	public static void catching(
472
    		String option,
474
    		String option,
473
    		Class clazz,
475
    		Class<?> clazz,
474
    		String methodName,
476
    		String methodName,
475
    		Throwable throwable) {
477
    		Throwable throwable) {
476
478
Lines 503-509 Link Here
503
    	 */
505
    	 */
504
    	public static void throwing(
506
    	public static void throwing(
505
    		String option,
507
    		String option,
506
    		Class clazz,
508
    		Class<?> clazz,
507
    		String methodName,
509
    		String methodName,
508
    		Throwable throwable) {
510
    		Throwable throwable) {
509
511
Lines 533-539 Link Here
533
    	 */
535
    	 */
534
    	public static void entering(
536
    	public static void entering(
535
    		String option,
537
    		String option,
536
    		Class clazz,
538
    		Class<?> clazz,
537
    		String methodName) {
539
    		String methodName) {
538
540
539
    		if (shouldTrace(option)) {
541
    		if (shouldTrace(option)) {
Lines 558-564 Link Here
558
    	 */
560
    	 */
559
    	public static void entering(
561
    	public static void entering(
560
    		String option,
562
    		String option,
561
    		Class clazz,
563
    		Class<?> clazz,
562
    		String methodName,
564
    		String methodName,
563
    		Object parameter) {
565
    		Object parameter) {
564
566
Lines 587-593 Link Here
587
    	 */
589
    	 */
588
    	public static void entering(
590
    	public static void entering(
589
    		String option,
591
    		String option,
590
    		Class clazz,
592
    		Class<?> clazz,
591
    		String methodName,
593
    		String methodName,
592
    		Object[] parameters) {
594
    		Object[] parameters) {
593
595
Lines 614-620 Link Here
614
    	 */
616
    	 */
615
    	public static void exiting(
617
    	public static void exiting(
616
    		String option,
618
    		String option,
617
    		Class clazz,
619
    		Class<?> clazz,
618
    		String methodName) {
620
    		String methodName) {
619
621
620
    		if (shouldTrace(option)) {
622
    		if (shouldTrace(option)) {
Lines 639-645 Link Here
639
    	 */
641
    	 */
640
    	public static void exiting(
642
    	public static void exiting(
641
    		String option,
643
    		String option,
642
    		Class clazz,
644
    		Class<?> clazz,
643
    		String methodName,
645
    		String methodName,
644
    		Object returnValue) {
646
    		Object returnValue) {
645
647
Lines 656-666 Link Here
656
    	}
658
    	}
657
    }
659
    }
658
660
659
	public static void catching(Class class1, String functionName, Throwable exception) {
661
	public static void catching(Class<?> class1, String functionName, Throwable exception) {
660
		Tracing.catching(EMFModelValidationDebugOptions.EXCEPTIONS_CATCHING, class1, functionName, exception);
662
		Tracing.catching(EMFModelValidationDebugOptions.EXCEPTIONS_CATCHING, class1, functionName, exception);
661
	}
663
	}
662
	
664
	
663
	public static void throwing(Class class1, String functionName, Throwable exception) {
665
	public static void throwing(Class<?> class1, String functionName, Throwable exception) {
664
		Tracing.throwing(EMFModelValidationDebugOptions.EXCEPTIONS_THROWING, class1, functionName, exception);
666
		Tracing.throwing(EMFModelValidationDebugOptions.EXCEPTIONS_THROWING, class1, functionName, exception);
665
	}
667
	}
666
668
Lines 688-694 Link Here
688
	 * 
690
	 * 
689
	 * @see org.eclipse.osgi.util.NLS
691
	 * @see org.eclipse.osgi.util.NLS
690
	 */
692
	 */
691
	public static String getMessage(String messagePattern, Object[] args) {
693
	public static String getMessage(String messagePattern, Object... args) {
692
		return formatMessage(messagePattern, args);
694
		return formatMessage(messagePattern, args);
693
	}
695
	}
694
	
696
	
Lines 703-709 Link Here
703
	 * 
705
	 * 
704
	 * @see org.eclipse.osgi.util.NLS
706
	 * @see org.eclipse.osgi.util.NLS
705
	 */
707
	 */
706
	private static String formatMessage(String messagePattern, Object[] args) {
708
	private static String formatMessage(String messagePattern, Object... args) {
707
		try {
709
		try {
708
			return NLS.bind(messagePattern, args);
710
			return NLS.bind(messagePattern, args);
709
		} catch (Exception e) {
711
		} catch (Exception e) {
Lines 733-739 Link Here
733
	 * @return the list, <code>strings[0]</code> if there is only one element,
735
	 * @return the list, <code>strings[0]</code> if there is only one element,
734
	 *    or <code>""</code> if the array has no elements
736
	 *    or <code>""</code> if the array has no elements
735
	 */
737
	 */
736
	public static String formatList(Collection items) {
738
	public static String formatList(Collection<?> items) {
737
		switch (items.size()) {
739
		switch (items.size()) {
738
			case 0 :
740
			case 0 :
739
				return ""; //$NON-NLS-1$
741
				return ""; //$NON-NLS-1$
Lines 756-763 Link Here
756
	 * 
758
	 * 
757
	 * @see #formatList(Collection)
759
	 * @see #formatList(Collection)
758
	 */
760
	 */
759
	private static String formatList2(Collection items) {
761
	private static String formatList2(Collection<?> items) {
760
		Iterator iter = items.iterator();
762
		Iterator<?> iter = items.iterator();
761
		int max = items.size() - 1;
763
		int max = items.size() - 1;
762
764
763
		final String sep = getString(
765
		final String sep = getString(
Lines 800-807 Link Here
800
	 * 
802
	 * 
801
	 * @see #formatList(Collection)
803
	 * @see #formatList(Collection)
802
	 */
804
	 */
803
	private static String formatPair(Collection items) {
805
	private static String formatPair(Collection<?> items) {
804
		Iterator iter = items.iterator();
806
		Iterator<?> iter = items.iterator();
805
807
806
		StringBuffer result = new StringBuffer(32);
808
		StringBuffer result = new StringBuffer(32);
807
809
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 25-28 Link Here
25
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)",
25
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)",
26
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)"
26
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)"
27
Eclipse-LazyStart: true
27
Eclipse-LazyStart: true
28
Bundle-RequiredExecutionEnvironment: J2SE-1.4
28
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)src/org/eclipse/emf/validation/xml/AbstractXmlConstraintDescriptor.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-37 Link Here
32
 * 
32
 * 
33
 * @author Chris McGee (cmcgee)
33
 * @author Chris McGee (cmcgee)
34
 */
34
 */
35
@SuppressWarnings("deprecation")
35
public abstract class AbstractXmlConstraintDescriptor
36
public abstract class AbstractXmlConstraintDescriptor
36
	extends AbstractConstraintDescriptor
37
	extends AbstractConstraintDescriptor
37
	implements IXmlConstraintDescriptor {
38
	implements IXmlConstraintDescriptor {
(-)src/org/eclipse/emf/validation/xml/XmlConstraintProvider.java (-4 / +6 lines)
Lines 85-90 Link Here
85
	 * @throws CoreException if the superclass implementation of this
85
	 * @throws CoreException if the superclass implementation of this
86
	 *    method throws or on an error in accessing the <code>config</code>
86
	 *    method throws or on an error in accessing the <code>config</code>
87
	 */
87
	 */
88
	@Override
88
	public void setInitializationData(
89
	public void setInitializationData(
89
			IConfigurationElement config,
90
			IConfigurationElement config,
90
			String propertyName,
91
			String propertyName,
Lines 95-108 Link Here
95
		IConfigurationElement[] constraintses = config.getChildren(
96
		IConfigurationElement[] constraintses = config.getChildren(
96
				XmlConfig.E_CONSTRAINTS);
97
				XmlConfig.E_CONSTRAINTS);
97
		
98
		
98
		for (int i = 0; i < constraintses.length; i++) {
99
		for (IConfigurationElement element : constraintses) {
99
			IConfigurationElement next =
100
			IConfigurationElement next =
100
				XmlConfig.parseConstraintsWithIncludes(constraintses[i]);
101
				XmlConfig.parseConstraintsWithIncludes(element);
101
			
102
			
102
			IConfigurationElement[] configs = next.getChildren();
103
			IConfigurationElement[] configs = next.getChildren();
103
104
104
			for (int j = 0; j < configs.length; j++) {
105
			for (IConfigurationElement element2 : configs) {
105
				addConstraint(configs[j]);
106
				addConstraint(element2);
106
			}
107
			}
107
		}
108
		}
108
		
109
		
Lines 115-120 Link Here
115
	 * 
116
	 * 
116
	 * @param config the <TT>&lt;constraint&gt;</TT> element
117
	 * @param config the <TT>&lt;constraint&gt;</TT> element
117
	 */
118
	 */
119
	@SuppressWarnings("deprecation")
118
	private void addConstraint(IConfigurationElement config) {
120
	private void addConstraint(IConfigurationElement config) {
119
		final String contributorId = config
121
		final String contributorId = config
120
			.getDeclaringExtension()
122
			.getDeclaringExtension()
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:44:32 EST 2006
1
#Thu Nov 08 18:54:38 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 21-25 Link Here
21
src.includes = plugin.xml,\
21
src.includes = plugin.xml,\
22
               plugin.properties,\
22
               plugin.properties,\
23
               about.html
23
               about.html
24
javacSource = 1.4
24
javacSource = 1.5
25
javacTarget = 1.4
25
javacTarget = 1.5
(-)META-INF/MANIFEST.MF (-4 / +4 lines)
Lines 2-19 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.ui.ide; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.ui.ide; singleton:=true
5
Bundle-Version: 1.0.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.ui.ide.internal.ValidationUIIDEPlugin$Implementation
6
Bundle-Activator: org.eclipse.emf.validation.ui.ide.internal.ValidationUIIDEPlugin$Implementation
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.emf.validation.ui.ide.internal;x-internal:=true,
9
Export-Package: org.eclipse.emf.validation.ui.ide.internal;x-internal:=true,
10
 org.eclipse.emf.validation.ui.ide.internal.l10n;x-internal:=true,
10
 org.eclipse.emf.validation.ui.ide.internal.l10n;x-internal:=true,
11
 org.eclipse.emf.validation.ui.ide.quickfix
11
 org.eclipse.emf.validation.ui.ide.quickfix
12
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)",
12
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)",
13
 org.eclipse.emf.validation.ui;bundle-version="[1.0.0,2.0.0)";visibility:=reexport,
13
 org.eclipse.emf.validation.ui;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
14
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
14
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
17
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)"
17
 org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)"
18
Eclipse-LazyStart: true
18
Eclipse-LazyStart: true
19
Bundle-RequiredExecutionEnvironment: J2SE-1.4
19
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:49:40 EST 2006
1
#Thu Nov 08 19:08:49 EST 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/validation/ui/ide/quickfix/ValidationMarkerResolution.java (-2 / +2 lines)
Lines 88-97 Link Here
88
		if (result) {
88
		if (result) {
89
			// see whether this constraint is in any mandatory category
89
			// see whether this constraint is in any mandatory category
90
			
90
			
91
			for (Iterator iter = constraint.getCategories().iterator();
91
			for (Iterator<Category> iter = constraint.getCategories().iterator();
92
					result && iter.hasNext();) {
92
					result && iter.hasNext();) {
93
				
93
				
94
				result = !((Category) iter.next()).isMandatory();
94
				result = !iter.next().isMandatory();
95
			}
95
			}
96
		}
96
		}
97
		
97
		
(-)src/org/eclipse/emf/validation/ui/ide/internal/ValidationUIIDEPlugin.java (-11 / +13 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 128-133 Link Here
128
        super(new ResourceLocator[] {});
128
        super(new ResourceLocator[] {});
129
    }
129
    }
130
130
131
    @Override
131
    public ResourceLocator getPluginResourceLocator() {
132
    public ResourceLocator getPluginResourceLocator() {
132
        return plugin;
133
        return plugin;
133
    }
134
    }
Lines 160-166 Link Here
160
    	/**
161
    	/**
161
    	 * The cached debug options (for optimization).
162
    	 * The cached debug options (for optimization).
162
    	 */
163
    	 */
163
    	private static final Map cachedOptions = new HashMap();
164
    	private static final Map<String, Boolean> cachedOptions =
165
    	    new HashMap<String, Boolean>();
164
166
165
    	/**
167
    	/**
166
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
168
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 185-191 Link Here
185
    			Boolean value = null;
187
    			Boolean value = null;
186
    			
188
    			
187
    			synchronized (cachedOptions) {
189
    			synchronized (cachedOptions) {
188
    				value = (Boolean) cachedOptions.get(option);
190
    				value = cachedOptions.get(option);
189
    	
191
    	
190
    				if (null == value) {
192
    				if (null == value) {
191
    					value =
193
    					value =
Lines 302-308 Link Here
302
    	 */
304
    	 */
303
    	public static void changing(
305
    	public static void changing(
304
            String option,
306
            String option,
305
            Class clazz,
307
            Class<?> clazz,
306
            String methodName,
308
            String methodName,
307
            String valueDescription,
309
            String valueDescription,
308
            Object oldValue,
310
            Object oldValue,
Lines 341-347 Link Here
341
    	 */
343
    	 */
342
    	public static void catching(
344
    	public static void catching(
343
    		String option,
345
    		String option,
344
    		Class clazz,
346
    		Class<?> clazz,
345
    		String methodName,
347
    		String methodName,
346
    		Throwable throwable) {
348
    		Throwable throwable) {
347
349
Lines 374-380 Link Here
374
    	 */
376
    	 */
375
    	public static void throwing(
377
    	public static void throwing(
376
    		String option,
378
    		String option,
377
    		Class clazz,
379
    		Class<?> clazz,
378
    		String methodName,
380
    		String methodName,
379
    		Throwable throwable) {
381
    		Throwable throwable) {
380
382
Lines 404-410 Link Here
404
    	 */
406
    	 */
405
    	public static void entering(
407
    	public static void entering(
406
    		String option,
408
    		String option,
407
    		Class clazz,
409
    		Class<?> clazz,
408
    		String methodName) {
410
    		String methodName) {
409
411
410
    		if (shouldTrace(option)) {
412
    		if (shouldTrace(option)) {
Lines 429-435 Link Here
429
    	 */
431
    	 */
430
    	public static void entering(
432
    	public static void entering(
431
    		String option,
433
    		String option,
432
    		Class clazz,
434
    		Class<?> clazz,
433
    		String methodName,
435
    		String methodName,
434
    		Object parameter) {
436
    		Object parameter) {
435
437
Lines 458-464 Link Here
458
    	 */
460
    	 */
459
    	public static void entering(
461
    	public static void entering(
460
    		String option,
462
    		String option,
461
    		Class clazz,
463
    		Class<?> clazz,
462
    		String methodName,
464
    		String methodName,
463
    		Object[] parameters) {
465
    		Object[] parameters) {
464
466
Lines 485-491 Link Here
485
    	 */
487
    	 */
486
    	public static void exiting(
488
    	public static void exiting(
487
    		String option,
489
    		String option,
488
    		Class clazz,
490
    		Class<?> clazz,
489
    		String methodName) {
491
    		String methodName) {
490
492
491
    		if (shouldTrace(option)) {
493
    		if (shouldTrace(option)) {
Lines 510-516 Link Here
510
    	 */
512
    	 */
511
    	public static void exiting(
513
    	public static void exiting(
512
    		String option,
514
    		String option,
513
    		Class clazz,
515
    		Class<?> clazz,
514
    		String methodName,
516
    		String methodName,
515
    		Object returnValue) {
517
    		Object returnValue) {
516
518
(-)src/org/eclipse/emf/validation/examples/ocl/OCLConstraintProvider.java (-2 / +2 lines)
Lines 30-35 Link Here
30
import org.eclipse.core.runtime.Status;
30
import org.eclipse.core.runtime.Status;
31
import org.eclipse.emf.validation.model.Category;
31
import org.eclipse.emf.validation.model.Category;
32
import org.eclipse.emf.validation.model.CategoryManager;
32
import org.eclipse.emf.validation.model.CategoryManager;
33
import org.eclipse.emf.validation.model.IModelConstraint;
33
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
34
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
34
import org.eclipse.emf.validation.service.ConstraintExistsException;
35
import org.eclipse.emf.validation.service.ConstraintExistsException;
35
import org.eclipse.ocl.OCLInput;
36
import org.eclipse.ocl.OCLInput;
Lines 136-143 Link Here
136
	}
137
	}
137
	
138
	
138
	private void addConstraint(Category category, String namespace, OCL ocl, Constraint constraint) {
139
	private void addConstraint(Category category, String namespace, OCL ocl, Constraint constraint) {
139
		@SuppressWarnings("unchecked")
140
		Collection<IModelConstraint> constraints = getConstraints();
140
		Collection<OCLConstraint> constraints = getConstraints();
141
		
141
		
142
		OCLConstraintDescriptor desc = new OCLConstraintDescriptor(
142
		OCLConstraintDescriptor desc = new OCLConstraintDescriptor(
143
				namespace, constraint, constraints.size() + 1);
143
				namespace, constraint, constraints.size() + 1);
(-)src/org/eclipse/emf/validation/examples/ocl/OCLConstraintDescriptor.java (-2 / +2 lines)
Lines 61-67 Link Here
61
		return getBody();
61
		return getBody();
62
	}
62
	}
63
63
64
	public EvaluationMode getEvaluationMode() {
64
	public EvaluationMode<?> getEvaluationMode() {
65
		return EvaluationMode.BATCH;
65
		return EvaluationMode.BATCH;
66
	}
66
	}
67
67
Lines 70-76 Link Here
70
	}
70
	}
71
71
72
	public String getMessagePattern() {
72
	public String getMessagePattern() {
73
		return "Constraint " + getName() + " violated on {0}";
73
		return String.format("Constraint %s violated on {0}", getName()); //$NON-NLS-1$
74
	}
74
	}
75
75
76
	public String getName() {
76
	public String getName() {
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 2-14 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.ocl; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.ocl; singleton:=true
5
Bundle-Version: 1.1.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.examples.ocl.OCLValidationExamplePlugin
6
Bundle-Activator: org.eclipse.emf.validation.examples.ocl.OCLValidationExamplePlugin
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.emf.validation.examples.ocl
9
Export-Package: org.eclipse.emf.validation.examples.ocl
10
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
10
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)",
11
 org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)",
12
 org.eclipse.emf.validation.ocl;bundle-version="[1.1.0,2.0.0)",
12
 org.eclipse.emf.validation.ocl;bundle-version="[1.1.0,2.0.0)",
13
 org.eclipse.ocl.ecore;bundle-version="[1.1.0,2.0.0)"
13
 org.eclipse.ocl.ecore;bundle-version="[1.1.0,2.0.0)"
14
Eclipse-LazyStart: true
14
Eclipse-LazyStart: true
(-)src/ordersystem/impl/OrderSystemFactoryImpl.java (-8 / +42 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 19-31 Link Here
19
19
20
import java.util.Date;
20
import java.util.Date;
21
21
22
import ordersystem.*;
22
import ordersystem.Account;
23
import ordersystem.Address;
24
import ordersystem.Customer;
25
import ordersystem.InventoryItem;
26
import ordersystem.LineItem;
27
import ordersystem.Order;
28
import ordersystem.OrderSystem;
29
import ordersystem.OrderSystemFactory;
30
import ordersystem.OrderSystemPackage;
31
import ordersystem.Product;
32
import ordersystem.Warehouse;
23
33
24
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EClass;
25
import org.eclipse.emf.ecore.EDataType;
35
import org.eclipse.emf.ecore.EDataType;
26
import org.eclipse.emf.ecore.EObject;
36
import org.eclipse.emf.ecore.EObject;
27
37
import org.eclipse.emf.ecore.EPackage;
28
import org.eclipse.emf.ecore.impl.EFactoryImpl;
38
import org.eclipse.emf.ecore.impl.EFactoryImpl;
39
import org.eclipse.emf.ecore.plugin.EcorePlugin;
29
40
30
/**
41
/**
31
 * <!-- begin-user-doc -->
42
 * <!-- begin-user-doc -->
Lines 35-41 Link Here
35
 */
46
 */
36
public class OrderSystemFactoryImpl extends EFactoryImpl implements OrderSystemFactory {
47
public class OrderSystemFactoryImpl extends EFactoryImpl implements OrderSystemFactory {
37
	/**
48
	/**
38
	 * Creates and instance of the factory.
49
	 * Creates the default factory implementation.
50
	 * <!-- begin-user-doc -->
51
	 * <!-- end-user-doc -->
52
	 * @generated
53
	 */
54
	public static OrderSystemFactory init() {
55
		try {
56
			OrderSystemFactory theOrderSystemFactory = (OrderSystemFactory)EPackage.Registry.INSTANCE.getEFactory("http:///ordersystem.ecore"); //$NON-NLS-1$ 
57
			if (theOrderSystemFactory != null) {
58
				return theOrderSystemFactory;
59
			}
60
		}
61
		catch (Exception exception) {
62
			EcorePlugin.INSTANCE.log(exception);
63
		}
64
		return new OrderSystemFactoryImpl();
65
	}
66
67
	/**
68
	 * Creates an instance of the factory.
39
	 * <!-- begin-user-doc -->
69
	 * <!-- begin-user-doc -->
40
     * <!-- end-user-doc -->
70
     * <!-- end-user-doc -->
41
	 * @generated
71
	 * @generated
Lines 49-55 Link Here
49
     * <!-- end-user-doc -->
79
     * <!-- end-user-doc -->
50
	 * @generated
80
	 * @generated
51
	 */
81
	 */
52
    public EObject create(EClass eClass) {
82
    @Override
83
				public EObject create(EClass eClass) {
53
		switch (eClass.getClassifierID()) {
84
		switch (eClass.getClassifierID()) {
54
			case OrderSystemPackage.ORDER: return createOrder();
85
			case OrderSystemPackage.ORDER: return createOrder();
55
			case OrderSystemPackage.PRODUCT: return createProduct();
86
			case OrderSystemPackage.PRODUCT: return createProduct();
Lines 70-76 Link Here
70
     * <!-- end-user-doc -->
101
     * <!-- end-user-doc -->
71
	 * @generated
102
	 * @generated
72
	 */
103
	 */
73
    public Object createFromString(EDataType eDataType, String initialValue) {
104
    @Override
105
				public Object createFromString(EDataType eDataType, String initialValue) {
74
		switch (eDataType.getClassifierID()) {
106
		switch (eDataType.getClassifierID()) {
75
			case OrderSystemPackage.JAVA_DATE:
107
			case OrderSystemPackage.JAVA_DATE:
76
				return createJavaDateFromString(eDataType, initialValue);
108
				return createJavaDateFromString(eDataType, initialValue);
Lines 84-90 Link Here
84
     * <!-- end-user-doc -->
116
     * <!-- end-user-doc -->
85
	 * @generated
117
	 * @generated
86
	 */
118
	 */
87
    public String convertToString(EDataType eDataType, Object instanceValue) {
119
    @Override
120
				public String convertToString(EDataType eDataType, Object instanceValue) {
88
		switch (eDataType.getClassifierID()) {
121
		switch (eDataType.getClassifierID()) {
89
			case OrderSystemPackage.JAVA_DATE:
122
			case OrderSystemPackage.JAVA_DATE:
90
				return convertJavaDateToString(eDataType, instanceValue);
123
				return convertJavaDateToString(eDataType, instanceValue);
Lines 222-228 Link Here
222
	 * @deprecated
255
	 * @deprecated
223
	 * @generated
256
	 * @generated
224
	 */
257
	 */
225
    public static OrderSystemPackage getPackage() {
258
    @Deprecated
259
				public static OrderSystemPackage getPackage() {
226
		return OrderSystemPackage.eINSTANCE;
260
		return OrderSystemPackage.eINSTANCE;
227
	}
261
	}
228
} //OrderSystemFactoryImpl
262
} //OrderSystemFactoryImpl
(-)src/ordersystem/impl/OrderSystemImpl.java (-67 / +61 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 27-42 Link Here
27
27
28
import org.eclipse.emf.common.notify.Notification;
28
import org.eclipse.emf.common.notify.Notification;
29
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.NotificationChain;
30
31
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
32
33
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EStructuralFeature;
35
import org.eclipse.emf.ecore.InternalEObject;
32
import org.eclipse.emf.ecore.InternalEObject;
36
37
import org.eclipse.emf.ecore.impl.ENotificationImpl;
33
import org.eclipse.emf.ecore.impl.ENotificationImpl;
38
import org.eclipse.emf.ecore.impl.EObjectImpl;
34
import org.eclipse.emf.ecore.impl.EObjectImpl;
39
40
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
35
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
41
import org.eclipse.emf.ecore.util.InternalEList;
36
import org.eclipse.emf.ecore.util.InternalEList;
42
37
Lines 85-91 Link Here
85
	 * @generated
80
	 * @generated
86
	 * @ordered
81
	 * @ordered
87
	 */
82
	 */
88
    protected EList customer = null;
83
    protected EList<Customer> customer;
89
84
90
	/**
85
	/**
91
	 * The cached value of the '{@link #getProduct() <em>Product</em>}' containment reference list.
86
	 * The cached value of the '{@link #getProduct() <em>Product</em>}' containment reference list.
Lines 95-101 Link Here
95
	 * @generated
90
	 * @generated
96
	 * @ordered
91
	 * @ordered
97
	 */
92
	 */
98
    protected EList product = null;
93
    protected EList<Product> product;
99
94
100
	/**
95
	/**
101
	 * The cached value of the '{@link #getWarehouse() <em>Warehouse</em>}' containment reference list.
96
	 * The cached value of the '{@link #getWarehouse() <em>Warehouse</em>}' containment reference list.
Lines 105-111 Link Here
105
	 * @generated
100
	 * @generated
106
	 * @ordered
101
	 * @ordered
107
	 */
102
	 */
108
    protected EList warehouse = null;
103
    protected EList<Warehouse> warehouse;
109
104
110
	/**
105
	/**
111
	 * <!-- begin-user-doc -->
106
	 * <!-- begin-user-doc -->
Lines 121-128 Link Here
121
     * <!-- end-user-doc -->
116
     * <!-- end-user-doc -->
122
	 * @generated
117
	 * @generated
123
	 */
118
	 */
124
    protected EClass eStaticClass() {
119
    @Override
125
		return OrderSystemPackage.eINSTANCE.getOrderSystem();
120
				protected EClass eStaticClass() {
121
		return OrderSystemPackage.Literals.ORDER_SYSTEM;
126
	}
122
	}
127
123
128
	/**
124
	/**
Lines 151-159 Link Here
151
     * <!-- end-user-doc -->
147
     * <!-- end-user-doc -->
152
	 * @generated
148
	 * @generated
153
	 */
149
	 */
154
    public EList getCustomer() {
150
    public EList<Customer> getCustomer() {
155
		if (customer == null) {
151
		if (customer == null) {
156
			customer = new EObjectContainmentWithInverseEList(Customer.class, this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystemPackage.CUSTOMER__OWNER);
152
			customer = new EObjectContainmentWithInverseEList<Customer>(Customer.class, this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystemPackage.CUSTOMER__OWNER);
157
		}
153
		}
158
		return customer;
154
		return customer;
159
	}
155
	}
Lines 163-171 Link Here
163
     * <!-- end-user-doc -->
159
     * <!-- end-user-doc -->
164
	 * @generated
160
	 * @generated
165
	 */
161
	 */
166
    public EList getProduct() {
162
    public EList<Product> getProduct() {
167
		if (product == null) {
163
		if (product == null) {
168
			product = new EObjectContainmentWithInverseEList(Product.class, this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystemPackage.PRODUCT__OWNER);
164
			product = new EObjectContainmentWithInverseEList<Product>(Product.class, this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystemPackage.PRODUCT__OWNER);
169
		}
165
		}
170
		return product;
166
		return product;
171
	}
167
	}
Lines 175-238 Link Here
175
     * <!-- end-user-doc -->
171
     * <!-- end-user-doc -->
176
	 * @generated
172
	 * @generated
177
	 */
173
	 */
178
    public EList getWarehouse() {
174
    public EList<Warehouse> getWarehouse() {
179
		if (warehouse == null) {
175
		if (warehouse == null) {
180
			warehouse = new EObjectContainmentWithInverseEList(Warehouse.class, this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystemPackage.WAREHOUSE__OWNER);
176
			warehouse = new EObjectContainmentWithInverseEList<Warehouse>(Warehouse.class, this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystemPackage.WAREHOUSE__OWNER);
181
		}
177
		}
182
		return warehouse;
178
		return warehouse;
183
	}
179
	}
184
180
185
	/**
181
	/**
186
	 * <!-- begin-user-doc -->
182
	 * <!-- begin-user-doc -->
187
     * <!-- end-user-doc -->
183
	 * <!-- end-user-doc -->
188
	 * @generated
184
	 * @generated
189
	 */
185
	 */
190
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
186
	@SuppressWarnings("unchecked")
191
		if (featureID >= 0) {
187
		@Override
192
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
188
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
193
				case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
189
		switch (featureID) {
194
					return ((InternalEList)getCustomer()).basicAdd(otherEnd, msgs);
190
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
195
				case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
191
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getCustomer()).basicAdd(otherEnd, msgs);
196
					return ((InternalEList)getProduct()).basicAdd(otherEnd, msgs);
192
			case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
197
				case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
193
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getProduct()).basicAdd(otherEnd, msgs);
198
					return ((InternalEList)getWarehouse()).basicAdd(otherEnd, msgs);
194
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
199
				default:
195
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getWarehouse()).basicAdd(otherEnd, msgs);
200
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
201
			}
202
		}
196
		}
203
		if (eContainer != null)
197
		return super.eInverseAdd(otherEnd, featureID, msgs);
204
			msgs = eBasicRemoveFromContainer(msgs);
205
		return eBasicSetContainer(otherEnd, featureID, msgs);
206
	}
198
	}
207
199
208
	/**
200
	/**
209
	 * <!-- begin-user-doc -->
201
	 * <!-- begin-user-doc -->
210
     * <!-- end-user-doc -->
202
	 * <!-- end-user-doc -->
211
	 * @generated
203
	 * @generated
212
	 */
204
	 */
213
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
205
	@Override
214
		if (featureID >= 0) {
206
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
215
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
207
		switch (featureID) {
216
				case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
208
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
217
					return ((InternalEList)getCustomer()).basicRemove(otherEnd, msgs);
209
				return ((InternalEList<?>)getCustomer()).basicRemove(otherEnd, msgs);
218
				case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
210
			case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
219
					return ((InternalEList)getProduct()).basicRemove(otherEnd, msgs);
211
				return ((InternalEList<?>)getProduct()).basicRemove(otherEnd, msgs);
220
				case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
212
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
221
					return ((InternalEList)getWarehouse()).basicRemove(otherEnd, msgs);
213
				return ((InternalEList<?>)getWarehouse()).basicRemove(otherEnd, msgs);
222
				default:
223
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
224
			}
225
		}
214
		}
226
		return eBasicSetContainer(null, featureID, msgs);
215
		return super.eInverseRemove(otherEnd, featureID, msgs);
227
	}
216
	}
228
217
229
	/**
218
	/**
230
	 * <!-- begin-user-doc -->
219
	 * <!-- begin-user-doc -->
231
     * <!-- end-user-doc -->
220
	 * <!-- end-user-doc -->
232
	 * @generated
221
	 * @generated
233
	 */
222
	 */
234
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
223
	@Override
235
		switch (eDerivedStructuralFeatureID(eFeature)) {
224
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
225
		switch (featureID) {
236
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
226
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
237
				return new Integer(getVersion());
227
				return new Integer(getVersion());
238
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
228
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
Lines 242-283 Link Here
242
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
232
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
243
				return getWarehouse();
233
				return getWarehouse();
244
		}
234
		}
245
		return eDynamicGet(eFeature, resolve);
235
		return super.eGet(featureID, resolve, coreType);
246
	}
236
	}
247
237
248
	/**
238
	/**
249
	 * <!-- begin-user-doc -->
239
	 * <!-- begin-user-doc -->
250
     * <!-- end-user-doc -->
240
	 * <!-- end-user-doc -->
251
	 * @generated
241
	 * @generated
252
	 */
242
	 */
253
    public void eSet(EStructuralFeature eFeature, Object newValue) {
243
	@SuppressWarnings("unchecked")
254
		switch (eDerivedStructuralFeatureID(eFeature)) {
244
		@Override
245
	public void eSet(int featureID, Object newValue) {
246
		switch (featureID) {
255
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
247
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
256
				setVersion(((Integer)newValue).intValue());
248
				setVersion(((Integer)newValue).intValue());
257
				return;
249
				return;
258
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
250
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
259
				getCustomer().clear();
251
				getCustomer().clear();
260
				getCustomer().addAll((Collection)newValue);
252
				getCustomer().addAll((Collection<? extends Customer>)newValue);
261
				return;
253
				return;
262
			case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
254
			case OrderSystemPackage.ORDER_SYSTEM__PRODUCT:
263
				getProduct().clear();
255
				getProduct().clear();
264
				getProduct().addAll((Collection)newValue);
256
				getProduct().addAll((Collection<? extends Product>)newValue);
265
				return;
257
				return;
266
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
258
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
267
				getWarehouse().clear();
259
				getWarehouse().clear();
268
				getWarehouse().addAll((Collection)newValue);
260
				getWarehouse().addAll((Collection<? extends Warehouse>)newValue);
269
				return;
261
				return;
270
		}
262
		}
271
		eDynamicSet(eFeature, newValue);
263
		super.eSet(featureID, newValue);
272
	}
264
	}
273
265
274
	/**
266
	/**
275
	 * <!-- begin-user-doc -->
267
	 * <!-- begin-user-doc -->
276
     * <!-- end-user-doc -->
268
	 * <!-- end-user-doc -->
277
	 * @generated
269
	 * @generated
278
	 */
270
	 */
279
    public void eUnset(EStructuralFeature eFeature) {
271
	@Override
280
		switch (eDerivedStructuralFeatureID(eFeature)) {
272
	public void eUnset(int featureID) {
273
		switch (featureID) {
281
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
274
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
282
				setVersion(VERSION_EDEFAULT);
275
				setVersion(VERSION_EDEFAULT);
283
				return;
276
				return;
Lines 291-306 Link Here
291
				getWarehouse().clear();
284
				getWarehouse().clear();
292
				return;
285
				return;
293
		}
286
		}
294
		eDynamicUnset(eFeature);
287
		super.eUnset(featureID);
295
	}
288
	}
296
289
297
	/**
290
	/**
298
	 * <!-- begin-user-doc -->
291
	 * <!-- begin-user-doc -->
299
     * <!-- end-user-doc -->
292
	 * <!-- end-user-doc -->
300
	 * @generated
293
	 * @generated
301
	 */
294
	 */
302
    public boolean eIsSet(EStructuralFeature eFeature) {
295
	@Override
303
		switch (eDerivedStructuralFeatureID(eFeature)) {
296
	public boolean eIsSet(int featureID) {
297
		switch (featureID) {
304
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
298
			case OrderSystemPackage.ORDER_SYSTEM__VERSION:
305
				return version != VERSION_EDEFAULT;
299
				return version != VERSION_EDEFAULT;
306
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
300
			case OrderSystemPackage.ORDER_SYSTEM__CUSTOMER:
Lines 310-319 Link Here
310
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
304
			case OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE:
311
				return warehouse != null && !warehouse.isEmpty();
305
				return warehouse != null && !warehouse.isEmpty();
312
		}
306
		}
313
		return eDynamicIsSet(eFeature);
307
		return super.eIsSet(featureID);
314
	}
308
	}
315
309
316
    /**
310
	/**
317
     * <!-- begin-user-doc -->
311
     * <!-- begin-user-doc -->
318
     * <!-- end-user-doc -->
312
     * <!-- end-user-doc -->
319
     */
313
     */
(-)src/ordersystem/impl/WarehouseImpl.java (-74 / +75 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 27-42 Link Here
27
27
28
import org.eclipse.emf.common.notify.Notification;
28
import org.eclipse.emf.common.notify.Notification;
29
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.NotificationChain;
30
31
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
32
33
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EStructuralFeature;
35
import org.eclipse.emf.ecore.InternalEObject;
32
import org.eclipse.emf.ecore.InternalEObject;
36
37
import org.eclipse.emf.ecore.impl.ENotificationImpl;
33
import org.eclipse.emf.ecore.impl.ENotificationImpl;
38
import org.eclipse.emf.ecore.impl.EObjectImpl;
34
import org.eclipse.emf.ecore.impl.EObjectImpl;
39
40
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
35
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
41
import org.eclipse.emf.ecore.util.EcoreUtil;
36
import org.eclipse.emf.ecore.util.EcoreUtil;
42
import org.eclipse.emf.ecore.util.InternalEList;
37
import org.eclipse.emf.ecore.util.InternalEList;
Lines 86-92 Link Here
86
	 * @generated
81
	 * @generated
87
	 * @ordered
82
	 * @ordered
88
	 */
83
	 */
89
    protected EList item = null;
84
    protected EList<InventoryItem> item;
90
85
91
	/**
86
	/**
92
	 * The cached value of the '{@link #getLocation() <em>Location</em>}' containment reference.
87
	 * The cached value of the '{@link #getLocation() <em>Location</em>}' containment reference.
Lines 96-102 Link Here
96
	 * @generated
91
	 * @generated
97
	 * @ordered
92
	 * @ordered
98
	 */
93
	 */
99
    protected Address location = null;
94
    protected Address location;
100
95
101
	/**
96
	/**
102
	 * <!-- begin-user-doc -->
97
	 * <!-- begin-user-doc -->
Lines 112-119 Link Here
112
     * <!-- end-user-doc -->
107
     * <!-- end-user-doc -->
113
	 * @generated
108
	 * @generated
114
	 */
109
	 */
115
    protected EClass eStaticClass() {
110
    @Override
116
		return OrderSystemPackage.eINSTANCE.getWarehouse();
111
				protected EClass eStaticClass() {
112
		return OrderSystemPackage.Literals.WAREHOUSE;
117
	}
113
	}
118
114
119
	/**
115
	/**
Lines 144-150 Link Here
144
	 */
140
	 */
145
    public OrderSystem getOwner() {
141
    public OrderSystem getOwner() {
146
		if (eContainerFeatureID != OrderSystemPackage.WAREHOUSE__OWNER) return null;
142
		if (eContainerFeatureID != OrderSystemPackage.WAREHOUSE__OWNER) return null;
147
		return (OrderSystem)eContainer;
143
		return (OrderSystem)eContainer();
144
	}
145
146
	/**
147
	 * <!-- begin-user-doc -->
148
	 * <!-- end-user-doc -->
149
	 * @generated
150
	 */
151
	public NotificationChain basicSetOwner(OrderSystem newOwner, NotificationChain msgs) {
152
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.WAREHOUSE__OWNER, msgs);
153
		return msgs;
148
	}
154
	}
149
155
150
	/**
156
	/**
Lines 153-167 Link Here
153
	 * @generated
159
	 * @generated
154
	 */
160
	 */
155
    public void setOwner(OrderSystem newOwner) {
161
    public void setOwner(OrderSystem newOwner) {
156
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.WAREHOUSE__OWNER && newOwner != null)) {
162
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.WAREHOUSE__OWNER && newOwner != null)) {
157
			if (EcoreUtil.isAncestor(this, newOwner))
163
			if (EcoreUtil.isAncestor(this, newOwner))
158
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
164
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
159
			NotificationChain msgs = null;
165
			NotificationChain msgs = null;
160
			if (eContainer != null)
166
			if (eInternalContainer() != null)
161
				msgs = eBasicRemoveFromContainer(msgs);
167
				msgs = eBasicRemoveFromContainer(msgs);
162
			if (newOwner != null)
168
			if (newOwner != null)
163
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystem.class, msgs);
169
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystem.class, msgs);
164
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.WAREHOUSE__OWNER, msgs);
170
			msgs = basicSetOwner(newOwner, msgs);
165
			if (msgs != null) msgs.dispatch();
171
			if (msgs != null) msgs.dispatch();
166
		}
172
		}
167
		else if (eNotificationRequired())
173
		else if (eNotificationRequired())
Lines 173-181 Link Here
173
     * <!-- end-user-doc -->
179
     * <!-- end-user-doc -->
174
	 * @generated
180
	 * @generated
175
	 */
181
	 */
176
    public EList getItem() {
182
    public EList<InventoryItem> getItem() {
177
		if (item == null) {
183
		if (item == null) {
178
			item = new EObjectContainmentWithInverseEList(InventoryItem.class, this, OrderSystemPackage.WAREHOUSE__ITEM, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE);
184
			item = new EObjectContainmentWithInverseEList<InventoryItem>(InventoryItem.class, this, OrderSystemPackage.WAREHOUSE__ITEM, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE);
179
		}
185
		}
180
		return item;
186
		return item;
181
	}
187
	}
Lines 225-296 Link Here
225
231
226
	/**
232
	/**
227
	 * <!-- begin-user-doc -->
233
	 * <!-- begin-user-doc -->
228
     * <!-- end-user-doc -->
234
	 * <!-- end-user-doc -->
229
	 * @generated
235
	 * @generated
230
	 */
236
	 */
231
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
237
	@SuppressWarnings("unchecked")
232
		if (featureID >= 0) {
238
		@Override
233
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
239
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
234
				case OrderSystemPackage.WAREHOUSE__OWNER:
240
		switch (featureID) {
235
					if (eContainer != null)
241
			case OrderSystemPackage.WAREHOUSE__OWNER:
236
						msgs = eBasicRemoveFromContainer(msgs);
242
				if (eInternalContainer() != null)
237
					return eBasicSetContainer(otherEnd, OrderSystemPackage.WAREHOUSE__OWNER, msgs);
243
					msgs = eBasicRemoveFromContainer(msgs);
238
				case OrderSystemPackage.WAREHOUSE__ITEM:
244
				return basicSetOwner((OrderSystem)otherEnd, msgs);
239
					return ((InternalEList)getItem()).basicAdd(otherEnd, msgs);
245
			case OrderSystemPackage.WAREHOUSE__ITEM:
240
				default:
246
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getItem()).basicAdd(otherEnd, msgs);
241
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
242
			}
243
		}
247
		}
244
		if (eContainer != null)
248
		return super.eInverseAdd(otherEnd, featureID, msgs);
245
			msgs = eBasicRemoveFromContainer(msgs);
246
		return eBasicSetContainer(otherEnd, featureID, msgs);
247
	}
249
	}
248
250
249
	/**
251
	/**
250
	 * <!-- begin-user-doc -->
252
	 * <!-- begin-user-doc -->
251
     * <!-- end-user-doc -->
253
	 * <!-- end-user-doc -->
252
	 * @generated
254
	 * @generated
253
	 */
255
	 */
254
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
256
	@Override
255
		if (featureID >= 0) {
257
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
256
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
258
		switch (featureID) {
257
				case OrderSystemPackage.WAREHOUSE__OWNER:
259
			case OrderSystemPackage.WAREHOUSE__OWNER:
258
					return eBasicSetContainer(null, OrderSystemPackage.WAREHOUSE__OWNER, msgs);
260
				return basicSetOwner(null, msgs);
259
				case OrderSystemPackage.WAREHOUSE__ITEM:
261
			case OrderSystemPackage.WAREHOUSE__ITEM:
260
					return ((InternalEList)getItem()).basicRemove(otherEnd, msgs);
262
				return ((InternalEList<?>)getItem()).basicRemove(otherEnd, msgs);
261
				case OrderSystemPackage.WAREHOUSE__LOCATION:
263
			case OrderSystemPackage.WAREHOUSE__LOCATION:
262
					return basicSetLocation(null, msgs);
264
				return basicSetLocation(null, msgs);
263
				default:
264
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
265
			}
266
		}
265
		}
267
		return eBasicSetContainer(null, featureID, msgs);
266
		return super.eInverseRemove(otherEnd, featureID, msgs);
268
	}
267
	}
269
268
270
	/**
269
	/**
271
	 * <!-- begin-user-doc -->
270
	 * <!-- begin-user-doc -->
272
     * <!-- end-user-doc -->
271
	 * <!-- end-user-doc -->
273
	 * @generated
272
	 * @generated
274
	 */
273
	 */
275
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
274
	@Override
276
		if (eContainerFeatureID >= 0) {
275
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
277
			switch (eContainerFeatureID) {
276
		switch (eContainerFeatureID) {
278
				case OrderSystemPackage.WAREHOUSE__OWNER:
277
			case OrderSystemPackage.WAREHOUSE__OWNER:
279
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystem.class, msgs);
278
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__WAREHOUSE, OrderSystem.class, msgs);
280
				default:
281
					return eDynamicBasicRemoveFromContainer(msgs);
282
			}
283
		}
279
		}
284
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
280
		return super.eBasicRemoveFromContainerFeature(msgs);
285
	}
281
	}
286
282
287
	/**
283
	/**
288
	 * <!-- begin-user-doc -->
284
	 * <!-- begin-user-doc -->
289
     * <!-- end-user-doc -->
285
	 * <!-- end-user-doc -->
290
	 * @generated
286
	 * @generated
291
	 */
287
	 */
292
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
288
	@Override
293
		switch (eDerivedStructuralFeatureID(eFeature)) {
289
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
290
		switch (featureID) {
294
			case OrderSystemPackage.WAREHOUSE__NAME:
291
			case OrderSystemPackage.WAREHOUSE__NAME:
295
				return getName();
292
				return getName();
296
			case OrderSystemPackage.WAREHOUSE__OWNER:
293
			case OrderSystemPackage.WAREHOUSE__OWNER:
Lines 300-315 Link Here
300
			case OrderSystemPackage.WAREHOUSE__LOCATION:
297
			case OrderSystemPackage.WAREHOUSE__LOCATION:
301
				return getLocation();
298
				return getLocation();
302
		}
299
		}
303
		return eDynamicGet(eFeature, resolve);
300
		return super.eGet(featureID, resolve, coreType);
304
	}
301
	}
305
302
306
	/**
303
	/**
307
	 * <!-- begin-user-doc -->
304
	 * <!-- begin-user-doc -->
308
     * <!-- end-user-doc -->
305
	 * <!-- end-user-doc -->
309
	 * @generated
306
	 * @generated
310
	 */
307
	 */
311
    public void eSet(EStructuralFeature eFeature, Object newValue) {
308
	@SuppressWarnings("unchecked")
312
		switch (eDerivedStructuralFeatureID(eFeature)) {
309
		@Override
310
	public void eSet(int featureID, Object newValue) {
311
		switch (featureID) {
313
			case OrderSystemPackage.WAREHOUSE__NAME:
312
			case OrderSystemPackage.WAREHOUSE__NAME:
314
				setName((String)newValue);
313
				setName((String)newValue);
315
				return;
314
				return;
Lines 318-339 Link Here
318
				return;
317
				return;
319
			case OrderSystemPackage.WAREHOUSE__ITEM:
318
			case OrderSystemPackage.WAREHOUSE__ITEM:
320
				getItem().clear();
319
				getItem().clear();
321
				getItem().addAll((Collection)newValue);
320
				getItem().addAll((Collection<? extends InventoryItem>)newValue);
322
				return;
321
				return;
323
			case OrderSystemPackage.WAREHOUSE__LOCATION:
322
			case OrderSystemPackage.WAREHOUSE__LOCATION:
324
				setLocation((Address)newValue);
323
				setLocation((Address)newValue);
325
				return;
324
				return;
326
		}
325
		}
327
		eDynamicSet(eFeature, newValue);
326
		super.eSet(featureID, newValue);
328
	}
327
	}
329
328
330
	/**
329
	/**
331
	 * <!-- begin-user-doc -->
330
	 * <!-- begin-user-doc -->
332
     * <!-- end-user-doc -->
331
	 * <!-- end-user-doc -->
333
	 * @generated
332
	 * @generated
334
	 */
333
	 */
335
    public void eUnset(EStructuralFeature eFeature) {
334
	@Override
336
		switch (eDerivedStructuralFeatureID(eFeature)) {
335
	public void eUnset(int featureID) {
336
		switch (featureID) {
337
			case OrderSystemPackage.WAREHOUSE__NAME:
337
			case OrderSystemPackage.WAREHOUSE__NAME:
338
				setName(NAME_EDEFAULT);
338
				setName(NAME_EDEFAULT);
339
				return;
339
				return;
Lines 347-362 Link Here
347
				setLocation((Address)null);
347
				setLocation((Address)null);
348
				return;
348
				return;
349
		}
349
		}
350
		eDynamicUnset(eFeature);
350
		super.eUnset(featureID);
351
	}
351
	}
352
352
353
	/**
353
	/**
354
	 * <!-- begin-user-doc -->
354
	 * <!-- begin-user-doc -->
355
     * <!-- end-user-doc -->
355
	 * <!-- end-user-doc -->
356
	 * @generated
356
	 * @generated
357
	 */
357
	 */
358
    public boolean eIsSet(EStructuralFeature eFeature) {
358
	@Override
359
		switch (eDerivedStructuralFeatureID(eFeature)) {
359
	public boolean eIsSet(int featureID) {
360
		switch (featureID) {
360
			case OrderSystemPackage.WAREHOUSE__NAME:
361
			case OrderSystemPackage.WAREHOUSE__NAME:
361
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
362
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
362
			case OrderSystemPackage.WAREHOUSE__OWNER:
363
			case OrderSystemPackage.WAREHOUSE__OWNER:
Lines 366-375 Link Here
366
			case OrderSystemPackage.WAREHOUSE__LOCATION:
367
			case OrderSystemPackage.WAREHOUSE__LOCATION:
367
				return location != null;
368
				return location != null;
368
		}
369
		}
369
		return eDynamicIsSet(eFeature);
370
		return super.eIsSet(featureID);
370
	}
371
	}
371
372
372
    /**
373
	/**
373
     * <!-- begin-user-doc -->
374
     * <!-- begin-user-doc -->
374
     * <!-- end-user-doc -->
375
     * <!-- end-user-doc -->
375
     */
376
     */
(-)src/ordersystem/impl/OrderSystemPackageImpl.java (-75 / +79 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 30-38 Link Here
30
import ordersystem.OrderSystemPackage;
30
import ordersystem.OrderSystemPackage;
31
import ordersystem.Product;
31
import ordersystem.Product;
32
import ordersystem.Warehouse;
32
import ordersystem.Warehouse;
33
34
import ordersystem.special.SpecialPackage;
33
import ordersystem.special.SpecialPackage;
35
36
import ordersystem.special.impl.SpecialPackageImpl;
34
import ordersystem.special.impl.SpecialPackageImpl;
37
35
38
import org.eclipse.emf.ecore.EAttribute;
36
import org.eclipse.emf.ecore.EAttribute;
Lines 40-46 Link Here
40
import org.eclipse.emf.ecore.EDataType;
38
import org.eclipse.emf.ecore.EDataType;
41
import org.eclipse.emf.ecore.EPackage;
39
import org.eclipse.emf.ecore.EPackage;
42
import org.eclipse.emf.ecore.EReference;
40
import org.eclipse.emf.ecore.EReference;
43
44
import org.eclipse.emf.ecore.impl.EPackageImpl;
41
import org.eclipse.emf.ecore.impl.EPackageImpl;
45
42
46
/**
43
/**
Lines 169-192 Link Here
169
	 * @generated
166
	 * @generated
170
	 */
167
	 */
171
    public static OrderSystemPackage init() {
168
    public static OrderSystemPackage init() {
172
		if (isInited) return (OrderSystemPackage)EPackage.Registry.INSTANCE.get(OrderSystemPackage.eNS_URI);
169
		if (isInited) return (OrderSystemPackage)EPackage.Registry.INSTANCE.getEPackage(OrderSystemPackage.eNS_URI);
173
170
174
		// Obtain or create and register package.
171
		// Obtain or create and register package
175
		OrderSystemPackageImpl theOrderSystemPackage = (OrderSystemPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof EPackage ? EPackage.Registry.INSTANCE.get(eNS_URI) : new OrderSystemPackageImpl());
172
		OrderSystemPackageImpl theOrderSystemPackage = (OrderSystemPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof OrderSystemPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new OrderSystemPackageImpl());
176
173
177
		isInited = true;
174
		isInited = true;
178
175
179
		// Obtain or create and register interdependencies
176
		// Obtain or create and register interdependencies
180
		SpecialPackageImpl theSpecialPackage = (SpecialPackageImpl)(EPackage.Registry.INSTANCE.get(SpecialPackage.eNS_URI) instanceof EPackage ? EPackage.Registry.INSTANCE.get(SpecialPackage.eNS_URI) : SpecialPackageImpl.eINSTANCE);
177
		SpecialPackageImpl theSpecialPackage = (SpecialPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(SpecialPackage.eNS_URI) instanceof SpecialPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(SpecialPackage.eNS_URI) : SpecialPackage.eINSTANCE);
181
178
182
		// Step 1: create meta-model objects
179
		// Create package meta-data objects
183
		theOrderSystemPackage.createPackageContents();
180
		theOrderSystemPackage.createPackageContents();
184
		theSpecialPackage.createPackageContents();
181
		theSpecialPackage.createPackageContents();
185
182
186
		// Step 2: complete initialization
183
		// Initialize created meta-data
187
		theOrderSystemPackage.initializePackageContents();
184
		theOrderSystemPackage.initializePackageContents();
188
		theSpecialPackage.initializePackageContents();
185
		theSpecialPackage.initializePackageContents();
189
186
187
		// Mark meta-data to indicate it can't be changed
188
		theOrderSystemPackage.freeze();
189
190
		return theOrderSystemPackage;
190
		return theOrderSystemPackage;
191
	}
191
	}
192
192
Lines 794-873 Link Here
794
		setNsURI(eNS_URI);
794
		setNsURI(eNS_URI);
795
795
796
		// Obtain other dependent packages
796
		// Obtain other dependent packages
797
		SpecialPackageImpl theSpecialPackage = (SpecialPackageImpl)EPackage.Registry.INSTANCE.getEPackage(SpecialPackage.eNS_URI);
797
		SpecialPackage theSpecialPackage = (SpecialPackage)EPackage.Registry.INSTANCE.getEPackage(SpecialPackage.eNS_URI);
798
798
799
		// Add subpackages
799
		// Add subpackages
800
		getESubpackages().add(theSpecialPackage);
800
		getESubpackages().add(theSpecialPackage);
801
801
802
		// Create type parameters
803
804
		// Set bounds for type parameters
805
802
		// Add supertypes to classes
806
		// Add supertypes to classes
803
807
804
		// Initialize classes and features; add operations and parameters
808
		// Initialize classes and features; add operations and parameters
805
		initEClass(orderEClass, Order.class, "Order", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
809
		initEClass(orderEClass, Order.class, "Order", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
806
		initEAttribute(getOrder_PlacedOn(), this.getJavaDate(), "placedOn", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
810
		initEAttribute(getOrder_PlacedOn(), this.getJavaDate(), "placedOn", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
807
		initEAttribute(getOrder_FilledOn(), this.getJavaDate(), "filledOn", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
811
		initEAttribute(getOrder_FilledOn(), this.getJavaDate(), "filledOn", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
808
		initEAttribute(getOrder_Completed(), ecorePackage.getEBoolean(), "completed", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
812
		initEAttribute(getOrder_Completed(), ecorePackage.getEBoolean(), "completed", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
809
		initEAttribute(getOrder_Id(), ecorePackage.getEString(), "id", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
813
		initEAttribute(getOrder_Id(), ecorePackage.getEString(), "id", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
810
		initEReference(getOrder_Owner(), this.getCustomer(), this.getCustomer_Order(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
814
		initEReference(getOrder_Owner(), this.getCustomer(), this.getCustomer_Order(), "owner", null, 0, 1, Order.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
811
		initEReference(getOrder_Item(), this.getLineItem(), this.getLineItem_Owner(), "item", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
815
		initEReference(getOrder_Item(), this.getLineItem(), this.getLineItem_Owner(), "item", null, 0, -1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
812
816
813
		initEClass(productEClass, Product.class, "Product", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
817
		initEClass(productEClass, Product.class, "Product", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
814
		initEAttribute(getProduct_Name(), ecorePackage.getEString(), "name", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
818
		initEAttribute(getProduct_Name(), ecorePackage.getEString(), "name", null, 0, 1, Product.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
815
		initEAttribute(getProduct_Sku(), ecorePackage.getEString(), "sku", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
819
		initEAttribute(getProduct_Sku(), ecorePackage.getEString(), "sku", null, 0, 1, Product.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
816
		initEAttribute(getProduct_Price(), ecorePackage.getEDouble(), "price", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
820
		initEAttribute(getProduct_Price(), ecorePackage.getEDouble(), "price", null, 0, 1, Product.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
817
		initEReference(getProduct_Owner(), this.getOrderSystem(), this.getOrderSystem_Product(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
821
		initEReference(getProduct_Owner(), this.getOrderSystem(), this.getOrderSystem_Product(), "owner", null, 0, 1, Product.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
818
822
819
		initEClass(warehouseEClass, Warehouse.class, "Warehouse", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
823
		initEClass(warehouseEClass, Warehouse.class, "Warehouse", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
820
		initEAttribute(getWarehouse_Name(), ecorePackage.getEString(), "name", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
824
		initEAttribute(getWarehouse_Name(), ecorePackage.getEString(), "name", null, 0, 1, Warehouse.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
821
		initEReference(getWarehouse_Owner(), this.getOrderSystem(), this.getOrderSystem_Warehouse(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
825
		initEReference(getWarehouse_Owner(), this.getOrderSystem(), this.getOrderSystem_Warehouse(), "owner", null, 0, 1, Warehouse.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
822
		initEReference(getWarehouse_Item(), this.getInventoryItem(), this.getInventoryItem_Warehouse(), "item", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
826
		initEReference(getWarehouse_Item(), this.getInventoryItem(), this.getInventoryItem_Warehouse(), "item", null, 0, -1, Warehouse.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
823
		initEReference(getWarehouse_Location(), this.getAddress(), null, "location", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
827
		initEReference(getWarehouse_Location(), this.getAddress(), null, "location", null, 1, 1, Warehouse.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
824
828
825
		initEClass(orderSystemEClass, OrderSystem.class, "OrderSystem", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
829
		initEClass(orderSystemEClass, OrderSystem.class, "OrderSystem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
826
		initEAttribute(getOrderSystem_Version(), ecorePackage.getEInt(), "version", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
830
		initEAttribute(getOrderSystem_Version(), ecorePackage.getEInt(), "version", null, 0, 1, OrderSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
827
		initEReference(getOrderSystem_Customer(), this.getCustomer(), this.getCustomer_Owner(), "customer", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
831
		initEReference(getOrderSystem_Customer(), this.getCustomer(), this.getCustomer_Owner(), "customer", null, 0, -1, OrderSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
828
		initEReference(getOrderSystem_Product(), this.getProduct(), this.getProduct_Owner(), "product", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
832
		initEReference(getOrderSystem_Product(), this.getProduct(), this.getProduct_Owner(), "product", null, 0, -1, OrderSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
829
		initEReference(getOrderSystem_Warehouse(), this.getWarehouse(), this.getWarehouse_Owner(), "warehouse", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
833
		initEReference(getOrderSystem_Warehouse(), this.getWarehouse(), this.getWarehouse_Owner(), "warehouse", null, 0, -1, OrderSystem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
830
834
831
		initEClass(lineItemEClass, LineItem.class, "LineItem", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
835
		initEClass(lineItemEClass, LineItem.class, "LineItem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
832
		initEAttribute(getLineItem_Quantity(), ecorePackage.getEInt(), "quantity", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
836
		initEAttribute(getLineItem_Quantity(), ecorePackage.getEInt(), "quantity", null, 0, 1, LineItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
833
		initEAttribute(getLineItem_Discount(), ecorePackage.getEDouble(), "discount", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
837
		initEAttribute(getLineItem_Discount(), ecorePackage.getEDouble(), "discount", null, 0, 1, LineItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
834
		initEReference(getLineItem_Owner(), this.getOrder(), this.getOrder_Item(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
838
		initEReference(getLineItem_Owner(), this.getOrder(), this.getOrder_Item(), "owner", null, 0, 1, LineItem.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
835
		initEReference(getLineItem_Product(), this.getProduct(), null, "product", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
839
		initEReference(getLineItem_Product(), this.getProduct(), null, "product", null, 1, 1, LineItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
836
840
837
		addEOperation(lineItemEClass, ecorePackage.getEDouble(), "getCost"); //$NON-NLS-1$
841
		addEOperation(lineItemEClass, ecorePackage.getEDouble(), "getCost", 0, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$
838
842
839
		initEClass(inventoryItemEClass, InventoryItem.class, "InventoryItem", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
843
		initEClass(inventoryItemEClass, InventoryItem.class, "InventoryItem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
840
		initEAttribute(getInventoryItem_InStock(), ecorePackage.getEInt(), "inStock", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
844
		initEAttribute(getInventoryItem_InStock(), ecorePackage.getEInt(), "inStock", null, 0, 1, InventoryItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
841
		initEAttribute(getInventoryItem_RestockThreshold(), ecorePackage.getEInt(), "restockThreshold", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
845
		initEAttribute(getInventoryItem_RestockThreshold(), ecorePackage.getEInt(), "restockThreshold", null, 0, 1, InventoryItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
842
		initEAttribute(getInventoryItem_NextStockDate(), this.getJavaDate(), "nextStockDate", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
846
		initEAttribute(getInventoryItem_NextStockDate(), this.getJavaDate(), "nextStockDate", null, 0, 1, InventoryItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
843
		initEReference(getInventoryItem_Warehouse(), this.getWarehouse(), this.getWarehouse_Item(), "Warehouse", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
847
		initEReference(getInventoryItem_Warehouse(), this.getWarehouse(), this.getWarehouse_Item(), "Warehouse", null, 0, 1, InventoryItem.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
844
		initEReference(getInventoryItem_Product(), this.getProduct(), null, "product", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
848
		initEReference(getInventoryItem_Product(), this.getProduct(), null, "product", null, 1, 1, InventoryItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
845
849
846
		initEClass(customerEClass, Customer.class, "Customer", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
850
		initEClass(customerEClass, Customer.class, "Customer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
847
		initEAttribute(getCustomer_LastName(), ecorePackage.getEString(), "lastName", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
851
		initEAttribute(getCustomer_LastName(), ecorePackage.getEString(), "lastName", null, 0, 1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
848
		initEAttribute(getCustomer_FirstName(), ecorePackage.getEString(), "firstName", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
852
		initEAttribute(getCustomer_FirstName(), ecorePackage.getEString(), "firstName", null, 0, 1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
849
		initEReference(getCustomer_Owner(), this.getOrderSystem(), this.getOrderSystem_Customer(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
853
		initEReference(getCustomer_Owner(), this.getOrderSystem(), this.getOrderSystem_Customer(), "owner", null, 0, 1, Customer.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
850
		initEReference(getCustomer_Account(), this.getAccount(), this.getAccount_Owner(), "account", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
854
		initEReference(getCustomer_Account(), this.getAccount(), this.getAccount_Owner(), "account", null, 0, -1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
851
		initEReference(getCustomer_Order(), this.getOrder(), this.getOrder_Owner(), "order", null, 0, -1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
855
		initEReference(getCustomer_Order(), this.getOrder(), this.getOrder_Owner(), "order", null, 0, -1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
852
856
853
		initEClass(addressEClass, Address.class, "Address", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
857
		initEClass(addressEClass, Address.class, "Address", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
854
		initEAttribute(getAddress_Number(), ecorePackage.getEString(), "number", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
858
		initEAttribute(getAddress_Number(), ecorePackage.getEString(), "number", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
855
		initEAttribute(getAddress_Street(), ecorePackage.getEString(), "street", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
859
		initEAttribute(getAddress_Street(), ecorePackage.getEString(), "street", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
856
		initEAttribute(getAddress_Apartment(), ecorePackage.getEString(), "apartment", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
860
		initEAttribute(getAddress_Apartment(), ecorePackage.getEString(), "apartment", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
857
		initEAttribute(getAddress_City(), ecorePackage.getEString(), "city", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
861
		initEAttribute(getAddress_City(), ecorePackage.getEString(), "city", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
858
		initEAttribute(getAddress_Province(), ecorePackage.getEString(), "province", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
862
		initEAttribute(getAddress_Province(), ecorePackage.getEString(), "province", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
859
		initEAttribute(getAddress_PostalCode(), ecorePackage.getEString(), "postalCode", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
863
		initEAttribute(getAddress_PostalCode(), ecorePackage.getEString(), "postalCode", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
860
		initEAttribute(getAddress_Country(), ecorePackage.getEString(), "country", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
864
		initEAttribute(getAddress_Country(), ecorePackage.getEString(), "country", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
861
865
862
		initEClass(accountEClass, Account.class, "Account", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
866
		initEClass(accountEClass, Account.class, "Account", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
863
		initEAttribute(getAccount_PaymentMethod(), ecorePackage.getEString(), "paymentMethod", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
867
		initEAttribute(getAccount_PaymentMethod(), ecorePackage.getEString(), "paymentMethod", null, 0, 1, Account.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
864
		initEAttribute(getAccount_AccountNumber(), ecorePackage.getEString(), "accountNumber", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
868
		initEAttribute(getAccount_AccountNumber(), ecorePackage.getEString(), "accountNumber", null, 0, 1, Account.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
865
		initEReference(getAccount_Owner(), this.getCustomer(), this.getCustomer_Account(), "owner", null, 0, 1, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
869
		initEReference(getAccount_Owner(), this.getCustomer(), this.getCustomer_Account(), "owner", null, 0, 1, Account.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
866
		initEReference(getAccount_BillingAddress(), this.getAddress(), null, "billingAddress", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
870
		initEReference(getAccount_BillingAddress(), this.getAddress(), null, "billingAddress", null, 1, 1, Account.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
867
		initEReference(getAccount_ShippingAddress(), this.getAddress(), null, "shippingAddress", null, 1, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
871
		initEReference(getAccount_ShippingAddress(), this.getAddress(), null, "shippingAddress", null, 1, 1, Account.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
868
872
869
		// Initialize data types
873
		// Initialize data types
870
		initEDataType(javaDateEDataType, Date.class, "JavaDate", IS_SERIALIZABLE); //$NON-NLS-1$
874
		initEDataType(javaDateEDataType, Date.class, "JavaDate", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
871
875
872
		// Create resource
876
		// Create resource
873
		createResource(eNS_URI);
877
		createResource(eNS_URI);
(-)src/ordersystem/impl/AccountImpl.java (-69 / +68 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 20-38 Link Here
20
import ordersystem.Account;
20
import ordersystem.Account;
21
import ordersystem.Address;
21
import ordersystem.Address;
22
import ordersystem.Customer;
22
import ordersystem.Customer;
23
24
import ordersystem.OrderSystemPackage;
23
import ordersystem.OrderSystemPackage;
25
24
26
import org.eclipse.emf.common.notify.Notification;
25
import org.eclipse.emf.common.notify.Notification;
27
import org.eclipse.emf.common.notify.NotificationChain;
26
import org.eclipse.emf.common.notify.NotificationChain;
28
29
import org.eclipse.emf.ecore.EClass;
27
import org.eclipse.emf.ecore.EClass;
30
import org.eclipse.emf.ecore.EStructuralFeature;
31
import org.eclipse.emf.ecore.InternalEObject;
28
import org.eclipse.emf.ecore.InternalEObject;
32
33
import org.eclipse.emf.ecore.impl.ENotificationImpl;
29
import org.eclipse.emf.ecore.impl.ENotificationImpl;
34
import org.eclipse.emf.ecore.impl.EObjectImpl;
30
import org.eclipse.emf.ecore.impl.EObjectImpl;
35
36
import org.eclipse.emf.ecore.util.EcoreUtil;
31
import org.eclipse.emf.ecore.util.EcoreUtil;
37
32
38
/**
33
/**
Lines 101-107 Link Here
101
	 * @generated
96
	 * @generated
102
	 * @ordered
97
	 * @ordered
103
	 */
98
	 */
104
    protected Address billingAddress = null;
99
    protected Address billingAddress;
105
100
106
	/**
101
	/**
107
	 * The cached value of the '{@link #getShippingAddress() <em>Shipping Address</em>}' containment reference.
102
	 * The cached value of the '{@link #getShippingAddress() <em>Shipping Address</em>}' containment reference.
Lines 111-117 Link Here
111
	 * @generated
106
	 * @generated
112
	 * @ordered
107
	 * @ordered
113
	 */
108
	 */
114
    protected Address shippingAddress = null;
109
    protected Address shippingAddress;
115
110
116
	/**
111
	/**
117
	 * <!-- begin-user-doc -->
112
	 * <!-- begin-user-doc -->
Lines 127-134 Link Here
127
     * <!-- end-user-doc -->
122
     * <!-- end-user-doc -->
128
	 * @generated
123
	 * @generated
129
	 */
124
	 */
130
    protected EClass eStaticClass() {
125
    @Override
131
		return OrderSystemPackage.eINSTANCE.getAccount();
126
				protected EClass eStaticClass() {
127
		return OrderSystemPackage.Literals.ACCOUNT;
132
	}
128
	}
133
129
134
	/**
130
	/**
Lines 180-186 Link Here
180
	 */
176
	 */
181
    public Customer getOwner() {
177
    public Customer getOwner() {
182
		if (eContainerFeatureID != OrderSystemPackage.ACCOUNT__OWNER) return null;
178
		if (eContainerFeatureID != OrderSystemPackage.ACCOUNT__OWNER) return null;
183
		return (Customer)eContainer;
179
		return (Customer)eContainer();
180
	}
181
182
	/**
183
	 * <!-- begin-user-doc -->
184
	 * <!-- end-user-doc -->
185
	 * @generated
186
	 */
187
	public NotificationChain basicSetOwner(Customer newOwner, NotificationChain msgs) {
188
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.ACCOUNT__OWNER, msgs);
189
		return msgs;
184
	}
190
	}
185
191
186
	/**
192
	/**
Lines 189-203 Link Here
189
	 * @generated
195
	 * @generated
190
	 */
196
	 */
191
    public void setOwner(Customer newOwner) {
197
    public void setOwner(Customer newOwner) {
192
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.ACCOUNT__OWNER && newOwner != null)) {
198
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.ACCOUNT__OWNER && newOwner != null)) {
193
			if (EcoreUtil.isAncestor(this, newOwner))
199
			if (EcoreUtil.isAncestor(this, newOwner))
194
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
200
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
195
			NotificationChain msgs = null;
201
			NotificationChain msgs = null;
196
			if (eContainer != null)
202
			if (eInternalContainer() != null)
197
				msgs = eBasicRemoveFromContainer(msgs);
203
				msgs = eBasicRemoveFromContainer(msgs);
198
			if (newOwner != null)
204
			if (newOwner != null)
199
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.CUSTOMER__ACCOUNT, Customer.class, msgs);
205
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.CUSTOMER__ACCOUNT, Customer.class, msgs);
200
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.ACCOUNT__OWNER, msgs);
206
			msgs = basicSetOwner(newOwner, msgs);
201
			if (msgs != null) msgs.dispatch();
207
			if (msgs != null) msgs.dispatch();
202
		}
208
		}
203
		else if (eNotificationRequired())
209
		else if (eNotificationRequired())
Lines 292-361 Link Here
292
298
293
	/**
299
	/**
294
	 * <!-- begin-user-doc -->
300
	 * <!-- begin-user-doc -->
295
     * <!-- end-user-doc -->
301
	 * <!-- end-user-doc -->
296
	 * @generated
302
	 * @generated
297
	 */
303
	 */
298
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
304
	@Override
299
		if (featureID >= 0) {
305
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
300
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
306
		switch (featureID) {
301
				case OrderSystemPackage.ACCOUNT__OWNER:
307
			case OrderSystemPackage.ACCOUNT__OWNER:
302
					if (eContainer != null)
308
				if (eInternalContainer() != null)
303
						msgs = eBasicRemoveFromContainer(msgs);
309
					msgs = eBasicRemoveFromContainer(msgs);
304
					return eBasicSetContainer(otherEnd, OrderSystemPackage.ACCOUNT__OWNER, msgs);
310
				return basicSetOwner((Customer)otherEnd, msgs);
305
				default:
306
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
307
			}
308
		}
311
		}
309
		if (eContainer != null)
312
		return super.eInverseAdd(otherEnd, featureID, msgs);
310
			msgs = eBasicRemoveFromContainer(msgs);
311
		return eBasicSetContainer(otherEnd, featureID, msgs);
312
	}
313
	}
313
314
314
	/**
315
	/**
315
	 * <!-- begin-user-doc -->
316
	 * <!-- begin-user-doc -->
316
     * <!-- end-user-doc -->
317
	 * <!-- end-user-doc -->
317
	 * @generated
318
	 * @generated
318
	 */
319
	 */
319
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
320
	@Override
320
		if (featureID >= 0) {
321
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
321
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
322
		switch (featureID) {
322
				case OrderSystemPackage.ACCOUNT__OWNER:
323
			case OrderSystemPackage.ACCOUNT__OWNER:
323
					return eBasicSetContainer(null, OrderSystemPackage.ACCOUNT__OWNER, msgs);
324
				return basicSetOwner(null, msgs);
324
				case OrderSystemPackage.ACCOUNT__BILLING_ADDRESS:
325
			case OrderSystemPackage.ACCOUNT__BILLING_ADDRESS:
325
					return basicSetBillingAddress(null, msgs);
326
				return basicSetBillingAddress(null, msgs);
326
				case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
327
			case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
327
					return basicSetShippingAddress(null, msgs);
328
				return basicSetShippingAddress(null, msgs);
328
				default:
329
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
330
			}
331
		}
329
		}
332
		return eBasicSetContainer(null, featureID, msgs);
330
		return super.eInverseRemove(otherEnd, featureID, msgs);
333
	}
331
	}
334
332
335
	/**
333
	/**
336
	 * <!-- begin-user-doc -->
334
	 * <!-- begin-user-doc -->
337
     * <!-- end-user-doc -->
335
	 * <!-- end-user-doc -->
338
	 * @generated
336
	 * @generated
339
	 */
337
	 */
340
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
338
	@Override
341
		if (eContainerFeatureID >= 0) {
339
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
342
			switch (eContainerFeatureID) {
340
		switch (eContainerFeatureID) {
343
				case OrderSystemPackage.ACCOUNT__OWNER:
341
			case OrderSystemPackage.ACCOUNT__OWNER:
344
					return (eContainer).eInverseRemove(this, OrderSystemPackage.CUSTOMER__ACCOUNT, Customer.class, msgs);
342
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.CUSTOMER__ACCOUNT, Customer.class, msgs);
345
				default:
346
					return eDynamicBasicRemoveFromContainer(msgs);
347
			}
348
		}
343
		}
349
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
344
		return super.eBasicRemoveFromContainerFeature(msgs);
350
	}
345
	}
351
346
352
	/**
347
	/**
353
	 * <!-- begin-user-doc -->
348
	 * <!-- begin-user-doc -->
354
     * <!-- end-user-doc -->
349
	 * <!-- end-user-doc -->
355
	 * @generated
350
	 * @generated
356
	 */
351
	 */
357
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
352
	@Override
358
		switch (eDerivedStructuralFeatureID(eFeature)) {
353
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
354
		switch (featureID) {
359
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
355
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
360
				return getPaymentMethod();
356
				return getPaymentMethod();
361
			case OrderSystemPackage.ACCOUNT__ACCOUNT_NUMBER:
357
			case OrderSystemPackage.ACCOUNT__ACCOUNT_NUMBER:
Lines 367-382 Link Here
367
			case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
363
			case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
368
				return getShippingAddress();
364
				return getShippingAddress();
369
		}
365
		}
370
		return eDynamicGet(eFeature, resolve);
366
		return super.eGet(featureID, resolve, coreType);
371
	}
367
	}
372
368
373
	/**
369
	/**
374
	 * <!-- begin-user-doc -->
370
	 * <!-- begin-user-doc -->
375
     * <!-- end-user-doc -->
371
	 * <!-- end-user-doc -->
376
	 * @generated
372
	 * @generated
377
	 */
373
	 */
378
    public void eSet(EStructuralFeature eFeature, Object newValue) {
374
	@Override
379
		switch (eDerivedStructuralFeatureID(eFeature)) {
375
	public void eSet(int featureID, Object newValue) {
376
		switch (featureID) {
380
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
377
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
381
				setPaymentMethod((String)newValue);
378
				setPaymentMethod((String)newValue);
382
				return;
379
				return;
Lines 393-408 Link Here
393
				setShippingAddress((Address)newValue);
390
				setShippingAddress((Address)newValue);
394
				return;
391
				return;
395
		}
392
		}
396
		eDynamicSet(eFeature, newValue);
393
		super.eSet(featureID, newValue);
397
	}
394
	}
398
395
399
	/**
396
	/**
400
	 * <!-- begin-user-doc -->
397
	 * <!-- begin-user-doc -->
401
     * <!-- end-user-doc -->
398
	 * <!-- end-user-doc -->
402
	 * @generated
399
	 * @generated
403
	 */
400
	 */
404
    public void eUnset(EStructuralFeature eFeature) {
401
	@Override
405
		switch (eDerivedStructuralFeatureID(eFeature)) {
402
	public void eUnset(int featureID) {
403
		switch (featureID) {
406
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
404
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
407
				setPaymentMethod(PAYMENT_METHOD_EDEFAULT);
405
				setPaymentMethod(PAYMENT_METHOD_EDEFAULT);
408
				return;
406
				return;
Lines 419-434 Link Here
419
				setShippingAddress((Address)null);
417
				setShippingAddress((Address)null);
420
				return;
418
				return;
421
		}
419
		}
422
		eDynamicUnset(eFeature);
420
		super.eUnset(featureID);
423
	}
421
	}
424
422
425
	/**
423
	/**
426
	 * <!-- begin-user-doc -->
424
	 * <!-- begin-user-doc -->
427
     * <!-- end-user-doc -->
425
	 * <!-- end-user-doc -->
428
	 * @generated
426
	 * @generated
429
	 */
427
	 */
430
    public boolean eIsSet(EStructuralFeature eFeature) {
428
	@Override
431
		switch (eDerivedStructuralFeatureID(eFeature)) {
429
	public boolean eIsSet(int featureID) {
430
		switch (featureID) {
432
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
431
			case OrderSystemPackage.ACCOUNT__PAYMENT_METHOD:
433
				return PAYMENT_METHOD_EDEFAULT == null ? paymentMethod != null : !PAYMENT_METHOD_EDEFAULT.equals(paymentMethod);
432
				return PAYMENT_METHOD_EDEFAULT == null ? paymentMethod != null : !PAYMENT_METHOD_EDEFAULT.equals(paymentMethod);
434
			case OrderSystemPackage.ACCOUNT__ACCOUNT_NUMBER:
433
			case OrderSystemPackage.ACCOUNT__ACCOUNT_NUMBER:
Lines 440-449 Link Here
440
			case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
439
			case OrderSystemPackage.ACCOUNT__SHIPPING_ADDRESS:
441
				return shippingAddress != null;
440
				return shippingAddress != null;
442
		}
441
		}
443
		return eDynamicIsSet(eFeature);
442
		return super.eIsSet(featureID);
444
	}
443
	}
445
444
446
    /**
445
	/**
447
     * <!-- begin-user-doc -->
446
     * <!-- begin-user-doc -->
448
     * <!-- end-user-doc -->
447
     * <!-- end-user-doc -->
449
     */
448
     */
(-)src/ordersystem/impl/InventoryItemImpl.java (-65 / +65 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 26-39 Link Here
26
26
27
import org.eclipse.emf.common.notify.Notification;
27
import org.eclipse.emf.common.notify.Notification;
28
import org.eclipse.emf.common.notify.NotificationChain;
28
import org.eclipse.emf.common.notify.NotificationChain;
29
30
import org.eclipse.emf.ecore.EClass;
29
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EStructuralFeature;
32
import org.eclipse.emf.ecore.InternalEObject;
30
import org.eclipse.emf.ecore.InternalEObject;
33
34
import org.eclipse.emf.ecore.impl.ENotificationImpl;
31
import org.eclipse.emf.ecore.impl.ENotificationImpl;
35
import org.eclipse.emf.ecore.impl.EObjectImpl;
32
import org.eclipse.emf.ecore.impl.EObjectImpl;
36
37
import org.eclipse.emf.ecore.util.EcoreUtil;
33
import org.eclipse.emf.ecore.util.EcoreUtil;
38
34
39
/**
35
/**
Lines 122-128 Link Here
122
	 * @generated
118
	 * @generated
123
	 * @ordered
119
	 * @ordered
124
	 */
120
	 */
125
    protected Product product = null;
121
    protected Product product;
126
122
127
	/**
123
	/**
128
	 * <!-- begin-user-doc -->
124
	 * <!-- begin-user-doc -->
Lines 138-145 Link Here
138
     * <!-- end-user-doc -->
134
     * <!-- end-user-doc -->
139
	 * @generated
135
	 * @generated
140
	 */
136
	 */
141
    protected EClass eStaticClass() {
137
    @Override
142
		return OrderSystemPackage.eINSTANCE.getInventoryItem();
138
				protected EClass eStaticClass() {
139
		return OrderSystemPackage.Literals.INVENTORY_ITEM;
143
	}
140
	}
144
141
145
	/**
142
	/**
Lines 212-218 Link Here
212
	 */
209
	 */
213
    public Warehouse getWarehouse() {
210
    public Warehouse getWarehouse() {
214
		if (eContainerFeatureID != OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE) return null;
211
		if (eContainerFeatureID != OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE) return null;
215
		return (Warehouse)eContainer;
212
		return (Warehouse)eContainer();
213
	}
214
215
	/**
216
	 * <!-- begin-user-doc -->
217
	 * <!-- end-user-doc -->
218
	 * @generated
219
	 */
220
	public NotificationChain basicSetWarehouse(Warehouse newWarehouse, NotificationChain msgs) {
221
		msgs = eBasicSetContainer((InternalEObject)newWarehouse, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE, msgs);
222
		return msgs;
216
	}
223
	}
217
224
218
	/**
225
	/**
Lines 221-235 Link Here
221
	 * @generated
228
	 * @generated
222
	 */
229
	 */
223
    public void setWarehouse(Warehouse newWarehouse) {
230
    public void setWarehouse(Warehouse newWarehouse) {
224
		if (newWarehouse != eContainer || (eContainerFeatureID != OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE && newWarehouse != null)) {
231
		if (newWarehouse != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE && newWarehouse != null)) {
225
			if (EcoreUtil.isAncestor(this, newWarehouse))
232
			if (EcoreUtil.isAncestor(this, newWarehouse))
226
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
233
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
227
			NotificationChain msgs = null;
234
			NotificationChain msgs = null;
228
			if (eContainer != null)
235
			if (eInternalContainer() != null)
229
				msgs = eBasicRemoveFromContainer(msgs);
236
				msgs = eBasicRemoveFromContainer(msgs);
230
			if (newWarehouse != null)
237
			if (newWarehouse != null)
231
				msgs = ((InternalEObject)newWarehouse).eInverseAdd(this, OrderSystemPackage.WAREHOUSE__ITEM, Warehouse.class, msgs);
238
				msgs = ((InternalEObject)newWarehouse).eInverseAdd(this, OrderSystemPackage.WAREHOUSE__ITEM, Warehouse.class, msgs);
232
			msgs = eBasicSetContainer((InternalEObject)newWarehouse, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE, msgs);
239
			msgs = basicSetWarehouse(newWarehouse, msgs);
233
			if (msgs != null) msgs.dispatch();
240
			if (msgs != null) msgs.dispatch();
234
		}
241
		}
235
		else if (eNotificationRequired())
242
		else if (eNotificationRequired())
Lines 243-250 Link Here
243
	 */
250
	 */
244
    public Product getProduct() {
251
    public Product getProduct() {
245
		if (product != null && product.eIsProxy()) {
252
		if (product != null && product.eIsProxy()) {
246
			Product oldProduct = product;
253
			InternalEObject oldProduct = (InternalEObject)product;
247
			product = (Product)eResolveProxy((InternalEObject)product);
254
			product = (Product)eResolveProxy(oldProduct);
248
			if (product != oldProduct) {
255
			if (product != oldProduct) {
249
				if (eNotificationRequired())
256
				if (eNotificationRequired())
250
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OrderSystemPackage.INVENTORY_ITEM__PRODUCT, oldProduct, product));
257
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OrderSystemPackage.INVENTORY_ITEM__PRODUCT, oldProduct, product));
Lines 276-341 Link Here
276
283
277
	/**
284
	/**
278
	 * <!-- begin-user-doc -->
285
	 * <!-- begin-user-doc -->
279
     * <!-- end-user-doc -->
286
	 * <!-- end-user-doc -->
280
	 * @generated
287
	 * @generated
281
	 */
288
	 */
282
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
289
	@Override
283
		if (featureID >= 0) {
290
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
284
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
291
		switch (featureID) {
285
				case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
292
			case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
286
					if (eContainer != null)
293
				if (eInternalContainer() != null)
287
						msgs = eBasicRemoveFromContainer(msgs);
294
					msgs = eBasicRemoveFromContainer(msgs);
288
					return eBasicSetContainer(otherEnd, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE, msgs);
295
				return basicSetWarehouse((Warehouse)otherEnd, msgs);
289
				default:
290
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
291
			}
292
		}
296
		}
293
		if (eContainer != null)
297
		return super.eInverseAdd(otherEnd, featureID, msgs);
294
			msgs = eBasicRemoveFromContainer(msgs);
295
		return eBasicSetContainer(otherEnd, featureID, msgs);
296
	}
298
	}
297
299
298
	/**
300
	/**
299
	 * <!-- begin-user-doc -->
301
	 * <!-- begin-user-doc -->
300
     * <!-- end-user-doc -->
302
	 * <!-- end-user-doc -->
301
	 * @generated
303
	 * @generated
302
	 */
304
	 */
303
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
305
	@Override
304
		if (featureID >= 0) {
306
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
305
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
307
		switch (featureID) {
306
				case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
308
			case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
307
					return eBasicSetContainer(null, OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE, msgs);
309
				return basicSetWarehouse(null, msgs);
308
				default:
309
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
310
			}
311
		}
310
		}
312
		return eBasicSetContainer(null, featureID, msgs);
311
		return super.eInverseRemove(otherEnd, featureID, msgs);
313
	}
312
	}
314
313
315
	/**
314
	/**
316
	 * <!-- begin-user-doc -->
315
	 * <!-- begin-user-doc -->
317
     * <!-- end-user-doc -->
316
	 * <!-- end-user-doc -->
318
	 * @generated
317
	 * @generated
319
	 */
318
	 */
320
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
319
	@Override
321
		if (eContainerFeatureID >= 0) {
320
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
322
			switch (eContainerFeatureID) {
321
		switch (eContainerFeatureID) {
323
				case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
322
			case OrderSystemPackage.INVENTORY_ITEM__WAREHOUSE:
324
					return (eContainer).eInverseRemove(this, OrderSystemPackage.WAREHOUSE__ITEM, Warehouse.class, msgs);
323
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.WAREHOUSE__ITEM, Warehouse.class, msgs);
325
				default:
326
					return eDynamicBasicRemoveFromContainer(msgs);
327
			}
328
		}
324
		}
329
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
325
		return super.eBasicRemoveFromContainerFeature(msgs);
330
	}
326
	}
331
327
332
	/**
328
	/**
333
	 * <!-- begin-user-doc -->
329
	 * <!-- begin-user-doc -->
334
     * <!-- end-user-doc -->
330
	 * <!-- end-user-doc -->
335
	 * @generated
331
	 * @generated
336
	 */
332
	 */
337
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
333
	@Override
338
		switch (eDerivedStructuralFeatureID(eFeature)) {
334
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
335
		switch (featureID) {
339
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
336
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
340
				return new Integer(getInStock());
337
				return new Integer(getInStock());
341
			case OrderSystemPackage.INVENTORY_ITEM__RESTOCK_THRESHOLD:
338
			case OrderSystemPackage.INVENTORY_ITEM__RESTOCK_THRESHOLD:
Lines 348-363 Link Here
348
				if (resolve) return getProduct();
345
				if (resolve) return getProduct();
349
				return basicGetProduct();
346
				return basicGetProduct();
350
		}
347
		}
351
		return eDynamicGet(eFeature, resolve);
348
		return super.eGet(featureID, resolve, coreType);
352
	}
349
	}
353
350
354
	/**
351
	/**
355
	 * <!-- begin-user-doc -->
352
	 * <!-- begin-user-doc -->
356
     * <!-- end-user-doc -->
353
	 * <!-- end-user-doc -->
357
	 * @generated
354
	 * @generated
358
	 */
355
	 */
359
    public void eSet(EStructuralFeature eFeature, Object newValue) {
356
	@Override
360
		switch (eDerivedStructuralFeatureID(eFeature)) {
357
	public void eSet(int featureID, Object newValue) {
358
		switch (featureID) {
361
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
359
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
362
				setInStock(((Integer)newValue).intValue());
360
				setInStock(((Integer)newValue).intValue());
363
				return;
361
				return;
Lines 374-389 Link Here
374
				setProduct((Product)newValue);
372
				setProduct((Product)newValue);
375
				return;
373
				return;
376
		}
374
		}
377
		eDynamicSet(eFeature, newValue);
375
		super.eSet(featureID, newValue);
378
	}
376
	}
379
377
380
	/**
378
	/**
381
	 * <!-- begin-user-doc -->
379
	 * <!-- begin-user-doc -->
382
     * <!-- end-user-doc -->
380
	 * <!-- end-user-doc -->
383
	 * @generated
381
	 * @generated
384
	 */
382
	 */
385
    public void eUnset(EStructuralFeature eFeature) {
383
	@Override
386
		switch (eDerivedStructuralFeatureID(eFeature)) {
384
	public void eUnset(int featureID) {
385
		switch (featureID) {
387
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
386
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
388
				setInStock(IN_STOCK_EDEFAULT);
387
				setInStock(IN_STOCK_EDEFAULT);
389
				return;
388
				return;
Lines 400-415 Link Here
400
				setProduct((Product)null);
399
				setProduct((Product)null);
401
				return;
400
				return;
402
		}
401
		}
403
		eDynamicUnset(eFeature);
402
		super.eUnset(featureID);
404
	}
403
	}
405
404
406
	/**
405
	/**
407
	 * <!-- begin-user-doc -->
406
	 * <!-- begin-user-doc -->
408
     * <!-- end-user-doc -->
407
	 * <!-- end-user-doc -->
409
	 * @generated
408
	 * @generated
410
	 */
409
	 */
411
    public boolean eIsSet(EStructuralFeature eFeature) {
410
	@Override
412
		switch (eDerivedStructuralFeatureID(eFeature)) {
411
	public boolean eIsSet(int featureID) {
412
		switch (featureID) {
413
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
413
			case OrderSystemPackage.INVENTORY_ITEM__IN_STOCK:
414
				return inStock != IN_STOCK_EDEFAULT;
414
				return inStock != IN_STOCK_EDEFAULT;
415
			case OrderSystemPackage.INVENTORY_ITEM__RESTOCK_THRESHOLD:
415
			case OrderSystemPackage.INVENTORY_ITEM__RESTOCK_THRESHOLD:
Lines 421-430 Link Here
421
			case OrderSystemPackage.INVENTORY_ITEM__PRODUCT:
421
			case OrderSystemPackage.INVENTORY_ITEM__PRODUCT:
422
				return product != null;
422
				return product != null;
423
		}
423
		}
424
		return eDynamicIsSet(eFeature);
424
		return super.eIsSet(featureID);
425
	}
425
	}
426
426
427
    /**
427
	/**
428
     * <!-- begin-user-doc -->
428
     * <!-- begin-user-doc -->
429
     * <!-- end-user-doc -->
429
     * <!-- end-user-doc -->
430
     */
430
     */
(-)src/ordersystem/impl/AddressImpl.java (-24 / +25 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-31 Link Here
18
package ordersystem.impl;
18
package ordersystem.impl;
19
19
20
import ordersystem.Address;
20
import ordersystem.Address;
21
22
import ordersystem.OrderSystemPackage;
21
import ordersystem.OrderSystemPackage;
23
22
24
import org.eclipse.emf.common.notify.Notification;
23
import org.eclipse.emf.common.notify.Notification;
25
26
import org.eclipse.emf.ecore.EClass;
24
import org.eclipse.emf.ecore.EClass;
27
import org.eclipse.emf.ecore.EStructuralFeature;
28
29
import org.eclipse.emf.ecore.impl.ENotificationImpl;
25
import org.eclipse.emf.ecore.impl.ENotificationImpl;
30
import org.eclipse.emf.ecore.impl.EObjectImpl;
26
import org.eclipse.emf.ecore.impl.EObjectImpl;
31
27
Lines 203-210 Link Here
203
     * <!-- end-user-doc -->
199
     * <!-- end-user-doc -->
204
	 * @generated
200
	 * @generated
205
	 */
201
	 */
206
    protected EClass eStaticClass() {
202
    @Override
207
		return OrderSystemPackage.eINSTANCE.getAddress();
203
				protected EClass eStaticClass() {
204
		return OrderSystemPackage.Literals.ADDRESS;
208
	}
205
	}
209
206
210
	/**
207
	/**
Lines 356-366 Link Here
356
353
357
	/**
354
	/**
358
	 * <!-- begin-user-doc -->
355
	 * <!-- begin-user-doc -->
359
     * <!-- end-user-doc -->
356
	 * <!-- end-user-doc -->
360
	 * @generated
357
	 * @generated
361
	 */
358
	 */
362
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
359
	@Override
363
		switch (eDerivedStructuralFeatureID(eFeature)) {
360
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
361
		switch (featureID) {
364
			case OrderSystemPackage.ADDRESS__NUMBER:
362
			case OrderSystemPackage.ADDRESS__NUMBER:
365
				return getNumber();
363
				return getNumber();
366
			case OrderSystemPackage.ADDRESS__STREET:
364
			case OrderSystemPackage.ADDRESS__STREET:
Lines 376-391 Link Here
376
			case OrderSystemPackage.ADDRESS__COUNTRY:
374
			case OrderSystemPackage.ADDRESS__COUNTRY:
377
				return getCountry();
375
				return getCountry();
378
		}
376
		}
379
		return eDynamicGet(eFeature, resolve);
377
		return super.eGet(featureID, resolve, coreType);
380
	}
378
	}
381
379
382
	/**
380
	/**
383
	 * <!-- begin-user-doc -->
381
	 * <!-- begin-user-doc -->
384
     * <!-- end-user-doc -->
382
	 * <!-- end-user-doc -->
385
	 * @generated
383
	 * @generated
386
	 */
384
	 */
387
    public void eSet(EStructuralFeature eFeature, Object newValue) {
385
	@Override
388
		switch (eDerivedStructuralFeatureID(eFeature)) {
386
	public void eSet(int featureID, Object newValue) {
387
		switch (featureID) {
389
			case OrderSystemPackage.ADDRESS__NUMBER:
388
			case OrderSystemPackage.ADDRESS__NUMBER:
390
				setNumber((String)newValue);
389
				setNumber((String)newValue);
391
				return;
390
				return;
Lines 408-423 Link Here
408
				setCountry((String)newValue);
407
				setCountry((String)newValue);
409
				return;
408
				return;
410
		}
409
		}
411
		eDynamicSet(eFeature, newValue);
410
		super.eSet(featureID, newValue);
412
	}
411
	}
413
412
414
	/**
413
	/**
415
	 * <!-- begin-user-doc -->
414
	 * <!-- begin-user-doc -->
416
     * <!-- end-user-doc -->
415
	 * <!-- end-user-doc -->
417
	 * @generated
416
	 * @generated
418
	 */
417
	 */
419
    public void eUnset(EStructuralFeature eFeature) {
418
	@Override
420
		switch (eDerivedStructuralFeatureID(eFeature)) {
419
	public void eUnset(int featureID) {
420
		switch (featureID) {
421
			case OrderSystemPackage.ADDRESS__NUMBER:
421
			case OrderSystemPackage.ADDRESS__NUMBER:
422
				setNumber(NUMBER_EDEFAULT);
422
				setNumber(NUMBER_EDEFAULT);
423
				return;
423
				return;
Lines 440-455 Link Here
440
				setCountry(COUNTRY_EDEFAULT);
440
				setCountry(COUNTRY_EDEFAULT);
441
				return;
441
				return;
442
		}
442
		}
443
		eDynamicUnset(eFeature);
443
		super.eUnset(featureID);
444
	}
444
	}
445
445
446
	/**
446
	/**
447
	 * <!-- begin-user-doc -->
447
	 * <!-- begin-user-doc -->
448
     * <!-- end-user-doc -->
448
	 * <!-- end-user-doc -->
449
	 * @generated
449
	 * @generated
450
	 */
450
	 */
451
    public boolean eIsSet(EStructuralFeature eFeature) {
451
	@Override
452
		switch (eDerivedStructuralFeatureID(eFeature)) {
452
	public boolean eIsSet(int featureID) {
453
		switch (featureID) {
453
			case OrderSystemPackage.ADDRESS__NUMBER:
454
			case OrderSystemPackage.ADDRESS__NUMBER:
454
				return NUMBER_EDEFAULT == null ? number != null : !NUMBER_EDEFAULT.equals(number);
455
				return NUMBER_EDEFAULT == null ? number != null : !NUMBER_EDEFAULT.equals(number);
455
			case OrderSystemPackage.ADDRESS__STREET:
456
			case OrderSystemPackage.ADDRESS__STREET:
Lines 465-474 Link Here
465
			case OrderSystemPackage.ADDRESS__COUNTRY:
466
			case OrderSystemPackage.ADDRESS__COUNTRY:
466
				return COUNTRY_EDEFAULT == null ? country != null : !COUNTRY_EDEFAULT.equals(country);
467
				return COUNTRY_EDEFAULT == null ? country != null : !COUNTRY_EDEFAULT.equals(country);
467
		}
468
		}
468
		return eDynamicIsSet(eFeature);
469
		return super.eIsSet(featureID);
469
	}
470
	}
470
471
471
    /**
472
	/**
472
     * <!-- begin-user-doc -->
473
     * <!-- begin-user-doc -->
473
     * <!-- end-user-doc -->
474
     * <!-- end-user-doc -->
474
     */
475
     */
(-)src/ordersystem/impl/LineItemImpl.java (-71 / +71 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-37 Link Here
24
24
25
import org.eclipse.emf.common.notify.Notification;
25
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.NotificationChain;
26
import org.eclipse.emf.common.notify.NotificationChain;
27
28
import org.eclipse.emf.ecore.EClass;
27
import org.eclipse.emf.ecore.EClass;
29
import org.eclipse.emf.ecore.EStructuralFeature;
30
import org.eclipse.emf.ecore.InternalEObject;
28
import org.eclipse.emf.ecore.InternalEObject;
31
32
import org.eclipse.emf.ecore.impl.ENotificationImpl;
29
import org.eclipse.emf.ecore.impl.ENotificationImpl;
33
import org.eclipse.emf.ecore.impl.EObjectImpl;
30
import org.eclipse.emf.ecore.impl.EObjectImpl;
34
35
import org.eclipse.emf.ecore.util.EcoreUtil;
31
import org.eclipse.emf.ecore.util.EcoreUtil;
36
32
37
/**
33
/**
Lines 99-105 Link Here
99
	 * @generated
95
	 * @generated
100
	 * @ordered
96
	 * @ordered
101
	 */
97
	 */
102
    protected Product product = null;
98
    protected Product product;
103
99
104
	/**
100
	/**
105
	 * <!-- begin-user-doc -->
101
	 * <!-- begin-user-doc -->
Lines 115-122 Link Here
115
     * <!-- end-user-doc -->
111
     * <!-- end-user-doc -->
116
	 * @generated
112
	 * @generated
117
	 */
113
	 */
118
    protected EClass eStaticClass() {
114
    @Override
119
		return OrderSystemPackage.eINSTANCE.getLineItem();
115
				protected EClass eStaticClass() {
116
		return OrderSystemPackage.Literals.LINE_ITEM;
120
	}
117
	}
121
118
122
	/**
119
	/**
Lines 168-174 Link Here
168
	 */
165
	 */
169
    public Order getOwner() {
166
    public Order getOwner() {
170
		if (eContainerFeatureID != OrderSystemPackage.LINE_ITEM__OWNER) return null;
167
		if (eContainerFeatureID != OrderSystemPackage.LINE_ITEM__OWNER) return null;
171
		return (Order)eContainer;
168
		return (Order)eContainer();
169
	}
170
171
	/**
172
	 * <!-- begin-user-doc -->
173
	 * <!-- end-user-doc -->
174
	 * @generated
175
	 */
176
	public NotificationChain basicSetOwner(Order newOwner, NotificationChain msgs) {
177
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.LINE_ITEM__OWNER, msgs);
178
		return msgs;
172
	}
179
	}
173
180
174
	/**
181
	/**
Lines 177-191 Link Here
177
	 * @generated
184
	 * @generated
178
	 */
185
	 */
179
    public void setOwner(Order newOwner) {
186
    public void setOwner(Order newOwner) {
180
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.LINE_ITEM__OWNER && newOwner != null)) {
187
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.LINE_ITEM__OWNER && newOwner != null)) {
181
			if (EcoreUtil.isAncestor(this, newOwner))
188
			if (EcoreUtil.isAncestor(this, newOwner))
182
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
189
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
183
			NotificationChain msgs = null;
190
			NotificationChain msgs = null;
184
			if (eContainer != null)
191
			if (eInternalContainer() != null)
185
				msgs = eBasicRemoveFromContainer(msgs);
192
				msgs = eBasicRemoveFromContainer(msgs);
186
			if (newOwner != null)
193
			if (newOwner != null)
187
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER__ITEM, Order.class, msgs);
194
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER__ITEM, Order.class, msgs);
188
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.LINE_ITEM__OWNER, msgs);
195
			msgs = basicSetOwner(newOwner, msgs);
189
			if (msgs != null) msgs.dispatch();
196
			if (msgs != null) msgs.dispatch();
190
		}
197
		}
191
		else if (eNotificationRequired())
198
		else if (eNotificationRequired())
Lines 199-206 Link Here
199
	 */
206
	 */
200
    public Product getProduct() {
207
    public Product getProduct() {
201
		if (product != null && product.eIsProxy()) {
208
		if (product != null && product.eIsProxy()) {
202
			Product oldProduct = product;
209
			InternalEObject oldProduct = (InternalEObject)product;
203
			product = (Product)eResolveProxy((InternalEObject)product);
210
			product = (Product)eResolveProxy(oldProduct);
204
			if (product != oldProduct) {
211
			if (product != oldProduct) {
205
				if (eNotificationRequired())
212
				if (eNotificationRequired())
206
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OrderSystemPackage.LINE_ITEM__PRODUCT, oldProduct, product));
213
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OrderSystemPackage.LINE_ITEM__PRODUCT, oldProduct, product));
Lines 244-309 Link Here
244
251
245
	/**
252
	/**
246
	 * <!-- begin-user-doc -->
253
	 * <!-- begin-user-doc -->
247
     * <!-- end-user-doc -->
254
	 * <!-- end-user-doc -->
248
	 * @generated
255
	 * @generated
249
	 */
256
	 */
250
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
257
	@Override
251
		if (featureID >= 0) {
258
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
252
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
259
		switch (featureID) {
253
				case OrderSystemPackage.LINE_ITEM__OWNER:
260
			case OrderSystemPackage.LINE_ITEM__OWNER:
254
					if (eContainer != null)
261
				if (eInternalContainer() != null)
255
						msgs = eBasicRemoveFromContainer(msgs);
262
					msgs = eBasicRemoveFromContainer(msgs);
256
					return eBasicSetContainer(otherEnd, OrderSystemPackage.LINE_ITEM__OWNER, msgs);
263
				return basicSetOwner((Order)otherEnd, msgs);
257
				default:
258
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
259
			}
260
		}
264
		}
261
		if (eContainer != null)
265
		return super.eInverseAdd(otherEnd, featureID, msgs);
262
			msgs = eBasicRemoveFromContainer(msgs);
263
		return eBasicSetContainer(otherEnd, featureID, msgs);
264
	}
266
	}
265
267
266
	/**
268
				/**
267
	 * <!-- begin-user-doc -->
269
	 * <!-- begin-user-doc -->
268
     * <!-- end-user-doc -->
270
	 * <!-- end-user-doc -->
269
	 * @generated
271
	 * @generated
270
	 */
272
	 */
271
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
273
	@Override
272
		if (featureID >= 0) {
274
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
273
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
275
		switch (featureID) {
274
				case OrderSystemPackage.LINE_ITEM__OWNER:
276
			case OrderSystemPackage.LINE_ITEM__OWNER:
275
					return eBasicSetContainer(null, OrderSystemPackage.LINE_ITEM__OWNER, msgs);
277
				return basicSetOwner(null, msgs);
276
				default:
277
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
278
			}
279
		}
278
		}
280
		return eBasicSetContainer(null, featureID, msgs);
279
		return super.eInverseRemove(otherEnd, featureID, msgs);
281
	}
280
	}
282
281
283
	/**
282
				/**
284
	 * <!-- begin-user-doc -->
283
	 * <!-- begin-user-doc -->
285
     * <!-- end-user-doc -->
284
	 * <!-- end-user-doc -->
286
	 * @generated
285
	 * @generated
287
	 */
286
	 */
288
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
287
	@Override
289
		if (eContainerFeatureID >= 0) {
288
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
290
			switch (eContainerFeatureID) {
289
		switch (eContainerFeatureID) {
291
				case OrderSystemPackage.LINE_ITEM__OWNER:
290
			case OrderSystemPackage.LINE_ITEM__OWNER:
292
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER__ITEM, Order.class, msgs);
291
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.ORDER__ITEM, Order.class, msgs);
293
				default:
294
					return eDynamicBasicRemoveFromContainer(msgs);
295
			}
296
		}
292
		}
297
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
293
		return super.eBasicRemoveFromContainerFeature(msgs);
298
	}
294
	}
299
295
300
	/**
296
				/**
301
	 * <!-- begin-user-doc -->
297
	 * <!-- begin-user-doc -->
302
     * <!-- end-user-doc -->
298
	 * <!-- end-user-doc -->
303
	 * @generated
299
	 * @generated
304
	 */
300
	 */
305
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
301
	@Override
306
		switch (eDerivedStructuralFeatureID(eFeature)) {
302
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
303
		switch (featureID) {
307
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
304
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
308
				return new Integer(getQuantity());
305
				return new Integer(getQuantity());
309
			case OrderSystemPackage.LINE_ITEM__DISCOUNT:
306
			case OrderSystemPackage.LINE_ITEM__DISCOUNT:
Lines 314-329 Link Here
314
				if (resolve) return getProduct();
311
				if (resolve) return getProduct();
315
				return basicGetProduct();
312
				return basicGetProduct();
316
		}
313
		}
317
		return eDynamicGet(eFeature, resolve);
314
		return super.eGet(featureID, resolve, coreType);
318
	}
315
	}
319
316
320
	/**
317
				/**
321
	 * <!-- begin-user-doc -->
318
	 * <!-- begin-user-doc -->
322
     * <!-- end-user-doc -->
319
	 * <!-- end-user-doc -->
323
	 * @generated
320
	 * @generated
324
	 */
321
	 */
325
    public void eSet(EStructuralFeature eFeature, Object newValue) {
322
	@Override
326
		switch (eDerivedStructuralFeatureID(eFeature)) {
323
	public void eSet(int featureID, Object newValue) {
324
		switch (featureID) {
327
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
325
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
328
				setQuantity(((Integer)newValue).intValue());
326
				setQuantity(((Integer)newValue).intValue());
329
				return;
327
				return;
Lines 337-352 Link Here
337
				setProduct((Product)newValue);
335
				setProduct((Product)newValue);
338
				return;
336
				return;
339
		}
337
		}
340
		eDynamicSet(eFeature, newValue);
338
		super.eSet(featureID, newValue);
341
	}
339
	}
342
340
343
	/**
341
				/**
344
	 * <!-- begin-user-doc -->
342
	 * <!-- begin-user-doc -->
345
     * <!-- end-user-doc -->
343
	 * <!-- end-user-doc -->
346
	 * @generated
344
	 * @generated
347
	 */
345
	 */
348
    public void eUnset(EStructuralFeature eFeature) {
346
	@Override
349
		switch (eDerivedStructuralFeatureID(eFeature)) {
347
	public void eUnset(int featureID) {
348
		switch (featureID) {
350
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
349
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
351
				setQuantity(QUANTITY_EDEFAULT);
350
				setQuantity(QUANTITY_EDEFAULT);
352
				return;
351
				return;
Lines 360-375 Link Here
360
				setProduct((Product)null);
359
				setProduct((Product)null);
361
				return;
360
				return;
362
		}
361
		}
363
		eDynamicUnset(eFeature);
362
		super.eUnset(featureID);
364
	}
363
	}
365
364
366
	/**
365
				/**
367
	 * <!-- begin-user-doc -->
366
	 * <!-- begin-user-doc -->
368
     * <!-- end-user-doc -->
367
	 * <!-- end-user-doc -->
369
	 * @generated
368
	 * @generated
370
	 */
369
	 */
371
    public boolean eIsSet(EStructuralFeature eFeature) {
370
	@Override
372
		switch (eDerivedStructuralFeatureID(eFeature)) {
371
	public boolean eIsSet(int featureID) {
372
		switch (featureID) {
373
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
373
			case OrderSystemPackage.LINE_ITEM__QUANTITY:
374
				return quantity != QUANTITY_EDEFAULT;
374
				return quantity != QUANTITY_EDEFAULT;
375
			case OrderSystemPackage.LINE_ITEM__DISCOUNT:
375
			case OrderSystemPackage.LINE_ITEM__DISCOUNT:
Lines 379-388 Link Here
379
			case OrderSystemPackage.LINE_ITEM__PRODUCT:
379
			case OrderSystemPackage.LINE_ITEM__PRODUCT:
380
				return product != null;
380
				return product != null;
381
		}
381
		}
382
		return eDynamicIsSet(eFeature);
382
		return super.eIsSet(featureID);
383
	}
383
	}
384
384
385
    /**
385
	/**
386
     * <!-- begin-user-doc -->
386
     * <!-- begin-user-doc -->
387
     * <!-- end-user-doc -->
387
     * <!-- end-user-doc -->
388
     */
388
     */
(-)src/ordersystem/impl/CustomerImpl.java (-80 / +80 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 23-43 Link Here
23
import ordersystem.Customer;
23
import ordersystem.Customer;
24
import ordersystem.Order;
24
import ordersystem.Order;
25
import ordersystem.OrderSystem;
25
import ordersystem.OrderSystem;
26
27
import ordersystem.OrderSystemPackage;
26
import ordersystem.OrderSystemPackage;
28
27
29
import org.eclipse.emf.common.notify.Notification;
28
import org.eclipse.emf.common.notify.Notification;
30
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.NotificationChain;
31
32
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
33
34
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EClass;
35
import org.eclipse.emf.ecore.EStructuralFeature;
36
import org.eclipse.emf.ecore.InternalEObject;
32
import org.eclipse.emf.ecore.InternalEObject;
37
38
import org.eclipse.emf.ecore.impl.ENotificationImpl;
33
import org.eclipse.emf.ecore.impl.ENotificationImpl;
39
import org.eclipse.emf.ecore.impl.EObjectImpl;
34
import org.eclipse.emf.ecore.impl.EObjectImpl;
40
41
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
35
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
42
import org.eclipse.emf.ecore.util.EcoreUtil;
36
import org.eclipse.emf.ecore.util.EcoreUtil;
43
import org.eclipse.emf.ecore.util.InternalEList;
37
import org.eclipse.emf.ecore.util.InternalEList;
Lines 108-114 Link Here
108
	 * @generated
102
	 * @generated
109
	 * @ordered
103
	 * @ordered
110
	 */
104
	 */
111
    protected EList account = null;
105
    protected EList<Account> account;
112
106
113
	/**
107
	/**
114
	 * The cached value of the '{@link #getOrder() <em>Order</em>}' containment reference list.
108
	 * The cached value of the '{@link #getOrder() <em>Order</em>}' containment reference list.
Lines 118-124 Link Here
118
	 * @generated
112
	 * @generated
119
	 * @ordered
113
	 * @ordered
120
	 */
114
	 */
121
    protected EList order = null;
115
    protected EList<Order> order;
122
116
123
	/**
117
	/**
124
	 * <!-- begin-user-doc -->
118
	 * <!-- begin-user-doc -->
Lines 134-141 Link Here
134
     * <!-- end-user-doc -->
128
     * <!-- end-user-doc -->
135
	 * @generated
129
	 * @generated
136
	 */
130
	 */
137
    protected EClass eStaticClass() {
131
    @Override
138
		return OrderSystemPackage.eINSTANCE.getCustomer();
132
				protected EClass eStaticClass() {
133
		return OrderSystemPackage.Literals.CUSTOMER;
139
	}
134
	}
140
135
141
	/**
136
	/**
Lines 187-193 Link Here
187
	 */
182
	 */
188
    public OrderSystem getOwner() {
183
    public OrderSystem getOwner() {
189
		if (eContainerFeatureID != OrderSystemPackage.CUSTOMER__OWNER) return null;
184
		if (eContainerFeatureID != OrderSystemPackage.CUSTOMER__OWNER) return null;
190
		return (OrderSystem)eContainer;
185
		return (OrderSystem)eContainer();
186
	}
187
188
	/**
189
	 * <!-- begin-user-doc -->
190
	 * <!-- end-user-doc -->
191
	 * @generated
192
	 */
193
	public NotificationChain basicSetOwner(OrderSystem newOwner, NotificationChain msgs) {
194
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.CUSTOMER__OWNER, msgs);
195
		return msgs;
191
	}
196
	}
192
197
193
	/**
198
	/**
Lines 196-210 Link Here
196
	 * @generated
201
	 * @generated
197
	 */
202
	 */
198
    public void setOwner(OrderSystem newOwner) {
203
    public void setOwner(OrderSystem newOwner) {
199
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.CUSTOMER__OWNER && newOwner != null)) {
204
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.CUSTOMER__OWNER && newOwner != null)) {
200
			if (EcoreUtil.isAncestor(this, newOwner))
205
			if (EcoreUtil.isAncestor(this, newOwner))
201
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
206
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
202
			NotificationChain msgs = null;
207
			NotificationChain msgs = null;
203
			if (eContainer != null)
208
			if (eInternalContainer() != null)
204
				msgs = eBasicRemoveFromContainer(msgs);
209
				msgs = eBasicRemoveFromContainer(msgs);
205
			if (newOwner != null)
210
			if (newOwner != null)
206
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystem.class, msgs);
211
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystem.class, msgs);
207
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.CUSTOMER__OWNER, msgs);
212
			msgs = basicSetOwner(newOwner, msgs);
208
			if (msgs != null) msgs.dispatch();
213
			if (msgs != null) msgs.dispatch();
209
		}
214
		}
210
		else if (eNotificationRequired())
215
		else if (eNotificationRequired())
Lines 216-224 Link Here
216
     * <!-- end-user-doc -->
221
     * <!-- end-user-doc -->
217
	 * @generated
222
	 * @generated
218
	 */
223
	 */
219
    public EList getAccount() {
224
    public EList<Account> getAccount() {
220
		if (account == null) {
225
		if (account == null) {
221
			account = new EObjectContainmentWithInverseEList(Account.class, this, OrderSystemPackage.CUSTOMER__ACCOUNT, OrderSystemPackage.ACCOUNT__OWNER);
226
			account = new EObjectContainmentWithInverseEList<Account>(Account.class, this, OrderSystemPackage.CUSTOMER__ACCOUNT, OrderSystemPackage.ACCOUNT__OWNER);
222
		}
227
		}
223
		return account;
228
		return account;
224
	}
229
	}
Lines 228-310 Link Here
228
     * <!-- end-user-doc -->
233
     * <!-- end-user-doc -->
229
	 * @generated
234
	 * @generated
230
	 */
235
	 */
231
    public EList getOrder() {
236
    public EList<Order> getOrder() {
232
		if (order == null) {
237
		if (order == null) {
233
			order = new EObjectContainmentWithInverseEList(Order.class, this, OrderSystemPackage.CUSTOMER__ORDER, OrderSystemPackage.ORDER__OWNER);
238
			order = new EObjectContainmentWithInverseEList<Order>(Order.class, this, OrderSystemPackage.CUSTOMER__ORDER, OrderSystemPackage.ORDER__OWNER);
234
		}
239
		}
235
		return order;
240
		return order;
236
	}
241
	}
237
242
238
	/**
243
	/**
239
	 * <!-- begin-user-doc -->
244
	 * <!-- begin-user-doc -->
240
     * <!-- end-user-doc -->
245
	 * <!-- end-user-doc -->
241
	 * @generated
246
	 * @generated
242
	 */
247
	 */
243
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
248
	@SuppressWarnings("unchecked")
244
		if (featureID >= 0) {
249
		@Override
245
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
250
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
246
				case OrderSystemPackage.CUSTOMER__OWNER:
251
		switch (featureID) {
247
					if (eContainer != null)
252
			case OrderSystemPackage.CUSTOMER__OWNER:
248
						msgs = eBasicRemoveFromContainer(msgs);
253
				if (eInternalContainer() != null)
249
					return eBasicSetContainer(otherEnd, OrderSystemPackage.CUSTOMER__OWNER, msgs);
254
					msgs = eBasicRemoveFromContainer(msgs);
250
				case OrderSystemPackage.CUSTOMER__ACCOUNT:
255
				return basicSetOwner((OrderSystem)otherEnd, msgs);
251
					return ((InternalEList)getAccount()).basicAdd(otherEnd, msgs);
256
			case OrderSystemPackage.CUSTOMER__ACCOUNT:
252
				case OrderSystemPackage.CUSTOMER__ORDER:
257
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getAccount()).basicAdd(otherEnd, msgs);
253
					return ((InternalEList)getOrder()).basicAdd(otherEnd, msgs);
258
			case OrderSystemPackage.CUSTOMER__ORDER:
254
				default:
259
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getOrder()).basicAdd(otherEnd, msgs);
255
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
256
			}
257
		}
260
		}
258
		if (eContainer != null)
261
		return super.eInverseAdd(otherEnd, featureID, msgs);
259
			msgs = eBasicRemoveFromContainer(msgs);
260
		return eBasicSetContainer(otherEnd, featureID, msgs);
261
	}
262
	}
262
263
263
	/**
264
	/**
264
	 * <!-- begin-user-doc -->
265
	 * <!-- begin-user-doc -->
265
     * <!-- end-user-doc -->
266
	 * <!-- end-user-doc -->
266
	 * @generated
267
	 * @generated
267
	 */
268
	 */
268
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
269
	@Override
269
		if (featureID >= 0) {
270
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
270
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
271
		switch (featureID) {
271
				case OrderSystemPackage.CUSTOMER__OWNER:
272
			case OrderSystemPackage.CUSTOMER__OWNER:
272
					return eBasicSetContainer(null, OrderSystemPackage.CUSTOMER__OWNER, msgs);
273
				return basicSetOwner(null, msgs);
273
				case OrderSystemPackage.CUSTOMER__ACCOUNT:
274
			case OrderSystemPackage.CUSTOMER__ACCOUNT:
274
					return ((InternalEList)getAccount()).basicRemove(otherEnd, msgs);
275
				return ((InternalEList<?>)getAccount()).basicRemove(otherEnd, msgs);
275
				case OrderSystemPackage.CUSTOMER__ORDER:
276
			case OrderSystemPackage.CUSTOMER__ORDER:
276
					return ((InternalEList)getOrder()).basicRemove(otherEnd, msgs);
277
				return ((InternalEList<?>)getOrder()).basicRemove(otherEnd, msgs);
277
				default:
278
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
279
			}
280
		}
278
		}
281
		return eBasicSetContainer(null, featureID, msgs);
279
		return super.eInverseRemove(otherEnd, featureID, msgs);
282
	}
280
	}
283
281
284
	/**
282
	/**
285
	 * <!-- begin-user-doc -->
283
	 * <!-- begin-user-doc -->
286
     * <!-- end-user-doc -->
284
	 * <!-- end-user-doc -->
287
	 * @generated
285
	 * @generated
288
	 */
286
	 */
289
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
287
	@Override
290
		if (eContainerFeatureID >= 0) {
288
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
291
			switch (eContainerFeatureID) {
289
		switch (eContainerFeatureID) {
292
				case OrderSystemPackage.CUSTOMER__OWNER:
290
			case OrderSystemPackage.CUSTOMER__OWNER:
293
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystem.class, msgs);
291
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystem.class, msgs);
294
				default:
295
					return eDynamicBasicRemoveFromContainer(msgs);
296
			}
297
		}
292
		}
298
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
293
		return super.eBasicRemoveFromContainerFeature(msgs);
299
	}
294
	}
300
295
301
	/**
296
	/**
302
	 * <!-- begin-user-doc -->
297
	 * <!-- begin-user-doc -->
303
     * <!-- end-user-doc -->
298
	 * <!-- end-user-doc -->
304
	 * @generated
299
	 * @generated
305
	 */
300
	 */
306
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
301
	@Override
307
		switch (eDerivedStructuralFeatureID(eFeature)) {
302
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
303
		switch (featureID) {
308
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
304
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
309
				return getLastName();
305
				return getLastName();
310
			case OrderSystemPackage.CUSTOMER__FIRST_NAME:
306
			case OrderSystemPackage.CUSTOMER__FIRST_NAME:
Lines 316-331 Link Here
316
			case OrderSystemPackage.CUSTOMER__ORDER:
312
			case OrderSystemPackage.CUSTOMER__ORDER:
317
				return getOrder();
313
				return getOrder();
318
		}
314
		}
319
		return eDynamicGet(eFeature, resolve);
315
		return super.eGet(featureID, resolve, coreType);
320
	}
316
	}
321
317
322
	/**
318
	/**
323
	 * <!-- begin-user-doc -->
319
	 * <!-- begin-user-doc -->
324
     * <!-- end-user-doc -->
320
	 * <!-- end-user-doc -->
325
	 * @generated
321
	 * @generated
326
	 */
322
	 */
327
    public void eSet(EStructuralFeature eFeature, Object newValue) {
323
	@SuppressWarnings("unchecked")
328
		switch (eDerivedStructuralFeatureID(eFeature)) {
324
		@Override
325
	public void eSet(int featureID, Object newValue) {
326
		switch (featureID) {
329
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
327
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
330
				setLastName((String)newValue);
328
				setLastName((String)newValue);
331
				return;
329
				return;
Lines 337-359 Link Here
337
				return;
335
				return;
338
			case OrderSystemPackage.CUSTOMER__ACCOUNT:
336
			case OrderSystemPackage.CUSTOMER__ACCOUNT:
339
				getAccount().clear();
337
				getAccount().clear();
340
				getAccount().addAll((Collection)newValue);
338
				getAccount().addAll((Collection<? extends Account>)newValue);
341
				return;
339
				return;
342
			case OrderSystemPackage.CUSTOMER__ORDER:
340
			case OrderSystemPackage.CUSTOMER__ORDER:
343
				getOrder().clear();
341
				getOrder().clear();
344
				getOrder().addAll((Collection)newValue);
342
				getOrder().addAll((Collection<? extends Order>)newValue);
345
				return;
343
				return;
346
		}
344
		}
347
		eDynamicSet(eFeature, newValue);
345
		super.eSet(featureID, newValue);
348
	}
346
	}
349
347
350
	/**
348
	/**
351
	 * <!-- begin-user-doc -->
349
	 * <!-- begin-user-doc -->
352
     * <!-- end-user-doc -->
350
	 * <!-- end-user-doc -->
353
	 * @generated
351
	 * @generated
354
	 */
352
	 */
355
    public void eUnset(EStructuralFeature eFeature) {
353
	@Override
356
		switch (eDerivedStructuralFeatureID(eFeature)) {
354
	public void eUnset(int featureID) {
355
		switch (featureID) {
357
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
356
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
358
				setLastName(LAST_NAME_EDEFAULT);
357
				setLastName(LAST_NAME_EDEFAULT);
359
				return;
358
				return;
Lines 370-385 Link Here
370
				getOrder().clear();
369
				getOrder().clear();
371
				return;
370
				return;
372
		}
371
		}
373
		eDynamicUnset(eFeature);
372
		super.eUnset(featureID);
374
	}
373
	}
375
374
376
	/**
375
	/**
377
	 * <!-- begin-user-doc -->
376
	 * <!-- begin-user-doc -->
378
     * <!-- end-user-doc -->
377
	 * <!-- end-user-doc -->
379
	 * @generated
378
	 * @generated
380
	 */
379
	 */
381
    public boolean eIsSet(EStructuralFeature eFeature) {
380
	@Override
382
		switch (eDerivedStructuralFeatureID(eFeature)) {
381
	public boolean eIsSet(int featureID) {
382
		switch (featureID) {
383
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
383
			case OrderSystemPackage.CUSTOMER__LAST_NAME:
384
				return LAST_NAME_EDEFAULT == null ? lastName != null : !LAST_NAME_EDEFAULT.equals(lastName);
384
				return LAST_NAME_EDEFAULT == null ? lastName != null : !LAST_NAME_EDEFAULT.equals(lastName);
385
			case OrderSystemPackage.CUSTOMER__FIRST_NAME:
385
			case OrderSystemPackage.CUSTOMER__FIRST_NAME:
Lines 391-400 Link Here
391
			case OrderSystemPackage.CUSTOMER__ORDER:
391
			case OrderSystemPackage.CUSTOMER__ORDER:
392
				return order != null && !order.isEmpty();
392
				return order != null && !order.isEmpty();
393
		}
393
		}
394
		return eDynamicIsSet(eFeature);
394
		return super.eIsSet(featureID);
395
	}
395
	}
396
396
397
    /**
397
	/**
398
     * <!-- begin-user-doc -->
398
     * <!-- begin-user-doc -->
399
     * <!-- end-user-doc -->
399
     * <!-- end-user-doc -->
400
     */
400
     */
(-)src/ordersystem/impl/ProductImpl.java (-62 / +62 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 23-36 Link Here
23
23
24
import org.eclipse.emf.common.notify.Notification;
24
import org.eclipse.emf.common.notify.Notification;
25
import org.eclipse.emf.common.notify.NotificationChain;
25
import org.eclipse.emf.common.notify.NotificationChain;
26
27
import org.eclipse.emf.ecore.EClass;
26
import org.eclipse.emf.ecore.EClass;
28
import org.eclipse.emf.ecore.EStructuralFeature;
29
import org.eclipse.emf.ecore.InternalEObject;
27
import org.eclipse.emf.ecore.InternalEObject;
30
31
import org.eclipse.emf.ecore.impl.ENotificationImpl;
28
import org.eclipse.emf.ecore.impl.ENotificationImpl;
32
import org.eclipse.emf.ecore.impl.EObjectImpl;
29
import org.eclipse.emf.ecore.impl.EObjectImpl;
33
34
import org.eclipse.emf.ecore.util.EcoreUtil;
30
import org.eclipse.emf.ecore.util.EcoreUtil;
35
31
36
/**
32
/**
Lines 124-131 Link Here
124
     * <!-- end-user-doc -->
120
     * <!-- end-user-doc -->
125
	 * @generated
121
	 * @generated
126
	 */
122
	 */
127
    protected EClass eStaticClass() {
123
    @Override
128
		return OrderSystemPackage.eINSTANCE.getProduct();
124
				protected EClass eStaticClass() {
125
		return OrderSystemPackage.Literals.PRODUCT;
129
	}
126
	}
130
127
131
	/**
128
	/**
Lines 198-204 Link Here
198
	 */
195
	 */
199
    public OrderSystem getOwner() {
196
    public OrderSystem getOwner() {
200
		if (eContainerFeatureID != OrderSystemPackage.PRODUCT__OWNER) return null;
197
		if (eContainerFeatureID != OrderSystemPackage.PRODUCT__OWNER) return null;
201
		return (OrderSystem)eContainer;
198
		return (OrderSystem)eContainer();
199
	}
200
201
	/**
202
	 * <!-- begin-user-doc -->
203
	 * <!-- end-user-doc -->
204
	 * @generated
205
	 */
206
	public NotificationChain basicSetOwner(OrderSystem newOwner, NotificationChain msgs) {
207
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.PRODUCT__OWNER, msgs);
208
		return msgs;
202
	}
209
	}
203
210
204
	/**
211
	/**
Lines 207-221 Link Here
207
	 * @generated
214
	 * @generated
208
	 */
215
	 */
209
    public void setOwner(OrderSystem newOwner) {
216
    public void setOwner(OrderSystem newOwner) {
210
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.PRODUCT__OWNER && newOwner != null)) {
217
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.PRODUCT__OWNER && newOwner != null)) {
211
			if (EcoreUtil.isAncestor(this, newOwner))
218
			if (EcoreUtil.isAncestor(this, newOwner))
212
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
219
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
213
			NotificationChain msgs = null;
220
			NotificationChain msgs = null;
214
			if (eContainer != null)
221
			if (eInternalContainer() != null)
215
				msgs = eBasicRemoveFromContainer(msgs);
222
				msgs = eBasicRemoveFromContainer(msgs);
216
			if (newOwner != null)
223
			if (newOwner != null)
217
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystem.class, msgs);
224
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystem.class, msgs);
218
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.PRODUCT__OWNER, msgs);
225
			msgs = basicSetOwner(newOwner, msgs);
219
			if (msgs != null) msgs.dispatch();
226
			if (msgs != null) msgs.dispatch();
220
		}
227
		}
221
		else if (eNotificationRequired())
228
		else if (eNotificationRequired())
Lines 224-289 Link Here
224
231
225
	/**
232
	/**
226
	 * <!-- begin-user-doc -->
233
	 * <!-- begin-user-doc -->
227
     * <!-- end-user-doc -->
234
	 * <!-- end-user-doc -->
228
	 * @generated
235
	 * @generated
229
	 */
236
	 */
230
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
237
	@Override
231
		if (featureID >= 0) {
238
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
232
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
239
		switch (featureID) {
233
				case OrderSystemPackage.PRODUCT__OWNER:
240
			case OrderSystemPackage.PRODUCT__OWNER:
234
					if (eContainer != null)
241
				if (eInternalContainer() != null)
235
						msgs = eBasicRemoveFromContainer(msgs);
242
					msgs = eBasicRemoveFromContainer(msgs);
236
					return eBasicSetContainer(otherEnd, OrderSystemPackage.PRODUCT__OWNER, msgs);
243
				return basicSetOwner((OrderSystem)otherEnd, msgs);
237
				default:
238
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
239
			}
240
		}
244
		}
241
		if (eContainer != null)
245
		return super.eInverseAdd(otherEnd, featureID, msgs);
242
			msgs = eBasicRemoveFromContainer(msgs);
243
		return eBasicSetContainer(otherEnd, featureID, msgs);
244
	}
246
	}
245
247
246
	/**
248
	/**
247
	 * <!-- begin-user-doc -->
249
	 * <!-- begin-user-doc -->
248
     * <!-- end-user-doc -->
250
	 * <!-- end-user-doc -->
249
	 * @generated
251
	 * @generated
250
	 */
252
	 */
251
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
253
	@Override
252
		if (featureID >= 0) {
254
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
253
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
255
		switch (featureID) {
254
				case OrderSystemPackage.PRODUCT__OWNER:
256
			case OrderSystemPackage.PRODUCT__OWNER:
255
					return eBasicSetContainer(null, OrderSystemPackage.PRODUCT__OWNER, msgs);
257
				return basicSetOwner(null, msgs);
256
				default:
257
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
258
			}
259
		}
258
		}
260
		return eBasicSetContainer(null, featureID, msgs);
259
		return super.eInverseRemove(otherEnd, featureID, msgs);
261
	}
260
	}
262
261
263
	/**
262
	/**
264
	 * <!-- begin-user-doc -->
263
	 * <!-- begin-user-doc -->
265
     * <!-- end-user-doc -->
264
	 * <!-- end-user-doc -->
266
	 * @generated
265
	 * @generated
267
	 */
266
	 */
268
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
267
	@Override
269
		if (eContainerFeatureID >= 0) {
268
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
270
			switch (eContainerFeatureID) {
269
		switch (eContainerFeatureID) {
271
				case OrderSystemPackage.PRODUCT__OWNER:
270
			case OrderSystemPackage.PRODUCT__OWNER:
272
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystem.class, msgs);
271
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystem.class, msgs);
273
				default:
274
					return eDynamicBasicRemoveFromContainer(msgs);
275
			}
276
		}
272
		}
277
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
273
		return super.eBasicRemoveFromContainerFeature(msgs);
278
	}
274
	}
279
275
280
	/**
276
	/**
281
	 * <!-- begin-user-doc -->
277
	 * <!-- begin-user-doc -->
282
     * <!-- end-user-doc -->
278
	 * <!-- end-user-doc -->
283
	 * @generated
279
	 * @generated
284
	 */
280
	 */
285
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
281
	@Override
286
		switch (eDerivedStructuralFeatureID(eFeature)) {
282
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
283
		switch (featureID) {
287
			case OrderSystemPackage.PRODUCT__NAME:
284
			case OrderSystemPackage.PRODUCT__NAME:
288
				return getName();
285
				return getName();
289
			case OrderSystemPackage.PRODUCT__SKU:
286
			case OrderSystemPackage.PRODUCT__SKU:
Lines 293-308 Link Here
293
			case OrderSystemPackage.PRODUCT__OWNER:
290
			case OrderSystemPackage.PRODUCT__OWNER:
294
				return getOwner();
291
				return getOwner();
295
		}
292
		}
296
		return eDynamicGet(eFeature, resolve);
293
		return super.eGet(featureID, resolve, coreType);
297
	}
294
	}
298
295
299
	/**
296
	/**
300
	 * <!-- begin-user-doc -->
297
	 * <!-- begin-user-doc -->
301
     * <!-- end-user-doc -->
298
	 * <!-- end-user-doc -->
302
	 * @generated
299
	 * @generated
303
	 */
300
	 */
304
    public void eSet(EStructuralFeature eFeature, Object newValue) {
301
	@Override
305
		switch (eDerivedStructuralFeatureID(eFeature)) {
302
	public void eSet(int featureID, Object newValue) {
303
		switch (featureID) {
306
			case OrderSystemPackage.PRODUCT__NAME:
304
			case OrderSystemPackage.PRODUCT__NAME:
307
				setName((String)newValue);
305
				setName((String)newValue);
308
				return;
306
				return;
Lines 316-331 Link Here
316
				setOwner((OrderSystem)newValue);
314
				setOwner((OrderSystem)newValue);
317
				return;
315
				return;
318
		}
316
		}
319
		eDynamicSet(eFeature, newValue);
317
		super.eSet(featureID, newValue);
320
	}
318
	}
321
319
322
	/**
320
	/**
323
	 * <!-- begin-user-doc -->
321
	 * <!-- begin-user-doc -->
324
     * <!-- end-user-doc -->
322
	 * <!-- end-user-doc -->
325
	 * @generated
323
	 * @generated
326
	 */
324
	 */
327
    public void eUnset(EStructuralFeature eFeature) {
325
	@Override
328
		switch (eDerivedStructuralFeatureID(eFeature)) {
326
	public void eUnset(int featureID) {
327
		switch (featureID) {
329
			case OrderSystemPackage.PRODUCT__NAME:
328
			case OrderSystemPackage.PRODUCT__NAME:
330
				setName(NAME_EDEFAULT);
329
				setName(NAME_EDEFAULT);
331
				return;
330
				return;
Lines 339-354 Link Here
339
				setOwner((OrderSystem)null);
338
				setOwner((OrderSystem)null);
340
				return;
339
				return;
341
		}
340
		}
342
		eDynamicUnset(eFeature);
341
		super.eUnset(featureID);
343
	}
342
	}
344
343
345
	/**
344
	/**
346
	 * <!-- begin-user-doc -->
345
	 * <!-- begin-user-doc -->
347
     * <!-- end-user-doc -->
346
	 * <!-- end-user-doc -->
348
	 * @generated
347
	 * @generated
349
	 */
348
	 */
350
    public boolean eIsSet(EStructuralFeature eFeature) {
349
	@Override
351
		switch (eDerivedStructuralFeatureID(eFeature)) {
350
	public boolean eIsSet(int featureID) {
351
		switch (featureID) {
352
			case OrderSystemPackage.PRODUCT__NAME:
352
			case OrderSystemPackage.PRODUCT__NAME:
353
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
353
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
354
			case OrderSystemPackage.PRODUCT__SKU:
354
			case OrderSystemPackage.PRODUCT__SKU:
Lines 358-367 Link Here
358
			case OrderSystemPackage.PRODUCT__OWNER:
358
			case OrderSystemPackage.PRODUCT__OWNER:
359
				return getOwner() != null;
359
				return getOwner() != null;
360
		}
360
		}
361
		return eDynamicIsSet(eFeature);
361
		return super.eIsSet(featureID);
362
	}
362
	}
363
363
364
    /**
364
	/**
365
     * <!-- begin-user-doc -->
365
     * <!-- begin-user-doc -->
366
     * <!-- end-user-doc -->
366
     * <!-- end-user-doc -->
367
     */
367
     */
(-)src/ordersystem/impl/OrderImpl.java (-72 / +72 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 23-43 Link Here
23
import ordersystem.Customer;
23
import ordersystem.Customer;
24
import ordersystem.LineItem;
24
import ordersystem.LineItem;
25
import ordersystem.Order;
25
import ordersystem.Order;
26
27
import ordersystem.OrderSystemPackage;
26
import ordersystem.OrderSystemPackage;
28
27
29
import org.eclipse.emf.common.notify.Notification;
28
import org.eclipse.emf.common.notify.Notification;
30
import org.eclipse.emf.common.notify.NotificationChain;
29
import org.eclipse.emf.common.notify.NotificationChain;
31
32
import org.eclipse.emf.common.util.EList;
30
import org.eclipse.emf.common.util.EList;
33
34
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EClass;
35
import org.eclipse.emf.ecore.EStructuralFeature;
36
import org.eclipse.emf.ecore.InternalEObject;
32
import org.eclipse.emf.ecore.InternalEObject;
37
38
import org.eclipse.emf.ecore.impl.ENotificationImpl;
33
import org.eclipse.emf.ecore.impl.ENotificationImpl;
39
import org.eclipse.emf.ecore.impl.EObjectImpl;
34
import org.eclipse.emf.ecore.impl.EObjectImpl;
40
41
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
35
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
42
import org.eclipse.emf.ecore.util.EcoreUtil;
36
import org.eclipse.emf.ecore.util.EcoreUtil;
43
import org.eclipse.emf.ecore.util.InternalEList;
37
import org.eclipse.emf.ecore.util.InternalEList;
Lines 149-155 Link Here
149
	 * @generated
143
	 * @generated
150
	 * @ordered
144
	 * @ordered
151
	 */
145
	 */
152
    protected EList item = null;
146
    protected EList<LineItem> item;
153
147
154
	/**
148
	/**
155
	 * <!-- begin-user-doc -->
149
	 * <!-- begin-user-doc -->
Lines 165-172 Link Here
165
     * <!-- end-user-doc -->
159
     * <!-- end-user-doc -->
166
	 * @generated
160
	 * @generated
167
	 */
161
	 */
168
    protected EClass eStaticClass() {
162
    @Override
169
		return OrderSystemPackage.eINSTANCE.getOrder();
163
				protected EClass eStaticClass() {
164
		return OrderSystemPackage.Literals.ORDER;
170
	}
165
	}
171
166
172
	/**
167
	/**
Lines 260-266 Link Here
260
	 */
255
	 */
261
    public Customer getOwner() {
256
    public Customer getOwner() {
262
		if (eContainerFeatureID != OrderSystemPackage.ORDER__OWNER) return null;
257
		if (eContainerFeatureID != OrderSystemPackage.ORDER__OWNER) return null;
263
		return (Customer)eContainer;
258
		return (Customer)eContainer();
259
	}
260
261
	/**
262
	 * <!-- begin-user-doc -->
263
	 * <!-- end-user-doc -->
264
	 * @generated
265
	 */
266
	public NotificationChain basicSetOwner(Customer newOwner, NotificationChain msgs) {
267
		msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.ORDER__OWNER, msgs);
268
		return msgs;
264
	}
269
	}
265
270
266
	/**
271
	/**
Lines 269-283 Link Here
269
	 * @generated
274
	 * @generated
270
	 */
275
	 */
271
    public void setOwner(Customer newOwner) {
276
    public void setOwner(Customer newOwner) {
272
		if (newOwner != eContainer || (eContainerFeatureID != OrderSystemPackage.ORDER__OWNER && newOwner != null)) {
277
		if (newOwner != eInternalContainer() || (eContainerFeatureID != OrderSystemPackage.ORDER__OWNER && newOwner != null)) {
273
			if (EcoreUtil.isAncestor(this, newOwner))
278
			if (EcoreUtil.isAncestor(this, newOwner))
274
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
279
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
275
			NotificationChain msgs = null;
280
			NotificationChain msgs = null;
276
			if (eContainer != null)
281
			if (eInternalContainer() != null)
277
				msgs = eBasicRemoveFromContainer(msgs);
282
				msgs = eBasicRemoveFromContainer(msgs);
278
			if (newOwner != null)
283
			if (newOwner != null)
279
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.CUSTOMER__ORDER, Customer.class, msgs);
284
				msgs = ((InternalEObject)newOwner).eInverseAdd(this, OrderSystemPackage.CUSTOMER__ORDER, Customer.class, msgs);
280
			msgs = eBasicSetContainer((InternalEObject)newOwner, OrderSystemPackage.ORDER__OWNER, msgs);
285
			msgs = basicSetOwner(newOwner, msgs);
281
			if (msgs != null) msgs.dispatch();
286
			if (msgs != null) msgs.dispatch();
282
		}
287
		}
283
		else if (eNotificationRequired())
288
		else if (eNotificationRequired())
Lines 289-367 Link Here
289
     * <!-- end-user-doc -->
294
     * <!-- end-user-doc -->
290
	 * @generated
295
	 * @generated
291
	 */
296
	 */
292
    public EList getItem() {
297
    public EList<LineItem> getItem() {
293
		if (item == null) {
298
		if (item == null) {
294
			item = new EObjectContainmentWithInverseEList(LineItem.class, this, OrderSystemPackage.ORDER__ITEM, OrderSystemPackage.LINE_ITEM__OWNER);
299
			item = new EObjectContainmentWithInverseEList<LineItem>(LineItem.class, this, OrderSystemPackage.ORDER__ITEM, OrderSystemPackage.LINE_ITEM__OWNER);
295
		}
300
		}
296
		return item;
301
		return item;
297
	}
302
	}
298
303
299
	/**
304
	/**
300
	 * <!-- begin-user-doc -->
305
	 * <!-- begin-user-doc -->
301
     * <!-- end-user-doc -->
306
	 * <!-- end-user-doc -->
302
	 * @generated
307
	 * @generated
303
	 */
308
	 */
304
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
309
	@SuppressWarnings("unchecked")
305
		if (featureID >= 0) {
310
		@Override
306
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
311
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
307
				case OrderSystemPackage.ORDER__OWNER:
312
		switch (featureID) {
308
					if (eContainer != null)
313
			case OrderSystemPackage.ORDER__OWNER:
309
						msgs = eBasicRemoveFromContainer(msgs);
314
				if (eInternalContainer() != null)
310
					return eBasicSetContainer(otherEnd, OrderSystemPackage.ORDER__OWNER, msgs);
315
					msgs = eBasicRemoveFromContainer(msgs);
311
				case OrderSystemPackage.ORDER__ITEM:
316
				return basicSetOwner((Customer)otherEnd, msgs);
312
					return ((InternalEList)getItem()).basicAdd(otherEnd, msgs);
317
			case OrderSystemPackage.ORDER__ITEM:
313
				default:
318
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getItem()).basicAdd(otherEnd, msgs);
314
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
315
			}
316
		}
319
		}
317
		if (eContainer != null)
320
		return super.eInverseAdd(otherEnd, featureID, msgs);
318
			msgs = eBasicRemoveFromContainer(msgs);
319
		return eBasicSetContainer(otherEnd, featureID, msgs);
320
	}
321
	}
321
322
322
	/**
323
	/**
323
	 * <!-- begin-user-doc -->
324
	 * <!-- begin-user-doc -->
324
     * <!-- end-user-doc -->
325
	 * <!-- end-user-doc -->
325
	 * @generated
326
	 * @generated
326
	 */
327
	 */
327
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
328
	@Override
328
		if (featureID >= 0) {
329
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
329
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
330
		switch (featureID) {
330
				case OrderSystemPackage.ORDER__OWNER:
331
			case OrderSystemPackage.ORDER__OWNER:
331
					return eBasicSetContainer(null, OrderSystemPackage.ORDER__OWNER, msgs);
332
				return basicSetOwner(null, msgs);
332
				case OrderSystemPackage.ORDER__ITEM:
333
			case OrderSystemPackage.ORDER__ITEM:
333
					return ((InternalEList)getItem()).basicRemove(otherEnd, msgs);
334
				return ((InternalEList<?>)getItem()).basicRemove(otherEnd, msgs);
334
				default:
335
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
336
			}
337
		}
335
		}
338
		return eBasicSetContainer(null, featureID, msgs);
336
		return super.eInverseRemove(otherEnd, featureID, msgs);
339
	}
337
	}
340
338
341
	/**
339
	/**
342
	 * <!-- begin-user-doc -->
340
	 * <!-- begin-user-doc -->
343
     * <!-- end-user-doc -->
341
	 * <!-- end-user-doc -->
344
	 * @generated
342
	 * @generated
345
	 */
343
	 */
346
    public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
344
	@Override
347
		if (eContainerFeatureID >= 0) {
345
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
348
			switch (eContainerFeatureID) {
346
		switch (eContainerFeatureID) {
349
				case OrderSystemPackage.ORDER__OWNER:
347
			case OrderSystemPackage.ORDER__OWNER:
350
					return (eContainer).eInverseRemove(this, OrderSystemPackage.CUSTOMER__ORDER, Customer.class, msgs);
348
				return eInternalContainer().eInverseRemove(this, OrderSystemPackage.CUSTOMER__ORDER, Customer.class, msgs);
351
				default:
352
					return eDynamicBasicRemoveFromContainer(msgs);
353
			}
354
		}
349
		}
355
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
350
		return super.eBasicRemoveFromContainerFeature(msgs);
356
	}
351
	}
357
352
358
	/**
353
	/**
359
	 * <!-- begin-user-doc -->
354
	 * <!-- begin-user-doc -->
360
     * <!-- end-user-doc -->
355
	 * <!-- end-user-doc -->
361
	 * @generated
356
	 * @generated
362
	 */
357
	 */
363
    public Object eGet(EStructuralFeature eFeature, boolean resolve) {
358
	@Override
364
		switch (eDerivedStructuralFeatureID(eFeature)) {
359
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
360
		switch (featureID) {
365
			case OrderSystemPackage.ORDER__PLACED_ON:
361
			case OrderSystemPackage.ORDER__PLACED_ON:
366
				return getPlacedOn();
362
				return getPlacedOn();
367
			case OrderSystemPackage.ORDER__FILLED_ON:
363
			case OrderSystemPackage.ORDER__FILLED_ON:
Lines 375-390 Link Here
375
			case OrderSystemPackage.ORDER__ITEM:
371
			case OrderSystemPackage.ORDER__ITEM:
376
				return getItem();
372
				return getItem();
377
		}
373
		}
378
		return eDynamicGet(eFeature, resolve);
374
		return super.eGet(featureID, resolve, coreType);
379
	}
375
	}
380
376
381
	/**
377
	/**
382
	 * <!-- begin-user-doc -->
378
	 * <!-- begin-user-doc -->
383
     * <!-- end-user-doc -->
379
	 * <!-- end-user-doc -->
384
	 * @generated
380
	 * @generated
385
	 */
381
	 */
386
    public void eSet(EStructuralFeature eFeature, Object newValue) {
382
	@SuppressWarnings("unchecked")
387
		switch (eDerivedStructuralFeatureID(eFeature)) {
383
		@Override
384
	public void eSet(int featureID, Object newValue) {
385
		switch (featureID) {
388
			case OrderSystemPackage.ORDER__PLACED_ON:
386
			case OrderSystemPackage.ORDER__PLACED_ON:
389
				setPlacedOn((Date)newValue);
387
				setPlacedOn((Date)newValue);
390
				return;
388
				return;
Lines 402-420 Link Here
402
				return;
400
				return;
403
			case OrderSystemPackage.ORDER__ITEM:
401
			case OrderSystemPackage.ORDER__ITEM:
404
				getItem().clear();
402
				getItem().clear();
405
				getItem().addAll((Collection)newValue);
403
				getItem().addAll((Collection<? extends LineItem>)newValue);
406
				return;
404
				return;
407
		}
405
		}
408
		eDynamicSet(eFeature, newValue);
406
		super.eSet(featureID, newValue);
409
	}
407
	}
410
408
411
	/**
409
	/**
412
	 * <!-- begin-user-doc -->
410
	 * <!-- begin-user-doc -->
413
     * <!-- end-user-doc -->
411
	 * <!-- end-user-doc -->
414
	 * @generated
412
	 * @generated
415
	 */
413
	 */
416
    public void eUnset(EStructuralFeature eFeature) {
414
	@Override
417
		switch (eDerivedStructuralFeatureID(eFeature)) {
415
	public void eUnset(int featureID) {
416
		switch (featureID) {
418
			case OrderSystemPackage.ORDER__PLACED_ON:
417
			case OrderSystemPackage.ORDER__PLACED_ON:
419
				setPlacedOn(PLACED_ON_EDEFAULT);
418
				setPlacedOn(PLACED_ON_EDEFAULT);
420
				return;
419
				return;
Lines 434-449 Link Here
434
				getItem().clear();
433
				getItem().clear();
435
				return;
434
				return;
436
		}
435
		}
437
		eDynamicUnset(eFeature);
436
		super.eUnset(featureID);
438
	}
437
	}
439
438
440
	/**
439
	/**
441
	 * <!-- begin-user-doc -->
440
	 * <!-- begin-user-doc -->
442
     * <!-- end-user-doc -->
441
	 * <!-- end-user-doc -->
443
	 * @generated
442
	 * @generated
444
	 */
443
	 */
445
    public boolean eIsSet(EStructuralFeature eFeature) {
444
	@Override
446
		switch (eDerivedStructuralFeatureID(eFeature)) {
445
	public boolean eIsSet(int featureID) {
446
		switch (featureID) {
447
			case OrderSystemPackage.ORDER__PLACED_ON:
447
			case OrderSystemPackage.ORDER__PLACED_ON:
448
				return PLACED_ON_EDEFAULT == null ? placedOn != null : !PLACED_ON_EDEFAULT.equals(placedOn);
448
				return PLACED_ON_EDEFAULT == null ? placedOn != null : !PLACED_ON_EDEFAULT.equals(placedOn);
449
			case OrderSystemPackage.ORDER__FILLED_ON:
449
			case OrderSystemPackage.ORDER__FILLED_ON:
Lines 457-466 Link Here
457
			case OrderSystemPackage.ORDER__ITEM:
457
			case OrderSystemPackage.ORDER__ITEM:
458
				return item != null && !item.isEmpty();
458
				return item != null && !item.isEmpty();
459
		}
459
		}
460
		return eDynamicIsSet(eFeature);
460
		return super.eIsSet(featureID);
461
	}
461
	}
462
462
463
    /**
463
	/**
464
     * <!-- begin-user-doc -->
464
     * <!-- begin-user-doc -->
465
     * <!-- end-user-doc -->
465
     * <!-- end-user-doc -->
466
     */
466
     */
(-)src/org/eclipse/emf/validation/tests/SetTargetConstraint.java (-1 / +2 lines)
Lines 39-44 Link Here
39
	public static boolean enabled = false;
39
	public static boolean enabled = false;
40
	
40
	
41
	// Documentation copied from the inherited specification
41
	// Documentation copied from the inherited specification
42
	@Override
42
	public IStatus validate(IValidationContext ctx) {
43
	public IStatus validate(IValidationContext ctx) {
43
		if (!enabled) {
44
		if (!enabled) {
44
			return ctx.createSuccessStatus();
45
			return ctx.createSuccessStatus();
Lines 63-69 Link Here
63
					null);
64
					null);
64
		}
65
		}
65
		
66
		
66
		Collection statuses = new java.util.ArrayList();
67
		Collection<IStatus> statuses = new java.util.ArrayList<IStatus>();
67
		
68
		
68
		statuses.add(ConstraintStatus.createStatus(
69
		statuses.add(ConstraintStatus.createStatus(
69
				ctx,
70
				ctx,
(-)src/org/eclipse/emf/validation/tests/LogCapture.java (-8 / +5 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.validation.tests;
17
package org.eclipse.emf.validation.tests;
18
18
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
20
22
import junit.framework.TestCase;
21
import junit.framework.TestCase;
Lines 41-47 Link Here
41
			}
40
			}
42
		}};
41
		}};
43
	
42
	
44
	private final List logs = new java.util.ArrayList();
43
	private final List<IStatus> logs = new java.util.ArrayList<IStatus>();
45
	private IStatus lastLog;
44
	private IStatus lastLog;
46
    
45
    
47
    /**
46
    /**
Lines 83-89 Link Here
83
	 * 
82
	 * 
84
	 * @return a list (possibly empty) of {@link IStatus}es
83
	 * @return a list (possibly empty) of {@link IStatus}es
85
	 */
84
	 */
86
	public List getLogs() {
85
	public List<IStatus> getLogs() {
87
		return logs;
86
		return logs;
88
	}
87
	}
89
	
88
	
Lines 95-106 Link Here
95
	 * 
94
	 * 
96
	 * @return the matching log entries
95
	 * @return the matching log entries
97
	 */
96
	 */
98
	public List getLogs(int statusCode) {
97
	public List<IStatus> getLogs(int statusCode) {
99
	    List result = new java.util.ArrayList();
98
	    List<IStatus> result = new java.util.ArrayList<IStatus>();
100
	    
99
	    
101
	    for (Iterator iter = logs.iterator(); iter.hasNext();) {
100
	    for (IStatus next : logs) {
102
	        IStatus next = (IStatus) iter.next();
103
	        
104
	        if (next.getCode() == statusCode) {
101
	        if (next.getCode() == statusCode) {
105
	            result.add(next);
102
	            result.add(next);
106
	        }
103
	        }
(-)src/org/eclipse/emf/validation/tests/AllTests.java (-1 / +2 lines)
Lines 44-50 Link Here
44
	static {
44
	static {
45
		// register the .ordersystem extension for loading the example XMI file
45
		// register the .ordersystem extension for loading the example XMI file
46
		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
46
		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
47
		Map m = reg.getExtensionToFactoryMap();
47
		Map<String, Object> m = reg.getExtensionToFactoryMap();
48
		m.put("ordersystem", new XMIResourceFactoryImpl()); //$NON-NLS-1$
48
		m.put("ordersystem", new XMIResourceFactoryImpl()); //$NON-NLS-1$
49
	}
49
	}
50
	
50
	
Lines 80-85 Link Here
80
		// this method is called if and only if unit tests are being executed
80
		// this method is called if and only if unit tests are being executed
81
		TestSuite suite = new TestSuite(
81
		TestSuite suite = new TestSuite(
82
				"Test for org.eclipse.emf.validation plug-in") { //$NON-NLS-1$
82
				"Test for org.eclipse.emf.validation plug-in") { //$NON-NLS-1$
83
			@Override
83
			public void run(TestResult result) {
84
			public void run(TestResult result) {
84
				// ensure that the tests know that they are running
85
				// ensure that the tests know that they are running
85
				executingUnitTests = true;
86
				executingUnitTests = true;
(-)src/org/eclipse/emf/validation/tests/FrameworkTest.java (-56 / +27 lines)
Lines 18-28 Link Here
18
package org.eclipse.emf.validation.tests;
18
package org.eclipse.emf.validation.tests;
19
19
20
import java.io.IOException;
20
import java.io.IOException;
21
import java.util.Arrays;
22
import java.util.Collection;
21
import java.util.Collection;
23
import java.util.Collections;
22
import java.util.Collections;
24
import java.util.Iterator;
25
26
import ordersystem.OrderSystem;
23
import ordersystem.OrderSystem;
27
import ordersystem.OrderSystemFactory;
24
import ordersystem.OrderSystemFactory;
28
import ordersystem.special.SpecialFactory;
25
import ordersystem.special.SpecialFactory;
Lines 68-73 Link Here
68
	 * Load the static example Order System model (<tt>test.ordersystem</tt>)
65
	 * Load the static example Order System model (<tt>test.ordersystem</tt>)
69
	 * on the first invocation of this method.
66
	 * on the first invocation of this method.
70
	 */
67
	 */
68
	@Override
71
	protected void setUp() throws Exception {
69
	protected void setUp() throws Exception {
72
		if (orderSystem == null) {
70
		if (orderSystem == null) {
73
			ResourceSet resourceSet = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
71
			ResourceSet resourceSet = new org.eclipse.emf.ecore.resource.impl.ResourceSetImpl();
Lines 138-145 Link Here
138
136
139
		IStatus[] status = getStatuses(batchValidator.validate(object));
137
		IStatus[] status = getStatuses(batchValidator.validate(object));
140
138
141
		for (int i=0; i<status.length; i++) {
139
		for (IStatus element : status) {
142
			IModelConstraint constraint = ((IConstraintStatus)status[i]).getConstraint();
140
			IModelConstraint constraint = ((IConstraintStatus)element).getConstraint();
143
			
141
			
144
			if (constraint.getDescriptor().getId().equals(ID_PREFIX + "ordersystem.marker")) { //$NON-NLS-1$
142
			if (constraint.getDescriptor().getId().equals(ID_PREFIX + "ordersystem.marker")) { //$NON-NLS-1$
145
				return;
143
				return;
Lines 163-172 Link Here
163
		assertAllConstraintsPresent(
161
		assertAllConstraintsPresent(
164
				"batch", //$NON-NLS-1$
162
				"batch", //$NON-NLS-1$
165
				status,
163
				status,
166
				Arrays.asList(new String[] {
164
				ID_PREFIX + "order.hasContents", //$NON-NLS-1$
167
						ID_PREFIX + "order.hasContents", //$NON-NLS-1$
165
				ID_PREFIX + "order.notFilledBeforePlacement"); //$NON-NLS-1$
168
						ID_PREFIX + "order.notFilledBeforePlacement", //$NON-NLS-1$
169
				}));
170
	}
166
	}
171
	
167
	
172
	/**
168
	/**
Lines 185-194 Link Here
185
		assertAllConstraintsPresent(
181
		assertAllConstraintsPresent(
186
				"live", //$NON-NLS-1$
182
				"live", //$NON-NLS-1$
187
				status,
183
				status,
188
				Arrays.asList(new String[] {
184
				ID_PREFIX + "order.hasName", //$NON-NLS-1$
189
						ID_PREFIX + "order.hasName", //$NON-NLS-1$
185
				ID_PREFIX + "order.hasOwner"); //$NON-NLS-1$
190
						ID_PREFIX + "order.hasOwner", //$NON-NLS-1$
191
				}));
192
	}
186
	}
193
187
194
	/**
188
	/**
Lines 204-213 Link Here
204
		IStatus[] status = getStatuses(liveValidator.validate(
198
		IStatus[] status = getStatuses(liveValidator.validate(
205
					Collections.nCopies(5, event)));
199
					Collections.nCopies(5, event)));
206
200
207
		Collection evaluatedConstraints = new java.util.HashSet();
201
		Collection<IModelConstraint> evaluatedConstraints =
202
			new java.util.HashSet<IModelConstraint>();
208
		
203
		
209
		for (int i = 0; i < status.length; i++) {
204
		for (IStatus element : status) {
210
			IConstraintStatus next = (IConstraintStatus)status[i];
205
			IConstraintStatus next = (IConstraintStatus)element;
211
			
206
			
212
			evaluatedConstraints.add(next.getConstraint());
207
			evaluatedConstraints.add(next.getConstraint());
213
		}
208
		}
Lines 292-300 Link Here
292
		assertAllConstraintsNotPresent(
287
		assertAllConstraintsNotPresent(
293
				"batch", //$NON-NLS-1$
288
				"batch", //$NON-NLS-1$
294
				status,
289
				status,
295
				Arrays.asList(new String[] {
290
				ID_PREFIX + "bad.constraint.xml"); //$NON-NLS-1$
296
						ID_PREFIX + "bad.constraint.xml", //$NON-NLS-1$
297
					}));
298
	}
291
	}
299
292
300
	/**
293
	/**
Lines 308-323 Link Here
308
301
309
		IStatus[] status = getStatuses(batchValidator.validate(object));
302
		IStatus[] status = getStatuses(batchValidator.validate(object));
310
		
303
		
311
		Collection ids = Arrays.asList(new String[] {
304
		String[] ids = new String[] {
312
				ID_PREFIX + "bad.constraint.disabled.java", //$NON-NLS-1$
305
				ID_PREFIX + "bad.constraint.disabled.java", //$NON-NLS-1$
313
				ID_PREFIX + "bad.constraint.disabled.ocl", //$NON-NLS-1$
306
				ID_PREFIX + "bad.constraint.disabled.ocl", //$NON-NLS-1$
314
				ID_PREFIX + "bad.constraint.disabled.bsh", //$NON-NLS-1$
307
				ID_PREFIX + "bad.constraint.disabled.bsh", //$NON-NLS-1$
315
				ID_PREFIX + "bad.constraint.disabled.runtime", //$NON-NLS-1$
308
				ID_PREFIX + "bad.constraint.disabled.runtime", //$NON-NLS-1$
316
			});
309
			};
317
		
310
		
318
		for (Iterator iter = ids.iterator(); iter.hasNext();) {
311
		for (String id : ids) {
319
			String id = (String)iter.next();
320
			
321
			IStatus nextStatus = getStatus(status, id);
312
			IStatus nextStatus = getStatus(status, id);
322
			if (nextStatus != null) {
313
			if (nextStatus != null) {
323
				assertTrue(nextStatus.matches(IStatus.INFO));
314
				assertTrue(nextStatus.matches(IStatus.INFO));
Lines 359-366 Link Here
359
350
360
		IStatus[] status = getStatuses(batchValidator.validate(object));
351
		IStatus[] status = getStatuses(batchValidator.validate(object));
361
352
362
		for (int i=0; i<status.length; i++) {
353
		for (IStatus element : status) {
363
			IModelConstraint constraint = ((IConstraintStatus)status[i]).getConstraint();
354
			IModelConstraint constraint = ((IConstraintStatus)element).getConstraint();
364
			assertFalse("Got constraints from ordersystem namespace prefix provider.", constraint.getDescriptor().getId().startsWith(ID_PREFIX + "ordersystem")); //$NON-NLS-1$ //$NON-NLS-2$
355
			assertFalse("Got constraints from ordersystem namespace prefix provider.", constraint.getDescriptor().getId().startsWith(ID_PREFIX + "ordersystem")); //$NON-NLS-1$ //$NON-NLS-2$
365
		}
356
		}
366
		
357
		
Lines 387-402 Link Here
387
		assertAllConstraintsPresent(
378
		assertAllConstraintsPresent(
388
				"batch", //$NON-NLS-1$
379
				"batch", //$NON-NLS-1$
389
				status,
380
				status,
390
				Arrays.asList(new String[] {
381
				ID_PREFIX + "providertarget.batch1"); //$NON-NLS-1$
391
						ID_PREFIX + "providertarget.batch1", //$NON-NLS-1$
392
					}));
393
382
394
		assertAllConstraintsNotPresent(
383
		assertAllConstraintsNotPresent(
395
				"batch", //$NON-NLS-1$
384
				"batch", //$NON-NLS-1$
396
				status,
385
				status,
397
				Arrays.asList(new String[] {
386
				ID_PREFIX + "providertarget.batch2"); //$NON-NLS-1$
398
						 ID_PREFIX + "providertarget.batch2", //$NON-NLS-1$
399
							}));
400
		
387
		
401
		// also check that the provider filter correctly excludes the
388
		// also check that the provider filter correctly excludes the
402
		//   Order type (the constraint otherwise would apply to all types,
389
		//   Order type (the constraint otherwise would apply to all types,
Lines 409-417 Link Here
409
		assertAllConstraintsNotPresent(
396
		assertAllConstraintsNotPresent(
410
				"batch", //$NON-NLS-1$
397
				"batch", //$NON-NLS-1$
411
				status,
398
				status,
412
				Arrays.asList(new String[] {
399
				ID_PREFIX + "providertarget.batch1"); //$NON-NLS-1$
413
						ID_PREFIX + "providertarget.batch1", //$NON-NLS-1$
414
					}));
415
	}
400
	}
416
	
401
	
417
	/**
402
	/**
Lines 434-449 Link Here
434
		assertAllConstraintsPresent(
419
		assertAllConstraintsPresent(
435
				"live", //$NON-NLS-1$
420
				"live", //$NON-NLS-1$
436
				status,
421
				status,
437
				Arrays.asList(new String[] {
422
				ID_PREFIX + "providertarget.live2"); //$NON-NLS-1$
438
						ID_PREFIX + "providertarget.live2", //$NON-NLS-1$
439
					}));
440
423
441
		assertAllConstraintsNotPresent(
424
		assertAllConstraintsNotPresent(
442
				"live", //$NON-NLS-1$
425
				"live", //$NON-NLS-1$
443
				status,
426
				status,
444
				Arrays.asList(new String[] {
427
				ID_PREFIX + "providertarget.live1"); //$NON-NLS-1$
445
						ID_PREFIX + "providertarget.live1", //$NON-NLS-1$
446
					}));
447
		
428
		
448
		// also check that the provider filter correctly excludes the
429
		// also check that the provider filter correctly excludes the
449
		//   Order type (the constraint otherwise would apply to all types,
430
		//   Order type (the constraint otherwise would apply to all types,
Lines 457-465 Link Here
457
		assertAllConstraintsNotPresent(
438
		assertAllConstraintsNotPresent(
458
				"live", //$NON-NLS-1$
439
				"live", //$NON-NLS-1$
459
				status,
440
				status,
460
				Arrays.asList(new String[] {
441
				ID_PREFIX + "providertarget.live2"); //$NON-NLS-1$
461
						 ID_PREFIX + "providertarget.live2", //$NON-NLS-1$
462
					}));
463
		
442
		
464
		// finally, check that the provider filter correctly excludes an
443
		// finally, check that the provider filter correctly excludes an
465
		//   event type that is not "Set"
444
		//   event type that is not "Set"
Lines 472-480 Link Here
472
		assertAllConstraintsNotPresent(
451
		assertAllConstraintsNotPresent(
473
				"live", //$NON-NLS-1$
452
				"live", //$NON-NLS-1$
474
				status,
453
				status,
475
				Arrays.asList(new String[] {
454
				ID_PREFIX + "providertarget.live2"); //$NON-NLS-1$
476
						ID_PREFIX + "providertarget.live2", //$NON-NLS-1$
477
					}));
478
	}
455
	}
479
	
456
	
480
	/**
457
	/**
Lines 490-498 Link Here
490
		assertAllConstraintsPresent(
467
		assertAllConstraintsPresent(
491
				"batch", //$NON-NLS-1$
468
				"batch", //$NON-NLS-1$
492
				status,
469
				status,
493
				Arrays.asList(new String[] {
470
				ID_PREFIX + "multipackage.test"); //$NON-NLS-1$
494
						ID_PREFIX + "multipackage.test", //$NON-NLS-1$
495
					}));
496
	}
471
	}
497
	
472
	
498
	/**
473
	/**
Lines 509-517 Link Here
509
		assertAllConstraintsPresent(
484
		assertAllConstraintsPresent(
510
				"batch", //$NON-NLS-1$
485
				"batch", //$NON-NLS-1$
511
				status,
486
				status,
512
				Arrays.asList(new String[] {
487
				ID_PREFIX + "inheritance.test"); //$NON-NLS-1$
513
						ID_PREFIX + "inheritance.test", //$NON-NLS-1$
514
					}));
515
	}
488
	}
516
	
489
	
517
	/**
490
	/**
Lines 528-535 Link Here
528
		assertAllConstraintsPresent(
501
		assertAllConstraintsPresent(
529
				"batch", //$NON-NLS-1$
502
				"batch", //$NON-NLS-1$
530
				status,
503
				status,
531
				Arrays.asList(new String[] {
504
				ID_PREFIX + "qualifiedName.test"); //$NON-NLS-1$
532
						ID_PREFIX + "qualifiedName.test", //$NON-NLS-1$
533
					}));
534
	}
505
	}
535
}
506
}
(-)src/org/eclipse/emf/validation/tests/CachedTestProvider.java (-7 / +9 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
17
18
package org.eclipse.emf.validation.tests;
18
package org.eclipse.emf.validation.tests;
19
19
20
import org.eclipse.emf.validation.model.IModelConstraint;
20
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
21
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
21
22
22
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EClass;
Lines 33-39 Link Here
33
public class CachedTestProvider extends AbstractConstraintProvider {
34
public class CachedTestProvider extends AbstractConstraintProvider {
34
	private static CachedTestProvider instance;
35
	private static CachedTestProvider instance;
35
	
36
	
36
	private final java.util.Map hits = new java.util.HashMap();
37
	private final java.util.Map<EClass, Integer> hits = new java.util.HashMap<EClass, Integer>();
37
	
38
	
38
	/**
39
	/**
39
	 * Initializes me and remembers me for static access.
40
	 * Initializes me and remembers me for static access.
Lines 47-54 Link Here
47
	}
48
	}
48
	
49
	
49
	// redefines the inherited method
50
	// redefines the inherited method
50
	public Collection getBatchConstraints(EObject eObject,
51
	@Override
51
			Collection constraints) {
52
	public Collection<IModelConstraint> getBatchConstraints(EObject eObject,
53
			Collection<IModelConstraint> constraints) {
52
		// I don't actually need to provide any constraints in order to
54
		// I don't actually need to provide any constraints in order to
53
		//   register a hit.  The cache will remember that there are no
55
		//   register a hit.  The cache will remember that there are no
54
		//   constraints!
56
		//   constraints!
Lines 64-70 Link Here
64
	 * @param clazz the EMF type
66
	 * @param clazz the EMF type
65
	 */
67
	 */
66
	private final void registerHit(EClass clazz) {
68
	private final void registerHit(EClass clazz) {
67
		hits.put(clazz, new Integer(getHitCount(clazz) + 1));
69
		hits.put(clazz, getHitCount(clazz) + 1);
68
	}
70
	}
69
	
71
	
70
	/**
72
	/**
Lines 84-91 Link Here
84
	 * @return the number of times that I have provided constraints
86
	 * @return the number of times that I have provided constraints
85
	 */
87
	 */
86
	public int getHitCount(EClass clazz) {
88
	public int getHitCount(EClass clazz) {
87
		Integer result = (Integer)hits.get(clazz);
89
		Integer result = hits.get(clazz);
88
		
90
		
89
		return (result == null) ? 0 : result.intValue();
91
		return (result == null) ? 0 : result;
90
	}
92
	}
91
}
93
}
(-)src/org/eclipse/emf/validation/tests/TestBase.java (-52 / +46 lines)
Lines 17-24 Link Here
17
17
18
package org.eclipse.emf.validation.tests;
18
package org.eclipse.emf.validation.tests;
19
19
20
import java.util.Arrays;
20
import java.util.Collection;
21
import java.util.Collection;
21
import java.util.Iterator;
22
import java.util.List;
22
import java.util.List;
23
23
24
import junit.framework.TestCase;
24
import junit.framework.TestCase;
Lines 31-38 Link Here
31
import org.eclipse.emf.validation.model.IConstraintStatus;
31
import org.eclipse.emf.validation.model.IConstraintStatus;
32
import org.eclipse.emf.validation.model.IModelConstraint;
32
import org.eclipse.emf.validation.model.IModelConstraint;
33
import org.eclipse.emf.validation.service.IBatchValidator;
33
import org.eclipse.emf.validation.service.IBatchValidator;
34
import org.eclipse.emf.validation.service.ILiveValidator;
34
import org.eclipse.emf.validation.service.ITraversalStrategy;
35
import org.eclipse.emf.validation.service.ITraversalStrategy;
35
import org.eclipse.emf.validation.service.IValidator;
36
import org.eclipse.emf.validation.service.ModelValidationService;
36
import org.eclipse.emf.validation.service.ModelValidationService;
37
37
38
/**
38
/**
Lines 49-67 Link Here
49
	
49
	
50
	protected final IBatchValidator batchValidator;
50
	protected final IBatchValidator batchValidator;
51
	protected final IBatchValidator treeValidator;
51
	protected final IBatchValidator treeValidator;
52
	protected final IValidator liveValidator;
52
	protected final ILiveValidator liveValidator;
53
	
53
	
54
	public TestBase(String name) {
54
	public TestBase(String name) {
55
		super(name);
55
		super(name);
56
		
56
		
57
		batchValidator = (IBatchValidator)
57
		batchValidator = ModelValidationService.getInstance().newValidator(
58
			ModelValidationService.getInstance().newValidator(
59
				EvaluationMode.BATCH);
58
				EvaluationMode.BATCH);
60
		batchValidator.setTraversalStrategy(new ITraversalStrategy.Flat());
59
		batchValidator.setTraversalStrategy(new ITraversalStrategy.Flat());
61
		batchValidator.setReportSuccesses(true);
60
		batchValidator.setReportSuccesses(true);
62
		
61
		
63
		treeValidator = (IBatchValidator)
62
		treeValidator = ModelValidationService.getInstance().newValidator(
64
			ModelValidationService.getInstance().newValidator(
65
				EvaluationMode.BATCH);
63
				EvaluationMode.BATCH);
66
		treeValidator.setTraversalStrategy(new ITraversalStrategy.Recursive());
64
		treeValidator.setTraversalStrategy(new ITraversalStrategy.Recursive());
67
		treeValidator.setReportSuccesses(true);
65
		treeValidator.setReportSuccesses(true);
Lines 82-97 Link Here
82
	protected void assertAllConstraintsNotPresent(
80
	protected void assertAllConstraintsNotPresent(
83
			String constraintType,
81
			String constraintType,
84
			IStatus[] statuses,
82
			IStatus[] statuses,
85
			Collection ids) {
83
			String... ids) {
86
		
84
		
87
		Collection found = new java.util.ArrayList();
85
		Collection<String> found = new java.util.ArrayList<String>();
88
		
86
		
89
		for (int i = 0; i < statuses.length; i++) {
87
		for (IStatus element : statuses) {
90
			IModelConstraint next = ((IConstraintStatus)statuses[i]).getConstraint();
88
			IModelConstraint next = ((IConstraintStatus)element).getConstraint();
91
			
89
			
92
			String id = next.getDescriptor().getId();
90
			String id = next.getDescriptor().getId();
93
			
91
			
94
			if (ids.contains(id)) {
92
			if (Arrays.asList(ids).contains(id)) {
95
				found.add(id);
93
				found.add(id);
96
			}
94
			}
97
		}
95
		}
Lines 111-127 Link Here
111
	 */
109
	 */
112
	protected void assertAllConstraintsNotPresent(
110
	protected void assertAllConstraintsNotPresent(
113
			String constraintType,
111
			String constraintType,
114
			Collection constraints,
112
			Collection<IModelConstraint> constraints,
115
			Collection ids) {
113
			String... ids) {
116
		
114
		
117
		Collection found = new java.util.ArrayList();
115
		Collection<String> found = new java.util.ArrayList<String>();
118
		
116
		
119
		for (Iterator iter = constraints.iterator(); iter.hasNext();) {
117
		for (IModelConstraint next : constraints) {
120
			IModelConstraint next = (IModelConstraint)iter.next();
121
			
122
			String id = next.getDescriptor().getId();
118
			String id = next.getDescriptor().getId();
123
			
119
			
124
			if (ids.contains(id)) {
120
			if (Arrays.asList(ids).contains(id)) {
125
				found.add(id);
121
				found.add(id);
126
			}
122
			}
127
		}
123
		}
Lines 142-153 Link Here
142
	protected void assertAllConstraintsPresent(
138
	protected void assertAllConstraintsPresent(
143
			String constraintType,
139
			String constraintType,
144
			IStatus[] statuses,
140
			IStatus[] statuses,
145
			Collection ids) {
141
			String... ids) {
146
		
142
		
147
		Collection notFound = new java.util.LinkedList(ids);
143
		Collection<String> notFound = new java.util.LinkedList<String>(Arrays.asList(ids));
148
		
144
		
149
		for (int i = 0; i < statuses.length; i++) {
145
		for (IStatus element : statuses) {
150
			IModelConstraint next = ((IConstraintStatus)statuses[i]).getConstraint();
146
			IModelConstraint next = ((IConstraintStatus)element).getConstraint();
151
			
147
			
152
			notFound.remove(next.getDescriptor().getId());
148
			notFound.remove(next.getDescriptor().getId());
153
		}
149
		}
Lines 167-180 Link Here
167
	 */
163
	 */
168
	protected void assertAllConstraintsPresent(
164
	protected void assertAllConstraintsPresent(
169
			String constraintType,
165
			String constraintType,
170
			Collection constraints,
166
			Collection<IModelConstraint> constraints,
171
			Collection ids) {
167
			String... ids) {
172
		
168
		
173
		Collection notFound = new java.util.LinkedList(ids);
169
		Collection<String> notFound = new java.util.LinkedList<String>(Arrays.asList(ids));
174
		
170
		
175
		for (Iterator iter = constraints.iterator(); iter.hasNext();) {
171
		for (IModelConstraint next : constraints) {
176
			IModelConstraint next = (IModelConstraint)iter.next();
177
			
178
			notFound.remove(next.getDescriptor().getId());
172
			notFound.remove(next.getDescriptor().getId());
179
		}
173
		}
180
		
174
		
Lines 194-205 Link Here
194
	protected void assertAllTargetsPresent(
188
	protected void assertAllTargetsPresent(
195
			String constraintType,
189
			String constraintType,
196
			IStatus[] statuses,
190
			IStatus[] statuses,
197
			Collection targets) {
191
			Collection<? extends EObject> targets) {
198
		
192
		
199
		Collection notFound = new java.util.LinkedList(targets);
193
		Collection<EObject> notFound = new java.util.LinkedList<EObject>(targets);
200
		
194
		
201
		for (int i = 0; i < statuses.length; i++) {
195
		for (IStatus element : statuses) {
202
			IConstraintStatus next = (IConstraintStatus)statuses[i];
196
			IConstraintStatus next = (IConstraintStatus)element;
203
			
197
			
204
			notFound.remove(next.getTarget());
198
			notFound.remove(next.getTarget());
205
		}
199
		}
Lines 211-219 Link Here
211
205
212
	protected void assertConstraintAndTargetNotPresent(String constraintType,
206
	protected void assertConstraintAndTargetNotPresent(String constraintType,
213
			IStatus[] statuses, String constraintId, EObject target) {
207
			IStatus[] statuses, String constraintId, EObject target) {
214
		for (int i = 0; i < statuses.length; i++) {
208
		for (IStatus element : statuses) {
215
			IConstraintStatus status = (IConstraintStatus)statuses[i];
209
			IConstraintStatus status = (IConstraintStatus)element;
216
			IModelConstraint constraint  = ((IConstraintStatus)statuses[i]).getConstraint();
210
			IModelConstraint constraint  = ((IConstraintStatus)element).getConstraint();
217
			
211
			
218
			if (target.equals(status.getTarget()) && constraintId.equals(constraint.getDescriptor().getId())) {
212
			if (target.equals(status.getTarget()) && constraintId.equals(constraint.getDescriptor().getId())) {
219
				fail("Found unwanted " + constraintType + " constraint " + constraintId + " on " + target); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
213
				fail("Found unwanted " + constraintType + " constraint " + constraintId + " on " + target); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Lines 223-231 Link Here
223
217
224
	protected void assertConstraintAndTargetPresent(String constraintType,
218
	protected void assertConstraintAndTargetPresent(String constraintType,
225
			IStatus[] statuses, String constraintId, EObject target) {
219
			IStatus[] statuses, String constraintId, EObject target) {
226
		for (int i = 0; i < statuses.length; i++) {
220
		for (IStatus element : statuses) {
227
			IConstraintStatus status = (IConstraintStatus)statuses[i];
221
			IConstraintStatus status = (IConstraintStatus)element;
228
			IModelConstraint constraint  = ((IConstraintStatus)statuses[i]).getConstraint();
222
			IModelConstraint constraint  = ((IConstraintStatus)element).getConstraint();
229
			
223
			
230
			if (target.equals(status.getTarget()) && constraintId.equals(constraint.getDescriptor().getId())) {
224
			if (target.equals(status.getTarget()) && constraintId.equals(constraint.getDescriptor().getId())) {
231
				return;
225
				return;
Lines 244-251 Link Here
244
	protected IStatus getStatus(IStatus[] statuses, String id) {
238
	protected IStatus getStatus(IStatus[] statuses, String id) {
245
		IStatus result = null;
239
		IStatus result = null;
246
		
240
		
247
		for (int i = 0; i < statuses.length; i++) {
241
		for (IStatus element : statuses) {
248
			IConstraintStatus next = (IConstraintStatus)statuses[i];
242
			IConstraintStatus next = (IConstraintStatus)element;
249
			
243
			
250
			if (next.getConstraint().getDescriptor().getId().equals(id)) {
244
			if (next.getConstraint().getDescriptor().getId().equals(id)) {
251
				result = next;
245
				result = next;
Lines 265-281 Link Here
265
	 * @since 1.1
259
	 * @since 1.1
266
	 */
260
	 */
267
	protected IStatus[] getStatuses(IStatus[] statuses, String id) {
261
	protected IStatus[] getStatuses(IStatus[] statuses, String id) {
268
		List result = new java.util.ArrayList();
262
		List<IStatus> result = new java.util.ArrayList<IStatus>();
269
		
263
		
270
		for (int i = 0; i < statuses.length; i++) {
264
		for (IStatus element : statuses) {
271
			IConstraintStatus next = (IConstraintStatus)statuses[i];
265
			IConstraintStatus next = (IConstraintStatus) element;
272
			
266
			
273
			if (next.getConstraint().getDescriptor().getId().equals(id)) {
267
			if (next.getConstraint().getDescriptor().getId().equals(id)) {
274
				result.add(next);
268
				result.add(next);
275
			}
269
			}
276
		}
270
		}
277
		
271
		
278
		return (IStatus[]) result.toArray(new IStatus[result.size()]);
272
		return result.toArray(new IStatus[result.size()]);
279
	}
273
	}
280
274
281
	/**
275
	/**
Lines 293-311 Link Here
293
			return new IStatus[0];
287
			return new IStatus[0];
294
		}
288
		}
295
		
289
		
296
		List result = new java.util.ArrayList();
290
		List<IStatus> result = new java.util.ArrayList<IStatus>();
297
		
291
		
298
		collectStatuses(status, result);
292
		collectStatuses(status, result);
299
		
293
		
300
		return (IStatus[]) result.toArray(new IStatus[result.size()]);
294
		return result.toArray(new IStatus[result.size()]);
301
	}
295
	}
302
	
296
	
303
	private void collectStatuses(IStatus status, List statuses) {
297
	private void collectStatuses(IStatus status, List<IStatus> statuses) {
304
		if (status.isMultiStatus()) {
298
		if (status.isMultiStatus()) {
305
			IStatus[] children = status.getChildren();
299
			IStatus[] children = status.getChildren();
306
			
300
			
307
			for (int i = 0; i < children.length; i++) {
301
			for (IStatus element : children) {
308
				collectStatuses(children[i], statuses);
302
				collectStatuses(element, statuses);
309
			}
303
			}
310
		} else {
304
		} else {
311
			statuses.add(status);
305
			statuses.add(status);
Lines 327-334 Link Here
327
		System.out.println(o);
321
		System.out.println(o);
328
	
322
	
329
		final int childTabs = tabs + 1;
323
		final int childTabs = tabs + 1;
330
		for (Iterator iter = o.eContents().iterator(); iter.hasNext(); ) {
324
		for (EObject next : o.eContents()) {
331
			showRecursive((EObject)iter.next(), childTabs);
325
			showRecursive(next, childTabs);
332
		}
326
		}
333
	}
327
	}
334
328
(-)src/org/eclipse/emf/validation/tests/Example1.java (-5 / +3 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
package org.eclipse.emf.validation.tests;
18
package org.eclipse.emf.validation.tests;
19
19
20
import java.util.Calendar;
20
import java.util.Calendar;
21
import java.util.Iterator;
22
import java.util.Random;
21
import java.util.Random;
23
22
24
import ordersystem.Account;
23
import ordersystem.Account;
Lines 88-96 Link Here
88
		result.setLocation(createAddress(city));
87
		result.setLocation(createAddress(city));
89
88
90
		int i = 1;
89
		int i = 1;
91
		for (Iterator iter = os.getProduct().iterator(); iter.hasNext(); ) {
90
		for (Product next : os.getProduct()) {
92
			result.getItem()
91
			result.getItem().add(createInventoryItem(next, i++));
93
					.add(createInventoryItem((Product)iter.next(), i++));
94
		}
92
		}
95
93
96
		os.getWarehouse().add(result);
94
		os.getWarehouse().add(result);
(-)src/org/eclipse/emf/validation/tests/TestBadXmlConfigProvider.java (-9 / +14 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2001 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 26-31 Link Here
26
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.Notification;
27
import org.eclipse.emf.ecore.EObject;
27
import org.eclipse.emf.ecore.EObject;
28
28
29
import org.eclipse.emf.validation.model.IModelConstraint;
29
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
30
import org.eclipse.emf.validation.service.AbstractConstraintProvider;
30
import org.eclipse.emf.validation.util.XmlConfig;
31
import org.eclipse.emf.validation.util.XmlConfig;
31
32
Lines 46-61 Link Here
46
 * @author Christian W. Damus (cdamus)
47
 * @author Christian W. Damus (cdamus)
47
 */
48
 */
48
public class TestBadXmlConfigProvider extends AbstractConstraintProvider {
49
public class TestBadXmlConfigProvider extends AbstractConstraintProvider {
49
	private static final java.util.Map instanceMap = new java.util.HashMap();
50
	private static final java.util.Map<String, TestBadXmlConfigProvider> instanceMap =
51
		new java.util.HashMap<String, TestBadXmlConfigProvider>();
50
	
52
	
51
	/**
53
	/**
52
	 * Always throws.
54
	 * Always throws.
53
	 * 
55
	 * 
54
	 * @throws RuntimeException always
56
	 * @throws RuntimeException always
55
	 */
57
	 */
56
	public Collection getLiveConstraints(
58
	@Override
59
	public Collection<IModelConstraint> getLiveConstraints(
57
			Notification notification,
60
			Notification notification,
58
			Collection constraints) {
61
			Collection<IModelConstraint> constraints) {
59
		if (AllTests.isExecutingUnitTests()) {
62
		if (AllTests.isExecutingUnitTests()) {
60
			// only throw if we are actually executing the unit tests
63
			// only throw if we are actually executing the unit tests
61
			throw new RuntimeException("I am supposed to abend."); //$NON-NLS-1$
64
			throw new RuntimeException("I am supposed to abend."); //$NON-NLS-1$
Lines 70-78 Link Here
70
	 * 
73
	 * 
71
	 * @throws RuntimeException always
74
	 * @throws RuntimeException always
72
	 */
75
	 */
73
	public Collection getBatchConstraints(
76
	@Override
77
	public Collection<IModelConstraint> getBatchConstraints(
74
			EObject eObject,
78
			EObject eObject,
75
			Collection constraints) {
79
			Collection<IModelConstraint> constraints) {
76
		if (AllTests.isExecutingUnitTests()) {
80
		if (AllTests.isExecutingUnitTests()) {
77
			// only throw if we are actually executing the unit tests
81
			// only throw if we are actually executing the unit tests
78
			throw new RuntimeException("I am supposed to abend."); //$NON-NLS-1$
82
			throw new RuntimeException("I am supposed to abend."); //$NON-NLS-1$
Lines 87-92 Link Here
87
	 * 
91
	 * 
88
	 * @throws CoreException if no <tt>&lt;constraints&gt;</tt> element is found
92
	 * @throws CoreException if no <tt>&lt;constraints&gt;</tt> element is found
89
	 */
93
	 */
94
	@Override
90
	public void setInitializationData(
95
	public void setInitializationData(
91
			IConfigurationElement config,
96
			IConfigurationElement config,
92
			String propertyName,
97
			String propertyName,
Lines 111-118 Link Here
111
		// put this instance into the map
116
		// put this instance into the map
112
		String[] uris = getNamespaceUris();
117
		String[] uris = getNamespaceUris();
113
		
118
		
114
		for (int i = 0; i < uris.length; i++) {
119
		for (String element : uris) {
115
			registerInstance(uris[i], this);
120
			registerInstance(element, this);
116
		}
121
		}
117
	}
122
	}
118
	
123
	
Lines 123-129 Link Here
123
	 * @return the corresponding instance
128
	 * @return the corresponding instance
124
	 */
129
	 */
125
	public static TestBadXmlConfigProvider getInstance(String uriNsPrefix) {
130
	public static TestBadXmlConfigProvider getInstance(String uriNsPrefix) {
126
		return (TestBadXmlConfigProvider)instanceMap.get(uriNsPrefix);
131
		return instanceMap.get(uriNsPrefix);
127
	}
132
	}
128
	
133
	
129
	private static synchronized void registerInstance(
134
	private static synchronized void registerInstance(
(-)src/org/eclipse/emf/validation/tests/MultiConstraint.java (-3 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-50 Link Here
34
	public static boolean enabled = false;
34
	public static boolean enabled = false;
35
	
35
	
36
	// Documentation copied from the inherited specification
36
	// Documentation copied from the inherited specification
37
	@Override
37
	public IStatus validate(IValidationContext ctx) {
38
	public IStatus validate(IValidationContext ctx) {
38
		if (!enabled) {
39
		if (!enabled) {
39
			return ctx.createSuccessStatus();
40
			return ctx.createSuccessStatus();
40
		}
41
		}
41
		
42
		
42
		Collection statuses = new java.util.ArrayList();
43
		Collection<IStatus> statuses = new java.util.ArrayList<IStatus>();
43
		
44
		
44
		statuses.add(ctx.createFailureStatus(new Object[] {"Nothing to say."})); //$NON-NLS-1$
45
		statuses.add(ctx.createFailureStatus(new Object[] {"Nothing to say."})); //$NON-NLS-1$
45
		
46
		
46
		// try a nested multi-status, just for fun
47
		// try a nested multi-status, just for fun
47
		Collection nested = new java.util.ArrayList();
48
		Collection<IStatus> nested = new java.util.ArrayList<IStatus>();
48
		nested.add(ConstraintStatus.createStatus(
49
		nested.add(ConstraintStatus.createStatus(
49
				ctx,
50
				ctx,
50
				ctx.getTarget().eContents(),
51
				ctx.getTarget().eContents(),
(-)src/org/eclipse/emf/validation/internal/xml/tests/XmlConstraintProviderTest.java (-35 / +22 lines)
Lines 17-25 Link Here
17
17
18
package org.eclipse.emf.validation.internal.xml.tests;
18
package org.eclipse.emf.validation.internal.xml.tests;
19
19
20
import java.util.Arrays;
21
import java.util.Collection;
20
import java.util.Collection;
22
import java.util.Iterator;
23
import java.util.List;
21
import java.util.List;
24
22
25
import ordersystem.OrderSystemFactory;
23
import ordersystem.OrderSystemFactory;
Lines 27-32 Link Here
27
25
28
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.core.runtime.IConfigurationElement;
27
import org.eclipse.core.runtime.IConfigurationElement;
28
import org.eclipse.core.runtime.IStatus;
30
import org.eclipse.emf.common.notify.Notification;
29
import org.eclipse.emf.common.notify.Notification;
31
import org.eclipse.emf.ecore.EObject;
30
import org.eclipse.emf.ecore.EObject;
32
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
31
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
Lines 34-40 Link Here
34
import org.eclipse.emf.validation.model.IModelConstraint;
33
import org.eclipse.emf.validation.model.IModelConstraint;
35
import org.eclipse.emf.validation.service.IBatchValidator;
34
import org.eclipse.emf.validation.service.IBatchValidator;
36
import org.eclipse.emf.validation.service.ITraversalStrategy;
35
import org.eclipse.emf.validation.service.ITraversalStrategy;
37
import org.eclipse.emf.validation.service.IValidator;
38
import org.eclipse.emf.validation.service.ModelValidationService;
36
import org.eclipse.emf.validation.service.ModelValidationService;
39
import org.eclipse.emf.validation.tests.TestBase;
37
import org.eclipse.emf.validation.tests.TestBase;
40
import org.eclipse.emf.validation.tests.TestNotification;
38
import org.eclipse.emf.validation.tests.TestNotification;
Lines 57-66 Link Here
57
		// validate an object for which the test plug-in does not define any
55
		// validate an object for which the test plug-in does not define any
58
		//    constraints at all, to force the providers to be loaded (so
56
		//    constraints at all, to force the providers to be loaded (so
59
		//    that the static "fixture" instance will be initialized)
57
		//    that the static "fixture" instance will be initialized)
60
		IValidator validator = ModelValidationService.getInstance().newValidator(
58
		IBatchValidator validator = ModelValidationService.getInstance().newValidator(
61
				EvaluationMode.BATCH);
59
				EvaluationMode.BATCH);
62
		((IBatchValidator)validator).setTraversalStrategy(
60
		validator.setTraversalStrategy(new ITraversalStrategy.Flat());
63
			new ITraversalStrategy.Flat());
64
		validator.validate(OrderSystemFactory.eINSTANCE.createInventoryItem());
61
		validator.validate(OrderSystemFactory.eINSTANCE.createInventoryItem());
65
	}
62
	}
66
	
63
	
Lines 73-83 Link Here
73
		private boolean initializationDataWasSet = false;
70
		private boolean initializationDataWasSet = false;
74
		
71
		
75
		// gives the outer class access to the protected superclass method
72
		// gives the outer class access to the protected superclass method
76
		protected List getConstraints() {
73
		@Override
74
		protected List<IModelConstraint> getConstraints() {
77
			return super.getConstraints();
75
			return super.getConstraints();
78
		}
76
		}
79
		
77
		
80
		// extends the inherited method to record the fact of this being set
78
		// extends the inherited method to record the fact of this being set
79
		@Override
81
		public void setInitializationData(IConfigurationElement config,
80
		public void setInitializationData(IConfigurationElement config,
82
				String propertyName, Object data) throws CoreException {
81
				String propertyName, Object data) throws CoreException {
83
			super.setInitializationData(config, propertyName, data);
82
			super.setInitializationData(config, propertyName, data);
Lines 99-120 Link Here
99
	}
98
	}
100
	
99
	
101
	public void test_getConstraints() {
100
	public void test_getConstraints() {
102
		Collection result = fixture.getConstraints();
101
		Collection<IModelConstraint> result = fixture.getConstraints();
103
		
102
		
104
		assertAllConstraintsPresent(
103
		assertAllConstraintsPresent(
105
				"various", //$NON-NLS-1$
104
				"various", //$NON-NLS-1$
106
				result,
105
				result,
107
				Arrays.asList(new Object[] {
106
				ID_PREFIX + "product.batch1", //$NON-NLS-1$
108
						ID_PREFIX + "product.batch1", //$NON-NLS-1$
107
				ID_PREFIX + "product.batch2", //$NON-NLS-1$
109
						ID_PREFIX + "product.batch2", //$NON-NLS-1$
108
				ID_PREFIX + "product.live1", //$NON-NLS-1$
110
						ID_PREFIX + "product.live1", //$NON-NLS-1$
109
				ID_PREFIX + "product.live2"); //$NON-NLS-1$
111
						ID_PREFIX + "product.live2", //$NON-NLS-1$
112
					}));
113
		
110
		
114
		// check that all of the constraints are proxies
111
		// check that all of the constraints are proxies
115
		for (Iterator iter = result.iterator(); iter.hasNext();) {
112
		for (IModelConstraint next : result) {
116
			IModelConstraint next = (IModelConstraint)iter.next();
117
			
118
			assertTrue(next.getClass().getName().endsWith("$ConstraintProxy")); //$NON-NLS-1$
113
			assertTrue(next.getClass().getName().endsWith("$ConstraintProxy")); //$NON-NLS-1$
119
		}
114
		}
120
	}
115
	}
Lines 122-144 Link Here
122
	public void test_getBatchConstraints() {
117
	public void test_getBatchConstraints() {
123
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
118
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
124
		
119
		
125
		Collection result = new java.util.HashSet();
120
		Collection<IModelConstraint> result = new java.util.HashSet<IModelConstraint>();
126
		
121
		
127
		fixture.getBatchConstraints(object, result);
122
		fixture.getBatchConstraints(object, result);
128
		
123
		
129
		assertAllConstraintsPresent(
124
		assertAllConstraintsPresent(
130
				"batch", //$NON-NLS-1$
125
				"batch", //$NON-NLS-1$
131
				result,
126
				result,
132
				Arrays.asList(new Object[] {
127
				ID_PREFIX + "product.batch1", //$NON-NLS-1$
133
						ID_PREFIX + "product.batch1", //$NON-NLS-1$
128
				ID_PREFIX + "product.batch2"); //$NON-NLS-1$
134
						ID_PREFIX + "product.batch2", //$NON-NLS-1$
135
					}));
136
	}
129
	}
137
130
138
	public void test_getLiveConstraints() {
131
	public void test_getLiveConstraints() {
139
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
132
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
140
		
133
		
141
		Collection result = new java.util.HashSet();
134
		Collection<IModelConstraint> result = new java.util.HashSet<IModelConstraint>();
142
		
135
		
143
		fixture.getLiveConstraints(
136
		fixture.getLiveConstraints(
144
				new TestNotification(object, Notification.SET),
137
				new TestNotification(object, Notification.SET),
Lines 147-168 Link Here
147
		assertAllConstraintsPresent(
140
		assertAllConstraintsPresent(
148
				"live", //$NON-NLS-1$
141
				"live", //$NON-NLS-1$
149
				result,
142
				result,
150
				Arrays.asList(new Object[] {
143
				ID_PREFIX + "product.live1"); //$NON-NLS-1$
151
						ID_PREFIX + "product.live1", //$NON-NLS-1$
152
					}));
153
		
144
		
154
		assertAllConstraintsNotPresent(
145
		assertAllConstraintsNotPresent(
155
				"live", //$NON-NLS-1$
146
				"live", //$NON-NLS-1$
156
				result,
147
				result,
157
				Arrays.asList(new Object[] {
148
				ID_PREFIX + "product.live2"); //$NON-NLS-1$
158
						ID_PREFIX + "product.live2", //$NON-NLS-1$
159
					}));
160
	}
149
	}
161
150
162
	public void test_getLiveConstraintsForFeature() {
151
	public void test_getLiveConstraintsForFeature() {
163
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
152
		EObject object = OrderSystemFactory.eINSTANCE.createProduct();
164
		
153
		
165
		Collection result = new java.util.HashSet();
154
		Collection<IModelConstraint> result = new java.util.HashSet<IModelConstraint>();
166
		
155
		
167
		fixture.getLiveConstraints(
156
		fixture.getLiveConstraints(
168
				new TestNotification(
157
				new TestNotification(
Lines 177-190 Link Here
177
		assertAllConstraintsPresent(
166
		assertAllConstraintsPresent(
178
				"live", //$NON-NLS-1$
167
				"live", //$NON-NLS-1$
179
				result,
168
				result,
180
				Arrays.asList(new Object[] {
169
				ID_PREFIX + "product.live1", //$NON-NLS-1$
181
						ID_PREFIX + "product.live1", //$NON-NLS-1$
170
				ID_PREFIX + "product.live2"); //$NON-NLS-1$
182
						ID_PREFIX + "product.live2", //$NON-NLS-1$
183
					}));
184
	}
171
	}
185
    
172
    
186
    public void test_duplicateConstraintsLogged_207988() {
173
    public void test_duplicateConstraintsLogged_207988() {
187
        List statuses = TestPlugin.getLogCapture().getLogs(
174
        List<IStatus> statuses = TestPlugin.getLogCapture().getLogs(
188
            EMFModelValidationStatusCodes.PROVIDER_DUPLICATE_CONSTRAINT);
175
            EMFModelValidationStatusCodes.PROVIDER_DUPLICATE_CONSTRAINT);
189
        assertFalse("Duplicate constraint not logged", statuses.isEmpty()); //$NON-NLS-1$
176
        assertFalse("Duplicate constraint not logged", statuses.isEmpty()); //$NON-NLS-1$
190
    }
177
    }
(-)src/org/eclipse/emf/validation/internal/service/tests/ParameterizedConstraintParserTest.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2006 IBM Corporation and others.
4
 * Copyright (c) 2006, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.validation.internal.service.tests;
17
package org.eclipse.emf.validation.internal.service.tests;
18
18
19
import java.util.Arrays;
20
import java.util.Collections;
19
import java.util.Collections;
21
20
22
import ordersystem.Order;
21
import ordersystem.Order;
Lines 79-85 Link Here
79
		assertAllConstraintsPresent(
78
		assertAllConstraintsPresent(
80
				"batch", //$NON-NLS-1$
79
				"batch", //$NON-NLS-1$
81
				statuses,
80
				statuses,
82
				Arrays.asList(new String[] {TEST_ID1}));
81
				TEST_ID1);
83
		
82
		
84
		IStatus status = getStatus(statuses, TEST_ID1);
83
		IStatus status = getStatus(statuses, TEST_ID1);
85
		
84
		
Lines 109-115 Link Here
109
		assertAllConstraintsPresent(
108
		assertAllConstraintsPresent(
110
				"batch", //$NON-NLS-1$
109
				"batch", //$NON-NLS-1$
111
				statuses,
110
				statuses,
112
				Arrays.asList(new String[] {TEST_ID2}));
111
				TEST_ID2);
113
		
112
		
114
		IStatus status = getStatus(statuses, TEST_ID2);
113
		IStatus status = getStatus(statuses, TEST_ID2);
115
		
114
		
Lines 138-144 Link Here
138
		assertAllConstraintsPresent(
137
		assertAllConstraintsPresent(
139
				"batch", //$NON-NLS-1$
138
				"batch", //$NON-NLS-1$
140
				statuses,
139
				statuses,
141
				Arrays.asList(new String[] {ID_PREFIX + "order.newParserAPI"})); //$NON-NLS-1$
140
				ID_PREFIX + "order.newParserAPI"); //$NON-NLS-1$
142
		
141
		
143
		IStatus status = getStatus(statuses, ID_PREFIX + "order.newParserAPI"); //$NON-NLS-1$
142
		IStatus status = getStatus(statuses, ID_PREFIX + "order.newParserAPI"); //$NON-NLS-1$
144
		
143
		
Lines 200-205 Link Here
200
	public static final class JavaConstraint extends AbstractModelConstraint {
199
	public static final class JavaConstraint extends AbstractModelConstraint {
201
		static boolean enabled = false;
200
		static boolean enabled = false;
202
201
202
		@Override
203
		public IStatus validate(IValidationContext ctx) {
203
		public IStatus validate(IValidationContext ctx) {
204
			assertTrue(ctx.getTarget() instanceof Order);
204
			assertTrue(ctx.getTarget() instanceof Order);
205
			
205
			
Lines 251-257 Link Here
251
			return "Test constraint"; //$NON-NLS-1$
251
			return "Test constraint"; //$NON-NLS-1$
252
		}
252
		}
253
253
254
		public EvaluationMode getEvaluationMode() {
254
		public EvaluationMode<?> getEvaluationMode() {
255
			return EvaluationMode.BATCH;
255
			return EvaluationMode.BATCH;
256
		}
256
		}
257
257
(-)src/org/eclipse/emf/validation/internal/service/tests/ModelValidationServiceTest.java (-47 / +35 lines)
Lines 22-28 Link Here
22
import java.util.Collection;
22
import java.util.Collection;
23
import java.util.Collections;
23
import java.util.Collections;
24
import java.util.List;
24
import java.util.List;
25
import java.util.ListIterator;
26
import java.util.Set;
25
import java.util.Set;
27
26
28
import ordersystem.Address;
27
import ordersystem.Address;
Lines 53-60 Link Here
53
import org.eclipse.emf.validation.service.IBatchValidator;
52
import org.eclipse.emf.validation.service.IBatchValidator;
54
import org.eclipse.emf.validation.service.IConstraintDescriptor;
53
import org.eclipse.emf.validation.service.IConstraintDescriptor;
55
import org.eclipse.emf.validation.service.IConstraintFilter;
54
import org.eclipse.emf.validation.service.IConstraintFilter;
55
import org.eclipse.emf.validation.service.ILiveValidator;
56
import org.eclipse.emf.validation.service.ITraversalStrategy;
56
import org.eclipse.emf.validation.service.ITraversalStrategy;
57
import org.eclipse.emf.validation.service.IValidator;
58
import org.eclipse.emf.validation.service.ModelValidationService;
57
import org.eclipse.emf.validation.service.ModelValidationService;
59
import org.eclipse.emf.validation.tests.CancelConstraint;
58
import org.eclipse.emf.validation.tests.CancelConstraint;
60
import org.eclipse.emf.validation.tests.MultiConstraint;
59
import org.eclipse.emf.validation.tests.MultiConstraint;
Lines 99-112 Link Here
99
		assertAllConstraintsPresent(
98
		assertAllConstraintsPresent(
100
				"batch", //$NON-NLS-1$
99
				"batch", //$NON-NLS-1$
101
				status,
100
				status,
102
				Arrays.asList(new String[] {
101
				ID_PREFIX + "order.hasContents", //$NON-NLS-1$
103
						ID_PREFIX + "order.hasContents", //$NON-NLS-1$
102
				ID_PREFIX + "order.notFilledBeforePlacement"); //$NON-NLS-1$
104
						ID_PREFIX + "order.notFilledBeforePlacement", //$NON-NLS-1$
105
				}));
106
	}
103
	}
107
104
108
	public void test_validateBatchCollection() {
105
	public void test_validateBatchCollection() {
109
		Collection objects = new java.util.ArrayList();
106
		Collection<EObject> objects = new java.util.ArrayList<EObject>();
110
		objects.add(OrderSystemFactory.eINSTANCE.createOrder());
107
		objects.add(OrderSystemFactory.eINSTANCE.createOrder());
111
		objects.add(OrderSystemFactory.eINSTANCE.createAddress());
108
		objects.add(OrderSystemFactory.eINSTANCE.createAddress());
112
109
Lines 129-142 Link Here
129
		assertAllTargetsPresent(
126
		assertAllTargetsPresent(
130
				"batch", //$NON-NLS-1$
127
				"batch", //$NON-NLS-1$
131
				status,
128
				status,
132
				Arrays.asList(new Object[] {
129
				Arrays.asList(new EObject[] {
133
						order,
130
						order,
134
						item,
131
						item,
135
				}));
132
				}));
136
	}
133
	}
137
134
138
	public void test_validateSubtreeBatchCollection() {
135
	public void test_validateSubtreeBatchCollection() {
139
		Collection orders = new java.util.ArrayList();
136
		Collection<EObject> orders = new java.util.ArrayList<EObject>();
140
		
137
		
141
		Order order1 = OrderSystemFactory.eINSTANCE.createOrder();
138
		Order order1 = OrderSystemFactory.eINSTANCE.createOrder();
142
		LineItem item1 = OrderSystemFactory.eINSTANCE.createLineItem();
139
		LineItem item1 = OrderSystemFactory.eINSTANCE.createLineItem();
Lines 155-161 Link Here
155
		assertAllTargetsPresent(
152
		assertAllTargetsPresent(
156
				"batch", //$NON-NLS-1$
153
				"batch", //$NON-NLS-1$
157
				status,
154
				status,
158
				Arrays.asList(new Object[] {
155
				Arrays.asList(new EObject[] {
159
						order1,
156
						order1,
160
						item1,
157
						item1,
161
						order2,
158
						order2,
Lines 173-186 Link Here
173
		assertAllConstraintsPresent(
170
		assertAllConstraintsPresent(
174
				"live", //$NON-NLS-1$
171
				"live", //$NON-NLS-1$
175
				status,
172
				status,
176
				Arrays.asList(new String[] {
173
				ID_PREFIX + "order.hasName", //$NON-NLS-1$
177
						ID_PREFIX + "order.hasName", //$NON-NLS-1$
174
				ID_PREFIX + "order.hasOwner"); //$NON-NLS-1$
178
						ID_PREFIX + "order.hasOwner", //$NON-NLS-1$
179
				}));
180
	}
175
	}
181
176
182
	public void test_validateLiveList() {
177
	public void test_validateLiveList() {
183
		List events = new java.util.ArrayList();
178
		List<Notification> events = new java.util.ArrayList<Notification>();
184
		Resource res = new XMIResourceImpl();
179
		Resource res = new XMIResourceImpl();
185
		
180
		
186
		Order order = OrderSystemFactory.eINSTANCE.createOrder();
181
		Order order = OrderSystemFactory.eINSTANCE.createOrder();
Lines 197-206 Link Here
197
192
198
		IStatus[] status = getStatuses(liveValidator.validate(events));
193
		IStatus[] status = getStatuses(liveValidator.validate(events));
199
194
200
		List targets = new java.util.LinkedList(events);
195
		List<EObject> targets = new java.util.ArrayList<EObject>(events.size());
201
		
196
		
202
		for (ListIterator iter = targets.listIterator(); iter.hasNext();) {
197
		for (Notification next : events) {
203
			iter.set(((Notification)iter.next()).getNotifier());
198
			targets.add((EObject) next.getNotifier());
204
		}
199
		}
205
		
200
		
206
		assertAllTargetsPresent(
201
		assertAllTargetsPresent(
Lines 226-234 Link Here
226
		assertAllConstraintsPresent(
221
		assertAllConstraintsPresent(
227
				"batch", //$NON-NLS-1$
222
				"batch", //$NON-NLS-1$
228
				status,
223
				status,
229
				Arrays.asList(new String[] {
224
				ID_PREFIX + "order.multiConstraint"); //$NON-NLS-1$
230
						ID_PREFIX + "order.multiConstraint", //$NON-NLS-1$
231
				}));
232
		
225
		
233
		status = getStatuses(status, ID_PREFIX + "order.multiConstraint"); //$NON-NLS-1$
226
		status = getStatuses(status, ID_PREFIX + "order.multiConstraint"); //$NON-NLS-1$
234
		assertEquals(3, status.length);
227
		assertEquals(3, status.length);
Lines 237-244 Link Here
237
		boolean foundFun = false;
230
		boolean foundFun = false;
238
		boolean foundSilly = false;
231
		boolean foundSilly = false;
239
		
232
		
240
		final Set justOrder = Collections.singleton(order);
233
		final Set<Order> justOrder = Collections.singleton(order);
241
		final Set orderAndItem = new java.util.HashSet();
234
		final Set<EObject> orderAndItem = new java.util.HashSet<EObject>();
242
		orderAndItem.add(order);
235
		orderAndItem.add(order);
243
		orderAndItem.addAll(order.getItem());
236
		orderAndItem.addAll(order.getItem());
244
		
237
		
Lines 293-301 Link Here
293
		assertAllConstraintsPresent(
286
		assertAllConstraintsPresent(
294
				"batch", //$NON-NLS-1$
287
				"batch", //$NON-NLS-1$
295
				status,
288
				status,
296
				Arrays.asList(new String[] {
289
				ID_PREFIX + "order.setTargetConstraint"); //$NON-NLS-1$
297
						ID_PREFIX + "order.setTargetConstraint", //$NON-NLS-1$
298
				}));
299
		
290
		
300
		status = getStatuses(status, ID_PREFIX + "order.setTargetConstraint"); //$NON-NLS-1$
291
		status = getStatuses(status, ID_PREFIX + "order.setTargetConstraint"); //$NON-NLS-1$
301
		assertEquals(3, status.length);
292
		assertEquals(3, status.length);
Lines 304-311 Link Here
304
		boolean foundSilly = false;
295
		boolean foundSilly = false;
305
		boolean foundSuccess = false;
296
		boolean foundSuccess = false;
306
		
297
		
307
		final Set justItem = Collections.singleton(item);
298
		final Set<LineItem> justItem = Collections.singleton(item);
308
		final Set orderAndItem = new java.util.HashSet();
299
		final Set<EObject> orderAndItem = new java.util.HashSet<EObject>();
309
		orderAndItem.add(order);
300
		orderAndItem.add(order);
310
		orderAndItem.addAll(order.getItem());
301
		orderAndItem.addAll(order.getItem());
311
		
302
		
Lines 351-365 Link Here
351
		Order order2 = OrderSystemFactory.eINSTANCE.createOrder();
342
		Order order2 = OrderSystemFactory.eINSTANCE.createOrder();
352
		order2.setCompleted(false);
343
		order2.setCompleted(false);
353
		
344
		
354
		EList contents = new XMIResourceImpl().getContents();
345
		EList<EObject> contents = new XMIResourceImpl().getContents();
355
		contents.add(order1);
346
		contents.add(order1);
356
		contents.add(order2);
347
		contents.add(order2);
357
		
348
		
358
		Collection events = new ArrayList();
349
		Collection<Notification> events = new ArrayList<Notification>();
359
		events.add(new TestNotification(order1, Notification.SET));
350
		events.add(new TestNotification(order1, Notification.SET));
360
		events.add(new TestNotification(order2, Notification.SET));
351
		events.add(new TestNotification(order2, Notification.SET));
361
		
352
		
362
		IValidator validator = ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
353
		ILiveValidator validator = ModelValidationService.getInstance().newValidator(
354
		    EvaluationMode.LIVE);
363
        IConstraintFilter filter = new IConstraintFilter() {
355
        IConstraintFilter filter = new IConstraintFilter() {
364
            public boolean accept(IConstraintDescriptor constraint,
356
            public boolean accept(IConstraintDescriptor constraint,
365
                    EObject object) {
357
                    EObject object) {
Lines 394-404 Link Here
394
		Order order2 = OrderSystemFactory.eINSTANCE.createOrder();
386
		Order order2 = OrderSystemFactory.eINSTANCE.createOrder();
395
		order2.setCompleted(false);
387
		order2.setCompleted(false);
396
		
388
		
397
		EList contents = new XMIResourceImpl().getContents();
389
		EList<EObject> contents = new XMIResourceImpl().getContents();
398
		contents.add(order1);
390
		contents.add(order1);
399
		contents.add(order2);
391
		contents.add(order2);
400
		
392
		
401
		Collection targets = new ArrayList();
393
		Collection<EObject> targets = new ArrayList<EObject>();
402
		targets.add(order1);
394
		targets.add(order1);
403
		targets.add(order2);
395
		targets.add(order2);
404
		
396
		
Lines 447-455 Link Here
447
        assertAllConstraintsPresent(
439
        assertAllConstraintsPresent(
448
                "batch", //$NON-NLS-1$
440
                "batch", //$NON-NLS-1$
449
                status,
441
                status,
450
                Arrays.asList(new String[] {
442
                ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
451
                        ID_PREFIX + "order.cancelConstraint", //$NON-NLS-1$
452
                }));
453
        
443
        
454
        IStatus particular = getStatus(status, ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
444
        IStatus particular = getStatus(status, ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
455
        assertTrue("Wrong kind of constraint", particular instanceof IConstraintStatus); //$NON-NLS-1$
445
        assertTrue("Wrong kind of constraint", particular instanceof IConstraintStatus); //$NON-NLS-1$
Lines 470-485 Link Here
470
        EObject object = OrderSystemFactory.eINSTANCE.createOrder();
460
        EObject object = OrderSystemFactory.eINSTANCE.createOrder();
471
        res.getContents().add(object);    // must be in a resource
461
        res.getContents().add(object);    // must be in a resource
472
462
473
        Collection events = new ArrayList();
463
        Collection<Notification> events = new ArrayList<Notification>();
474
        events.add(new TestNotification(object, Notification.SET));
464
        events.add(new TestNotification(object, Notification.SET));
475
        IStatus[] status = getStatuses(liveValidator.validate(events));
465
        IStatus[] status = getStatuses(liveValidator.validate(events));
476
466
477
        assertAllConstraintsPresent(
467
        assertAllConstraintsPresent(
478
                "live", //$NON-NLS-1$
468
                "live", //$NON-NLS-1$
479
                status,
469
                status,
480
                Arrays.asList(new String[] {
470
                ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
481
                        ID_PREFIX + "order.cancelConstraint", //$NON-NLS-1$
482
                }));
483
        
471
        
484
        IStatus particular = getStatus(status, ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
472
        IStatus particular = getStatus(status, ID_PREFIX + "order.cancelConstraint"); //$NON-NLS-1$
485
        assertTrue("Wrong kind of constraint", particular instanceof IConstraintStatus); //$NON-NLS-1$
473
        assertTrue("Wrong kind of constraint", particular instanceof IConstraintStatus); //$NON-NLS-1$
Lines 504-509 Link Here
504
        epackage.getEClassifiers().add(myOrderClass);
492
        epackage.getEClassifiers().add(myOrderClass);
505
        
493
        
506
        class MyOrderImpl extends OrderImpl {
494
        class MyOrderImpl extends OrderImpl {
495
            @Override
507
            public EClass eClass() {
496
            public EClass eClass() {
508
                return myOrderClass;
497
                return myOrderClass;
509
            }
498
            }
Lines 519-528 Link Here
519
        assertAllConstraintsPresent(
508
        assertAllConstraintsPresent(
520
            "batch", //$NON-NLS-1$
509
            "batch", //$NON-NLS-1$
521
            status,
510
            status,
522
            Arrays.asList(new String[] {
511
            ID_PREFIX + "order.hasContents", //$NON-NLS-1$
523
                    ID_PREFIX + "order.hasContents", //$NON-NLS-1$
512
            ID_PREFIX + "order.notFilledBeforePlacement"); //$NON-NLS-1$
524
                    ID_PREFIX + "order.notFilledBeforePlacement", //$NON-NLS-1$
525
            }));
526
    }
513
    }
527
    
514
    
528
    /**
515
    /**
Lines 530-536 Link Here
530
     * not repeatedly validate an element.
517
     * not repeatedly validate an element.
531
     */
518
     */
532
    public void test_recursiveTraversalStrategy_207990() {
519
    public void test_recursiveTraversalStrategy_207990() {
533
        Collection objects = new java.util.ArrayList();
520
        Collection<EObject> objects = new java.util.ArrayList<EObject>();
534
        
521
        
535
        Order order1 = OrderSystemFactory.eINSTANCE.createOrder();
522
        Order order1 = OrderSystemFactory.eINSTANCE.createOrder();
536
        LineItem item1 = OrderSystemFactory.eINSTANCE.createLineItem();
523
        LineItem item1 = OrderSystemFactory.eINSTANCE.createLineItem();
Lines 540-546 Link Here
540
        objects.add(item1);  // child element precedes ancestor
527
        objects.add(item1);  // child element precedes ancestor
541
        objects.add(order1);
528
        objects.add(order1);
542
529
543
        Set visited = new java.util.HashSet();
530
        Set<EObject> visited = new java.util.HashSet<EObject>();
544
        ITraversalStrategy traversal = batchValidator.getDefaultTraversalStrategy();
531
        ITraversalStrategy traversal = batchValidator.getDefaultTraversalStrategy();
545
        
532
        
546
        traversal.startTraversal(objects, new NullProgressMonitor());
533
        traversal.startTraversal(objects, new NullProgressMonitor());
Lines 621-626 Link Here
621
    // Framework methods
608
    // Framework methods
622
    //
609
    //
623
    
610
    
611
    @Override
624
    protected void tearDown()
612
    protected void tearDown()
625
        throws Exception {
613
        throws Exception {
626
        
614
        
Lines 670-676 Link Here
670
            return delegate.next();
658
            return delegate.next();
671
        }
659
        }
672
660
673
        public void startTraversal(Collection traversalRoots,
661
        public void startTraversal(Collection<? extends EObject> traversalRoots,
674
                IProgressMonitor monitor) {
662
                IProgressMonitor monitor) {
675
            synchronized (TestTraversalStrategy.class) {
663
            synchronized (TestTraversalStrategy.class) {
676
                used = true;
664
                used = true;
(-)src/org/eclipse/emf/validation/internal/service/tests/ConstraintListenersTest.java (-2 / +4 lines)
Lines 138-143 Link Here
138
		assertNull("Remove category for non-associated category incorrectly sent an event", listener.getLastEvent()); //$NON-NLS-1$
138
		assertNull("Remove category for non-associated category incorrectly sent an event", listener.getLastEvent()); //$NON-NLS-1$
139
	}
139
	}
140
	
140
	
141
	@Override
141
	protected void setUp() throws Exception {
142
	protected void setUp() throws Exception {
142
		super.setUp();
143
		super.setUp();
143
		
144
		
Lines 149-154 Link Here
149
		listener.setEnabled(true);
150
		listener.setEnabled(true);
150
	}
151
	}
151
	
152
	
153
	@Override
152
	protected void tearDown() throws Exception {
154
	protected void tearDown() throws Exception {
153
		listener.setEnabled(false);
155
		listener.setEnabled(false);
154
		listener.setLastEvent(null);
156
		listener.setLastEvent(null);
Lines 199-206 Link Here
199
			return 0;
201
			return 0;
200
		}
202
		}
201
		
203
		
202
		public EvaluationMode getEvaluationMode() {
204
		public EvaluationMode<?> getEvaluationMode() {
203
			return null;
205
			return EvaluationMode.NULL;
204
		}
206
		}
205
207
206
		public boolean targetsTypeOf(EObject eObject) {
208
		public boolean targetsTypeOf(EObject eObject) {
(-)src/org/eclipse/emf/validation/internal/service/tests/ConstraintRegistryTest.java (-4 / +8 lines)
Lines 99-105 Link Here
99
	}
99
	}
100
100
101
	public void testGetAllDescriptors() {
101
	public void testGetAllDescriptors() {
102
		Collection allFound =
102
		Collection<IConstraintDescriptor> allFound =
103
			ConstraintRegistry.getInstance().getAllDescriptors();
103
			ConstraintRegistry.getInstance().getAllDescriptors();
104
		
104
		
105
		assertNotNull(allFound);
105
		assertNotNull(allFound);
Lines 185-198 Link Here
185
	public void test_bulkRegister() {
185
	public void test_bulkRegister() {
186
        ConstraintListener.getInstance().reset();
186
        ConstraintListener.getInstance().reset();
187
        
187
        
188
        Collection constraints = new java.util.ArrayList();
188
        Collection<IModelConstraint> constraints = new java.util.ArrayList<IModelConstraint>();
189
        constraints.add(new FixtureConstraint());
189
        constraints.add(new FixtureConstraint());
190
        constraints.add(new FixtureConstraint());
190
        constraints.add(new FixtureConstraint());
191
        constraints.add(new FixtureConstraint());
191
        constraints.add(new FixtureConstraint());
192
        constraints.add(new FixtureConstraint());
192
        constraints.add(new FixtureConstraint());
193
        
193
        
194
        class ProviderAccess extends AbstractConstraintProvider {
194
        class ProviderAccess extends AbstractConstraintProvider {
195
            public void registerConstraints(Collection constraints)
195
            @Override
196
            public void registerConstraints(
197
                    Collection<? extends IModelConstraint> constraints)
196
                throws ConstraintExistsException {
198
                throws ConstraintExistsException {
197
                super.registerConstraints(constraints);
199
                super.registerConstraints(constraints);
198
            }}
200
            }}
Lines 211-216 Link Here
211
	// Test fixtures
213
	// Test fixtures
212
	//
214
	//
213
    
215
    
216
    @Override
214
    protected void setUp() throws Exception {
217
    protected void setUp() throws Exception {
215
        super.setUp();
218
        super.setUp();
216
        
219
        
Lines 221-226 Link Here
221
        listener.setEnabled(true);
224
        listener.setEnabled(true);
222
    }
225
    }
223
    
226
    
227
    @Override
224
    protected void tearDown() throws Exception {
228
    protected void tearDown() throws Exception {
225
        ConstraintListener listener = ConstraintListener.getInstance();
229
        ConstraintListener listener = ConstraintListener.getInstance();
226
        
230
        
Lines 272-278 Link Here
272
			return 0;
276
			return 0;
273
		}
277
		}
274
		
278
		
275
		public EvaluationMode getEvaluationMode() {
279
		public EvaluationMode<?> getEvaluationMode() {
276
			return null;
280
			return null;
277
		}
281
		}
278
282
(-)src/org/eclipse/emf/validation/internal/service/tests/EventTypeServiceTest.java (-1 / +2 lines)
Lines 46-52 Link Here
46
	}
46
	}
47
	
47
	
48
	public void test_getNotificationGenerators_177647() {
48
	public void test_getNotificationGenerators_177647() {
49
		Collection generators = EventTypeService.getInstance().getNotificationGenerators();
49
		Collection<INotificationGenerator> generators =
50
			EventTypeService.getInstance().getNotificationGenerators();
50
		
51
		
51
		assertEquals(generators.size(), 1);
52
		assertEquals(generators.size(), 1);
52
	}
53
	}
(-)src/ordersystem/special/SpecialPackage.java (-3 / +55 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-40 Link Here
35
 * </ul>
35
 * </ul>
36
 * <!-- end-user-doc -->
36
 * <!-- end-user-doc -->
37
 * @see ordersystem.special.SpecialFactory
37
 * @see ordersystem.special.SpecialFactory
38
 * @model kind="package"
38
 * @generated
39
 * @generated
39
 */
40
 */
40
public interface SpecialPackage extends EPackage{
41
public interface SpecialPackage extends EPackage{
Lines 135-141 Link Here
135
	int PREFERRED_CUSTOMER__SINCE = OrderSystemPackage.CUSTOMER_FEATURE_COUNT + 0;
136
	int PREFERRED_CUSTOMER__SINCE = OrderSystemPackage.CUSTOMER_FEATURE_COUNT + 0;
136
137
137
	/**
138
	/**
138
	 * The number of structural features of the the '<em>Preferred Customer</em>' class.
139
	 * The number of structural features of the '<em>Preferred Customer</em>' class.
139
	 * <!-- begin-user-doc -->
140
	 * <!-- begin-user-doc -->
140
	 * <!-- end-user-doc -->
141
	 * <!-- end-user-doc -->
141
	 * @generated
142
	 * @generated
Lines 199-205 Link Here
199
	int LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL = OrderSystemPackage.PRODUCT_FEATURE_COUNT + 0;
200
	int LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL = OrderSystemPackage.PRODUCT_FEATURE_COUNT + 0;
200
201
201
	/**
202
	/**
202
	 * The number of structural features of the the '<em>Limited Edition Product</em>' class.
203
	 * The number of structural features of the '<em>Limited Edition Product</em>' class.
203
	 * <!-- begin-user-doc -->
204
	 * <!-- begin-user-doc -->
204
	 * <!-- end-user-doc -->
205
	 * <!-- end-user-doc -->
205
	 * @generated
206
	 * @generated
Lines 259-262 Link Here
259
	 */
260
	 */
260
	SpecialFactory getSpecialFactory();
261
	SpecialFactory getSpecialFactory();
261
262
263
	/**
264
	 * <!-- begin-user-doc -->
265
	 * Defines literals for the meta objects that represent
266
	 * <ul>
267
	 *   <li>each class,</li>
268
	 *   <li>each feature of each class,</li>
269
	 *   <li>each enum,</li>
270
	 *   <li>and each data type</li>
271
	 * </ul>
272
	 * <!-- end-user-doc -->
273
	 * @generated
274
	 */
275
	interface Literals {
276
		/**
277
		 * The meta object literal for the '{@link ordersystem.special.impl.PreferredCustomerImpl <em>Preferred Customer</em>}' class.
278
		 * <!-- begin-user-doc -->
279
		 * <!-- end-user-doc -->
280
		 * @see ordersystem.special.impl.PreferredCustomerImpl
281
		 * @see ordersystem.special.impl.SpecialPackageImpl#getPreferredCustomer()
282
		 * @generated
283
		 */
284
		EClass PREFERRED_CUSTOMER = eINSTANCE.getPreferredCustomer();
285
286
		/**
287
		 * The meta object literal for the '<em><b>Since</b></em>' attribute feature.
288
		 * <!-- begin-user-doc -->
289
		 * <!-- end-user-doc -->
290
		 * @generated
291
		 */
292
		EAttribute PREFERRED_CUSTOMER__SINCE = eINSTANCE.getPreferredCustomer_Since();
293
294
		/**
295
		 * The meta object literal for the '{@link ordersystem.special.impl.LimitedEditionProductImpl <em>Limited Edition Product</em>}' class.
296
		 * <!-- begin-user-doc -->
297
		 * <!-- end-user-doc -->
298
		 * @see ordersystem.special.impl.LimitedEditionProductImpl
299
		 * @see ordersystem.special.impl.SpecialPackageImpl#getLimitedEditionProduct()
300
		 * @generated
301
		 */
302
		EClass LIMITED_EDITION_PRODUCT = eINSTANCE.getLimitedEditionProduct();
303
304
		/**
305
		 * The meta object literal for the '<em><b>Available Until</b></em>' attribute feature.
306
		 * <!-- begin-user-doc -->
307
		 * <!-- end-user-doc -->
308
		 * @generated
309
		 */
310
		EAttribute LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL = eINSTANCE.getLimitedEditionProduct_AvailableUntil();
311
312
	}
313
262
} //SpecialPackage
314
} //SpecialPackage
(-)src/ordersystem/special/PreferredCustomer.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-40 Link Here
34
 * </p>
34
 * </p>
35
 *
35
 *
36
 * @see ordersystem.special.SpecialPackage#getPreferredCustomer()
36
 * @see ordersystem.special.SpecialPackage#getPreferredCustomer()
37
 *
37
 * @model
38
 * @generated
38
 * @generated
39
 */
39
 */
40
public interface PreferredCustomer extends Customer {
40
public interface PreferredCustomer extends Customer {
(-)src/ordersystem/special/LimitedEditionProduct.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-40 Link Here
34
 * </p>
34
 * </p>
35
 *
35
 *
36
 * @see ordersystem.special.SpecialPackage#getLimitedEditionProduct()
36
 * @see ordersystem.special.SpecialPackage#getLimitedEditionProduct()
37
 *
37
 * @model
38
 * @generated
38
 * @generated
39
 */
39
 */
40
public interface LimitedEditionProduct extends Product {
40
public interface LimitedEditionProduct extends Product {
(-)src/ordersystem/special/SpecialFactory.java (-2 / +2 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-40 Link Here
34
	 * <!-- end-user-doc -->
34
	 * <!-- end-user-doc -->
35
	 * @generated
35
	 * @generated
36
	 */
36
	 */
37
	SpecialFactory eINSTANCE = new ordersystem.special.impl.SpecialFactoryImpl();
37
	SpecialFactory eINSTANCE = ordersystem.special.impl.SpecialFactoryImpl.init();
38
38
39
	/**
39
	/**
40
	 * Returns a new object of class '<em>Preferred Customer</em>'.
40
	 * Returns a new object of class '<em>Preferred Customer</em>'.
(-)src/org/eclipse/emf/validation/internal/model/tests/SpecialOrderNotificationGenerator.java (-9 / +5 lines)
Lines 20-27 Link Here
20
20
21
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.Collection;
22
import java.util.Collection;
23
import java.util.Iterator;
24
25
import ordersystem.LineItem;
23
import ordersystem.LineItem;
26
import ordersystem.Order;
24
import ordersystem.Order;
27
import ordersystem.special.LimitedEditionProduct;
25
import ordersystem.special.LimitedEditionProduct;
Lines 39-55 Link Here
39
	 * Create special notifications for those orders who contain limited
37
	 * Create special notifications for those orders who contain limited
40
	 * edition products
38
	 * edition products
41
	 */ 
39
	 */ 
42
	public Collection generateNotifications(Collection notifications) {
40
	public Collection<Notification> generateNotifications(Collection<? extends Notification> notifications) {
43
		Collection newNotifications = new ArrayList();
41
		Collection<Notification> newNotifications = new ArrayList<Notification>();
44
		
42
		
45
		for (Iterator iter=notifications.iterator(); iter.hasNext(); ) {
43
		for (Notification notification : notifications) {
46
			Notification notification = (Notification)iter.next();
47
			if (notification.getNotifier() instanceof Order) {
44
			if (notification.getNotifier() instanceof Order) {
48
				Order order = (Order)notification.getNotifier();
45
				Order order = (Order) notification.getNotifier();
49
				LimitedEditionProduct lep = null;
46
				LimitedEditionProduct lep = null;
50
				
47
				
51
				for (Iterator itemIter=order.getItem().iterator(); itemIter.hasNext();) {
48
				for (LineItem obj : order.getItem()) {
52
					LineItem obj = (LineItem)itemIter.next();
53
					if (obj.getProduct() instanceof LimitedEditionProduct)  {
49
					if (obj.getProduct() instanceof LimitedEditionProduct)  {
54
						lep = (LimitedEditionProduct)obj.getProduct();
50
						lep = (LimitedEditionProduct)obj.getProduct();
55
					}
51
					}
(-)src/org/eclipse/emf/validation/internal/model/tests/ConstraintSeverityTest.java (-6 / +5 lines)
Lines 25-31 Link Here
25
import java.io.ObjectInputStream;
25
import java.io.ObjectInputStream;
26
import java.io.ObjectOutput;
26
import java.io.ObjectOutput;
27
import java.io.ObjectOutputStream;
27
import java.io.ObjectOutputStream;
28
import java.util.Iterator;
29
import java.util.List;
28
import java.util.List;
30
29
31
import junit.framework.TestCase;
30
import junit.framework.TestCase;
Lines 53-59 Link Here
53
	}
52
	}
54
53
55
	public void test_getAllInstances() {
54
	public void test_getAllInstances() {
56
		List instances = ConstraintSeverity.getAllInstances();
55
		List<ConstraintSeverity> instances = ConstraintSeverity.getAllInstances();
57
		
56
		
58
		assertTrue(instances.contains(ConstraintSeverity.NULL));
57
		assertTrue(instances.contains(ConstraintSeverity.NULL));
59
		assertTrue(instances.contains(ConstraintSeverity.INFO));
58
		assertTrue(instances.contains(ConstraintSeverity.INFO));
Lines 84-91 Link Here
84
		try {
83
		try {
85
			output = new ObjectOutputStream(stream);
84
			output = new ObjectOutputStream(stream);
86
			
85
			
87
			for (Iterator i = ConstraintSeverity.getAllInstances().iterator(); i.hasNext();) {
86
			for (ConstraintSeverity next : ConstraintSeverity.getAllInstances()) {
88
				output.writeObject(i.next());
87
				output.writeObject(next);
89
			}
88
			}
90
			
89
			
91
			output.flush();
90
			output.flush();
Lines 93-100 Link Here
93
			input =	new ObjectInputStream(
92
			input =	new ObjectInputStream(
94
					new ByteArrayInputStream(stream.toByteArray()));
93
					new ByteArrayInputStream(stream.toByteArray()));
95
			
94
			
96
			for (Iterator i = ConstraintSeverity.getAllInstances().iterator(); i.hasNext();) {
95
			for (ConstraintSeverity next : ConstraintSeverity.getAllInstances()) {
97
				assertSame(i.next(), input.readObject());
96
				assertSame(next, input.readObject());
98
			}
97
			}
99
		} catch (Exception e) {
98
		} catch (Exception e) {
100
			fail(e.getLocalizedMessage());
99
			fail(e.getLocalizedMessage());
(-)src/org/eclipse/emf/validation/internal/model/tests/EMFEventTypeTest.java (-7 / +6 lines)
Lines 27-33 Link Here
27
import java.io.ObjectInputStream;
27
import java.io.ObjectInputStream;
28
import java.io.ObjectOutput;
28
import java.io.ObjectOutput;
29
import java.io.ObjectOutputStream;
29
import java.io.ObjectOutputStream;
30
import java.util.Iterator;
31
import java.util.List;
30
import java.util.List;
32
31
33
import junit.framework.TestCase;
32
import junit.framework.TestCase;
Lines 112-118 Link Here
112
	}
111
	}
113
112
114
	public void test_getPredefinedInstances_177647() {
113
	public void test_getPredefinedInstances_177647() {
115
		List instances = EMFEventType.getPredefinedInstances();
114
		List<EMFEventType> instances = EMFEventType.getPredefinedInstances();
116
		
115
		
117
		assertTrue(instances.contains(EMFEventType.NULL));
116
		assertTrue(instances.contains(EMFEventType.NULL));
118
		assertTrue(instances.contains(EMFEventType.ADD));
117
		assertTrue(instances.contains(EMFEventType.ADD));
Lines 127-133 Link Here
127
	}
126
	}
128
	
127
	
129
	public void test_getAllInstances() {
128
	public void test_getAllInstances() {
130
		List instances = EMFEventType.getAllInstances();
129
		List<EMFEventType> instances = EMFEventType.getAllInstances();
131
		
130
		
132
		assertTrue(instances.contains(EMFEventType.NULL));
131
		assertTrue(instances.contains(EMFEventType.NULL));
133
		assertTrue(instances.contains(EMFEventType.ADD));
132
		assertTrue(instances.contains(EMFEventType.ADD));
Lines 198-205 Link Here
198
		try {
197
		try {
199
			output = new ObjectOutputStream(stream);
198
			output = new ObjectOutputStream(stream);
200
			
199
			
201
			for (Iterator i = EMFEventType.getAllInstances().iterator(); i.hasNext();) {
200
			for (EMFEventType next : EMFEventType.getAllInstances()) {
202
				output.writeObject(i.next());
201
				output.writeObject(next);
203
			}
202
			}
204
			
203
			
205
			output.flush();
204
			output.flush();
Lines 207-214 Link Here
207
			input =	new ObjectInputStream(
206
			input =	new ObjectInputStream(
208
					new ByteArrayInputStream(stream.toByteArray()));
207
					new ByteArrayInputStream(stream.toByteArray()));
209
			
208
			
210
			for (Iterator i = EMFEventType.getAllInstances().iterator(); i.hasNext();) {
209
			for (EMFEventType next : EMFEventType.getAllInstances()) {
211
				assertSame(i.next(), input.readObject());
210
				assertSame(next, input.readObject());
212
			}
211
			}
213
		} catch (Exception e) {
212
		} catch (Exception e) {
214
			fail(e.getLocalizedMessage());
213
			fail(e.getLocalizedMessage());
(-)src/org/eclipse/emf/validation/internal/model/tests/CategoryTest.java (-15 / +13 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 22-29 Link Here
22
import org.eclipse.emf.validation.model.CategoryManager;
22
import org.eclipse.emf.validation.model.CategoryManager;
23
23
24
import java.util.Collection;
24
import java.util.Collection;
25
import java.util.Iterator;
26
27
import junit.framework.TestCase;
25
import junit.framework.TestCase;
28
26
29
/**
27
/**
Lines 101-110 Link Here
101
	 * Tests the consistency of the top-level categories query.
99
	 * Tests the consistency of the top-level categories query.
102
	 */
100
	 */
103
	public void test_getTopLevelCategories() {
101
	public void test_getTopLevelCategories() {
104
		Collection topLevel = mgr.getTopLevelCategories();
102
		Collection<Category> topLevel = mgr.getTopLevelCategories();
105
		
103
		
106
		for (Iterator iter = topLevel.iterator(); iter.hasNext();) {
104
		for (Category next : topLevel) {
107
			assertNull(((Category)iter.next()).getParent());
105
			assertNull(next.getParent());
108
		}
106
		}
109
	}
107
	}
110
	
108
	
Lines 112-121 Link Here
112
	 * Tests the consistency of the mandatory categories query.
110
	 * Tests the consistency of the mandatory categories query.
113
	 */
111
	 */
114
	public void test_getMandatoryCategories() {
112
	public void test_getMandatoryCategories() {
115
		Collection topLevel = mgr.getMandatoryCategories();
113
		Collection<Category> topLevel = mgr.getMandatoryCategories();
116
		
114
		
117
		for (Iterator iter = topLevel.iterator(); iter.hasNext();) {
115
		for (Category next : topLevel) {
118
			assertTrue(((Category)iter.next()).isMandatory());
116
			assertTrue(next.isMandatory());
119
		}
117
		}
120
	}
118
	}
121
	
119
	
Lines 136-143 Link Here
136
	public void test_dumpCategories() {
134
	public void test_dumpCategories() {
137
		Trace.trace(">>> Testing dumpCategories"); //$NON-NLS-1$
135
		Trace.trace(">>> Testing dumpCategories"); //$NON-NLS-1$
138
		
136
		
139
		for (Iterator iter = mgr.getTopLevelCategories().iterator(); iter.hasNext();) {
137
		for (Category next : mgr.getTopLevelCategories()) {
140
			dumpCategory((Category)iter.next());
138
			dumpCategory(next);
141
		}
139
		}
142
	}
140
	}
143
	
141
	
Lines 149-160 Link Here
149
	private void dumpCategory(Category category) {
147
	private void dumpCategory(Category category) {
150
		Trace.trace(category.toString());
148
		Trace.trace(category.toString());
151
		
149
		
152
		for (Iterator iter = category.getConstraints().iterator(); iter.hasNext();) {
150
		for (Object next : category.getConstraints()) {
153
			Trace.trace("    " + iter.next()); //$NON-NLS-1$
151
			Trace.trace("    " + next); //$NON-NLS-1$
154
		}
152
		}
155
		
153
		
156
		for (Iterator iter = category.getChildren().iterator(); iter.hasNext();) {
154
		for (Category child : category.getChildren()) {
157
			dumpCategory((Category)iter.next());
155
			dumpCategory(child);
158
		}
156
		}
159
	}
157
	}
160
}
158
}
(-)src/org/eclipse/emf/validation/internal/model/tests/EvaluationModeTest.java (-6 / +5 lines)
Lines 23-29 Link Here
23
import java.io.ObjectInputStream;
23
import java.io.ObjectInputStream;
24
import java.io.ObjectOutput;
24
import java.io.ObjectOutput;
25
import java.io.ObjectOutputStream;
25
import java.io.ObjectOutputStream;
26
import java.util.Iterator;
27
import java.util.List;
26
import java.util.List;
28
27
29
import junit.framework.TestCase;
28
import junit.framework.TestCase;
Lines 51-57 Link Here
51
	}
50
	}
52
51
53
	public void test_getAllInstances() {
52
	public void test_getAllInstances() {
54
		List instances = EvaluationMode.getAllInstances();
53
		List<EvaluationMode<?>> instances = EvaluationMode.getAllInstances();
55
		
54
		
56
		assertTrue(instances.contains(EvaluationMode.BATCH));
55
		assertTrue(instances.contains(EvaluationMode.BATCH));
57
		assertTrue(instances.contains(EvaluationMode.LIVE));
56
		assertTrue(instances.contains(EvaluationMode.LIVE));
Lines 109-116 Link Here
109
		try {
108
		try {
110
			output = new ObjectOutputStream(stream);
109
			output = new ObjectOutputStream(stream);
111
			
110
			
112
			for (Iterator i = EvaluationMode.getAllInstances().iterator(); i.hasNext();) {
111
			for (EvaluationMode<?> next : EvaluationMode.getAllInstances()) {
113
				output.writeObject(i.next());
112
				output.writeObject(next);
114
			}
113
			}
115
			
114
			
116
			output.flush();
115
			output.flush();
Lines 118-125 Link Here
118
			input =	new ObjectInputStream(
117
			input =	new ObjectInputStream(
119
					new ByteArrayInputStream(stream.toByteArray()));
118
					new ByteArrayInputStream(stream.toByteArray()));
120
			
119
			
121
			for (Iterator i = EvaluationMode.getAllInstances().iterator(); i.hasNext();) {
120
			for (EvaluationMode<?> next : EvaluationMode.getAllInstances()) {
122
				assertSame(i.next(), input.readObject());
121
				assertSame(next, input.readObject());
123
			}
122
			}
124
		} catch (Exception e) {
123
		} catch (Exception e) {
125
			fail(e.getLocalizedMessage());
124
			fail(e.getLocalizedMessage());
(-)src/org/eclipse/emf/validation/internal/model/tests/ClientContextManagerTest.java (-10 / +11 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 105-110 Link Here
105
				{"class", TestSelector.class.getName()}})); //$NON-NLS-1$
105
				{"class", TestSelector.class.getName()}})); //$NON-NLS-1$
106
	}
106
	}
107
	
107
	
108
	@Override
108
	protected void setUp() {
109
	protected void setUp() {
109
		// this setup effectively tests the configureBindings() method,
110
		// this setup effectively tests the configureBindings() method,
110
		//    including the ability of the system to ignore
111
		//    including the ability of the system to ignore
Lines 158-164 Link Here
158
	
159
	
159
	public void test_getBindings_eobject() {
160
	public void test_getBindings_eobject() {
160
		IModelConstraint constraint = new TestConstraint();
161
		IModelConstraint constraint = new TestConstraint();
161
		Collection constraints = Collections.singleton(constraint);
162
		Collection<IModelConstraint> constraints = Collections.singleton(constraint);
162
		
163
		
163
		assertTrue(mgr.getBindings(product, constraints).contains(constraint));
164
		assertTrue(mgr.getBindings(product, constraints).contains(constraint));
164
		assertFalse(mgr.getBindings(order, constraints).contains(constraint));
165
		assertFalse(mgr.getBindings(order, constraints).contains(constraint));
Lines 166-179 Link Here
166
	
167
	
167
	public void test_getBindings_eobject_none() {
168
	public void test_getBindings_eobject_none() {
168
		IModelConstraint constraint = new TestConstraint();
169
		IModelConstraint constraint = new TestConstraint();
169
		Collection constraints = Collections.singleton(constraint);
170
		Collection<IModelConstraint> constraints = Collections.singleton(constraint);
170
		
171
		
171
		assertTrue(mgr.getBindings(order, constraints).isEmpty());
172
		assertTrue(mgr.getBindings(order, constraints).isEmpty());
172
	}
173
	}
173
	
174
	
174
	public void test_getBindings_context() {
175
	public void test_getBindings_context() {
175
		IModelConstraint constraint = new TestConstraint();
176
		IModelConstraint constraint = new TestConstraint();
176
		Collection constraints = Collections.singleton(constraint);
177
		Collection<IModelConstraint> constraints = Collections.singleton(constraint);
177
		
178
		
178
		assertTrue(mgr.getBindings(ctx, constraints).contains(constraint));
179
		assertTrue(mgr.getBindings(ctx, constraints).contains(constraint));
179
		assertFalse(mgr.getBindings(ctx2, constraints).contains(constraint));
180
		assertFalse(mgr.getBindings(ctx2, constraints).contains(constraint));
Lines 181-192 Link Here
181
	
182
	
182
	public void test_getBindings_contexts() {
183
	public void test_getBindings_contexts() {
183
		IModelConstraint constraint = new TestConstraint();
184
		IModelConstraint constraint = new TestConstraint();
184
		Collection constraints = Collections.singleton(constraint);
185
		Collection<IModelConstraint> constraints = Collections.singleton(constraint);
185
		
186
		
186
		assertTrue(mgr.getBindings(
187
		assertTrue(mgr.getBindings(
187
			Arrays.asList(new Object[] {ctx, ctx2}), constraints).contains(constraint));
188
			Arrays.asList(ctx, ctx2), constraints).contains(constraint));
188
		assertFalse(mgr.getBindings(
189
		assertFalse(mgr.getBindings(
189
			Arrays.asList(new Object[] {ctx2, ctx2}), constraints).contains(constraint));
190
			Arrays.asList(ctx2, ctx2), constraints).contains(constraint));
190
	}
191
	}
191
	
192
	
192
	public void test_defaultBindings_context() {
193
	public void test_defaultBindings_context() {
Lines 211-217 Link Here
211
					return descr;
212
					return descr;
212
				}};
213
				}};
213
			
214
			
214
			Collection constraints = Collections.singleton(constraint);
215
			Collection<IModelConstraint> constraints = Collections.singleton(constraint);
215
			
216
			
216
			IClientContext junitCtx = mgr.getClientContext(JUNIT_CLIENT);
217
			IClientContext junitCtx = mgr.getClientContext(JUNIT_CLIENT);
217
			
218
			
Lines 244-254 Link Here
244
					return descr;
245
					return descr;
245
				}};
246
				}};
246
			
247
			
247
			Collection contexts = new java.util.ArrayList();
248
			Collection<IClientContext> contexts = new java.util.ArrayList<IClientContext>();
248
			contexts.add(ctx);
249
			contexts.add(ctx);
249
			contexts.add(ctx2);
250
			contexts.add(ctx2);
250
			
251
			
251
			Collection constraints = Collections.singleton(constraint);
252
			Collection<IModelConstraint> constraints = Collections.singleton(constraint);
252
			
253
			
253
			IClientContext junitCtx = mgr.getClientContext(JUNIT_CLIENT);
254
			IClientContext junitCtx = mgr.getClientContext(JUNIT_CLIENT);
254
			
255
			
(-)src/org/eclipse/emf/validation/internal/model/tests/ConstraintStatusTest.java (-10 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 51-57 Link Here
51
	private static final EObject TEST_TARGET =
51
	private static final EObject TEST_TARGET =
52
		OrderSystemFactory.eINSTANCE.createWarehouse();
52
		OrderSystemFactory.eINSTANCE.createWarehouse();
53
	
53
	
54
	private static final Set TEST_RESULTLOCUS =
54
	private static final Set<EObject> TEST_RESULTLOCUS =
55
		Collections.singleton(TEST_TARGET);
55
		Collections.singleton(TEST_TARGET);
56
	
56
	
57
	private static FixtureConstraint fixtureConstraint;
57
	private static FixtureConstraint fixtureConstraint;
Lines 59-69 Link Here
59
	private static ConstraintStatus failedFixture;
59
	private static ConstraintStatus failedFixture;
60
	
60
	
61
	private static class FixtureConstraint implements IModelConstraint {
61
	private static class FixtureConstraint implements IModelConstraint {
62
		private String name;
62
		private final String name;
63
		private String id;
63
		private final String id;
64
		private String pluginId;
64
		private final String pluginId;
65
		private ConstraintSeverity severity;
65
		private final ConstraintSeverity severity;
66
		private int code;
66
		private final int code;
67
67
68
		FixtureConstraint(String name, String id, String pluginId,
68
		FixtureConstraint(String name, String id, String pluginId,
69
				ConstraintSeverity severity, int code) {
69
				ConstraintSeverity severity, int code) {
Lines 121-127 Link Here
121
					return null;
121
					return null;
122
				}
122
				}
123
123
124
				public EvaluationMode getEvaluationMode() {
124
				public EvaluationMode<?> getEvaluationMode() {
125
					return null;
125
					return null;
126
				}
126
				}
127
127
Lines 145-152 Link Here
145
					// do nothing
145
					// do nothing
146
				}
146
				}
147
147
148
				public Set getCategories() {
148
				public Set<Category> getCategories() {
149
					return Collections.EMPTY_SET;
149
					return Collections.emptySet();
150
				}
150
				}
151
151
152
				public void addCategory(Category category) {
152
				public void addCategory(Category category) {
(-)src/ordersystem/Product.java (-5 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-41 Link Here
35
 * </p>
35
 * </p>
36
 *
36
 *
37
 * @see ordersystem.OrderSystemPackage#getProduct()
37
 * @see ordersystem.OrderSystemPackage#getProduct()
38
 *
38
 * @model
39
 * @generated
39
 * @generated
40
 */
40
 */
41
public interface Product extends EObject{
41
public interface Product extends EObject{
Lines 50-56 Link Here
50
	 * @return the value of the '<em>Name</em>' attribute.
50
	 * @return the value of the '<em>Name</em>' attribute.
51
	 * @see #setName(String)
51
	 * @see #setName(String)
52
	 * @see ordersystem.OrderSystemPackage#getProduct_Name()
52
	 * @see ordersystem.OrderSystemPackage#getProduct_Name()
53
	 *
53
	 * @model
54
	 * @generated
54
	 * @generated
55
	 */
55
	 */
56
    String getName();
56
    String getName();
Lines 76-82 Link Here
76
	 * @return the value of the '<em>Sku</em>' attribute.
76
	 * @return the value of the '<em>Sku</em>' attribute.
77
	 * @see #setSku(String)
77
	 * @see #setSku(String)
78
	 * @see ordersystem.OrderSystemPackage#getProduct_Sku()
78
	 * @see ordersystem.OrderSystemPackage#getProduct_Sku()
79
	 *
79
	 * @model
80
	 * @generated
80
	 * @generated
81
	 */
81
	 */
82
    String getSku();
82
    String getSku();
Lines 102-108 Link Here
102
	 * @return the value of the '<em>Price</em>' attribute.
102
	 * @return the value of the '<em>Price</em>' attribute.
103
	 * @see #setPrice(double)
103
	 * @see #setPrice(double)
104
	 * @see ordersystem.OrderSystemPackage#getProduct_Price()
104
	 * @see ordersystem.OrderSystemPackage#getProduct_Price()
105
	 *
105
	 * @model
106
	 * @generated
106
	 * @generated
107
	 */
107
	 */
108
    double getPrice();
108
    double getPrice();
(-)src/ordersystem/Customer.java (-8 / +8 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 38-44 Link Here
38
 * </p>
38
 * </p>
39
 *
39
 *
40
 * @see ordersystem.OrderSystemPackage#getCustomer()
40
 * @see ordersystem.OrderSystemPackage#getCustomer()
41
 *
41
 * @model
42
 * @generated
42
 * @generated
43
 */
43
 */
44
public interface Customer extends EObject{
44
public interface Customer extends EObject{
Lines 53-59 Link Here
53
	 * @return the value of the '<em>Last Name</em>' attribute.
53
	 * @return the value of the '<em>Last Name</em>' attribute.
54
	 * @see #setLastName(String)
54
	 * @see #setLastName(String)
55
	 * @see ordersystem.OrderSystemPackage#getCustomer_LastName()
55
	 * @see ordersystem.OrderSystemPackage#getCustomer_LastName()
56
	 *
56
	 * @model
57
	 * @generated
57
	 * @generated
58
	 */
58
	 */
59
    String getLastName();
59
    String getLastName();
Lines 79-85 Link Here
79
	 * @return the value of the '<em>First Name</em>' attribute.
79
	 * @return the value of the '<em>First Name</em>' attribute.
80
	 * @see #setFirstName(String)
80
	 * @see #setFirstName(String)
81
	 * @see ordersystem.OrderSystemPackage#getCustomer_FirstName()
81
	 * @see ordersystem.OrderSystemPackage#getCustomer_FirstName()
82
	 *
82
	 * @model
83
	 * @generated
83
	 * @generated
84
	 */
84
	 */
85
    String getFirstName();
85
    String getFirstName();
Lines 135-144 Link Here
135
	 * @return the value of the '<em>Account</em>' containment reference list.
135
	 * @return the value of the '<em>Account</em>' containment reference list.
136
	 * @see ordersystem.OrderSystemPackage#getCustomer_Account()
136
	 * @see ordersystem.OrderSystemPackage#getCustomer_Account()
137
	 * @see ordersystem.Account#getOwner
137
	 * @see ordersystem.Account#getOwner
138
	 * @model type="ordersystem.Account" opposite="owner" containment="true"
138
	 * @model opposite="owner" containment="true"
139
	 * @generated
139
	 * @generated
140
	 */
140
	 */
141
    EList getAccount();
141
    EList<Account> getAccount();
142
142
143
	/**
143
	/**
144
	 * Returns the value of the '<em><b>Order</b></em>' containment reference list.
144
	 * Returns the value of the '<em><b>Order</b></em>' containment reference list.
Lines 153-161 Link Here
153
	 * @return the value of the '<em>Order</em>' containment reference list.
153
	 * @return the value of the '<em>Order</em>' containment reference list.
154
	 * @see ordersystem.OrderSystemPackage#getCustomer_Order()
154
	 * @see ordersystem.OrderSystemPackage#getCustomer_Order()
155
	 * @see ordersystem.Order#getOwner
155
	 * @see ordersystem.Order#getOwner
156
	 * @model type="ordersystem.Order" opposite="owner" containment="true"
156
	 * @model opposite="owner" containment="true"
157
	 * @generated
157
	 * @generated
158
	 */
158
	 */
159
    EList getOrder();
159
    EList<Order> getOrder();
160
160
161
} // Customer
161
} // Customer
(-)src/ordersystem/Order.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 41-47 Link Here
41
 * </p>
41
 * </p>
42
 *
42
 *
43
 * @see ordersystem.OrderSystemPackage#getOrder()
43
 * @see ordersystem.OrderSystemPackage#getOrder()
44
 *
44
 * @model
45
 * @generated
45
 * @generated
46
 */
46
 */
47
public interface Order extends EObject{
47
public interface Order extends EObject{
Lines 108-114 Link Here
108
	 * @return the value of the '<em>Completed</em>' attribute.
108
	 * @return the value of the '<em>Completed</em>' attribute.
109
	 * @see #setCompleted(boolean)
109
	 * @see #setCompleted(boolean)
110
	 * @see ordersystem.OrderSystemPackage#getOrder_Completed()
110
	 * @see ordersystem.OrderSystemPackage#getOrder_Completed()
111
	 *
111
	 * @model
112
	 * @generated
112
	 * @generated
113
	 */
113
	 */
114
    boolean isCompleted();
114
    boolean isCompleted();
Lines 134-140 Link Here
134
	 * @return the value of the '<em>Id</em>' attribute.
134
	 * @return the value of the '<em>Id</em>' attribute.
135
	 * @see #setId(String)
135
	 * @see #setId(String)
136
	 * @see ordersystem.OrderSystemPackage#getOrder_Id()
136
	 * @see ordersystem.OrderSystemPackage#getOrder_Id()
137
	 *
137
	 * @model
138
	 * @generated
138
	 * @generated
139
	 */
139
	 */
140
    String getId();
140
    String getId();
Lines 190-198 Link Here
190
	 * @return the value of the '<em>Item</em>' containment reference list.
190
	 * @return the value of the '<em>Item</em>' containment reference list.
191
	 * @see ordersystem.OrderSystemPackage#getOrder_Item()
191
	 * @see ordersystem.OrderSystemPackage#getOrder_Item()
192
	 * @see ordersystem.LineItem#getOwner
192
	 * @see ordersystem.LineItem#getOwner
193
	 * @model type="ordersystem.LineItem" opposite="owner" containment="true"
193
	 * @model opposite="owner" containment="true"
194
	 * @generated
194
	 * @generated
195
	 */
195
	 */
196
    EList getItem();
196
    EList<LineItem> getItem();
197
197
198
} // Order
198
} // Order
(-)src/ordersystem/InventoryItem.java (-4 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 38-44 Link Here
38
 * </p>
38
 * </p>
39
 *
39
 *
40
 * @see ordersystem.OrderSystemPackage#getInventoryItem()
40
 * @see ordersystem.OrderSystemPackage#getInventoryItem()
41
 *
41
 * @model
42
 * @generated
42
 * @generated
43
 */
43
 */
44
public interface InventoryItem extends EObject{
44
public interface InventoryItem extends EObject{
Lines 53-59 Link Here
53
	 * @return the value of the '<em>In Stock</em>' attribute.
53
	 * @return the value of the '<em>In Stock</em>' attribute.
54
	 * @see #setInStock(int)
54
	 * @see #setInStock(int)
55
	 * @see ordersystem.OrderSystemPackage#getInventoryItem_InStock()
55
	 * @see ordersystem.OrderSystemPackage#getInventoryItem_InStock()
56
	 *
56
	 * @model
57
	 * @generated
57
	 * @generated
58
	 */
58
	 */
59
    int getInStock();
59
    int getInStock();
Lines 79-85 Link Here
79
	 * @return the value of the '<em>Restock Threshold</em>' attribute.
79
	 * @return the value of the '<em>Restock Threshold</em>' attribute.
80
	 * @see #setRestockThreshold(int)
80
	 * @see #setRestockThreshold(int)
81
	 * @see ordersystem.OrderSystemPackage#getInventoryItem_RestockThreshold()
81
	 * @see ordersystem.OrderSystemPackage#getInventoryItem_RestockThreshold()
82
	 *
82
	 * @model
83
	 * @generated
83
	 * @generated
84
	 */
84
	 */
85
    int getRestockThreshold();
85
    int getRestockThreshold();
(-)src/ordersystem/OrderSystemFactory.java (-4 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 34-46 Link Here
34
     * <!-- end-user-doc -->
34
     * <!-- end-user-doc -->
35
	 * @generated
35
	 * @generated
36
	 */
36
	 */
37
    OrderSystemFactory eINSTANCE = new ordersystem.impl.OrderSystemFactoryImpl();
37
    OrderSystemFactory eINSTANCE = ordersystem.impl.OrderSystemFactoryImpl.init();
38
38
39
	/**
39
	/**
40
	 * Returns a new object of class '<em>OrderSystem</em>'.
40
	 * Returns a new object of class '<em>Order System</em>'.
41
	 * <!-- begin-user-doc -->
41
	 * <!-- begin-user-doc -->
42
     * <!-- end-user-doc -->
42
     * <!-- end-user-doc -->
43
	 * @return a new object of class '<em>OrderSystem</em>'.
43
	 * @return a new object of class '<em>Order System</em>'.
44
	 * @generated
44
	 * @generated
45
	 */
45
	 */
46
    OrderSystem createOrderSystem();
46
    OrderSystem createOrderSystem();
(-)src/ordersystem/OrderSystemPackage.java (-13 / +481 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-40 Link Here
35
 * </ul>
35
 * </ul>
36
 * <!-- end-user-doc -->
36
 * <!-- end-user-doc -->
37
 * @see ordersystem.OrderSystemFactory
37
 * @see ordersystem.OrderSystemFactory
38
 * @model kind="package"
38
 * @generated
39
 * @generated
39
 */
40
 */
40
public interface OrderSystemPackage extends EPackage{
41
public interface OrderSystemPackage extends EPackage{
Lines 71-77 Link Here
71
    OrderSystemPackage eINSTANCE = ordersystem.impl.OrderSystemPackageImpl.init();
72
    OrderSystemPackage eINSTANCE = ordersystem.impl.OrderSystemPackageImpl.init();
72
73
73
	/**
74
	/**
74
	 * The meta object id for the '{@link ordersystem.impl.OrderSystemImpl <em>OrderSystem</em>}' class.
75
	 * The meta object id for the '{@link ordersystem.impl.OrderSystemImpl <em>Order System</em>}' class.
75
	 * <!-- begin-user-doc -->
76
	 * <!-- begin-user-doc -->
76
     * <!-- end-user-doc -->
77
     * <!-- end-user-doc -->
77
	 * @see ordersystem.impl.OrderSystemImpl
78
	 * @see ordersystem.impl.OrderSystemImpl
Lines 175-181 Link Here
175
    int ORDER__ITEM = 5;
176
    int ORDER__ITEM = 5;
176
177
177
	/**
178
	/**
178
	 * The number of structural features of the the '<em>Order</em>' class.
179
	 * The number of structural features of the '<em>Order</em>' class.
179
	 * <!-- begin-user-doc -->
180
	 * <!-- begin-user-doc -->
180
     * <!-- end-user-doc -->
181
     * <!-- end-user-doc -->
181
	 * @generated
182
	 * @generated
Lines 240-246 Link Here
240
    int PRODUCT__OWNER = 3;
241
    int PRODUCT__OWNER = 3;
241
242
242
	/**
243
	/**
243
	 * The number of structural features of the the '<em>Product</em>' class.
244
	 * The number of structural features of the '<em>Product</em>' class.
244
	 * <!-- begin-user-doc -->
245
	 * <!-- begin-user-doc -->
245
     * <!-- end-user-doc -->
246
     * <!-- end-user-doc -->
246
	 * @generated
247
	 * @generated
Lines 295-301 Link Here
295
    int WAREHOUSE__LOCATION = 3;
296
    int WAREHOUSE__LOCATION = 3;
296
297
297
	/**
298
	/**
298
	 * The number of structural features of the the '<em>Warehouse</em>' class.
299
	 * The number of structural features of the '<em>Warehouse</em>' class.
299
	 * <!-- begin-user-doc -->
300
	 * <!-- begin-user-doc -->
300
     * <!-- end-user-doc -->
301
     * <!-- end-user-doc -->
301
	 * @generated
302
	 * @generated
Lines 340-346 Link Here
340
    int ORDER_SYSTEM__WAREHOUSE = 3;
341
    int ORDER_SYSTEM__WAREHOUSE = 3;
341
342
342
	/**
343
	/**
343
	 * The number of structural features of the the '<em>OrderSystem</em>' class.
344
	 * The number of structural features of the '<em>Order System</em>' class.
344
	 * <!-- begin-user-doc -->
345
	 * <!-- begin-user-doc -->
345
     * <!-- end-user-doc -->
346
     * <!-- end-user-doc -->
346
	 * @generated
347
	 * @generated
Lines 385-391 Link Here
385
    int LINE_ITEM__PRODUCT = 3;
386
    int LINE_ITEM__PRODUCT = 3;
386
387
387
	/**
388
	/**
388
	 * The number of structural features of the the '<em>Line Item</em>' class.
389
	 * The number of structural features of the '<em>Line Item</em>' class.
389
	 * <!-- begin-user-doc -->
390
	 * <!-- begin-user-doc -->
390
     * <!-- end-user-doc -->
391
     * <!-- end-user-doc -->
391
	 * @generated
392
	 * @generated
Lines 449-455 Link Here
449
    int INVENTORY_ITEM__PRODUCT = 4;
450
    int INVENTORY_ITEM__PRODUCT = 4;
450
451
451
	/**
452
	/**
452
	 * The number of structural features of the the '<em>Inventory Item</em>' class.
453
	 * The number of structural features of the '<em>Inventory Item</em>' class.
453
	 * <!-- begin-user-doc -->
454
	 * <!-- begin-user-doc -->
454
     * <!-- end-user-doc -->
455
     * <!-- end-user-doc -->
455
	 * @generated
456
	 * @generated
Lines 503-509 Link Here
503
    int CUSTOMER__ORDER = 4;
504
    int CUSTOMER__ORDER = 4;
504
505
505
	/**
506
	/**
506
	 * The number of structural features of the the '<em>Customer</em>' class.
507
	 * The number of structural features of the '<em>Customer</em>' class.
507
	 * <!-- begin-user-doc -->
508
	 * <!-- begin-user-doc -->
508
     * <!-- end-user-doc -->
509
     * <!-- end-user-doc -->
509
	 * @generated
510
	 * @generated
Lines 575-581 Link Here
575
    int ADDRESS__COUNTRY = 6;
576
    int ADDRESS__COUNTRY = 6;
576
577
577
	/**
578
	/**
578
	 * The number of structural features of the the '<em>Address</em>' class.
579
	 * The number of structural features of the '<em>Address</em>' class.
579
	 * <!-- begin-user-doc -->
580
	 * <!-- begin-user-doc -->
580
     * <!-- end-user-doc -->
581
     * <!-- end-user-doc -->
581
	 * @generated
582
	 * @generated
Lines 629-635 Link Here
629
    int ACCOUNT__SHIPPING_ADDRESS = 4;
630
    int ACCOUNT__SHIPPING_ADDRESS = 4;
630
631
631
	/**
632
	/**
632
	 * The number of structural features of the the '<em>Account</em>' class.
633
	 * The number of structural features of the '<em>Account</em>' class.
633
	 * <!-- begin-user-doc -->
634
	 * <!-- begin-user-doc -->
634
     * <!-- end-user-doc -->
635
     * <!-- end-user-doc -->
635
	 * @generated
636
	 * @generated
Lines 649-658 Link Here
649
650
650
651
651
	/**
652
	/**
652
	 * Returns the meta object for class '{@link ordersystem.OrderSystem <em>OrderSystem</em>}'.
653
	 * Returns the meta object for class '{@link ordersystem.OrderSystem <em>Order System</em>}'.
653
	 * <!-- begin-user-doc -->
654
	 * <!-- begin-user-doc -->
654
     * <!-- end-user-doc -->
655
     * <!-- end-user-doc -->
655
	 * @return the meta object for class '<em>OrderSystem</em>'.
656
	 * @return the meta object for class '<em>Order System</em>'.
656
	 * @see ordersystem.OrderSystem
657
	 * @see ordersystem.OrderSystem
657
	 * @generated
658
	 * @generated
658
	 */
659
	 */
Lines 1242-1245 Link Here
1242
	 */
1243
	 */
1243
    OrderSystemFactory getOrderSystemFactory();
1244
    OrderSystemFactory getOrderSystemFactory();
1244
1245
1246
	/**
1247
	 * <!-- begin-user-doc -->
1248
	 * Defines literals for the meta objects that represent
1249
	 * <ul>
1250
	 *   <li>each class,</li>
1251
	 *   <li>each feature of each class,</li>
1252
	 *   <li>each enum,</li>
1253
	 *   <li>and each data type</li>
1254
	 * </ul>
1255
	 * <!-- end-user-doc -->
1256
	 * @generated
1257
	 */
1258
	interface Literals {
1259
		/**
1260
		 * The meta object literal for the '{@link ordersystem.impl.OrderImpl <em>Order</em>}' class.
1261
		 * <!-- begin-user-doc -->
1262
		 * <!-- end-user-doc -->
1263
		 * @see ordersystem.impl.OrderImpl
1264
		 * @see ordersystem.impl.OrderSystemPackageImpl#getOrder()
1265
		 * @generated
1266
		 */
1267
		EClass ORDER = eINSTANCE.getOrder();
1268
1269
		/**
1270
		 * The meta object literal for the '<em><b>Placed On</b></em>' attribute feature.
1271
		 * <!-- begin-user-doc -->
1272
		 * <!-- end-user-doc -->
1273
		 * @generated
1274
		 */
1275
		EAttribute ORDER__PLACED_ON = eINSTANCE.getOrder_PlacedOn();
1276
1277
		/**
1278
		 * The meta object literal for the '<em><b>Filled On</b></em>' attribute feature.
1279
		 * <!-- begin-user-doc -->
1280
		 * <!-- end-user-doc -->
1281
		 * @generated
1282
		 */
1283
		EAttribute ORDER__FILLED_ON = eINSTANCE.getOrder_FilledOn();
1284
1285
		/**
1286
		 * The meta object literal for the '<em><b>Completed</b></em>' attribute feature.
1287
		 * <!-- begin-user-doc -->
1288
		 * <!-- end-user-doc -->
1289
		 * @generated
1290
		 */
1291
		EAttribute ORDER__COMPLETED = eINSTANCE.getOrder_Completed();
1292
1293
		/**
1294
		 * The meta object literal for the '<em><b>Id</b></em>' attribute feature.
1295
		 * <!-- begin-user-doc -->
1296
		 * <!-- end-user-doc -->
1297
		 * @generated
1298
		 */
1299
		EAttribute ORDER__ID = eINSTANCE.getOrder_Id();
1300
1301
		/**
1302
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1303
		 * <!-- begin-user-doc -->
1304
		 * <!-- end-user-doc -->
1305
		 * @generated
1306
		 */
1307
		EReference ORDER__OWNER = eINSTANCE.getOrder_Owner();
1308
1309
		/**
1310
		 * The meta object literal for the '<em><b>Item</b></em>' containment reference list feature.
1311
		 * <!-- begin-user-doc -->
1312
		 * <!-- end-user-doc -->
1313
		 * @generated
1314
		 */
1315
		EReference ORDER__ITEM = eINSTANCE.getOrder_Item();
1316
1317
		/**
1318
		 * The meta object literal for the '{@link ordersystem.impl.ProductImpl <em>Product</em>}' class.
1319
		 * <!-- begin-user-doc -->
1320
		 * <!-- end-user-doc -->
1321
		 * @see ordersystem.impl.ProductImpl
1322
		 * @see ordersystem.impl.OrderSystemPackageImpl#getProduct()
1323
		 * @generated
1324
		 */
1325
		EClass PRODUCT = eINSTANCE.getProduct();
1326
1327
		/**
1328
		 * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
1329
		 * <!-- begin-user-doc -->
1330
		 * <!-- end-user-doc -->
1331
		 * @generated
1332
		 */
1333
		EAttribute PRODUCT__NAME = eINSTANCE.getProduct_Name();
1334
1335
		/**
1336
		 * The meta object literal for the '<em><b>Sku</b></em>' attribute feature.
1337
		 * <!-- begin-user-doc -->
1338
		 * <!-- end-user-doc -->
1339
		 * @generated
1340
		 */
1341
		EAttribute PRODUCT__SKU = eINSTANCE.getProduct_Sku();
1342
1343
		/**
1344
		 * The meta object literal for the '<em><b>Price</b></em>' attribute feature.
1345
		 * <!-- begin-user-doc -->
1346
		 * <!-- end-user-doc -->
1347
		 * @generated
1348
		 */
1349
		EAttribute PRODUCT__PRICE = eINSTANCE.getProduct_Price();
1350
1351
		/**
1352
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1353
		 * <!-- begin-user-doc -->
1354
		 * <!-- end-user-doc -->
1355
		 * @generated
1356
		 */
1357
		EReference PRODUCT__OWNER = eINSTANCE.getProduct_Owner();
1358
1359
		/**
1360
		 * The meta object literal for the '{@link ordersystem.impl.WarehouseImpl <em>Warehouse</em>}' class.
1361
		 * <!-- begin-user-doc -->
1362
		 * <!-- end-user-doc -->
1363
		 * @see ordersystem.impl.WarehouseImpl
1364
		 * @see ordersystem.impl.OrderSystemPackageImpl#getWarehouse()
1365
		 * @generated
1366
		 */
1367
		EClass WAREHOUSE = eINSTANCE.getWarehouse();
1368
1369
		/**
1370
		 * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
1371
		 * <!-- begin-user-doc -->
1372
		 * <!-- end-user-doc -->
1373
		 * @generated
1374
		 */
1375
		EAttribute WAREHOUSE__NAME = eINSTANCE.getWarehouse_Name();
1376
1377
		/**
1378
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1379
		 * <!-- begin-user-doc -->
1380
		 * <!-- end-user-doc -->
1381
		 * @generated
1382
		 */
1383
		EReference WAREHOUSE__OWNER = eINSTANCE.getWarehouse_Owner();
1384
1385
		/**
1386
		 * The meta object literal for the '<em><b>Item</b></em>' containment reference list feature.
1387
		 * <!-- begin-user-doc -->
1388
		 * <!-- end-user-doc -->
1389
		 * @generated
1390
		 */
1391
		EReference WAREHOUSE__ITEM = eINSTANCE.getWarehouse_Item();
1392
1393
		/**
1394
		 * The meta object literal for the '<em><b>Location</b></em>' containment reference feature.
1395
		 * <!-- begin-user-doc -->
1396
		 * <!-- end-user-doc -->
1397
		 * @generated
1398
		 */
1399
		EReference WAREHOUSE__LOCATION = eINSTANCE.getWarehouse_Location();
1400
1401
		/**
1402
		 * The meta object literal for the '{@link ordersystem.impl.OrderSystemImpl <em>Order System</em>}' class.
1403
		 * <!-- begin-user-doc -->
1404
		 * <!-- end-user-doc -->
1405
		 * @see ordersystem.impl.OrderSystemImpl
1406
		 * @see ordersystem.impl.OrderSystemPackageImpl#getOrderSystem()
1407
		 * @generated
1408
		 */
1409
		EClass ORDER_SYSTEM = eINSTANCE.getOrderSystem();
1410
1411
		/**
1412
		 * The meta object literal for the '<em><b>Version</b></em>' attribute feature.
1413
		 * <!-- begin-user-doc -->
1414
		 * <!-- end-user-doc -->
1415
		 * @generated
1416
		 */
1417
		EAttribute ORDER_SYSTEM__VERSION = eINSTANCE.getOrderSystem_Version();
1418
1419
		/**
1420
		 * The meta object literal for the '<em><b>Customer</b></em>' containment reference list feature.
1421
		 * <!-- begin-user-doc -->
1422
		 * <!-- end-user-doc -->
1423
		 * @generated
1424
		 */
1425
		EReference ORDER_SYSTEM__CUSTOMER = eINSTANCE.getOrderSystem_Customer();
1426
1427
		/**
1428
		 * The meta object literal for the '<em><b>Product</b></em>' containment reference list feature.
1429
		 * <!-- begin-user-doc -->
1430
		 * <!-- end-user-doc -->
1431
		 * @generated
1432
		 */
1433
		EReference ORDER_SYSTEM__PRODUCT = eINSTANCE.getOrderSystem_Product();
1434
1435
		/**
1436
		 * The meta object literal for the '<em><b>Warehouse</b></em>' containment reference list feature.
1437
		 * <!-- begin-user-doc -->
1438
		 * <!-- end-user-doc -->
1439
		 * @generated
1440
		 */
1441
		EReference ORDER_SYSTEM__WAREHOUSE = eINSTANCE.getOrderSystem_Warehouse();
1442
1443
		/**
1444
		 * The meta object literal for the '{@link ordersystem.impl.LineItemImpl <em>Line Item</em>}' class.
1445
		 * <!-- begin-user-doc -->
1446
		 * <!-- end-user-doc -->
1447
		 * @see ordersystem.impl.LineItemImpl
1448
		 * @see ordersystem.impl.OrderSystemPackageImpl#getLineItem()
1449
		 * @generated
1450
		 */
1451
		EClass LINE_ITEM = eINSTANCE.getLineItem();
1452
1453
		/**
1454
		 * The meta object literal for the '<em><b>Quantity</b></em>' attribute feature.
1455
		 * <!-- begin-user-doc -->
1456
		 * <!-- end-user-doc -->
1457
		 * @generated
1458
		 */
1459
		EAttribute LINE_ITEM__QUANTITY = eINSTANCE.getLineItem_Quantity();
1460
1461
		/**
1462
		 * The meta object literal for the '<em><b>Discount</b></em>' attribute feature.
1463
		 * <!-- begin-user-doc -->
1464
		 * <!-- end-user-doc -->
1465
		 * @generated
1466
		 */
1467
		EAttribute LINE_ITEM__DISCOUNT = eINSTANCE.getLineItem_Discount();
1468
1469
		/**
1470
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1471
		 * <!-- begin-user-doc -->
1472
		 * <!-- end-user-doc -->
1473
		 * @generated
1474
		 */
1475
		EReference LINE_ITEM__OWNER = eINSTANCE.getLineItem_Owner();
1476
1477
		/**
1478
		 * The meta object literal for the '<em><b>Product</b></em>' reference feature.
1479
		 * <!-- begin-user-doc -->
1480
		 * <!-- end-user-doc -->
1481
		 * @generated
1482
		 */
1483
		EReference LINE_ITEM__PRODUCT = eINSTANCE.getLineItem_Product();
1484
1485
		/**
1486
		 * The meta object literal for the '{@link ordersystem.impl.InventoryItemImpl <em>Inventory Item</em>}' class.
1487
		 * <!-- begin-user-doc -->
1488
		 * <!-- end-user-doc -->
1489
		 * @see ordersystem.impl.InventoryItemImpl
1490
		 * @see ordersystem.impl.OrderSystemPackageImpl#getInventoryItem()
1491
		 * @generated
1492
		 */
1493
		EClass INVENTORY_ITEM = eINSTANCE.getInventoryItem();
1494
1495
		/**
1496
		 * The meta object literal for the '<em><b>In Stock</b></em>' attribute feature.
1497
		 * <!-- begin-user-doc -->
1498
		 * <!-- end-user-doc -->
1499
		 * @generated
1500
		 */
1501
		EAttribute INVENTORY_ITEM__IN_STOCK = eINSTANCE.getInventoryItem_InStock();
1502
1503
		/**
1504
		 * The meta object literal for the '<em><b>Restock Threshold</b></em>' attribute feature.
1505
		 * <!-- begin-user-doc -->
1506
		 * <!-- end-user-doc -->
1507
		 * @generated
1508
		 */
1509
		EAttribute INVENTORY_ITEM__RESTOCK_THRESHOLD = eINSTANCE.getInventoryItem_RestockThreshold();
1510
1511
		/**
1512
		 * The meta object literal for the '<em><b>Next Stock Date</b></em>' attribute feature.
1513
		 * <!-- begin-user-doc -->
1514
		 * <!-- end-user-doc -->
1515
		 * @generated
1516
		 */
1517
		EAttribute INVENTORY_ITEM__NEXT_STOCK_DATE = eINSTANCE.getInventoryItem_NextStockDate();
1518
1519
		/**
1520
		 * The meta object literal for the '<em><b>Warehouse</b></em>' container reference feature.
1521
		 * <!-- begin-user-doc -->
1522
		 * <!-- end-user-doc -->
1523
		 * @generated
1524
		 */
1525
		EReference INVENTORY_ITEM__WAREHOUSE = eINSTANCE.getInventoryItem_Warehouse();
1526
1527
		/**
1528
		 * The meta object literal for the '<em><b>Product</b></em>' reference feature.
1529
		 * <!-- begin-user-doc -->
1530
		 * <!-- end-user-doc -->
1531
		 * @generated
1532
		 */
1533
		EReference INVENTORY_ITEM__PRODUCT = eINSTANCE.getInventoryItem_Product();
1534
1535
		/**
1536
		 * The meta object literal for the '{@link ordersystem.impl.CustomerImpl <em>Customer</em>}' class.
1537
		 * <!-- begin-user-doc -->
1538
		 * <!-- end-user-doc -->
1539
		 * @see ordersystem.impl.CustomerImpl
1540
		 * @see ordersystem.impl.OrderSystemPackageImpl#getCustomer()
1541
		 * @generated
1542
		 */
1543
		EClass CUSTOMER = eINSTANCE.getCustomer();
1544
1545
		/**
1546
		 * The meta object literal for the '<em><b>Last Name</b></em>' attribute feature.
1547
		 * <!-- begin-user-doc -->
1548
		 * <!-- end-user-doc -->
1549
		 * @generated
1550
		 */
1551
		EAttribute CUSTOMER__LAST_NAME = eINSTANCE.getCustomer_LastName();
1552
1553
		/**
1554
		 * The meta object literal for the '<em><b>First Name</b></em>' attribute feature.
1555
		 * <!-- begin-user-doc -->
1556
		 * <!-- end-user-doc -->
1557
		 * @generated
1558
		 */
1559
		EAttribute CUSTOMER__FIRST_NAME = eINSTANCE.getCustomer_FirstName();
1560
1561
		/**
1562
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1563
		 * <!-- begin-user-doc -->
1564
		 * <!-- end-user-doc -->
1565
		 * @generated
1566
		 */
1567
		EReference CUSTOMER__OWNER = eINSTANCE.getCustomer_Owner();
1568
1569
		/**
1570
		 * The meta object literal for the '<em><b>Account</b></em>' containment reference list feature.
1571
		 * <!-- begin-user-doc -->
1572
		 * <!-- end-user-doc -->
1573
		 * @generated
1574
		 */
1575
		EReference CUSTOMER__ACCOUNT = eINSTANCE.getCustomer_Account();
1576
1577
		/**
1578
		 * The meta object literal for the '<em><b>Order</b></em>' containment reference list feature.
1579
		 * <!-- begin-user-doc -->
1580
		 * <!-- end-user-doc -->
1581
		 * @generated
1582
		 */
1583
		EReference CUSTOMER__ORDER = eINSTANCE.getCustomer_Order();
1584
1585
		/**
1586
		 * The meta object literal for the '{@link ordersystem.impl.AddressImpl <em>Address</em>}' class.
1587
		 * <!-- begin-user-doc -->
1588
		 * <!-- end-user-doc -->
1589
		 * @see ordersystem.impl.AddressImpl
1590
		 * @see ordersystem.impl.OrderSystemPackageImpl#getAddress()
1591
		 * @generated
1592
		 */
1593
		EClass ADDRESS = eINSTANCE.getAddress();
1594
1595
		/**
1596
		 * The meta object literal for the '<em><b>Number</b></em>' attribute feature.
1597
		 * <!-- begin-user-doc -->
1598
		 * <!-- end-user-doc -->
1599
		 * @generated
1600
		 */
1601
		EAttribute ADDRESS__NUMBER = eINSTANCE.getAddress_Number();
1602
1603
		/**
1604
		 * The meta object literal for the '<em><b>Street</b></em>' attribute feature.
1605
		 * <!-- begin-user-doc -->
1606
		 * <!-- end-user-doc -->
1607
		 * @generated
1608
		 */
1609
		EAttribute ADDRESS__STREET = eINSTANCE.getAddress_Street();
1610
1611
		/**
1612
		 * The meta object literal for the '<em><b>Apartment</b></em>' attribute feature.
1613
		 * <!-- begin-user-doc -->
1614
		 * <!-- end-user-doc -->
1615
		 * @generated
1616
		 */
1617
		EAttribute ADDRESS__APARTMENT = eINSTANCE.getAddress_Apartment();
1618
1619
		/**
1620
		 * The meta object literal for the '<em><b>City</b></em>' attribute feature.
1621
		 * <!-- begin-user-doc -->
1622
		 * <!-- end-user-doc -->
1623
		 * @generated
1624
		 */
1625
		EAttribute ADDRESS__CITY = eINSTANCE.getAddress_City();
1626
1627
		/**
1628
		 * The meta object literal for the '<em><b>Province</b></em>' attribute feature.
1629
		 * <!-- begin-user-doc -->
1630
		 * <!-- end-user-doc -->
1631
		 * @generated
1632
		 */
1633
		EAttribute ADDRESS__PROVINCE = eINSTANCE.getAddress_Province();
1634
1635
		/**
1636
		 * The meta object literal for the '<em><b>Postal Code</b></em>' attribute feature.
1637
		 * <!-- begin-user-doc -->
1638
		 * <!-- end-user-doc -->
1639
		 * @generated
1640
		 */
1641
		EAttribute ADDRESS__POSTAL_CODE = eINSTANCE.getAddress_PostalCode();
1642
1643
		/**
1644
		 * The meta object literal for the '<em><b>Country</b></em>' attribute feature.
1645
		 * <!-- begin-user-doc -->
1646
		 * <!-- end-user-doc -->
1647
		 * @generated
1648
		 */
1649
		EAttribute ADDRESS__COUNTRY = eINSTANCE.getAddress_Country();
1650
1651
		/**
1652
		 * The meta object literal for the '{@link ordersystem.impl.AccountImpl <em>Account</em>}' class.
1653
		 * <!-- begin-user-doc -->
1654
		 * <!-- end-user-doc -->
1655
		 * @see ordersystem.impl.AccountImpl
1656
		 * @see ordersystem.impl.OrderSystemPackageImpl#getAccount()
1657
		 * @generated
1658
		 */
1659
		EClass ACCOUNT = eINSTANCE.getAccount();
1660
1661
		/**
1662
		 * The meta object literal for the '<em><b>Payment Method</b></em>' attribute feature.
1663
		 * <!-- begin-user-doc -->
1664
		 * <!-- end-user-doc -->
1665
		 * @generated
1666
		 */
1667
		EAttribute ACCOUNT__PAYMENT_METHOD = eINSTANCE.getAccount_PaymentMethod();
1668
1669
		/**
1670
		 * The meta object literal for the '<em><b>Account Number</b></em>' attribute feature.
1671
		 * <!-- begin-user-doc -->
1672
		 * <!-- end-user-doc -->
1673
		 * @generated
1674
		 */
1675
		EAttribute ACCOUNT__ACCOUNT_NUMBER = eINSTANCE.getAccount_AccountNumber();
1676
1677
		/**
1678
		 * The meta object literal for the '<em><b>Owner</b></em>' container reference feature.
1679
		 * <!-- begin-user-doc -->
1680
		 * <!-- end-user-doc -->
1681
		 * @generated
1682
		 */
1683
		EReference ACCOUNT__OWNER = eINSTANCE.getAccount_Owner();
1684
1685
		/**
1686
		 * The meta object literal for the '<em><b>Billing Address</b></em>' containment reference feature.
1687
		 * <!-- begin-user-doc -->
1688
		 * <!-- end-user-doc -->
1689
		 * @generated
1690
		 */
1691
		EReference ACCOUNT__BILLING_ADDRESS = eINSTANCE.getAccount_BillingAddress();
1692
1693
		/**
1694
		 * The meta object literal for the '<em><b>Shipping Address</b></em>' containment reference feature.
1695
		 * <!-- begin-user-doc -->
1696
		 * <!-- end-user-doc -->
1697
		 * @generated
1698
		 */
1699
		EReference ACCOUNT__SHIPPING_ADDRESS = eINSTANCE.getAccount_ShippingAddress();
1700
1701
		/**
1702
		 * The meta object literal for the '<em>Java Date</em>' data type.
1703
		 * <!-- begin-user-doc -->
1704
		 * <!-- end-user-doc -->
1705
		 * @see java.util.Date
1706
		 * @see ordersystem.impl.OrderSystemPackageImpl#getJavaDate()
1707
		 * @generated
1708
		 */
1709
		EDataType JAVA_DATE = eINSTANCE.getJavaDate();
1710
1711
	}
1712
1245
} //OrderSystemPackage
1713
} //OrderSystemPackage
(-)src/ordersystem/Address.java (-9 / +9 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 38-44 Link Here
38
 * </p>
38
 * </p>
39
 *
39
 *
40
 * @see ordersystem.OrderSystemPackage#getAddress()
40
 * @see ordersystem.OrderSystemPackage#getAddress()
41
 *
41
 * @model
42
 * @generated
42
 * @generated
43
 */
43
 */
44
public interface Address extends EObject{
44
public interface Address extends EObject{
Lines 53-59 Link Here
53
	 * @return the value of the '<em>Number</em>' attribute.
53
	 * @return the value of the '<em>Number</em>' attribute.
54
	 * @see #setNumber(String)
54
	 * @see #setNumber(String)
55
	 * @see ordersystem.OrderSystemPackage#getAddress_Number()
55
	 * @see ordersystem.OrderSystemPackage#getAddress_Number()
56
	 *
56
	 * @model
57
	 * @generated
57
	 * @generated
58
	 */
58
	 */
59
    String getNumber();
59
    String getNumber();
Lines 79-85 Link Here
79
	 * @return the value of the '<em>Street</em>' attribute.
79
	 * @return the value of the '<em>Street</em>' attribute.
80
	 * @see #setStreet(String)
80
	 * @see #setStreet(String)
81
	 * @see ordersystem.OrderSystemPackage#getAddress_Street()
81
	 * @see ordersystem.OrderSystemPackage#getAddress_Street()
82
	 *
82
	 * @model
83
	 * @generated
83
	 * @generated
84
	 */
84
	 */
85
    String getStreet();
85
    String getStreet();
Lines 105-111 Link Here
105
	 * @return the value of the '<em>Apartment</em>' attribute.
105
	 * @return the value of the '<em>Apartment</em>' attribute.
106
	 * @see #setApartment(String)
106
	 * @see #setApartment(String)
107
	 * @see ordersystem.OrderSystemPackage#getAddress_Apartment()
107
	 * @see ordersystem.OrderSystemPackage#getAddress_Apartment()
108
	 *
108
	 * @model
109
	 * @generated
109
	 * @generated
110
	 */
110
	 */
111
    String getApartment();
111
    String getApartment();
Lines 131-137 Link Here
131
	 * @return the value of the '<em>City</em>' attribute.
131
	 * @return the value of the '<em>City</em>' attribute.
132
	 * @see #setCity(String)
132
	 * @see #setCity(String)
133
	 * @see ordersystem.OrderSystemPackage#getAddress_City()
133
	 * @see ordersystem.OrderSystemPackage#getAddress_City()
134
	 *
134
	 * @model
135
	 * @generated
135
	 * @generated
136
	 */
136
	 */
137
    String getCity();
137
    String getCity();
Lines 157-163 Link Here
157
	 * @return the value of the '<em>Province</em>' attribute.
157
	 * @return the value of the '<em>Province</em>' attribute.
158
	 * @see #setProvince(String)
158
	 * @see #setProvince(String)
159
	 * @see ordersystem.OrderSystemPackage#getAddress_Province()
159
	 * @see ordersystem.OrderSystemPackage#getAddress_Province()
160
	 *
160
	 * @model
161
	 * @generated
161
	 * @generated
162
	 */
162
	 */
163
    String getProvince();
163
    String getProvince();
Lines 183-189 Link Here
183
	 * @return the value of the '<em>Postal Code</em>' attribute.
183
	 * @return the value of the '<em>Postal Code</em>' attribute.
184
	 * @see #setPostalCode(String)
184
	 * @see #setPostalCode(String)
185
	 * @see ordersystem.OrderSystemPackage#getAddress_PostalCode()
185
	 * @see ordersystem.OrderSystemPackage#getAddress_PostalCode()
186
	 *
186
	 * @model
187
	 * @generated
187
	 * @generated
188
	 */
188
	 */
189
    String getPostalCode();
189
    String getPostalCode();
Lines 209-215 Link Here
209
	 * @return the value of the '<em>Country</em>' attribute.
209
	 * @return the value of the '<em>Country</em>' attribute.
210
	 * @see #setCountry(String)
210
	 * @see #setCountry(String)
211
	 * @see ordersystem.OrderSystemPackage#getAddress_Country()
211
	 * @see ordersystem.OrderSystemPackage#getAddress_Country()
212
	 *
212
	 * @model
213
	 * @generated
213
	 * @generated
214
	 */
214
	 */
215
    String getCountry();
215
    String getCountry();
(-)src/ordersystem/Warehouse.java (-5 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 37-43 Link Here
37
 * </p>
37
 * </p>
38
 *
38
 *
39
 * @see ordersystem.OrderSystemPackage#getWarehouse()
39
 * @see ordersystem.OrderSystemPackage#getWarehouse()
40
 *
40
 * @model
41
 * @generated
41
 * @generated
42
 */
42
 */
43
public interface Warehouse extends EObject{
43
public interface Warehouse extends EObject{
Lines 52-58 Link Here
52
	 * @return the value of the '<em>Name</em>' attribute.
52
	 * @return the value of the '<em>Name</em>' attribute.
53
	 * @see #setName(String)
53
	 * @see #setName(String)
54
	 * @see ordersystem.OrderSystemPackage#getWarehouse_Name()
54
	 * @see ordersystem.OrderSystemPackage#getWarehouse_Name()
55
	 *
55
	 * @model
56
	 * @generated
56
	 * @generated
57
	 */
57
	 */
58
    String getName();
58
    String getName();
Lines 108-117 Link Here
108
	 * @return the value of the '<em>Item</em>' containment reference list.
108
	 * @return the value of the '<em>Item</em>' containment reference list.
109
	 * @see ordersystem.OrderSystemPackage#getWarehouse_Item()
109
	 * @see ordersystem.OrderSystemPackage#getWarehouse_Item()
110
	 * @see ordersystem.InventoryItem#getWarehouse
110
	 * @see ordersystem.InventoryItem#getWarehouse
111
	 * @model type="ordersystem.InventoryItem" opposite="Warehouse" containment="true"
111
	 * @model opposite="Warehouse" containment="true"
112
	 * @generated
112
	 * @generated
113
	 */
113
	 */
114
    EList getItem();
114
    EList<InventoryItem> getItem();
115
115
116
	/**
116
	/**
117
	 * Returns the value of the '<em><b>Location</b></em>' containment reference.
117
	 * Returns the value of the '<em><b>Location</b></em>' containment reference.
(-)src/ordersystem/LineItem.java (-5 / +5 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 35-41 Link Here
35
 * </p>
35
 * </p>
36
 *
36
 *
37
 * @see ordersystem.OrderSystemPackage#getLineItem()
37
 * @see ordersystem.OrderSystemPackage#getLineItem()
38
 *
38
 * @model
39
 * @generated
39
 * @generated
40
 */
40
 */
41
public interface LineItem extends EObject{
41
public interface LineItem extends EObject{
Lines 50-56 Link Here
50
	 * @return the value of the '<em>Quantity</em>' attribute.
50
	 * @return the value of the '<em>Quantity</em>' attribute.
51
	 * @see #setQuantity(int)
51
	 * @see #setQuantity(int)
52
	 * @see ordersystem.OrderSystemPackage#getLineItem_Quantity()
52
	 * @see ordersystem.OrderSystemPackage#getLineItem_Quantity()
53
	 *
53
	 * @model
54
	 * @generated
54
	 * @generated
55
	 */
55
	 */
56
    int getQuantity();
56
    int getQuantity();
Lines 76-82 Link Here
76
	 * @return the value of the '<em>Discount</em>' attribute.
76
	 * @return the value of the '<em>Discount</em>' attribute.
77
	 * @see #setDiscount(double)
77
	 * @see #setDiscount(double)
78
	 * @see ordersystem.OrderSystemPackage#getLineItem_Discount()
78
	 * @see ordersystem.OrderSystemPackage#getLineItem_Discount()
79
	 *
79
	 * @model
80
	 * @generated
80
	 * @generated
81
	 */
81
	 */
82
    double getDiscount();
82
    double getDiscount();
Lines 148-154 Link Here
148
	/**
148
	/**
149
	 * <!-- begin-user-doc -->
149
	 * <!-- begin-user-doc -->
150
     * <!-- end-user-doc -->
150
     * <!-- end-user-doc -->
151
	 * @model parameters=""
151
	 * @model kind="operation"
152
	 * @generated
152
	 * @generated
153
	 */
153
	 */
154
    double getCost();
154
    double getCost();
(-)src/ordersystem/Account.java (-4 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 36-42 Link Here
36
 * </p>
36
 * </p>
37
 *
37
 *
38
 * @see ordersystem.OrderSystemPackage#getAccount()
38
 * @see ordersystem.OrderSystemPackage#getAccount()
39
 *
39
 * @model
40
 * @generated
40
 * @generated
41
 */
41
 */
42
public interface Account extends EObject{
42
public interface Account extends EObject{
Lines 51-57 Link Here
51
	 * @return the value of the '<em>Payment Method</em>' attribute.
51
	 * @return the value of the '<em>Payment Method</em>' attribute.
52
	 * @see #setPaymentMethod(String)
52
	 * @see #setPaymentMethod(String)
53
	 * @see ordersystem.OrderSystemPackage#getAccount_PaymentMethod()
53
	 * @see ordersystem.OrderSystemPackage#getAccount_PaymentMethod()
54
	 *
54
	 * @model
55
	 * @generated
55
	 * @generated
56
	 */
56
	 */
57
    String getPaymentMethod();
57
    String getPaymentMethod();
Lines 77-83 Link Here
77
	 * @return the value of the '<em>Account Number</em>' attribute.
77
	 * @return the value of the '<em>Account Number</em>' attribute.
78
	 * @see #setAccountNumber(String)
78
	 * @see #setAccountNumber(String)
79
	 * @see ordersystem.OrderSystemPackage#getAccount_AccountNumber()
79
	 * @see ordersystem.OrderSystemPackage#getAccount_AccountNumber()
80
	 *
80
	 * @model
81
	 * @generated
81
	 * @generated
82
	 */
82
	 */
83
    String getAccountNumber();
83
    String getAccountNumber();
(-)src/ordersystem/OrderSystem.java (-9 / +9 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 37-43 Link Here
37
 * </p>
37
 * </p>
38
 *
38
 *
39
 * @see ordersystem.OrderSystemPackage#getOrderSystem()
39
 * @see ordersystem.OrderSystemPackage#getOrderSystem()
40
 *
40
 * @model
41
 * @generated
41
 * @generated
42
 */
42
 */
43
public interface OrderSystem extends EObject{
43
public interface OrderSystem extends EObject{
Lines 52-58 Link Here
52
	 * @return the value of the '<em>Version</em>' attribute.
52
	 * @return the value of the '<em>Version</em>' attribute.
53
	 * @see #setVersion(int)
53
	 * @see #setVersion(int)
54
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Version()
54
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Version()
55
	 *
55
	 * @model
56
	 * @generated
56
	 * @generated
57
	 */
57
	 */
58
    int getVersion();
58
    int getVersion();
Lines 80-89 Link Here
80
	 * @return the value of the '<em>Customer</em>' containment reference list.
80
	 * @return the value of the '<em>Customer</em>' containment reference list.
81
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Customer()
81
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Customer()
82
	 * @see ordersystem.Customer#getOwner
82
	 * @see ordersystem.Customer#getOwner
83
	 * @model type="ordersystem.Customer" opposite="owner" containment="true"
83
	 * @model opposite="owner" containment="true"
84
	 * @generated
84
	 * @generated
85
	 */
85
	 */
86
    EList getCustomer();
86
    EList<Customer> getCustomer();
87
87
88
	/**
88
	/**
89
	 * Returns the value of the '<em><b>Product</b></em>' containment reference list.
89
	 * Returns the value of the '<em><b>Product</b></em>' containment reference list.
Lines 98-107 Link Here
98
	 * @return the value of the '<em>Product</em>' containment reference list.
98
	 * @return the value of the '<em>Product</em>' containment reference list.
99
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Product()
99
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Product()
100
	 * @see ordersystem.Product#getOwner
100
	 * @see ordersystem.Product#getOwner
101
	 * @model type="ordersystem.Product" opposite="owner" containment="true"
101
	 * @model opposite="owner" containment="true"
102
	 * @generated
102
	 * @generated
103
	 */
103
	 */
104
    EList getProduct();
104
    EList<Product> getProduct();
105
105
106
	/**
106
	/**
107
	 * Returns the value of the '<em><b>Warehouse</b></em>' containment reference list.
107
	 * Returns the value of the '<em><b>Warehouse</b></em>' containment reference list.
Lines 116-124 Link Here
116
	 * @return the value of the '<em>Warehouse</em>' containment reference list.
116
	 * @return the value of the '<em>Warehouse</em>' containment reference list.
117
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Warehouse()
117
	 * @see ordersystem.OrderSystemPackage#getOrderSystem_Warehouse()
118
	 * @see ordersystem.Warehouse#getOwner
118
	 * @see ordersystem.Warehouse#getOwner
119
	 * @model type="ordersystem.Warehouse" opposite="owner" containment="true"
119
	 * @model opposite="owner" containment="true"
120
	 * @generated
120
	 * @generated
121
	 */
121
	 */
122
    EList getWarehouse();
122
    EList<Warehouse> getWarehouse();
123
123
124
} // OrderSystem
124
} // OrderSystem
(-)src/ordersystem/special/impl/SpecialFactoryImpl.java (-4 / +29 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-28 Link Here
17
17
18
package ordersystem.special.impl;
18
package ordersystem.special.impl;
19
19
20
import ordersystem.special.*;
20
import ordersystem.special.LimitedEditionProduct;
21
import ordersystem.special.PreferredCustomer;
22
import ordersystem.special.SpecialFactory;
23
import ordersystem.special.SpecialPackage;
21
24
22
import org.eclipse.emf.ecore.EClass;
25
import org.eclipse.emf.ecore.EClass;
23
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.ecore.EObject;
24
27
import org.eclipse.emf.ecore.EPackage;
25
import org.eclipse.emf.ecore.impl.EFactoryImpl;
28
import org.eclipse.emf.ecore.impl.EFactoryImpl;
29
import org.eclipse.emf.ecore.plugin.EcorePlugin;
26
30
27
/**
31
/**
28
 * <!-- begin-user-doc -->
32
 * <!-- begin-user-doc -->
Lines 32-38 Link Here
32
 */
36
 */
33
public class SpecialFactoryImpl extends EFactoryImpl implements SpecialFactory {
37
public class SpecialFactoryImpl extends EFactoryImpl implements SpecialFactory {
34
	/**
38
	/**
35
	 * Creates and instance of the factory.
39
	 * Creates the default factory implementation.
40
	 * <!-- begin-user-doc -->
41
	 * <!-- end-user-doc -->
42
	 * @generated
43
	 */
44
	public static SpecialFactory init() {
45
		try {
46
			SpecialFactory theSpecialFactory = (SpecialFactory)EPackage.Registry.INSTANCE.getEFactory("http:///ordersystem/special.ecore"); //$NON-NLS-1$ 
47
			if (theSpecialFactory != null) {
48
				return theSpecialFactory;
49
			}
50
		}
51
		catch (Exception exception) {
52
			EcorePlugin.INSTANCE.log(exception);
53
		}
54
		return new SpecialFactoryImpl();
55
	}
56
57
	/**
58
	 * Creates an instance of the factory.
36
	 * <!-- begin-user-doc -->
59
	 * <!-- begin-user-doc -->
37
	 * <!-- end-user-doc -->
60
	 * <!-- end-user-doc -->
38
	 * @generated
61
	 * @generated
Lines 46-51 Link Here
46
	 * <!-- end-user-doc -->
69
	 * <!-- end-user-doc -->
47
	 * @generated
70
	 * @generated
48
	 */
71
	 */
72
	@Override
49
	public EObject create(EClass eClass) {
73
	public EObject create(EClass eClass) {
50
		switch (eClass.getClassifierID()) {
74
		switch (eClass.getClassifierID()) {
51
			case SpecialPackage.PREFERRED_CUSTOMER: return createPreferredCustomer();
75
			case SpecialPackage.PREFERRED_CUSTOMER: return createPreferredCustomer();
Lines 90-95 Link Here
90
	 * @deprecated
114
	 * @deprecated
91
	 * @generated
115
	 * @generated
92
	 */
116
	 */
117
	@Deprecated
93
	public static SpecialPackage getPackage() {
118
	public static SpecialPackage getPackage() {
94
		return SpecialPackage.eINSTANCE;
119
		return SpecialPackage.eINSTANCE;
95
	}
120
	}
(-)src/ordersystem/special/impl/PreferredCustomerImpl.java (-141 / +20 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 17-44 Link Here
17
17
18
package ordersystem.special.impl;
18
package ordersystem.special.impl;
19
19
20
import java.util.Collection;
21
import java.util.Date;
20
import java.util.Date;
22
21
23
import ordersystem.OrderSystem;
24
import ordersystem.OrderSystemPackage;
25
26
import ordersystem.impl.CustomerImpl;
22
import ordersystem.impl.CustomerImpl;
27
28
import ordersystem.special.PreferredCustomer;
23
import ordersystem.special.PreferredCustomer;
29
import ordersystem.special.SpecialPackage;
24
import ordersystem.special.SpecialPackage;
30
25
31
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.Notification;
32
import org.eclipse.emf.common.notify.NotificationChain;
33
34
import org.eclipse.emf.ecore.EClass;
27
import org.eclipse.emf.ecore.EClass;
35
import org.eclipse.emf.ecore.EStructuralFeature;
36
import org.eclipse.emf.ecore.InternalEObject;
37
38
import org.eclipse.emf.ecore.impl.ENotificationImpl;
28
import org.eclipse.emf.ecore.impl.ENotificationImpl;
39
29
40
import org.eclipse.emf.ecore.util.InternalEList;
41
42
/**
30
/**
43
 * <!-- begin-user-doc -->
31
 * <!-- begin-user-doc -->
44
 * An implementation of the model object '<em><b>Preferred Customer</b></em>'.
32
 * An implementation of the model object '<em><b>Preferred Customer</b></em>'.
Lines 87-94 Link Here
87
	 * <!-- end-user-doc -->
75
	 * <!-- end-user-doc -->
88
	 * @generated
76
	 * @generated
89
	 */
77
	 */
78
	@Override
90
	protected EClass eStaticClass() {
79
	protected EClass eStaticClass() {
91
		return SpecialPackage.eINSTANCE.getPreferredCustomer();
80
		return SpecialPackage.Literals.PREFERRED_CUSTOMER;
92
	}
81
	}
93
82
94
	/**
83
	/**
Lines 117-201 Link Here
117
	 * <!-- end-user-doc -->
106
	 * <!-- end-user-doc -->
118
	 * @generated
107
	 * @generated
119
	 */
108
	 */
120
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
109
	@Override
121
		if (featureID >= 0) {
110
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
122
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
111
		switch (featureID) {
123
				case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
124
					if (eContainer != null)
125
						msgs = eBasicRemoveFromContainer(msgs);
126
					return eBasicSetContainer(otherEnd, SpecialPackage.PREFERRED_CUSTOMER__OWNER, msgs);
127
				case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
128
					return ((InternalEList)getAccount()).basicAdd(otherEnd, msgs);
129
				case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
130
					return ((InternalEList)getOrder()).basicAdd(otherEnd, msgs);
131
				default:
132
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
133
			}
134
		}
135
		if (eContainer != null)
136
			msgs = eBasicRemoveFromContainer(msgs);
137
		return eBasicSetContainer(otherEnd, featureID, msgs);
138
	}
139
140
	/**
141
	 * <!-- begin-user-doc -->
142
	 * <!-- end-user-doc -->
143
	 * @generated
144
	 */
145
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
146
		if (featureID >= 0) {
147
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
148
				case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
149
					return eBasicSetContainer(null, SpecialPackage.PREFERRED_CUSTOMER__OWNER, msgs);
150
				case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
151
					return ((InternalEList)getAccount()).basicRemove(otherEnd, msgs);
152
				case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
153
					return ((InternalEList)getOrder()).basicRemove(otherEnd, msgs);
154
				default:
155
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
156
			}
157
		}
158
		return eBasicSetContainer(null, featureID, msgs);
159
	}
160
161
	/**
162
	 * <!-- begin-user-doc -->
163
	 * <!-- end-user-doc -->
164
	 * @generated
165
	 */
166
	public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
167
		if (eContainerFeatureID >= 0) {
168
			switch (eContainerFeatureID) {
169
				case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
170
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__CUSTOMER, OrderSystem.class, msgs);
171
				default:
172
					return eDynamicBasicRemoveFromContainer(msgs);
173
			}
174
		}
175
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
176
	}
177
178
	/**
179
	 * <!-- begin-user-doc -->
180
	 * <!-- end-user-doc -->
181
	 * @generated
182
	 */
183
	public Object eGet(EStructuralFeature eFeature, boolean resolve) {
184
		switch (eDerivedStructuralFeatureID(eFeature)) {
185
			case SpecialPackage.PREFERRED_CUSTOMER__LAST_NAME:
186
				return getLastName();
187
			case SpecialPackage.PREFERRED_CUSTOMER__FIRST_NAME:
188
				return getFirstName();
189
			case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
190
				return getOwner();
191
			case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
192
				return getAccount();
193
			case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
194
				return getOrder();
195
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
112
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
196
				return getSince();
113
				return getSince();
197
		}
114
		}
198
		return eDynamicGet(eFeature, resolve);
115
		return super.eGet(featureID, resolve, coreType);
199
	}
116
	}
200
117
201
	/**
118
	/**
Lines 203-232 Link Here
203
	 * <!-- end-user-doc -->
120
	 * <!-- end-user-doc -->
204
	 * @generated
121
	 * @generated
205
	 */
122
	 */
206
	public void eSet(EStructuralFeature eFeature, Object newValue) {
123
	@Override
207
		switch (eDerivedStructuralFeatureID(eFeature)) {
124
	public void eSet(int featureID, Object newValue) {
208
			case SpecialPackage.PREFERRED_CUSTOMER__LAST_NAME:
125
		switch (featureID) {
209
				setLastName((String)newValue);
210
				return;
211
			case SpecialPackage.PREFERRED_CUSTOMER__FIRST_NAME:
212
				setFirstName((String)newValue);
213
				return;
214
			case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
215
				setOwner((OrderSystem)newValue);
216
				return;
217
			case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
218
				getAccount().clear();
219
				getAccount().addAll((Collection)newValue);
220
				return;
221
			case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
222
				getOrder().clear();
223
				getOrder().addAll((Collection)newValue);
224
				return;
225
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
126
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
226
				setSince((Date)newValue);
127
				setSince((Date)newValue);
227
				return;
128
				return;
228
		}
129
		}
229
		eDynamicSet(eFeature, newValue);
130
		super.eSet(featureID, newValue);
230
	}
131
	}
231
132
232
	/**
133
	/**
Lines 234-261 Link Here
234
	 * <!-- end-user-doc -->
135
	 * <!-- end-user-doc -->
235
	 * @generated
136
	 * @generated
236
	 */
137
	 */
237
	public void eUnset(EStructuralFeature eFeature) {
138
	@Override
238
		switch (eDerivedStructuralFeatureID(eFeature)) {
139
	public void eUnset(int featureID) {
239
			case SpecialPackage.PREFERRED_CUSTOMER__LAST_NAME:
140
		switch (featureID) {
240
				setLastName(LAST_NAME_EDEFAULT);
241
				return;
242
			case SpecialPackage.PREFERRED_CUSTOMER__FIRST_NAME:
243
				setFirstName(FIRST_NAME_EDEFAULT);
244
				return;
245
			case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
246
				setOwner((OrderSystem)null);
247
				return;
248
			case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
249
				getAccount().clear();
250
				return;
251
			case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
252
				getOrder().clear();
253
				return;
254
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
141
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
255
				setSince(SINCE_EDEFAULT);
142
				setSince(SINCE_EDEFAULT);
256
				return;
143
				return;
257
		}
144
		}
258
		eDynamicUnset(eFeature);
145
		super.eUnset(featureID);
259
	}
146
	}
260
147
261
	/**
148
	/**
Lines 263-284 Link Here
263
	 * <!-- end-user-doc -->
150
	 * <!-- end-user-doc -->
264
	 * @generated
151
	 * @generated
265
	 */
152
	 */
266
	public boolean eIsSet(EStructuralFeature eFeature) {
153
	@Override
267
		switch (eDerivedStructuralFeatureID(eFeature)) {
154
	public boolean eIsSet(int featureID) {
268
			case SpecialPackage.PREFERRED_CUSTOMER__LAST_NAME:
155
		switch (featureID) {
269
				return LAST_NAME_EDEFAULT == null ? lastName != null : !LAST_NAME_EDEFAULT.equals(lastName);
270
			case SpecialPackage.PREFERRED_CUSTOMER__FIRST_NAME:
271
				return FIRST_NAME_EDEFAULT == null ? firstName != null : !FIRST_NAME_EDEFAULT.equals(firstName);
272
			case SpecialPackage.PREFERRED_CUSTOMER__OWNER:
273
				return getOwner() != null;
274
			case SpecialPackage.PREFERRED_CUSTOMER__ACCOUNT:
275
				return account != null && !account.isEmpty();
276
			case SpecialPackage.PREFERRED_CUSTOMER__ORDER:
277
				return order != null && !order.isEmpty();
278
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
156
			case SpecialPackage.PREFERRED_CUSTOMER__SINCE:
279
				return SINCE_EDEFAULT == null ? since != null : !SINCE_EDEFAULT.equals(since);
157
				return SINCE_EDEFAULT == null ? since != null : !SINCE_EDEFAULT.equals(since);
280
		}
158
		}
281
		return eDynamicIsSet(eFeature);
159
		return super.eIsSet(featureID);
282
	}
160
	}
283
161
284
	/**
162
	/**
Lines 286-291 Link Here
286
	 * <!-- end-user-doc -->
164
	 * <!-- end-user-doc -->
287
	 * @generated
165
	 * @generated
288
	 */
166
	 */
167
	@Override
289
	public String toString() {
168
	public String toString() {
290
		if (eIsProxy()) return super.toString();
169
		if (eIsProxy()) return super.toString();
291
170
(-)src/ordersystem/special/impl/SpecialPackageImpl.java (-15 / +19 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-26 Link Here
18
package ordersystem.special.impl;
18
package ordersystem.special.impl;
19
19
20
import ordersystem.OrderSystemPackage;
20
import ordersystem.OrderSystemPackage;
21
22
import ordersystem.impl.OrderSystemPackageImpl;
21
import ordersystem.impl.OrderSystemPackageImpl;
23
24
import ordersystem.special.LimitedEditionProduct;
22
import ordersystem.special.LimitedEditionProduct;
25
import ordersystem.special.PreferredCustomer;
23
import ordersystem.special.PreferredCustomer;
26
import ordersystem.special.SpecialFactory;
24
import ordersystem.special.SpecialFactory;
Lines 29-35 Link Here
29
import org.eclipse.emf.ecore.EAttribute;
27
import org.eclipse.emf.ecore.EAttribute;
30
import org.eclipse.emf.ecore.EClass;
28
import org.eclipse.emf.ecore.EClass;
31
import org.eclipse.emf.ecore.EPackage;
29
import org.eclipse.emf.ecore.EPackage;
32
33
import org.eclipse.emf.ecore.impl.EPackageImpl;
30
import org.eclipse.emf.ecore.impl.EPackageImpl;
34
31
35
/**
32
/**
Lines 102-125 Link Here
102
	 * @generated
99
	 * @generated
103
	 */
100
	 */
104
	public static SpecialPackage init() {
101
	public static SpecialPackage init() {
105
		if (isInited) return (SpecialPackage)EPackage.Registry.INSTANCE.get(SpecialPackage.eNS_URI);
102
		if (isInited) return (SpecialPackage)EPackage.Registry.INSTANCE.getEPackage(SpecialPackage.eNS_URI);
106
103
107
		// Obtain or create and register package.
104
		// Obtain or create and register package
108
		SpecialPackageImpl theSpecialPackage = (SpecialPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof EPackage ? EPackage.Registry.INSTANCE.get(eNS_URI) : new SpecialPackageImpl());
105
		SpecialPackageImpl theSpecialPackage = (SpecialPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SpecialPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SpecialPackageImpl());
109
106
110
		isInited = true;
107
		isInited = true;
111
108
112
		// Obtain or create and register interdependencies
109
		// Obtain or create and register interdependencies
113
		OrderSystemPackageImpl theOrderSystemPackage = (OrderSystemPackageImpl)(EPackage.Registry.INSTANCE.get(OrderSystemPackage.eNS_URI) instanceof EPackage ? EPackage.Registry.INSTANCE.get(OrderSystemPackage.eNS_URI) : OrderSystemPackageImpl.eINSTANCE);
110
		OrderSystemPackageImpl theOrderSystemPackage = (OrderSystemPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(OrderSystemPackage.eNS_URI) instanceof OrderSystemPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(OrderSystemPackage.eNS_URI) : OrderSystemPackage.eINSTANCE);
114
111
115
		// Step 1: create meta-model objects
112
		// Create package meta-data objects
116
		theSpecialPackage.createPackageContents();
113
		theSpecialPackage.createPackageContents();
117
		theOrderSystemPackage.createPackageContents();
114
		theOrderSystemPackage.createPackageContents();
118
115
119
		// Step 2: complete initialization
116
		// Initialize created meta-data
120
		theSpecialPackage.initializePackageContents();
117
		theSpecialPackage.initializePackageContents();
121
		theOrderSystemPackage.initializePackageContents();
118
		theOrderSystemPackage.initializePackageContents();
122
119
120
		// Mark meta-data to indicate it can't be changed
121
		theSpecialPackage.freeze();
122
123
		return theSpecialPackage;
123
		return theSpecialPackage;
124
	}
124
	}
125
125
Lines 218-234 Link Here
218
		setNsURI(eNS_URI);
218
		setNsURI(eNS_URI);
219
219
220
		// Obtain other dependent packages
220
		// Obtain other dependent packages
221
		OrderSystemPackageImpl theOrderSystemPackage = (OrderSystemPackageImpl)EPackage.Registry.INSTANCE.getEPackage(OrderSystemPackage.eNS_URI);
221
		OrderSystemPackage theOrderSystemPackage = (OrderSystemPackage)EPackage.Registry.INSTANCE.getEPackage(OrderSystemPackage.eNS_URI);
222
223
		// Create type parameters
224
225
		// Set bounds for type parameters
222
226
223
		// Add supertypes to classes
227
		// Add supertypes to classes
224
		preferredCustomerEClass.getESuperTypes().add(theOrderSystemPackage.getCustomer());
228
		preferredCustomerEClass.getESuperTypes().add(theOrderSystemPackage.getCustomer());
225
		limitedEditionProductEClass.getESuperTypes().add(theOrderSystemPackage.getProduct());
229
		limitedEditionProductEClass.getESuperTypes().add(theOrderSystemPackage.getProduct());
226
230
227
		// Initialize classes and features; add operations and parameters
231
		// Initialize classes and features; add operations and parameters
228
		initEClass(preferredCustomerEClass, PreferredCustomer.class, "PreferredCustomer", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
232
		initEClass(preferredCustomerEClass, PreferredCustomer.class, "PreferredCustomer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
229
		initEAttribute(getPreferredCustomer_Since(), theOrderSystemPackage.getJavaDate(), "since", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
233
		initEAttribute(getPreferredCustomer_Since(), theOrderSystemPackage.getJavaDate(), "since", null, 0, 1, PreferredCustomer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
230
234
231
		initEClass(limitedEditionProductEClass, LimitedEditionProduct.class, "LimitedEditionProduct", !IS_ABSTRACT, !IS_INTERFACE); //$NON-NLS-1$
235
		initEClass(limitedEditionProductEClass, LimitedEditionProduct.class, "LimitedEditionProduct", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$
232
		initEAttribute(getLimitedEditionProduct_AvailableUntil(), theOrderSystemPackage.getJavaDate(), "availableUntil", null, 0, 1, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
236
		initEAttribute(getLimitedEditionProduct_AvailableUntil(), theOrderSystemPackage.getJavaDate(), "availableUntil", null, 0, 1, LimitedEditionProduct.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$
233
	}
237
	}
234
} //SpecialPackageImpl
238
} //SpecialPackageImpl
(-)src/ordersystem/special/impl/LimitedEditionProductImpl.java (-118 / +20 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 19-39 Link Here
19
19
20
import java.util.Date;
20
import java.util.Date;
21
21
22
import ordersystem.OrderSystem;
23
import ordersystem.OrderSystemPackage;
24
25
import ordersystem.impl.ProductImpl;
22
import ordersystem.impl.ProductImpl;
26
27
import ordersystem.special.LimitedEditionProduct;
23
import ordersystem.special.LimitedEditionProduct;
28
import ordersystem.special.SpecialPackage;
24
import ordersystem.special.SpecialPackage;
29
25
30
import org.eclipse.emf.common.notify.Notification;
26
import org.eclipse.emf.common.notify.Notification;
31
import org.eclipse.emf.common.notify.NotificationChain;
32
33
import org.eclipse.emf.ecore.EClass;
27
import org.eclipse.emf.ecore.EClass;
34
import org.eclipse.emf.ecore.EStructuralFeature;
35
import org.eclipse.emf.ecore.InternalEObject;
36
37
import org.eclipse.emf.ecore.impl.ENotificationImpl;
28
import org.eclipse.emf.ecore.impl.ENotificationImpl;
38
29
39
/**
30
/**
Lines 84-91 Link Here
84
	 * <!-- end-user-doc -->
75
	 * <!-- end-user-doc -->
85
	 * @generated
76
	 * @generated
86
	 */
77
	 */
78
	@Override
87
	protected EClass eStaticClass() {
79
	protected EClass eStaticClass() {
88
		return SpecialPackage.eINSTANCE.getLimitedEditionProduct();
80
		return SpecialPackage.Literals.LIMITED_EDITION_PRODUCT;
89
	}
81
	}
90
82
91
	/**
83
	/**
Lines 114-188 Link Here
114
	 * <!-- end-user-doc -->
106
	 * <!-- end-user-doc -->
115
	 * @generated
107
	 * @generated
116
	 */
108
	 */
117
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
109
	@Override
118
		if (featureID >= 0) {
110
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
119
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
111
		switch (featureID) {
120
				case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
121
					if (eContainer != null)
122
						msgs = eBasicRemoveFromContainer(msgs);
123
					return eBasicSetContainer(otherEnd, SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER, msgs);
124
				default:
125
					return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
126
			}
127
		}
128
		if (eContainer != null)
129
			msgs = eBasicRemoveFromContainer(msgs);
130
		return eBasicSetContainer(otherEnd, featureID, msgs);
131
	}
132
133
	/**
134
	 * <!-- begin-user-doc -->
135
	 * <!-- end-user-doc -->
136
	 * @generated
137
	 */
138
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
139
		if (featureID >= 0) {
140
			switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
141
				case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
142
					return eBasicSetContainer(null, SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER, msgs);
143
				default:
144
					return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
145
			}
146
		}
147
		return eBasicSetContainer(null, featureID, msgs);
148
	}
149
150
	/**
151
	 * <!-- begin-user-doc -->
152
	 * <!-- end-user-doc -->
153
	 * @generated
154
	 */
155
	public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
156
		if (eContainerFeatureID >= 0) {
157
			switch (eContainerFeatureID) {
158
				case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
159
					return (eContainer).eInverseRemove(this, OrderSystemPackage.ORDER_SYSTEM__PRODUCT, OrderSystem.class, msgs);
160
				default:
161
					return eDynamicBasicRemoveFromContainer(msgs);
162
			}
163
		}
164
		return (eContainer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
165
	}
166
167
	/**
168
	 * <!-- begin-user-doc -->
169
	 * <!-- end-user-doc -->
170
	 * @generated
171
	 */
172
	public Object eGet(EStructuralFeature eFeature, boolean resolve) {
173
		switch (eDerivedStructuralFeatureID(eFeature)) {
174
			case SpecialPackage.LIMITED_EDITION_PRODUCT__NAME:
175
				return getName();
176
			case SpecialPackage.LIMITED_EDITION_PRODUCT__SKU:
177
				return getSku();
178
			case SpecialPackage.LIMITED_EDITION_PRODUCT__PRICE:
179
				return new Double(getPrice());
180
			case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
181
				return getOwner();
182
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
112
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
183
				return getAvailableUntil();
113
				return getAvailableUntil();
184
		}
114
		}
185
		return eDynamicGet(eFeature, resolve);
115
		return super.eGet(featureID, resolve, coreType);
186
	}
116
	}
187
117
188
	/**
118
	/**
Lines 190-214 Link Here
190
	 * <!-- end-user-doc -->
120
	 * <!-- end-user-doc -->
191
	 * @generated
121
	 * @generated
192
	 */
122
	 */
193
	public void eSet(EStructuralFeature eFeature, Object newValue) {
123
	@Override
194
		switch (eDerivedStructuralFeatureID(eFeature)) {
124
	public void eSet(int featureID, Object newValue) {
195
			case SpecialPackage.LIMITED_EDITION_PRODUCT__NAME:
125
		switch (featureID) {
196
				setName((String)newValue);
197
				return;
198
			case SpecialPackage.LIMITED_EDITION_PRODUCT__SKU:
199
				setSku((String)newValue);
200
				return;
201
			case SpecialPackage.LIMITED_EDITION_PRODUCT__PRICE:
202
				setPrice(((Double)newValue).doubleValue());
203
				return;
204
			case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
205
				setOwner((OrderSystem)newValue);
206
				return;
207
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
126
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
208
				setAvailableUntil((Date)newValue);
127
				setAvailableUntil((Date)newValue);
209
				return;
128
				return;
210
		}
129
		}
211
		eDynamicSet(eFeature, newValue);
130
		super.eSet(featureID, newValue);
212
	}
131
	}
213
132
214
	/**
133
	/**
Lines 216-240 Link Here
216
	 * <!-- end-user-doc -->
135
	 * <!-- end-user-doc -->
217
	 * @generated
136
	 * @generated
218
	 */
137
	 */
219
	public void eUnset(EStructuralFeature eFeature) {
138
	@Override
220
		switch (eDerivedStructuralFeatureID(eFeature)) {
139
	public void eUnset(int featureID) {
221
			case SpecialPackage.LIMITED_EDITION_PRODUCT__NAME:
140
		switch (featureID) {
222
				setName(NAME_EDEFAULT);
223
				return;
224
			case SpecialPackage.LIMITED_EDITION_PRODUCT__SKU:
225
				setSku(SKU_EDEFAULT);
226
				return;
227
			case SpecialPackage.LIMITED_EDITION_PRODUCT__PRICE:
228
				setPrice(PRICE_EDEFAULT);
229
				return;
230
			case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
231
				setOwner((OrderSystem)null);
232
				return;
233
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
141
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
234
				setAvailableUntil(AVAILABLE_UNTIL_EDEFAULT);
142
				setAvailableUntil(AVAILABLE_UNTIL_EDEFAULT);
235
				return;
143
				return;
236
		}
144
		}
237
		eDynamicUnset(eFeature);
145
		super.eUnset(featureID);
238
	}
146
	}
239
147
240
	/**
148
	/**
Lines 242-261 Link Here
242
	 * <!-- end-user-doc -->
150
	 * <!-- end-user-doc -->
243
	 * @generated
151
	 * @generated
244
	 */
152
	 */
245
	public boolean eIsSet(EStructuralFeature eFeature) {
153
	@Override
246
		switch (eDerivedStructuralFeatureID(eFeature)) {
154
	public boolean eIsSet(int featureID) {
247
			case SpecialPackage.LIMITED_EDITION_PRODUCT__NAME:
155
		switch (featureID) {
248
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
249
			case SpecialPackage.LIMITED_EDITION_PRODUCT__SKU:
250
				return SKU_EDEFAULT == null ? sku != null : !SKU_EDEFAULT.equals(sku);
251
			case SpecialPackage.LIMITED_EDITION_PRODUCT__PRICE:
252
				return price != PRICE_EDEFAULT;
253
			case SpecialPackage.LIMITED_EDITION_PRODUCT__OWNER:
254
				return getOwner() != null;
255
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
156
			case SpecialPackage.LIMITED_EDITION_PRODUCT__AVAILABLE_UNTIL:
256
				return AVAILABLE_UNTIL_EDEFAULT == null ? availableUntil != null : !AVAILABLE_UNTIL_EDEFAULT.equals(availableUntil);
157
				return AVAILABLE_UNTIL_EDEFAULT == null ? availableUntil != null : !AVAILABLE_UNTIL_EDEFAULT.equals(availableUntil);
257
		}
158
		}
258
		return eDynamicIsSet(eFeature);
159
		return super.eIsSet(featureID);
259
	}
160
	}
260
161
261
	/**
162
	/**
Lines 263-268 Link Here
263
	 * <!-- end-user-doc -->
164
	 * <!-- end-user-doc -->
264
	 * @generated
165
	 * @generated
265
	 */
166
	 */
167
	@Override
266
	public String toString() {
168
	public String toString() {
267
		if (eIsProxy()) return super.toString();
169
		if (eIsProxy()) return super.toString();
268
170
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 30-34 Link Here
30
               plugin.properties,\
30
               plugin.properties,\
31
               include_files/,\
31
               include_files/,\
32
               about.html
32
               about.html
33
javacSource = 1.4
33
javacSource = 1.5
34
javacTarget = 1.4
34
javacTarget = 1.5
(-)src/ordersystem/special/util/SpecialSwitch.java (-24 / +24 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 40-46 Link Here
40
 * @see ordersystem.special.SpecialPackage
40
 * @see ordersystem.special.SpecialPackage
41
 * @generated
41
 * @generated
42
 */
42
 */
43
public class SpecialSwitch {
43
public class SpecialSwitch<T> {
44
	/**
44
	/**
45
	 * The cached model package
45
	 * The cached model package
46
	 * <!-- begin-user-doc -->
46
	 * <!-- begin-user-doc -->
Lines 68-74 Link Here
68
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
68
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
69
	 * @generated
69
	 * @generated
70
	 */
70
	 */
71
	public Object doSwitch(EObject theEObject) {
71
	public T doSwitch(EObject theEObject) {
72
		return doSwitch(theEObject.eClass(), theEObject);
72
		return doSwitch(theEObject.eClass(), theEObject);
73
	}
73
	}
74
74
Lines 79-94 Link Here
79
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
79
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
80
	 * @generated
80
	 * @generated
81
	 */
81
	 */
82
	protected Object doSwitch(EClass theEClass, EObject theEObject) {
82
	protected T doSwitch(EClass theEClass, EObject theEObject) {
83
		if (theEClass.eContainer() == modelPackage) {
83
		if (theEClass.eContainer() == modelPackage) {
84
			return doSwitch(theEClass.getClassifierID(), theEObject);
84
			return doSwitch(theEClass.getClassifierID(), theEObject);
85
		}
85
		}
86
		else {
86
		else {
87
			List eSuperTypes = theEClass.getESuperTypes();
87
			List<EClass> eSuperTypes = theEClass.getESuperTypes();
88
			return
88
			return
89
				eSuperTypes.isEmpty() ?
89
				eSuperTypes.isEmpty() ?
90
					defaultCase(theEObject) :
90
					defaultCase(theEObject) :
91
					doSwitch((EClass)eSuperTypes.get(0), theEObject);
91
					doSwitch(eSuperTypes.get(0), theEObject);
92
		}
92
		}
93
	}
93
	}
94
94
Lines 99-116 Link Here
99
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
99
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
100
	 * @generated
100
	 * @generated
101
	 */
101
	 */
102
	protected Object doSwitch(int classifierID, EObject theEObject) {
102
	protected T doSwitch(int classifierID, EObject theEObject) {
103
		switch (classifierID) {
103
		switch (classifierID) {
104
			case SpecialPackage.PREFERRED_CUSTOMER: {
104
			case SpecialPackage.PREFERRED_CUSTOMER: {
105
				PreferredCustomer preferredCustomer = (PreferredCustomer)theEObject;
105
				PreferredCustomer preferredCustomer = (PreferredCustomer)theEObject;
106
				Object result = casePreferredCustomer(preferredCustomer);
106
				T result = casePreferredCustomer(preferredCustomer);
107
				if (result == null) result = caseCustomer(preferredCustomer);
107
				if (result == null) result = caseCustomer(preferredCustomer);
108
				if (result == null) result = defaultCase(theEObject);
108
				if (result == null) result = defaultCase(theEObject);
109
				return result;
109
				return result;
110
			}
110
			}
111
			case SpecialPackage.LIMITED_EDITION_PRODUCT: {
111
			case SpecialPackage.LIMITED_EDITION_PRODUCT: {
112
				LimitedEditionProduct limitedEditionProduct = (LimitedEditionProduct)theEObject;
112
				LimitedEditionProduct limitedEditionProduct = (LimitedEditionProduct)theEObject;
113
				Object result = caseLimitedEditionProduct(limitedEditionProduct);
113
				T result = caseLimitedEditionProduct(limitedEditionProduct);
114
				if (result == null) result = caseProduct(limitedEditionProduct);
114
				if (result == null) result = caseProduct(limitedEditionProduct);
115
				if (result == null) result = defaultCase(theEObject);
115
				if (result == null) result = defaultCase(theEObject);
116
				return result;
116
				return result;
Lines 120-196 Link Here
120
	}
120
	}
121
121
122
	/**
122
	/**
123
	 * Returns the result of interpretting the object as an instance of '<em>Preferred Customer</em>'.
123
	 * Returns the result of interpreting the object as an instance of '<em>Preferred Customer</em>'.
124
	 * <!-- begin-user-doc -->
124
	 * <!-- begin-user-doc -->
125
	 * This implementation returns null;
125
	 * This implementation returns null;
126
	 * returning a non-null result will terminate the switch.
126
	 * returning a non-null result will terminate the switch.
127
	 * <!-- end-user-doc -->
127
	 * <!-- end-user-doc -->
128
	 * @param object the target of the switch.
128
	 * @param object the target of the switch.
129
	 * @return the result of interpretting the object as an instance of '<em>Preferred Customer</em>'.
129
	 * @return the result of interpreting the object as an instance of '<em>Preferred Customer</em>'.
130
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
130
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
131
	 * @generated
131
	 * @generated
132
	 */
132
	 */
133
	public Object casePreferredCustomer(PreferredCustomer object) {
133
	public T casePreferredCustomer(PreferredCustomer object) {
134
		return null;
134
		return null;
135
	}
135
	}
136
136
137
	/**
137
	/**
138
	 * Returns the result of interpretting the object as an instance of '<em>Limited Edition Product</em>'.
138
	 * Returns the result of interpreting the object as an instance of '<em>Limited Edition Product</em>'.
139
	 * <!-- begin-user-doc -->
139
	 * <!-- begin-user-doc -->
140
	 * This implementation returns null;
140
	 * This implementation returns null;
141
	 * returning a non-null result will terminate the switch.
141
	 * returning a non-null result will terminate the switch.
142
	 * <!-- end-user-doc -->
142
	 * <!-- end-user-doc -->
143
	 * @param object the target of the switch.
143
	 * @param object the target of the switch.
144
	 * @return the result of interpretting the object as an instance of '<em>Limited Edition Product</em>'.
144
	 * @return the result of interpreting the object as an instance of '<em>Limited Edition Product</em>'.
145
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
145
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
146
	 * @generated
146
	 * @generated
147
	 */
147
	 */
148
	public Object caseLimitedEditionProduct(LimitedEditionProduct object) {
148
	public T caseLimitedEditionProduct(LimitedEditionProduct object) {
149
		return null;
149
		return null;
150
	}
150
	}
151
151
152
	/**
152
	/**
153
	 * Returns the result of interpretting the object as an instance of '<em>Customer</em>'.
153
	 * Returns the result of interpreting the object as an instance of '<em>Customer</em>'.
154
	 * <!-- begin-user-doc -->
154
	 * <!-- begin-user-doc -->
155
	 * This implementation returns null;
155
	 * This implementation returns null;
156
	 * returning a non-null result will terminate the switch.
156
	 * returning a non-null result will terminate the switch.
157
	 * <!-- end-user-doc -->
157
	 * <!-- end-user-doc -->
158
	 * @param object the target of the switch.
158
	 * @param object the target of the switch.
159
	 * @return the result of interpretting the object as an instance of '<em>Customer</em>'.
159
	 * @return the result of interpreting the object as an instance of '<em>Customer</em>'.
160
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
160
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
161
	 * @generated
161
	 * @generated
162
	 */
162
	 */
163
	public Object caseCustomer(Customer object) {
163
	public T caseCustomer(Customer object) {
164
		return null;
164
		return null;
165
	}
165
	}
166
166
167
	/**
167
	/**
168
	 * Returns the result of interpretting the object as an instance of '<em>Product</em>'.
168
	 * Returns the result of interpreting the object as an instance of '<em>Product</em>'.
169
	 * <!-- begin-user-doc -->
169
	 * <!-- begin-user-doc -->
170
	 * This implementation returns null;
170
	 * This implementation returns null;
171
	 * returning a non-null result will terminate the switch.
171
	 * returning a non-null result will terminate the switch.
172
	 * <!-- end-user-doc -->
172
	 * <!-- end-user-doc -->
173
	 * @param object the target of the switch.
173
	 * @param object the target of the switch.
174
	 * @return the result of interpretting the object as an instance of '<em>Product</em>'.
174
	 * @return the result of interpreting the object as an instance of '<em>Product</em>'.
175
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
175
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
176
	 * @generated
176
	 * @generated
177
	 */
177
	 */
178
	public Object caseProduct(Product object) {
178
	public T caseProduct(Product object) {
179
		return null;
179
		return null;
180
	}
180
	}
181
181
182
	/**
182
	/**
183
	 * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
183
	 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
184
	 * <!-- begin-user-doc -->
184
	 * <!-- begin-user-doc -->
185
	 * This implementation returns null;
185
	 * This implementation returns null;
186
	 * returning a non-null result will terminate the switch, but this is the last case anyway.
186
	 * returning a non-null result will terminate the switch, but this is the last case anyway.
187
	 * <!-- end-user-doc -->
187
	 * <!-- end-user-doc -->
188
	 * @param object the target of the switch.
188
	 * @param object the target of the switch.
189
	 * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
189
	 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
190
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
190
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
191
	 * @generated
191
	 * @generated
192
	 */
192
	 */
193
	public Object defaultCase(EObject object) {
193
	public T defaultCase(EObject object) {
194
		return null;
194
		return null;
195
	}
195
	}
196
196
(-)src/ordersystem/special/util/SpecialAdapterFactory.java (-9 / +16 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 66-71 Link Here
66
	 * @return whether this factory is applicable for the type of the object.
66
	 * @return whether this factory is applicable for the type of the object.
67
	 * @generated
67
	 * @generated
68
	 */
68
	 */
69
	@Override
69
	public boolean isFactoryForType(Object object) {
70
	public boolean isFactoryForType(Object object) {
70
		if (object == modelPackage) {
71
		if (object == modelPackage) {
71
			return true;
72
			return true;
Lines 82-102 Link Here
82
	 * <!-- end-user-doc -->
83
	 * <!-- end-user-doc -->
83
	 * @generated
84
	 * @generated
84
	 */
85
	 */
85
	protected SpecialSwitch modelSwitch =
86
	protected SpecialSwitch<Adapter> modelSwitch =
86
		new SpecialSwitch() {
87
		new SpecialSwitch<Adapter>() {
87
			public Object casePreferredCustomer(PreferredCustomer object) {
88
			@Override
89
			public Adapter casePreferredCustomer(PreferredCustomer object) {
88
				return createPreferredCustomerAdapter();
90
				return createPreferredCustomerAdapter();
89
			}
91
			}
90
			public Object caseLimitedEditionProduct(LimitedEditionProduct object) {
92
			@Override
93
			public Adapter caseLimitedEditionProduct(LimitedEditionProduct object) {
91
				return createLimitedEditionProductAdapter();
94
				return createLimitedEditionProductAdapter();
92
			}
95
			}
93
			public Object caseCustomer(Customer object) {
96
			@Override
97
			public Adapter caseCustomer(Customer object) {
94
				return createCustomerAdapter();
98
				return createCustomerAdapter();
95
			}
99
			}
96
			public Object caseProduct(Product object) {
100
			@Override
101
			public Adapter caseProduct(Product object) {
97
				return createProductAdapter();
102
				return createProductAdapter();
98
			}
103
			}
99
			public Object defaultCase(EObject object) {
104
			@Override
105
			public Adapter defaultCase(EObject object) {
100
				return createEObjectAdapter();
106
				return createEObjectAdapter();
101
			}
107
			}
102
		};
108
		};
Lines 109-116 Link Here
109
	 * @return the adapter for the <code>target</code>.
115
	 * @return the adapter for the <code>target</code>.
110
	 * @generated
116
	 * @generated
111
	 */
117
	 */
118
	@Override
112
	public Adapter createAdapter(Notifier target) {
119
	public Adapter createAdapter(Notifier target) {
113
		return (Adapter)modelSwitch.doSwitch((EObject)target);
120
		return modelSwitch.doSwitch((EObject)target);
114
	}
121
	}
115
122
116
123
(-)src/ordersystem/util/OrderSystemSwitch.java (-46 / +46 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 37-43 Link Here
37
 * @see ordersystem.OrderSystemPackage
37
 * @see ordersystem.OrderSystemPackage
38
 * @generated
38
 * @generated
39
 */
39
 */
40
public class OrderSystemSwitch {
40
public class OrderSystemSwitch<T> {
41
	/**
41
	/**
42
	 * The cached model package
42
	 * The cached model package
43
	 * <!-- begin-user-doc -->
43
	 * <!-- begin-user-doc -->
Lines 65-71 Link Here
65
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
65
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
66
	 * @generated
66
	 * @generated
67
	 */
67
	 */
68
    public Object doSwitch(EObject theEObject) {
68
    public T doSwitch(EObject theEObject) {
69
		return doSwitch(theEObject.eClass(), theEObject);
69
		return doSwitch(theEObject.eClass(), theEObject);
70
	}
70
	}
71
71
Lines 76-91 Link Here
76
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
76
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
77
	 * @generated
77
	 * @generated
78
	 */
78
	 */
79
	protected Object doSwitch(EClass theEClass, EObject theEObject) {
79
	protected T doSwitch(EClass theEClass, EObject theEObject) {
80
		if (theEClass.eContainer() == modelPackage) {
80
		if (theEClass.eContainer() == modelPackage) {
81
			return doSwitch(theEClass.getClassifierID(), theEObject);
81
			return doSwitch(theEClass.getClassifierID(), theEObject);
82
		}
82
		}
83
		else {
83
		else {
84
			List eSuperTypes = theEClass.getESuperTypes();
84
			List<EClass> eSuperTypes = theEClass.getESuperTypes();
85
			return
85
			return
86
				eSuperTypes.isEmpty() ?
86
				eSuperTypes.isEmpty() ?
87
					defaultCase(theEObject) :
87
					defaultCase(theEObject) :
88
					doSwitch((EClass)eSuperTypes.get(0), theEObject);
88
					doSwitch(eSuperTypes.get(0), theEObject);
89
		}
89
		}
90
	}
90
	}
91
91
Lines 96-154 Link Here
96
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
96
	 * @return the first non-null result returned by a <code>caseXXX</code> call.
97
	 * @generated
97
	 * @generated
98
	 */
98
	 */
99
	protected Object doSwitch(int classifierID, EObject theEObject) {
99
	protected T doSwitch(int classifierID, EObject theEObject) {
100
		switch (classifierID) {
100
		switch (classifierID) {
101
			case OrderSystemPackage.ORDER: {
101
			case OrderSystemPackage.ORDER: {
102
				Order order = (Order)theEObject;
102
				Order order = (Order)theEObject;
103
				Object result = caseOrder(order);
103
				T result = caseOrder(order);
104
				if (result == null) result = defaultCase(theEObject);
104
				if (result == null) result = defaultCase(theEObject);
105
				return result;
105
				return result;
106
			}
106
			}
107
			case OrderSystemPackage.PRODUCT: {
107
			case OrderSystemPackage.PRODUCT: {
108
				Product product = (Product)theEObject;
108
				Product product = (Product)theEObject;
109
				Object result = caseProduct(product);
109
				T result = caseProduct(product);
110
				if (result == null) result = defaultCase(theEObject);
110
				if (result == null) result = defaultCase(theEObject);
111
				return result;
111
				return result;
112
			}
112
			}
113
			case OrderSystemPackage.WAREHOUSE: {
113
			case OrderSystemPackage.WAREHOUSE: {
114
				Warehouse warehouse = (Warehouse)theEObject;
114
				Warehouse warehouse = (Warehouse)theEObject;
115
				Object result = caseWarehouse(warehouse);
115
				T result = caseWarehouse(warehouse);
116
				if (result == null) result = defaultCase(theEObject);
116
				if (result == null) result = defaultCase(theEObject);
117
				return result;
117
				return result;
118
			}
118
			}
119
			case OrderSystemPackage.ORDER_SYSTEM: {
119
			case OrderSystemPackage.ORDER_SYSTEM: {
120
				OrderSystem orderSystem = (OrderSystem)theEObject;
120
				OrderSystem orderSystem = (OrderSystem)theEObject;
121
				Object result = caseOrderSystem(orderSystem);
121
				T result = caseOrderSystem(orderSystem);
122
				if (result == null) result = defaultCase(theEObject);
122
				if (result == null) result = defaultCase(theEObject);
123
				return result;
123
				return result;
124
			}
124
			}
125
			case OrderSystemPackage.LINE_ITEM: {
125
			case OrderSystemPackage.LINE_ITEM: {
126
				LineItem lineItem = (LineItem)theEObject;
126
				LineItem lineItem = (LineItem)theEObject;
127
				Object result = caseLineItem(lineItem);
127
				T result = caseLineItem(lineItem);
128
				if (result == null) result = defaultCase(theEObject);
128
				if (result == null) result = defaultCase(theEObject);
129
				return result;
129
				return result;
130
			}
130
			}
131
			case OrderSystemPackage.INVENTORY_ITEM: {
131
			case OrderSystemPackage.INVENTORY_ITEM: {
132
				InventoryItem inventoryItem = (InventoryItem)theEObject;
132
				InventoryItem inventoryItem = (InventoryItem)theEObject;
133
				Object result = caseInventoryItem(inventoryItem);
133
				T result = caseInventoryItem(inventoryItem);
134
				if (result == null) result = defaultCase(theEObject);
134
				if (result == null) result = defaultCase(theEObject);
135
				return result;
135
				return result;
136
			}
136
			}
137
			case OrderSystemPackage.CUSTOMER: {
137
			case OrderSystemPackage.CUSTOMER: {
138
				Customer customer = (Customer)theEObject;
138
				Customer customer = (Customer)theEObject;
139
				Object result = caseCustomer(customer);
139
				T result = caseCustomer(customer);
140
				if (result == null) result = defaultCase(theEObject);
140
				if (result == null) result = defaultCase(theEObject);
141
				return result;
141
				return result;
142
			}
142
			}
143
			case OrderSystemPackage.ADDRESS: {
143
			case OrderSystemPackage.ADDRESS: {
144
				Address address = (Address)theEObject;
144
				Address address = (Address)theEObject;
145
				Object result = caseAddress(address);
145
				T result = caseAddress(address);
146
				if (result == null) result = defaultCase(theEObject);
146
				if (result == null) result = defaultCase(theEObject);
147
				return result;
147
				return result;
148
			}
148
			}
149
			case OrderSystemPackage.ACCOUNT: {
149
			case OrderSystemPackage.ACCOUNT: {
150
				Account account = (Account)theEObject;
150
				Account account = (Account)theEObject;
151
				Object result = caseAccount(account);
151
				T result = caseAccount(account);
152
				if (result == null) result = defaultCase(theEObject);
152
				if (result == null) result = defaultCase(theEObject);
153
				return result;
153
				return result;
154
			}
154
			}
Lines 157-308 Link Here
157
	}
157
	}
158
158
159
	/**
159
	/**
160
	 * Returns the result of interpretting the object as an instance of '<em>OrderSystem</em>'.
160
	 * Returns the result of interpreting the object as an instance of '<em>Order System</em>'.
161
	 * <!-- begin-user-doc -->
161
	 * <!-- begin-user-doc -->
162
     * This implementation returns null;
162
     * This implementation returns null;
163
     * returning a non-null result will terminate the switch.
163
     * returning a non-null result will terminate the switch.
164
     * <!-- end-user-doc -->
164
     * <!-- end-user-doc -->
165
	 * @param object the target of the switch.
165
	 * @param object the target of the switch.
166
	 * @return the result of interpretting the object as an instance of '<em>OrderSystem</em>'.
166
	 * @return the result of interpreting the object as an instance of '<em>Order System</em>'.
167
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
167
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
168
	 * @generated
168
	 * @generated
169
	 */
169
	 */
170
    public Object caseOrderSystem(OrderSystem object) {
170
    public T caseOrderSystem(OrderSystem object) {
171
		return null;
171
		return null;
172
	}
172
	}
173
173
174
	/**
174
	/**
175
	 * Returns the result of interpretting the object as an instance of '<em>Customer</em>'.
175
	 * Returns the result of interpreting the object as an instance of '<em>Customer</em>'.
176
	 * <!-- begin-user-doc -->
176
	 * <!-- begin-user-doc -->
177
     * This implementation returns null;
177
     * This implementation returns null;
178
     * returning a non-null result will terminate the switch.
178
     * returning a non-null result will terminate the switch.
179
     * <!-- end-user-doc -->
179
     * <!-- end-user-doc -->
180
	 * @param object the target of the switch.
180
	 * @param object the target of the switch.
181
	 * @return the result of interpretting the object as an instance of '<em>Customer</em>'.
181
	 * @return the result of interpreting the object as an instance of '<em>Customer</em>'.
182
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
182
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
183
	 * @generated
183
	 * @generated
184
	 */
184
	 */
185
    public Object caseCustomer(Customer object) {
185
    public T caseCustomer(Customer object) {
186
		return null;
186
		return null;
187
	}
187
	}
188
188
189
	/**
189
	/**
190
	 * Returns the result of interpretting the object as an instance of '<em>Account</em>'.
190
	 * Returns the result of interpreting the object as an instance of '<em>Account</em>'.
191
	 * <!-- begin-user-doc -->
191
	 * <!-- begin-user-doc -->
192
     * This implementation returns null;
192
     * This implementation returns null;
193
     * returning a non-null result will terminate the switch.
193
     * returning a non-null result will terminate the switch.
194
     * <!-- end-user-doc -->
194
     * <!-- end-user-doc -->
195
	 * @param object the target of the switch.
195
	 * @param object the target of the switch.
196
	 * @return the result of interpretting the object as an instance of '<em>Account</em>'.
196
	 * @return the result of interpreting the object as an instance of '<em>Account</em>'.
197
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
197
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
198
	 * @generated
198
	 * @generated
199
	 */
199
	 */
200
    public Object caseAccount(Account object) {
200
    public T caseAccount(Account object) {
201
		return null;
201
		return null;
202
	}
202
	}
203
203
204
	/**
204
	/**
205
	 * Returns the result of interpretting the object as an instance of '<em>Address</em>'.
205
	 * Returns the result of interpreting the object as an instance of '<em>Address</em>'.
206
	 * <!-- begin-user-doc -->
206
	 * <!-- begin-user-doc -->
207
     * This implementation returns null;
207
     * This implementation returns null;
208
     * returning a non-null result will terminate the switch.
208
     * returning a non-null result will terminate the switch.
209
     * <!-- end-user-doc -->
209
     * <!-- end-user-doc -->
210
	 * @param object the target of the switch.
210
	 * @param object the target of the switch.
211
	 * @return the result of interpretting the object as an instance of '<em>Address</em>'.
211
	 * @return the result of interpreting the object as an instance of '<em>Address</em>'.
212
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
212
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
213
	 * @generated
213
	 * @generated
214
	 */
214
	 */
215
    public Object caseAddress(Address object) {
215
    public T caseAddress(Address object) {
216
		return null;
216
		return null;
217
	}
217
	}
218
218
219
	/**
219
	/**
220
	 * Returns the result of interpretting the object as an instance of '<em>Order</em>'.
220
	 * Returns the result of interpreting the object as an instance of '<em>Order</em>'.
221
	 * <!-- begin-user-doc -->
221
	 * <!-- begin-user-doc -->
222
     * This implementation returns null;
222
     * This implementation returns null;
223
     * returning a non-null result will terminate the switch.
223
     * returning a non-null result will terminate the switch.
224
     * <!-- end-user-doc -->
224
     * <!-- end-user-doc -->
225
	 * @param object the target of the switch.
225
	 * @param object the target of the switch.
226
	 * @return the result of interpretting the object as an instance of '<em>Order</em>'.
226
	 * @return the result of interpreting the object as an instance of '<em>Order</em>'.
227
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
227
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
228
	 * @generated
228
	 * @generated
229
	 */
229
	 */
230
    public Object caseOrder(Order object) {
230
    public T caseOrder(Order object) {
231
		return null;
231
		return null;
232
	}
232
	}
233
233
234
	/**
234
	/**
235
	 * Returns the result of interpretting the object as an instance of '<em>Line Item</em>'.
235
	 * Returns the result of interpreting the object as an instance of '<em>Line Item</em>'.
236
	 * <!-- begin-user-doc -->
236
	 * <!-- begin-user-doc -->
237
     * This implementation returns null;
237
     * This implementation returns null;
238
     * returning a non-null result will terminate the switch.
238
     * returning a non-null result will terminate the switch.
239
     * <!-- end-user-doc -->
239
     * <!-- end-user-doc -->
240
	 * @param object the target of the switch.
240
	 * @param object the target of the switch.
241
	 * @return the result of interpretting the object as an instance of '<em>Line Item</em>'.
241
	 * @return the result of interpreting the object as an instance of '<em>Line Item</em>'.
242
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
242
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
243
	 * @generated
243
	 * @generated
244
	 */
244
	 */
245
    public Object caseLineItem(LineItem object) {
245
    public T caseLineItem(LineItem object) {
246
		return null;
246
		return null;
247
	}
247
	}
248
248
249
	/**
249
	/**
250
	 * Returns the result of interpretting the object as an instance of '<em>Product</em>'.
250
	 * Returns the result of interpreting the object as an instance of '<em>Product</em>'.
251
	 * <!-- begin-user-doc -->
251
	 * <!-- begin-user-doc -->
252
     * This implementation returns null;
252
     * This implementation returns null;
253
     * returning a non-null result will terminate the switch.
253
     * returning a non-null result will terminate the switch.
254
     * <!-- end-user-doc -->
254
     * <!-- end-user-doc -->
255
	 * @param object the target of the switch.
255
	 * @param object the target of the switch.
256
	 * @return the result of interpretting the object as an instance of '<em>Product</em>'.
256
	 * @return the result of interpreting the object as an instance of '<em>Product</em>'.
257
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
257
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
258
	 * @generated
258
	 * @generated
259
	 */
259
	 */
260
    public Object caseProduct(Product object) {
260
    public T caseProduct(Product object) {
261
		return null;
261
		return null;
262
	}
262
	}
263
263
264
	/**
264
	/**
265
	 * Returns the result of interpretting the object as an instance of '<em>Warehouse</em>'.
265
	 * Returns the result of interpreting the object as an instance of '<em>Warehouse</em>'.
266
	 * <!-- begin-user-doc -->
266
	 * <!-- begin-user-doc -->
267
     * This implementation returns null;
267
     * This implementation returns null;
268
     * returning a non-null result will terminate the switch.
268
     * returning a non-null result will terminate the switch.
269
     * <!-- end-user-doc -->
269
     * <!-- end-user-doc -->
270
	 * @param object the target of the switch.
270
	 * @param object the target of the switch.
271
	 * @return the result of interpretting the object as an instance of '<em>Warehouse</em>'.
271
	 * @return the result of interpreting the object as an instance of '<em>Warehouse</em>'.
272
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
272
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
273
	 * @generated
273
	 * @generated
274
	 */
274
	 */
275
    public Object caseWarehouse(Warehouse object) {
275
    public T caseWarehouse(Warehouse object) {
276
		return null;
276
		return null;
277
	}
277
	}
278
278
279
	/**
279
	/**
280
	 * Returns the result of interpretting the object as an instance of '<em>Inventory Item</em>'.
280
	 * Returns the result of interpreting the object as an instance of '<em>Inventory Item</em>'.
281
	 * <!-- begin-user-doc -->
281
	 * <!-- begin-user-doc -->
282
     * This implementation returns null;
282
     * This implementation returns null;
283
     * returning a non-null result will terminate the switch.
283
     * returning a non-null result will terminate the switch.
284
     * <!-- end-user-doc -->
284
     * <!-- end-user-doc -->
285
	 * @param object the target of the switch.
285
	 * @param object the target of the switch.
286
	 * @return the result of interpretting the object as an instance of '<em>Inventory Item</em>'.
286
	 * @return the result of interpreting the object as an instance of '<em>Inventory Item</em>'.
287
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
287
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
288
	 * @generated
288
	 * @generated
289
	 */
289
	 */
290
    public Object caseInventoryItem(InventoryItem object) {
290
    public T caseInventoryItem(InventoryItem object) {
291
		return null;
291
		return null;
292
	}
292
	}
293
293
294
	/**
294
	/**
295
	 * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
295
	 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
296
	 * <!-- begin-user-doc -->
296
	 * <!-- begin-user-doc -->
297
     * This implementation returns null;
297
     * This implementation returns null;
298
     * returning a non-null result will terminate the switch, but this is the last case anyway.
298
     * returning a non-null result will terminate the switch, but this is the last case anyway.
299
     * <!-- end-user-doc -->
299
     * <!-- end-user-doc -->
300
	 * @param object the target of the switch.
300
	 * @param object the target of the switch.
301
	 * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
301
	 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
302
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
302
	 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
303
	 * @generated
303
	 * @generated
304
	 */
304
	 */
305
    public Object defaultCase(EObject object) {
305
    public T defaultCase(EObject object) {
306
		return null;
306
		return null;
307
	}
307
	}
308
308
(-)src/ordersystem/util/OrderSystemAdapterFactory.java (-17 / +29 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2005 IBM Corporation and others.
4
 * Copyright (c) 2005, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 63-69 Link Here
63
	 * @return whether this factory is applicable for the type of the object.
63
	 * @return whether this factory is applicable for the type of the object.
64
	 * @generated
64
	 * @generated
65
	 */
65
	 */
66
    public boolean isFactoryForType(Object object) {
66
    @Override
67
				public boolean isFactoryForType(Object object) {
67
		if (object == modelPackage) {
68
		if (object == modelPackage) {
68
			return true;
69
			return true;
69
		}
70
		}
Lines 79-114 Link Here
79
     * <!-- end-user-doc -->
80
     * <!-- end-user-doc -->
80
	 * @generated
81
	 * @generated
81
	 */
82
	 */
82
    protected OrderSystemSwitch modelSwitch =
83
    protected OrderSystemSwitch<Adapter> modelSwitch =
83
		new OrderSystemSwitch() {
84
		new OrderSystemSwitch<Adapter>() {
84
			public Object caseOrder(Order object) {
85
			@Override
86
			public Adapter caseOrder(Order object) {
85
				return createOrderAdapter();
87
				return createOrderAdapter();
86
			}
88
			}
87
			public Object caseProduct(Product object) {
89
			@Override
90
			public Adapter caseProduct(Product object) {
88
				return createProductAdapter();
91
				return createProductAdapter();
89
			}
92
			}
90
			public Object caseWarehouse(Warehouse object) {
93
			@Override
94
			public Adapter caseWarehouse(Warehouse object) {
91
				return createWarehouseAdapter();
95
				return createWarehouseAdapter();
92
			}
96
			}
93
			public Object caseOrderSystem(OrderSystem object) {
97
			@Override
98
			public Adapter caseOrderSystem(OrderSystem object) {
94
				return createOrderSystemAdapter();
99
				return createOrderSystemAdapter();
95
			}
100
			}
96
			public Object caseLineItem(LineItem object) {
101
			@Override
102
			public Adapter caseLineItem(LineItem object) {
97
				return createLineItemAdapter();
103
				return createLineItemAdapter();
98
			}
104
			}
99
			public Object caseInventoryItem(InventoryItem object) {
105
			@Override
106
			public Adapter caseInventoryItem(InventoryItem object) {
100
				return createInventoryItemAdapter();
107
				return createInventoryItemAdapter();
101
			}
108
			}
102
			public Object caseCustomer(Customer object) {
109
			@Override
110
			public Adapter caseCustomer(Customer object) {
103
				return createCustomerAdapter();
111
				return createCustomerAdapter();
104
			}
112
			}
105
			public Object caseAddress(Address object) {
113
			@Override
114
			public Adapter caseAddress(Address object) {
106
				return createAddressAdapter();
115
				return createAddressAdapter();
107
			}
116
			}
108
			public Object caseAccount(Account object) {
117
			@Override
118
			public Adapter caseAccount(Account object) {
109
				return createAccountAdapter();
119
				return createAccountAdapter();
110
			}
120
			}
111
			public Object defaultCase(EObject object) {
121
			@Override
122
			public Adapter defaultCase(EObject object) {
112
				return createEObjectAdapter();
123
				return createEObjectAdapter();
113
			}
124
			}
114
		};
125
		};
Lines 121-133 Link Here
121
	 * @return the adapter for the <code>target</code>.
132
	 * @return the adapter for the <code>target</code>.
122
	 * @generated
133
	 * @generated
123
	 */
134
	 */
124
    public Adapter createAdapter(Notifier target) {
135
    @Override
125
		return (Adapter)modelSwitch.doSwitch((EObject)target);
136
				public Adapter createAdapter(Notifier target) {
137
		return modelSwitch.doSwitch((EObject)target);
126
	}
138
	}
127
139
128
140
129
	/**
141
	/**
130
	 * Creates a new adapter for an object of class '{@link ordersystem.OrderSystem <em>OrderSystem</em>}'.
142
	 * Creates a new adapter for an object of class '{@link ordersystem.OrderSystem <em>Order System</em>}'.
131
	 * <!-- begin-user-doc -->
143
	 * <!-- begin-user-doc -->
132
     * This default implementation returns null so that we can easily ignore cases;
144
     * This default implementation returns null so that we can easily ignore cases;
133
     * it's useful to ignore a case when inheritance will catch all the cases anyway.
145
     * it's useful to ignore a case when inheritance will catch all the cases anyway.
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 30-33 Link Here
30
 org.eclipse.emf.validation.ui;bundle-version="1.1.100",
30
 org.eclipse.emf.validation.ui;bundle-version="1.1.100",
31
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)"
31
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)"
32
Eclipse-LazyStart: true
32
Eclipse-LazyStart: true
33
Bundle-RequiredExecutionEnvironment: J2SE-1.4
33
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)model/order.genmodel (-1 / +2 lines)
Lines 4-10 Link Here
4
    xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.validation.tests/src"
4
    xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.validation.tests/src"
5
    editDirectory="/org.eclipse.emf.validation.tests.edit/src" editorDirectory="/org.eclipse.emf.validation.tests.editor/src"
5
    editDirectory="/org.eclipse.emf.validation.tests.edit/src" editorDirectory="/org.eclipse.emf.validation.tests.editor/src"
6
    modelPluginID="org.eclipse.emf.validation.tests" modelName="Order" editPluginClass="ordersystem.provider.OrderEditPlugin"
6
    modelPluginID="org.eclipse.emf.validation.tests" modelName="Order" editPluginClass="ordersystem.provider.OrderEditPlugin"
7
    editorPluginClass="ordersystem.presentation.OrderEditorPlugin" nonNLSMarkers="true">
7
    editorPluginClass="ordersystem.presentation.OrderEditorPlugin" nonNLSMarkers="true"
8
    complianceLevel="5.0">
8
  <foreignModel>OrderSystem.mdl</foreignModel>
9
  <foreignModel>OrderSystem.mdl</foreignModel>
9
  <genPackages prefix="OrderSystem" ecorePackage="OrderSystem.ecore#/">
10
  <genPackages prefix="OrderSystem" ecorePackage="OrderSystem.ecore#/">
10
    <genDataTypes ecoreDataType="OrderSystem.ecore#//JavaDate"/>
11
    <genDataTypes ecoreDataType="OrderSystem.ecore#//JavaDate"/>
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/GetLiveConstraintsOperationTest.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 26-31 Link Here
26
26
27
import org.eclipse.emf.validation.EMFEventType;
27
import org.eclipse.emf.validation.EMFEventType;
28
import org.eclipse.emf.validation.internal.service.GetLiveConstraintsOperation;
28
import org.eclipse.emf.validation.internal.service.GetLiveConstraintsOperation;
29
import org.eclipse.emf.validation.model.IModelConstraint;
29
import org.eclipse.emf.validation.tests.TestNotification;
30
import org.eclipse.emf.validation.tests.TestNotification;
30
31
31
/**
32
/**
Lines 49-54 Link Here
49
	/* (non-Javadoc)
50
	/* (non-Javadoc)
50
	 * Extends the inherited method.
51
	 * Extends the inherited method.
51
	 */
52
	 */
53
	@Override
52
	protected void setUp() throws Exception {
54
	protected void setUp() throws Exception {
53
		super.setUp();
55
		super.setUp();
54
		
56
		
Lines 84-101 Link Here
84
	}
86
	}
85
	
87
	
86
	public void test_execute() {
88
	public void test_execute() {
87
		Object o = getFixture().execute(new TestProvider());
89
		Collection<IModelConstraint> c = getFixture().execute(new TestProvider());
88
		assertNotNull(o);
90
		assertNotNull(c);
89
		assertTrue("Execution result not collection", o instanceof Collection);//$NON-NLS-1$
90
		
91
		
91
		Collection c = (Collection)o;
92
		assertTrue("Token not found", c.contains(LIVE_TOKEN));//$NON-NLS-1$
92
		assertTrue("Token not found", c.contains(LIVE_TOKEN));//$NON-NLS-1$
93
	}
93
	}
94
94
95
	public void test_getConstraints() {
95
	public void test_getConstraints() {
96
		getFixture().execute(new TestProvider());
96
		getFixture().execute(new TestProvider());
97
		
97
		
98
		Collection c = getFixture().getConstraints();
98
		Collection<IModelConstraint> c = getFixture().getConstraints();
99
		
99
		
100
		// check that the token is in this collection
100
		// check that the token is in this collection
101
		assertTrue("Token not found", c.contains(LIVE_TOKEN)); //$NON-NLS-1$
101
		assertTrue("Token not found", c.contains(LIVE_TOKEN)); //$NON-NLS-1$
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/LiveValidatorTest.java (-65 / +41 lines)
Lines 17-23 Link Here
17
17
18
package org.eclipse.emf.validation.internal.service.impl.tests;
18
package org.eclipse.emf.validation.internal.service.impl.tests;
19
19
20
import java.util.Arrays;
21
import java.util.Collections;
20
import java.util.Collections;
22
import java.util.List;
21
import java.util.List;
23
22
Lines 28-35 Link Here
28
import ordersystem.OrderSystemFactory;
27
import ordersystem.OrderSystemFactory;
29
import ordersystem.OrderSystemPackage;
28
import ordersystem.OrderSystemPackage;
30
import ordersystem.Product;
29
import ordersystem.Product;
31
import ordersystem.special.impl.SpecialFactoryImpl;
30
import ordersystem.special.SpecialFactory;
32
33
import org.eclipse.core.runtime.IStatus;
31
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.emf.common.notify.Notification;
32
import org.eclipse.emf.common.notify.Notification;
35
import org.eclipse.emf.common.notify.impl.AdapterImpl;
33
import org.eclipse.emf.common.notify.impl.AdapterImpl;
Lines 43-49 Link Here
43
import org.eclipse.emf.validation.internal.service.LiveValidator;
41
import org.eclipse.emf.validation.internal.service.LiveValidator;
44
import org.eclipse.emf.validation.model.EvaluationMode;
42
import org.eclipse.emf.validation.model.EvaluationMode;
45
import org.eclipse.emf.validation.service.ILiveValidator;
43
import org.eclipse.emf.validation.service.ILiveValidator;
46
import org.eclipse.emf.validation.service.IValidator;
47
import org.eclipse.emf.validation.service.ModelValidationService;
44
import org.eclipse.emf.validation.service.ModelValidationService;
48
import org.eclipse.emf.validation.tests.TestBase;
45
import org.eclipse.emf.validation.tests.TestBase;
49
import org.eclipse.emf.validation.tests.TestNotification;
46
import org.eclipse.emf.validation.tests.TestNotification;
Lines 68-73 Link Here
68
	/* (non-Javadoc)
65
	/* (non-Javadoc)
69
	 * Extends the inherited method.
66
	 * Extends the inherited method.
70
	 */
67
	 */
68
	@Override
71
	protected void setUp() throws Exception {
69
	protected void setUp() throws Exception {
72
		super.setUp();
70
		super.setUp();
73
		
71
		
Lines 101-107 Link Here
101
	 * Class to test for IStatus validate(Object)
99
	 * Class to test for IStatus validate(Object)
102
	 */
100
	 */
103
	public void test_validate_object() {
101
	public void test_validate_object() {
104
		Object target = new TestNotification(
102
		Notification target = new TestNotification(
105
				OrderSystemFactory.eINSTANCE.createProduct(),
103
				OrderSystemFactory.eINSTANCE.createProduct(),
106
				Notification.SET,
104
				Notification.SET,
107
				OrderSystemPackage.PRODUCT__SKU,
105
				OrderSystemPackage.PRODUCT__SKU,
Lines 113-125 Link Here
113
		} catch (Exception e) {
111
		} catch (Exception e) {
114
			fail("Should not throw."); //$NON-NLS-1$
112
			fail("Should not throw."); //$NON-NLS-1$
115
		}
113
		}
116
		
117
		try {
118
			getValidator().validate("foo"); //$NON-NLS-1$
119
			fail("Should throw."); //$NON-NLS-1$
120
		} catch (Exception e) {
121
			// good
122
		}
123
	}
114
	}
124
115
125
	/*
116
	/*
Lines 144-150 Link Here
144
	 * Class to test for IStatus validate(Collection)
135
	 * Class to test for IStatus validate(Collection)
145
	 */
136
	 */
146
	public void test_validateCollection() {
137
	public void test_validateCollection() {
147
		Object target = new TestNotification(
138
		Notification target = new TestNotification(
148
				OrderSystemFactory.eINSTANCE.createProduct(),
139
				OrderSystemFactory.eINSTANCE.createProduct(),
149
				Notification.SET,
140
				Notification.SET,
150
				OrderSystemPackage.PRODUCT__SKU,
141
				OrderSystemPackage.PRODUCT__SKU,
Lines 153-169 Link Here
153
		
144
		
154
		try {
145
		try {
155
			getValidator().validate(Collections.singleton(target));
146
			getValidator().validate(Collections.singleton(target));
156
			getValidator().validate(Collections.EMPTY_SET);
147
			getValidator().validate(Collections.<Notification>emptySet());
157
		} catch (Exception e) {
148
		} catch (Exception e) {
158
			fail("Should not throw."); //$NON-NLS-1$
149
			fail("Should not throw."); //$NON-NLS-1$
159
		}
150
		}
160
		
161
		try {
162
			getValidator().validate(Collections.singleton("foo")); //$NON-NLS-1$
163
			fail("Should throw."); //$NON-NLS-1$
164
		} catch (Exception e) {
165
			// good
166
		}
167
	}
151
	}
168
	
152
	
169
	private OrderSystem createOrderSystem() {
153
	private OrderSystem createOrderSystem() {
Lines 187-193 Link Here
187
		os.getCustomer().add(c);
171
		os.getCustomer().add(c);
188
		
172
		
189
		// validate the changes, using a real validator
173
		// validate the changes, using a real validator
190
		IValidator realValidator =
174
		ILiveValidator realValidator =
191
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
175
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
192
		realValidator.validate(ng.getNotifications());
176
		realValidator.validate(ng.getNotifications());
193
		
177
		
Lines 219-225 Link Here
219
		}
203
		}
220
		
204
		
221
		// add a few customers, individually, to record separate notifications
205
		// add a few customers, individually, to record separate notifications
222
		List customers = new java.util.ArrayList();
206
		List<Customer> customers = new java.util.ArrayList<Customer>();
223
		Customer c = OrderSystemFactory.eINSTANCE.createCustomer();
207
		Customer c = OrderSystemFactory.eINSTANCE.createCustomer();
224
		os.getCustomer().add(c);  // one
208
		os.getCustomer().add(c);  // one
225
		customers.add(c);
209
		customers.add(c);
Lines 231-237 Link Here
231
		customers.add(c);
215
		customers.add(c);
232
		
216
		
233
		// validate the changes, using a real validator
217
		// validate the changes, using a real validator
234
		IValidator realValidator =
218
		ILiveValidator realValidator =
235
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
219
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
236
		realValidator.validate(ng.getNotifications());
220
		realValidator.validate(ng.getNotifications());
237
		
221
		
Lines 256-262 Link Here
256
		OrderSystem os = createOrderSystem();
240
		OrderSystem os = createOrderSystem();
257
		
241
		
258
		// add a few customers
242
		// add a few customers
259
		List customers = new java.util.ArrayList();
243
		List<Customer> customers = new java.util.ArrayList<Customer>();
260
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
244
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
261
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
245
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
262
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
246
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
Lines 271-281 Link Here
271
		}
255
		}
272
		
256
		
273
		// remove a customer
257
		// remove a customer
274
		Customer c = (Customer) customers.get(0);
258
		Customer c = customers.get(0);
275
		os.getCustomer().remove(c);
259
		os.getCustomer().remove(c);
276
		
260
		
277
		// validate the changes, using a real validator
261
		// validate the changes, using a real validator
278
		IValidator realValidator =
262
		ILiveValidator realValidator =
279
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
263
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
280
		realValidator.validate(ng.getNotifications());
264
		realValidator.validate(ng.getNotifications());
281
		
265
		
Lines 300-306 Link Here
300
		OrderSystem os = createOrderSystem();
284
		OrderSystem os = createOrderSystem();
301
		
285
		
302
		// add a few customers
286
		// add a few customers
303
		List customers = new java.util.ArrayList();
287
		List<Customer> customers = new java.util.ArrayList<Customer>();
304
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
288
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
305
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
289
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
306
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
290
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
Lines 320-326 Link Here
320
		os.getCustomer().remove(customers.get(2));  // three
304
		os.getCustomer().remove(customers.get(2));  // three
321
		
305
		
322
		// validate the changes, using a real validator
306
		// validate the changes, using a real validator
323
		IValidator realValidator =
307
		ILiveValidator realValidator =
324
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
308
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
325
		realValidator.validate(ng.getNotifications());
309
		realValidator.validate(ng.getNotifications());
326
		
310
		
Lines 345-351 Link Here
345
		OrderSystem os = createOrderSystem();
329
		OrderSystem os = createOrderSystem();
346
		
330
		
347
		// add a few customers
331
		// add a few customers
348
		List customers = new java.util.ArrayList();
332
		List<Customer> customers = new java.util.ArrayList<Customer>();
349
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
333
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
350
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
334
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
351
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
335
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
Lines 363-369 Link Here
363
		os.getCustomer().move(0, 2);
347
		os.getCustomer().move(0, 2);
364
		
348
		
365
		// validate the changes, using a real validator
349
		// validate the changes, using a real validator
366
		IValidator realValidator =
350
		ILiveValidator realValidator =
367
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
351
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
368
		realValidator.validate(ng.getNotifications());
352
		realValidator.validate(ng.getNotifications());
369
		
353
		
Lines 388-394 Link Here
388
		OrderSystem os = createOrderSystem();
372
		OrderSystem os = createOrderSystem();
389
		
373
		
390
		// add a few customers
374
		// add a few customers
391
		List customers = new java.util.ArrayList();
375
		List<Customer> customers = new java.util.ArrayList<Customer>();
392
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
376
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
393
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
377
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
394
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
378
		customers.add(OrderSystemFactory.eINSTANCE.createCustomer());
Lines 408-414 Link Here
408
		os.getCustomer().move(0, 1);  // three
392
		os.getCustomer().move(0, 1);  // three
409
		
393
		
410
		// validate the changes, using a real validator
394
		// validate the changes, using a real validator
411
		IValidator realValidator =
395
		ILiveValidator realValidator =
412
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
396
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
413
		realValidator.validate(ng.getNotifications());
397
		realValidator.validate(ng.getNotifications());
414
		
398
		
Lines 444-450 Link Here
444
		os.eAdapters().remove(ng);
428
		os.eAdapters().remove(ng);
445
		
429
		
446
		// validate the changes, using a real validator
430
		// validate the changes, using a real validator
447
		IValidator realValidator =
431
		ILiveValidator realValidator =
448
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
432
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
449
		realValidator.validate(ng.getNotifications());
433
		realValidator.validate(ng.getNotifications());
450
		
434
		
Lines 484-490 Link Here
484
		os.eAdapters().remove(ng);  // three
468
		os.eAdapters().remove(ng);  // three
485
		
469
		
486
		// validate the changes, using a real validator
470
		// validate the changes, using a real validator
487
		IValidator realValidator =
471
		ILiveValidator realValidator =
488
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
472
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
489
		realValidator.validate(ng.getNotifications());
473
		realValidator.validate(ng.getNotifications());
490
		
474
		
Lines 519-525 Link Here
519
		os.setVersion(3);
503
		os.setVersion(3);
520
		
504
		
521
		// validate the changes, using a real validator
505
		// validate the changes, using a real validator
522
		IValidator realValidator =
506
		ILiveValidator realValidator =
523
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
507
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
524
		realValidator.validate(ng.getNotifications());
508
		realValidator.validate(ng.getNotifications());
525
		
509
		
Lines 556-562 Link Here
556
		os.setVersion(3);
540
		os.setVersion(3);
557
		
541
		
558
		// validate the changes, using a real validator
542
		// validate the changes, using a real validator
559
		IValidator realValidator =
543
		ILiveValidator realValidator =
560
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
544
			ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
561
		realValidator.validate(ng.getNotifications());
545
		realValidator.validate(ng.getNotifications());
562
		
546
		
Lines 581-587 Link Here
581
		EObject object = OrderSystemFactory.eINSTANCE.createOrder(); // Don't add to a resource
565
		EObject object = OrderSystemFactory.eINSTANCE.createOrder(); // Don't add to a resource
582
		Notification event = new TestNotification(object, Notification.SET);
566
		Notification event = new TestNotification(object, Notification.SET);
583
		
567
		
584
		ILiveValidator localValidator = (ILiveValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
568
		ILiveValidator localValidator = ModelValidationService.getInstance().newValidator(
569
			EvaluationMode.LIVE);
585
		localValidator.setReportSuccesses(true);
570
		localValidator.setReportSuccesses(true);
586
		IStatus[] status = getStatuses(localValidator.validate(event));
571
		IStatus[] status = getStatuses(localValidator.validate(event));
587
		
572
		
Lines 589-617 Link Here
589
		assertAllConstraintsNotPresent(
574
		assertAllConstraintsNotPresent(
590
				"live", //$NON-NLS-1$
575
				"live", //$NON-NLS-1$
591
				status,
576
				status,
592
				Arrays.asList(new String[] {
577
				ID_PREFIX + "order.hasName", //$NON-NLS-1$
593
						ID_PREFIX + "order.hasName", //$NON-NLS-1$
578
				ID_PREFIX + "order.hasOwner"); //$NON-NLS-1$
594
						ID_PREFIX + "order.hasOwner", //$NON-NLS-1$
595
				}));
596
	}
579
	}
597
	
580
	
598
	public void test_notficationFilterCustom_177653() {
581
	public void test_notficationFilterCustom_177653() {
599
		EObject object = OrderSystemFactory.eINSTANCE.createOrder();
582
		EObject object = OrderSystemFactory.eINSTANCE.createOrder();
600
		Notification event = new TestNotification(object, Notification.SET);
583
		Notification event = new TestNotification(object, Notification.SET);
601
		
584
		
602
		ILiveValidator localValidator = (ILiveValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
585
		ILiveValidator localValidator = ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
603
		localValidator.setReportSuccesses(true);
586
		localValidator.setReportSuccesses(true);
604
		
587
		
605
		// Set notification filter which accepts eObjects that are not attached
588
		// Set notification filter which accepts eObjects that are not attached
606
		// to a resource
589
		// to a resource
607
		localValidator.setNotificationFilter(new FilteredCollection.Filter() {
590
		localValidator.setNotificationFilter(new FilteredCollection.Filter<Notification>() {
608
			public boolean accept(Object element) {
591
			public boolean accept(Notification element) {
609
				if (element instanceof Notification) {
592
				return (element.getNotifier() instanceof EObject);
610
					Notification notification = (Notification)element;
611
					return (notification.getNotifier() instanceof EObject);
612
				}
613
                
614
				return false;
615
			}});
593
			}});
616
		
594
		
617
		IStatus[] status = getStatuses(localValidator.validate(event));
595
		IStatus[] status = getStatuses(localValidator.validate(event));
Lines 619-634 Link Here
619
		assertAllConstraintsPresent(
597
		assertAllConstraintsPresent(
620
				"live", //$NON-NLS-1$
598
				"live", //$NON-NLS-1$
621
				status,
599
				status,
622
				Arrays.asList(new String[] {
600
				ID_PREFIX + "order.hasName", //$NON-NLS-1$
623
						ID_PREFIX + "order.hasName", //$NON-NLS-1$
601
				ID_PREFIX + "order.hasOwner"); //$NON-NLS-1$
624
						ID_PREFIX + "order.hasOwner", //$NON-NLS-1$
625
				}));
626
	}
602
	}
627
	
603
	
628
	public void test_notificationGenerator_177647() {
604
	public void test_notificationGenerator_177647() {
629
		Order order = OrderSystemFactory.eINSTANCE.createOrder();
605
		Order order = OrderSystemFactory.eINSTANCE.createOrder();
630
		LineItem item = OrderSystemFactory.eINSTANCE.createLineItem();
606
		LineItem item = OrderSystemFactory.eINSTANCE.createLineItem();
631
		Product product = SpecialFactoryImpl.eINSTANCE.createLimitedEditionProduct();
607
		Product product = SpecialFactory.eINSTANCE.createLimitedEditionProduct();
632
		
608
		
633
		Resource res = new XMIResourceImpl();
609
		Resource res = new XMIResourceImpl();
634
		
610
		
Lines 641-647 Link Here
641
		
617
		
642
		Notification event = new TestNotification(order, Notification.SET);
618
		Notification event = new TestNotification(order, Notification.SET);
643
		
619
		
644
		ILiveValidator localValidator = (ILiveValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
620
		ILiveValidator localValidator = ModelValidationService.getInstance().newValidator(EvaluationMode.LIVE);
645
		localValidator.setReportSuccesses(true);
621
		localValidator.setReportSuccesses(true);
646
		
622
		
647
		IStatus[] status = getStatuses(localValidator.validate(event));
623
		IStatus[] status = getStatuses(localValidator.validate(event));
Lines 649-678 Link Here
649
		assertAllConstraintsPresent(
625
		assertAllConstraintsPresent(
650
				"live", //$NON-NLS-1$
626
				"live", //$NON-NLS-1$
651
				status,
627
				status,
652
				Arrays.asList(new String[] {
628
				ID_PREFIX + "limitedEdition.canIncludeInSpecial"); //$NON-NLS-1$
653
						ID_PREFIX + "limitedEdition.canIncludeInSpecial", //$NON-NLS-1$
654
				}));
655
		
629
		
656
		// Ensure that a constraint targeted at ALL events (eg using wildcard),
630
		// Ensure that a constraint targeted at ALL events (eg using wildcard),
657
		// does not get triggered see
631
		// does not get triggered see
658
		// XMLConstraintDescriptor#targetsEvent(Notification)
632
		// XMLConstraintDescriptor#targetsEvent(Notification)
659
		assertAllConstraintsNotPresent(
633
		assertAllConstraintsNotPresent(
660
				"live", status, Arrays.asList(new String[] { //$NON-NLS-1$
634
				"live", status, //$NON-NLS-1$
661
						ID_PREFIX + "limitedEdition.hasDates", //$NON-NLS-1$
635
				ID_PREFIX + "limitedEdition.hasDates"); //$NON-NLS-1$
662
						}));
663
	}
636
	}
664
	
637
	
665
	private static class NotificationGatherer extends AdapterImpl {
638
	private static class NotificationGatherer extends AdapterImpl {
666
		private List notifications = new java.util.ArrayList();
639
		private final List<Notification> notifications =
640
			new java.util.ArrayList<Notification>();
667
		
641
		
668
		/* (non-Javadoc)
642
		/* (non-Javadoc)
669
		 * Redefines/Implements/Extends the inherited method.
643
		 * Redefines/Implements/Extends the inherited method.
670
		 */
644
		 */
645
		@Override
671
		public void notifyChanged(Notification msg) {
646
		public void notifyChanged(Notification msg) {
672
			notifications.add(msg);
647
			notifications.add(msg);
673
		}
648
		}
674
		
649
		
675
		List getNotifications() {
650
		List<Notification> getNotifications() {
676
			return notifications;
651
			return notifications;
677
		}
652
		}
678
		
653
		
Lines 691-696 Link Here
691
		/* (non-Javadoc)
666
		/* (non-Javadoc)
692
		 * Redefines/Implements/Extends the inherited method.
667
		 * Redefines/Implements/Extends the inherited method.
693
		 */
668
		 */
669
		@Override
694
		public IStatus validate(IValidationContext ctx) {
670
		public IStatus validate(IValidationContext ctx) {
695
			instance = this;
671
			instance = this;
696
			invocationCount++;
672
			invocationCount++;
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/ConstraintCacheTest.java (-10 / +15 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 28-33 Link Here
28
import org.eclipse.emf.validation.internal.service.ConstraintCache;
28
import org.eclipse.emf.validation.internal.service.ConstraintCache;
29
import org.eclipse.emf.validation.internal.service.IProviderDescriptor;
29
import org.eclipse.emf.validation.internal.service.IProviderDescriptor;
30
import org.eclipse.emf.validation.internal.service.IProviderOperation;
30
import org.eclipse.emf.validation.internal.service.IProviderOperation;
31
import org.eclipse.emf.validation.model.IModelConstraint;
31
import org.eclipse.emf.validation.service.IModelConstraintProvider;
32
import org.eclipse.emf.validation.service.IModelConstraintProvider;
32
import org.eclipse.emf.validation.tests.TestNotification;
33
import org.eclipse.emf.validation.tests.TestNotification;
33
34
Lines 54-59 Link Here
54
	/* (non-Javadoc)
55
	/* (non-Javadoc)
55
	 * Extends the inherited method.
56
	 * Extends the inherited method.
56
	 */
57
	 */
58
	@Override
57
	protected void setUp() throws Exception {
59
	protected void setUp() throws Exception {
58
		super.setUp();
60
		super.setUp();
59
		
61
		
Lines 77-90 Link Here
77
	}
79
	}
78
80
79
	public void test_getProviders() {
81
	public void test_getProviders() {
80
		Collection c = getFixture().getProviders();
82
		Collection<IProviderDescriptor> c = getFixture().getProviders();
81
		
83
		
82
		assertNotNull("Collection is null", c); //$NON-NLS-1$
84
		assertNotNull("Collection is null", c); //$NON-NLS-1$
83
		assertFalse("Collection is empty", c.isEmpty()); //$NON-NLS-1$
85
		assertFalse("Collection is empty", c.isEmpty()); //$NON-NLS-1$
84
	}
86
	}
85
87
86
	public void test_addProvider() {
88
	public void test_addProvider() {
87
		Collection c = getFixture().getProviders();
89
		Collection<IProviderDescriptor> c = getFixture().getProviders();
88
		
90
		
89
		assertNotNull("Collection is null", c); //$NON-NLS-1$
91
		assertNotNull("Collection is null", c); //$NON-NLS-1$
90
		assertTrue("Provider not found", c.contains(provider)); //$NON-NLS-1$
92
		assertTrue("Provider not found", c.contains(provider)); //$NON-NLS-1$
Lines 93-99 Link Here
93
	public void test_getBatchConstraints() {
95
	public void test_getBatchConstraints() {
94
		assertTrue("Hit count should be zero", batchHits == 0); //$NON-NLS-1$
96
		assertTrue("Hit count should be zero", batchHits == 0); //$NON-NLS-1$
95
		
97
		
96
		Collection c = getFixture().getBatchConstraints(
98
		Collection<IModelConstraint> c = getFixture().getBatchConstraints(
97
				OrderSystemFactory.eINSTANCE.createProduct(),
99
				OrderSystemFactory.eINSTANCE.createProduct(),
98
				null);
100
				null);
99
		
101
		
Lines 114-120 Link Here
114
	public void test_getLiveConstraints() {
116
	public void test_getLiveConstraints() {
115
		assertTrue("Hit count should be zero", liveHits == 0); //$NON-NLS-1$
117
		assertTrue("Hit count should be zero", liveHits == 0); //$NON-NLS-1$
116
		
118
		
117
		Collection c = getFixture().getLiveConstraints(
119
		Collection<IModelConstraint> c = getFixture().getLiveConstraints(
118
				new TestNotification(
120
				new TestNotification(
119
						OrderSystemFactory.eINSTANCE.createProduct(),
121
						OrderSystemFactory.eINSTANCE.createProduct(),
120
						Notification.SET),
122
						Notification.SET),
Lines 139-145 Link Here
139
	static class TestDescriptor implements IProviderDescriptor {
141
	static class TestDescriptor implements IProviderDescriptor {
140
		private final IModelConstraintProvider testProvider = new TestProvider();
142
		private final IModelConstraintProvider testProvider = new TestProvider();
141
		
143
		
142
		public boolean provides(IProviderOperation operation) {
144
		public boolean provides(
145
				IProviderOperation<? extends Collection<? extends IModelConstraint>> operation) {
143
			return true;
146
			return true;
144
		}
147
		}
145
148
Lines 163-179 Link Here
163
	static class TestProvider
166
	static class TestProvider
164
			extends AbstractGetConstraintsOperationTest.TestProvider {
167
			extends AbstractGetConstraintsOperationTest.TestProvider {
165
		
168
		
166
		public Collection getBatchConstraints(
169
		@Override
170
		public Collection<IModelConstraint> getBatchConstraints(
167
			EObject eObject,
171
			EObject eObject,
168
			Collection constraints) {
172
			Collection<IModelConstraint> constraints) {
169
			
173
			
170
			batchHits++;
174
			batchHits++;
171
			return super.getBatchConstraints(eObject, constraints);
175
			return super.getBatchConstraints(eObject, constraints);
172
		}
176
		}
173
		
177
		
174
		public Collection getLiveConstraints(
178
		@Override
179
		public Collection<IModelConstraint> getLiveConstraints(
175
			Notification notification,
180
			Notification notification,
176
			Collection constraints) {
181
			Collection<IModelConstraint> constraints) {
177
			
182
			
178
			liveHits++;
183
			liveHits++;
179
			return super.getLiveConstraints(notification, constraints);
184
			return super.getLiveConstraints(notification, constraints);
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/BatchValidatorTest.java (-21 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 29-34 Link Here
29
import org.eclipse.emf.validation.internal.service.IProviderOperation;
29
import org.eclipse.emf.validation.internal.service.IProviderOperation;
30
import org.eclipse.emf.validation.internal.service.IProviderOperationExecutor;
30
import org.eclipse.emf.validation.internal.service.IProviderOperationExecutor;
31
import org.eclipse.emf.validation.model.EvaluationMode;
31
import org.eclipse.emf.validation.model.EvaluationMode;
32
import org.eclipse.emf.validation.model.IModelConstraint;
32
33
33
import junit.framework.TestCase;
34
import junit.framework.TestCase;
34
35
Lines 51-56 Link Here
51
	/* (non-Javadoc)
52
	/* (non-Javadoc)
52
	 * Extends the inherited method.
53
	 * Extends the inherited method.
53
	 */
54
	 */
55
	@Override
54
	protected void setUp() throws Exception {
56
	protected void setUp() throws Exception {
55
		super.setUp();
57
		super.setUp();
56
		
58
		
Lines 84-124 Link Here
84
	 * Class to test for IStatus validate(Object)
86
	 * Class to test for IStatus validate(Object)
85
	 */
87
	 */
86
	public void test_validate_object() {
88
	public void test_validate_object() {
87
		Object target = OrderSystemFactory.eINSTANCE.createProduct();
89
		EObject target = OrderSystemFactory.eINSTANCE.createProduct();
88
		
90
		
89
		try {
91
		try {
90
			getValidator().validate(target);
92
			getValidator().validate(target);
91
		} catch (Exception e) {
93
		} catch (Exception e) {
92
			fail("Should not throw."); //$NON-NLS-1$
94
			fail("Should not throw."); //$NON-NLS-1$
93
		}
95
		}
94
		
95
		try {
96
			getValidator().validate("foo"); //$NON-NLS-1$
97
			fail("Should throw."); //$NON-NLS-1$
98
		} catch (Exception e) {
99
			// good
100
		}
101
	}
96
	}
102
97
103
	/*
98
	/*
104
	 * Class to test for IStatus validate(Collection)
99
	 * Class to test for IStatus validate(Collection)
105
	 */
100
	 */
106
	public void test_validateCollection() {
101
	public void test_validateCollection() {
107
		Object target = OrderSystemFactory.eINSTANCE.createProduct();
102
		EObject target = OrderSystemFactory.eINSTANCE.createProduct();
108
		
103
		
109
		try {
104
		try {
110
			getValidator().validate(Collections.singleton(target));
105
			getValidator().validate(Collections.singleton(target));
111
			getValidator().validate(Collections.EMPTY_SET);
106
			getValidator().validate(Collections.<EObject>emptySet());
112
		} catch (Exception e) {
107
		} catch (Exception e) {
113
			fail("Should not throw."); //$NON-NLS-1$
108
			fail("Should not throw."); //$NON-NLS-1$
114
		}
109
		}
115
		
116
		try {
117
			getValidator().validate(Collections.singleton("foo")); //$NON-NLS-1$
118
			fail("Should throw."); //$NON-NLS-1$
119
		} catch (Exception e) {
120
			// good
121
		}
122
	}
110
	}
123
	
111
	
124
	public void test_isIncludeLiveConstraints() {
112
	public void test_isIncludeLiveConstraints() {
Lines 163-169 Link Here
163
	public void test_validate_Collection_IProgressMonitor() {
151
	public void test_validate_Collection_IProgressMonitor() {
164
		TestMonitor monitor = new TestMonitor();
152
		TestMonitor monitor = new TestMonitor();
165
		
153
		
166
		Collection targets = new java.util.LinkedList();
154
		Collection<EObject> targets = new java.util.ArrayList<EObject>();
167
		targets.add(OrderSystemFactory.eINSTANCE.createProduct());
155
		targets.add(OrderSystemFactory.eINSTANCE.createProduct());
168
		targets.add(OrderSystemFactory.eINSTANCE.createProduct());
156
		targets.add(OrderSystemFactory.eINSTANCE.createProduct());
169
		
157
		
Lines 233-243 Link Here
233
		}
221
		}
234
	}
222
	}
235
	
223
	
236
	static class TestExecutor implements IProviderOperationExecutor {
224
	static class TestExecutor
225
			implements IProviderOperationExecutor<Collection<IModelConstraint>> {
237
		/* (non-Javadoc)
226
		/* (non-Javadoc)
238
		 * Implements the inherited method.
227
		 * Implements the inherited method.
239
		 */
228
		 */
240
		public void execute(IProviderOperation op) {
229
		public void execute(IProviderOperation<? extends Collection<IModelConstraint>> op) {
241
			// don't need to do anything
230
			// don't need to do anything
242
		}
231
		}
243
	}
232
	}
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/ConstraintDescriptorTest.java (-19 / +15 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 18-24 Link Here
18
package org.eclipse.emf.validation.internal.service.impl.tests;
18
package org.eclipse.emf.validation.internal.service.impl.tests;
19
19
20
import java.util.Collections;
20
import java.util.Collections;
21
import java.util.Iterator;
22
import java.util.List;
21
import java.util.List;
23
import java.util.Map;
22
import java.util.Map;
24
import java.util.Set;
23
import java.util.Set;
Lines 34-39 Link Here
34
import org.eclipse.core.runtime.IStatus;
33
import org.eclipse.core.runtime.IStatus;
35
import org.eclipse.core.runtime.InvalidRegistryObjectException;
34
import org.eclipse.core.runtime.InvalidRegistryObjectException;
36
import org.eclipse.core.runtime.Status;
35
import org.eclipse.core.runtime.Status;
36
import org.eclipse.emf.common.notify.Notification;
37
import org.eclipse.emf.validation.EMFEventType;
37
import org.eclipse.emf.validation.EMFEventType;
38
import org.eclipse.emf.validation.internal.util.XmlConstraintDescriptor;
38
import org.eclipse.emf.validation.internal.util.XmlConstraintDescriptor;
39
import org.eclipse.emf.validation.model.Category;
39
import org.eclipse.emf.validation.model.Category;
Lines 60-66 Link Here
60
	private static final String TEST_BODY = "self.name = 'Ottawa'";//$NON-NLS-1$
60
	private static final String TEST_BODY = "self.name = 'Ottawa'";//$NON-NLS-1$
61
	private static final int TEST_CODE = 1000;
61
	private static final int TEST_CODE = 1000;
62
	private static final ConstraintSeverity TEST_SEVERITY = ConstraintSeverity.WARNING;
62
	private static final ConstraintSeverity TEST_SEVERITY = ConstraintSeverity.WARNING;
63
	private static final EvaluationMode TEST_MODE = EvaluationMode.LIVE;
63
	private static final EvaluationMode<Notification> TEST_MODE = EvaluationMode.LIVE;
64
	private static final String TEST_NAMESPACE_URI = "http:///ordersystem.ecore"; //$NON-NLS-1$
64
	private static final String TEST_NAMESPACE_URI = "http:///ordersystem.ecore"; //$NON-NLS-1$
65
	private static final String TEST_CLASS = "Warehouse"; //$NON-NLS-1$
65
	private static final String TEST_CLASS = "Warehouse"; //$NON-NLS-1$
66
	private static final String TEST_EVENT = "Set"; //$NON-NLS-1$
66
	private static final String TEST_EVENT = "Set"; //$NON-NLS-1$
Lines 74-81 Link Here
74
	 * Handy implementation of the Eclipse extension configuration element. 
74
	 * Handy implementation of the Eclipse extension configuration element. 
75
	 */
75
	 */
76
	public static class FixtureElement implements IConfigurationElement {
76
	public static class FixtureElement implements IConfigurationElement {
77
		private final Map attributes = new java.util.HashMap();
77
		private final Map<String, String> attributes = new java.util.HashMap<String, String>();
78
		private final List children = new java.util.ArrayList();
78
		private final List<IConfigurationElement> children = new java.util.ArrayList<IConfigurationElement>();
79
		private Object parent;
79
		private Object parent;
80
		private final String myName;
80
		private final String myName;
81
		private String value = ""; //$NON-NLS-1$
81
		private String value = ""; //$NON-NLS-1$
Lines 99-106 Link Here
99
			FixtureElement result = new FixtureElement(name);
99
			FixtureElement result = new FixtureElement(name);
100
			
100
			
101
			if (attributes != null) {
101
			if (attributes != null) {
102
				for (int i = 0; i < attributes.length; i++) {
102
				for (String[] element : attributes) {
103
					result.putAttribute(attributes[i][0], attributes[i][1]);
103
					result.putAttribute(element[0], element[1]);
104
				}
104
				}
105
			}
105
			}
106
				
106
				
Lines 111-117 Link Here
111
		
111
		
112
		// implements/extends the inherited method
112
		// implements/extends the inherited method
113
		public String getAttribute(String name) {
113
		public String getAttribute(String name) {
114
			return (String)attributes.get(name);
114
			return attributes.get(name);
115
		}
115
		}
116
		
116
		
117
		public FixtureElement putAttribute(String name, String newValue) {
117
		public FixtureElement putAttribute(String name, String newValue) {
Lines 127-156 Link Here
127
127
128
		// implements/extends the inherited method
128
		// implements/extends the inherited method
129
		public String[] getAttributeNames() {
129
		public String[] getAttributeNames() {
130
			return (String[])attributes.keySet().toArray(
130
			return attributes.keySet().toArray(new String[attributes.size()]);
131
					new String[attributes.size()]);
132
		}
131
		}
133
132
134
		// implements/extends the inherited method
133
		// implements/extends the inherited method
135
		public IConfigurationElement[] getChildren() {
134
		public IConfigurationElement[] getChildren() {
136
			return (IConfigurationElement[])children.toArray(
135
			return children.toArray(new IConfigurationElement[children.size()]);
137
					new IConfigurationElement[children.size()]);
138
		}
136
		}
139
137
140
		// implements/extends the inherited method
138
		// implements/extends the inherited method
141
		public IConfigurationElement[] getChildren(String name) {
139
		public IConfigurationElement[] getChildren(String name) {
142
			List result = new java.util.ArrayList();
140
			List<IConfigurationElement> result = new java.util.ArrayList<IConfigurationElement>();
143
			
141
			
144
			for (Iterator iter = children.iterator(); iter.hasNext(); ) {
142
			for (IConfigurationElement next : children) {
145
				IConfigurationElement next = (IConfigurationElement)iter.next();
146
				
147
				if (next.getName().equals(name)) {
143
				if (next.getName().equals(name)) {
148
					result.add(next);
144
					result.add(next);
149
				}
145
				}
150
			}
146
			}
151
			
147
			
152
			return (IConfigurationElement[])result.toArray(
148
			return result.toArray(new IConfigurationElement[result.size()]);
153
					new IConfigurationElement[result.size()]);
154
		}
149
		}
155
		
150
		
156
		public FixtureElement addChild(IConfigurationElement child) {
151
		public FixtureElement addChild(IConfigurationElement child) {
Lines 188-193 Link Here
188
		// constructor can find the plug-in ID that it needs from the
183
		// constructor can find the plug-in ID that it needs from the
189
		// configuration element
184
		// configuration element
190
		/** @deprecated */
185
		/** @deprecated */
186
		@Deprecated
191
		public IExtension getDeclaringExtension() {
187
		public IExtension getDeclaringExtension() {
192
			return new IExtension() {
188
			return new IExtension() {
193
				
189
				
Lines 418-424 Link Here
418
	}
414
	}
419
415
420
	public void test_getCategories() {
416
	public void test_getCategories() {
421
		Set categories = Collections.singleton(
417
		Set<Category> categories = Collections.singleton(
422
				CategoryManager.getInstance().getDefaultCategory());
418
				CategoryManager.getInstance().getDefaultCategory());
423
		
419
		
424
		assertEquals(categories, getFixture().getCategories());
420
		assertEquals(categories, getFixture().getCategories());
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/AbstractGetConstraintsOperationTest.java (-11 / +13 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 40-47 Link Here
40
 * @author Christian W. Damus (cdamus)
40
 * @author Christian W. Damus (cdamus)
41
 */
41
 */
42
abstract class AbstractGetConstraintsOperationTest extends TestBase {
42
abstract class AbstractGetConstraintsOperationTest extends TestBase {
43
	protected static final Object BATCH_TOKEN = newConstraint(EvaluationMode.BATCH);
43
	protected static final IModelConstraint BATCH_TOKEN = newConstraint(EvaluationMode.BATCH);
44
	protected static final Object LIVE_TOKEN = newConstraint(EvaluationMode.LIVE);
44
	protected static final IModelConstraint LIVE_TOKEN = newConstraint(EvaluationMode.LIVE);
45
	
45
	
46
	private AbstractGetConstraintsOperation fixture;
46
	private AbstractGetConstraintsOperation fixture;
47
	
47
	
Lines 61-67 Link Here
61
		this.fixture = fixture;
61
		this.fixture = fixture;
62
	}
62
	}
63
	
63
	
64
	private static TestConstraint newConstraint(EvaluationMode mode) {
64
	private static TestConstraint newConstraint(EvaluationMode<?> mode) {
65
		ConstraintDescriptorTest.FixtureElement config =
65
		ConstraintDescriptorTest.FixtureElement config =
66
			ConstraintDescriptorTest.newFixtureConfig();
66
			ConstraintDescriptorTest.newFixtureConfig();
67
		
67
		
Lines 83-109 Link Here
83
		/* (non-Javadoc)
83
		/* (non-Javadoc)
84
		 * Redefines/Implements/Extends the inherited method.
84
		 * Redefines/Implements/Extends the inherited method.
85
		 */
85
		 */
86
		public Collection getBatchConstraints(
86
		public Collection<IModelConstraint> getBatchConstraints(
87
				EObject eObject,
87
				EObject eObject,
88
				Collection constraints) {
88
				Collection<IModelConstraint> constraints) {
89
			return appendTo(constraints, BATCH_TOKEN);
89
			return appendTo(constraints, BATCH_TOKEN);
90
		}
90
		}
91
91
92
		/* (non-Javadoc)
92
		/* (non-Javadoc)
93
		 * Redefines/Implements/Extends the inherited method.
93
		 * Redefines/Implements/Extends the inherited method.
94
		 */
94
		 */
95
		public Collection getLiveConstraints(
95
		public Collection<IModelConstraint> getLiveConstraints(
96
				Notification notification,
96
				Notification notification,
97
				Collection constraints) {
97
				Collection<IModelConstraint> constraints) {
98
			return appendTo(constraints, LIVE_TOKEN);
98
			return appendTo(constraints, LIVE_TOKEN);
99
		}
99
		}
100
		
100
		
101
		private Collection appendTo(Collection c, Object o) {
101
		private Collection<IModelConstraint> appendTo(Collection<IModelConstraint> c,
102
				IModelConstraint constraint) {
103
			
102
			if (c == null) {
104
			if (c == null) {
103
				c = new java.util.ArrayList(1);
105
				c = new java.util.ArrayList<IModelConstraint>(1);
104
			}
106
			}
105
			
107
			
106
			c.add(o);
108
			c.add(constraint);
107
			
109
			
108
			return c;
110
			return c;
109
		}
111
		}
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/GetBatchConstraintsOperationTest.java (-6 / +6 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 24-29 Link Here
24
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EObject;
25
25
26
import org.eclipse.emf.validation.internal.service.GetBatchConstraintsOperation;
26
import org.eclipse.emf.validation.internal.service.GetBatchConstraintsOperation;
27
import org.eclipse.emf.validation.model.IModelConstraint;
27
28
28
/**
29
/**
29
 * Tests for {@link GetBatchConstraintsOperation}.
30
 * Tests for {@link GetBatchConstraintsOperation}.
Lines 45-50 Link Here
45
	/* (non-Javadoc)
46
	/* (non-Javadoc)
46
	 * Extends the inherited method.
47
	 * Extends the inherited method.
47
	 */
48
	 */
49
	@Override
48
	protected void setUp() throws Exception {
50
	protected void setUp() throws Exception {
49
		super.setUp();
51
		super.setUp();
50
		
52
		
Lines 60-77 Link Here
60
	}
62
	}
61
63
62
	public void test_execute() {
64
	public void test_execute() {
63
		Object o = getFixture().execute(new TestProvider());
65
		Collection<IModelConstraint> c = getFixture().execute(new TestProvider());
64
		assertNotNull(o);
66
		assertNotNull(c);
65
		assertTrue("Execution result not collection", o instanceof Collection);//$NON-NLS-1$
66
		
67
		
67
		Collection c = (Collection)o;
68
		assertTrue("Token not found", c.contains(BATCH_TOKEN));//$NON-NLS-1$
68
		assertTrue("Token not found", c.contains(BATCH_TOKEN));//$NON-NLS-1$
69
	}
69
	}
70
70
71
	public void test_getConstraints() {
71
	public void test_getConstraints() {
72
		getFixture().execute(new TestProvider());
72
		getFixture().execute(new TestProvider());
73
		
73
		
74
		Collection c = getFixture().getConstraints();
74
		Collection<IModelConstraint> c = getFixture().getConstraints();
75
		
75
		
76
		// check that the token is in this collection
76
		// check that the token is in this collection
77
		assertTrue("Token not found", c.contains(BATCH_TOKEN)); //$NON-NLS-1$
77
		assertTrue("Token not found", c.contains(BATCH_TOKEN)); //$NON-NLS-1$
(-)src/org/eclipse/emf/validation/internal/util/tests/FilteredCollectionTest.java (-14 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 20-27 Link Here
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.Arrays;
21
import java.util.Arrays;
22
import java.util.Collection;
22
import java.util.Collection;
23
import java.util.Iterator;
24
25
import org.eclipse.emf.validation.util.FilteredCollection;
23
import org.eclipse.emf.validation.util.FilteredCollection;
26
24
27
import junit.framework.Test;
25
import junit.framework.Test;
Lines 34-48 Link Here
34
 * @author Christian W. Damus (cdamus)
32
 * @author Christian W. Damus (cdamus)
35
 */
33
 */
36
public class FilteredCollectionTest extends TestCase {
34
public class FilteredCollectionTest extends TestCase {
37
	private class Filter implements FilteredCollection.Filter {
35
	private class Filter implements FilteredCollection.Filter<Integer> {
38
		// filters out odd integers
36
		// filters out odd integers
39
		public boolean accept(Object element) {
37
		public boolean accept(Integer element) {
40
			return (((Integer)element).intValue() % 2) == 0;
38
			return (element % 2) == 0;
41
		}
39
		}
42
	}
40
	}
43
	
41
	
44
	private Filter filter = new Filter();
42
	private final Filter filter = new Filter();
45
	private Collection original = Arrays.asList(
43
	private final Collection<Integer> original = Arrays.asList(
46
		new Integer[] {
44
		new Integer[] {
47
			new Integer(0),
45
			new Integer(0),
48
			new Integer(1),
46
			new Integer(1),
Lines 51-63 Link Here
51
			new Integer(4),
49
			new Integer(4),
52
			new Integer(5),
50
			new Integer(5),
53
			});
51
			});
54
	private Collection expectedFilteredResult = Arrays.asList(
52
	private final Collection<Integer> expectedFilteredResult = Arrays.asList(
55
		new Integer[] {
53
		new Integer[] {
56
			new Integer(0),
54
			new Integer(0),
57
			new Integer(2),
55
			new Integer(2),
58
			new Integer(4),
56
			new Integer(4),
59
			});
57
			});
60
	private FilteredCollection filteredCollection = new FilteredCollection(
58
	private final FilteredCollection<Integer> filteredCollection = new FilteredCollection<Integer>(
61
			original,
59
			original,
62
			filter);
60
			filter);
63
61
Lines 78-90 Link Here
78
	/** Tests for correct iteration. */
76
	/** Tests for correct iteration. */
79
	public void test_iterator() {
77
	public void test_iterator() {
80
		// test for contents.  Note that lists can only be compared to lists
78
		// test for contents.  Note that lists can only be compared to lists
81
		assertEquals(expectedFilteredResult, new ArrayList(filteredCollection));
79
		assertEquals(expectedFilteredResult, new ArrayList<Integer>(filteredCollection));
82
		
80
		
83
		// test for ordering
81
		// test for ordering
84
		int i = 0;
82
		int i = 0;
85
		for (Iterator iter = filteredCollection.iterator(); iter.hasNext();) {
83
		for (Integer next : filteredCollection) {
86
			Integer next = (Integer)iter.next();
87
			
88
			assertEquals(i, next.intValue());
84
			assertEquals(i, next.intValue());
89
			
85
			
90
			i = i + 2;
86
			i = i + 2;
(-)src/org/eclipse/emf/validation/internal/util/tests/DisabledConstraintTest.java (-9 / +10 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 27-32 Link Here
27
27
28
import org.eclipse.core.runtime.IStatus;
28
import org.eclipse.core.runtime.IStatus;
29
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.runtime.Status;
30
import org.eclipse.emf.common.notify.Notification;
30
import org.eclipse.emf.ecore.EObject;
31
import org.eclipse.emf.ecore.EObject;
31
import org.eclipse.emf.ecore.EStructuralFeature;
32
import org.eclipse.emf.ecore.EStructuralFeature;
32
33
Lines 84-90 Link Here
84
	
85
	
85
	public static class ValidationContext implements IValidationContext {
86
	public static class ValidationContext implements IValidationContext {
86
		private final EObject target;
87
		private final EObject target;
87
		private Set resultLocus = new java.util.HashSet();
88
		private final Set<EObject> resultLocus = new java.util.HashSet<EObject>();
88
		
89
		
89
		public ValidationContext(EObject target) {
90
		public ValidationContext(EObject target) {
90
			this.target = target;
91
			this.target = target;
Lines 107-114 Link Here
107
		}
108
		}
108
109
109
		// implements the inherited method
110
		// implements the inherited method
110
		public List getAllEvents() {
111
		public List<Notification> getAllEvents() {
111
			return Collections.EMPTY_LIST;
112
			return Collections.emptyList();
112
		}
113
		}
113
114
114
		// implements the inherited method
115
		// implements the inherited method
Lines 127-133 Link Here
127
		}
128
		}
128
129
129
		// implements the inherited method
130
		// implements the inherited method
130
		public void skipCurrentConstraintForAll(Collection eObjects) {
131
		public void skipCurrentConstraintForAll(Collection<?> eObjects) {
131
			// no need to do anything in this test fixture
132
			// no need to do anything in this test fixture
132
		}
133
		}
133
		
134
		
Lines 147-153 Link Here
147
		}
148
		}
148
149
149
		// implements the inherited method
150
		// implements the inherited method
150
		public Set getResultLocus() {
151
		public Set<EObject> getResultLocus() {
151
			return resultLocus;
152
			return resultLocus;
152
		}
153
		}
153
		
154
		
Lines 157-164 Link Here
157
		}
158
		}
158
		
159
		
159
		// implements the inherited method
160
		// implements the inherited method
160
		public void addResults(Collection eObjects) {
161
		public void addResults(Collection<? extends EObject> eObjects) {
161
			resultLocus.add(eObjects);
162
			resultLocus.addAll(eObjects);
162
		}
163
		}
163
164
164
		/* (non-Javadoc)
165
		/* (non-Javadoc)
Lines 171-177 Link Here
171
		/* (non-Javadoc)
172
		/* (non-Javadoc)
172
		 * Redefines/Implements/Extends the inherited method.
173
		 * Redefines/Implements/Extends the inherited method.
173
		 */
174
		 */
174
		public IStatus createFailureStatus(Object[] messageArguments) {
175
		public IStatus createFailureStatus(Object... messageArguments) {
175
			return new Status(
176
			return new Status(
176
				IStatus.ERROR,
177
				IStatus.ERROR,
177
				"org.eclipse.emf.validation.tests", //$NON-NLS-1$
178
				"org.eclipse.emf.validation.tests", //$NON-NLS-1$
(-)src/org/eclipse/emf/validation/internal/util/tests/ConstraintFactoryTest.java (-2 / +4 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2003, 2006 IBM Corporation and others.
4
 * Copyright (c) 2003, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 33-45 Link Here
33
 * @author Christian W. Damus (cdamus)
33
 * @author Christian W. Damus (cdamus)
34
 */
34
 */
35
public class ConstraintFactoryTest extends TestCase {
35
public class ConstraintFactoryTest extends TestCase {
36
	private ConstraintFactory factory = ConstraintFactory.getInstance();
36
	private final ConstraintFactory factory = ConstraintFactory.getInstance();
37
	
37
	
38
	public void test_getInstance() {
38
	public void test_getInstance() {
39
		assertSame(factory, ConstraintFactory.getInstance());
39
		assertSame(factory, ConstraintFactory.getInstance());
40
	}
40
	}
41
41
42
	public void test_newConstraint() {
42
	public void test_newConstraint() {
43
		@SuppressWarnings("deprecation")
43
		IModelConstraint constraint = factory.newConstraint(
44
		IModelConstraint constraint = factory.newConstraint(
44
				ConstraintDescriptorTest.getFixture());
45
				ConstraintDescriptorTest.getFixture());
45
		
46
		
Lines 66-71 Link Here
66
		try {
67
		try {
67
			XmlConstraintDescriptor desc = new XmlConstraintDescriptor(element);
68
			XmlConstraintDescriptor desc = new XmlConstraintDescriptor(element);
68
			
69
			
70
			@SuppressWarnings("deprecation")
69
			IModelConstraint constraint = factory.newConstraint(desc);
71
			IModelConstraint constraint = factory.newConstraint(desc);
70
			
72
			
71
			assertFalse(desc.isEnabled());
73
			assertFalse(desc.isEnabled());
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:48:36 EST 2006
1
#Wed Oct 31 00:04:04 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:49:05 EST 2006
1
#Wed Oct 31 00:02:33 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/validation/ui/internal/preferences/ValidationLiveProblemsDestination.java (-13 / +15 lines)
Lines 15-20 Link Here
15
import java.util.Arrays;
15
import java.util.Arrays;
16
import java.util.List;
16
import java.util.List;
17
17
18
import org.eclipse.emf.common.util.Enumerator;
18
import org.eclipse.emf.validation.ui.internal.ValidationUIPlugin;
19
import org.eclipse.emf.validation.ui.internal.ValidationUIPlugin;
19
20
20
21
Lines 23-39 Link Here
23
 *
24
 *
24
 * @author Christian W. Damus (cdamus)
25
 * @author Christian W. Damus (cdamus)
25
 */
26
 */
26
public class ValidationLiveProblemsDestination {
27
public enum ValidationLiveProblemsDestination implements Enumerator {
27
    /**
28
    DIALOG("Dialog"), //$NON-NLS-1$
28
     * An internal unique identifier for this enumerated type.
29
    CONSOLE("Console"); //$NON-NLS-1$
29
     */
30
    private static int nextOrdinal = 0;
31
    
32
    private String name;
33
    private int ordinal;
34
30
35
    public static final ValidationLiveProblemsDestination DIALOG = new ValidationLiveProblemsDestination("Dialog"); //$NON-NLS-1$
31
    private String name;
36
    public static final ValidationLiveProblemsDestination CONSOLE = new ValidationLiveProblemsDestination("Console"); //$NON-NLS-1$
37
32
38
    /**
33
    /**
39
     * The list of values for this enumerated type.
34
     * The list of values for this enumerated type.
Lines 65-71 Link Here
65
     */
60
     */
66
    private ValidationLiveProblemsDestination(String name) {
61
    private ValidationLiveProblemsDestination(String name) {
67
        this.name = name;
62
        this.name = name;
68
        this.ordinal = nextOrdinal++;
69
    }
63
    }
70
64
71
    /**
65
    /**
Lines 73-87 Link Here
73
     * 
67
     * 
74
     * @return The list of constants for this enumerated type.
68
     * @return The list of constants for this enumerated type.
75
     */
69
     */
76
    protected List getValues() {
70
    protected List<ValidationLiveProblemsDestination> getValues() {
77
        return Arrays.asList(VALUES);
71
        return Arrays.asList(VALUES);
78
    }
72
    }
79
    
73
    
80
    public int getOrdinal() {
74
    public int getOrdinal() {
81
    	return ordinal;
75
    	return getValue();
82
    }
76
    }
83
    
77
    
84
    public String getName() {
78
    public String getName() {
85
    	return name;
79
    	return name;
86
    }
80
    }
81
    
82
    public int getValue() {
83
    	return ordinal();
84
    }
85
    
86
    public String getLiteral() {
87
    	return getName();
88
    }
87
}
89
}
(-)src/org/eclipse/emf/validation/ui/internal/preferences/CategoryTreeNode.java (-67 / +63 lines)
Lines 20-26 Link Here
20
import java.util.Collections;
20
import java.util.Collections;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.List;
22
import java.util.List;
23
import java.util.ListIterator;
24
23
25
import org.eclipse.emf.ecore.EObject;
24
import org.eclipse.emf.ecore.EObject;
26
import org.eclipse.emf.validation.model.Category;
25
import org.eclipse.emf.validation.model.Category;
Lines 49-55 Link Here
49
	 */
48
	 */
50
	private ICategoryTreeNode delegate;
49
	private ICategoryTreeNode delegate;
51
	
50
	
52
	private List constraints;
51
	private List<IConstraintNode> constraints;
53
	
52
	
54
	/**
53
	/**
55
	 * Implementation of the root node of the category selection tree.
54
	 * Implementation of the root node of the category selection tree.
Lines 68-89 Link Here
68
		}
67
		}
69
		
68
		
70
		// implements the inherited method to wrap the top-level categories
69
		// implements the inherited method to wrap the top-level categories
71
		protected List createChildren() {
70
		@Override
72
			List result = new java.util.ArrayList(
71
        protected List<ICategoryTreeNode> createChildren() {
73
					CategoryManager.getInstance().getTopLevelCategories());
72
		    Collection<Category> topLevel = CategoryManager.getInstance().getTopLevelCategories();
74
			
73
			List<ICategoryTreeNode> result = new java.util.ArrayList<ICategoryTreeNode>(
75
			for (ListIterator iter = result.listIterator(); iter.hasNext();) {
74
					topLevel.size());
76
				Category next = (Category) iter.next();
75
			
77
				
76
			for (Category next : topLevel) {
78
				if (isRecursivelyEmpty(next)) {
77
				if (!isRecursivelyEmpty(next)) {
79
					iter.remove();
78
					result.add(new CategoryTreeNode(getTree(), next, this, getFilter()));
80
				} else {
81
					iter.set(
82
							new CategoryTreeNode(
83
									getTree(),
84
									next,
85
									this,
86
									getFilter()));
87
				}
79
				}
88
			}
80
			}
89
			
81
			
Lines 116-128 Link Here
116
		}
108
		}
117
		
109
		
118
		// redefines the inherited method
110
		// redefines the inherited method
119
		public String getDescription() {
111
		@Override
112
        public String getDescription() {
120
			return ""; //$NON-NLS-1$
113
			return ""; //$NON-NLS-1$
121
		}
114
		}
122
		
115
		
123
		// redefines the inherited method
116
		// redefines the inherited method
124
		public List getConstraints() {
117
		public List<IConstraintNode> getConstraints() {
125
			return Collections.EMPTY_LIST;
118
			return Collections.emptyList();
126
		}
119
		}
127
	}
120
	}
128
	
121
	
Lines 153-165 Link Here
153
		}
146
		}
154
		
147
		
155
		// redefines the inherited method
148
		// redefines the inherited method
156
		protected List createChildren() {
149
		@Override
150
        protected List<ICategoryTreeNode> createChildren() {
157
			// delegates are leaf nodes, by definition
151
			// delegates are leaf nodes, by definition
158
			return Collections.EMPTY_LIST;
152
			return Collections.emptyList();
159
		}
153
		}
160
		
154
		
161
		// extends the inherited method
155
		// extends the inherited method
162
		public String toString() {
156
		@Override
157
        public String toString() {
163
			String result = super.toString();
158
			String result = super.toString();
164
			
159
			
165
			StringBuffer buf = new StringBuffer(result.length() + 2);
160
			StringBuffer buf = new StringBuffer(result.length() + 2);
Lines 232-257 Link Here
232
	}
227
	}
233
	
228
	
234
	// implements the inherited method
229
	// implements the inherited method
235
	protected List createChildren() {
230
	@Override
231
    protected List<ICategoryTreeNode> createChildren() {
236
		final Category category = getCategory();
232
		final Category category = getCategory();
237
		Collection categoryChildren = category.getChildren();
233
		Collection<Category> categoryChildren = category.getChildren();
238
		
234
		
239
		List result;
235
		List<ICategoryTreeNode> result;
240
		
236
		
241
		if (!categoryChildren.isEmpty() && !getConstraints(category, getFilter()).isEmpty()) {
237
		if (!categoryChildren.isEmpty() && !getConstraints(category, getFilter()).isEmpty()) {
242
			// add one for the delegate child that contains my own constraints
238
			// add one for the delegate child that contains my own constraints
243
			result = new java.util.ArrayList(categoryChildren.size() + 1);
239
			result = new java.util.ArrayList<ICategoryTreeNode>(categoryChildren.size() + 1);
244
			
240
			
245
			// add my delegate
241
			// add my delegate
246
			delegate = new DelegateNode(getTree(), category, this, getFilter());
242
			delegate = new DelegateNode(getTree(), category, this, getFilter());
247
			result.add(delegate);
243
			result.add(delegate);
248
		} else {
244
		} else {
249
			result = new java.util.ArrayList(categoryChildren.size());
245
			result = new java.util.ArrayList<ICategoryTreeNode>(categoryChildren.size());
250
		}
246
		}
251
		
247
		
252
		for (Iterator iter = categoryChildren.iterator(); iter.hasNext();) {
248
		for (Category next : categoryChildren) {
253
			Category next = (Category) iter.next();
254
			
255
			if (!isRecursivelyEmpty(next)) {
249
			if (!isRecursivelyEmpty(next)) {
256
				result.add(new CategoryTreeNode(
250
				result.add(new CategoryTreeNode(
257
						getTree(),
251
						getTree(),
Lines 311-319 Link Here
311
	 */
305
	 */
312
	private void propagateToConstraints(boolean newChecked) {
306
	private void propagateToConstraints(boolean newChecked) {
313
		if (!hasDelegate()) {
307
		if (!hasDelegate()) {
314
			for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
308
			for (IConstraintNode next : getConstraints()) {
315
				IConstraintNode next = (IConstraintNode) iter.next();
316
				
317
				// my constraints update my check state as necessary
309
				// my constraints update my check state as necessary
318
				next.setChecked(newChecked);
310
				next.setChecked(newChecked);
319
			}
311
			}
Lines 388-396 Link Here
388
		boolean newChecked = newValue;
380
		boolean newChecked = newValue;
389
		boolean newGrayed = false;
381
		boolean newGrayed = false;
390
		
382
		
391
		for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
383
		for (IConstraintNode next : getConstraints()) {
392
			IConstraintNode next = (IConstraintNode) iter.next();
393
			
394
			if (next != constraint) {
384
			if (next != constraint) {
395
				if (next.isChecked() != newValue) {
385
				if (next.isChecked() != newValue) {
396
					newGrayed = true;
386
					newGrayed = true;
Lines 424-434 Link Here
424
	}
414
	}
425
	
415
	
426
	// extends the inherited method
416
	// extends the inherited method
427
	public void applyToPreferences() {
417
	@Override
418
    public void applyToPreferences() {
428
		if (!hasDelegate()) {
419
		if (!hasDelegate()) {
429
			for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
420
			for (IConstraintNode next : getConstraints()) {
430
				IConstraintNode next = (IConstraintNode) iter.next();
431
				
432
				next.applyToPreferences();
421
				next.applyToPreferences();
433
			}
422
			}
434
		}
423
		}
Lines 437-448 Link Here
437
	}
426
	}
438
	
427
	
439
	// extends the inherited method
428
	// extends the inherited method
440
	public void revertFromPreferences() {
429
	@Override
430
    public void revertFromPreferences() {
441
		if (!hasDelegate()) {
431
		if (!hasDelegate()) {
442
			IConstraintNode node = null;
432
			IConstraintNode node = null;
443
			
433
			
444
			for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
434
			for (Iterator<IConstraintNode> iter = getConstraints().iterator();
445
				node = (IConstraintNode) iter.next();
435
			        iter.hasNext();) {
436
			    
437
				node = iter.next();
446
				
438
				
447
				node.revertFromPreferences();
439
				node.revertFromPreferences();
448
			}
440
			}
Lines 457-468 Link Here
457
	}
449
	}
458
	
450
	
459
	// extends the inherited method
451
	// extends the inherited method
460
	public void restoreDefaults() {
452
	@Override
453
    public void restoreDefaults() {
461
		if (!hasDelegate()) {
454
		if (!hasDelegate()) {
462
			IConstraintNode node = null;
455
			IConstraintNode node = null;
463
			
456
			
464
			for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
457
			for (Iterator<IConstraintNode> iter = getConstraints().iterator();
465
				node = (IConstraintNode) iter.next();
458
			        iter.hasNext();) {
459
			    
460
				node = iter.next();
466
				
461
				
467
				node.restoreDefaults();
462
				node.restoreDefaults();
468
			}
463
			}
Lines 483-489 Link Here
483
	 * @return <code>null</code> if I have a delegate node; the superclass
478
	 * @return <code>null</code> if I have a delegate node; the superclass
484
	 *     result, otherwise
479
	 *     result, otherwise
485
	 */
480
	 */
486
	public Category getCategory() {
481
	@Override
482
    public Category getCategory() {
487
		if (hasDelegate()) {
483
		if (hasDelegate()) {
488
			return null;
484
			return null;
489
		} else {
485
		} else {
Lines 492-512 Link Here
492
	}
488
	}
493
	
489
	
494
	// implements the inherited method
490
	// implements the inherited method
495
	public List getConstraints() {
491
	public List<IConstraintNode> getConstraints() {
496
		if (hasDelegate()) {
492
		if (hasDelegate()) {
497
			constraints = Collections.EMPTY_LIST;
493
			constraints = Collections.emptyList();
498
		} else if (constraints == null) {
494
		} else if (constraints == null) {
499
			constraints = new java.util.ArrayList(
495
		    Collection<IConstraintDescriptor> descriptors = getConstraints(
500
                getConstraints(getCategory(), getFilter()));
496
		        getCategory(), getFilter());
501
			
497
			constraints = new java.util.ArrayList<IConstraintNode>(
502
			for (ListIterator iter = constraints.listIterator();
498
		            descriptors.size());
503
					iter.hasNext();) {
499
		    
504
				
500
			for (IConstraintDescriptor next : descriptors) {
505
				IConstraintNode node = ConstraintNode.getInstance(
501
				IConstraintNode node = ConstraintNode.getInstance(next);
506
					(IConstraintDescriptor)iter.next());
507
				
502
				
508
				node.addCategory(this);
503
				node.addCategory(this);
509
				iter.set(node);
504
				constraints.add(node);
510
			}
505
			}
511
		}
506
		}
512
		
507
		
Lines 514-531 Link Here
514
	}
509
	}
515
	
510
	
516
	// implements the inherited method
511
	// implements the inherited method
517
	public IConstraintNode[] getSelectedConstraints() {
512
	@Override
518
		List result = new java.util.ArrayList(getConstraints().size());
513
    public IConstraintNode[] getSelectedConstraints() {
514
		List<IConstraintNode> result = new java.util.ArrayList<IConstraintNode>(
515
		        getConstraints().size());
519
		
516
		
520
		for (Iterator iter = getConstraints().iterator(); iter.hasNext();) {
517
		for (IConstraintNode next : getConstraints()) {
521
			IConstraintNode next = (IConstraintNode) iter.next();
522
			
523
			if (next.isChecked()) {
518
			if (next.isChecked()) {
524
				result.add(next);
519
				result.add(next);
525
			}
520
			}
526
		}
521
		}
527
		
522
		
528
		return (IConstraintNode[]) result.toArray(
523
		return result.toArray(
529
			new IConstraintNode[result.size()]);
524
			new IConstraintNode[result.size()]);
530
	}
525
	}
531
	
526
	
Lines 544-550 Link Here
544
	 * category (because my delegate has it), I return my delegate's category's
539
	 * category (because my delegate has it), I return my delegate's category's
545
	 * name.
540
	 * name.
546
	 */
541
	 */
547
	public String toString() {
542
	@Override
543
    public String toString() {
548
		if ((getCategory() == null) && hasDelegate()) {
544
		if ((getCategory() == null) && hasDelegate()) {
549
			return delegate.getCategory().getName();
545
			return delegate.getCategory().getName();
550
		} else {
546
		} else {
(-)src/org/eclipse/emf/validation/ui/internal/preferences/ConstraintNode.java (-9 / +9 lines)
Lines 34-46 Link Here
34
public class ConstraintNode
34
public class ConstraintNode
35
	implements IConstraintNode {
35
	implements IConstraintNode {
36
36
37
	private static final java.util.Map instanceMap = new java.util.HashMap();
37
	private static final java.util.Map<String, IConstraintNode> instanceMap =
38
		new java.util.HashMap<String, IConstraintNode>();
38
	
39
	
39
	private final IConstraintDescriptor constraint;
40
	private final IConstraintDescriptor constraint;
40
	private Boolean mandatory;
41
	private Boolean mandatory;
41
	private boolean checked = false;
42
	private boolean checked = false;
42
	
43
	
43
	private final java.util.Set categories = new java.util.HashSet();
44
	private final java.util.Set<ICategoryTreeNode> categories =
45
		new java.util.HashSet<ICategoryTreeNode>();
44
	
46
	
45
	/**
47
	/**
46
	 * Initializes me with the constraint that I represent.
48
	 * Initializes me with the constraint that I represent.
Lines 64-70 Link Here
64
		IConstraintNode result = null;
66
		IConstraintNode result = null;
65
		
67
		
66
		if (id != null) {
68
		if (id != null) {
67
			result = (IConstraintNode) instanceMap.get(id);
69
			result = instanceMap.get(id);
68
			
70
			
69
			if (result == null) {
71
			if (result == null) {
70
				result = new ConstraintNode(constraint);
72
				result = new ConstraintNode(constraint);
Lines 107-113 Link Here
107
	/* (non-Javadoc)
109
	/* (non-Javadoc)
108
	 * Implements the inherited method.
110
	 * Implements the inherited method.
109
	 */
111
	 */
110
	public Collection getCategories() {
112
	public Collection<Category> getCategories() {
111
		return constraint.getCategories();
113
		return constraint.getCategories();
112
	}
114
	}
113
115
Lines 158-167 Link Here
158
		if (mandatory == null) {
160
		if (mandatory == null) {
159
			boolean m = false;
161
			boolean m = false;
160
			
162
			
161
			for (Iterator iter = constraint.getCategories().iterator();
163
			for (Iterator<Category> iter = constraint.getCategories().iterator();
162
					!m && iter.hasNext();) {
164
					!m && iter.hasNext();) {
163
				
165
				
164
				if (((Category) iter.next()).isMandatory()) {
166
				if (iter.next().isMandatory()) {
165
					m = true;
167
					m = true;
166
				}
168
				}
167
			}
169
			}
Lines 239-247 Link Here
239
	 * This allows them to update theirs, to match.
241
	 * This allows them to update theirs, to match.
240
	 */
242
	 */
241
	private void updateCategories() {
243
	private void updateCategories() {
242
		for (Iterator iter = categories.iterator(); iter.hasNext();) {
244
		for (ICategoryTreeNode next : categories) {
243
			ICategoryTreeNode next = (ICategoryTreeNode) iter.next();
244
			
245
			next.updateCheckState(this);
245
			next.updateCheckState(this);
246
		}
246
		}
247
	}
247
	}
(-)src/org/eclipse/emf/validation/ui/internal/preferences/AbstractCategoryTreeNode.java (-18 / +16 lines)
Lines 16-22 Link Here
16
 */
16
 */
17
package org.eclipse.emf.validation.ui.internal.preferences;
17
package org.eclipse.emf.validation.ui.internal.preferences;
18
18
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
import java.util.Set;
20
import java.util.Set;
22
21
Lines 67-73 Link Here
67
	 * 
66
	 * 
68
	 * @return my children
67
	 * @return my children
69
	 */
68
	 */
70
	protected abstract List createChildren();
69
	protected abstract List<ICategoryTreeNode> createChildren();
71
	
70
	
72
	/**
71
	/**
73
	 * Lazily initializes my children on first access.
72
	 * Lazily initializes my children on first access.
Lines 76-84 Link Here
76
	 */
75
	 */
77
	private void initChildren() {
76
	private void initChildren() {
78
		if (children == null) {
77
		if (children == null) {
79
			List childList = createChildren();
78
			List<ICategoryTreeNode> childList = createChildren();
80
			children = (ICategoryTreeNode[])childList.toArray(
79
			children = childList.toArray(new ICategoryTreeNode[childList.size()]);
81
					new ICategoryTreeNode[childList.size()]);
82
		}
80
		}
83
	}
81
	}
84
	
82
	
Lines 96-103 Link Here
96
		if (result) {
94
		if (result) {
97
			// check children, too
95
			// check children, too
98
			
96
			
99
			for (Iterator iter = cat.getChildren().iterator(); result && iter.hasNext();) {
97
			for (Category child : cat.getChildren()) {
100
				result = isRecursivelyEmpty((Category) iter.next());
98
				result = isRecursivelyEmpty(child);
101
			}
99
			}
102
		}
100
		}
103
		
101
		
Lines 115-126 Link Here
115
     * 
113
     * 
116
     * @since 1.1
114
     * @since 1.1
117
     */
115
     */
118
    protected static Set getConstraints(Category category, IConstraintFilter filter) {
116
    protected static Set<IConstraintDescriptor> getConstraints(Category category, IConstraintFilter filter) {
119
        Set filteredConstraints = new java.util.HashSet();
117
        Set<IConstraintDescriptor> filteredConstraints =
118
        	new java.util.HashSet<IConstraintDescriptor>();
120
        
119
        
121
        for (Iterator iter = category.getConstraints().iterator(); iter.hasNext();) {
120
        for (IConstraintDescriptor descriptor : category.getConstraints()) {
122
            IConstraintDescriptor descriptor = (IConstraintDescriptor)iter.next();
123
            
124
            if (filter.accept(descriptor, null)) {
121
            if (filter.accept(descriptor, null)) {
125
                filteredConstraints.add(descriptor);
122
                filteredConstraints.add(descriptor);
126
            }
123
            }
Lines 169-176 Link Here
169
	public void applyToPreferences() {
166
	public void applyToPreferences() {
170
		ICategoryTreeNode[] currentChildren = getChildren();
167
		ICategoryTreeNode[] currentChildren = getChildren();
171
		
168
		
172
		for (int i = 0; i < currentChildren.length; i++) {
169
		for (ICategoryTreeNode element : currentChildren) {
173
			currentChildren[i].applyToPreferences();
170
			element.applyToPreferences();
174
		}
171
		}
175
	}
172
	}
176
	
173
	
Lines 178-185 Link Here
178
	public void revertFromPreferences() {
175
	public void revertFromPreferences() {
179
		ICategoryTreeNode[] currentChildren = getChildren();
176
		ICategoryTreeNode[] currentChildren = getChildren();
180
		
177
		
181
		for (int i = 0; i < currentChildren.length; i++) {
178
		for (ICategoryTreeNode element : currentChildren) {
182
			currentChildren[i].revertFromPreferences();
179
			element.revertFromPreferences();
183
		}
180
		}
184
	}
181
	}
185
182
Lines 187-194 Link Here
187
	public void restoreDefaults() {
184
	public void restoreDefaults() {
188
		ICategoryTreeNode[] currentChildren = getChildren();
185
		ICategoryTreeNode[] currentChildren = getChildren();
189
		
186
		
190
		for (int i = 0; i < currentChildren.length; i++) {
187
		for (ICategoryTreeNode element : currentChildren) {
191
			currentChildren[i].restoreDefaults();
188
			element.restoreDefaults();
192
		}
189
		}
193
	}
190
	}
194
	
191
	
Lines 200-205 Link Here
200
	}
197
	}
201
	
198
	
202
	// redefines the inherited method
199
	// redefines the inherited method
200
	@Override
203
	public String toString() {
201
	public String toString() {
204
		return (getCategory() == null)
202
		return (getCategory() == null)
205
			? "" //$NON-NLS-1$
203
			? "" //$NON-NLS-1$
(-)src/org/eclipse/emf/validation/ui/internal/preferences/ConstraintDetailsHelper.java (-8 / +5 lines)
Lines 18-24 Link Here
18
18
19
import java.text.MessageFormat;
19
import java.text.MessageFormat;
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Iterator;
22
import java.util.List;
21
import java.util.List;
23
22
24
import org.eclipse.emf.validation.model.Category;
23
import org.eclipse.emf.validation.model.Category;
Lines 70-76 Link Here
70
	public static String formatConstraintDescription(
69
	public static String formatConstraintDescription(
71
			IConstraintNode constraint,
70
			IConstraintNode constraint,
72
			Category selectedCategory,
71
			Category selectedCategory,
73
			List styles) {
72
			List<? super StyleRange> styles) {
74
		
73
		
75
		String description = constraint.getDescription();
74
		String description = constraint.getDescription();
76
		
75
		
Lines 93-99 Link Here
93
						   description,
92
						   description,
94
						   constraint.getSeverity()});
93
						   constraint.getSeverity()});
95
		
94
		
96
		Collection categories = constraint.getCategories();
95
		Collection<Category> categories = constraint.getCategories();
97
		if (categories.size() > 1) {
96
		if (categories.size() > 1) {
98
			// also display the other categories that contain this constraint
97
			// also display the other categories that contain this constraint
99
			text = text + getOtherCategories(selectedCategory, categories);
98
			text = text + getOtherCategories(selectedCategory, categories);
Lines 117-130 Link Here
117
	 */
116
	 */
118
	private static String getOtherCategories(
117
	private static String getOtherCategories(
119
			Category selected,
118
			Category selected,
120
			Collection categories) {
119
			Collection<? extends Category> categories) {
121
		
120
		
122
		StringBuffer result = new StringBuffer(64);
121
		StringBuffer result = new StringBuffer(64);
123
		result.append(ALSO_IN_CATEGORIES);
122
		result.append(ALSO_IN_CATEGORIES);
124
		
123
		
125
		for (Iterator iter = categories.iterator(); iter.hasNext();) {
124
		for (Category next : categories) {
126
			Category next = (Category)iter.next();
127
			
128
			if (next != selected) {
125
			if (next != selected) {
129
				result.append(PLATFORM_NEWLINE);
126
				result.append(PLATFORM_NEWLINE);
130
				result.append(next.getQualifiedName());
127
				result.append(next.getQualifiedName());
Lines 144-150 Link Here
144
	 * @param styles a list which collects the corresponding style ranges
141
	 * @param styles a list which collects the corresponding style ranges
145
	 * @return the original <code>text</code> minus the markup
142
	 * @return the original <code>text</code> minus the markup
146
	 */
143
	 */
147
	private static String parseStyles(String text, List styles) {
144
	private static String parseStyles(String text, List<? super StyleRange> styles) {
148
		int pos = -1;
145
		int pos = -1;
149
		int lastPos = 0;
146
		int lastPos = 0;
150
		
147
		
(-)src/org/eclipse/emf/validation/ui/internal/preferences/IConstraintNode.java (-1 / +2 lines)
Lines 19-24 Link Here
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
21
22
import org.eclipse.emf.validation.model.Category;
22
import org.eclipse.jface.viewers.CheckStateChangedEvent;
23
import org.eclipse.jface.viewers.CheckStateChangedEvent;
23
24
24
25
Lines 60-66 Link Here
60
	 * 
61
	 * 
61
	 * @return the categories of the constraint that I represent
62
	 * @return the categories of the constraint that I represent
62
	 */
63
	 */
63
	Collection getCategories();
64
	Collection<Category> getCategories();
64
	
65
	
65
	/**
66
	/**
66
	 * Obtains the evaluation mode of the constraint, to show in the GUI.
67
	 * Obtains the evaluation mode of the constraint, to show in the GUI.
(-)src/org/eclipse/emf/validation/ui/internal/preferences/ICategoryTreeNode.java (-1 / +1 lines)
Lines 101-107 Link Here
101
	 * 
101
	 * 
102
	 * @return my constraints, or an empty list if I am not a leaf node
102
	 * @return my constraints, or an empty list if I am not a leaf node
103
	 */
103
	 */
104
	List getConstraints();
104
	List<IConstraintNode> getConstraints();
105
	
105
	
106
	/**
106
	/**
107
	 * Obtains the category that I represent if I am a leaf node.
107
	 * Obtains the category that I represent if I am a leaf node.
(-)src/org/eclipse/emf/validation/ui/internal/ValidationUIPlugin.java (-11 / +13 lines)
Lines 136-142 Link Here
136
        super(new ResourceLocator[] {});
136
        super(new ResourceLocator[] {});
137
    }
137
    }
138
138
139
    public ResourceLocator getPluginResourceLocator() {
139
    @Override
140
	public ResourceLocator getPluginResourceLocator() {
140
        return plugin;
141
        return plugin;
141
    }
142
    }
142
143
Lines 178-184 Link Here
178
    	/**
179
    	/**
179
    	 * The cached debug options (for optimization).
180
    	 * The cached debug options (for optimization).
180
    	 */
181
    	 */
181
    	private static final Map cachedOptions = new HashMap();
182
    	private static final Map<String, Boolean> cachedOptions =
183
    		new HashMap<String, Boolean>();
182
184
183
    	/**
185
    	/**
184
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
186
    	 * Retrieves a Boolean value indicating whether tracing is enabled.
Lines 203-209 Link Here
203
    			Boolean value = null;
205
    			Boolean value = null;
204
    			
206
    			
205
    			synchronized (cachedOptions) {
207
    			synchronized (cachedOptions) {
206
    				value = (Boolean) cachedOptions.get(option);
208
    				value = cachedOptions.get(option);
207
    	
209
    	
208
    				if (null == value) {
210
    				if (null == value) {
209
    					value =
211
    					value =
Lines 320-326 Link Here
320
    	 */
322
    	 */
321
    	public static void changing(
323
    	public static void changing(
322
            String option,
324
            String option,
323
            Class clazz,
325
            Class<?> clazz,
324
            String methodName,
326
            String methodName,
325
            String valueDescription,
327
            String valueDescription,
326
            Object oldValue,
328
            Object oldValue,
Lines 359-365 Link Here
359
    	 */
361
    	 */
360
    	public static void catching(
362
    	public static void catching(
361
    		String option,
363
    		String option,
362
    		Class clazz,
364
    		Class<?> clazz,
363
    		String methodName,
365
    		String methodName,
364
    		Throwable throwable) {
366
    		Throwable throwable) {
365
367
Lines 392-398 Link Here
392
    	 */
394
    	 */
393
    	public static void throwing(
395
    	public static void throwing(
394
    		String option,
396
    		String option,
395
    		Class clazz,
397
    		Class<?> clazz,
396
    		String methodName,
398
    		String methodName,
397
    		Throwable throwable) {
399
    		Throwable throwable) {
398
400
Lines 422-428 Link Here
422
    	 */
424
    	 */
423
    	public static void entering(
425
    	public static void entering(
424
    		String option,
426
    		String option,
425
    		Class clazz,
427
    		Class<?> clazz,
426
    		String methodName) {
428
    		String methodName) {
427
429
428
    		if (shouldTrace(option)) {
430
    		if (shouldTrace(option)) {
Lines 447-453 Link Here
447
    	 */
449
    	 */
448
    	public static void entering(
450
    	public static void entering(
449
    		String option,
451
    		String option,
450
    		Class clazz,
452
    		Class<?> clazz,
451
    		String methodName,
453
    		String methodName,
452
    		Object parameter) {
454
    		Object parameter) {
453
455
Lines 476-482 Link Here
476
    	 */
478
    	 */
477
    	public static void entering(
479
    	public static void entering(
478
    		String option,
480
    		String option,
479
    		Class clazz,
481
    		Class<?> clazz,
480
    		String methodName,
482
    		String methodName,
481
    		Object[] parameters) {
483
    		Object[] parameters) {
482
484
Lines 503-509 Link Here
503
    	 */
505
    	 */
504
    	public static void exiting(
506
    	public static void exiting(
505
    		String option,
507
    		String option,
506
    		Class clazz,
508
    		Class<?> clazz,
507
    		String methodName) {
509
    		String methodName) {
508
510
509
    		if (shouldTrace(option)) {
511
    		if (shouldTrace(option)) {
Lines 528-534 Link Here
528
    	 */
530
    	 */
529
    	public static void exiting(
531
    	public static void exiting(
530
    		String option,
532
    		String option,
531
    		Class clazz,
533
    		Class<?> clazz,
532
    		String methodName,
534
    		String methodName,
533
    		Object returnValue) {
535
    		Object returnValue) {
534
536
(-)src/org/eclipse/emf/validation/ui/internal/LiveValidationListener.java (-23 / +27 lines)
Lines 16-22 Link Here
16
import java.text.MessageFormat;
16
import java.text.MessageFormat;
17
import java.util.Collection;
17
import java.util.Collection;
18
import java.util.HashSet;
18
import java.util.HashSet;
19
import java.util.Iterator;
20
import java.util.List;
19
import java.util.List;
21
import java.util.Set;
20
import java.util.Set;
22
21
Lines 28-33 Link Here
28
import org.eclipse.core.runtime.Platform;
27
import org.eclipse.core.runtime.Platform;
29
import org.eclipse.core.runtime.Status;
28
import org.eclipse.core.runtime.Status;
30
import org.eclipse.emf.validation.model.EvaluationMode;
29
import org.eclipse.emf.validation.model.EvaluationMode;
30
import org.eclipse.emf.validation.model.IConstraintStatus;
31
import org.eclipse.emf.validation.service.IValidationListener;
31
import org.eclipse.emf.validation.service.IValidationListener;
32
import org.eclipse.emf.validation.service.ValidationEvent;
32
import org.eclipse.emf.validation.service.ValidationEvent;
33
import org.eclipse.emf.validation.ui.internal.console.ConsoleUtil;
33
import org.eclipse.emf.validation.ui.internal.console.ConsoleUtil;
Lines 63-69 Link Here
63
	private static final String EP_UI_REGISTERED_CLIENT_CONTEXTS = "org.eclipse.emf.validation.ui.UIRegisteredClientContext"; //$NON-NLS-1$
63
	private static final String EP_UI_REGISTERED_CLIENT_CONTEXTS = "org.eclipse.emf.validation.ui.UIRegisteredClientContext"; //$NON-NLS-1$
64
	private static final String A_ID = "id"; //$NON-NLS-1$
64
	private static final String A_ID = "id"; //$NON-NLS-1$
65
	
65
	
66
	private static SoftReference registeredClientContextIds = null;
66
	private static SoftReference<Set<String>> registeredClientContextIds = null;
67
	
67
	
68
    /**
68
    /**
69
     * Helper object for creating message to output view.
69
     * Helper object for creating message to output view.
Lines 98-123 Link Here
98
	 *  
98
	 *  
99
	 * @return true if there is a supported client context in the collection, false otherwise
99
	 * @return true if there is a supported client context in the collection, false otherwise
100
	 */
100
	 */
101
    private synchronized static boolean isSupportedClientContexts(Collection clientContextIds) {
101
    private synchronized static boolean isSupportedClientContexts(
102
		Set registeredIds = registeredClientContextIds != null ? (Set)registeredClientContextIds.get() : null;
102
    		Collection<String> clientContextIds) {
103
		Set<String> registeredIds = registeredClientContextIds != null
104
			? registeredClientContextIds.get() : null;
105
			
103
    	if (registeredIds == null) {
106
    	if (registeredIds == null) {
104
    		registeredIds = new HashSet();
107
    		registeredIds = new HashSet<String>();
105
			registeredClientContextIds = new SoftReference(registeredIds);
108
			registeredClientContextIds = new SoftReference<Set<String>>(registeredIds);
106
			
109
			
107
			IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EP_UI_REGISTERED_CLIENT_CONTEXTS);
110
			IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EP_UI_REGISTERED_CLIENT_CONTEXTS);
108
			IExtension[] extensions = point.getExtensions();
111
			IExtension[] extensions = point.getExtensions();
109
			
112
			
110
			for (int i=0; i<extensions.length; i++) {
113
			for (IExtension element : extensions) {
111
				IConfigurationElement[] elements = extensions[i].getConfigurationElements();
114
				IConfigurationElement[] elements = element.getConfigurationElements();
112
				
115
				
113
				for (int j=0; j<elements.length; j++) {
116
				for (IConfigurationElement element2 : elements) {
114
					registeredIds.add(elements[j].getAttribute(A_ID));
117
					registeredIds.add(element2.getAttribute(A_ID));
115
				}
118
				}
116
			}
119
			}
117
		}
120
		}
118
    	
121
    	
119
    	for (Iterator i = clientContextIds.iterator(); i.hasNext();) {
122
    	for (String next : clientContextIds) {
120
    		if (registeredIds.contains(i.next())) {
123
    		if (registeredIds.contains(next)) {
121
    			return true;
124
    			return true;
122
    		}
125
    		}
123
    	}
126
    	}
Lines 133-140 Link Here
133
     */
136
     */
134
    private void showProblemMessages(ValidationEvent event) {
137
    private void showProblemMessages(ValidationEvent event) {
135
    	// The workbench must be running in order for us to display anything to the user
138
    	// The workbench must be running in order for us to display anything to the user
136
    	if (!PlatformUI.isWorkbenchRunning())
139
    	if (!PlatformUI.isWorkbenchRunning()) {
137
    		return;
140
			return;
141
		}
138
    	
142
    	
139
        final ValidationLiveProblemsDestination destination =
143
        final ValidationLiveProblemsDestination destination =
140
        	ValidationLiveProblemsDestination.getPreferenceSetting();
144
        	ValidationLiveProblemsDestination.getPreferenceSetting();
Lines 216-221 Link Here
216
					 * Redefines the inherited method to always return
220
					 * Redefines the inherited method to always return
217
					 * the more appropriate severity for the dialog.
221
					 * the more appropriate severity for the dialog.
218
					 */
222
					 */
223
					@Override
219
					public int getSeverity() {
224
					public int getSeverity() {
220
						return dialogSeverity;
225
						return dialogSeverity;
221
					}};
226
					}};
Lines 262-270 Link Here
262
     *     first in the array if none is found
267
     *     first in the array if none is found
263
     */
268
     */
264
    static IStatus getFirstStatus(IStatus[] statuses, int severity) {
269
    static IStatus getFirstStatus(IStatus[] statuses, int severity) {
265
    	for (int i = 0; i < statuses.length; i++) {
270
    	for (IStatus element : statuses) {
266
			if (statuses[i].matches(severity)) {
271
			if (element.matches(severity)) {
267
				return statuses[i];
272
				return element;
268
			}
273
			}
269
		}
274
		}
270
    	
275
    	
Lines 278-287 Link Here
278
     * @return its validation results, as a status array
283
     * @return its validation results, as a status array
279
     */
284
     */
280
    private static IStatus[] toStatusArray(ValidationEvent event) {
285
    private static IStatus[] toStatusArray(ValidationEvent event) {
281
    	List results = event.getValidationResults();
286
    	List<IConstraintStatus> results = event.getValidationResults();
282
    	
287
    	
283
    	return (IStatus[]) results.toArray(
288
    	return results.toArray(new IStatus[results.size()]);
284
    		new IStatus[results.size()]);
285
    }
289
    }
286
290
287
    /**
291
    /**
Lines 354-362 Link Here
354
        private void appendProblemsRecursive(
358
        private void appendProblemsRecursive(
355
            IStatus[] statuses,
359
            IStatus[] statuses,
356
            StringBuffer output) {
360
            StringBuffer output) {
357
            for (int i = 0; i < statuses.length; i++) {
361
            for (IStatus next : statuses) {
358
                IStatus next = statuses[i];
359
360
                if (!next.isOK()) {
362
                if (!next.isOK()) {
361
                    final String messagePattern;
363
                    final String messagePattern;
362
364
Lines 424-429 Link Here
424
		 * @param composite The composite to parent from.
426
		 * @param composite The composite to parent from.
425
		 * @return <code>composite</code>
427
		 * @return <code>composite</code>
426
		 */
428
		 */
429
		@Override
427
		protected Control createDialogArea(Composite composite) {
430
		protected Control createDialogArea(Composite composite) {
428
			Composite result;
431
			Composite result;
429
            
432
            
Lines 448-453 Link Here
448
451
449
				checkbox.addSelectionListener(new SelectionAdapter() {
452
				checkbox.addSelectionListener(new SelectionAdapter() {
450
453
454
					@Override
451
					public void widgetSelected(SelectionEvent e) {
455
					public void widgetSelected(SelectionEvent e) {
452
						// toggle the preference setting for display of live
456
						// toggle the preference setting for display of live
453
						//   warnings according to user's selection
457
						//   warnings according to user's selection
(-)build.properties (-2 / +2 lines)
Lines 24-28 Link Here
24
               plugin.properties,\
24
               plugin.properties,\
25
               icons/,\
25
               icons/,\
26
               about.html
26
               about.html
27
javacSource = 1.4
27
javacSource = 1.5
28
javacTarget = 1.4
28
javacTarget = 1.5
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/emf/validation/ui/internal/console/ConsoleUtil.java (-6 / +9 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 51-60 Link Here
51
public class ConsoleUtil {
51
public class ConsoleUtil {
52
	
52
	
53
	/** cache for console name to actual console object mapping*/
53
	/** cache for console name to actual console object mapping*/
54
	private static Map nameToConsole = new HashMap();
54
	private static Map<String, MessageConsole> nameToConsole =
55
		new HashMap<String, MessageConsole>();
55
	
56
	
56
	/** cache for 'console name' to 'default streams for error, warining and info for that console' mapping */
57
	/** cache for 'console name' to 'default streams for error, warining and info for that console' mapping */
57
	private static Map nameToDefaultStream = new HashMap();
58
	private static Map<String, MessageConsoleStream> nameToDefaultStream =
59
		new HashMap<String, MessageConsoleStream>();
58
	
60
	
59
	
61
	
60
	// Strings for error, info, warning and default message types
62
	// Strings for error, info, warning and default message types
Lines 92-98 Link Here
92
			nameToConsole.put(name, console );
94
			nameToConsole.put(name, console );
93
		}
95
		}
94
		
96
		
95
		return (MessageConsole) nameToConsole.get( name);
97
		return nameToConsole.get( name);
96
	}
98
	}
97
	
99
	
98
	
100
	
Lines 114-120 Link Here
114
	 */
116
	 */
115
	public static void unregisterConsole(String name){		
117
	public static void unregisterConsole(String name){		
116
		if(nameToConsole.containsKey( name)){		
118
		if(nameToConsole.containsKey( name)){		
117
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles( new IConsole[]{(IConsole)nameToConsole.get(name)});
119
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles(
120
				new IConsole[]{nameToConsole.get(name)});
118
			nameToConsole.remove( name);
121
			nameToConsole.remove( name);
119
			nameToDefaultStream.remove(name+ERROR );
122
			nameToDefaultStream.remove(name+ERROR );
120
			nameToDefaultStream.remove(name+INFO );
123
			nameToDefaultStream.remove(name+INFO );
Lines 142-148 Link Here
142
			
145
			
143
		}
146
		}
144
		
147
		
145
		return (MessageConsoleStream) nameToDefaultStream.get(name+type);
148
		return nameToDefaultStream.get(name+type);
146
		
149
		
147
	}
150
	}
148
	
151
	
(-)src/org/eclipse/emf/validation/ui/preferences/ConstraintsSelectionBlock.java (-5 / +9 lines)
Lines 363-369 Link Here
363
		 * @param constraint the constraint meta-data
363
		 * @param constraint the constraint meta-data
364
		 */
364
		 */
365
		private void setDetails(IConstraintNode constraint) {
365
		private void setDetails(IConstraintNode constraint) {
366
			List styles = new java.util.ArrayList(32); // lots of style info
366
			// lots of style info
367
			List<StyleRange> styles = new java.util.ArrayList<StyleRange>(32);
367
			String text = ConstraintDetailsHelper.formatConstraintDescription(
368
			String text = ConstraintDetailsHelper.formatConstraintDescription(
368
					constraint,
369
					constraint,
369
					getCurrentCategorySelection(),
370
					getCurrentCategorySelection(),
Lines 371-377 Link Here
371
		
372
		
372
			getDetailsArea().setText(text);
373
			getDetailsArea().setText(text);
373
			getDetailsArea().setStyleRanges(
374
			getDetailsArea().setStyleRanges(
374
					(StyleRange[])styles.toArray(new StyleRange[styles.size()]));
375
					styles.toArray(new StyleRange[styles.size()]));
375
		}
376
		}
376
	}
377
	}
377
	
378
	
Lines 432-442 Link Here
432
				ValidationUIPlugin.getImageDescriptor(LOCK_ICON).createImage(
433
				ValidationUIPlugin.getImageDescriptor(LOCK_ICON).createImage(
433
						true);
434
						true);
434
			
435
			
436
			@Override
435
			public void dispose() {
437
			public void dispose() {
436
				lockImage.dispose();
438
				lockImage.dispose();
437
				super.dispose();
439
				super.dispose();
438
			}
440
			}
439
441
442
			@Override
440
			public Image getImage(Object element) {
443
			public Image getImage(Object element) {
441
				ICategoryTreeNode node = (ICategoryTreeNode)element;
444
				ICategoryTreeNode node = (ICategoryTreeNode)element;
442
				
445
				
Lines 494-505 Link Here
494
						true);
497
						true);
495
			
498
			
496
			// extends the inherited method
499
			// extends the inherited method
500
			@Override
497
			public void dispose() {
501
			public void dispose() {
498
				lockImage.dispose();
502
				lockImage.dispose();
499
				super.dispose();
503
				super.dispose();
500
			}
504
			}
501
505
502
			// redefines the inherited method
506
			// redefines the inherited method
507
			@Override
503
			public Image getImage(Object element) {
508
			public Image getImage(Object element) {
504
				IConstraintNode constraint = (IConstraintNode) element;
509
				IConstraintNode constraint = (IConstraintNode) element;
505
				
510
				
Lines 514-519 Link Here
514
			}
519
			}
515
			
520
			
516
			// redefines the inherited method
521
			// redefines the inherited method
522
			@Override
517
			public String getText(Object element) {
523
			public String getText(Object element) {
518
				return ((IConstraintNode)element).getName();
524
				return ((IConstraintNode)element).getName();
519
			}});
525
			}});
Lines 646-654 Link Here
646
	}
652
	}
647
	
653
	
648
	private void markEnabledCategories(ICategoryTreeNode[] categories) {
654
	private void markEnabledCategories(ICategoryTreeNode[] categories) {
649
		for (int i = 0; i < categories.length; i++) {
655
		for (ICategoryTreeNode next : categories) {
650
			ICategoryTreeNode next = categories[i];
651
			
652
			getCategoryTree().setChecked(
656
			getCategoryTree().setChecked(
653
				next,
657
				next,
654
				next.isChecked());
658
				next.isChecked());
(-)META-INF/MANIFEST.MF (-3 / +3 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.ui; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.ui; singleton:=true
5
Bundle-Version: 1.1.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.ui.internal.ValidationUIPlugin$Implementation
6
Bundle-Activator: org.eclipse.emf.validation.ui.internal.ValidationUIPlugin$Implementation
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 11-20 Link Here
11
 org.eclipse.emf.validation.ui.internal.l10n;x-internal:=true,
11
 org.eclipse.emf.validation.ui.internal.l10n;x-internal:=true,
12
 org.eclipse.emf.validation.ui.internal.preferences;x-internal:=true,
12
 org.eclipse.emf.validation.ui.internal.preferences;x-internal:=true,
13
 org.eclipse.emf.validation.ui.preferences
13
 org.eclipse.emf.validation.ui.preferences
14
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.1.0,2.0.0)",
14
Require-Bundle: org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)",
15
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
15
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
17
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)",
17
 com.ibm.icu;bundle-version="[3.4.3,4.0.0)",
18
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)"
18
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)"
19
Eclipse-LazyStart: true
19
Eclipse-LazyStart: true
20
Bundle-RequiredExecutionEnvironment: J2SE-1.4
20
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)feature.xml (-2 / +4 lines)
Lines 18-24 Link Here
18
<feature
18
<feature
19
      id="org.eclipse.emf.validation.ocl"
19
      id="org.eclipse.emf.validation.ocl"
20
      label="%featureName"
20
      label="%featureName"
21
      version="1.1.0.qualifier"
21
      version="1.2.0.qualifier"
22
      provider-name="%providerName"
22
      provider-name="%providerName"
23
      image="modeling32.png">
23
      image="modeling32.png">
24
24
Lines 44-52 Link Here
44
   </url>
44
   </url>
45
45
46
   <requires>
46
   <requires>
47
      <import plugin="org.eclipse.emf.validation" version="1.0.0" match="compatible"/>
48
      <import plugin="org.eclipse.emf.ocl" version="1.0.0" match="compatible"/>
47
      <import plugin="org.eclipse.emf.ocl" version="1.0.0" match="compatible"/>
49
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
48
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
49
      <import plugin="org.eclipse.emf.validation" version="1.2.0" match="compatible"/>
50
      <import plugin="org.eclipse.ocl" version="1.1.0" match="compatible"/>
51
      <import plugin="org.eclipse.ocl.ecore" version="1.1.0" match="compatible"/>
50
   </requires>
52
   </requires>
51
53
52
   <plugin
54
   <plugin
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)build.properties (-2 / +2 lines)
Lines 20-24 Link Here
20
               .,\
20
               .,\
21
               about.html
21
               about.html
22
src.includes = about.html
22
src.includes = about.html
23
javacSource = 1.4
23
javacSource = 1.5
24
javacTarget = 1.4
24
javacTarget = 1.5
(-)src/org/eclipse/emf/validation/examples/general/constraints/NonEmptyNamesConstraint.java (-2 / +3 lines)
Lines 36-41 Link Here
36
	/* (non-Javadoc)
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
37
	 * @see org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.emf.validation.IValidationContext)
38
	 */
38
	 */
39
	@Override
39
	public IStatus validate(IValidationContext ctx) {
40
	public IStatus validate(IValidationContext ctx) {
40
		EObject eObj = ctx.getTarget();
41
		EObject eObj = ctx.getTarget();
41
		EMFEventType eType = ctx.getEventType();
42
		EMFEventType eType = ctx.getEventType();
Lines 50-56 Link Here
50
			}
51
			}
51
			
52
			
52
			if (name == null || name.length() == 0) {
53
			if (name == null || name.length() == 0) {
53
				return ctx.createFailureStatus(new Object[] {eObj.eClass().getName()});
54
				return ctx.createFailureStatus(eObj.eClass().getName());
54
			}
55
			}
55
		// In the case of live mode.
56
		// In the case of live mode.
56
		} else {
57
		} else {
Lines 58-64 Link Here
58
			
59
			
59
			if (newValue == null
60
			if (newValue == null
60
				|| ((String)newValue).length() == 0) {
61
				|| ((String)newValue).length() == 0) {
61
				return ctx.createFailureStatus(new Object[] {eObj.eClass().getName()});
62
				return ctx.createFailureStatus(eObj.eClass().getName());
62
			}
63
			}
63
		}
64
		}
64
		
65
		
(-)src/org/eclipse/emf/validation/examples/general/listeners/ValidationListener.java (-6 / +4 lines)
Lines 22-27 Link Here
22
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.emf.validation.examples.general.console.ConsoleUtil;
23
import org.eclipse.emf.validation.examples.general.console.ConsoleUtil;
24
import org.eclipse.emf.validation.examples.general.internal.l10n.ValidationMessages;
24
import org.eclipse.emf.validation.examples.general.internal.l10n.ValidationMessages;
25
import org.eclipse.emf.validation.model.IConstraintStatus;
25
import org.eclipse.emf.validation.service.IValidationListener;
26
import org.eclipse.emf.validation.service.IValidationListener;
26
import org.eclipse.emf.validation.service.ValidationEvent;
27
import org.eclipse.emf.validation.service.ValidationEvent;
27
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.osgi.util.NLS;
Lines 99-107 Link Here
99
	    private void appendProblemsRecursive(
100
	    private void appendProblemsRecursive(
100
	        IStatus[] statuses,
101
	        IStatus[] statuses,
101
	        StringBuffer output) {
102
	        StringBuffer output) {
102
	        for (int i = 0; i < statuses.length; i++) {
103
	        for (IStatus next : statuses) {
103
	            IStatus next = statuses[i];
104
	
105
	            if (!next.isOK()) {
104
	            if (!next.isOK()) {
106
	                final String messagePattern;
105
	                final String messagePattern;
107
	
106
	
Lines 222-230 Link Here
222
     * @return its validation results, as a status array
221
     * @return its validation results, as a status array
223
     */
222
     */
224
    private static IStatus[] toStatusArray(ValidationEvent event) {
223
    private static IStatus[] toStatusArray(ValidationEvent event) {
225
    	List results = event.getValidationResults();
224
    	List<IConstraintStatus> results = event.getValidationResults();
226
    	
225
    	
227
    	return (IStatus[]) results.toArray(
226
    	return results.toArray(new IStatus[results.size()]);
228
    		new IStatus[results.size()]);
229
    }    	
227
    }    	
230
}
228
}
(-)src/org/eclipse/emf/validation/examples/general/console/ConsoleUtil.java (-9 / +13 lines)
Lines 1-7 Link Here
1
/**
1
/**
2
 * <copyright>
2
 * <copyright>
3
 *
3
 *
4
 * Copyright (c) 2004, 2006 IBM Corporation and others.
4
 * Copyright (c) 2004, 2007 IBM Corporation and others.
5
 * All rights reserved.   This program and the accompanying materials
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 51-60 Link Here
51
public class ConsoleUtil {
51
public class ConsoleUtil {
52
	
52
	
53
	/** cache for console name to actual console object mapping*/
53
	/** cache for console name to actual console object mapping*/
54
	private static Map nameToConsole = new HashMap();
54
	private static Map<String, MessageConsole> nameToConsole =
55
		new HashMap<String, MessageConsole>();
55
	
56
	
56
	/** cache for 'console name' to 'default streams for error, warining and info for that console' mapping */
57
	/** cache for 'console name' to 'default streams for error, warning and info for that console' mapping */
57
	private static Map nameToDefaultStream = new HashMap();
58
	private static Map<String, MessageConsoleStream> nameToDefaultStream =
59
		new HashMap<String, MessageConsoleStream>();
58
	
60
	
59
	
61
	
60
	// Strings for error, info, warning and default message types
62
	// Strings for error, info, warning and default message types
Lines 87-98 Link Here
87
		if(nameToConsole.get(name) == null){	
89
		if(nameToConsole.get(name) == null){	
88
			
90
			
89
			MessageConsole console = new MessageConsole(name,image);
91
			MessageConsole console = new MessageConsole(name,image);
90
			ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console});			
92
			ConsolePlugin.getDefault().getConsoleManager().addConsoles(
93
				new IConsole[]{console});			
91
			
94
			
92
			nameToConsole.put(name, console );
95
			nameToConsole.put(name, console);
93
		}
96
		}
94
		
97
		
95
		return (MessageConsole) nameToConsole.get( name);
98
		return nameToConsole.get(name);
96
	}
99
	}
97
	
100
	
98
	
101
	
Lines 114-120 Link Here
114
	 */
117
	 */
115
	public static void unregisterConsole(String name){		
118
	public static void unregisterConsole(String name){		
116
		if(nameToConsole.containsKey( name)){		
119
		if(nameToConsole.containsKey( name)){		
117
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles( new IConsole[]{(IConsole)nameToConsole.get(name)});
120
			ConsolePlugin.getDefault().getConsoleManager().removeConsoles(
121
				new IConsole[]{nameToConsole.get(name)});
118
			nameToConsole.remove( name);
122
			nameToConsole.remove( name);
119
			nameToDefaultStream.remove(name+ERROR );
123
			nameToDefaultStream.remove(name+ERROR );
120
			nameToDefaultStream.remove(name+INFO );
124
			nameToDefaultStream.remove(name+INFO );
Lines 142-148 Link Here
142
			
146
			
143
		}
147
		}
144
		
148
		
145
		return (MessageConsoleStream) nameToDefaultStream.get(name+type);
149
		return nameToDefaultStream.get(name+type);
146
		
150
		
147
	}
151
	}
148
	
152
	
(-).settings/org.eclipse.jdt.core.prefs (-5 / +5 lines)
Lines 1-8 Link Here
1
#Wed Dec 20 11:46:50 EST 2006
1
#Tue Oct 30 22:16:49 EDT 2007
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
5
org.eclipse.jdt.core.compiler.compliance=1.4
5
org.eclipse.jdt.core.compiler.compliance=1.5
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.4
8
org.eclipse.jdt.core.compiler.source=1.5
(-)src/org/eclipse/emf/validation/examples/general/actions/EnableLiveValidationDelegate.java (-22 / +24 lines)
Lines 18-25 Link Here
18
package org.eclipse.emf.validation.examples.general.actions;
18
package org.eclipse.emf.validation.examples.general.actions;
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.Iterator;
21
import org.eclipse.emf.common.notify.Adapter;
22
23
import org.eclipse.emf.ecore.resource.Resource;
22
import org.eclipse.emf.ecore.resource.Resource;
24
import org.eclipse.emf.ecore.util.EContentAdapter;
23
import org.eclipse.emf.ecore.util.EContentAdapter;
25
import org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditor;
24
import org.eclipse.emf.examples.extlibrary.presentation.EXTLibraryEditor;
Lines 60-66 Link Here
60
	/**
59
	/**
61
	 * Selected EObjects
60
	 * Selected EObjects
62
	 */
61
	 */
63
	protected Collection selectedEObjects = null;
62
	protected Collection<Resource> selectedResources = null;
64
63
65
	String title = ValidationMessages.EnableLiveValidationDelegate_title;
64
	String title = ValidationMessages.EnableLiveValidationDelegate_title;
66
65
Lines 69-96 Link Here
69
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
68
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
70
	 *      org.eclipse.jface.viewers.ISelection)
69
	 *      org.eclipse.jface.viewers.ISelection)
71
	 */
70
	 */
71
	@SuppressWarnings("unchecked")
72
	public void selectionChanged(IAction action, final ISelection selection) {
72
	public void selectionChanged(IAction action, final ISelection selection) {
73
		this.selectedEObjects = null;
73
		this.selectedResources = null;
74
		try {
74
		try {
75
			if (selection instanceof IStructuredSelection) {
75
			if (selection instanceof IStructuredSelection) {
76
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
76
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
77
				this.selectedEObjects = structuredSelection.toList();
77
				
78
				Collection<?> selectedHunh = structuredSelection.toList();
79
				
80
				for (Object next : selectedHunh) {
81
					if (!(next instanceof Resource)) {
82
						action.setEnabled(false);
83
					} else if (resourceHasAdapter((Resource) next)) {
84
						action.setEnabled(false);
85
					}
86
				}
87
				
88
				if (action.isEnabled()) {
89
					this.selectedResources = (Collection<Resource>) selectedHunh;
90
				} else {
91
					this.selectedResources = null;
92
				}
78
			}
93
			}
79
		} catch (Exception e) {
94
		} catch (Exception e) {
80
			// Exceptions are not expected
95
			// Exceptions are not expected
81
			MessageDialog.openInformation(shell, title, MESSAGE_EXCEPTION);
96
			MessageDialog.openInformation(shell, title, MESSAGE_EXCEPTION);
82
			throw new RuntimeException(e);
97
			throw new RuntimeException(e);
83
		} finally {
98
		} finally {
84
			action.setEnabled((null != selectedEObjects));
99
			action.setEnabled((null != selectedResources));
85
		}
86
		
87
		for (Iterator i = selectedEObjects.iterator(); i.hasNext();) {
88
			Object o = i.next();
89
			if (!(o instanceof Resource)) {
90
				action.setEnabled(false);
91
			} else if (resourceHasAdapter((Resource)o)) {
92
				action.setEnabled(false);
93
			}
94
		}
100
		}
95
	}
101
	}
96
102
Lines 131-139 Link Here
131
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
137
	 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
132
	 */
138
	 */
133
	public void run(IAction action) {
139
	public void run(IAction action) {
134
		for (Iterator i = selectedEObjects.iterator(); i.hasNext();) {
140
		for (Resource r : selectedResources) {
135
			Resource r = (Resource)i.next();
136
			
137
			if (!resourceHasAdapter(r)) {
141
			if (!resourceHasAdapter(r)) {
138
				EContentAdapter liveValidationContentAdapter = new LiveValidationContentAdapter(this);
142
				EContentAdapter liveValidationContentAdapter = new LiveValidationContentAdapter(this);
139
				r.eAdapters().add(liveValidationContentAdapter);
143
				r.eAdapters().add(liveValidationContentAdapter);
Lines 142-151 Link Here
142
	}
146
	}
143
	
147
	
144
	private boolean resourceHasAdapter(Resource r) {
148
	private boolean resourceHasAdapter(Resource r) {
145
		Collection adapters = r.eAdapters();
149
		for (Adapter next : r.eAdapters()) {
146
		for (Iterator j = adapters.iterator(); j.hasNext();) {
150
			if (next instanceof LiveValidationContentAdapter) {
147
			Object o = j.next();
148
			if (o instanceof LiveValidationContentAdapter) {
149
				return true;
151
				return true;
150
			}
152
			}
151
		}
153
		}
(-)src/org/eclipse/emf/validation/examples/general/actions/BatchValidationDelegate.java (-14 / +23 lines)
Lines 19-25 Link Here
19
19
20
import java.util.Collection;
20
import java.util.Collection;
21
import java.util.HashSet;
21
import java.util.HashSet;
22
import java.util.Iterator;
23
import java.util.Set;
22
import java.util.Set;
24
23
25
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
Lines 41-46 Link Here
41
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.IStructuredSelection;
42
import org.eclipse.jface.viewers.LabelProvider;
41
import org.eclipse.jface.viewers.LabelProvider;
43
import org.eclipse.jface.viewers.Viewer;
42
import org.eclipse.jface.viewers.Viewer;
43
import org.eclipse.jface.window.Window;
44
import org.eclipse.swt.widgets.Event;
44
import org.eclipse.swt.widgets.Event;
45
import org.eclipse.swt.widgets.Shell;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.ui.IActionDelegate2;
46
import org.eclipse.ui.IActionDelegate2;
Lines 74-96 Link Here
74
	/**
74
	/**
75
	 * Selected EObjects
75
	 * Selected EObjects
76
	 */
76
	 */
77
	protected Collection selectedEObjects = null;
77
	protected Collection<EObject> selectedEObjects = null;
78
78
79
	/**
79
	/**
80
	 * The InputDialog title
80
	 * The InputDialog title
81
	 */
81
	 */
82
	private String title = ValidationMessages.BatchValidationDelegate_title;
82
	private final String title = ValidationMessages.BatchValidationDelegate_title;
83
83
84
	/*
84
	/*
85
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
85
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
86
	 *      org.eclipse.jface.viewers.ISelection)
86
	 *      org.eclipse.jface.viewers.ISelection)
87
	 */
87
	 */
88
	@SuppressWarnings("unchecked")
88
	public void selectionChanged(IAction action, final ISelection selection) {
89
	public void selectionChanged(IAction action, final ISelection selection) {
89
		this.selectedEObjects = null;
90
		this.selectedEObjects = null;
90
		try {
91
		try {
91
			if (selection instanceof IStructuredSelection) {
92
			if (selection instanceof IStructuredSelection) {
92
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
93
				IStructuredSelection structuredSelection = (IStructuredSelection) selection;
93
				this.selectedEObjects = structuredSelection.toList();
94
				
95
				Collection<?> selectedHunh = structuredSelection.toList();
96
				for (Object next : selectedHunh) {
97
					if (!(next instanceof EObject)) {
98
						action.setEnabled(false);
99
					}
100
				}
101
				
102
				if (action.isEnabled()) {
103
					this.selectedEObjects = (Collection<EObject>) selectedHunh;
104
				} else {
105
					this.selectedEObjects = null;
106
				}
94
			}
107
			}
95
		} catch (Exception e) {
108
		} catch (Exception e) {
96
			// Exceptions are not expected
109
			// Exceptions are not expected
Lines 100-110 Link Here
100
			action.setEnabled((null != selectedEObjects));
113
			action.setEnabled((null != selectedEObjects));
101
		}
114
		}
102
		
115
		
103
		for (Iterator i = selectedEObjects.iterator(); i.hasNext();) {
104
			if (!(i.next() instanceof EObject)) {
105
				action.setEnabled(false);
106
			}
107
		}
108
	}
116
	}
109
117
110
	/*
118
	/*
Lines 146-152 Link Here
146
	public void run(IAction action) {
154
	public void run(IAction action) {
147
		ValidationDelegateClientSelector.running = true;
155
		ValidationDelegateClientSelector.running = true;
148
		
156
		
149
		IBatchValidator validator = (IBatchValidator)ModelValidationService.getInstance()
157
		IBatchValidator validator = ModelValidationService.getInstance()
150
			.newValidator(EvaluationMode.BATCH);
158
			.newValidator(EvaluationMode.BATCH);
151
		validator.setIncludeLiveConstraints(true);
159
		validator.setIncludeLiveConstraints(true);
152
		
160
		
Lines 179-184 Link Here
179
				}
187
				}
180
			});
188
			});
181
			dialog.setLabelProvider(new LabelProvider() {
189
			dialog.setLabelProvider(new LabelProvider() {
190
				@Override
182
				public String getText(Object element) {
191
				public String getText(Object element) {
183
					if (element instanceof IStatus) {
192
					if (element instanceof IStatus) {
184
						return ((IStatus)element).getMessage();
193
						return ((IStatus)element).getMessage();
Lines 189-203 Link Here
189
			dialog.setBlockOnOpen(true);
198
			dialog.setBlockOnOpen(true);
190
			dialog.setMessage(ValidationMessages.BatchValidationDelegate_errorMessage);
199
			dialog.setMessage(ValidationMessages.BatchValidationDelegate_errorMessage);
191
			
200
			
192
			if (ListDialog.OK == dialog.open()) {
201
			if (Window.OK == dialog.open()) {
193
				Set errorSelections = new HashSet();
202
				Set<EObject> errorSelections = new HashSet<EObject>();
194
				if (!status.isMultiStatus()) {
203
				if (!status.isMultiStatus()) {
195
					IConstraintStatus cstatus = (IConstraintStatus)status;
204
					IConstraintStatus cstatus = (IConstraintStatus)status;
196
					errorSelections.add(cstatus.getTarget());
205
					errorSelections.add(cstatus.getTarget());
197
				} else {
206
				} else {
198
					IStatus[] children = status.getChildren();
207
					IStatus[] children = status.getChildren();
199
					for (int i = 0; i<children.length; i++) {
208
					for (IStatus element : children) {
200
						IConstraintStatus cstatus = (IConstraintStatus)children[i];
209
						IConstraintStatus cstatus = (IConstraintStatus)element;
201
						errorSelections.add(cstatus.getTarget());
210
						errorSelections.add(cstatus.getTarget());
202
					}
211
					}
203
				}
212
				}
(-)src/org/eclipse/emf/validation/examples/general/actions/LiveValidationContentAdapter.java (-2 / +3 lines)
Lines 51-64 Link Here
51
	/* (non-Javadoc)
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.emf.ecore.util.EContentAdapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
52
	 * @see org.eclipse.emf.ecore.util.EContentAdapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
53
	 */
53
	 */
54
	@Override
54
	public void notifyChanged(final Notification notification) {
55
	public void notifyChanged(final Notification notification) {
55
		super.notifyChanged(notification);
56
		super.notifyChanged(notification);
56
		
57
		
57
		actionDelegate.shell.getDisplay().asyncExec(new Runnable() {
58
		actionDelegate.shell.getDisplay().asyncExec(new Runnable() {
58
			public void run() {
59
			public void run() {
59
				if (validator == null) {
60
				if (validator == null) {
60
					validator = (ILiveValidator) ModelValidationService
61
					validator = ModelValidationService.getInstance().newValidator(
61
							.getInstance().newValidator(EvaluationMode.LIVE);
62
						EvaluationMode.LIVE);
62
				}
63
				}
63
				
64
				
64
				ValidationDelegateClientSelector.running = true;
65
				ValidationDelegateClientSelector.running = true;
(-)META-INF/MANIFEST.MF (-7 / +7 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %Plugin.name
3
Bundle-Name: %Plugin.name
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.general; singleton:=true
4
Bundle-SymbolicName: org.eclipse.emf.validation.examples.general; singleton:=true
5
Bundle-Version: 1.0.100.qualifier
5
Bundle-Version: 1.2.0.qualifier
6
Bundle-Activator: org.eclipse.emf.validation.examples.general.ValidationPlugin
6
Bundle-Activator: org.eclipse.emf.validation.examples.general.ValidationPlugin
7
Bundle-Vendor: %Plugin.providerName
7
Bundle-Vendor: %Plugin.providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
Lines 14-24 Link Here
14
 org.eclipse.emf.validation.examples.general.listeners
14
 org.eclipse.emf.validation.examples.general.listeners
15
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
15
Require-Bundle: org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
16
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
17
 org.eclipse.emf.validation;bundle-version="[1.0.0,2.0.0)",
17
 org.eclipse.emf.validation;bundle-version="[1.2.0,2.0.0)",
18
 org.eclipse.emf.examples.library;bundle-version="[2.2.0,3.0.0)",
18
 org.eclipse.emf.examples.library;bundle-version="[2.3.0,3.0.0)",
19
 org.eclipse.emf.examples.library.edit;bundle-version="[2.2.0,3.0.0)",
19
 org.eclipse.emf.examples.library.edit;bundle-version="[2.3.0,3.0.0)",
20
 org.eclipse.emf.examples.library.editor;bundle-version="[2.2.0,3.0.0)",
20
 org.eclipse.emf.examples.library.editor;bundle-version="[2.3.0,3.0.0)",
21
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)",
21
 org.eclipse.ui.console;bundle-version="[3.1.100,4.0.0)",
22
 org.eclipse.emf.validation.ui;bundle-version="[1.0.0,2.0.0)"
22
 org.eclipse.emf.validation.ui;bundle-version="[1.2.0,2.0.0)"
23
Eclipse-LazyStart: true
23
Eclipse-LazyStart: true
24
Bundle-RequiredExecutionEnvironment: J2SE-1.4
24
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)feature.xml (-5 / +10 lines)
Lines 44-57 Link Here
44
   </url>
44
   </url>
45
45
46
   <requires>
46
   <requires>
47
      <import plugin="org.junit" version="3.8.1" match="compatible"/>
48
      <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
49
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
47
      <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
50
      <import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
48
      <import plugin="org.eclipse.emf.ecore" version="2.2.0" match="compatible"/>
51
      <import plugin="org.eclipse.emf.ecore" version="2.2.0" match="compatible"/>
49
      <import plugin="org.junit" version="3.8.1" match="compatible"/>
50
      <import plugin="org.eclipse.emf.ecore.xmi" version="2.2.0" match="compatible"/>
52
      <import plugin="org.eclipse.emf.ecore.xmi" version="2.2.0" match="compatible"/>
51
      <import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
53
      <import plugin="org.apache.ant"/>
52
      <import plugin="org.eclipse.emf.validation.ui" version="1.0.1" match="greaterOrEqual"/>
54
      <import plugin="org.eclipse.ui.ide.application"/>
53
      <import plugin="org.eclipse.ui" version="3.2.0" match="compatible"/>
55
      <import plugin="org.eclipse.equinox.app"/>
54
      <import plugin="org.eclipse.emf.validation" version="1.1.1" match="greaterOrEqual"/>
56
      <import plugin="org.apache.ant" version="1.4.1" match="compatible"/>
57
      <import plugin="org.eclipse.emf.validation" version="1.2.0" match="greaterOrEqual"/>
58
      <import plugin="org.eclipse.core.resources" version="3.2.0" match="compatible"/>
59
      <import plugin="org.eclipse.emf.validation.ui" version="1.1.100" match="greaterOrEqual"/>
55
   </requires>
60
   </requires>
56
61
57
   <plugin
62
   <plugin

Return to bug 206808