catch up with branch daily

Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF b/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
index 5cdc017..a9f5a4a 100644
--- a/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
@@ -41,7 +41,7 @@
  org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional,
  filteringtable.osgi,
  popupbutton.osgi;bundle-version="[2.5.0,2.5.1)",
- mondrian.osgi;bundle-version="[3.5.0,3.5.1)",
+ mondrian.osgi;bundle-version="[3.5.0,4.0.0)",
  olap4j.osgi;bundle-version="[1.1.0,1.3.0)",
  refresher.osgi;bundle-version="[1.2.3.7,1.2.4)",
  org.eclipse.osbp.dsl.entity.xtext;bundle-version="[0.9.0,0.10.0)",
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
index ac10575..14ef6a1 100644
--- a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
@@ -80,6 +80,7 @@
 import org.eclipse.osbp.xtext.datamart.common.sql.OperativeDtoContainer
 import org.eclipse.osbp.xtext.datamartdsl.AxisEnum
 import org.eclipse.osbp.xtext.datamartdsl.DatamartAttribute
+import org.eclipse.osbp.xtext.datamartdsl.DatamartCube
 import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition
 import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity
 import org.eclipse.osbp.xtext.datamartdsl.DatamartPackage
@@ -151,7 +152,7 @@
  * <p>Helper class for a Treemap in order to make double values comparable.</p> 
  *
  */
-class DoubleComparator implements Comparator<Double> {
+class DoubleComparator implements Comparator<Double> { 
 	override compare(Double arg0, Double arg1) {
 		if (arg0 < arg1) {
 			return -1
@@ -268,6 +269,7 @@
 			else {
 				clsName = pkg.name.toString.concat(".").concat(table.name).concat(fileExtension.toFirstUpper)
 			}
+			val className = clsName
 			val cls = table.toClass(clsName)
 			if (table.isEmbedded) {
 				cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IViewEmbeddedProvider))
@@ -292,7 +294,7 @@
 				it.toFields(table)
 				it.toConstructor(table)
 				it.toGetterSetter(table)
-				it.toOperations(pkg, table)
+				it.toOperations(pkg, table, className)
 			])
 			if (table.isEmbedded) {
 
@@ -425,9 +427,6 @@
 		type.members += field
 		field = table.toField("blobService", _typeReferenceBuilder.typeRef(IBlobService)) [annotations += _annotationTypesBuilder.annotationRef(Inject)]
 		type.members += field
-		field = table.toField("selectedId", _typeReferenceBuilder.typeRef(Object)) [initializer = [append('''null''')]]
-		field.visibility = JvmVisibility::PRIVATE
-		type.members += field
 		// the package name of the referenced datamart
 		if (getSourceDataMartRefName(table) !== null) {
 			var packageName = (table.dataMartTable.datamartRef.eContainer as DatamartPackage).fullyQualifiedName.
@@ -437,6 +436,10 @@
 			type.members += field
 			field = table.toField("filterGenerator", _typeReferenceBuilder.typeRef(IDatamartFilterGenerator))
 			type.members += field
+			if(!table.task) {
+				field = table.toField("moreToLoad", _typeReferenceBuilder.typeRef(boolean)) [initializer = [append('''false''')]]
+				type.members += field
+			}
 		}
 		if(table.grid) {
 			field = table.toField("gridSourceService", _typeReferenceBuilder.typeRef(IGridSourceFacade))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
@@ -516,26 +519,24 @@
 			_typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer)))
 		operation.visibility = JvmVisibility::PUBLIC
 		type.members += operation
-		operation = table.toGetter("selectedId",
-			_typeReferenceBuilder.typeRef(Object))
-		operation.visibility = JvmVisibility::PUBLIC
-		type.members += operation
 	}
 
 	/**
 	 * <p>build the methods.</p> 
 	 *
 	 */
-	def void toOperations(JvmDeclaredType type, TablePackage pkg, Table table) {
+	def void toOperations(JvmDeclaredType type, TablePackage pkg, Table table, String clsName) {
 
 		// create view
 		type.members += table.toMethod("getCellSet", _typeReferenceBuilder.typeRef(DerivedCellSet),
 			[
+				parameters += table.toParameter("limited", _typeReferenceBuilder.typeRef(boolean))
 				body = [append(
 				'''
 				operativeDtoContainer = null;
 				«IF (table.dataMartTable !== null)»
-				DerivedCellSet cellSet = datamartInstance.getResults(«IF table.task»«ELSE»«IF ((table.isSelection) || table.isEmbedded)»null, null«ELSE»getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()«ENDIF»«ENDIF»);
+				DerivedCellSet cellSet = datamartInstance.getResults(«IF table.task||table.cube»«ELSE»«IF ((table.isSelection) || table.isEmbedded)»limited, null, null«ELSE»limited, getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()«ENDIF»«ENDIF»);
+				«IF !table.task && !table.isCube»moreToLoad = datamartInstance.isMoreToLoad();«ENDIF»
 				«ELSE»
 				DerivedCellSet cellSet = null;
 				«ENDIF»
@@ -570,13 +571,14 @@
 				annotations += _annotationTypesBuilder.annotationRef(PostConstruct)
 				body = [append(
 				'''
+				«IF !table.embedded»super.initView();«ENDIF»
 				user.addUserLocaleListener(this);
 				eventDispatcher.addEventReceiver(this);
 				«IF table.task»
 				taskClient.subscribeTaskEventNotification(this);
 				taskClient.subscribeProcessCompletedEventNotification(this);
 				«ENDIF»
-				«IF !table.grid && !table.isEmbedded»
+				«IF !table.grid && !table.isEmbedded && (table.task || table.cube)»
 				filterGenerator.addFilterChangeListener(this);
 				«ENDIF»
 				''')]
@@ -598,7 +600,7 @@
 				«IF !table.grid && !table.isEmbedded»
 				filterGenerator.removeFilterChangeListener(this);
 				«ENDIF»
-				''')]
+				«IF !table.embedded»super.destroyView();«ENDIF»''')]
 			])
 		// create view
 		type.members += table.toMethod("createView", _typeReferenceBuilder.typeRef(Void::TYPE),
@@ -613,8 +615,22 @@
 		// create components
 		type.members += table.toMethod("createComponents", _typeReferenceBuilder.typeRef(Void::TYPE),
 			[
-				body = [append('''«table.createComponents»''')]
+				body = [append('''«table.createComponents(clsName)»''')]
 			])
+		// setEnableManualInput dummy
+		type.members += table.toMethod("setEnableManualInput", _typeReferenceBuilder.typeRef(Void::TYPE), [
+			documentation = table.tabletype.documentation
+			visibility = JvmVisibility.PUBLIC
+			parameters += table.toParameter("manualInput", _typeReferenceBuilder.typeRef(boolean))
+			body = [append('''''')]
+		])
+		// setInput dummy
+		type.members += table.toMethod("setInput", _typeReferenceBuilder.typeRef(Void::TYPE), [
+			documentation = table.tabletype.documentation
+			visibility = JvmVisibility.PUBLIC
+			parameters += table.toParameter("dto", _typeReferenceBuilder.typeRef(Object))
+			body = [append('''''')]
+		])
 
 		// getSelectById
 		type.members += table.toMethod("getSelectById", _typeReferenceBuilder.typeRef(boolean), [
@@ -643,6 +659,20 @@
 						body = [append('''«table.createTable»''')]
 					])
 					
+				// init table
+				type.members += table.toMethod("initTable", _typeReferenceBuilder.typeRef(Void::TYPE),
+					[
+						parameters += table.toParameter("table", _typeReferenceBuilder.typeRef(CellSetFilterTable))
+						parameters += table.toParameter("cellSet", _typeReferenceBuilder.typeRef(DerivedCellSet))
+						body = [append('''«table.initTable»''')]
+					])
+					
+				type.members += table.toMethod("tableSettingsByUserProperties", _typeReferenceBuilder.typeRef(Void::TYPE),
+					[
+						parameters += table.toParameter("table", _typeReferenceBuilder.typeRef(CellSetFilterTable))
+						body = [append('''«table.tableSettingsByUserProperties»''')]
+					])
+					
 				type.members += table.toMethod("dataRefresh", _typeReferenceBuilder.typeRef(Void::TYPE),
 					[
 						body = [append('''«table.dataRefresh»''')]
@@ -811,7 +841,6 @@
 								«IF table.isEmbedded || table.task»
 								createComponents();
 								«ELSE»
-								selectedId = event.getData().get(EventDispatcherDataTag.ID);
 								renderData();
 								«ENDIF»
 							}
@@ -930,14 +959,7 @@
 			layoutManager.init(parent);
 			this.parent = parent;
 		'''
-		if(table.isGrid) {
-			val entity = EntityUtils.getEntityFromDto(table.dtoGridTable.dtoSource)
-			body = '''
-			«body»
-			persistenceService.registerPersistenceUnit("«entity?.persistenceUnit»", 
-									«entity?.fullyQualifiedName».class);
-			log.debug("PersistenceService registered");'''
-		} else {
+		if(!table.isGrid) {
 			body = '''
 			«body»
 			datamartInstance = new «getSourceDataMartRefName(table)»Datamart();
@@ -963,8 +985,8 @@
 			body = '''
 			«body»
 			toolbarUUID = UUID.randomUUID().toString();
-			toolbarClass = new «table.tabletype.toolbar.name.toString.toFirstUpper»Toolbar(toolbarUUID);
-			toolbarClass.createToolbar(eclipseContext, renderingEngine, themeResourceService);'''
+			toolbarClass = new «table.tabletype.toolbar.name.toString.toFirstUpper»Toolbar();
+			toolbarClass.createToolbar(eclipseContext, renderingEngine, themeResourceService, toolbarUUID);'''
 		}
 		body = '''
 			«body»
@@ -978,6 +1000,11 @@
 			(table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartTask;
 	}
 	
+	def boolean isCube(Table table) {
+		return table.dataMartTable instanceof TableDatamart &&
+			(table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartCube;
+	}
+	
 	def boolean isGrid(Table table) {
 		return table.tabletype instanceof TableGrid
 	}
@@ -996,11 +1023,14 @@
 
 	def renderAllowed() 
 	'''
-	if (getSelectById() && getSelectedId()==null) {
+	if (getSelectById()) {
 		for (DatamartFilter filter : datamartInstance.getFilters()) {
 			if(filter.isOptional()) {
 				return true;
 			}
+			if(!filter.getSql().isEmpty()) {
+				return true;
+			}
 		} 
 		return false;
 	}
@@ -1019,7 +1049,7 @@
 					break;
 				}
 			}
-			if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet())) {
+			if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet(true))) {
 				log.debug("cannot update container - full refresh");
 				«IF table.isEmbedded»
 				createComponents();
@@ -1043,13 +1073,13 @@
 	 * <p>build the data components.</p> 
 	 *
 	 */
-	def String createComponents(Table table) {
+	def String createComponents(Table table, String clsName) {
 		var body = ""
 		if (table.dataMartTable !== null) {
 			body = '''
 				if (renderAllowed()){
 					// get the results
-					final DerivedCellSet cellSet = getCellSet();
+					final DerivedCellSet cellSet = getCellSet(true);
 					if (cellSet == null) {
 						«IF !table.isEmbedded»promptSecurityMessage(dslMetadataService.translate(user.getLocale().toLanguageTag(), "securityMessage"), layoutManager.getDataArea());«ENDIF»
 						return;
@@ -1067,6 +1097,34 @@
 					tables.clear();
 					// generate a new result component
 					if (cellSet != null) {
+						«IF !table.task && !table.cube»
+						if(moreToLoad) {
+							Runnable backgroundFetch = new Runnable() {
+								public void run() {
+								    operativeDtoContainer = null;
+								    final DerivedCellSet cellSetAll = datamartInstance.getResults(false, getTaskOperativeDtoClass(), getTaskInitialOperativeDtos());
+								    if	(cellSet != null) {
+								    	operativeDtoContainer = cellSet.getOperativeDtoContainer();
+								    }
+									for(CellSetFilterTable table:tables) {
+									    dataSourceContainer = new CellSetIndexedContainer(eclipseContext, attributeLookupMap, cellSetAll, coordinateSystem, false);
+										UI.getCurrent().access(new Runnable() {
+											@Override
+											public void run() {
+											    table.setContainerDataSource(dataSourceContainer);
+											    initTable(table, cellSetAll);
+											    filterGenerator.addFilterChangeListener(«clsName».this);
+											}
+										});
+									}
+								}
+							};
+							new Thread(backgroundFetch).start();
+							moreToLoad = false;
+						} else {
+						    filterGenerator.addFilterChangeListener(«clsName».this);
+						}
+						«ENDIF»
 						// create a multidimensional coordinate system against the cellSet
 						for	(int axis = 0; axis < cellSet.getAxes().size(); axis++) {
 							getCoordinateSystem().add(0);
@@ -1209,6 +1267,65 @@
 	 */
 	def String createTable(Table table) {
 		var body = ""
+		var constructTable = "final CellSetFilterTable table = new CellSetFilterTable();"
+		var multiSelect = false;
+		if	(table.isSelection) {
+			constructTable = '''
+				final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable();
+				table.addTableRowCheckListener(this);
+				selectTable = table;
+			'''
+			multiSelect = (table.tabletype as TableSelection).multiSelection
+		}
+		body = '''
+			«body»«constructTable»
+			VerticalLayout tableLayout = new VerticalLayout();
+			«IF table.isEmbedded && table.isTask»
+			taskButtons = new ArrayList<Button>();
+			HorizontalLayout tools = new HorizontalLayout();
+			tools.addStyleName("os-embedded-toolbar");
+			tools.setSpacing(false);
+			
+			Button b = new Button(null, new Button.ClickListener() {
+			    public void buttonClick(ClickEvent event) {
+			    	taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);
+			    	MPerspective perspective = eclipseContext.get(MPerspective.class);
+					EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, "UserMenu", "«table.fullyQualifiedName»");
+					eventDispatcher.sendEvent(evnt);
+			    }
+			});
+			b.setIcon(themeResourceService.getThemeResource("task_action_resume", ThemeResourceType.ICON));
+			b.setDescription(null);
+			b.setEnabled(false);
+			b.addStyleName("v-button-small");
+			tools.addComponent(b);
+			taskButtons.add(b);
+			tableLayout.addComponent(tools);
+			«ENDIF»
+			table.setImmediate(true);
+			table.setMultiSelect(«multiSelect»);
+			table.setColumnCollapsingAllowed(true);
+			table.setColumnReorderingAllowed(true);
+			table.setId("table");
+			«IF table.isTable»
+			table.setRowHeaderMode(RowHeaderMode.«IF (table.tabletype as TableTable).headerMode !== null»«(table.tabletype as TableTable).headerMode.name()»«ELSE»HIDDEN«ENDIF»);
+			«ENDIF»
+			table.setFilterDecorator(tableFilterDecorator);
+			table.setFilterBarVisible(«table.tabletype.filtering.booleanValue»);
+			table.setSelectable(true);
+			table.setSizeFull();
+			tableLayout.addComponent(table);
+			tables.add(table);
+			initTable(table, cellSet);
+			return tableLayout;'''
+	}
+
+	/**
+	 * <p>build the table component.</p> 
+	 *
+	 */
+	def String initTable(Table table) {
+		var body = ""
 		var TableAxis category_axis = null
 		var TableAxis data_axis = null
 		var idMap = <String, IdAttribute>newHashMap
@@ -1258,57 +1375,6 @@
 			data_axis.axis = AxisEnum.COLUMNS;
 			table.dataMartTable.elements.add(data_axis);
 		}
-		var constructTable = "final CellSetFilterTable table = new CellSetFilterTable();"
-		var multiSelect = false;
-		if	(table.isSelection) {
-			constructTable = '''
-				final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable();
-				table.addTableRowCheckListener(this);
-				selectTable = table;
-			'''
-			multiSelect = (table.tabletype as TableSelection).multiSelection
-		}
-		body = '''
-			«body»«constructTable»
-			VerticalLayout tableLayout = new VerticalLayout();
-			«IF table.isEmbedded && table.isTask»
-			taskButtons = new ArrayList<Button>();
-			HorizontalLayout tools = new HorizontalLayout();
-			tools.addStyleName("os-embedded-toolbar");
-			tools.setSpacing(false);
-			
-			Button b = new Button(null, new Button.ClickListener() {
-			    public void buttonClick(ClickEvent event) {
-			    	taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);
-			    	MPerspective perspective = eclipseContext.get(MPerspective.class);
-					EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, "UserMenu", "«table.fullyQualifiedName»");
-					eventDispatcher.sendEvent(evnt);
-			    }
-			});
-			b.setIcon(themeResourceService.getThemeResource("task_action_start", ThemeResourceType.ICON));
-			b.setDescription(null);
-			b.setEnabled(false);
-			b.addStyleName("v-button-small");
-			tools.addComponent(b);
-			taskButtons.add(b);
-			tableLayout.addComponent(tools);
-			«ENDIF»
-			table.setImmediate(true);
-			table.setMultiSelect(«multiSelect»);
-			table.setColumnCollapsingAllowed(true);
-			table.setColumnReorderingAllowed(true);
-			table.setId("table");
-			«IF table.isTable»
-			table.setRowHeaderMode(RowHeaderMode.«IF (table.tabletype as TableTable).headerMode !== null»«(table.tabletype as TableTable).headerMode.name()»«ELSE»HIDDEN«ENDIF»);
-			«ENDIF»
-			table.setFilterDecorator(tableFilterDecorator);
-			table.setFilterBarVisible(«table.tabletype.filtering.booleanValue»);
-			table.setSelectable(true);
-			table.setSizeFull();
-			tableLayout.addComponent(table);
-			tables.add(table);
-		'''
-
 		// Initialization of the BlobLookupMap
 		table.initBlobLookup(blobLookupMap)
 		// Initialization of the EnumSet
@@ -1354,8 +1420,14 @@
 			dataSourceContainer = new CellSetIndexedContainer(eclipseContext, attributeLookupMap, cellSet, coordinateSystem, «table.isDatamartCrossJoined»);
 			table.setContainerDataSource(dataSourceContainer);
 			dataSourceContainer.addExtras(table);
+			tableSettingsByUserProperties(table);
 		'''
-		body = '''«body»«tableSettingsByUserProperties»«table.sendEvent»«columnCollapsedListener»«columnReorderListener»«columnResizeListener»
+		body = '''
+		«body»
+		«table.sendEvent»
+		«columnCollapsedListener»
+		«columnReorderListener»
+		«columnResizeListener»
 		'''
 		if (category_axis.hasRowHeight) {
 			body = '''
@@ -1393,7 +1465,6 @@
 			selectItemsFromWorkloadDto();
 			'''
 		}
-		body = '''«body»return tableLayout;'''
 		return body
 	}
 	
@@ -1899,14 +1970,14 @@
 		var datamartSource = table.dataMartTable.datamartRef.source
 		if (datamartSource instanceof DatamartEntity) {
 			// Initial all attributes of the entity
-			for (attribute : (datamartSource as DatamartEntity).entityRef.allAttributes) {
-				var resolution = attribute.resolution
+			for (attribute : table.dataMartTable.datamartRef.allEntityAttributes()) {
+				var resolution = attribute.attributeRef.resolution
 				if (resolution!== null) {
-					blobMap.put('''«attribute?.name?.replace("^", "")»''', resolution?.value)
+					blobMap.put('''«attribute?.attributeRef?.name?.replace("^", "")»''', resolution?.value)
 				}
 			}
 			// In case of having any explicit attribute definition
-			for (attribute : (datamartSource as DatamartEntity).attributes) {
+			for (attribute : table.dataMartTable.datamartRef.allEntityAttributes()) {
 				var resolution = attribute.attributeRef.resolution
 				if (resolution !== null) {
 					blobMap.put(DatamartAttributeUtil.getAliasedAttributeName(attribute), resolution?.value)
@@ -1923,9 +1994,9 @@
 		var datamartSource = table.dataMartTable.datamartRef.source
 		if (datamartSource instanceof DatamartEntity) {
 			// Initial all attributes of the entity
-			for (attribute : (datamartSource as DatamartEntity).entityRef.allAttributes) {
-				if (attribute.typeIsEnum) {
-					enumMap.put('''«attribute?.name?.replace("^", "")»''', '''«attribute?.type?.fullyQualifiedName»''')
+			for (attribute : table.dataMartTable.datamartRef.allEntityAttributes()) {
+				if (attribute.attributeRef.typeIsEnum) {
+					enumMap.put('''«attribute?.attributeRef?.name?.replace("^", "")»''', '''«attribute?.attributeRef?.type?.fullyQualifiedName»''')
 				}
 			}
 		}
@@ -2757,18 +2828,18 @@
 							body = '''
 							«body»
 									«IF entity.primaryKeyAttribute !== null»
+									Object idObj = dataSourceContainer.getValueByProperty(selection, "«alias.toLowerCase»");
 									MPerspective perspective = getContext().get(MPerspective.class);
 									EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", "«table.fullyQualifiedName»");
-									evnt.addItem(EventDispatcherDataTag.ID, dataSourceContainer.getValueByProperty(selection, "«alias.toLowerCase»"));
+									evnt.addItem(EventDispatcherDataTag.ID, idObj);
 									eventDispatcher.sendEvent(evnt);
+									SelectionStore.putSelectionToPerspectiveContext(getPart(), "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", idObj);
 									for (DatamartPrimary<?> primary : datamartInstance.getPrimaryList()){
 										if (!"«entity.baseType.fullyQualifiedName»".equals(primary.getEntityName())){
 											Object primaryValue = dataSourceContainer.getValueByProperty(selection, primary.getAlias().toLowerCase());
-											if (primaryValue != null) {
-												evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, primary.getEntityName() + "." + primary.getAttributeName(), "«table.fullyQualifiedName»");
-												evnt.addItem(EventDispatcherDataTag.ID, primaryValue);
-												eventDispatcher.sendEvent(evnt);
-											}
+											evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, primary.getEntityName() + "." + primary.getAttributeName(), "«table.fullyQualifiedName»");
+											evnt.addItem(EventDispatcherDataTag.ID, primaryValue);
+											eventDispatcher.sendEvent(evnt);
 										}
 									}
 									«ENDIF»
@@ -2876,7 +2947,7 @@
 });
 '''
 	
-	def tableSettingsByUserProperties() 
+	def tableSettingsByUserProperties(Table table) 
 		'''
 		// Setting the order of the columns via the visibleColumns list
 		Map<Object, Integer> visibleColumnsMap = user.getColumnUtil().getVisibleColumns(this.getClass().getCanonicalName() + ".columns");
@@ -3061,7 +3132,12 @@
 						workLoadItem.addOperativeDto(taskClient.getWorkloadDto(taskSummary), «IF "int".equals(keyType.name)»dtoService.get((int) Integer.parseInt(idValue))«ELSE»dtoService.get(idValue)«ENDIF»);
 					}
 					else {
-						workLoadItem.removeOperativeDto(taskClient.getWorkloadDto(taskSummary), «IF "int".equals(keyType.name)»dtoService.get((int) Integer.parseInt(idValue))«ELSE»dtoService.get(idValue)«ENDIF»);
+					   	for(IDto dtoToRemove : workLoadItem.getOperativeDtos(taskClient.getWorkloadDto(taskSummary))) {
+							if(((«dtoFqn»)dtoToRemove).getId()«IF "int".equals(keyType.name)»==(int) Integer.parseInt(idValue)«ELSE».equals(idValue)«ENDIF») {
+								workLoadItem.removeOperativeDto(taskClient.getWorkloadDto(taskSummary), dtoToRemove);
+								break;
+							}
+						}
 					}
 					'''
 				}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
index 44b09e0..fd0947f 100644
--- a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
@@ -119,6 +119,7 @@
 import org.osgi.service.event.Event
 import org.osgi.service.event.EventHandler
 import org.vaadin.hene.popupbutton.PopupButton
+import org.eclipse.osbp.runtime.common.event.SelectionStore
 
 class TableModelGenerator extends I18NModelGenerator {
 	@Inject TableGridSourceGenerator delegate
@@ -231,7 +232,8 @@
 			IDualData,
 			MPerspective,
 			MPart,
-			IPerspectiveProvider
+			IPerspectiveProvider,
+			SelectionStore
 		)
 		super.createAppendable(context, importManager, config)
 	}
diff --git a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
index 3c8da96..93a0eea 100644
--- a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
+++ b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
@@ -81,6 +81,7 @@
 import org.eclipse.osbp.xtext.datamart.common.sql.OperativeDtoContainer;
 import org.eclipse.osbp.xtext.datamartdsl.AxisEnum;
 import org.eclipse.osbp.xtext.datamartdsl.DatamartAttribute;
+import org.eclipse.osbp.xtext.datamartdsl.DatamartCube;
 import org.eclipse.osbp.xtext.datamartdsl.DatamartDefinition;
 import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity;
 import org.eclipse.osbp.xtext.datamartdsl.DatamartNavigation;
@@ -258,6 +259,7 @@
             }
           }
         }
+        final String className = clsName;
         final JvmGenericType cls = this._jvmTypesBuilder.toClass(table, clsName);
         boolean _isEmbedded_1 = this.isEmbedded(table);
         if (_isEmbedded_1) {
@@ -284,7 +286,7 @@
           this.toFields(it, table);
           this.toConstructor(it, table);
           this.toGetterSetter(it, table);
-          this.toOperations(it, pkg, table);
+          this.toOperations(it, pkg, table, className);
         };
         acceptor.<JvmGenericType>accept(cls, _function_1);
         boolean _isEmbedded_2 = this.isEmbedded(table);
@@ -505,18 +507,6 @@
     field = this._jvmTypesBuilder.toField(table, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class), _function_6);
     EList<JvmMember> _members_9 = type.getMembers();
     this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
-    final Procedure1<JvmField> _function_7 = (JvmField it) -> {
-      final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
-        StringConcatenation _builder = new StringConcatenation();
-        _builder.append("null");
-        it_1.append(_builder);
-      };
-      this._jvmTypesBuilder.setInitializer(it, _function_8);
-    };
-    field = this._jvmTypesBuilder.toField(table, "selectedId", this._typeReferenceBuilder.typeRef(Object.class), _function_7);
-    field.setVisibility(JvmVisibility.PRIVATE);
-    EList<JvmMember> _members_10 = type.getMembers();
-    this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
     String _sourceDataMartRefName = this.getSourceDataMartRefName(table);
     boolean _tripleNotEquals = (_sourceDataMartRefName != null);
     if (_tripleNotEquals) {
@@ -530,11 +520,26 @@
       _builder.append("Datamart");
       field = this._jvmTypesBuilder.toField(table, "datamartInstance", 
         this._typeReferenceBuilder.typeRef(_builder.toString()));
+      EList<JvmMember> _members_10 = type.getMembers();
+      this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
+      field = this._jvmTypesBuilder.toField(table, "filterGenerator", this._typeReferenceBuilder.typeRef(IDatamartFilterGenerator.class));
       EList<JvmMember> _members_11 = type.getMembers();
       this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
-      field = this._jvmTypesBuilder.toField(table, "filterGenerator", this._typeReferenceBuilder.typeRef(IDatamartFilterGenerator.class));
-      EList<JvmMember> _members_12 = type.getMembers();
-      this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
+      boolean _isTask = this.isTask(table);
+      boolean _not = (!_isTask);
+      if (_not) {
+        final Procedure1<JvmField> _function_7 = (JvmField it) -> {
+          final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
+            StringConcatenation _builder_1 = new StringConcatenation();
+            _builder_1.append("false");
+            it_1.append(_builder_1);
+          };
+          this._jvmTypesBuilder.setInitializer(it, _function_8);
+        };
+        field = this._jvmTypesBuilder.toField(table, "moreToLoad", this._typeReferenceBuilder.typeRef(boolean.class), _function_7);
+        EList<JvmMember> _members_12 = type.getMembers();
+        this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
+      }
     }
     boolean _isGrid = this.isGrid(table);
     if (_isGrid) {
@@ -616,8 +621,8 @@
     field = this._jvmTypesBuilder.toField(table, "tableFilterDecorator", this._typeReferenceBuilder.typeRef(TableFilterDecorator.class));
     EList<JvmMember> _members_26 = type.getMembers();
     this._jvmTypesBuilder.<JvmField>operator_add(_members_26, field);
-    boolean _isTask = this.isTask(table);
-    if (_isTask) {
+    boolean _isTask_1 = this.isTask(table);
+    if (_isTask_1) {
       final Procedure1<JvmField> _function_14 = (JvmField it) -> {
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
@@ -688,19 +693,17 @@
     operation.setVisibility(JvmVisibility.PUBLIC);
     EList<JvmMember> _members = type.getMembers();
     this._jvmTypesBuilder.<JvmOperation>operator_add(_members, operation);
-    operation = this._jvmTypesBuilder.toGetter(table, "selectedId", 
-      this._typeReferenceBuilder.typeRef(Object.class));
-    operation.setVisibility(JvmVisibility.PUBLIC);
-    EList<JvmMember> _members_1 = type.getMembers();
-    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, operation);
   }
   
   /**
    * <p>build the methods.</p>
    */
-  public void toOperations(final JvmDeclaredType type, final TablePackage pkg, final Table table) {
+  public void toOperations(final JvmDeclaredType type, final TablePackage pkg, final Table table, final String clsName) {
     EList<JvmMember> _members = type.getMembers();
     final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
+      EList<JvmFormalParameter> _parameters = it.getParameters();
+      JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "limited", this._typeReferenceBuilder.typeRef(boolean.class));
+      this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
       final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         _builder.append("operativeDtoContainer = null;");
@@ -711,20 +714,25 @@
           if (_tripleNotEquals) {
             _builder.append("DerivedCellSet cellSet = datamartInstance.getResults(");
             {
-              boolean _isTask = this.isTask(table);
-              if (_isTask) {
+              if ((this.isTask(table) || this.isCube(table))) {
               } else {
                 {
                   if ((this.isSelection(table) || this.isEmbedded(table))) {
-                    _builder.append("null, null");
+                    _builder.append("limited, null, null");
                   } else {
-                    _builder.append("getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()");
+                    _builder.append("limited, getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()");
                   }
                 }
               }
             }
             _builder.append(");");
             _builder.newLineIfNotEmpty();
+            {
+              if (((!this.isTask(table)) && (!this.isCube(table)))) {
+                _builder.append("moreToLoad = datamartInstance.isMoreToLoad();");
+              }
+            }
+            _builder.newLineIfNotEmpty();
           } else {
             _builder.append("DerivedCellSet cellSet = null;");
             _builder.newLine();
@@ -786,6 +794,14 @@
       this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
       final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
+        {
+          boolean _isEmbedded = this.isEmbedded(table);
+          boolean _not = (!_isEmbedded);
+          if (_not) {
+            _builder.append("super.initView();");
+          }
+        }
+        _builder.newLineIfNotEmpty();
         _builder.append("user.addUserLocaleListener(this);");
         _builder.newLine();
         _builder.append("eventDispatcher.addEventReceiver(this);");
@@ -800,7 +816,7 @@
           }
         }
         {
-          if (((!this.isGrid(table)) && (!this.isEmbedded(table)))) {
+          if ((((!this.isGrid(table)) && (!this.isEmbedded(table))) && (this.isTask(table) || this.isCube(table)))) {
             _builder.append("filterGenerator.addFilterChangeListener(this);");
             _builder.newLine();
           }
@@ -837,6 +853,13 @@
             _builder.newLine();
           }
         }
+        {
+          boolean _isEmbedded = this.isEmbedded(table);
+          boolean _not = (!_isEmbedded);
+          if (_not) {
+            _builder.append("super.destroyView();");
+          }
+        }
         it_1.append(_builder);
       };
       this._jvmTypesBuilder.setBody(it, _function_4);
@@ -868,7 +891,7 @@
     final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
       final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
-        String _createComponents = this.createComponents(table);
+        String _createComponents = this.createComponents(table, clsName);
         _builder.append(_createComponents);
         it_1.append(_builder);
       };
@@ -879,9 +902,39 @@
     EList<JvmMember> _members_6 = type.getMembers();
     final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> {
       this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(table.getTabletype()));
-      it.setVisibility(JvmVisibility.PRIVATE);
+      it.setVisibility(JvmVisibility.PUBLIC);
+      EList<JvmFormalParameter> _parameters = it.getParameters();
+      JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "manualInput", this._typeReferenceBuilder.typeRef(boolean.class));
+      this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
       final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
+        it_1.append(_builder);
+      };
+      this._jvmTypesBuilder.setBody(it, _function_7);
+    };
+    JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(table, "setEnableManualInput", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_6);
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
+    EList<JvmMember> _members_7 = type.getMembers();
+    final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
+      this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(table.getTabletype()));
+      it.setVisibility(JvmVisibility.PUBLIC);
+      EList<JvmFormalParameter> _parameters = it.getParameters();
+      JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "dto", this._typeReferenceBuilder.typeRef(Object.class));
+      this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
+      final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
+        StringConcatenation _builder = new StringConcatenation();
+        it_1.append(_builder);
+      };
+      this._jvmTypesBuilder.setBody(it, _function_8);
+    };
+    JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(table, "setInput", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_7);
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
+    EList<JvmMember> _members_8 = type.getMembers();
+    final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
+      this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(table.getTabletype()));
+      it.setVisibility(JvmVisibility.PRIVATE);
+      final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
+        StringConcatenation _builder = new StringConcatenation();
         _builder.append("return ");
         {
           TableOption _tabletype = table.getTabletype();
@@ -896,77 +949,110 @@
         _builder.append(";");
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setBody(it, _function_7);
+      this._jvmTypesBuilder.setBody(it, _function_9);
     };
-    JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(table, "getSelectById", this._typeReferenceBuilder.typeRef(boolean.class), _function_6);
-    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
+    JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(table, "getSelectById", this._typeReferenceBuilder.typeRef(boolean.class), _function_8);
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
     TableOption _tabletype = table.getTabletype();
     boolean _matched = false;
     if (_tabletype instanceof TableTable) {
       _matched=true;
-      EList<JvmMember> _members_7 = type.getMembers();
-      final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
+      EList<JvmMember> _members_9 = type.getMembers();
+      final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
         EList<JvmFormalParameter> _parameters = it.getParameters();
         JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "cellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
         EList<JvmFormalParameter> _parameters_1 = it.getParameters();
         JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(table, "axisNo", this._typeReferenceBuilder.typeRef(Integer.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
-        final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           String _createTabSheet = this.createTabSheet(table);
           _builder.append(_createTabSheet);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_8);
+        this._jvmTypesBuilder.setBody(it, _function_10);
       };
-      JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(table, "createTabSheet", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_7);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
-      EList<JvmMember> _members_8 = type.getMembers();
-      final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
+      JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(table, "createTabSheet", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_9);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
+      EList<JvmMember> _members_10 = type.getMembers();
+      final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
         EList<JvmFormalParameter> _parameters = it.getParameters();
         JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "cellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
-        final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           String _createTable = this.createTable(table);
           _builder.append(_createTable);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_9);
+        this._jvmTypesBuilder.setBody(it, _function_11);
       };
-      JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(table, "createTable", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_8);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
-      EList<JvmMember> _members_9 = type.getMembers();
-      final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
-        final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
+      JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(table, "createTable", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_10);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
+      EList<JvmMember> _members_11 = type.getMembers();
+      final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> {
+        EList<JvmFormalParameter> _parameters = it.getParameters();
+        JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "table", this._typeReferenceBuilder.typeRef(CellSetFilterTable.class));
+        this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
+        EList<JvmFormalParameter> _parameters_1 = it.getParameters();
+        JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(table, "cellSet", this._typeReferenceBuilder.typeRef(DerivedCellSet.class));
+        this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
+        final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
+          StringConcatenation _builder = new StringConcatenation();
+          String _initTable = this.initTable(table);
+          _builder.append(_initTable);
+          it_1.append(_builder);
+        };
+        this._jvmTypesBuilder.setBody(it, _function_12);
+      };
+      JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(table, "initTable", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_11);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
+      EList<JvmMember> _members_12 = type.getMembers();
+      final Procedure1<JvmOperation> _function_12 = (JvmOperation it) -> {
+        EList<JvmFormalParameter> _parameters = it.getParameters();
+        JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "table", this._typeReferenceBuilder.typeRef(CellSetFilterTable.class));
+        this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
+        final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
+          StringConcatenation _builder = new StringConcatenation();
+          CharSequence _tableSettingsByUserProperties = this.tableSettingsByUserProperties(table);
+          _builder.append(_tableSettingsByUserProperties);
+          it_1.append(_builder);
+        };
+        this._jvmTypesBuilder.setBody(it, _function_13);
+      };
+      JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(table, "tableSettingsByUserProperties", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_12);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12);
+      EList<JvmMember> _members_13 = type.getMembers();
+      final Procedure1<JvmOperation> _function_13 = (JvmOperation it) -> {
+        final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           String _dataRefresh = this.dataRefresh(table);
           _builder.append(_dataRefresh);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_10);
+        this._jvmTypesBuilder.setBody(it, _function_14);
       };
-      JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(table, "dataRefresh", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_9);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
-      EList<JvmMember> _members_10 = type.getMembers();
-      final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
-        final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
+      JvmOperation _method_13 = this._jvmTypesBuilder.toMethod(table, "dataRefresh", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_13);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, _method_13);
+      EList<JvmMember> _members_14 = type.getMembers();
+      final Procedure1<JvmOperation> _function_14 = (JvmOperation it) -> {
+        final Procedure1<ITreeAppendable> _function_15 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           CharSequence _renderAllowed = this.renderAllowed();
           _builder.append(_renderAllowed);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_11);
+        this._jvmTypesBuilder.setBody(it, _function_15);
       };
-      JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(table, "renderAllowed", this._typeReferenceBuilder.typeRef(boolean.class), _function_10);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
+      JvmOperation _method_14 = this._jvmTypesBuilder.toMethod(table, "renderAllowed", this._typeReferenceBuilder.typeRef(boolean.class), _function_14);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, _method_14);
     }
     if (!_matched) {
       if (_tabletype instanceof TableGrid) {
         _matched=true;
-        EList<JvmMember> _members_7 = type.getMembers();
-        final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
+        EList<JvmMember> _members_9 = type.getMembers();
+        final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
           QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(this.getDtoGridTable(table).getDtoSource());
           String _string = null;
           if (_fullyQualifiedName!=null) {
@@ -975,7 +1061,7 @@
           final String gridDtoFqn = _string;
           EObject _resolve = EcoreUtil2.resolve(this.getDtoGridTable(table).getDtoSource().getWrappedType(), table.eResource());
           final LEntity entity = ((LEntity) _resolve);
-          final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
+          final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
             StringConcatenation _builder = new StringConcatenation();
             CharSequence _createGridComponent = this.createGridComponent(pkg, table, entity, gridDtoFqn);
             _builder.append(_createGridComponent);
@@ -983,14 +1069,14 @@
             _builder.append("return grid;");
             it_1.append(_builder);
           };
-          this._jvmTypesBuilder.setBody(it, _function_8);
+          this._jvmTypesBuilder.setBody(it, _function_10);
         };
-        JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(table, "createDtoGrid", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_7);
-        this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
+        JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(table, "createDtoGrid", this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class), _function_9);
+        this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
       }
     }
-    EList<JvmMember> _members_7 = type.getMembers();
-    final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
+    EList<JvmMember> _members_9 = type.getMembers();
+    final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
       it.setVisibility(JvmVisibility.PUBLIC);
       EList<JvmAnnotationReference> _annotations = it.getAnnotations();
       JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
@@ -998,18 +1084,18 @@
       EList<JvmFormalParameter> _parameters = it.getParameters();
       JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "locale", this._typeReferenceBuilder.typeRef(Locale.class));
       this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
-      final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
+      final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         CharSequence _localeChanged = this.localeChanged(table);
         _builder.append(_localeChanged);
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setBody(it, _function_8);
+      this._jvmTypesBuilder.setBody(it, _function_10);
     };
-    JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(table, "localeChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_7);
-    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
-    EList<JvmMember> _members_8 = type.getMembers();
-    final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
+    JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(table, "localeChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_9);
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
+    EList<JvmMember> _members_10 = type.getMembers();
+    final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
       it.setVisibility(JvmVisibility.PUBLIC);
       EList<JvmAnnotationReference> _annotations = it.getAnnotations();
       JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
@@ -1017,19 +1103,19 @@
       EList<JvmFormalParameter> _parameters = it.getParameters();
       JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "event", this._typeReferenceBuilder.typeRef(EventDispatcherEvent.class));
       this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
-      final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
+      final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
         StringConcatenation _builder = new StringConcatenation();
         String _receiveEvent = this.receiveEvent(table);
         _builder.append(_receiveEvent);
         it_1.append(_builder);
       };
-      this._jvmTypesBuilder.setBody(it, _function_9);
+      this._jvmTypesBuilder.setBody(it, _function_11);
     };
-    JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(table, "receiveEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_8);
-    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
+    JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(table, "receiveEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_10);
+    this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
     if (((!this.isGrid(table)) && (!this.isEmbedded(table)))) {
-      EList<JvmMember> _members_9 = type.getMembers();
-      final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
+      EList<JvmMember> _members_11 = type.getMembers();
+      final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> {
         EList<JvmFormalParameter> _parameters = it.getParameters();
         JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "changedFilter", this._typeReferenceBuilder.typeRef(DatamartFilter.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
@@ -1037,21 +1123,21 @@
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
         this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
-        final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           String _filterChanged = this.filterChanged(table);
           _builder.append(_filterChanged);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_10);
+        this._jvmTypesBuilder.setBody(it, _function_12);
       };
-      JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(table, "filterChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_9);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
+      JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(table, "filterChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_11);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
     }
     boolean _isTask = this.isTask(table);
     if (_isTask) {
-      EList<JvmMember> _members_10 = type.getMembers();
-      final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
+      EList<JvmMember> _members_12 = type.getMembers();
+      final Procedure1<JvmOperation> _function_12 = (JvmOperation it) -> {
         EList<JvmFormalParameter> _parameters = it.getParameters();
         JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "type", this._typeReferenceBuilder.typeRef(BPMTaskEventType.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
@@ -1062,50 +1148,50 @@
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
         this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
-        final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           CharSequence _notifyTaskEvent = this.notifyTaskEvent(table);
           _builder.append(_notifyTaskEvent);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_11);
+        this._jvmTypesBuilder.setBody(it, _function_13);
       };
-      JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(table, "notifyTaskEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_10);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
-      EList<JvmMember> _members_11 = type.getMembers();
-      final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> {
+      JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(table, "notifyTaskEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_12);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12);
+      EList<JvmMember> _members_13 = type.getMembers();
+      final Procedure1<JvmOperation> _function_13 = (JvmOperation it) -> {
         it.setVisibility(JvmVisibility.PUBLIC);
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
         this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
-        final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           CharSequence _notifyTaskEvent = this.notifyTaskEvent(table);
           _builder.append(_notifyTaskEvent);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_12);
+        this._jvmTypesBuilder.setBody(it, _function_14);
       };
-      JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(table, "notifyProcessCompletedEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_11);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
+      JvmOperation _method_13 = this._jvmTypesBuilder.toMethod(table, "notifyProcessCompletedEvent", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_13);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, _method_13);
     }
     boolean _isSelection = this.isSelection(table);
     if (_isSelection) {
-      EList<JvmMember> _members_12 = type.getMembers();
-      final Procedure1<JvmOperation> _function_12 = (JvmOperation it) -> {
+      EList<JvmMember> _members_14 = type.getMembers();
+      final Procedure1<JvmOperation> _function_14 = (JvmOperation it) -> {
         it.setVisibility(JvmVisibility.PUBLIC);
-        final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_15 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           CharSequence _selectItemsFromWorkloadDto = this.selectItemsFromWorkloadDto(table);
           _builder.append(_selectItemsFromWorkloadDto);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_13);
+        this._jvmTypesBuilder.setBody(it, _function_15);
       };
-      JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(table, "selectItemsFromWorkloadDto", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_12);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12);
-      EList<JvmMember> _members_13 = type.getMembers();
-      final Procedure1<JvmOperation> _function_13 = (JvmOperation it) -> {
+      JvmOperation _method_14 = this._jvmTypesBuilder.toMethod(table, "selectItemsFromWorkloadDto", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_14);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, _method_14);
+      EList<JvmMember> _members_15 = type.getMembers();
+      final Procedure1<JvmOperation> _function_15 = (JvmOperation it) -> {
         it.setVisibility(JvmVisibility.PUBLIC);
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
@@ -1116,21 +1202,21 @@
         EList<JvmFormalParameter> _parameters_1 = it.getParameters();
         JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(table, "selected", this._typeReferenceBuilder.typeRef(boolean.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
-        final Procedure1<ITreeAppendable> _function_14 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_16 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           CharSequence _rowChecked = this.rowChecked(table);
           _builder.append(_rowChecked);
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_14);
+        this._jvmTypesBuilder.setBody(it, _function_16);
       };
-      JvmOperation _method_13 = this._jvmTypesBuilder.toMethod(table, "rowChecked", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_13);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, _method_13);
+      JvmOperation _method_15 = this._jvmTypesBuilder.toMethod(table, "rowChecked", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_15);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_15, _method_15);
     }
     boolean _isEmbedded = this.isEmbedded(table);
     if (_isEmbedded) {
-      EList<JvmMember> _members_14 = type.getMembers();
-      final Procedure1<JvmOperation> _function_14 = (JvmOperation it) -> {
+      EList<JvmMember> _members_16 = type.getMembers();
+      final Procedure1<JvmOperation> _function_16 = (JvmOperation it) -> {
         it.setVisibility(JvmVisibility.PUBLIC);
         EList<JvmAnnotationReference> _annotations = it.getAnnotations();
         JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
@@ -1138,7 +1224,7 @@
         EList<JvmFormalParameter> _parameters = it.getParameters();
         JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(table, "event", this._typeReferenceBuilder.typeRef(ClientConnector.AttachEvent.class));
         this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
-        final Procedure1<ITreeAppendable> _function_15 = (ITreeAppendable it_1) -> {
+        final Procedure1<ITreeAppendable> _function_17 = (ITreeAppendable it_1) -> {
           StringConcatenation _builder = new StringConcatenation();
           _builder.append("if(mustRefresh){");
           _builder.newLine();
@@ -1151,10 +1237,10 @@
           _builder.append("}");
           it_1.append(_builder);
         };
-        this._jvmTypesBuilder.setBody(it, _function_15);
+        this._jvmTypesBuilder.setBody(it, _function_17);
       };
-      JvmOperation _method_14 = this._jvmTypesBuilder.toMethod(table, "attach", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_14);
-      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, _method_14);
+      JvmOperation _method_16 = this._jvmTypesBuilder.toMethod(table, "attach", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_16);
+      this._jvmTypesBuilder.<JvmOperation>operator_add(_members_16, _method_16);
     }
   }
   
@@ -1320,9 +1406,6 @@
           _builder.newLine();
         } else {
           _builder.append("\t\t\t\t\t");
-          _builder.append("selectedId = event.getData().get(EventDispatcherDataTag.ID);");
-          _builder.newLine();
-          _builder.append("\t\t\t\t\t");
           _builder.append("renderData();");
           _builder.newLine();
         }
@@ -1607,101 +1690,79 @@
     _builder.newLine();
     String body = _builder.toString();
     boolean _isGrid = this.isGrid(table);
-    if (_isGrid) {
-      final LEntity entity = EntityUtils.getEntityFromDto(this.getDtoGridTable(table).getDtoSource());
+    boolean _not = (!_isGrid);
+    if (_not) {
       StringConcatenation _builder_1 = new StringConcatenation();
       _builder_1.append(body);
       _builder_1.newLineIfNotEmpty();
-      _builder_1.append("persistenceService.registerPersistenceUnit(\"");
-      String _persistenceUnit = null;
-      if (entity!=null) {
-        _persistenceUnit=entity.getPersistenceUnit();
-      }
-      _builder_1.append(_persistenceUnit);
-      _builder_1.append("\", ");
-      _builder_1.newLineIfNotEmpty();
-      _builder_1.append("\t\t\t\t\t\t");
-      QualifiedName _fullyQualifiedName = null;
-      if (entity!=null) {
-        _fullyQualifiedName=this._iQualifiedNameProvider.getFullyQualifiedName(entity);
-      }
-      _builder_1.append(_fullyQualifiedName, "\t\t\t\t\t\t");
-      _builder_1.append(".class);");
-      _builder_1.newLineIfNotEmpty();
-      _builder_1.append("log.debug(\"PersistenceService registered\");");
-      body = _builder_1.toString();
-    } else {
-      StringConcatenation _builder_2 = new StringConcatenation();
-      _builder_2.append(body);
-      _builder_2.newLineIfNotEmpty();
-      _builder_2.append("datamartInstance = new ");
+      _builder_1.append("datamartInstance = new ");
       String _sourceDataMartRefName = this.getSourceDataMartRefName(table);
-      _builder_2.append(_sourceDataMartRefName);
-      _builder_2.append("Datamart();");
-      _builder_2.newLineIfNotEmpty();
-      _builder_2.append("datamartInstance.setUser(user);");
-      _builder_2.newLine();
-      _builder_2.append("filterGenerator = new DatamartFilterGenerator(datamartInstance, ");
+      _builder_1.append(_sourceDataMartRefName);
+      _builder_1.append("Datamart();");
+      _builder_1.newLineIfNotEmpty();
+      _builder_1.append("datamartInstance.setUser(user);");
+      _builder_1.newLine();
+      _builder_1.append("filterGenerator = new DatamartFilterGenerator(datamartInstance, ");
       {
         boolean _isEmbedded_2 = this.isEmbedded(table);
         if (_isEmbedded_2) {
-          _builder_2.append("eclipseContext");
+          _builder_1.append("eclipseContext");
         } else {
-          _builder_2.append("getContext()");
+          _builder_1.append("getContext()");
         }
       }
-      _builder_2.append(", ");
+      _builder_1.append(", ");
       boolean _isShowCaption = this.getDataMartTable(table).getDatamartRef().isShowCaption();
-      _builder_2.append(_isShowCaption);
-      _builder_2.append(", ");
+      _builder_1.append(_isShowCaption);
+      _builder_1.append(", ");
       int _max = Integer.max(10, this.getDataMartTable(table).getDatamartRef().getNumMultiRows());
-      _builder_2.append(_max);
-      _builder_2.append(");");
-      _builder_2.newLineIfNotEmpty();
-      _builder_2.append("filterGenerator.createUIFilters(layoutManager);");
-      _builder_2.newLine();
-      body = _builder_2.toString();
+      _builder_1.append(_max);
+      _builder_1.append(");");
+      _builder_1.newLineIfNotEmpty();
+      _builder_1.append("filterGenerator.createUIFilters(layoutManager);");
+      _builder_1.newLine();
+      body = _builder_1.toString();
     }
     boolean _isSelection = this.isSelection(table);
     if (_isSelection) {
-      StringConcatenation _builder_3 = new StringConcatenation();
-      _builder_3.append(body);
-      _builder_3.newLineIfNotEmpty();
-      _builder_3.append("workLoadItem = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO);");
-      _builder_3.newLine();
-      _builder_3.append("taskSummary = (BPMTaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY);");
-      _builder_3.newLine();
-      body = _builder_3.toString();
+      StringConcatenation _builder_2 = new StringConcatenation();
+      _builder_2.append(body);
+      _builder_2.newLineIfNotEmpty();
+      _builder_2.append("workLoadItem = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO);");
+      _builder_2.newLine();
+      _builder_2.append("taskSummary = (BPMTaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY);");
+      _builder_2.newLine();
+      body = _builder_2.toString();
     }
-    StringConcatenation _builder_4 = new StringConcatenation();
-    _builder_4.append(body);
-    _builder_4.newLineIfNotEmpty();
-    _builder_4.append("coordinateSystem = new ArrayList<Integer>();");
-    _builder_4.newLine();
-    _builder_4.append("attributeLookupMap = new HashMap<>();");
-    _builder_4.newLine();
-    _builder_4.append("tabSheets = new HashMap<>();");
-    body = _builder_4.toString();
+    StringConcatenation _builder_3 = new StringConcatenation();
+    _builder_3.append(body);
+    _builder_3.newLineIfNotEmpty();
+    _builder_3.append("coordinateSystem = new ArrayList<Integer>();");
+    _builder_3.newLine();
+    _builder_3.append("attributeLookupMap = new HashMap<>();");
+    _builder_3.newLine();
+    _builder_3.append("tabSheets = new HashMap<>();");
+    body = _builder_3.toString();
     if (((!this.isEmbedded(table)) && (table.getTabletype().getToolbar() != null))) {
-      StringConcatenation _builder_5 = new StringConcatenation();
-      _builder_5.append(body);
-      _builder_5.newLineIfNotEmpty();
-      _builder_5.append("toolbarUUID = UUID.randomUUID().toString();");
-      _builder_5.newLine();
-      _builder_5.append("toolbarClass = new ");
+      StringConcatenation _builder_4 = new StringConcatenation();
+      _builder_4.append(body);
+      _builder_4.newLineIfNotEmpty();
+      _builder_4.append("toolbarUUID = UUID.randomUUID().toString();");
+      _builder_4.newLine();
+      _builder_4.append("toolbarClass = new ");
       String _firstUpper = StringExtensions.toFirstUpper(table.getTabletype().getToolbar().getName().toString());
-      _builder_5.append(_firstUpper);
-      _builder_5.append("Toolbar(toolbarUUID);");
-      _builder_5.newLineIfNotEmpty();
-      _builder_5.append("toolbarClass.createToolbar(eclipseContext, renderingEngine, themeResourceService);");
-      body = _builder_5.toString();
+      _builder_4.append(_firstUpper);
+      _builder_4.append("Toolbar();");
+      _builder_4.newLineIfNotEmpty();
+      _builder_4.append("toolbarClass.createToolbar(eclipseContext, renderingEngine, themeResourceService, toolbarUUID);");
+      body = _builder_4.toString();
     }
-    StringConcatenation _builder_6 = new StringConcatenation();
-    _builder_6.append(body);
-    _builder_6.newLineIfNotEmpty();
-    _builder_6.append("initDone = true;");
-    _builder_6.newLine();
-    body = _builder_6.toString();
+    StringConcatenation _builder_5 = new StringConcatenation();
+    _builder_5.append(body);
+    _builder_5.newLineIfNotEmpty();
+    _builder_5.append("initDone = true;");
+    _builder_5.newLine();
+    body = _builder_5.toString();
     return body;
   }
   
@@ -1710,6 +1771,11 @@
       (((TableDatamart) this.getDataMartTable(table)).getDatamartRef().getSource() instanceof DatamartTask));
   }
   
+  public boolean isCube(final Table table) {
+    return ((this.getDataMartTable(table) instanceof TableDatamart) && 
+      (((TableDatamart) this.getDataMartTable(table)).getDatamartRef().getSource() instanceof DatamartCube));
+  }
+  
   public boolean isGrid(final Table table) {
     TableOption _tabletype = table.getTabletype();
     return (_tabletype instanceof TableGrid);
@@ -1731,7 +1797,7 @@
   
   public CharSequence renderAllowed() {
     StringConcatenation _builder = new StringConcatenation();
-    _builder.append("if (getSelectById() && getSelectedId()==null) {");
+    _builder.append("if (getSelectById()) {");
     _builder.newLine();
     _builder.append("\t");
     _builder.append("for (DatamartFilter filter : datamartInstance.getFilters()) {");
@@ -1745,6 +1811,15 @@
     _builder.append("\t\t");
     _builder.append("}");
     _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("if(!filter.getSql().isEmpty()) {");
+    _builder.newLine();
+    _builder.append("\t\t\t");
+    _builder.append("return true;");
+    _builder.newLine();
+    _builder.append("\t\t");
+    _builder.append("}");
+    _builder.newLine();
     _builder.append("\t");
     _builder.append("} ");
     _builder.newLine();
@@ -1786,7 +1861,7 @@
     _builder.append("}");
     _builder.newLine();
     _builder.append("\t");
-    _builder.append("if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet())) {");
+    _builder.append("if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet(true))) {");
     _builder.newLine();
     _builder.append("\t\t");
     _builder.append("log.debug(\"cannot update container - full refresh\");");
@@ -1837,7 +1912,7 @@
   /**
    * <p>build the data components.</p>
    */
-  public String createComponents(final Table table) {
+  public String createComponents(final Table table, final String clsName) {
     String body = "";
     TableDatamart _dataMartTable = this.getDataMartTable(table);
     boolean _tripleNotEquals = (_dataMartTable != null);
@@ -1849,7 +1924,7 @@
       _builder.append("// get the results");
       _builder.newLine();
       _builder.append("\t");
-      _builder.append("final DerivedCellSet cellSet = getCellSet();");
+      _builder.append("final DerivedCellSet cellSet = getCellSet(true);");
       _builder.newLine();
       _builder.append("\t");
       _builder.append("if (cellSet == null) {");
@@ -1910,6 +1985,115 @@
       _builder.append("\t");
       _builder.append("if (cellSet != null) {");
       _builder.newLine();
+      {
+        if (((!this.isTask(table)) && (!this.isCube(table)))) {
+          _builder.append("\t\t");
+          _builder.append("if(moreToLoad) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t");
+          _builder.append("Runnable backgroundFetch = new Runnable() {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t");
+          _builder.append("public void run() {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t    ");
+          _builder.append("operativeDtoContainer = null;");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t    ");
+          _builder.append("final DerivedCellSet cellSetAll = datamartInstance.getResults(false, getTaskOperativeDtoClass(), getTaskInitialOperativeDtos());");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t    ");
+          _builder.append("if\t(cellSet != null) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t    \t");
+          _builder.append("operativeDtoContainer = cellSet.getOperativeDtoContainer();");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t    ");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t");
+          _builder.append("for(CellSetFilterTable table:tables) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t    ");
+          _builder.append("dataSourceContainer = new CellSetIndexedContainer(eclipseContext, attributeLookupMap, cellSetAll, coordinateSystem, false);");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t");
+          _builder.append("UI.getCurrent().access(new Runnable() {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t");
+          _builder.append("@Override");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t");
+          _builder.append("public void run() {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t    ");
+          _builder.append("table.setContainerDataSource(dataSourceContainer);");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t    ");
+          _builder.append("initTable(table, cellSetAll);");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t    ");
+          _builder.append("filterGenerator.addFilterChangeListener(");
+          _builder.append(clsName, "\t\t\t\t\t\t\t    ");
+          _builder.append(".this);");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t\t");
+          _builder.append("});");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t");
+          _builder.append("};");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t");
+          _builder.append("new Thread(backgroundFetch).start();");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("\t");
+          _builder.append("moreToLoad = false;");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("} else {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("    ");
+          _builder.append("filterGenerator.addFilterChangeListener(");
+          _builder.append(clsName, "\t\t    ");
+          _builder.append(".this);");
+          _builder.newLineIfNotEmpty();
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+        }
+      }
       _builder.append("\t\t");
       _builder.append("// create a multidimensional coordinate system against the cellSet");
       _builder.newLine();
@@ -2259,6 +2443,141 @@
    * <p>build the table component.</p>
    */
   public String createTable(final Table table) {
+    String _xblockexpression = null;
+    {
+      String body = "";
+      String constructTable = "final CellSetFilterTable table = new CellSetFilterTable();";
+      boolean multiSelect = false;
+      boolean _isSelection = this.isSelection(table);
+      if (_isSelection) {
+        StringConcatenation _builder = new StringConcatenation();
+        _builder.append("final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable();");
+        _builder.newLine();
+        _builder.append("table.addTableRowCheckListener(this);");
+        _builder.newLine();
+        _builder.append("selectTable = table;");
+        _builder.newLine();
+        constructTable = _builder.toString();
+        TableOption _tabletype = table.getTabletype();
+        multiSelect = ((TableSelection) _tabletype).isMultiSelection();
+      }
+      StringConcatenation _builder_1 = new StringConcatenation();
+      _builder_1.append(body);
+      _builder_1.append(constructTable);
+      _builder_1.newLineIfNotEmpty();
+      _builder_1.append("VerticalLayout tableLayout = new VerticalLayout();");
+      _builder_1.newLine();
+      {
+        if ((this.isEmbedded(table) && this.isTask(table))) {
+          _builder_1.append("taskButtons = new ArrayList<Button>();");
+          _builder_1.newLine();
+          _builder_1.append("HorizontalLayout tools = new HorizontalLayout();");
+          _builder_1.newLine();
+          _builder_1.append("tools.addStyleName(\"os-embedded-toolbar\");");
+          _builder_1.newLine();
+          _builder_1.append("tools.setSpacing(false);");
+          _builder_1.newLine();
+          _builder_1.newLine();
+          _builder_1.append("Button b = new Button(null, new Button.ClickListener() {");
+          _builder_1.newLine();
+          _builder_1.append("    ");
+          _builder_1.append("public void buttonClick(ClickEvent event) {");
+          _builder_1.newLine();
+          _builder_1.append("    \t");
+          _builder_1.append("taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);");
+          _builder_1.newLine();
+          _builder_1.append("    \t");
+          _builder_1.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
+          _builder_1.newLine();
+          _builder_1.append("\t\t");
+          _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, \"UserMenu\", \"");
+          QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(table);
+          _builder_1.append(_fullyQualifiedName, "\t\t");
+          _builder_1.append("\");");
+          _builder_1.newLineIfNotEmpty();
+          _builder_1.append("\t\t");
+          _builder_1.append("eventDispatcher.sendEvent(evnt);");
+          _builder_1.newLine();
+          _builder_1.append("    ");
+          _builder_1.append("}");
+          _builder_1.newLine();
+          _builder_1.append("});");
+          _builder_1.newLine();
+          _builder_1.append("b.setIcon(themeResourceService.getThemeResource(\"task_action_resume\", ThemeResourceType.ICON));");
+          _builder_1.newLine();
+          _builder_1.append("b.setDescription(null);");
+          _builder_1.newLine();
+          _builder_1.append("b.setEnabled(false);");
+          _builder_1.newLine();
+          _builder_1.append("b.addStyleName(\"v-button-small\");");
+          _builder_1.newLine();
+          _builder_1.append("tools.addComponent(b);");
+          _builder_1.newLine();
+          _builder_1.append("taskButtons.add(b);");
+          _builder_1.newLine();
+          _builder_1.append("tableLayout.addComponent(tools);");
+          _builder_1.newLine();
+        }
+      }
+      _builder_1.append("table.setImmediate(true);");
+      _builder_1.newLine();
+      _builder_1.append("table.setMultiSelect(");
+      _builder_1.append(multiSelect);
+      _builder_1.append(");");
+      _builder_1.newLineIfNotEmpty();
+      _builder_1.append("table.setColumnCollapsingAllowed(true);");
+      _builder_1.newLine();
+      _builder_1.append("table.setColumnReorderingAllowed(true);");
+      _builder_1.newLine();
+      _builder_1.append("table.setId(\"table\");");
+      _builder_1.newLine();
+      {
+        boolean _isTable = this.isTable(table);
+        if (_isTable) {
+          _builder_1.append("table.setRowHeaderMode(RowHeaderMode.");
+          {
+            TableOption _tabletype_1 = table.getTabletype();
+            RowHeaderMode _headerMode = ((TableTable) _tabletype_1).getHeaderMode();
+            boolean _tripleNotEquals = (_headerMode != null);
+            if (_tripleNotEquals) {
+              TableOption _tabletype_2 = table.getTabletype();
+              String _name = ((TableTable) _tabletype_2).getHeaderMode().name();
+              _builder_1.append(_name);
+            } else {
+              _builder_1.append("HIDDEN");
+            }
+          }
+          _builder_1.append(");");
+          _builder_1.newLineIfNotEmpty();
+        }
+      }
+      _builder_1.append("table.setFilterDecorator(tableFilterDecorator);");
+      _builder_1.newLine();
+      _builder_1.append("table.setFilterBarVisible(");
+      boolean _booleanValue = Boolean.valueOf(table.getTabletype().isFiltering()).booleanValue();
+      _builder_1.append(_booleanValue);
+      _builder_1.append(");");
+      _builder_1.newLineIfNotEmpty();
+      _builder_1.append("table.setSelectable(true);");
+      _builder_1.newLine();
+      _builder_1.append("table.setSizeFull();");
+      _builder_1.newLine();
+      _builder_1.append("tableLayout.addComponent(table);");
+      _builder_1.newLine();
+      _builder_1.append("tables.add(table);");
+      _builder_1.newLine();
+      _builder_1.append("initTable(table, cellSet);");
+      _builder_1.newLine();
+      _builder_1.append("return tableLayout;");
+      _xblockexpression = body = _builder_1.toString();
+    }
+    return _xblockexpression;
+  }
+  
+  /**
+   * <p>build the table component.</p>
+   */
+  public String initTable(final Table table) {
     String body = "";
     TableAxis category_axis = null;
     TableAxis data_axis = null;
@@ -2309,127 +2628,6 @@
       data_axis.setAxis(AxisEnum.COLUMNS);
       this.getDataMartTable(table).getElements().add(data_axis);
     }
-    String constructTable = "final CellSetFilterTable table = new CellSetFilterTable();";
-    boolean multiSelect = false;
-    boolean _isSelection = this.isSelection(table);
-    if (_isSelection) {
-      StringConcatenation _builder = new StringConcatenation();
-      _builder.append("final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable();");
-      _builder.newLine();
-      _builder.append("table.addTableRowCheckListener(this);");
-      _builder.newLine();
-      _builder.append("selectTable = table;");
-      _builder.newLine();
-      constructTable = _builder.toString();
-      TableOption _tabletype = table.getTabletype();
-      multiSelect = ((TableSelection) _tabletype).isMultiSelection();
-    }
-    StringConcatenation _builder_1 = new StringConcatenation();
-    _builder_1.append(body);
-    _builder_1.append(constructTable);
-    _builder_1.newLineIfNotEmpty();
-    _builder_1.append("VerticalLayout tableLayout = new VerticalLayout();");
-    _builder_1.newLine();
-    {
-      if ((this.isEmbedded(table) && this.isTask(table))) {
-        _builder_1.append("taskButtons = new ArrayList<Button>();");
-        _builder_1.newLine();
-        _builder_1.append("HorizontalLayout tools = new HorizontalLayout();");
-        _builder_1.newLine();
-        _builder_1.append("tools.addStyleName(\"os-embedded-toolbar\");");
-        _builder_1.newLine();
-        _builder_1.append("tools.setSpacing(false);");
-        _builder_1.newLine();
-        _builder_1.newLine();
-        _builder_1.append("Button b = new Button(null, new Button.ClickListener() {");
-        _builder_1.newLine();
-        _builder_1.append("    ");
-        _builder_1.append("public void buttonClick(ClickEvent event) {");
-        _builder_1.newLine();
-        _builder_1.append("    \t");
-        _builder_1.append("taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);");
-        _builder_1.newLine();
-        _builder_1.append("    \t");
-        _builder_1.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
-        _builder_1.newLine();
-        _builder_1.append("\t\t");
-        _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, \"UserMenu\", \"");
-        QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(table);
-        _builder_1.append(_fullyQualifiedName, "\t\t");
-        _builder_1.append("\");");
-        _builder_1.newLineIfNotEmpty();
-        _builder_1.append("\t\t");
-        _builder_1.append("eventDispatcher.sendEvent(evnt);");
-        _builder_1.newLine();
-        _builder_1.append("    ");
-        _builder_1.append("}");
-        _builder_1.newLine();
-        _builder_1.append("});");
-        _builder_1.newLine();
-        _builder_1.append("b.setIcon(themeResourceService.getThemeResource(\"task_action_start\", ThemeResourceType.ICON));");
-        _builder_1.newLine();
-        _builder_1.append("b.setDescription(null);");
-        _builder_1.newLine();
-        _builder_1.append("b.setEnabled(false);");
-        _builder_1.newLine();
-        _builder_1.append("b.addStyleName(\"v-button-small\");");
-        _builder_1.newLine();
-        _builder_1.append("tools.addComponent(b);");
-        _builder_1.newLine();
-        _builder_1.append("taskButtons.add(b);");
-        _builder_1.newLine();
-        _builder_1.append("tableLayout.addComponent(tools);");
-        _builder_1.newLine();
-      }
-    }
-    _builder_1.append("table.setImmediate(true);");
-    _builder_1.newLine();
-    _builder_1.append("table.setMultiSelect(");
-    _builder_1.append(multiSelect);
-    _builder_1.append(");");
-    _builder_1.newLineIfNotEmpty();
-    _builder_1.append("table.setColumnCollapsingAllowed(true);");
-    _builder_1.newLine();
-    _builder_1.append("table.setColumnReorderingAllowed(true);");
-    _builder_1.newLine();
-    _builder_1.append("table.setId(\"table\");");
-    _builder_1.newLine();
-    {
-      boolean _isTable = this.isTable(table);
-      if (_isTable) {
-        _builder_1.append("table.setRowHeaderMode(RowHeaderMode.");
-        {
-          TableOption _tabletype_1 = table.getTabletype();
-          RowHeaderMode _headerMode = ((TableTable) _tabletype_1).getHeaderMode();
-          boolean _tripleNotEquals = (_headerMode != null);
-          if (_tripleNotEquals) {
-            TableOption _tabletype_2 = table.getTabletype();
-            String _name = ((TableTable) _tabletype_2).getHeaderMode().name();
-            _builder_1.append(_name);
-          } else {
-            _builder_1.append("HIDDEN");
-          }
-        }
-        _builder_1.append(");");
-        _builder_1.newLineIfNotEmpty();
-      }
-    }
-    _builder_1.append("table.setFilterDecorator(tableFilterDecorator);");
-    _builder_1.newLine();
-    _builder_1.append("table.setFilterBarVisible(");
-    boolean _booleanValue = Boolean.valueOf(table.getTabletype().isFiltering()).booleanValue();
-    _builder_1.append(_booleanValue);
-    _builder_1.append(");");
-    _builder_1.newLineIfNotEmpty();
-    _builder_1.append("table.setSelectable(true);");
-    _builder_1.newLine();
-    _builder_1.append("table.setSizeFull();");
-    _builder_1.newLine();
-    _builder_1.append("tableLayout.addComponent(table);");
-    _builder_1.newLine();
-    _builder_1.append("tables.add(table);");
-    _builder_1.newLine();
-    body = _builder_1.toString();
     this.initBlobLookup(table, blobLookupMap);
     this.initEnumLookup(table, enumLookupMap);
     this.initIdMap(table, idMap);
@@ -2443,83 +2641,87 @@
     }
     if ((((((((intervalStyleMap.keySet().size() + numberLookupStyleMap.keySet().size()) + stringLookupStyleMap.keySet().size()) + intLookupStyleMap.keySet().size()) + intIntervalStyleMap.keySet().size()) + 
       dateLookupStyleMap.keySet().size()) > 0) || category_axis.isHasRowHeight())) {
-      StringConcatenation _builder_2 = new StringConcatenation();
-      _builder_2.append(body);
-      _builder_2.append("// add styles to page for the axis\'s custom styles");
-      _builder_2.newLineIfNotEmpty();
-      _builder_2.append("Styles styles = Page.getCurrent().getStyles();");
-      _builder_2.newLine();
-      body = _builder_2.toString();
+      StringConcatenation _builder = new StringConcatenation();
+      _builder.append(body);
+      _builder.append("// add styles to page for the axis\'s custom styles");
+      _builder.newLineIfNotEmpty();
+      _builder.append("Styles styles = Page.getCurrent().getStyles();");
+      _builder.newLine();
+      body = _builder.toString();
     }
     boolean _isHasRowHeight = category_axis.isHasRowHeight();
     if (_isHasRowHeight) {
       this.customformatCounter = (this.customformatCounter + 1);
-      StringConcatenation _builder_3 = new StringConcatenation();
-      _builder_3.append("rowcustomformat");
-      _builder_3.append(this.customformatCounter);
-      rowStyle = _builder_3.toString();
-      StringConcatenation _builder_4 = new StringConcatenation();
-      _builder_4.append(body);
-      _builder_4.append("styles.add(\".v-table-row-");
-      _builder_4.append(rowStyle);
-      _builder_4.append(" {height: ");
+      StringConcatenation _builder_1 = new StringConcatenation();
+      _builder_1.append("rowcustomformat");
+      _builder_1.append(this.customformatCounter);
+      rowStyle = _builder_1.toString();
+      StringConcatenation _builder_2 = new StringConcatenation();
+      _builder_2.append(body);
+      _builder_2.append("styles.add(\".v-table-row-");
+      _builder_2.append(rowStyle);
+      _builder_2.append(" {height: ");
       String _rowHeight = category_axis.getRowHeight();
-      _builder_4.append(_rowHeight);
-      _builder_4.append("px;}\");");
-      _builder_4.newLineIfNotEmpty();
-      body = _builder_4.toString();
+      _builder_2.append(_rowHeight);
+      _builder_2.append("px;}\");");
+      _builder_2.newLineIfNotEmpty();
+      body = _builder_2.toString();
     }
+    StringConcatenation _builder_3 = new StringConcatenation();
+    _builder_3.append(body);
+    String _createStyles = this.createStyles(intervalStyleMap, numberLookupStyleMap, intIntervalStyleMap, intLookupStyleMap, stringLookupStyleMap, dateLookupStyleMap);
+    _builder_3.append(_createStyles);
+    _builder_3.append(" ");
+    body = _builder_3.toString();
+    StringConcatenation _builder_4 = new StringConcatenation();
+    _builder_4.append(body);
+    String _generatePropertyLookups = this.generatePropertyLookups(idMap, formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap, numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, intIntervalStyleMap, intIntervalIconMap, intIntervalTooltipMap, intLookupStyleMap, intLookupIconMap, intLookupTooltipMap, stringLookupStyleMap, stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap, blobLookupMap, enumLookupMap);
+    _builder_4.append(_generatePropertyLookups);
+    body = _builder_4.toString();
     StringConcatenation _builder_5 = new StringConcatenation();
     _builder_5.append(body);
-    String _createStyles = this.createStyles(intervalStyleMap, numberLookupStyleMap, intIntervalStyleMap, intLookupStyleMap, stringLookupStyleMap, dateLookupStyleMap);
-    _builder_5.append(_createStyles);
-    _builder_5.append(" ");
+    _builder_5.append("// DO NOT MOVE THESE LINES!!!!! The data source container creation has to be before the user properties readings");
+    _builder_5.newLineIfNotEmpty();
+    _builder_5.append("dataSourceContainer = new CellSetIndexedContainer(eclipseContext, attributeLookupMap, cellSet, coordinateSystem, ");
+    boolean _isDatamartCrossJoined = this.isDatamartCrossJoined(table);
+    _builder_5.append(_isDatamartCrossJoined);
+    _builder_5.append(");");
+    _builder_5.newLineIfNotEmpty();
+    _builder_5.append("table.setContainerDataSource(dataSourceContainer);");
+    _builder_5.newLine();
+    _builder_5.append("dataSourceContainer.addExtras(table);");
+    _builder_5.newLine();
+    _builder_5.append("tableSettingsByUserProperties(table);");
+    _builder_5.newLine();
     body = _builder_5.toString();
     StringConcatenation _builder_6 = new StringConcatenation();
     _builder_6.append(body);
-    String _generatePropertyLookups = this.generatePropertyLookups(idMap, formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap, numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, intIntervalStyleMap, intIntervalIconMap, intIntervalTooltipMap, intLookupStyleMap, intLookupIconMap, intLookupTooltipMap, stringLookupStyleMap, stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap, blobLookupMap, enumLookupMap);
-    _builder_6.append(_generatePropertyLookups);
-    body = _builder_6.toString();
-    StringConcatenation _builder_7 = new StringConcatenation();
-    _builder_7.append(body);
-    _builder_7.append("// DO NOT MOVE THESE LINES!!!!! The data source container creation has to be before the user properties readings");
-    _builder_7.newLineIfNotEmpty();
-    _builder_7.append("dataSourceContainer = new CellSetIndexedContainer(eclipseContext, attributeLookupMap, cellSet, coordinateSystem, ");
-    boolean _isDatamartCrossJoined = this.isDatamartCrossJoined(table);
-    _builder_7.append(_isDatamartCrossJoined);
-    _builder_7.append(");");
-    _builder_7.newLineIfNotEmpty();
-    _builder_7.append("table.setContainerDataSource(dataSourceContainer);");
-    _builder_7.newLine();
-    _builder_7.append("dataSourceContainer.addExtras(table);");
-    _builder_7.newLine();
-    body = _builder_7.toString();
-    StringConcatenation _builder_8 = new StringConcatenation();
-    _builder_8.append(body);
-    CharSequence _tableSettingsByUserProperties = this.tableSettingsByUserProperties();
-    _builder_8.append(_tableSettingsByUserProperties);
+    _builder_6.newLineIfNotEmpty();
     String _sendEvent = this.sendEvent(table);
-    _builder_8.append(_sendEvent);
+    _builder_6.append(_sendEvent);
+    _builder_6.newLineIfNotEmpty();
     CharSequence _columnCollapsedListener = this.columnCollapsedListener();
-    _builder_8.append(_columnCollapsedListener);
+    _builder_6.append(_columnCollapsedListener);
+    _builder_6.newLineIfNotEmpty();
     CharSequence _columnReorderListener = this.columnReorderListener();
-    _builder_8.append(_columnReorderListener);
+    _builder_6.append(_columnReorderListener);
+    _builder_6.newLineIfNotEmpty();
     CharSequence _columnResizeListener = this.columnResizeListener();
-    _builder_8.append(_columnResizeListener);
-    _builder_8.newLineIfNotEmpty();
-    body = _builder_8.toString();
+    _builder_6.append(_columnResizeListener);
+    _builder_6.newLineIfNotEmpty();
+    body = _builder_6.toString();
     boolean _isHasRowHeight_1 = category_axis.isHasRowHeight();
     if (_isHasRowHeight_1) {
-      StringConcatenation _builder_9 = new StringConcatenation();
-      _builder_9.append(body);
-      _builder_9.append("dataSourceContainer.setRowStyle(\"");
-      _builder_9.append(rowStyle);
-      _builder_9.append("\");");
-      _builder_9.newLineIfNotEmpty();
-      body = _builder_9.toString();
+      StringConcatenation _builder_7 = new StringConcatenation();
+      _builder_7.append(body);
+      _builder_7.append("dataSourceContainer.setRowStyle(\"");
+      _builder_7.append(rowStyle);
+      _builder_7.append("\");");
+      _builder_7.newLineIfNotEmpty();
+      body = _builder_7.toString();
     }
-    boolean _isTable_1 = this.isTable(table);
-    if (_isTable_1) {
+    boolean _isTable = this.isTable(table);
+    if (_isTable) {
       TableDatamart _dataMartTable = this.getDataMartTable(table);
       if ((_dataMartTable instanceof TableDatamart)) {
         TableDatamart _dataMartTable_1 = this.getDataMartTable(table);
@@ -2527,31 +2729,27 @@
         for (final TableElement element_1 : _elements_1) {
           if ((element_1 instanceof TableAxis)) {
             TablePreorder _preOrder = ((TableAxis) element_1).getPreOrder();
-            boolean _tripleNotEquals_1 = (_preOrder != null);
-            if (_tripleNotEquals_1) {
-              StringConcatenation _builder_10 = new StringConcatenation();
-              _builder_10.append(body);
+            boolean _tripleNotEquals = (_preOrder != null);
+            if (_tripleNotEquals) {
+              StringConcatenation _builder_8 = new StringConcatenation();
+              _builder_8.append(body);
               String _preOrder_1 = this.preOrder(((TableAxis) element_1).getPreOrder(), ((TableAxis) element_1));
-              _builder_10.append(_preOrder_1);
-              body = _builder_10.toString();
+              _builder_8.append(_preOrder_1);
+              body = _builder_8.toString();
             }
           }
         }
       }
     }
-    boolean _isSelection_1 = this.isSelection(table);
-    if (_isSelection_1) {
-      StringConcatenation _builder_11 = new StringConcatenation();
-      _builder_11.append(body);
-      _builder_11.newLineIfNotEmpty();
-      _builder_11.append("selectItemsFromWorkloadDto();");
-      _builder_11.newLine();
-      body = _builder_11.toString();
+    boolean _isSelection = this.isSelection(table);
+    if (_isSelection) {
+      StringConcatenation _builder_9 = new StringConcatenation();
+      _builder_9.append(body);
+      _builder_9.newLineIfNotEmpty();
+      _builder_9.append("selectItemsFromWorkloadDto();");
+      _builder_9.newLine();
+      body = _builder_9.toString();
     }
-    StringConcatenation _builder_12 = new StringConcatenation();
-    _builder_12.append(body);
-    _builder_12.append("return tableLayout;");
-    body = _builder_12.toString();
     return body;
   }
   
@@ -3468,15 +3666,19 @@
   public void initBlobLookup(final Table table, final Map<String, String> blobMap) {
     DatamartSource datamartSource = this.getDataMartTable(table).getDatamartRef().getSource();
     if ((datamartSource instanceof DatamartEntity)) {
-      List<LEntityAttribute> _allAttributes = ((DatamartEntity) datamartSource).getEntityRef().getAllAttributes();
-      for (final LEntityAttribute attribute : _allAttributes) {
+      List<DatamartAttribute> _allEntityAttributes = this.datamartInferrer.allEntityAttributes(this.getDataMartTable(table).getDatamartRef());
+      for (final DatamartAttribute attribute : _allEntityAttributes) {
         {
-          LKeyAndValue resolution = this.getResolution(attribute);
+          LKeyAndValue resolution = this.getResolution(attribute.getAttributeRef());
           if ((resolution != null)) {
             StringConcatenation _builder = new StringConcatenation();
-            String _name = null;
+            LEntityAttribute _attributeRef = null;
             if (attribute!=null) {
-              _name=attribute.getName();
+              _attributeRef=attribute.getAttributeRef();
+            }
+            String _name = null;
+            if (_attributeRef!=null) {
+              _name=_attributeRef.getName();
             }
             String _replace = null;
             if (_name!=null) {
@@ -3491,8 +3693,8 @@
           }
         }
       }
-      EList<DatamartAttribute> _attributes = ((DatamartEntity) datamartSource).getAttributes();
-      for (final DatamartAttribute attribute_1 : _attributes) {
+      List<DatamartAttribute> _allEntityAttributes_1 = this.datamartInferrer.allEntityAttributes(this.getDataMartTable(table).getDatamartRef());
+      for (final DatamartAttribute attribute_1 : _allEntityAttributes_1) {
         {
           LKeyAndValue resolution = this.getResolution(attribute_1.getAttributeRef());
           if ((resolution != null)) {
@@ -3514,14 +3716,18 @@
   public void initEnumLookup(final Table table, final Map<String, String> enumMap) {
     DatamartSource datamartSource = this.getDataMartTable(table).getDatamartRef().getSource();
     if ((datamartSource instanceof DatamartEntity)) {
-      List<LEntityAttribute> _allAttributes = ((DatamartEntity) datamartSource).getEntityRef().getAllAttributes();
-      for (final LEntityAttribute attribute : _allAttributes) {
-        boolean _typeIsEnum = this._modelExtensions.typeIsEnum(attribute);
+      List<DatamartAttribute> _allEntityAttributes = this.datamartInferrer.allEntityAttributes(this.getDataMartTable(table).getDatamartRef());
+      for (final DatamartAttribute attribute : _allEntityAttributes) {
+        boolean _typeIsEnum = this._modelExtensions.typeIsEnum(attribute.getAttributeRef());
         if (_typeIsEnum) {
           StringConcatenation _builder = new StringConcatenation();
-          String _name = null;
+          LEntityAttribute _attributeRef = null;
           if (attribute!=null) {
-            _name=attribute.getName();
+            _attributeRef=attribute.getAttributeRef();
+          }
+          String _name = null;
+          if (_attributeRef!=null) {
+            _name=_attributeRef.getName();
           }
           String _replace = null;
           if (_name!=null) {
@@ -3529,9 +3735,13 @@
           }
           _builder.append(_replace);
           StringConcatenation _builder_1 = new StringConcatenation();
-          LScalarType _type = null;
+          LEntityAttribute _attributeRef_1 = null;
           if (attribute!=null) {
-            _type=attribute.getType();
+            _attributeRef_1=attribute.getAttributeRef();
+          }
+          LScalarType _type = null;
+          if (_attributeRef_1!=null) {
+            _type=_attributeRef_1.getType();
           }
           QualifiedName _fullyQualifiedName = null;
           if (_type!=null) {
@@ -5760,6 +5970,12 @@
                 boolean _tripleNotEquals = (_primaryKeyAttribute != null);
                 if (_tripleNotEquals) {
                   _builder_1.append("\t\t");
+                  _builder_1.append("Object idObj = dataSourceContainer.getValueByProperty(selection, \"");
+                  String _lowerCase = alias.toLowerCase();
+                  _builder_1.append(_lowerCase, "\t\t");
+                  _builder_1.append("\");");
+                  _builder_1.newLineIfNotEmpty();
+                  _builder_1.append("\t\t");
                   _builder_1.append("MPerspective perspective = getContext().get(MPerspective.class);");
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
@@ -5775,22 +5991,28 @@
                   _builder_1.append("\");");
                   _builder_1.newLineIfNotEmpty();
                   _builder_1.append("\t\t");
-                  _builder_1.append("evnt.addItem(EventDispatcherDataTag.ID, dataSourceContainer.getValueByProperty(selection, \"");
-                  String _lowerCase = alias.toLowerCase();
-                  _builder_1.append(_lowerCase, "\t\t");
-                  _builder_1.append("\"));");
-                  _builder_1.newLineIfNotEmpty();
+                  _builder_1.append("evnt.addItem(EventDispatcherDataTag.ID, idObj);");
+                  _builder_1.newLine();
                   _builder_1.append("\t\t");
                   _builder_1.append("eventDispatcher.sendEvent(evnt);");
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
+                  _builder_1.append("SelectionStore.putSelectionToPerspectiveContext(getPart(), \"");
+                  QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
+                  _builder_1.append(_fullyQualifiedName_2, "\t\t");
+                  _builder_1.append(".");
+                  String _idAttributeName_1 = entity.getIdAttributeName();
+                  _builder_1.append(_idAttributeName_1, "\t\t");
+                  _builder_1.append("\", idObj);");
+                  _builder_1.newLineIfNotEmpty();
+                  _builder_1.append("\t\t");
                   _builder_1.append("for (DatamartPrimary<?> primary : datamartInstance.getPrimaryList()){");
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
                   _builder_1.append("\t");
                   _builder_1.append("if (!\"");
-                  QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
-                  _builder_1.append(_fullyQualifiedName_2, "\t\t\t");
+                  QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
+                  _builder_1.append(_fullyQualifiedName_3, "\t\t\t");
                   _builder_1.append("\".equals(primary.getEntityName())){");
                   _builder_1.newLineIfNotEmpty();
                   _builder_1.append("\t\t");
@@ -5799,28 +6021,20 @@
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
                   _builder_1.append("\t\t");
-                  _builder_1.append("if (primaryValue != null) {");
-                  _builder_1.newLine();
-                  _builder_1.append("\t\t");
-                  _builder_1.append("\t\t\t");
                   _builder_1.append("evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, primary.getEntityName() + \".\" + primary.getAttributeName(), \"");
-                  QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(table);
-                  _builder_1.append(_fullyQualifiedName_3, "\t\t\t\t\t");
+                  QualifiedName _fullyQualifiedName_4 = this._iQualifiedNameProvider.getFullyQualifiedName(table);
+                  _builder_1.append(_fullyQualifiedName_4, "\t\t\t\t");
                   _builder_1.append("\");");
                   _builder_1.newLineIfNotEmpty();
                   _builder_1.append("\t\t");
-                  _builder_1.append("\t\t\t");
+                  _builder_1.append("\t\t");
                   _builder_1.append("evnt.addItem(EventDispatcherDataTag.ID, primaryValue);");
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
-                  _builder_1.append("\t\t\t");
+                  _builder_1.append("\t\t");
                   _builder_1.append("eventDispatcher.sendEvent(evnt);");
                   _builder_1.newLine();
                   _builder_1.append("\t\t");
-                  _builder_1.append("\t\t");
-                  _builder_1.append("}");
-                  _builder_1.newLine();
-                  _builder_1.append("\t\t");
                   _builder_1.append("\t");
                   _builder_1.append("}");
                   _builder_1.newLine();
@@ -6104,7 +6318,7 @@
     return _builder;
   }
   
-  public CharSequence tableSettingsByUserProperties() {
+  public CharSequence tableSettingsByUserProperties(final Table table) {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("// Setting the order of the columns via the visibleColumns list");
     _builder.newLine();
@@ -6508,18 +6722,35 @@
           _builder.newLine();
           _builder.append("else {");
           _builder.newLine();
-          _builder.append("\t");
-          _builder.append("workLoadItem.removeOperativeDto(taskClient.getWorkloadDto(taskSummary), ");
+          _builder.append("   \t");
+          _builder.append("for(IDto dtoToRemove : workLoadItem.getOperativeDtos(taskClient.getWorkloadDto(taskSummary))) {");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("if(((");
+          _builder.append(dtoFqn, "\t\t");
+          _builder.append(")dtoToRemove).getId()");
           {
             boolean _equals_1 = "int".equals(keyType.getName());
             if (_equals_1) {
-              _builder.append("dtoService.get((int) Integer.parseInt(idValue))");
+              _builder.append("==(int) Integer.parseInt(idValue)");
             } else {
-              _builder.append("dtoService.get(idValue)");
+              _builder.append(".equals(idValue)");
             }
           }
-          _builder.append(");");
+          _builder.append(") {");
           _builder.newLineIfNotEmpty();
+          _builder.append("\t\t\t");
+          _builder.append("workLoadItem.removeOperativeDto(taskClient.getWorkloadDto(taskSummary), dtoToRemove);");
+          _builder.newLine();
+          _builder.append("\t\t\t");
+          _builder.append("break;");
+          _builder.newLine();
+          _builder.append("\t\t");
+          _builder.append("}");
+          _builder.newLine();
+          _builder.append("\t");
+          _builder.append("}");
+          _builder.newLine();
           _builder.append("}");
           _builder.newLine();
           _xblockexpression = _builder;
diff --git a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
index d7da3c2..90ba902 100644
--- a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
+++ b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
@@ -68,6 +68,7 @@
 import org.eclipse.osbp.preferences.ProductConfiguration;
 import org.eclipse.osbp.runtime.common.event.EventDispatcherEvent;
 import org.eclipse.osbp.runtime.common.event.IDualData;
+import org.eclipse.osbp.runtime.common.event.SelectionStore;
 import org.eclipse.osbp.runtime.common.filter.IDTOServiceWithMutablePersistence;
 import org.eclipse.osbp.runtime.web.vaadin.common.data.IBeanSearchServiceFactory;
 import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider;
@@ -225,7 +226,8 @@
         IDualData.class, 
         MPerspective.class, 
         MPart.class, 
-        IPerspectiveProvider.class);
+        IPerspectiveProvider.class, 
+        SelectionStore.class);
       _xblockexpression = super.createAppendable(context, importManager, config);
     }
     return _xblockexpression;