Merge branch '3.0.M7-build' of ssh://git.eclipse.org/gitroot/gmf-tooling/org.eclipse.gmf-tooling into 3.0.M7-build
diff --git a/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
index 21c9e8d..0561b68 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/impl/parsers/ParserProvider.xpt
@@ -192,7 +192,7 @@
 «ENDDEFINE»
 
 «DEFINE _parser(modelFacet : gmfgen::LabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::ExternalParser-»
-«REM»NO-OP«ENDREM-»
+«REM»NO-OP«ENDREM»«-»
 «ENDDEFINE»
 
 «DEFINE _parser(modelFacet : gmfgen::FeatureLabelModelFacet, element : gmfgen::GenCommonBase) FOR gmfgen::PredefinedParser»
@@ -238,8 +238,10 @@
 		«EXPAND _setPatterns(viewMethod, editMethod, parserVar) FOR modelFacet-»		
 «ENDDEFINE»
 
-«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::PredefinedEnumParser»		
-			org.eclipse.emf.ecore.EAttribute editableFeature = «EXPAND MetaModel::MetaFeature FOR modelFacet.editableMetaFeatures->first()»;
+«DEFINE _createPredefinedParser(modelFacet : gmfgen::FeatureLabelModelFacet, parserVar : String) FOR gmfgen::PredefinedEnumParser»
+	«LET if modelFacet.editableMetaFeatures->isEmpty() then modelFacet.metaFeatures->first() else modelFacet.editableMetaFeatures->first() endif AS feature-»
+			org.eclipse.emf.ecore.EAttribute editableFeature = «EXPAND MetaModel::MetaFeature FOR feature»;
+	«ENDLET-»
 			«getQualifiedClassName()» «parserVar» = new «getQualifiedClassName()»(editableFeature);
 «ENDDEFINE»
 
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
index 836d292..e087325 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/AllTests.java
@@ -86,8 +86,7 @@
 			System.err.println("Generating a target platform");
 			Utils.setTargetPlatform();
 		}
-		
-		
+
 		TestSuite suite = new TestSuite("Tests for org.eclipse.gmf, tooling side");
 		final SessionSetup sessionSetup = SessionSetup.newInstance();
 		final LinksSessionSetup sessionSetup2 = LinksSessionSetup.newInstance();
@@ -97,16 +96,15 @@
 		// subclassing to generate extra code
 		final SessionSetup setupEditHelpersTest = new EditHelpersTest.EditHelpersSessionSetup();
 		final SessionSetup setupBundleActivationTest = new BundleActivationTest.CustomSetup();
-		
+
 		SessionSetup.disallowSingleTestCaseUse();
-		
 
 		JavaCore.initializeAfterLoad(null);
 
 		/*
-		 * Temporary workaround: loading all the projects in the
-		 * beginning to get rid of the problems with runtime registries
-		 * reloading. In particular - ViewService.
+		 * Temporary workaround: loading all the projects in the beginning to
+		 * get rid of the problems with runtime registries reloading. In
+		 * particular - ViewService.
 		 */
 		// since we force initialization, need to make sure our tests would use same initialized setup instances. 
 		Plugin.getConfig().registerInstance(SessionSetup.class, sessionSetup);
@@ -146,10 +144,10 @@
 		suite.addTestSuite(TestDefaultMergeService.class);
 		suite.addTestSuite(PluginXMLTextMergerTest.class);
 		suite.addTestSuite(ManifestMergeTest.class);
-        suite.addTestSuite(OrganizeImportsPostprocessorTest.class);
+		suite.addTestSuite(OrganizeImportsPostprocessorTest.class);
 
 		suite.addTestSuite(EcoreGenModelMatcherTest.class);
-		suite.addTestSuite(ModelLoadHelperTest.class);		
+		suite.addTestSuite(ModelLoadHelperTest.class);
 		suite.addTest(AllMigrationTests.suite());
 		suite.addTest(AllValidateTests.suite());
 
@@ -163,14 +161,14 @@
 		suite.addTestSuite(MapModeStrategyTest.class);
 		suite.addTestSuite(ViewmapProducersTest.class);
 		suite.addTestSuite(ToolDefHandocodedImplTest.class);
-		suite.addTestSuite(AuditHandcodedTest.class);		
-		suite.addTestSuite(AuditRulesTest.class);		
+		suite.addTestSuite(AuditHandcodedTest.class);
+		suite.addTestSuite(AuditRulesTest.class);
 		suite.addTestSuite(ElementInitializerTest.class);
 		suite.addTestSuite(CodegenReconcileTest.class);
 		// though it might be an overkill to check two setups, it should be fast and won't hurt.
 		suite.addTest(feed(TestAllDerivedFeatures.class, sessionSetup, "-SessionSetup"));
 		suite.addTest(feed(TestAllDerivedFeatures.class, sessionSetup2, "-LinksSessionSetup"));
-		
+
 		suite.addTestSuite(DiagramNodeTest.class);
 		suite.addTestSuite(CompartmentPropertiesTest.class);
 		suite.addTestSuite(NamingStrategyTest.class);
@@ -189,19 +187,19 @@
 		
 		suite.addTestSuite(LinkCreationTest.class);
 		suite.addTestSuite(LinkCreationConstraintsTest.class);
-		suite.addTestSuite(MetricRulesTest.class);		
+		suite.addTestSuite(MetricRulesTest.class);
 		suite.addTestSuite(GenFeatureSeqInitializerTest.class);
 		suite.addTestSuite(GenModelGraphAnalyzerTest.class);
 		suite.addTestSuite(EditHelpersTest.class);
-		//suite.addTest(feed(ParsersTest.class, new ParsersSetup(false), "-direct"));
-		//suite.addTest(feed(ParsersTest.class, new ParsersSetup(true), "-provider"));
+		suite.addTest(feed(ParsersTest.class, new ParsersSetup(false), "-direct"));
+		suite.addTest(feed(ParsersTest.class, new ParsersSetup(true), "-provider"));
 
 		// slowest test goes last
 		suite.addTestSuite(RuntimeCompilationTest.class);
 
-
 		//$JUnit-END$
 		suite.addTest(new CleanupTest("testCleanup") {
+
 			protected void performCleanup() throws Exception {
 				sessionSetup.cleanup();
 				sessionSetup2.cleanup();
@@ -211,7 +209,7 @@
 				setupBundleActivationTest.cleanup();
 			}
 		});
-		
+
 		return suite;
 	}
 
@@ -231,7 +229,7 @@
 		c.register(GenModelTransformerSimpleTest.class, SessionSetup.class);
 		c.register(LabelMappingTransformTest.class, SessionSetup.class);
 		c.register(PaletteTransformationTest.class, SessionSetup.class);
-		c.register(AuditHandcodedTest.class, SessionSetup.class);		
+		c.register(AuditHandcodedTest.class, SessionSetup.class);
 		c.register(CodegenReconcileTest.class, SessionSetup.class);
 		// Default configuration, TestAllDerivedFeatures also runs for LinksSessionSetup 
 		c.register(TestAllDerivedFeatures.class, SessionSetup.class);
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/AbstractDiagramEditorTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/AbstractDiagramEditorTest.java
index 747806a..b955bd4 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/AbstractDiagramEditorTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/AbstractDiagramEditorTest.java
@@ -104,6 +104,7 @@
 	protected void tearDown() throws Exception {
 		if (myEditor != null) {
 			closeEditor(myEditor);
+			myEditor = null;
 		}
 		// keep project alive for potential workspace investigations
 		// deleteProject();
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/ParsersTest.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/ParsersTest.java
index 63b8236..83efec5 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/ParsersTest.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/gef/ParsersTest.java
@@ -525,8 +525,11 @@
 			final PredefinedParser printfRegexParser = GMFGenFactory.eINSTANCE.createPredefinedParser();
 			printfRegexParser.setViewMethod(LabelTextAccessMethod.PRINTF);
 			printfRegexParser.setEditMethod(LabelTextAccessMethod.REGEXP);
+			
 			final CustomParser customParser = GMFGenFactory.eINSTANCE.createCustomParser();
 			customParser.setQualifiedName(diagramkin.getEditPartsPackageName() + ".MyCustomParser");
+			customParser.setGenerateBoilerplate(false); // because we will generate this class externally, see ParsersSetup#GenProjectSetup#hookExtraCodeGeneration
+			
 			final ExternalParser externalParser = GMFGenFactory.eINSTANCE.createExternalParser();
 			externalParser.setHint("\"Description\""); // value of CommonParserHint.DESCIPTION constant, 
 			// not the constant itself to manually (visually) assure (in the generated class) the hint is being used.
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
index c509c49..8b72fee 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/GenProjectSetup.java
@@ -19,6 +19,7 @@
 
 import junit.framework.Assert;
 
+import org.eclipse.core.commands.contexts.Context;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
@@ -36,6 +37,8 @@
 import org.eclipse.gmf.tests.Plugin;
 import org.eclipse.gmf.tests.Utils;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 
@@ -46,7 +49,9 @@
 public class GenProjectSetup extends GenProjectBaseSetup {
 
 	private ArrayList<Bundle> myAllInstalledBundes = new ArrayList<Bundle>();
+
 	private Bundle myBundle;
+
 	private final boolean myIsFullRuntimeRun;
 
 	public GenProjectSetup(GeneratorConfiguration generatorFactory) {
@@ -65,8 +70,9 @@
 	 * FIXME introduce DiaGenSourceBase with single getDiagram() accessor
 	 */
 	public GenProjectSetup init(GenEditorGenerator genEditor) throws BundleException {
-		final boolean[] extensionChangeNotification = new boolean[] {true};
+		final boolean[] extensionChangeNotification = new boolean[] { true };
 		final IRegistryChangeListener listener = new IRegistryChangeListener() {
+
 			public void registryChanged(IRegistryChangeEvent event) {
 				extensionChangeNotification[0] = false;
 			}
@@ -87,6 +93,7 @@
 			// System.out.println("Jobs to wait:" + jt.getJobsCount()); 13!
 			registerExtensions(myBundle);
 			registerEMFEditExtensions();
+			registerContexts();
 			// there should be hit, any .diagram plugin is supposed to register extensions we monitor with the listener above.
 			monitorExtensionLoad(extensionChangeNotification, 60);
 			monitorExtensionLoad(jt.getNonEmptyCondition(), 10);
@@ -127,7 +134,7 @@
 
 	/**
 	 * Manually registering all extensions from the generated (diagramming) plugin into eclipse registries
-	 */ 
+	 */
 	private void registerExtensions(Bundle bundle) {
 		IConfigurationElement[] configElements = getConfigurationElements(bundle.getSymbolicName(), "org.eclipse.emf.ecore.extension_parser");
 		for (int i = 0; i < configElements.length; i++) {
@@ -141,10 +148,38 @@
 		}
 	}
 
+	private void registerContexts() {
+		IContextService contextService = (IContextService) PlatformUI.getWorkbench().getService(IContextService.class);
+		if (contextService == null) {
+			return;
+		}
+
+		for (Bundle next : myAllInstalledBundes) {
+			IConfigurationElement[] configElements = getConfigurationElements(next.getSymbolicName(), "org.eclipse.ui.contexts");
+			for (int i = 0; i < configElements.length; i++) {
+				IConfigurationElement element = configElements[i];
+				if (element.getName().equals("context")) {
+					String id = element.getAttribute("id");
+					String description = element.getAttribute("description");
+					String name = element.getAttribute("name");
+					String parentId = element.getAttribute("parentId");
+					if (id == null || description == null || name == null || parentId == null) {
+						continue;
+					}
+					Context context = contextService.getContext(id);
+					if (!context.isDefined()) {
+						context.define(name, description, parentId);
+					}
+				}
+			}
+		}
+
+	}
+
 	private void registerEMFEditExtensions() {
-		for(Bundle next : myAllInstalledBundes) {
+		for (Bundle next : myAllInstalledBundes) {
 			IConfigurationElement[] configElements = getConfigurationElements(next.getSymbolicName(), "org.eclipse.emf.edit.itemProviderAdapterFactories");
-			for(int i = 0; i < configElements.length; i++) {
+			for (int i = 0; i < configElements.length; i++) {
 				IConfigurationElement element = configElements[i];
 				if (element.getName().equals("factory")) {
 					String packageURI = element.getAttribute("uri");
@@ -152,24 +187,23 @@
 					String supportedTypes = element.getAttribute("supportedTypes");
 					if (packageURI == null) {
 						continue;
-					}
-					else if (className == null) {
+					} else if (className == null) {
 						continue;
-					}
-					else if (supportedTypes == null) {
+					} else if (supportedTypes == null) {
 						continue;
 					}
 					class PluginAdapterFactoryDescriptor extends PluginClassDescriptor implements ComposedAdapterFactory.Descriptor {
+
 						public PluginAdapterFactoryDescriptor(IConfigurationElement element, String attributeName) {
 							super(element, attributeName);
 						}
 
 						public AdapterFactory createAdapterFactory() {
-							return (AdapterFactory)createInstance();
+							return (AdapterFactory) createInstance();
 						}
 					}
 
-					for (StringTokenizer stringTokenizer = new StringTokenizer(supportedTypes); stringTokenizer.hasMoreTokens(); ) {
+					for (StringTokenizer stringTokenizer = new StringTokenizer(supportedTypes); stringTokenizer.hasMoreTokens();) {
 						String supportedType = stringTokenizer.nextToken();
 						ArrayList<String> key = new ArrayList<String>(2);
 						key.add(packageURI);
@@ -189,7 +223,7 @@
 			if (bundlID.equals(configs[i].getContributor().getName())) {
 				ownConfigs.add(configs[i]);
 			}
-		}		
+		}
 		return ownConfigs.toArray(new IConfigurationElement[ownConfigs.size()]);
 	}
 
diff --git a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/RuntimeWorkspaceSetup.java b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/RuntimeWorkspaceSetup.java
index d9ce324..a73e74f 100644
--- a/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/RuntimeWorkspaceSetup.java
+++ b/tests/org.eclipse.gmf.tests/src/org/eclipse/gmf/tests/setup/RuntimeWorkspaceSetup.java
@@ -29,6 +29,7 @@
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.gmf.tests.Plugin;
 import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
 
 /**
  * Running tests within PDE, we face two major problems:
@@ -79,10 +80,10 @@
 		List<String> l = Arrays.asList(Platform.getCommandLineArgs());
 		int i;
 		if ((i = l.indexOf("-dev")) != -1) {
-			isDevBinPresent = i + 1 < l.size() && l.get(i+1).startsWith("bin");
+			isDevBinPresent = i + 1 < l.size() && l.get(i + 1).startsWith("bin");
 		} else {
 			String osgiDevProp = Plugin.getBundleContext().getProperty("osgi.dev");
-			isDevBinPresent = osgiDevProp!= null && osgiDevProp.contains("bin");
+			isDevBinPresent = osgiDevProp != null && osgiDevProp.contains("bin");
 		}
 	}
 
@@ -145,13 +146,14 @@
 	/**
 	 * at least 1.4
 	 */
+	@SuppressWarnings("restriction")
 	private static void ensureJava14() {
-		if (!JavaCore.VERSION_1_4.equals(JavaCore.getOption(JavaCore.COMPILER_SOURCE))) {
+		String actual = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
+		long comparableValue = CompilerOptions.versionToJdkLevel(actual);
+		if (comparableValue < CompilerOptions.versionToJdkLevel(JavaCore.VERSION_1_4)) {
 			@SuppressWarnings("unchecked")
-			Hashtable<String,String> options = JavaCore.getOptions();
-			options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4);
-			options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4);
-			options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_4);
+			Hashtable<String, String> options = JavaCore.getOptions();
+			JavaCore.setComplianceOptions(JavaCore.VERSION_1_4, options);
 			JavaCore.setOptions(options);
 		}
 	}
@@ -163,7 +165,7 @@
 		wd.setFileStateLongevity(0);
 		wd.setMaxFileStates(0);
 		wd.setMaxFileStateSize(0);
-		wd.setSnapshotInterval(60*60*1000);
+		wd.setSnapshotInterval(60 * 60 * 1000);
 	}
 
 	private static void switchAutobuildOff(IWorkspaceDescription wd) {