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 249496 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/validation/internal/service/impl/tests/AllTests.java (-1 / +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, 2008 IBM Corporation, Zeligsoft Inc., 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 9-14 Link Here
9
 *
9
 *
10
 * Contributors:
10
 * Contributors:
11
 *   IBM - Initial API and implementation
11
 *   IBM - Initial API and implementation
12
 *   Zeligsoft - Bug 249496
12
 *
13
 *
13
 * </copyright>
14
 * </copyright>
14
 *
15
 *
Lines 43-47 Link Here
43
		
44
		
44
		addTestSuite(BatchValidatorTest.class);
45
		addTestSuite(BatchValidatorTest.class);
45
		addTestSuite(LiveValidatorTest.class);
46
		addTestSuite(LiveValidatorTest.class);
47
		
48
		addTest(ClientContextTest.suite());
46
	}
49
	}
47
}
50
}
(-)plugin.xml (+104 lines)
Lines 470-473 Link Here
470
         </eclass>
470
         </eclass>
471
      </traversalStrategy>
471
      </traversalStrategy>
472
   </extension>
472
   </extension>
473
   
474
   <!-- Constraints only used for client-context inclusion/exclusion testing -->
475
   <extension name="Contraints for client-context testing" point="org.eclipse.emf.validation.constraintProviders">
476
     <category id="clientContextTest" name="JUnit Client Context Testing Context"/>
477
     <category id="clientContextTest/one" name="First level of nesting"/>
478
     <category id="clientContextTest/one/two" name="Second level of nesting"/>
479
     <category id="clientContextTest/one/twoA" name="Second level of nesting (A)"/>
480
     <category id="clientContextTest/one/two/three" name="Third level of nesting"/>
481
     <category id="clientContextTest/one/two/threeA" name="Third level of nesting (A)"/>
482
     <constraintProvider>
483
         <package namespaceUri="http://www.eclipse.org/emf/2002/Ecore" />
484
         <constraints categories="clientContextTest/one">
485
            <constraint name="Dummy1.1" statusCode="1" lang="OCL" id="clientContext.1.1">
486
               <message>Nothing to say.</message>
487
               <target class="EAnnotation"/>
488
               true
489
            </constraint>
490
            <constraint name="Dummy1.2" statusCode="1" lang="OCL" id="clientContext.1.2">
491
               <message>Nothing to say.</message>
492
               <target class="EAnnotation"/>
493
               true
494
            </constraint>
495
         </constraints>
496
         <constraints categories="clientContextTest/one/two">
497
            <constraint name="Dummy2.1" statusCode="1" lang="OCL" id="clientContext.2.1">
498
               <message>Nothing to say.</message>
499
               <target class="EAnnotation"/>
500
               true
501
            </constraint>
502
            <constraint name="Dummy2.2" statusCode="1" lang="OCL" id="clientContext.2.2">
503
               <message>Nothing to say.</message>
504
               <target class="EAnnotation"/>
505
               true
506
            </constraint>
507
         </constraints>
508
         <constraints categories="clientContextTest/one/twoA">
509
            <constraint name="Dummy2a.1" statusCode="1" lang="OCL" id="clientContext.2a.1">
510
               <message>Nothing to say.</message>
511
               <target class="EAnnotation"/>
512
               true
513
            </constraint>
514
            <constraint name="Dummy2a.2" statusCode="1" lang="OCL" id="clientContext.2a.2">
515
               <message>Nothing to say.</message>
516
               <target class="EAnnotation"/>
517
               true
518
            </constraint>
519
         </constraints>
520
         <constraints categories="clientContextTest/one/two/three">
521
            <constraint name="Dummy3.1" statusCode="1" lang="OCL" id="clientContext.3.1">
522
               <message>Nothing to say.</message>
523
               <target class="EAnnotation"/>
524
               true
525
            </constraint>
526
            <constraint name="Dummy3.2" statusCode="1" lang="OCL" id="clientContext.3.2">
527
               <message>Nothing to say.</message>
528
               <target class="EAnnotation"/>
529
               true
530
            </constraint>
531
         </constraints>
532
         <constraints categories="clientContextTest/one/two/threeA">
533
            <constraint name="Dummy3a.1" statusCode="1" lang="OCL" id="clientContext.3a.1">
534
               <message>Nothing to say.</message>
535
               <target class="EAnnotation"/>
536
               true
537
            </constraint>
538
            <constraint name="Dummy3a.2" statusCode="1" lang="OCL" id="clientContext.3a.2">
539
               <message>Nothing to say.</message>
540
               <target class="EAnnotation"/>
541
               true
542
            </constraint>
543
         </constraints>
544
      </constraintProvider>
545
   </extension>
546
   <!-- A client-context only used for inclusion/exclusion testing -->
547
   <extension point="org.eclipse.emf.validation.constraintBindings">
548
      <clientContext
549
            id="org.eclipse.emf.validation.tests.testContextToExtend">
550
          <!-- We are never enabled -->
551
          <enablement>
552
            <systemTest property="BOGUS_SYSTEM_PROPERTY" value="1"/>
553
         </enablement>
554
      </clientContext>
555
      <binding context="org.eclipse.emf.validation.tests.testContextToExtend">
556
         <category ref="clientContextTest/one/two/three"/>
557
      </binding>
558
   </extension>
559
   <extension point="org.eclipse.emf.validation.constraintBindings">
560
      <clientContext
561
            id="org.eclipse.emf.validation.tests.testcontext">
562
          <!-- We are never enabled -->
563
          <enablement>
564
            <systemTest property="BOGUS_SYSTEM_PROPERTY" value="1"/>
565
         </enablement>
566
      </clientContext>
567
      <binding context="org.eclipse.emf.validation.tests.testcontext">
568
         <category ref="clientContextTest/one"/>
569
         <excludeCategory ref="clientContextTest/one/two"/>
570
         <extendClientContext ref="org.eclipse.emf.validation.tests.testContextToExtend"/>
571
         <excludeConstraint ref="org.eclipse.emf.validation.tests.clientContext.1.1"/>
572
         <excludeConstraint ref="org.eclipse.emf.validation.tests.clientContext.2a.1"/>
573
         <constraint ref="org.eclipse.emf.validation.tests.clientContext.2.2"/>
574
         <constraint ref="org.eclipse.emf.validation.tests.clientContext.3a.2"/>
575
      </binding>
576
   </extension>
473
</plugin>
577
</plugin>
(-)src/org/eclipse/emf/validation/internal/service/impl/tests/ClientContextTest.java (+156 lines)
Added Link Here
1
/**
2
 * <copyright>
3
 * 
4
 * Copyright (c) 2008 Zeligsoft Inc. and others.
5
 * All rights reserved.   This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
8
 * http://www.eclipse.org/legal/epl-v10.html
9
 * 
10
 * Contributors:
11
 *   Zeligsoft - Initial API and implementation
12
 * 
13
 * </copyright>
14
 *
15
 * $Id$
16
 */
17
18
package org.eclipse.emf.validation.internal.service.impl.tests;
19
20
import junit.framework.Test;
21
import junit.framework.TestCase;
22
import junit.framework.TestSuite;
23
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.emf.ecore.EcoreFactory;
27
import org.eclipse.emf.validation.IValidationContext;
28
import org.eclipse.emf.validation.internal.service.ClientContext;
29
import org.eclipse.emf.validation.internal.service.ClientContextManager;
30
import org.eclipse.emf.validation.internal.service.IClientContext;
31
import org.eclipse.emf.validation.model.EvaluationMode;
32
import org.eclipse.emf.validation.model.IModelConstraint;
33
import org.eclipse.emf.validation.service.ConstraintRegistry;
34
import org.eclipse.emf.validation.service.IConstraintDescriptor;
35
import org.eclipse.emf.validation.service.ModelValidationService;
36
37
/**
38
 * Tests the {@link ClientContext} class.
39
 * 
40
 * @author Christian W. Damus (cdamus)
41
 */
42
@SuppressWarnings("nls")
43
public class ClientContextTest
44
		extends TestCase {
45
46
	private IModelConstraint constraint1_1;
47
48
	private IModelConstraint constraint1_2;
49
50
	private IModelConstraint constraint2_1;
51
52
	private IModelConstraint constraint2_2;
53
54
	private IModelConstraint constraint2a_1;
55
56
	private IModelConstraint constraint2a_2;
57
58
	private IModelConstraint constraint3_1;
59
60
	private IModelConstraint constraint3_2;
61
62
	private IModelConstraint constraint3a_1;
63
64
	private IModelConstraint constraint3a_2;
65
66
	private IClientContext fixture;
67
68
	/**
69
	 * Initialize me with my name.
70
	 * 
71
	 * @param name
72
	 *            my name
73
	 */
74
	public ClientContextTest(String name) {
75
		super(name);
76
	}
77
78
	public static Test suite() {
79
		return new TestSuite(ClientContextTest.class, "Client context tests");
80
	}
81
82
	public void test_includedChildOfExcludedCategory() {
83
		assertTrue("Constraint is excluded", fixture.includes(constraint3_1));
84
		assertTrue("Constraint is excluded", fixture.includes(constraint3_2));
85
	}
86
87
	public void test_constraintExcludedFromIncludedCategory() {
88
		assertFalse("Constraint is included", fixture.includes(constraint1_1));
89
		assertTrue("Constraint is excluded", fixture.includes(constraint1_2));
90
	}
91
92
	public void test_constraintIncludedInExcludedCategory() {
93
		assertFalse("Constraint is included", fixture.includes(constraint2_1));
94
		assertTrue("Constraint is excluded", fixture.includes(constraint2_2));
95
	}
96
97
	public void test_constraintExcludedFromIncludedCategory_nested() {
98
		assertFalse("Constraint is included", fixture.includes(constraint2a_1));
99
		assertTrue("Constraint is excluded", fixture.includes(constraint2a_2));
100
	}
101
102
	public void test_constraintIncludedInExcludedCategory_nested() {
103
		assertFalse("Constraint is included", fixture.includes(constraint3a_1));
104
		assertTrue("Constraint is excluded", fixture.includes(constraint3a_2));
105
	}
106
107
	//
108
	// Test framework
109
	//
110
111
	@Override
112
	protected void setUp()
113
			throws Exception {
114
115
		super.setUp();
116
117
		fixture = ClientContextManager.getInstance().getClientContext(
118
			"org.eclipse.emf.validation.tests.testcontext");
119
120
		final String prefix = "org.eclipse.emf.validation.tests.clientContext.";
121
		final ConstraintRegistry reg = ConstraintRegistry.getInstance();
122
123
		// cause our test constraints to be created
124
		ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH)
125
			.validate(EcoreFactory.eINSTANCE.createEAnnotation());
126
127
		constraint1_1 = new TestConstraint(reg.getDescriptor(prefix + "1.1"));
128
		constraint1_2 = new TestConstraint(reg.getDescriptor(prefix + "1.2"));
129
		constraint2_1 = new TestConstraint(reg.getDescriptor(prefix + "2.1"));
130
		constraint2_2 = new TestConstraint(reg.getDescriptor(prefix + "2.2"));
131
		constraint2a_1 = new TestConstraint(reg.getDescriptor(prefix + "2a.1"));
132
		constraint2a_2 = new TestConstraint(reg.getDescriptor(prefix + "2a.2"));
133
		constraint3_1 = new TestConstraint(reg.getDescriptor(prefix + "3.1"));
134
		constraint3_2 = new TestConstraint(reg.getDescriptor(prefix + "3.2"));
135
		constraint3a_1 = new TestConstraint(reg.getDescriptor(prefix + "3a.1"));
136
		constraint3a_2 = new TestConstraint(reg.getDescriptor(prefix + "3a.2"));
137
	}
138
139
	private static final class TestConstraint
140
			implements IModelConstraint {
141
142
		private IConstraintDescriptor desc;
143
144
		TestConstraint(IConstraintDescriptor desc) {
145
			this.desc = desc;
146
		}
147
148
		public IStatus validate(IValidationContext c) {
149
			return Status.OK_STATUS;
150
		}
151
152
		public IConstraintDescriptor getDescriptor() {
153
			return desc;
154
		}
155
	}
156
}
(-)src/org/eclipse/emf/validation/internal/l10n/ValidationMessages.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., 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 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
9
 *    IBM Corporation - initial API and implementation 
10
 *    Zeligsoft - Bug 249496
10
 ****************************************************************************/
11
 ****************************************************************************/
11
12
12
package org.eclipse.emf.validation.internal.l10n;
13
package org.eclipse.emf.validation.internal.l10n;
Lines 78-83 Link Here
78
	public static String binding_noSuchContext_ERROR_;
79
	public static String binding_noSuchContext_ERROR_;
79
	public static String binding_noConstraintRef_WARN_;
80
	public static String binding_noConstraintRef_WARN_;
80
	public static String binding_noCategoryRef_WARN_;
81
	public static String binding_noCategoryRef_WARN_;
82
	public static String binding_noClientContextRef_WARN_;
81
	public static String mode_live;
83
	public static String mode_live;
82
	public static String mode_batch;
84
	public static String mode_batch;
83
	public static String mode_unknown;
85
	public static String mode_unknown;
(-)src/org/eclipse/emf/validation/internal/l10n/ValidationMessages.properties (-1 / +9 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2003, 2007 IBM Corporation and others.
2
# Copyright (c) 2003, 2008 IBM Corporation, Zeligsoft Inc., 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 7-12 Link Here
7
# 
7
# 
8
# Contributors:
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
#     Zeligsoft - Bug 249496
10
# 
11
# 
11
# $Id$
12
# $Id$
12
###############################################################################
13
###############################################################################
Lines 381-386 Link Here
381
binding_noCategoryRef_WARN_= Constraint category binding for client context \
382
binding_noCategoryRef_WARN_= Constraint category binding for client context \
382
	{0} does not reference a category path in plug-in {1}.
383
	{0} does not reference a category path in plug-in {1}.
383
384
385
# Indicates that a client context extension does not actually specify any context.
386
# args:
387
#   0 - the client context ID of the binding
388
#   1 - the ID of the plug-in defining the offending extension
389
binding_noClientContextRef_WARN_= Constraint binding for client context {0} does \
390
	not reference an extended client context in plug-in {1}.
391
384
392
385
# ==============================================================================
393
# ==============================================================================
386
# Translation Instruction: section to be translated
394
# Translation Instruction: section to be translated
(-)src/org/eclipse/emf/validation/internal/EMFModelValidationStatusCodes.java (-2 / +4 lines)
Lines 1-12 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
2
 * Copyright (c) 2003, 2008 IBM Corporation, Zeligsoft Inc., 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
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
9
 *    IBM Corporation - initial API and implementation
10
 *    Zeligsoft - Bug 249496
10
 ****************************************************************************/
11
 ****************************************************************************/
11
12
12
13
Lines 75-80 Link Here
75
	public static final int BINDING_NO_SUCH_CLIENT = 121;
76
	public static final int BINDING_NO_SUCH_CLIENT = 121;
76
	public static final int BINDING_NO_CONSTRAINT = 122;
77
	public static final int BINDING_NO_CONSTRAINT = 122;
77
	public static final int BINDING_NO_CATEGORY = 123;
78
	public static final int BINDING_NO_CATEGORY = 123;
79
	public static final int BINDING_NO_CLIENT_CONTEXT = 124;
78
	
80
	
79
	public static final int LISTENER_UNCAUGHT_EXCEPTION = 130;
81
	public static final int LISTENER_UNCAUGHT_EXCEPTION = 130;
80
	
82
	
(-)src/org/eclipse/emf/validation/internal/service/ClientContextManager.java (-33 / +45 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation
9
 *    IBM Corporation - initial API and implementation
10
 *    Zeligsoft - Bug 137213
10
 *    Zeligsoft - Bugs 137213, 249496
11
 *    Borland Software - Bug 137213
11
 *    Borland Software - Bug 137213
12
 ****************************************************************************/
12
 ****************************************************************************/
13
13
Lines 52-59 Link Here
52
	private static final String E_BINDING = "binding"; //$NON-NLS-1$
52
	private static final String E_BINDING = "binding"; //$NON-NLS-1$
53
	private static final String A_CONTEXT = "context"; //$NON-NLS-1$
53
	private static final String A_CONTEXT = "context"; //$NON-NLS-1$
54
	
54
	
55
	private static final String A_CONSTRAINT = "constraint"; //$NON-NLS-1$
55
	private static final String E_CONSTRAINT = "constraint"; //$NON-NLS-1$
56
	private static final String A_CATEGORY = "category"; //$NON-NLS-1$
56
	private static final String E_CATEGORY = "category"; //$NON-NLS-1$
57
	private static final String E_EXTEND_CLIENT_CONTEXT = "extendClientContext"; //$NON-NLS-1$
58
	private static final String E_EXCLUDE_CONSTRAINT = "excludeConstraint"; //$NON-NLS-1$
59
	private static final String E_EXCLUDE_CATEGORY = "excludeCategory"; //$NON-NLS-1$
57
	private static final String A_REF = "ref"; //$NON-NLS-1$
60
	private static final String A_REF = "ref"; //$NON-NLS-1$
58
	
61
	
59
	private static final ClientContextManager INSTANCE = new ClientContextManager();
62
	private static final ClientContextManager INSTANCE = new ClientContextManager();
Lines 341-347 Link Here
341
			// add the constraint to all default contexts so that we don't do
344
			// add the constraint to all default contexts so that we don't do
342
			//   this computation again
345
			//   this computation again
343
			for (ClientContext next : defaultContexts) {
346
			for (ClientContext next : defaultContexts) {
344
				next.bindConstraint(id);
347
				next.includeConstraint(id);
345
			}
348
			}
346
		}
349
		}
347
		
350
		
Lines 447-493 Link Here
447
	 * @param config a particular <code>&lt;binding&gt;</config> element
450
	 * @param config a particular <code>&lt;binding&gt;</config> element
448
	 */
451
	 */
449
	private void configureBindings(ClientContext context, IConfigurationElement config) {
452
	private void configureBindings(ClientContext context, IConfigurationElement config) {
450
		String id = config.getAttribute(A_CONSTRAINT);
453
		String id = config.getAttribute(E_CONSTRAINT);
451
		
454
		
452
		if (id != null) {
455
		if (id != null) {
453
			context.bindConstraint(id);
456
			context.includeConstraint(id);
454
		}
457
		}
455
		
458
		
456
		id = config.getAttribute(A_CATEGORY);
459
		id = config.getAttribute(E_CATEGORY);
457
		
460
		
458
		if (id != null) {
461
		if (id != null) {
459
			context.bindCategory(id);
462
			context.includeCategory(id);
460
		}
463
		}
461
		
464
		
462
		IConfigurationElement[] children = config.getChildren(A_CONSTRAINT);
465
		IConfigurationElement[] children = config.getChildren();
463
		for (IConfigurationElement element : children) {
466
		for (IConfigurationElement element : children) {
467
			final String name = element.getName();
464
			final String ref = element.getAttribute(A_REF);
468
			final String ref = element.getAttribute(A_REF);
465
			
469
			
466
			if (ref == null) {
470
			if (ref == null) {
467
				Log.warningMessage(
471
				if (E_CONSTRAINT.equals(name) || E_EXCLUDE_CONSTRAINT.equals(name)) {
468
					EMFModelValidationStatusCodes.BINDING_NO_CONSTRAINT,
472
					Log.warningMessage(
469
					ValidationMessages.binding_noConstraintRef_WARN_,
473
						EMFModelValidationStatusCodes.BINDING_NO_CONSTRAINT,
470
					new Object[] {
474
						ValidationMessages.binding_noConstraintRef_WARN_,
471
						context.getId(),
475
						new Object[] {
472
						config.getDeclaringExtension().getNamespaceIdentifier()});
476
							context.getId(),
473
			} else {
477
							config.getDeclaringExtension().getNamespaceIdentifier()});
474
				context.bindConstraint(ref);
478
				} else if (E_EXTEND_CLIENT_CONTEXT.equals(name)) {
475
			}
479
					Log.warningMessage(
476
		}
480
						EMFModelValidationStatusCodes.BINDING_NO_CLIENT_CONTEXT,
477
		
481
						ValidationMessages.binding_noClientContextRef_WARN_,
478
		children = config.getChildren(A_CATEGORY);
482
						new Object[] {
479
		for (IConfigurationElement element : children) {
483
							context.getId(),
480
			final String ref = element.getAttribute(A_REF);
484
							config.getDeclaringExtension().getNamespaceIdentifier()});
481
			
485
				} else {
482
			if (ref == null) {
486
					Log.errorMessage(
483
				Log.errorMessage(
487
						EMFModelValidationStatusCodes.BINDING_NO_CATEGORY,
484
					EMFModelValidationStatusCodes.BINDING_NO_CATEGORY,
488
						ValidationMessages.binding_noCategoryRef_WARN_,
485
					ValidationMessages.binding_noCategoryRef_WARN_,
489
						new Object[] {
486
					new Object[] {
490
							context.getId(),
487
						context.getId(),
491
							config.getDeclaringExtension().getNamespaceIdentifier()});
488
						config.getDeclaringExtension().getNamespaceIdentifier()});
492
				}
489
			} else {
493
			} else if (E_CONSTRAINT.equals(name)) {
490
				context.bindCategory(ref);
494
				context.includeConstraint(ref);
495
			} else if (E_CATEGORY.equals(name)) {
496
				context.includeCategory(ref);
497
			} else if (E_EXTEND_CLIENT_CONTEXT.equals(name)) {
498
				context.extendClientContext(ref);
499
			} else if (E_EXCLUDE_CONSTRAINT.equals(name)) {
500
				context.excludeConstraint(ref);
501
			} else if (E_EXCLUDE_CATEGORY.equals(name)) {
502
				context.excludeCategory(ref);
491
			}
503
			}
492
		}
504
		}
493
	}
505
	}
(-)src/org/eclipse/emf/validation/internal/service/ClientContext.java (-60 / +432 lines)
Lines 1-25 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., 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
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
9
 *    IBM Corporation - initial API and implementation
10
 *    Zeligsoft - Bug 249496
10
 ****************************************************************************/
11
 ****************************************************************************/
11
12
12
package org.eclipse.emf.validation.internal.service;
13
package org.eclipse.emf.validation.internal.service;
13
14
14
import java.util.Collection;
15
import java.util.Collection;
15
import java.util.Iterator;
16
import java.util.Map;
16
import java.util.Set;
17
import java.util.Set;
17
18
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.Status;
22
23
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
23
import org.eclipse.emf.validation.internal.EMFModelValidationPlugin;
24
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
24
import org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes;
25
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
25
import org.eclipse.emf.validation.internal.l10n.ValidationMessages;
Lines 52-62 Link Here
52
	private final IClientSelector selector;
52
	private final IClientSelector selector;
53
	private final boolean isDefault;
53
	private final boolean isDefault;
54
	
54
	
55
	// set of String constraint IDs that are bound to me
55
	// map of String constraint IDs that are bound to me, the boolean value
56
	private final Set<String> constraintBindings = new java.util.HashSet<String>();
56
	// indicating absolute inclusion or exclusion.  Absence of a value means
57
	// that we still need to compute
58
	private final Map<String, Boolean> constraintBindings = new java.util.HashMap<String, Boolean>();
57
	
59
	
58
	// set of String category IDs that are bound to me
60
	// set of String category IDs that are bound to me
59
	private final Set<String> categoryBindings = new java.util.HashSet<String>();
61
	private BindingFilter filter = BindingFilter.NULL;
60
	
62
	
61
	/**
63
	/**
62
	 * Initializes me with my XML configuration.
64
	 * Initializes me with my XML configuration.
Lines 235-314 Link Here
235
	}
237
	}
236
238
237
	public boolean includes(IModelConstraint constraint) {
239
	public boolean includes(IModelConstraint constraint) {
238
		boolean result = false;
240
		IConstraintDescriptor desc = constraint.getDescriptor();
239
		
241
		
240
		IConstraintDescriptor descriptor = constraint.getDescriptor();
242
		return (desc != null) && includes(desc);
243
	}
244
	
245
	boolean includes(IConstraintDescriptor constraint) {
246
		Boolean result = constraintBindings.get(constraint.getId());
241
		
247
		
242
		if (descriptor != null) {
248
		if (result == null) {
243
			result = constraintBindings.contains(descriptor.getId());
249
			// cache the result for this constraint
244
			
250
			result = filter.getBinding(constraint);
245
			if (!result && !categoryBindings.isEmpty()) {
251
			constraintBindings.put(constraint.getId(), result);
246
				// look for a bound category
247
				result = hasCategoryBinding(descriptor.getCategories());
248
				
249
				if (result) {
250
					// cache the result for this constraint
251
					bindConstraint(descriptor.getId());
252
				}
253
			}
254
		}
252
		}
255
		
253
		
256
		return result;
254
		return result;
257
	}
255
	}
258
	
256
	
259
	/**
257
	/**
260
	 * Determines whether any of the specified <code>categories</code> is bound
258
	 * Adds a constraint inclusion binding to me.
261
	 * to me.
262
	 * 
259
	 * 
263
	 * @param categories a collection of categories (usually from a constraint)
260
	 * @param constraintId the ID of a constraint that is to be included in me
264
	 * @return <code>true</code> if any of the <code>categories</code> is bound,
265
	 *     or if any of their ancestors is bound; <code>false</code>, otherwise
266
	 */
261
	 */
267
	private boolean hasCategoryBinding(Collection<Category> categories) {
262
	void includeConstraint(String constraintId) {
268
		boolean result = false;
263
		filter = filter.includeConstraint(constraintId);
269
		
270
		for (Iterator<Category> iter = categories.iterator(); !result && iter.hasNext();) {
271
			Category category = iter.next();
272
			
273
			result = categoryBindings.contains(category.getPath());
274
			
275
			if (!result) {
276
				// search the ancestors
277
				Category ancestor = category.getParent();
278
				
279
				while ((ancestor != null) && !result) {
280
					result = categoryBindings.contains(ancestor.getPath());
281
					ancestor = ancestor.getParent();
282
				}
283
				
284
				if (result) {
285
					// cache the original category for quicker results on the
286
					//    next constraint that it includes
287
					bindCategory(category.getPath());
288
				}
289
			}
290
		}
291
		
292
		return result;
293
	}
264
	}
294
265
295
	/**
266
	/**
296
	 * Binds a constraint to me.
267
	 * Adds a constraint exclusion binding to me.
297
	 * 
268
	 * 
298
	 * @param constraintId the ID of a constraint that is to be bound to me
269
	 * @param constraintId the ID of a constraint that is to be excluded from me
299
	 */
270
	 */
300
	void bindConstraint(String constraintId) {
271
	void excludeConstraint(String constraintId) {
301
		constraintBindings.add(constraintId);
272
		filter = filter.excludeConstraint(constraintId);
302
	}
273
	}
303
274
304
	/**
275
	/**
305
	 * Binds a constraint category to me.
276
	 * Adds a constraint category inclusion to me.
306
	 * 
277
	 * 
307
	 * @param categoryId the qualified ID (path) of a constraint category that
278
	 * @param categoryId the qualified ID (path) of a constraint category that
308
	 *     is to be bound to me
279
	 *     is to be included in me
309
	 */
280
	 */
310
	void bindCategory(String categoryId) {
281
	void includeCategory(String categoryId) {
311
		categoryBindings.add(categoryId);
282
		filter = filter.includeCategory(categoryId);
283
	}
284
285
	/**
286
	 * Adds a constraint category exclusion to me.
287
	 * 
288
	 * @param categoryId
289
	 *            the qualified ID (path) of a constraint category that is to be
290
	 *            excluded from me
291
	 */
292
	void excludeCategory(String categoryId) {
293
		filter = filter.excludeCategory(categoryId);
294
	}
295
296
	/**
297
	 * Adds a client-context extension to me.
298
	 * 
299
	 * @param clientContextID
300
	 *            a client-context to extend
301
	 */
302
	void extendClientContext(String clientContextID) {
303
		filter = filter.extendClientContext(clientContextID);
312
	}
304
	}
313
305
314
	/**
306
	/**
Lines 332-335 Link Here
332
	public String toString() {
324
	public String toString() {
333
		return "ClientContext[" + getId() + ']'; //$NON-NLS-1$
325
		return "ClientContext[" + getId() + ']'; //$NON-NLS-1$
334
	}
326
	}
327
	
328
	
329
	/**
330
	 * A chain-structured constraint-binding filter. Filters are chained in the
331
	 * order in which they are parsed from the extension point. The head of the
332
	 * filter chain applies its filter and, if it doesn't find any match,
333
	 * delegates down the chain. The chain is terminated by the {@link #NULL}
334
	 * filter, which always excludes the constraint.
335
	 * 
336
	 * @author Christian W. Damus (cdamus)
337
	 */
338
	private static class BindingFilter {
339
340
		private BindingFilter next;
341
342
		/** A filter that excludes every constraint. */
343
		static final BindingFilter NULL = new BindingFilter() {
344
345
			boolean getBinding(IConstraintDescriptor constraint) {
346
				return false;
347
			}
348
		};
349
350
		/**
351
		 * Queries whether the specified constraint is definitely included (
352
		 * <code>true</code>) or excluded (<code>false</code>) from the client
353
		 * context. If I don't have definitive knowledge of this constraint, I
354
		 * delegate to the next in the chain.
355
		 * 
356
		 * @param constraint
357
		 *            a constraint descriptor
358
		 * @return whether the constraint is included
359
		 */
360
		boolean getBinding(IConstraintDescriptor constraint) {
361
			return isExcluded(constraint)
362
				? false
363
				: isIncluded(constraint)
364
					? true
365
					: next().getBinding(constraint);
366
		}
367
368
		/**
369
		 * Queries whether I know that a constraint is included.
370
		 * 
371
		 * @param constraint
372
		 *            a constraint descriptor
373
		 * @return <code>true</code> if the constraint is included, or
374
		 *         <code>false</code> if I do not know
375
		 */
376
		boolean isExcluded(IConstraintDescriptor constraint) {
377
			return false;
378
		}
379
380
		/**
381
		 * Queries whether I know that a constraint is excluded.
382
		 * 
383
		 * @param constraint
384
		 *            a constraint descriptor
385
		 * @return <code>true</code> if the constraint is excluded, or
386
		 *         <code>false</code> if I do not know
387
		 */
388
		boolean isIncluded(IConstraintDescriptor constraint) {
389
			return false;
390
		}
391
392
		/**
393
		 * Obtains the next filter in my chain.
394
		 * 
395
		 * @return my next, or <code>null</code> if I am the end of the chain
396
		 */
397
		BindingFilter next() {
398
			return next;
399
		}
400
401
		/**
402
		 * Assigns my next filter.
403
		 * 
404
		 * @param next
405
		 *            my new next
406
		 */
407
		void setNext(BindingFilter next) {
408
			this.next = next;
409
		}
410
411
		/**
412
		 * Obtains a filter, chaining me, that definitively includes the
413
		 * specified category and all of its constraints and sub-categories. The
414
		 * result may be optimized to be myself augmented with this category, if
415
		 * I am a filter of the appropriate kind. Or, the result may be a new
416
		 * filter chain.
417
		 * 
418
		 * @param category
419
		 *            a category to include
420
		 * 
421
		 * @return a filter that includes the category
422
		 */
423
		BindingFilter includeCategory(String category) {
424
			CategoryInclusion result = new CategoryInclusion(category);
425
			result.setNext(this);
426
			return result;
427
		}
428
429
		/**
430
		 * Obtains a filter, chaining me, that definitively excludes the
431
		 * specified category and all of its constraints and sub-categories. The
432
		 * result may be optimized to be myself augmented with this category, if
433
		 * I am a filter of the appropriate kind. Or, the result may be a new
434
		 * filter chain.
435
		 * 
436
		 * @param category
437
		 *            a category to exclude
438
		 * 
439
		 * @return a filter that excludes the category
440
		 */
441
		BindingFilter excludeCategory(String category) {
442
			CategoryExclusion result = new CategoryExclusion(category);
443
			result.setNext(this);
444
			return result;
445
		}
446
447
		/**
448
		 * Obtains a filter, chaining me, that definitively includes the
449
		 * specified constraint. The result may be optimized to be myself
450
		 * augmented with this constraint, if I am a filter of the appropriate
451
		 * kind. Or, the result may be a new filter chain.
452
		 * 
453
		 * @param constraint
454
		 *            a constraint to include
455
		 * 
456
		 * @return a filter that includes the constraint
457
		 */
458
		BindingFilter includeConstraint(String constraint) {
459
			ConstraintInclusion result = new ConstraintInclusion(constraint);
460
			result.setNext(this);
461
			return result;
462
		}
463
464
		/**
465
		 * Obtains a filter, chaining me, that definitively excludes the
466
		 * specified constraint. The result may be optimized to be myself
467
		 * augmented with this constraint, if I am a filter of the appropriate
468
		 * kind. Or, the result may be a new filter chain.
469
		 * 
470
		 * @param constraint
471
		 *            a constraint to exclude
472
		 * 
473
		 * @return a filter that excludes the constraint
474
		 */
475
		BindingFilter excludeConstraint(String constraint) {
476
			ConstraintExclusion result = new ConstraintExclusion(constraint);
477
			result.setNext(this);
478
			return result;
479
		}
480
481
		/**
482
		 * Obtains a filter, chaining me, that inherits the constraints bound to
483
		 * the specified client-context. The result may be optimized to be
484
		 * myself myself augmented with this client-context, if I am a filter of
485
		 * the appropriate kind. Or, the result may be a new filter chain.
486
		 * 
487
		 * @param clientContext
488
		 *            a client-context to extend
489
		 * 
490
		 * @return a filter that extends the client-context
491
		 */
492
		BindingFilter extendClientContext(String clientContext) {
493
			ContextExtension result = new ContextExtension(clientContext);
494
			result.setNext(this);
495
			return result;
496
		}
497
	}
498
499
	/**
500
	 * A binding filter that definitively includes one or more constraints.
501
	 * 
502
	 * @author Christian W. Damus (cdamus)
503
	 */
504
	private static class ConstraintInclusion
505
			extends BindingFilter {
506
507
		private final Set<String> constraints = new java.util.HashSet<String>();
508
509
		ConstraintInclusion(String constraint) {
510
			constraints.add(constraint);
511
		}
512
513
		@Override
514
		boolean isIncluded(IConstraintDescriptor constraint) {
515
			return constraints.contains(constraint.getId());
516
		}
517
518
		@Override
519
		BindingFilter includeConstraint(String constraint) {
520
			constraints.add(constraint);
521
			return this;
522
		}
523
	}
524
525
	/**
526
	 * A binding filter that definitively excludes one or more constraints.
527
	 * 
528
	 * @author Christian W. Damus (cdamus)
529
	 */
530
	private static class ConstraintExclusion
531
			extends BindingFilter {
532
533
		private final Set<String> constraints = new java.util.HashSet<String>();
534
535
		ConstraintExclusion(String constraint) {
536
			constraints.add(constraint);
537
		}
538
539
		@Override
540
		boolean isExcluded(IConstraintDescriptor constraint) {
541
			return constraints.contains(constraint.getId());
542
		}
543
544
		@Override
545
		BindingFilter excludeConstraint(String constraint) {
546
			constraints.add(constraint);
547
			return this;
548
		}
549
	}
550
551
	/**
552
	 * A binding filter that definitively includes one or more categories.
553
	 * 
554
	 * @author Christian W. Damus (cdamus)
555
	 */
556
	private static class CategoryInclusion
557
			extends BindingFilter {
558
559
		private final CategorySet categories;
560
561
		CategoryInclusion(String category) {
562
			categories = new CategorySet(category);
563
		}
564
565
		@Override
566
		boolean isIncluded(IConstraintDescriptor constraint) {
567
			return categories.containsAny(constraint.getCategories());
568
		}
569
570
		@Override
571
		BindingFilter includeCategory(String category) {
572
			categories.add(category);
573
			return this;
574
		}
575
	}
576
577
	/**
578
	 * A binding filter that definitively excludes one or more categories.
579
	 * 
580
	 * @author Christian W. Damus (cdamus)
581
	 */
582
	private static class CategoryExclusion
583
			extends BindingFilter {
584
585
		private final CategorySet categories;
586
587
		CategoryExclusion(String category) {
588
			categories = new CategorySet(category);
589
		}
590
591
		@Override
592
		boolean isExcluded(IConstraintDescriptor constraint) {
593
			return categories.containsAny(constraint.getCategories());
594
		}
595
596
		@Override
597
		BindingFilter excludeCategory(String category) {
598
			categories.add(category);
599
			return this;
600
		}
601
	}
602
603
	private static final class CategorySet {
604
605
		private final Set<String> categories = new java.util.HashSet<String>();
606
607
		CategorySet(String category) {
608
			categories.add(category);
609
		}
610
611
		boolean containsAny(Collection<? extends Category> categories) {
612
			boolean result = false;
613
614
			for (Category next : categories) {
615
				if (contains(next)) {
616
					result = true;
617
					break;
618
				}
619
			}
620
621
			return result;
622
		}
623
624
		boolean contains(Category category) {
625
			boolean result = false;
626
627
			String path = category.getPath();
628
			result = categories.contains(path);
629
630
			if (!result) {
631
				// search the ancestors
632
				Category ancestor = category.getParent();
633
634
				while ((ancestor != null) && !result) {
635
					result = categories.contains(ancestor.getPath());
636
					ancestor = ancestor.getParent();
637
				}
638
639
				if (result) {
640
					// cache the original category for quicker results on the
641
					// next category that it contains
642
					add(path);
643
				}
644
			}
645
646
			return result;
647
		}
648
649
		void add(String category) {
650
			categories.add(category);
651
		}
652
	}
653
654
	/**
655
	 * A binding filter that inherits the bindings of another context.
656
	 * 
657
	 * @author Christian W. Damus (cdamus)
658
	 */
659
	private static class ContextExtension
660
			extends BindingFilter {
661
662
		private final Set<String> extendedContextIDs = new java.util.HashSet<String>();
663
664
		private volatile Set<ClientContext> extendedContexts;
665
666
		ContextExtension(String clientContext) {
667
			extendedContextIDs.add(clientContext);
668
		}
669
670
		@Override
671
		boolean isIncluded(IConstraintDescriptor constraint) {
672
			if (extendedContexts == null) {
673
				// do this lazily because we don't know the order in which
674
				// client-contexts will be discovered in the extension registry
675
				ClientContextManager mgr = ClientContextManager.getInstance();
676
				Set<ClientContext> contexts = new java.util.HashSet<ClientContext>();
677
678
				synchronized (extendedContextIDs) {
679
					for (String next : extendedContextIDs) {
680
						contexts
681
							.add((ClientContext) mgr.getClientContext(next));
682
					}
683
					
684
					extendedContexts = contexts;
685
				}
686
			}
687
688
			for (ClientContext extended : extendedContexts) {
689
				if (extended.includes(constraint)) {
690
					return true;
691
				}
692
			}
693
694
			return false;
695
		}
696
697
		@Override
698
		BindingFilter extendClientContext(String clientContext) {
699
			synchronized (extendedContextIDs) {
700
				extendedContexts = null; // purge
701
				extendedContextIDs.add(clientContext);
702
			}
703
704
			return this;
705
		}
706
	}
335
}
707
}
(-)schema/constraintBindings.exsd (-40 / +100 lines)
Lines 1-10 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.emf.validation">
3
<schema targetNamespace="org.eclipse.emf.validation" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appinfo>
6
         <meta.schema plugin="org.eclipse.emf.validation" id="constraintBindings" name="EMF Validation Constraint Bindings"/>
6
         <meta.schema plugin="org.eclipse.emf.validation" id="constraintBindings" name="EMF Validation Constraint Bindings"/>
7
      </appInfo>
7
      </appinfo>
8
      <documentation>
8
      <documentation>
9
         This extension point allows clients of the EMF Validation
9
         This extension point allows clients of the EMF Validation
10
framework to define &quot;client contexts&quot; that describe the
10
framework to define &quot;client contexts&quot; that describe the
Lines 17-22 Link Here
17
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
17
   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
18
18
19
   <element name="extension">
19
   <element name="extension">
20
      <annotation>
21
         <appinfo>
22
            <meta.element />
23
         </appinfo>
24
      </annotation>
20
      <complexType>
25
      <complexType>
21
         <sequence>
26
         <sequence>
22
            <element ref="clientContext" minOccurs="0" maxOccurs="unbounded"/>
27
            <element ref="clientContext" minOccurs="0" maxOccurs="unbounded"/>
Lines 41-49 Link Here
41
               <documentation>
46
               <documentation>
42
                  
47
                  
43
               </documentation>
48
               </documentation>
44
               <appInfo>
49
               <appinfo>
45
                  <meta.attribute translatable="true"/>
50
                  <meta.attribute translatable="true"/>
46
               </appInfo>
51
               </appinfo>
47
            </annotation>
52
            </annotation>
48
         </attribute>
53
         </attribute>
49
      </complexType>
54
      </complexType>
Lines 51-59 Link Here
51
56
52
   <element name="clientContext">
57
   <element name="clientContext">
53
      <annotation>
58
      <annotation>
54
         <appInfo>
59
         <appinfo>
55
            <meta.element labelAttribute="id"/>
60
            <meta.element labelAttribute="id"/>
56
         </appInfo>
61
         </appinfo>
57
         <documentation>
62
         <documentation>
58
            &lt;p&gt;
63
            &lt;p&gt;
59
Definition of a client context, representing a class of
64
Definition of a client context, representing a class of
Lines 110-118 Link Here
110
                  Identifies a class implementing the &lt;code&gt;org.eclipse.emf.validation.internal.model.IClientSelector&lt;/code&gt;
115
                  Identifies a class implementing the &lt;code&gt;org.eclipse.emf.validation.internal.model.IClientSelector&lt;/code&gt;
111
internal API interface.
116
internal API interface.
112
               </documentation>
117
               </documentation>
113
               <appInfo>
118
               <appinfo>
114
                  <meta.attribute kind="java" basedOn="org.eclipse.emf.validation.internal.model.IClientSelector"/>
119
                  <meta.attribute kind="java" basedOn="org.eclipse.emf.validation.internal.model.IClientSelector"/>
115
               </appInfo>
120
               </appinfo>
116
            </annotation>
121
            </annotation>
117
         </attribute>
122
         </attribute>
118
      </complexType>
123
      </complexType>
Lines 120-128 Link Here
120
125
121
   <element name="binding">
126
   <element name="binding">
122
      <annotation>
127
      <annotation>
123
         <appInfo>
128
         <appinfo>
124
            <meta.element labelAttribute="context"/>
129
            <meta.element labelAttribute="context"/>
125
         </appInfo>
130
         </appinfo>
126
         <documentation>
131
         <documentation>
127
            &lt;p&gt;
132
            &lt;p&gt;
128
Declares a binding between a client context and one or more
133
Declares a binding between a client context and one or more
Lines 131-136 Link Here
131
&lt;/p&gt;
136
&lt;/p&gt;
132
&lt;p&gt;
137
&lt;p&gt;
133
The constraints to be bound may be specified by either:
138
The constraints to be bound may be specified by either:
139
&lt;/p&gt;
134
&lt;ul&gt;
140
&lt;ul&gt;
135
  &lt;li&gt;the &lt;code&gt;constraint&lt;/code&gt; attribute, to reference
141
  &lt;li&gt;the &lt;code&gt;constraint&lt;/code&gt; attribute, to reference
136
      a single constraint&lt;/li&gt;
142
      a single constraint&lt;/li&gt;
Lines 141-153 Link Here
141
      and/or &lt;code&gt;&amp;lt;category&amp;gt;&lt;/code&gt; elements to
147
      and/or &lt;code&gt;&amp;lt;category&amp;gt;&lt;/code&gt; elements to
142
      reference multiple constraints and/or categories&lt;/li&gt;
148
      reference multiple constraints and/or categories&lt;/li&gt;
143
&lt;/ul&gt;
149
&lt;/ul&gt;
150
&lt;p&gt;
151
Since the 1.3 release, selective exclusion of constraints and sub-categories that are contained by included categories is supported.  Within a &lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt; element, ordering of inclusion and exclusion elements is significant:  they are processed in the order in which they are declared in the extension.  However, the order of inclusions and exclusions in separate bindings for the same context is undefined.
144
&lt;/p&gt;
152
&lt;/p&gt;
145
         </documentation>
153
         </documentation>
146
      </annotation>
154
      </annotation>
147
      <complexType>
155
      <complexType>
148
         <sequence>
156
         <sequence>
149
            <element ref="constraint" minOccurs="0" maxOccurs="unbounded"/>
157
            <choice minOccurs="0" maxOccurs="unbounded">
150
            <element ref="category" minOccurs="0" maxOccurs="unbounded"/>
158
               <element ref="category"/>
159
               <element ref="constraint"/>
160
               <element ref="extendClientContext"/>
161
               <element ref="excludeCategory"/>
162
               <element ref="excludeConstraint"/>
163
            </choice>
151
         </sequence>
164
         </sequence>
152
         <attribute name="context" type="string" use="required">
165
         <attribute name="context" type="string" use="required">
153
            <annotation>
166
            <annotation>
Lines 185-193 Link Here
185
198
186
   <element name="constraint">
199
   <element name="constraint">
187
      <annotation>
200
      <annotation>
188
         <appInfo>
201
         <appinfo>
189
            <meta.element labelAttribute="ref"/>
202
            <meta.element labelAttribute="ref"/>
190
         </appInfo>
203
         </appinfo>
191
         <documentation>
204
         <documentation>
192
            Includes a constraint in a client context
205
            Includes a constraint in a client context
193
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.
206
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.
Lines 209-217 Link Here
209
222
210
   <element name="category">
223
   <element name="category">
211
      <annotation>
224
      <annotation>
212
         <appInfo>
225
         <appinfo>
213
            <meta.element labelAttribute="ref"/>
226
            <meta.element labelAttribute="ref"/>
214
         </appInfo>
227
         </appinfo>
215
         <documentation>
228
         <documentation>
216
            Includes a constraint category in a client context
229
            Includes a constraint category in a client context
217
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.  All of the referenced
230
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.  All of the referenced
Lines 233-251 Link Here
233
      </complexType>
246
      </complexType>
234
   </element>
247
   </element>
235
248
249
   <element name="extendClientContext">
250
      <annotation>
251
         <documentation>
252
            Since 1.3.  References a client-context that the bound context extends.  Conceptually, this declares that objects matching the referenced context also match my bound context.  In practice, this means that my bound context inherits all of the constraint bindings from the referenced context.
253
&lt;br/&gt;&lt;br/&gt;
254
Of course, subsequent exclusions can filter out unwanted constraints, too.  &lt;b&gt;Note&lt;/b&gt;, also, that this effects a dependency on the referenced client context and also imposes a partial ordering on the bindings.  All of the bindings contributed to the referenced context are applied before any inclusions or exclusions that follow the &lt;code&gt;&amp;lt;extendClientContext&amp;gt;&lt;/code&gt; element in the current &lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.
255
         </documentation>
256
      </annotation>
257
      <complexType>
258
         <attribute name="ref" type="string" use="required">
259
            <annotation>
260
               <documentation>
261
                  References the ID of a client-context to extend.  All constraint bindings of the client context are inherited by this binding.
262
               </documentation>
263
            </annotation>
264
         </attribute>
265
      </complexType>
266
   </element>
267
268
   <element name="excludeCategory">
269
      <annotation>
270
         <documentation>
271
            Since 1.3.  Excludes a constraint category from a client context
272
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;.  All of the referenced
273
category&apos;s constraints and those of any sub-categories
274
(recursively) are excluded.  This is useful when including some parent category, to filter out selective sub-categories.  Not only is it simpler than explicitly including all of the desired sub-categories, but it ensures that sub-categories that are added later will be included implicitly.
275
         </documentation>
276
      </annotation>
277
      <complexType>
278
         <attribute name="ref" type="string" use="required">
279
            <annotation>
280
               <documentation>
281
                  References the fully-qualified ID of a constraint category to
282
exclude from the client context. The category ID does not
283
necessarily include its contributing plug-in ID, but is a
284
path reflecting the hierarchical structure of categories.
285
               </documentation>
286
            </annotation>
287
         </attribute>
288
      </complexType>
289
   </element>
290
291
   <element name="excludeConstraint">
292
      <annotation>
293
         <documentation>
294
            Since 1.3.  Excludes a constraint from a client context
295
&lt;code&gt;&amp;lt;binding&amp;gt;&lt;/code&gt;. This is useful when including some parent category, to filter out selective constraints cointained within it.  Not only is it simpler than explicitly including all of the desired constraints and sub-categories, but it ensures that constraints and sub-categories that are added later will be included implicitly.
296
         </documentation>
297
      </annotation>
298
      <complexType>
299
         <attribute name="ref" type="string" use="required">
300
            <annotation>
301
               <documentation>
302
                  References the fully-qualified ID of a constraint to exclude
303
from the client context.  The ID includes the constraint&apos;s
304
contributing plug-in ID, if it is not explicit in the XML
305
definition of the constraint.
306
               </documentation>
307
            </annotation>
308
         </attribute>
309
      </complexType>
310
   </element>
311
236
   <annotation>
312
   <annotation>
237
      <appInfo>
313
      <appinfo>
238
         <meta.section type="since"/>
314
         <meta.section type="since"/>
239
      </appInfo>
315
      </appinfo>
240
      <documentation>
316
      <documentation>
241
         1.0
317
         1.0
242
      </documentation>
318
      </documentation>
243
   </annotation>
319
   </annotation>
244
320
245
   <annotation>
321
   <annotation>
246
      <appInfo>
322
      <appinfo>
247
         <meta.section type="examples"/>
323
         <meta.section type="examples"/>
248
      </appInfo>
324
      </appinfo>
249
      <documentation>
325
      <documentation>
250
         &lt;p&gt;
326
         &lt;p&gt;
251
Example of a context which includes &lt;code&gt;EObjects&lt;/code&gt; in *.library resources only, not
327
Example of a context which includes &lt;code&gt;EObjects&lt;/code&gt; in *.library resources only, not
Lines 291-320 Link Here
291
      </documentation>
367
      </documentation>
292
   </annotation>
368
   </annotation>
293
369
294
   <annotation>
295
      <appInfo>
296
         <meta.section type="apiInfo"/>
297
      </appInfo>
298
      <documentation>
299
         
300
      </documentation>
301
   </annotation>
302
370
303
   <annotation>
304
      <appInfo>
305
         <meta.section type="implementation"/>
306
      </appInfo>
307
      <documentation>
308
         
309
      </documentation>
310
   </annotation>
311
371
312
   <annotation>
372
   <annotation>
313
      <appInfo>
373
      <appinfo>
314
         <meta.section type="copyright"/>
374
         <meta.section type="copyright"/>
315
      </appInfo>
375
      </appinfo>
316
      <documentation>
376
      <documentation>
317
         Copyright (c) 2005  IBM Corporation and others.&lt;br&gt;
377
         Copyright (c) 2005, 2008  IBM Corporation, Zeligsoft Inc., and others.&lt;br&gt;
318
 All rights reserved. This program and the accompanying materials 
378
 All rights reserved. This program and the accompanying materials 
319
 are made available under the terms of the Eclipse Public License v1.0 
379
 are made available under the terms of the Eclipse Public License v1.0 
320
 which accompanies this distribution, and is available at 
380
 which accompanies this distribution, and is available at 

Return to bug 249496