Merge branch 'master' of git://git.eclipse.org/gitroot/amp/org.eclipse.amp
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/AscapeAspect.xpt b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/AscapeAspect.xpt
index 435337b..f7f12c9 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/AscapeAspect.xpt
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/AscapeAspect.xpt
@@ -229,7 +229,7 @@
     «ELSEIF function.id() == "uniformDistribution"-»
         randomInRange(«inputs.expression(path, inner).toString(", ")»);
 	«ELSEIF function.id() == "timeNow"-»
-		«path.last().accessPath(this, inner)»getScape().getPeriod()
+		«path.last().accessPath(this, inner)»«reference.owner.parent != null ? "getScape()." : ""»getPeriod()
     «ELSEIF function.id() == "available"-»
         isAvailable()
     «ELSEIF function.id() == "withinBoundaries"-»
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/ScapeAspect.xpt b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/ScapeAspect.xpt
index a7703ec..a1f3486 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/ScapeAspect.xpt
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/ScapeAspect.xpt
@@ -142,12 +142,15 @@
         setAutoCreate(false);

         setPrototypeAgent(new org.ascape.model.Scape());

    		«ENDIF-»

-        «IF acts().exists(e| e.metaType == ARule || e.metaType == AInitialize)-»

-        //A manager scape provides rule execution for itself in the case where a Scape is the root scape.

+        «IF acts().exists(e| e.metaType == ARule || e.metaType == AInitialize) || attributes.exists(e | e.gatherData)-»

+        //A manager scape provides rule execution and stat collection for itself.

         if (isRoot()) {

-	        Scape managerScape = new Scape(new Singleton());

-    	    add(managerScape);

+	        Scape «scape()» = new Scape(new Singleton());

+    	    add(«scape()»);

 			«EXPAND ChildBuilderProxy FOR (AGroup) rootActivity-»

+			«IF attributes.exists(e | e.gatherData)-»

+			«EXPAND StatBuilder-»

+			«ENDIF-»

 		}

    		«ENDIF-»

 		«IF (rootActivity != null)-»

@@ -412,10 +415,24 @@
 		«ENDFOREACH»

 «ENDDEFINE»

 

+«DEFINE StatBuilder FOR SAgent-»

+	«IF genStats() != "none"-»

+		«IF parent != null-»

+        «scape()».addStatCollector(new org.ascape.util.data.StatCollectorCond(«scape()».getName() + " Population") {

+        		«EXPAND metaabm::tmpl::Java::GenerateComment»

+				private static final long serialVersionUID = 1L;

+				«EXPAND metaabm::tmpl::Java::GenerateComment»

+                @SuppressWarnings("unused")

+                public final boolean meetsCondition(Object object) {return true;}

+        });

+		«ENDIF-»

+		«EXPAND StatBuilder FOREACH attributes-»

+	«ENDIF-»

+«ENDDEFINE»

 «DEFINE StatBuilderBody(SAttribute outer, String mod, String name) FOR SAttribute-»

     «((SAgent) parent()).fieldName()».addStatCollector(new org.ascape.util.data.StatCollector«outer(outer).statCondTerm()»(«name») {

 		«EXPAND metaabm::tmpl::Java::GenerateComment»

-		private static final long serialVersionUID = 6846144446402098985L;

+		private static final long serialVersionUID = 1L;

 		«IF outer != this-»

 		«EXPAND StatBuilderBody (outer, mod) FOR outer-»

 		«ENDIF-»

@@ -447,18 +464,6 @@
 		«ENDFOREACH-»

 	«ENDIF-»

 «ENDDEFINE»

-«DEFINE StatBuilder FOR SAgent-»

-	«IF genStats() != "none"-»

-        «scape()».addStatCollector(new org.ascape.util.data.StatCollectorCond(«scape()».getName() + " Population") {

-        		«EXPAND metaabm::tmpl::Java::GenerateComment»

-				private static final long serialVersionUID = 684614444640209893L;

-				«EXPAND metaabm::tmpl::Java::GenerateComment»

-                @SuppressWarnings("unused")

-                public final boolean meetsCondition(Object object) {return true;}

-        });

-		«EXPAND StatBuilder FOREACH attributes-»

-	«ENDIF-»

-«ENDDEFINE»

 

 «DEFINE ChildBuilder FOR ARule-»

 		«reference.scape()».addRule(new Rule("«label»") {

@@ -471,7 +476,7 @@
 		});

 «ENDDEFINE»

 «DEFINE ChildBuilderProxy FOR ARule-»

-		managerScape.addRule(new Rule("«label»") {

+		«reference.fieldName()».addRule(new Rule("«label»") {

 			private static final long serialVersionUID = 6846144446402098981L;

 			public void execute(Agent a) {

 				((«this.typeName()») a.getScape()).«id()»();

@@ -494,7 +499,7 @@
 		});

 «ENDDEFINE»

 «DEFINE ChildBuilderProxy FOR AInitialize-»

-		managerScape.addInitialRule(new Rule("«label»") {

+		«reference.scape()».addInitialRule(new Rule("«label»") {

 			private static final long serialVersionUID = 6846144446402098981L;

 			public void execute(Agent a) {

 				((«this.typeName()») a.getScape()).«id()»();

diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/inferascape.ext b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/inferascape.ext
index 6a1bed9..7449294 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/inferascape.ext
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/inferascape.ext
@@ -290,7 +290,9 @@
 	statCond(typed) ? "Cond" : "CSAMM";
 
 cached String statLabel(SAttribute inner, SAttribute outer, String desc) :
-	(inner.parent().parent().parent() != null ? "getName() + \" " : "\"") + inner.parent().label + " " + desc.spaceTrail() + (outer != inner ? outer.label.spaceTrail() : "") + inner.label + "\"";
+	(inner.parent().parent() != null && inner.parent().parent().parent() != null 
+		? "getName() + \" " 
+		: "\"") + inner.parent().label + " " + desc.spaceTrail() + (outer != inner ? outer.label.spaceTrail() : "") + inner.label + "\"";
 
 cached int gridDimSize(SGrid grid) : 
 	grid.attributes.size > 1 ? grid.attributes.get(1).defaultValue.asInteger() : 20;
@@ -312,3 +314,5 @@
 	
 cached List setterSpace(SStyle style) :
 	style.agent.attributes.setterSpace();
+	
+	
\ No newline at end of file
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/namesascape.ext b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/namesascape.ext
index ed2ab4b..803df13 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/namesascape.ext
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ascape/src/metaabm/ascape/tmpl/namesascape.ext
@@ -77,6 +77,9 @@
 cached String scape(SAgent agent) :
 	agent.id() + "Scape";
 
+cached String scape(SContext agent) :
+	agent.parent != null ? agent.id() + "Scape" : agent.id() + "Manager";
+
 cached String fieldName(SAgent agent) :
 	agent.scape();
 	
\ No newline at end of file
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.escape/src/metaabm/escape/tmpl/EscapeAspect.xpt b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.escape/src/metaabm/escape/tmpl/EscapeAspect.xpt
index d18036d..2e8d13e 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.escape/src/metaabm/escape/tmpl/EscapeAspect.xpt
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.escape/src/metaabm/escape/tmpl/EscapeAspect.xpt
@@ -273,7 +273,7 @@
     «ELSEIF function.id() == "uniformDistribution"-»
         randomInRange(«inputs.expression(path, inner).toString(", ")»);
     «ELSEIF function.id() == "timeNow"-»
-        «path.last().accessPath(this, inner)»getScape().getPeriod()
+		«path.last().accessPath(this, inner)»«reference.owner.parent != null ? "getScape()." : ""»getPeriod()
     «ELSEIF function.id() == "available"-»
         isAvailable()
     «ELSEIF function.id() == "withinBoundaries"-»
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ide/src/org/eclipse/amp/amf/gen/ide/AbstractMWEBuilder.java b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ide/src/org/eclipse/amp/amf/gen/ide/AbstractMWEBuilder.java
index 1c07285..905c867 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ide/src/org/eclipse/amp/amf/gen/ide/AbstractMWEBuilder.java
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen.ide/src/org/eclipse/amp/amf/gen/ide/AbstractMWEBuilder.java
@@ -160,6 +160,9 @@
         boolean success = true;
         for (String workflow : workflowPaths) {
             success &= workflowRunner.run(workflow, workflowMonitor, getGenProperties(), slotContents);
+            if (!success) {
+            	break;
+            }
         }
         LogWorkflow.setSuccess(success);
         LogWorkflow.report(pluginName, fullTaskDescription, false);
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen/src/metaabm/tmpl/infer.ext b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen/src/metaabm/tmpl/infer.ext
index 60141e2..2c1403c 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen/src/metaabm/tmpl/infer.ext
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.gen/src/metaabm/tmpl/infer.ext
@@ -85,7 +85,7 @@
 	firstSelection(sel, sel.agent);
 	
 cached String accessPathInner(IID value, SImplemented owner, Boolean inner) :
-	inner ? "((" + owner.implementation.className + ")" + owner.innerValue().id() + ")." : "";
+	inner  && owner.parent != null ? "((" + owner.implementation.className + ")" + owner.innerValue().id() + ")." : "";
 
 cached Boolean ancestor(Void parent, SAgent child) : 
 	false;
diff --git a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.ide.ascape/src/org/eclipse/amp/amf/ide/ascape/AscapeProjectWizard.java b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.ide.ascape/src/org/eclipse/amp/amf/ide/ascape/AscapeProjectWizard.java
index b38a4f7..1e6a10f 100644
--- a/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.ide.ascape/src/org/eclipse/amp/amf/ide/ascape/AscapeProjectWizard.java
+++ b/org.eclipse.amp.amf/plugins/org.eclipse.amp.amf.ide.ascape/src/org/eclipse/amp/amf/ide/ascape/AscapeProjectWizard.java
@@ -46,7 +46,6 @@
 	@Override
 	public List<String> getBuilders() {
 		List<String> builderIDs = super.getBuilders();
-		builderIDs.add(GenIDEPlugin.PLUGIN_ID + "." + MetaABMBuilder.BUILDER_ID);
 		builderIDs.add(GenIDEPlugin.PLUGIN_ID + "." + DocumentModelBuilder.DOCUMENT_BUILDER_ID);
 		builderIDs.add(AscapeIDEActivator.PLUGIN_ID + "." + AscapeModelBuilder.ASCAPE_BUILDER_ID);
 		return builderIDs;
diff --git a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.amf.ide/src/org/eclipse/amp/escape/amf/ide/EscapeAMFProjectWizard.java b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.amf.ide/src/org/eclipse/amp/escape/amf/ide/EscapeAMFProjectWizard.java
index eb4c132..554fbc5 100644
--- a/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.amf.ide/src/org/eclipse/amp/escape/amf/ide/EscapeAMFProjectWizard.java
+++ b/org.eclipse.amp.escape/plugins/org.eclipse.amp.escape.amf.ide/src/org/eclipse/amp/escape/amf/ide/EscapeAMFProjectWizard.java
@@ -42,7 +42,6 @@
 	@Override
 	public List<String> getBuilders() {
 		List<String> builderIDs = new ArrayList<String>();
-		builderIDs.add(GenIDEPlugin.PLUGIN_ID + "." + MetaABMBuilder.BUILDER_ID);
 		builderIDs.add(GenIDEPlugin.PLUGIN_ID + "." + DocumentModelBuilder.DOCUMENT_BUILDER_ID);
 		builderIDs.add(EscapeAMFPlugin.PLUGIN_ID + "." + EscapeModelBuilder.ESCAPE_BUILDER_ID);
 		builderIDs.addAll(super.getBuilders());