Bug 239947: Annotation-based facet scope.
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/AllTests.java b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/AllTests.java
index 8c0d4e5..83da7b9 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/AllTests.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/AllTests.java
@@ -19,6 +19,7 @@
 import org.eclipse.tigerstripe.workbench.base.test.builders.TestBasicModelProjectAuditor;
 import org.eclipse.tigerstripe.workbench.base.test.facet.BasicFacetTest;
 import org.eclipse.tigerstripe.workbench.base.test.facet.TestFacetResolution;
+import org.eclipse.tigerstripe.workbench.base.test.facet.TestFacetWithAnnotations;
 import org.eclipse.tigerstripe.workbench.base.test.generation.TestM0DeployUndeploy;
 import org.eclipse.tigerstripe.workbench.base.test.generation.TestM1Generation;
 import org.eclipse.tigerstripe.workbench.base.test.generation.TestProjectGenerationBasics;
@@ -68,6 +69,7 @@
 		// Facet Tests
 		suite.addTestSuite(BasicFacetTest.class);
 		suite.addTestSuite(TestFacetResolution.class);
+		suite.addTestSuite(TestFacetWithAnnotations.class);
 
 		// Metamodel migration test
 //		suite.addTestSuite(TestArtifactRefactor.class);
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/facet/TestFacetWithAnnotations.java b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/facet/TestFacetWithAnnotations.java
new file mode 100644
index 0000000..2a765f5
--- /dev/null
+++ b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/facet/TestFacetWithAnnotations.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Cisco Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Cisco Systems, Inc. - erdillon
+ *******************************************************************************/
+package org.eclipse.tigerstripe.workbench.base.test.facet;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.tigerstripe.annotation.core.Annotation;
+import org.eclipse.tigerstripe.annotation.core.AnnotationPlugin;
+import org.eclipse.tigerstripe.annotation.core.AnnotationType;
+import org.eclipse.tigerstripe.workbench.base.test.utils.ModelProjectHelper;
+import org.eclipse.tigerstripe.workbench.internal.InternalTigerstripeCore;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.IContractSegment;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.IFacetReference;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeAnnotationPattern;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopePattern;
+import org.eclipse.tigerstripe.workbench.model.deprecated_.IAbstractArtifact;
+import org.eclipse.tigerstripe.workbench.model.deprecated_.IManagedEntityArtifact;
+import org.eclipse.tigerstripe.workbench.project.ITigerstripeModelProject;
+
+public class TestFacetWithAnnotations extends TestCase {
+
+	private ITigerstripeModelProject project;
+
+	@Override
+	protected void setUp() throws Exception {
+		project = ModelProjectHelper.createModelProject(
+				"TestFacetWithAnnotations", true);
+
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		if (project != null && project.exists())
+			project.delete(true, null);
+	}
+
+	public void testDefineIncludeAnnotationPatterns() throws Exception {
+		testDefineAnnotationPatterns("includeFacet", ISegmentScope.INCLUDES);
+	}
+
+	public void testDefineExcludeAnnotationPatterns() throws Exception {
+		testDefineAnnotationPatterns("excludeFacet", ISegmentScope.EXCLUDES);
+	}
+
+	/**
+	 * Include M2 by Annotation. See it's the only one in facet
+	 * 
+	 * @throws Exception
+	 */
+	public void testResolveFacetWithAnnotationInclude() throws Exception {
+		IProject iProject = (IProject) project.getAdapter(IProject.class);
+		IFile facetFile = iProject.getFile("facetWithAnnotationInclude");
+		IContractSegment facet = InternalTigerstripeCore.createModelFacet(
+				facetFile, null);
+		ISegmentScope scope = facet.getISegmentScope();
+
+		AnnotationType[] annotationTypes = AnnotationPlugin.getManager()
+				.getTypes();
+
+		ScopeAnnotationPattern pattern = new ISegmentScope.ScopeAnnotationPattern();
+		pattern.type = ISegmentScope.INCLUDES;
+		pattern.annotationID = annotationTypes[1].getId();
+		scope.addAnnotationPattern(pattern);
+		facet.doSave();
+
+		IManagedEntityArtifact m1 = (IManagedEntityArtifact) project
+				.getArtifactManagerSession().getArtifactByFullyQualifiedName(
+						ModelProjectHelper.M1);
+		IManagedEntityArtifact m2 = (IManagedEntityArtifact) project
+				.getArtifactManagerSession().getArtifactByFullyQualifiedName(
+						ModelProjectHelper.M2);
+		Assert.assertNotNull(m1);
+		EObject obj = annotationTypes[1].createInstance();
+		Annotation ann = AnnotationPlugin.getManager().addAnnotation(m2, obj);
+		m2.saveAnnotation(ann);
+
+		IFacetReference ref = project.makeFacetReference(facetFile
+				.getProjectRelativePath().toOSString());
+
+		project.setActiveFacet(ref, null);
+
+		Assert.assertTrue(!m1.isInActiveFacet());
+		Assert.assertTrue(m2.isInActiveFacet());
+	}
+
+	/**
+	 * Exclude AS1 by annotation and see that M3 is not in facet anymore
+	 * 
+	 * @throws Exception
+	 */
+	public void testResolveFacetWithAnnotationExclude() throws Exception {
+		IProject iProject = (IProject) project.getAdapter(IProject.class);
+		IFile facetFile = iProject.getFile("facetWithAnnotationExclude");
+		IContractSegment facet = InternalTigerstripeCore.createModelFacet(
+				facetFile, null);
+		ISegmentScope scope = facet.getISegmentScope();
+
+		AnnotationType[] annotationTypes = AnnotationPlugin.getManager()
+				.getTypes();
+
+		ScopeAnnotationPattern pattern = new ISegmentScope.ScopeAnnotationPattern();
+		pattern.type = ISegmentScope.EXCLUDES;
+		pattern.annotationID = annotationTypes[1].getId();
+
+		ScopePattern pat = new ISegmentScope.ScopePattern();
+		pat.pattern = ModelProjectHelper.M1;
+		scope.addPattern(pat);
+		scope.addAnnotationPattern(pattern);
+		facet.doSave();
+
+		IManagedEntityArtifact m1 = (IManagedEntityArtifact) project
+				.getArtifactManagerSession().getArtifactByFullyQualifiedName(
+						ModelProjectHelper.M1);
+		IManagedEntityArtifact m2 = (IManagedEntityArtifact) project
+				.getArtifactManagerSession().getArtifactByFullyQualifiedName(
+						ModelProjectHelper.M2);
+
+		IManagedEntityArtifact m3 = (IManagedEntityArtifact) project
+				.getArtifactManagerSession().getArtifactByFullyQualifiedName(
+						ModelProjectHelper.M3);
+
+		IAbstractArtifact as1 = project.getArtifactManagerSession()
+				.getArtifactByFullyQualifiedName(ModelProjectHelper.AS1);
+
+		Assert.assertNotNull(as1);
+
+		EObject obj = annotationTypes[1].createInstance();
+		Annotation ann = AnnotationPlugin.getManager().addAnnotation(as1, obj);
+		AnnotationPlugin.getManager().save(ann);
+
+		IFacetReference ref = project.makeFacetReference(facetFile
+				.getProjectRelativePath().toOSString());
+
+		project.setActiveFacet(ref, null);
+
+		Assert.assertTrue(m1.isInActiveFacet());
+		Assert.assertTrue(m2.isInActiveFacet());
+		Assert.assertTrue(!m3.isInActiveFacet());
+	}
+
+	private void testDefineAnnotationPatterns(String facetName, int type)
+			throws Exception {
+		IProject iProject = (IProject) project.getAdapter(IProject.class);
+		IFile facetFile = iProject.getFile(facetName);
+		IContractSegment facet = InternalTigerstripeCore.createModelFacet(
+				facetFile, null);
+		ISegmentScope scope = facet.getISegmentScope();
+
+		AnnotationType[] annotationTypes = AnnotationPlugin.getManager()
+				.getTypes();
+
+		ScopeAnnotationPattern pattern = new ISegmentScope.ScopeAnnotationPattern();
+		pattern.type = type;
+		pattern.annotationID = annotationTypes[0].getId();
+		scope.addAnnotationPattern(pattern);
+		facet.doSave();
+
+		IFacetReference ref = project.makeFacetReference(facetFile
+				.getProjectRelativePath().toOSString());
+
+		IContractSegment resolvedFacet = ref.resolve();
+		ScopeAnnotationPattern[] resolvedPatterns = resolvedFacet
+				.getISegmentScope().getAnnotationPatterns();
+
+		Assert.assertTrue(resolvedPatterns.length == 1);
+		Assert.assertTrue(resolvedPatterns[0].type == type);
+		Assert.assertTrue(resolvedPatterns[0].annotationID
+				.equals(annotationTypes[0].getId()));
+	}
+
+}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/utils/ModelProjectHelper.java b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/utils/ModelProjectHelper.java
index 9782ea2..f4e8a44 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/utils/ModelProjectHelper.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base.test/src/org/eclipse/tigerstripe/workbench/base/test/utils/ModelProjectHelper.java
@@ -31,8 +31,13 @@
 	public final static String AS1 = "com.mycompany.AS1";
 
 	/**
-	 * Creates a model project with the following content - 2 Managed entities
-	 * (com.mycompany.M1, com.mycompany.M2)
+	 * Creates a model project with the following content 
+	 * 
+	 *                   AS1
+	 *           AC1---------->M3
+	 *            |
+	 *      M1-------->M2
+	 *      
 	 * 
 	 * @param projectName
 	 * @return
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/api/contract/segment/ISegmentScope.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/api/contract/segment/ISegmentScope.java
index 765aa43..5d9f2c1 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/api/contract/segment/ISegmentScope.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/api/contract/segment/ISegmentScope.java
@@ -68,6 +68,29 @@
 		}
 	}
 
+	public class ScopeAnnotationPattern {
+		public int type;
+
+		public String annotationID;
+
+		public ScopeAnnotationPattern() {
+
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (obj instanceof ScopeAnnotationPattern) {
+				ScopeAnnotationPattern other = (ScopeAnnotationPattern) obj;
+				if (other.annotationID == null)
+					return false;
+				return other.type == type
+						&& other.annotationID.equals(annotationID);
+			}
+			return false;
+		}
+
+	}
+
 	public class ScopeStereotypePattern {
 
 		public int type = INCLUDES;
@@ -107,6 +130,8 @@
 
 	public ScopeStereotypePattern[] getStereotypePatterns();
 
+	public ScopeAnnotationPattern[] getAnnotationPatterns();
+
 	/**
 	 * Returns all the ScopePatterns of the specified type
 	 * 
@@ -125,4 +150,10 @@
 
 	public void removeStereotypePattern(ScopeStereotypePattern pattern);
 
+	public ScopeAnnotationPattern[] getAnnotationPatterns(int type);
+
+	public void addAnnotationPattern(ScopeAnnotationPattern pattern);
+
+	public void removeAnnotationPattern(ScopeAnnotationPattern pattern);
+
 }
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/generator/PluggablePluginProjectAuditor.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/generator/PluggablePluginProjectAuditor.java
index 6466008..68bafbb 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/generator/PluggablePluginProjectAuditor.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/generator/PluggablePluginProjectAuditor.java
@@ -38,6 +38,7 @@
 import org.eclipse.tigerstripe.workbench.internal.BasePlugin;
 import org.eclipse.tigerstripe.workbench.internal.api.ITigerstripeConstants;
 import org.eclipse.tigerstripe.workbench.internal.builder.BuilderConstants;
+import org.eclipse.tigerstripe.workbench.internal.core.project.PluginProjectCreator;
 import org.eclipse.tigerstripe.workbench.model.deprecated_.IAbstractArtifact;
 import org.eclipse.tigerstripe.workbench.plugins.IPluginClasspathEntry;
 import org.eclipse.tigerstripe.workbench.plugins.IRule;
@@ -60,6 +61,7 @@
 	}
 
 	@Override
+	@SuppressWarnings("unchecked")
 	protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
 			throws CoreException {
 
@@ -257,7 +259,7 @@
 		// Associate Builder with Project
 		ICommand newCmd = description.newCommand();
 		newCmd.setBuilderName(BUILDER_ID);
-		List newCmds = new ArrayList();
+		List<ICommand> newCmds = new ArrayList<ICommand>();
 		newCmds.addAll(Arrays.asList(cmds));
 		newCmds.add(newCmd);
 		description.setBuildSpec((ICommand[]) newCmds
@@ -296,7 +298,7 @@
 			return;
 
 		// Remove builder from project
-		List newCmds = new ArrayList();
+		List<ICommand> newCmds = new ArrayList<ICommand>();
 		newCmds.addAll(Arrays.asList(cmds));
 		newCmds.remove(index);
 		description.setBuildSpec((ICommand[]) newCmds
@@ -327,16 +329,14 @@
 				if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY
 						&& entry.getEntryKind() != IClasspathEntry.CPE_VARIABLE) {
 					newEntryList.add(entry);
-				} else {
-					String entryP = entry.getPath().toOSString();
-					if (entry.getEntryKind() == IClasspathEntry.CPE_VARIABLE
-							&& (ITigerstripeConstants.EXTERNALAPI_LIB
-									.equals(entryP) || ITigerstripeConstants.EQUINOX_COMMON
-									.equals(entryP))) {
-						newEntryList.add(entry);
-					}
 				}
 			}
+
+			// then add the required ones
+			for (IClasspathEntry entry : PluginProjectCreator.REQUIRED_ENTRIES) {
+				newEntryList.add(entry);
+			}
+
 		} catch (JavaModelException e) {
 			BasePlugin.log(e);
 		}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/natures/TigerstripeProjectNature.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/natures/TigerstripeProjectNature.java
index f90580c..d6fedc7 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/natures/TigerstripeProjectNature.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/builder/natures/TigerstripeProjectNature.java
@@ -12,12 +12,7 @@
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectNature;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.tigerstripe.workbench.internal.BasePlugin;
 import org.eclipse.tigerstripe.workbench.internal.builder.BuilderConstants;
 import org.eclipse.tigerstripe.workbench.internal.builder.TigerstripeProjectAuditor;
 
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/ContractUtils.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/ContractUtils.java
index 95ca433..241b766 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/ContractUtils.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/ContractUtils.java
@@ -12,6 +12,7 @@
 
 import org.eclipse.tigerstripe.workbench.TigerstripeException;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeAnnotationPattern;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopePattern;
 import org.eclipse.tigerstripe.workbench.internal.core.util.RegExpFQNSetPred;
 
@@ -34,6 +35,14 @@
 			}
 		}
 
+		for (ScopeAnnotationPattern pattern : scope.getAnnotationPatterns()) {
+			if (pattern.type == ISegmentScope.INCLUDES) {
+				pred.addIsIncludedByAnnotationPattern(pattern.annotationID);
+			} else {
+				pred.addIsExcludedByAnnotationPattern(pattern.annotationID);
+			}
+		}
+
 		return pred;
 	}
 
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/predicate/FacetPredicate.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/predicate/FacetPredicate.java
index 7edbef2..6c6fe54 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/predicate/FacetPredicate.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/predicate/FacetPredicate.java
@@ -127,7 +127,7 @@
 	 * @param artifact
 	 * @return
 	 */
-	public boolean isExcludedByAnnotation(IStereotypeCapable capable)
+	public boolean isExcludedByStereotype(IStereotypeCapable capable)
 			throws TigerstripeException {
 
 		// Bug 1014
@@ -176,8 +176,7 @@
 		// that!
 
 		// Here we need to bypass the IArtifactManagerSession to ensure we are
-		// not going to
-		// hit an active facet
+		// not going to hit an active facet
 		Collection<IAbstractArtifact> artifacts = ((ArtifactManagerSessionImpl) tsProject
 				.getArtifactManagerSession()).getArtifactManager()
 				.getAllArtifacts(true, true, monitor);
@@ -190,7 +189,7 @@
 			// We only take the "Class Artifacts" not the relationships.
 			if (!(artifact instanceof IRelationship)
 					&& primaryPredicate.evaluate(artifact)
-					&& !isExcludedByAnnotation(artifact)) {
+					&& !isExcludedByStereotype(artifact)) {
 				baseArtifacts.add(artifact);
 				// for (IArtifact arti : artifact.getAncestors()) {
 				// baseArtifacts.add((IAbstractArtifact) arti);
@@ -243,7 +242,7 @@
 
 		// First of all ignore all that is excluded
 		if (primaryPredicate.isExcluded(artifact)
-				|| isExcludedByAnnotation(artifact)) {
+				|| isExcludedByStereotype(artifact)) {
 			TigerstripeRuntime.logTraceMessage("Excluding "
 					+ artifact.getFullyQualifiedName() + " per primary scope.");
 			return;
@@ -328,7 +327,7 @@
 		if (!ignoreParent && artifact.getExtendedArtifact() != null) {
 			IAbstractArtifact parent = artifact.getExtendedArtifact();
 			if (primaryPredicate.isExcluded(parent)
-					|| isExcludedByAnnotation(parent)) {
+					|| isExcludedByStereotype(parent)) {
 				IStatus error = new Status(IStatus.ERROR, BasePlugin
 						.getPluginId(),
 						"Inconsistent type hierarchy: Parent of "
@@ -349,7 +348,7 @@
 				scope.addAll(getAncestors(arti, false));
 			} else {
 				if (primaryPredicate.isExcluded(arti)
-						|| isExcludedByAnnotation(arti)) {
+						|| isExcludedByStereotype(arti)) {
 					IStatus error = new Status(IStatus.ERROR, BasePlugin
 							.getPluginId(),
 							"Inconsistent artifact: referenced artifact in "
@@ -407,12 +406,12 @@
 		Set<IAbstractArtifact> result = new HashSet<IAbstractArtifact>();
 
 		for (IField field : artifact.getFields()) {
-			if (!isExcludedByAnnotation(field)) {
+			if (!isExcludedByStereotype(field)) {
 				IType type = field.getType();
 				IAbstractArtifact arti = (IAbstractArtifact) type.getArtifact();
 				if (!type.isPrimitive() && arti != null
 						&& !(arti instanceof IPrimitiveTypeArtifact)
-						&& !isExcludedByAnnotation(arti)
+						&& !isExcludedByStereotype(arti)
 						&& !primaryPredicate.isExcluded(arti)) {
 					result.add(arti);
 					result.addAll(getAncestors(arti, false));
@@ -421,7 +420,7 @@
 		}
 
 		for (IMethod method : artifact.getMethods()) {
-			if (!isExcludedByAnnotation(method)) {
+			if (!isExcludedByStereotype(method)) {
 				// first the return type
 				IType returnType = method.getReturnType();
 				IAbstractArtifact arti = (IAbstractArtifact) returnType
@@ -429,9 +428,9 @@
 				if (!method.isVoid() && !returnType.isPrimitive()
 						&& arti != null
 						&& !(arti instanceof IPrimitiveTypeArtifact)) {
-					if ((isExcludedByAnnotation(arti) || primaryPredicate
+					if ((isExcludedByStereotype(arti) || primaryPredicate
 							.isExcluded(arti))
-							&& !isExcludedByAnnotation(method)) {
+							&& !isExcludedByStereotype(method)) {
 						IStatus error = new Status(IStatus.ERROR, BasePlugin
 								.getPluginId(),
 								"Inconsistent facet: the return type ("
@@ -442,9 +441,9 @@
 										+ " is explicitly excluded from facet.");
 						errors.add(error);
 					}
-					if (!isExcludedByAnnotation(arti)
+					if (!isExcludedByStereotype(arti)
 							&& !primaryPredicate.isExcluded(arti)
-							&& !isExcludedByAnnotation(method)) {
+							&& !isExcludedByStereotype(method)) {
 						result.add(arti);
 						result.addAll(getAncestors(arti, false));
 					}
@@ -459,9 +458,9 @@
 							&& !(argArti instanceof IPrimitiveTypeArtifact)) {
 
 						// Check for consistency of the facet
-						if ((isExcludedByAnnotation(argArti) || primaryPredicate
+						if ((isExcludedByStereotype(argArti) || primaryPredicate
 								.isExcluded(argArti))
-								&& !isExcludedByAnnotation(arg)) {
+								&& !isExcludedByStereotype(arg)) {
 							IStatus error = new Status(
 									IStatus.ERROR,
 									BasePlugin.getPluginId(),
@@ -477,9 +476,9 @@
 											+ " is explicitly excluded from facet.");
 							errors.add(error);
 						}
-						if (!isExcludedByAnnotation(argArti)
+						if (!isExcludedByStereotype(argArti)
 								&& !primaryPredicate.isExcluded(argArti)
-								&& !isExcludedByAnnotation(arg)) {
+								&& !isExcludedByStereotype(arg)) {
 							result.add(argArti);
 							result.addAll(getAncestors(argArti, false));
 						}
@@ -493,7 +492,7 @@
 							.getArtifactByFullyQualifiedName(
 									exc.getFullyQualifiedName(), true, true,
 									new NullProgressMonitor());
-					if (isExcludedByAnnotation(excArti)
+					if (isExcludedByStereotype(excArti)
 							|| primaryPredicate.isExcluded(excArti)) {
 						IStatus error = new Status(IStatus.ERROR, BasePlugin
 								.getPluginId(), "Inconsistent facet: the "
@@ -506,7 +505,7 @@
 								+ ") is explicitly excluded from facet.");
 						errors.add(error);
 					}
-					if (!isExcludedByAnnotation(excArti)
+					if (!isExcludedByStereotype(excArti)
 							&& !primaryPredicate.isExcluded(excArti)) {
 						result.add(excArti);
 						result.addAll(getAncestors(excArti, false));
@@ -552,7 +551,7 @@
 		ArtifactManager mgr = ((ArtifactManagerSessionImpl) session)
 				.getArtifactManager();
 
-		if (isExcludedByAnnotation(artifact)) {
+		if (isExcludedByStereotype(artifact)) {
 			TigerstripeRuntime.logTraceMessage("Excluding "
 					+ artifact.getFullyQualifiedName() + " by annotation.");
 			return result;
@@ -567,7 +566,7 @@
 				IAbstractArtifact arti = mgr.getArtifactByFullyQualifiedName(
 						fqn, true, true, new NullProgressMonitor());
 				if (arti != null && !primaryPredicate.isExcluded(arti)
-						&& !isExcludedByAnnotation(arti)) {
+						&& !isExcludedByStereotype(arti)) {
 					result.add(arti);
 					for (IAbstractArtifact a : arti.getAncestors()) {
 						result.add((IAbstractArtifact) a);
@@ -581,7 +580,7 @@
 				IAbstractArtifact arti = mgr.getArtifactByFullyQualifiedName(
 						fqn, true, true, new NullProgressMonitor());
 				if (arti != null && !primaryPredicate.isExcluded(arti)
-						&& !isExcludedByAnnotation(arti)) {
+						&& !isExcludedByStereotype(arti)) {
 					result.add(arti);
 					for (IAbstractArtifact a : arti.getAncestors()) {
 						result.add((IAbstractArtifact) a);
@@ -596,7 +595,7 @@
 				IAbstractArtifact arti = mgr.getArtifactByFullyQualifiedName(
 						fqn, true, true, new NullProgressMonitor());
 				if (arti != null && !primaryPredicate.isExcluded(arti)
-						&& !isExcludedByAnnotation(arti)) {
+						&& !isExcludedByStereotype(arti)) {
 					result.add(arti);
 					for (IAbstractArtifact a : arti.getAncestors()) {
 						result.add((IAbstractArtifact) a);
@@ -611,7 +610,7 @@
 				IAbstractArtifact arti = mgr.getArtifactByFullyQualifiedName(
 						fqn, true, true, new NullProgressMonitor());
 				if (arti != null && !primaryPredicate.isExcluded(arti)
-						&& !isExcludedByAnnotation(arti)) {
+						&& !isExcludedByStereotype(arti)) {
 					result.add(arti);
 					for (IAbstractArtifact a : arti.getAncestors()) {
 						result.add((IAbstractArtifact) a);
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/ContractSegment.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/ContractSegment.java
index a3a3174..adcf765 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/ContractSegment.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/ContractSegment.java
@@ -22,8 +22,9 @@
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.IContractSegment;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.IFacetReference;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope;
-import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeStereotypePattern;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeAnnotationPattern;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopePattern;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeStereotypePattern;
 import org.eclipse.tigerstripe.workbench.internal.api.contract.useCase.IUseCaseReference;
 import org.eclipse.tigerstripe.workbench.internal.api.impl.TigerstripeOssjProjectHandle;
 import org.eclipse.tigerstripe.workbench.internal.api.impl.TigerstripeProjectHandle;
@@ -236,11 +237,14 @@
 				FacetReference ref = null;
 				if (uriStr != null) {
 					URI uri = new URI(uriStr);
-					ref = new FacetReference(uri, (ITigerstripeModelProject) this
-							.getContainingProject());
+					ref = new FacetReference(uri,
+							(ITigerstripeModelProject) this
+									.getContainingProject());
 				} else if (relPathStr != null) {
 					if (projectLabelStr != null) {
-						ref = new FacetReference(relPathStr, projectLabelStr,
+						ref = new FacetReference(
+								relPathStr,
+								projectLabelStr,
 								(ITigerstripeModelProject) getContainingProject());
 					} else {
 						TigerstripeProject proj = ((TigerstripeOssjProjectHandle) getContainingProject())
@@ -293,7 +297,9 @@
 				} else if (relPathStr != null) {
 
 					if (projectLabelStr != null) {
-						ref = new UseCaseReference(relPathStr, projectLabelStr,
+						ref = new UseCaseReference(
+								relPathStr,
+								projectLabelStr,
 								(ITigerstripeModelProject) getContainingProject());
 					} else {
 						if (getContainingProject() instanceof ITigerstripeModelProject) {
@@ -323,13 +329,34 @@
 			patternElement.addAttribute("type", String.valueOf(pattern.type));
 			patternElement.addText(pattern.pattern);
 		}
+
+		// "annotationPattern" should not be used anymore. It was used when
+		// "stereotypes" were named "annotations" in Tigerstripe.
+		// Now that we have the TAF, this is now deprecated.
+		// for (ScopeStereotypePattern pattern : getISegmentScope()
+		// .getStereotypePatterns()) {
+		// Element patternElement = scopeElement
+		// .addElement("annotationPattern");
+		// patternElement.addAttribute("type", String.valueOf(pattern.type));
+		// patternElement.addText(pattern.stereotypeName);
+		// }
+
 		for (ScopeStereotypePattern pattern : getISegmentScope()
 				.getStereotypePatterns()) {
 			Element patternElement = scopeElement
-					.addElement("annotationPattern");
+					.addElement("stereotypePattern");
 			patternElement.addAttribute("type", String.valueOf(pattern.type));
 			patternElement.addText(pattern.stereotypeName);
 		}
+
+		for (ScopeAnnotationPattern pattern : getISegmentScope()
+				.getAnnotationPatterns()) {
+			Element patternElement = scopeElement
+					.addElement("tsAnnotationPattern");
+			patternElement.addAttribute("type", String.valueOf(pattern.type));
+			patternElement.addText(pattern.annotationID);
+		}
+
 	}
 
 	private void parseScope(Element rootElement) throws TigerstripeException {
@@ -347,10 +374,24 @@
 					pat.pattern = pattern;
 					scope.addPattern(pat);
 				} else if ("annotationPattern".equals(patternElement.getName())) {
+					// This tag is now deprecated, and only read for
+					// compatibility.
+					// the tag to use is now "stereotypePattern"
 					ScopeStereotypePattern pat = new ScopeStereotypePattern();
 					pat.type = type;
 					pat.stereotypeName = pattern;
 					scope.addStereotypePattern(pat);
+				} else if ("stereotypePattern".equals(patternElement.getName())) {
+					ScopeStereotypePattern pat = new ScopeStereotypePattern();
+					pat.type = type;
+					pat.stereotypeName = pattern;
+					scope.addStereotypePattern(pat);
+				} else if ("tsAnnotationPattern".equals(patternElement
+						.getName())) {
+					ScopeAnnotationPattern pat = new ScopeAnnotationPattern();
+					pat.type = type;
+					pat.annotationID = pattern;
+					scope.addAnnotationPattern(pat);
 				}
 			}
 		}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/SegmentScope.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/SegmentScope.java
index 718be72..ec58cf8 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/SegmentScope.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/contract/segment/SegmentScope.java
@@ -19,9 +19,17 @@
 
 	private List<ScopePattern> patterns = new ArrayList<ScopePattern>();
 
-	private List<ScopeStereotypePattern> annotationPatterns = new ArrayList<ScopeStereotypePattern>();
+	private List<ScopeStereotypePattern> stereotypePatterns = new ArrayList<ScopeStereotypePattern>();
+
+	private List<ScopeAnnotationPattern> annotationPatterns = new ArrayList<ScopeAnnotationPattern>();
 
 	public void addStereotypePattern(ScopeStereotypePattern pattern) {
+		if (!stereotypePatterns.contains(pattern)) {
+			stereotypePatterns.add(pattern);
+		}
+	}
+
+	public void addAnnotationPattern(ScopeAnnotationPattern pattern) {
 		if (!annotationPatterns.contains(pattern)) {
 			annotationPatterns.add(pattern);
 		}
@@ -34,8 +42,13 @@
 	}
 
 	public ScopeStereotypePattern[] getStereotypePatterns() {
+		return stereotypePatterns
+				.toArray(new ScopeStereotypePattern[stereotypePatterns.size()]);
+	}
+
+	public ScopeAnnotationPattern[] getAnnotationPatterns() {
 		return annotationPatterns
-				.toArray(new ScopeStereotypePattern[annotationPatterns.size()]);
+				.toArray(new ScopeAnnotationPattern[annotationPatterns.size()]);
 	}
 
 	public ScopePattern[] getPatterns() {
@@ -44,7 +57,7 @@
 
 	public ScopeStereotypePattern[] getStereotypePatterns(int type) {
 		List<ScopeStereotypePattern> subList = new ArrayList<ScopeStereotypePattern>();
-		for (ScopeStereotypePattern pattern : annotationPatterns) {
+		for (ScopeStereotypePattern pattern : stereotypePatterns) {
 			if (pattern.type == type) {
 				subList.add(pattern);
 			}
@@ -52,6 +65,16 @@
 		return subList.toArray(new ScopeStereotypePattern[subList.size()]);
 	}
 
+	public ScopeAnnotationPattern[] getAnnotationPatterns(int type) {
+		List<ScopeAnnotationPattern> subList = new ArrayList<ScopeAnnotationPattern>();
+		for (ScopeAnnotationPattern pattern : annotationPatterns) {
+			if (pattern.type == type) {
+				subList.add(pattern);
+			}
+		}
+		return subList.toArray(new ScopeAnnotationPattern[subList.size()]);
+	}
+
 	public ScopePattern[] getPatterns(int type) {
 		List<ScopePattern> subList = new ArrayList<ScopePattern>();
 		for (ScopePattern pattern : patterns) {
@@ -64,7 +87,7 @@
 
 	public void clear() {
 		patterns.clear();
-		annotationPatterns.clear();
+		stereotypePatterns.clear();
 	}
 
 	public boolean isValid() {
@@ -79,6 +102,12 @@
 	}
 
 	public void removeStereotypePattern(ScopeStereotypePattern pattern) {
+		if (stereotypePatterns.contains(pattern)) {
+			stereotypePatterns.remove(pattern);
+		}
+	}
+
+	public void removeAnnotationPattern(ScopeAnnotationPattern pattern) {
 		if (annotationPatterns.contains(pattern)) {
 			annotationPatterns.remove(pattern);
 		}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/model/ArtifactComponent.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/model/ArtifactComponent.java
index 2c43cc9..c31648f 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/model/ArtifactComponent.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/model/ArtifactComponent.java
@@ -11,7 +11,6 @@
 package org.eclipse.tigerstripe.workbench.internal.core.model;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -46,7 +45,7 @@
 /**
  * @author Eric Dillon
  * 
- * Any component of an artifact (method, field, tag)
+ *         Any component of an artifact (method, field, tag)
  */
 public abstract class ArtifactComponent implements IModelComponent,
 		IStereotypeCapable {
@@ -321,7 +320,7 @@
 			if (ref.getFacetPredicate() instanceof FacetPredicate) {
 				FacetPredicate predicate = (FacetPredicate) ref
 						.getFacetPredicate();
-				return !predicate.isExcludedByAnnotation(this);
+				return !predicate.isExcludedByStereotype(this);
 			} else
 				return true;
 		} else
@@ -446,7 +445,7 @@
 	public boolean hasAnnotations() {
 		return !getAnnotations().isEmpty();
 	}
-	
+
 	public boolean hasAnnotations(String schemeID) {
 		return !getAnnotations(schemeID).isEmpty();
 	}
@@ -462,27 +461,27 @@
 	}
 
 	public Annotation addAnnotation(String scheme, String packij, String clazz)
-	    throws TigerstripeException
-	{
+			throws TigerstripeException {
 		IAnnotationManager manager = AnnotationPlugin.getManager();
 		AnnotationType type = manager.getType(packij, clazz);
-		if(type == null)
-			throw new InvalidAnnotationTargetException("No such AnnotationType");
+		if (type == null)
+			throw new InvalidAnnotationTargetException("No such AnnotationType (" + packij + ", " + clazz + ")");
 		// Questionable stuff: not sure this should be here
 		String[] targets = type.getTargets();
 		boolean ok = targets.length == 0;
-		if(!ok)
-		{
-			for(int t = 0; t < targets.length; t++)
-			{
+		if (!ok) {
+			for (int t = 0; t < targets.length; t++) {
 				try {
-					if(Class.forName(targets[t], false, this.getClass().getClassLoader()).isInstance(this))
+					if (Class.forName(targets[t], false,
+							this.getClass().getClassLoader()).isInstance(this))
 						ok = true;
-				} catch (ClassNotFoundException e) {/* Nothing */}
+				} catch (ClassNotFoundException e) {/* Nothing */
+				}
 			}
 		}
-		if(!ok)
-			throw new InvalidAnnotationTargetException("Target not allowed for AnnotationType");
+		if (!ok)
+			throw new InvalidAnnotationTargetException(
+					"Target not allowed for AnnotationType");
 		// END questionable stuff
 		EObject content = type.createInstance();
 		try {
@@ -491,22 +490,22 @@
 			throw new TigerstripeException("Failed to add annotation of type: "+content.getClass().getName(), e);
 		}
 	}
-	
-	public Annotation addAnnotation(String packij, String clazz) throws TigerstripeException
-	{
+
+	public Annotation addAnnotation(String packij, String clazz)
+			throws TigerstripeException {
 		return addAnnotation(TS_SCHEME, packij, clazz);
 	}
-	
-	public Annotation addAnnotation(Class<? extends EObject> clazz) throws TigerstripeException
-	{
-		return addAnnotation(TS_SCHEME, clazz.getPackage().getName(), clazz.getName().substring(clazz.getName().lastIndexOf('.')+1));
+
+	public Annotation addAnnotation(Class<? extends EObject> clazz)
+			throws TigerstripeException {
+		return addAnnotation(TS_SCHEME, clazz.getPackage().getName(), clazz
+				.getName().substring(clazz.getName().lastIndexOf('.') + 1));
 	}
-	
-	public void saveAnnotation(Annotation annotation)
-	{
+
+	public void saveAnnotation(Annotation annotation) {
 		AnnotationPlugin.getManager().save(annotation);
 	}
-	
+
 	public ITigerstripeModelProject getProject() throws TigerstripeException {
 		if (getParentArtifact() != null)
 			return getParentArtifact().getProject();
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/project/PluginProjectCreator.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/project/PluginProjectCreator.java
index 45c3516..2e1b04a 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/project/PluginProjectCreator.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/project/PluginProjectCreator.java
@@ -16,6 +16,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.core.resources.IFolder;
@@ -42,6 +44,12 @@
 public class PluginProjectCreator extends BaseProjectCreator implements
 		IProjectCreator {
 
+	public static IClasspathEntry[] REQUIRED_ENTRIES = {
+			JavaCore.newVariableEntry(new Path(
+					ITigerstripeConstants.EQUINOX_COMMON), null, null),
+			JavaCore.newVariableEntry(new Path(
+					ITigerstripeConstants.EXTERNALAPI_LIB), null, null) };
+
 	@SuppressWarnings("unchecked")
 	public IWorkspaceRunnable getRunnable(final IProjectDetails projectDetails,
 			final IPath path, final Map properties) throws TigerstripeException {
@@ -92,12 +100,15 @@
 			templateFolder.create(true, true, null);
 
 			// set the build path
-			IClasspathEntry[] buildPath = {
-					JavaCore.newSourceEntry(projectHandle.getFolder("src")
-							.getFullPath()),
-					JavaRuntime.getDefaultJREContainerEntry(),
-					JavaCore.newVariableEntry(new Path(
-							ITigerstripeConstants.EXTERNALAPI_LIB), null, null) };
+			List<IClasspathEntry> buildPathList = new ArrayList<IClasspathEntry>();
+			buildPathList.add(JavaCore.newSourceEntry(projectHandle.getFolder(
+					"src").getFullPath()));
+			buildPathList.add(JavaRuntime.getDefaultJREContainerEntry());
+			for (IClasspathEntry entry : REQUIRED_ENTRIES) {
+				buildPathList.add(entry);
+			}
+			IClasspathEntry[] buildPath = buildPathList
+					.toArray(new IClasspathEntry[buildPathList.size()]);
 
 			newJavaProject.setRawClasspath(buildPath, projectHandle
 					.getFullPath().append("bin"), null);
@@ -115,8 +126,8 @@
 	/**
 	 * We will initialize file contents with a sample text.
 	 * 
-	 * @param pageProperties -
-	 *            the properties gathered through the wizard
+	 * @param pageProperties
+	 *            - the properties gathered through the wizard
 	 */
 	@Override
 	protected InputStream openContentStream(IProjectDetails projectDetails)
diff --git a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/util/RegExpFQNSetPred.java b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/util/RegExpFQNSetPred.java
index 8e74983..308684a 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/util/RegExpFQNSetPred.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.base/src/java/org/eclipse/tigerstripe/workbench/internal/core/util/RegExpFQNSetPred.java
@@ -13,20 +13,31 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.eclipse.tigerstripe.workbench.internal.core.model.AbstractArtifact;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.tigerstripe.annotation.core.Annotation;
+import org.eclipse.tigerstripe.annotation.core.AnnotationPlugin;
+import org.eclipse.tigerstripe.workbench.model.deprecated_.IAbstractArtifact;
 
 public class RegExpFQNSetPred implements Predicate {
 
 	private HashSet<Pattern> isIncludedExpSet = new HashSet<Pattern>();
 	private HashSet<Pattern> isExcludedExpSet = new HashSet<Pattern>();
+
+	private HashSet<String> isIncludedByAnnotation = new HashSet<String>();
+	private HashSet<String> isExcludedByAnnotation = new HashSet<String>();
+
 	private HashMap<String, Pattern> patternsByString = new HashMap<String, Pattern>();
+	private Set<String> annotationIds = new HashSet<String>();
 
 	public boolean isEmptyPredicate() {
-		return isIncludedExpSet.size() == 0 && isExcludedExpSet.size() == 0;
+		return isIncludedExpSet.size() == 0 && isExcludedExpSet.size() == 0
+				&& isIncludedByAnnotation.size() == 0
+				&& isExcludedByAnnotation.size() == 0;
 	}
 
 	public boolean evaluate(Object obj) {
@@ -34,12 +45,13 @@
 			// if there are no rules for what's acceptable and what's not,
 			// accept anything
 			return true;
-		else if (isExcludedExpSet.size() == 0)
+		else if (isExcludedExpSet.size() == 0
+				&& isExcludedByAnnotation.size() == 0)
 			// else if there are no rules for what's unacceptable, look to the
-			// rules about what
-			// is acceptable to determine what to do
+			// rules about what is acceptable to determine what to do
 			return isIncluded(obj);
-		else if (isIncludedExpSet.size() == 0)
+		else if (isIncludedExpSet.size() == 0
+				&& isIncludedByAnnotation.size() == 0)
 			// else if there are no rules for what's acceptable, look to the
 			// rules about what
 			// is unacceptable to determine what to do
@@ -68,7 +80,7 @@
 	}
 
 	/*
-	 * Note; in the two "add" methods for patterns (below), if the pattern
+	 * Note; in the four "add" methods for patterns (below), if the pattern
 	 * string already exists in this predicate (in either the included or
 	 * excluded patterns), then don't add it...it would either be a duplicate
 	 * pattern (which would be refused by the set) or create a conflict (since
@@ -91,6 +103,20 @@
 		return isExcludedExpSet.add(p);
 	}
 
+	public boolean addIsIncludedByAnnotationPattern(String annotationId) {
+		if (containsAnnotationIdPattern(annotationId))
+			return false;
+		annotationIds.add(annotationId);
+		return isIncludedByAnnotation.add(annotationId);
+	}
+
+	public boolean addIsExcludedByAnnotationPattern(String annotationId) {
+		if (containsAnnotationIdPattern(annotationId))
+			return false;
+		annotationIds.add(annotationId);
+		return isExcludedByAnnotation.add(annotationId);
+	}
+
 	/*
 	 * the next two methods are used to remove patterns from the Predicate
 	 */
@@ -139,29 +165,48 @@
 
 	// Bug 731: needed that to be public for facet predicate
 	public boolean isIncluded(Object obj) {
-		if (!(obj instanceof AbstractArtifact))
+		if (!(obj instanceof IAbstractArtifact))
 			return false;
+
+		IAbstractArtifact artifact = (IAbstractArtifact) obj;
+
 		// look through the patterns...if matches any, then is included
 		for (Pattern p : isIncludedExpSet) {
-			Matcher m = p.matcher(((AbstractArtifact) obj)
-					.getFullyQualifiedName());
+			Matcher m = p.matcher(artifact.getFullyQualifiedName());
 			if (m.matches())
 				return true;
 		}
+
+		for (String annotationId : isIncludedByAnnotation) {
+
+			List<Object> annotations = artifact.getAnnotations("tigerstripe",
+					annotationId);
+			if (annotations.size() != 0)
+				return true;
+		}
 		return false;
 	}
 
 	// Bug 731: needed that to be public for facet predicate
 	public boolean isExcluded(Object obj) {
-		if (!(obj instanceof AbstractArtifact))
+		if (!(obj instanceof IAbstractArtifact))
 			return false;
+
+		IAbstractArtifact artifact = (IAbstractArtifact) obj;
+
 		// look through the patterns...if matches any, then is excluded
 		for (Pattern p : isExcludedExpSet) {
-			Matcher m = p.matcher(((AbstractArtifact) obj)
-					.getFullyQualifiedName());
+			Matcher m = p.matcher(artifact.getFullyQualifiedName());
 			if (m.matches())
 				return true;
 		}
+
+		for (String annotationId : isExcludedByAnnotation) {
+			List<Object> annotations = artifact.getAnnotations("tigerstripe",
+					annotationId);
+			if (annotations.size() != 0)
+				return true;
+		}
 		return false;
 	}
 
@@ -175,4 +220,8 @@
 		return false;
 	}
 
+	private boolean containsAnnotationIdPattern(String annotationId) {
+		return annotationIds.contains(annotationId);
+	}
+
 }
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/META-INF/MANIFEST.MF b/plugins/org.eclipse.tigerstripe.workbench.ui.base/META-INF/MANIFEST.MF
index 763f7f2..209eae5 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.ui.base/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/META-INF/MANIFEST.MF
@@ -35,7 +35,9 @@
  org.eclipse.gmf.runtime.diagram.ui.resources.editor,
  org.eclipse.search,
  org.eclipse.tigerstripe.workbench.base;visibility:=reexport,
- org.eclipse.osgi.services
+ org.eclipse.osgi.services,
+ org.eclipse.tigerstripe.annotation.ui;bundle-version="0.4.0",
+ org.eclipse.tigerstripe.annotation.core;bundle-version="0.4.0"
 Bundle-ActivationPolicy: lazy
 Export-Package: org.eclipse.tigerstripe.workbench.ui,
  org.eclipse.tigerstripe.workbench.ui.internal.utils,
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/BrowseForAnnotationsDialog.java b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/BrowseForAnnotationsDialog.java
new file mode 100644
index 0000000..e4a49ae
--- /dev/null
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/dialogs/BrowseForAnnotationsDialog.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Cisco Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    E. Dillon (Cisco Systems, Inc.) - reformat for Code Open-Sourcing
+ *******************************************************************************/
+package org.eclipse.tigerstripe.workbench.ui.internal.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tigerstripe.annotation.core.AnnotationPlugin;
+import org.eclipse.tigerstripe.annotation.core.AnnotationType;
+import org.eclipse.tigerstripe.annotation.ui.AnnotationUIPlugin;
+import org.eclipse.tigerstripe.annotation.ui.util.DisplayAnnotationUtil;
+import org.eclipse.tigerstripe.workbench.TigerstripeException;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * @author Eric Dillon
+ * 
+ * 
+ */
+public class BrowseForAnnotationsDialog {
+
+	private class AnnotationTypeLabelProvider extends LabelProvider {
+		@Override
+		public String getText(Object element) {
+			if (element instanceof AnnotationType) {
+				ILabelProvider prov = AnnotationUIPlugin.getManager()
+						.getLabelProvider((AnnotationType) element);
+				if (prov != null)
+					return prov.getText(element);
+				else
+					return ((AnnotationType) element).getName();
+			}
+
+			return null;
+		}
+
+		@Override
+		public Image getImage(Object element) {
+			if (element instanceof AnnotationType) {
+				ILabelProvider prov = AnnotationUIPlugin.getManager()
+						.getLabelProvider((AnnotationType) element);
+				if (prov != null)
+					return prov.getImage(element);
+			}
+
+			return null;
+		}
+
+	}
+
+	private Collection<AnnotationType> existingAnnotationTypes;
+
+	private String title = "Annotation Type Selection";
+
+	private String message = "Please select a Annotation Type";
+
+	/**
+	 * 
+	 * @param initialElement
+	 * @param model
+	 */
+	public BrowseForAnnotationsDialog(
+			Collection<AnnotationType> existingInstances) {
+		this.existingAnnotationTypes = existingInstances;
+	}
+
+	/**
+	 * Opens up a dialog box with a list of available entities and returns the
+	 * EntityOptions that have been selected.
+	 * 
+	 * @return EntityOption[] - Returns an array of EntityOption as selected
+	 *         from the dialog
+	 */
+	public AnnotationType[] browseAvailableAnnotationTypes(Shell parentShell)
+			throws TigerstripeException {
+
+		ElementListSelectionDialog elsd = new ElementListSelectionDialog(
+				parentShell, new AnnotationTypeLabelProvider());
+
+		elsd.setTitle(getTitle());
+		elsd.setMessage(getMessage());
+
+		Object[] availableAnnotationTypes = getAvailableAnnotationTypesList();
+		elsd.setElements(availableAnnotationTypes);
+
+		if (elsd.open() == Window.OK) {
+
+			Object[] objects = elsd.getResult();
+			if (objects != null && objects.length != 0) {
+				AnnotationType[] result = new AnnotationType[objects.length];
+				for (int i = 0; i < result.length; i++) {
+					result[i] = (AnnotationType) objects[i];
+				}
+
+				return result;
+			}
+		}
+		return new AnnotationType[0];
+	}
+
+	/**
+	 * 
+	 * @return
+	 */
+	private Object[] getAvailableAnnotationTypesList()
+			throws TigerstripeException {
+
+		List<AnnotationType> annotationTypes = new ArrayList<AnnotationType>();
+
+		annotationTypes.addAll(Arrays.asList(AnnotationPlugin.getManager()
+				.getTypes()));
+
+		if (annotationTypes.size() == 0)
+			return new Object[0];
+
+		// now go thru the list and remove those that can't be re added
+		for (AnnotationType instance : existingAnnotationTypes) {
+			int target = -1;
+			for (int i = 0; i < annotationTypes.size(); i++) {
+				if (annotationTypes.get(i).getId().equals(instance.getId())) {
+					target = i;
+					break;
+				}
+			}
+			if (target != -1)
+				annotationTypes.remove(target);
+		}
+
+		Collections.sort(annotationTypes, new Comparator<AnnotationType>() {
+
+			public int compare(AnnotationType o1, AnnotationType o2) {
+				return o1.getName().compareTo(o2.getName());
+			}
+
+		});
+
+		return annotationTypes.toArray();
+	}
+
+	public String getMessage() {
+		return message;
+	}
+
+	public void setMessage(String message) {
+		this.message = message;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/AnnotationIncludeExcludeSection.java b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/AnnotationIncludeExcludeSection.java
new file mode 100644
index 0000000..754a121
--- /dev/null
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/AnnotationIncludeExcludeSection.java
@@ -0,0 +1,588 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Cisco Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    E. Dillon (Cisco Systems, Inc.) - reformat for Code Open-Sourcing
+ *******************************************************************************/
+package org.eclipse.tigerstripe.workbench.ui.internal.editors.segment.scope;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.tigerstripe.annotation.core.AnnotationPlugin;
+import org.eclipse.tigerstripe.annotation.core.AnnotationType;
+import org.eclipse.tigerstripe.workbench.TigerstripeException;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopeAnnotationPattern;
+import org.eclipse.tigerstripe.workbench.internal.api.contract.segment.ISegmentScope.ScopePattern;
+import org.eclipse.tigerstripe.workbench.internal.core.util.Util;
+import org.eclipse.tigerstripe.workbench.ui.EclipsePlugin;
+import org.eclipse.tigerstripe.workbench.ui.internal.dialogs.BrowseForAnnotationsDialog;
+import org.eclipse.tigerstripe.workbench.ui.internal.dialogs.Utils;
+import org.eclipse.tigerstripe.workbench.ui.internal.editors.segment.SegmentEditor;
+import org.eclipse.tigerstripe.workbench.ui.internal.editors.segment.TigerstripeSegmentSectionPart;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class AnnotationIncludeExcludeSection extends
+		TigerstripeSegmentSectionPart {
+
+	private Button addIncludesButton;
+
+	private Button sortIncludesButton;
+
+	private Button removeIncludesButton;
+
+	private Table includesTable;
+
+	private TableViewer includesViewer;
+
+	private Button addExcludesButton;
+
+	private Button sortExcludesButton;
+
+	private Button removeExcludesButton;
+
+	private Table excludesTable;
+
+	private TableViewer excludesViewer;
+
+	private class PatternLabelProvider extends LabelProvider {
+		@Override
+		public String getText(Object element) {
+			if (element instanceof ISegmentScope.ScopeAnnotationPattern) {
+				ISegmentScope.ScopeAnnotationPattern pattern = (ISegmentScope.ScopeAnnotationPattern) element;
+
+				AnnotationType type = AnnotationPlugin.getManager().getType(
+						Util.packageOf(pattern.annotationID),
+						Util.nameOf(pattern.annotationID));
+				return type.getName();
+			}
+			return "<unknown>";
+		}
+	}
+
+	private class PatternContentProvider implements IStructuredContentProvider {
+
+		private int targetType = ISegmentScope.INCLUDES;
+
+		/**
+		 * 
+		 * @param type
+		 *            needs to be either {@link ISegmentScope#INCLUDES} or
+		 *            {@link ISegmentScope#EXCLUDES}
+		 */
+		public PatternContentProvider(int type) {
+			if (type == ISegmentScope.INCLUDES
+					|| type == ISegmentScope.EXCLUDES) {
+				targetType = type;
+			}
+		}
+
+		public Object[] getElements(Object inputElement) {
+			if (inputElement instanceof ISegmentScope) {
+				ISegmentScope scope = (ISegmentScope) inputElement;
+				ScopeAnnotationPattern[] patterns = scope
+						.getAnnotationPatterns(targetType);
+				return patterns;
+			} else
+				return new ScopePattern[0];
+		}
+
+		public void dispose() {
+		}
+
+		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		}
+	}
+
+	private class PatternViewSorter extends ViewerSorter {
+
+		private boolean sort = false;
+
+		private boolean sorted = false;
+
+		public void setSort(boolean sort) {
+			this.sort = sort;
+		}
+
+		public boolean isSorted() {
+			return sorted;
+		}
+
+		public void setSorted(boolean sorted) {
+			this.sorted = sorted;
+		}
+
+		@Override
+		public void sort(Viewer viewer, Object[] elements) {
+			if (sort /* && !sorted */) {
+				super.sort(viewer, elements);
+				sort = false;
+			}
+		}
+
+	}
+
+	private class PatternCellModifier implements ICellModifier {
+
+		private TableViewer viewer;
+
+		public PatternCellModifier(TableViewer viewer) {
+			this.viewer = viewer;
+		}
+
+		public boolean canModify(Object element, String property) {
+			if ("PATTERN".equals(property))
+				return true;
+
+			return false;
+		}
+
+		public Object getValue(Object element, String property) {
+			if ("PATTERN".equals(property)) {
+				ScopeAnnotationPattern entry = (ScopeAnnotationPattern) element;
+				return entry.annotationID;
+			}
+
+			return null;
+		}
+
+		public void modify(Object item, String property, Object value) {
+
+			// null indicates that the validator rejected the values
+			if (value == null)
+				return;
+
+			ScopeAnnotationPattern pattern = (ScopeAnnotationPattern) ((TableItem) item)
+					.getData();
+			if (pattern.annotationID != null
+					&& !pattern.annotationID.equals(value)) {
+				pattern.annotationID = (String) value;
+				markPageModified();
+				viewer.refresh(true);
+			}
+		}
+	}
+
+	public AnnotationIncludeExcludeSection(ScopePage page, Composite parent,
+			FormToolkit toolkit) {
+		super(page, parent, toolkit, ExpandableComposite.TITLE_BAR);
+		setTitle("Annotation Scope Details");
+		createContent();
+	}
+
+	private ISegmentScope getScope() throws TigerstripeException {
+		return ((ScopePage) getPage()).getScope();
+	}
+
+	/**
+	 * Note: this is not implemented yet as it doesn't seem to apply yet, but it
+	 * is here as provision... just in case.
+	 * 
+	 * @return
+	 */
+	@Override
+	protected boolean isReadonly() {
+		return false;
+	}
+
+	@Override
+	protected void createContent() {
+
+		PatternLabelProvider labelProvider = new PatternLabelProvider();
+
+		TableWrapLayout layout = new TableWrapLayout();
+		layout.numColumns = 2;
+		getSection().setLayout(layout);
+
+		TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.heightHint = 550;
+		getSection().setLayoutData(td);
+
+		// Includes table
+		Label l = getToolkit().createLabel(getBody(),
+				"Annotation Included patterns");
+		td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.colspan = 2;
+		l.setLayoutData(td);
+
+		includesTable = getToolkit().createTable(getBody(),
+				SWT.BORDER | SWT.FLAT | SWT.FULL_SELECTION);
+		td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.rowspan = 3;
+		td.heightHint = 100;
+		td.grabHorizontal = true;
+		includesTable.setEnabled(!this.isReadonly());
+		includesTable.setLayoutData(td);
+		includesTable.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				updateRemoveButtonsState();
+			}
+		});
+
+		includesViewer = new TableViewer(includesTable);
+		try {
+			includesViewer.setLabelProvider(labelProvider);
+			includesViewer.setContentProvider(new PatternContentProvider(
+					ISegmentScope.INCLUDES));
+			includesViewer.setSorter(new PatternViewSorter());
+
+			includesViewer.setInput(getScope());
+			// includesViewer.setColumnProperties(new String[] { "PATTERN" });
+			// final TextCellEditor entryListCellEditor = new TextCellEditor(
+			// includesViewer.getTable());
+			// includesViewer
+			// .setCellEditors(new CellEditor[] { entryListCellEditor });
+			// includesViewer.setCellModifier(new PatternCellModifier(
+			// includesViewer));
+		} catch (TigerstripeException e) {
+			EclipsePlugin.log(e);
+		}
+
+		addIncludesButton = getToolkit().createButton(getBody(), "Add",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		td.maxWidth = 75;
+		addIncludesButton.setEnabled(!this.isReadonly());
+		addIncludesButton.setLayoutData(td);
+		addIncludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				addPatternSelected(ISegmentScope.INCLUDES);
+			}
+		});
+
+		sortIncludesButton = getToolkit().createButton(getBody(), "Sort",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		td.maxWidth = 75;
+		sortIncludesButton.setEnabled(!this.isReadonly());
+		sortIncludesButton.setLayoutData(td);
+		sortIncludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				sortButtonSelected(includesViewer);
+			}
+
+		});
+
+		removeIncludesButton = getToolkit().createButton(getBody(), "Remove",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		td.maxWidth = 75;
+		removeIncludesButton.setLayoutData(td);
+		removeIncludesButton.setEnabled(!this.isReadonly());
+		removeIncludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				removePatternSelected(ISegmentScope.INCLUDES);
+			}
+		});
+
+		// Spacer
+		l = getToolkit().createLabel(getBody(), "");
+		td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.colspan = 2;
+		td.heightHint = 15;
+		l.setLayoutData(td);
+
+		// excludes table
+		l = getToolkit()
+				.createLabel(getBody(), "Annotations Excluded patterns");
+		td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.colspan = 2;
+		l.setLayoutData(td);
+		excludesTable = getToolkit().createTable(getBody(),
+				SWT.BORDER | SWT.FLAT);
+		td = new TableWrapData(TableWrapData.FILL_GRAB);
+		td.rowspan = 3;
+		td.heightHint = 100;
+		excludesTable.setEnabled(!this.isReadonly());
+		excludesTable.setLayoutData(td);
+		excludesTable.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				updateRemoveButtonsState();
+			}
+		});
+
+		excludesViewer = new TableViewer(excludesTable);
+		try {
+			excludesViewer.setLabelProvider(labelProvider);
+			excludesViewer.setContentProvider(new PatternContentProvider(
+					ISegmentScope.EXCLUDES));
+			excludesViewer.setSorter(new PatternViewSorter());
+			excludesViewer.setInput(getScope());
+			// excludesViewer.setColumnProperties(new String[] { "PATTERN" });
+			// final TextCellEditor entryListCellEditor = new TextCellEditor(
+			// excludesViewer.getTable());
+			// excludesViewer
+			// .setCellEditors(new CellEditor[] { entryListCellEditor });
+			// excludesViewer.setCellModifier(new PatternCellModifier(
+			// excludesViewer));
+		} catch (TigerstripeException e) {
+			EclipsePlugin.log(e);
+		}
+
+		addExcludesButton = getToolkit().createButton(getBody(), "Add",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		// td.maxWidth = 75;
+		addExcludesButton.setEnabled(!this.isReadonly());
+		addExcludesButton.setLayoutData(td);
+		addExcludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				addPatternSelected(ISegmentScope.EXCLUDES);
+			}
+		});
+
+		sortExcludesButton = getToolkit().createButton(getBody(), "Sort",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		td.maxWidth = 75;
+		sortExcludesButton.setEnabled(!this.isReadonly());
+		sortExcludesButton.setLayoutData(td);
+		sortExcludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				sortButtonSelected(excludesViewer);
+			}
+		});
+
+		removeExcludesButton = getToolkit().createButton(getBody(), "Remove",
+				SWT.PUSH);
+		td = new TableWrapData(TableWrapData.LEFT);
+		td.maxWidth = 75;
+		removeExcludesButton.setLayoutData(td);
+		removeExcludesButton.setEnabled(!this.isReadonly());
+		removeExcludesButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// empty
+			}
+
+			public void widgetSelected(SelectionEvent e) {
+				removePatternSelected(ISegmentScope.EXCLUDES);
+			}
+		});
+
+		updateSection();
+
+		getSection().setClient(getBody());
+		getToolkit().paintBordersFor(getBody());
+	}
+
+	private void addPatternSelected(int type) {
+
+		List<AnnotationType> alreadySelected = new ArrayList<AnnotationType>();
+
+		try {
+			for (ScopeAnnotationPattern pattern : getScope()
+					.getAnnotationPatterns(type)) {
+				String pack = Util.packageOf(pattern.annotationID);
+				String clazz = Util.nameOf(pattern.annotationID);
+				AnnotationType annType = AnnotationPlugin.getManager().getType(
+						pack, clazz);
+				if (annType != null)
+					alreadySelected.add(annType);
+			}
+		} catch (TigerstripeException e) {
+			EclipsePlugin.log(e);
+		}
+
+		BrowseForAnnotationsDialog dialog = new BrowseForAnnotationsDialog(
+				alreadySelected);
+		try {
+			AnnotationType[] types = dialog
+					.browseAvailableAnnotationTypes(getSection().getShell());
+			if (types.length != 0) {
+				ScopeAnnotationPattern newPattern = new ScopeAnnotationPattern();
+				newPattern.type = type;
+				newPattern.annotationID = types[0].getId();
+				try {
+					getScope().addAnnotationPattern(newPattern);
+				} catch (TigerstripeException e) {
+					EclipsePlugin.log(e);
+				}
+
+				markPageModified();
+				if (type == ISegmentScope.EXCLUDES)
+					try {
+						refreshViewerAfterAdd(excludesViewer);
+					} catch (TigerstripeException e) {
+						EclipsePlugin.log(e);
+					}
+				else {
+					try {
+						refreshViewerAfterAdd(includesViewer);
+					} catch (TigerstripeException e) {
+						EclipsePlugin.log(e);
+					}
+				}
+				updateSortButtonsState();
+			}
+		} catch (TigerstripeException e) {
+			EclipsePlugin.log(e);
+		}
+	}
+
+	private void refreshViewerAfterAdd(TableViewer viewer)
+			throws TigerstripeException {
+
+		viewer.setInput(getScope());
+		((PatternViewSorter) viewer.getSorter()).setSorted(false);
+		viewer.refresh(true);
+	}
+
+	protected void sortButtonSelected(TableViewer viewer) {
+		PatternViewSorter viewSorter = (PatternViewSorter) viewer.getSorter();
+		if (!viewSorter.isSorted()) {
+			viewSorter.setSort(true);
+			viewer.refresh(true);
+			viewSorter.setSorted(true);
+		} else {
+			viewSorter.setSorted(false);
+			viewer.refresh(true);
+		}
+	}
+
+	protected void markPageModified() {
+		SegmentEditor editor = (SegmentEditor) getPage().getEditor();
+		editor.pageModified();
+	}
+
+	private void removePatternSelected(int type) {
+		Table targetTable = null;
+		if (type == ISegmentScope.INCLUDES) {
+			targetTable = includesTable;
+		} else {
+			targetTable = excludesTable;
+		}
+		int[] indices = targetTable.getSelectionIndices();
+
+		String msg = "Do you really want to remove ";
+		if (indices.length > 1) {
+			msg += "these patterns?";
+		} else {
+			msg += "this pattern?";
+		}
+		if (MessageDialog.openConfirm(getSection().getShell(),
+				"Remove Scope Pattern", msg)) {
+			for (int index : indices) {
+				ScopeAnnotationPattern pat = (ScopeAnnotationPattern) targetTable
+						.getItem(index).getData();
+				try {
+					getScope().removeAnnotationPattern(pat);
+				} catch (TigerstripeException e) {
+					EclipsePlugin.log(e);
+				}
+			}
+
+			markPageModified();
+			if (type == ISegmentScope.EXCLUDES)
+				try {
+					refreshViewerAfterRemove(excludesViewer);
+				} catch (TigerstripeException e) {
+					EclipsePlugin.log(e);
+				}
+			else {
+				try {
+					refreshViewerAfterRemove(includesViewer);
+				} catch (TigerstripeException e) {
+					EclipsePlugin.log(e);
+				}
+			}
+			updateSortButtonsState();
+			updateRemoveButtonsState();
+		}
+	}
+
+	private void refreshViewerAfterRemove(TableViewer viewer)
+			throws TigerstripeException {
+
+		PatternViewSorter viewSorter = (PatternViewSorter) viewer.getSorter();
+		viewer.setInput(getScope());
+		if (viewSorter.isSorted()) {
+			viewSorter.setSort(true);
+		}
+		viewer.refresh(true);
+
+	}
+
+	private void updateRemoveButtonsState() {
+		int[] indices = includesTable.getSelectionIndices();
+		removeIncludesButton.setEnabled(indices.length != 0);
+		indices = excludesTable.getSelectionIndices();
+		removeExcludesButton.setEnabled(indices.length != 0);
+	}
+
+	private void updateSortButtonsState() {
+		sortIncludesButton.setEnabled(includesTable.getItemCount() > 1);
+		sortExcludesButton.setEnabled(excludesTable.getItemCount() > 1);
+	}
+
+	private void updateSection() {
+		includesViewer.refresh(true);
+		excludesViewer.refresh(true);
+
+		updateRemoveButtonsState();
+		updateSortButtonsState();
+	}
+
+	@Override
+	public void setFocus() {
+		updateSection();
+		super.setFocus();
+	}
+
+	@Override
+	public void refresh() {
+		updateSection();
+		super.refresh();
+	}
+
+}
diff --git a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/ScopePage.java b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/ScopePage.java
index e4716b4..7cdfb28 100644
--- a/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/ScopePage.java
+++ b/plugins/org.eclipse.tigerstripe.workbench.ui.base/src/java/org/eclipse/tigerstripe/workbench/ui/internal/editors/segment/scope/ScopePage.java
@@ -66,6 +66,8 @@
 		body.setLayout(layout);
 
 		managedForm.addPart(new IncludeExcludeSection(this, body, toolkit));
+		managedForm.addPart(new AnnotationIncludeExcludeSection(this, body,
+				toolkit));
 	}
 
 	public ISegmentScope getScope() throws TigerstripeException {