Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table')
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/Activator.java46
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/GenerateTableDSL.mwe2193
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSL.xtext304
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceRuntimeModule.java42
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceStandaloneSetup.java40
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLRuntimeModule.java87
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLStandaloneSetup.java26
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/XcoreResourceFactory.java28
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/formatting/TableDSLFormatter.xtend58
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/OutputConfigurationProvider.java37
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableDSLGenerator.xtend37
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.xtend103
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend2864
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend250
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/scoping/TableDSLScopeProvider.xtend424
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/validation/TableDSLValidator.xtend94
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableQualifiedNameProvider.java68
-rw-r--r--org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableValueConverterService.java41
18 files changed, 4742 insertions, 0 deletions
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/Activator.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/Activator.java
new file mode 100644
index 0000000..c5d1c9e
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/Activator.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+import org.eclipse.osbp.gitinfo.Loginfo;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ Loginfo li = new Loginfo();
+ li.print( Activator.class.getCanonicalName(), Activator.class.getClassLoader());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/GenerateTableDSL.mwe2 b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/GenerateTableDSL.mwe2
new file mode 100644
index 0000000..eb65259
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/GenerateTableDSL.mwe2
@@ -0,0 +1,193 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+module org.eclipse.osbp.xtext.table.GenerateTableDSL
+
+import org.eclipse.emf.mwe.utils.*
+import org.eclipse.xtext.generator.*
+import org.eclipse.xtext.ui.generator.*
+import org.eclipse.osbp.dsl.mwe.*
+
+var projectName = "org.eclipse.osbp.xtext.table"
+var grammarURI = "platform:/resource/${projectName}/src/org/eclipse/osbp/xtext/table/TableDSL.xtext"
+var fileExtensions = "table"
+var runtimeProject = "../${projectName}"
+var generateXtendStub = true
+var encoding = "UTF-8"
+
+Workflow {
+
+ bean = org.eclipse.osbp.dsl.mwe.SemanticModelSetupComponent {
+ ePackage = org.eclipse.osbp.dsl.mwe.PackageMapping {
+ nsURI = "http://osbp.eclipse.org/gridsource/v1/core"
+ packageClass = "org.eclipse.osbp.infogrid.model.gridsource.CxGridSourcePackage"
+ factoryClass = "org.eclipse.osbp.infogrid.model.gridsource.impl.CxGridSourceFactoryImpl"
+ }
+
+ ePackage = org.eclipse.osbp.dsl.mwe.PackageMapping {
+ nsURI = "http://osbp.eclipse.org/gridsource/v1/core/style"
+ packageClass = "org.eclipse.osbp.infogrid.model.gridsource.style.CxGridStylePackage"
+ factoryClass = "org.eclipse.osbp.infogrid.model.gridsource.style.impl.CxGridStyleFactoryImpl"
+ }
+ }
+
+
+ bean = org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup : xcore {}
+ bean = org.eclipse.xtext.mwe.Reader {
+ register = xcore
+ }
+ bean = MavenStandaloneSetup {
+ scanClassPath = true
+ platformUri = "${runtimeProject}/.."
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.infogrid.model/model/gridsource.genmodel"
+ registerEcoreFile = "platform:/resource/org.eclipse.osbp.infogrid.model/model/gridsource.ecore" // vo mia
+ registerGeneratedEPackage = "org.eclipse.osbp.infogrid.model.gridsource.CxGridSourcePackage"
+ registerGeneratedEPackage = "org.eclipse.osbp.infogrid.model.gridsource.style.CxGridStylePackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.xtext.table/model/TableDSL.xcore"// registerEcoreFile = "platform:/resource/org.eclipse.osbp.xtext.table/model/TableDSL.xcore"
+ registerGeneratedEPackage = "org.eclipse.osbp.xtext.table.TableDSLPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore"// registerEcoreFile = "platform:/resource/org.eclipse.osbp.xtext.datamartdsl/model/DatamartDSL.xcore"
+ registerGeneratedEPackage = "org.eclipse.osbp.xtext.datamartdsl.DatamartDSLPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.xtext.cubedsl/model/CubeDSL.xcore"// registerEcoreFile = "platform:/resource/org.eclipse.osbp.xtext.cubedsl/model/CubeDSL.xcore"
+ registerGeneratedEPackage = "org.eclipse.osbp.xtext.cubedsl.CubeDSLPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.xtext.datainterchange/model/DataDSL.xcore"
+ registerGeneratedEPackage = "org.eclipse.osbp.xtext.datainterchange.DataDSLPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.xtext.action/model/ActionDSL.xcore"
+ registerGeneratedEPackage = "org.eclipse.osbp.xtext.action.ActionDSLPackage"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.dsl.entity.xtext/model/entity.xcore"
+ registerEcoreFile = "platform:/resource/org.eclipse.osbp.dsl.entity.xtext/model/entity.xcore"
+ registerGenModelFile = "platform:/resource/org.eclipse.osbp.dsl.common.xtext/model/types.xcore"
+ registerEcoreFile = "platform:/resource/org.eclipse.osbp.dsl.common.xtext/model/types.xcore"
+ registerGenModelFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
+ registerEcoreFile = "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore"
+ registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
+ registerEcoreFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xtype.ecore"
+ registerEcoreFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.ecore"
+ registerEcoreFile = "platform:/resource/org.eclipse.xtext.xbase/model/XAnnotations.ecore"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}/src-gen"
+ exclude = "README.txt"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.ui/src-gen"
+ exclude = "README.txt"
+ }
+
+ component = DirectoryCleaner {
+ directory = "${runtimeProject}.tests/src-gen"
+ exclude = "README.txt"
+ }
+
+ component = Generator {
+ pathRtProject = runtimeProject
+ pathUiProject = "${runtimeProject}.ui"
+ pathTestProject = "${runtimeProject}.tests"
+ projectNameRt = projectName
+ projectNameUi = "${projectName}.ui"
+ encoding = encoding
+ language = auto-inject {
+ uri = grammarURI
+
+ // Java API to access grammar elements (required by several other fragments)
+ fragment = grammarAccess.GrammarAccessFragment auto-inject {}
+
+ // generates Java API for the generated EPackages
+ fragment = ecore.EMFGeneratorFragment auto-inject {}
+
+ // the old serialization component
+ // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}
+
+ // serializer 2.0
+ fragment = serializer.SerializerFragment auto-inject {
+ generateStub = false
+ }
+
+ // a custom ResourceFactory for use with EMF
+ fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
+
+ // The antlr parser generator fragment.
+ fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
+ // options = {
+ // backtrack = true
+ // }
+ }
+
+ // Xtend-based API for validation
+ fragment = validation.ValidatorFragment auto-inject {
+ // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
+ // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
+ }
+
+ // old scoping and exporting API
+ // fragment = scoping.ImportURIScopingFragment auto-inject {}
+ // fragment = exporting.SimpleNamesFragment auto-inject {}
+
+ // scoping and exporting API
+ fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
+ fragment = exporting.QualifiedNamesFragment auto-inject {}
+ fragment = builder.BuilderIntegrationFragment auto-inject {}
+
+ // generator API
+ fragment = generator.GeneratorFragment auto-inject {}
+
+ // formatter API
+ fragment = formatting.FormatterFragment auto-inject {}
+
+ // labeling API
+ fragment = labeling.LabelProviderFragment auto-inject {}
+
+ // outline API
+ fragment = outline.OutlineTreeProviderFragment auto-inject {}
+ fragment = outline.QuickOutlineFragment auto-inject {}
+
+ // quickfix API
+ fragment = quickfix.QuickfixProviderFragment auto-inject {}
+
+ // content assist API
+ fragment = contentAssist.ContentAssistFragment auto-inject {}
+
+ // generates a more lightweight Antlr parser and lexer tailored for content assist
+ fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {
+ options = {
+ classSplitting = true
+ fieldsPerClass = "100"
+ methodsPerClass = "100"
+ }
+ }
+
+ // generates junit test support classes into Generator#pathTestProject
+ fragment = junit.Junit4Fragment auto-inject {}
+
+ // rename refactoring
+ fragment = refactoring.RefactorElementNameFragment auto-inject {}
+
+ // provides the necessary bindings for java types integration
+ fragment = types.TypesGeneratorFragment auto-inject {}
+
+ // generates the required bindings only if the grammar inherits from Xbase
+ fragment = xbase.XbaseGeneratorFragment auto-inject {}
+
+ // provides a preference page for template proposals
+ fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
+
+ // provides a compare view
+ fragment = compare.CompareFragment auto-inject {}
+
+ // parse grammar and generate i18n grammar
+ fragment = org.eclipse.osbp.xtext.basic.generator.BasicDslGrammarI18nGenerator auto-inject {}
+ }
+ }
+}
+
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSL.xtext b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSL.xtext
new file mode 100644
index 0000000..6552c17
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSL.xtext
@@ -0,0 +1,304 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+grammar org.eclipse.osbp.xtext.table.TableDSL with org.eclipse.xtext.xbase.annotations.XbaseWithAnnotations
+
+import "http://osbp.eclipse.org/gridsource/v1/core"
+import "http://osbp.eclipse.org/gridsource/v1/core/style" as style
+import "http://osbp.eclipse.org/xtext/table/TableDSL"
+import "http://osbp.eclipse.org/xtext/datamartdsl/DatamartDSL" as datamart
+import "http://osbp.eclipse.org/xtext/cubedsl/CubeDSL" as cube
+import "http://osbp.eclipse.org/xtext/action/ActionDSL" as action
+import "http://osbp.eclipse.org/dsl/common/types/v1" as types
+import "http://osbp.eclipse.org/dsl/dto/v1" as dto
+import "http://osbp.eclipse.org/dsl/entity/v1" as entity
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
+import "http://www.eclipse.org/xtext/common/JavaVMTypes"
+
+TableModel:
+ packages+=TablePackage*;
+
+TablePackage:
+ {TablePackage} 'package' name=QualifiedName
+ ('{' (imports+=TableImport)* (tables+=Table)* '}')?;
+
+Table:
+ {Table} 'table' name=TRANSLATABLEID (description?='described by' descriptionValue=TRANSLATABLESTRING)?
+ 'as' tabletype=TableOption;
+
+TableOption:
+ TableSelection | TableTable | TableGrid;
+
+TableSelection:
+ {TableSelection} (multiSelection?='multiselection' | 'singleselection') (((selectalways?='selectalways')?) & ('rowheader' headerMode=RowHeaderMode)?)
+ ((polling?='polling' pollingTime=Number)? &
+ (filtering?='filtering')? &
+ (embedded?='embedded')? &
+ ('toolbar' toolbar=[action::ActionToolbar])?)
+ ('using' source=TableDatamart)?;
+
+TableTable:
+ {TableTable} 'table' (((selectalways?='selectalways')?) & ('rowheader' headerMode=RowHeaderMode)?)
+ ((polling?='polling' pollingTime=Number)? &
+ (filtering?='filtering')? &
+ (embedded?='embedded')? &
+ ('toolbar' toolbar=[action::ActionToolbar])?)
+ ('using' source=TableDatamart)?;
+
+TablePreorder:
+ {TablePreorder} 'preorder' column=TableValueElement (ascending?='ascending')?;
+
+TableValue:
+ {TableValue} 'value' column=TableValueElement ((collapsed?='collapse')? & ('icon' iconName=STRING)? &
+ (formatter=TableFormatter)? & (hasImage?='image' image=TableImage)? & (tooltipPattern=TableTooltipPattern)?)
+ (('intervals' (hideLabelInterval?='hidelabel')? '{' (intervals+=TableInterval)* '}')? & ('lookups'
+ (hideLabelLookup?='hidelabel')? '{' (lookups+=TableLookup)* '}')?);
+
+TableFormatter:
+ {TableFormatter} 'formatter' format=STRING;
+
+TableImage:
+ {TableImage} 'path' imagePathPattern=STRING ((hasParameter?='dynamic')? & (hideImageLabel?='hidelabel')? &
+ (resize?='resize' resizeString=STRING)?);
+
+TableTooltipPattern:
+ {TableTooltipPattern} 'tooltipPattern' tooltipPattern=TRANSLATABLESTRING;
+
+TableValueElement:
+ TableMeasure | TableDerived | TableHierarchy | TableProperty | TableAggregation | TableOrdinal |
+ TableColumn | TableTask | TableAllColumns;
+
+TableTask:
+ {TableTask} 'taskId';
+
+TableAllColumns:
+ {TableAllColumns} 'allColumns';
+
+TableOrdinal:
+ 'ordinal' valueRef=Number;
+
+TableColumn:
+ 'column' valueRef=[datamart::DatamartColumn];
+
+TableMeasure:
+ 'measure' valueRef=[datamart::DatamartMeasure];
+
+TableDerived:
+ 'derived' valueRef=[datamart::DatamartDerivedMeasure];
+
+TableHierarchy:
+ 'level' valueRef=[cube::CubeLevel];
+
+TableProperty:
+ {TableProperty} 'property' valueRef=[datamart::DatamartProperty];
+
+TableAggregation:
+ 'aggregation' valueRef=[datamart::DatamartSetAggregationFunction];
+
+TableInterval:
+ (TableNumberInterval | TableDateDayInterval);
+
+TableNumberInterval:
+ {TableNumberInterval} 'up to' numberIntervalValue=SignedNumber numberRange=TableRangeElement;
+
+TableDateDayInterval:
+ {TableDateDayInterval} 'days in past' dateIntervalValue=SignedNumber dateRange=TableRangeElement;
+
+TableLookup:
+ (TableNumberLookup | TableStringLookup | TableDateDayLookup);
+
+TableNumberLookup:
+ {TableNumberLookup} 'number' lookupValue=SignedNumber discrete=TableRangeElement;
+
+TableStringLookup:
+ {TableStringLookup} 'string' lookupValue=STRING discrete=TableRangeElement;
+
+TableDateDayLookup:
+ {TableDateDayLookup} 'days in past' lookupValue=SignedNumber discrete=TableRangeElement;
+
+TableDatamart:
+ 'datamart' datamartRef=[datamart::DatamartDefinition] ('{' elements+=TableElement* '}')?;
+
+TableElement:
+ TableAxis;
+
+TableEvent:
+ 'broker' source=TableValueElement 'to' '{' brokerDatamarts+=TableBrokerDatamart* '}';
+
+TableBrokerDatamart:
+ 'datamart' datamartDef=[datamart::DatamartDefinition] (('filter' filter=STRING) | ('referenced'
+ reference=[entity::LEntityReference]));
+
+TableAxis:
+ 'axis' axis=AxisEnum ((hasRowHeight?='rowheight' rowHeight=Number)? & (preOrder=TablePreorder)?)
+ (hasDetails?='details' '{' values+=TableValue* '}')? (hasEvents?='events' '{' events+=TableEvent* '}')?;
+
+TableRangeElement:
+ TableTextColor | TableCellColor | TableIcon | TableTrend | TableTooltip;
+
+TableTextColor:
+ 'textcolor' rgb=STRING;
+
+TableCellColor:
+ 'cellcolor' rgb=STRING;
+
+TableIcon:
+ 'icon' icon=STRING;
+
+TableTrend:
+ 'trend' icon=TrendIconEnum;
+
+TableTooltip:
+ 'tooltip' tooltip=TRANSLATABLESTRING;
+
+TableImport returns types::LImport:
+ 'import' importedNamespace=TableQualifiedNameWithWildCard;
+
+ // ----------------------------- grid --------------------------------------
+TableGrid:
+ {TableGrid} 'grid' (((selectalways?='selectalways')?) & ('rowheader' headerMode=RowHeaderMode)?)
+ ((polling?='polling' pollingTime=Number)? &
+ (filtering?='filtering')? &
+ (embedded?='embedded')? &
+ ('toolbar' toolbar=[action::ActionToolbar])?)
+ ('using' source=TableDtoDatasource)?;
+
+TableDtoDatasource:
+// 'dto' rootType=JvmTypeReference '{'
+ 'dto' dtoSource=[dto::LDto] ('{'properties+=Property*'}')?;
+
+Property returns CxGridProperty:
+ (editable?='editable')? 'prop' path=NestedField 'style' style=PropertyStyle;
+
+NestedField returns CxGridNestedField:
+ {CxGridNestedField}
+ field=[JvmOperation] path=(NestedPath)?;
+
+NestedPath returns CxGridNestedPath:
+ {CxGridNestedPath}
+ '.' field=[JvmOperation] path=(NestedPath)?;
+
+PropertyStyle returns style::CxGridPropStyle:
+ PropertyButtonStyle | PropertyHtmlStyle | PropertyProgressbarStyle | PropertyTextStyle |
+ PropertyBooleanStyle | PropertyDateStyle | PropertyNumberStyle | PropertyImageStyle | PropertyQuantityStyle |
+ PropertyPriceStyle | GridPropIndicatorStyle;
+
+PropertyButtonStyle returns style::CxGridPropButtonStyle:
+ {style::CxGridPropButtonStyle}
+ 'buttonStyle' 'eventTopic' eventTopic=STRING;
+
+PropertyHtmlStyle returns style::CxGridPropHtmlStyle:
+ {style::CxGridPropHtmlStyle}
+ 'htmlStyle';
+
+PropertyBooleanStyle returns style::CxGridPropBooleanStyle:
+ {style::CxGridPropBooleanStyle}
+ 'boolStyle';
+
+PropertyDateStyle returns style::CxGridPropDateStyle:
+ {style::CxGridPropDateStyle}
+ 'dateStyle' 'format' dateFormat=STRING;
+
+PropertyNumberStyle returns style::CxGridPropNumberStyle:
+ {style::CxGridPropNumberStyle}
+ 'numberStyle' 'format' numberFormat=STRING;
+
+PropertyProgressbarStyle returns style::CxGridPropProgressbarStyle:
+ {style::CxGridPropProgressbarStyle}
+ 'progressbarStyle' 'max' maxValue=LDouble;
+
+GridPropIndicatorStyle returns style::CxGridPropIndicatorStyle:
+ {style::CxGridPropIndicatorStyle}
+ 'indicatorStyle' 'greenFrom' greenStarts=LDouble 'redUntil' redEnds=LDouble;
+
+PropertyQuantityStyle returns style::CxGridPropQuantityStyle:
+ {style::CxGridPropQuantityStyle}
+ 'quantityStyle' (htmlPattern=STRING)? 'value' '=' valuePropertyPath=NestedField ('(' 'format' valueNumberFormat=STRING
+ ')')? 'uom' '='
+ uomPropertyPath=NestedField;
+
+PropertyPriceStyle returns style::CxGridPropPriceStyle:
+ {style::CxGridPropPriceStyle}
+ 'priceStyle' (htmlPattern=STRING)? 'value' '=' valuePropertyPath=NestedField ('(' 'format' valueNumberFormat=STRING
+ ')')? 'currency' '='
+ currencyPropertyPath=NestedField;
+
+PropertyTextStyle returns style::CxGridPropTextStyle:
+ {style::CxGridPropTextStyle}
+ 'textStyle';
+
+PropertyImageStyle returns style::CxGridPropImageStyle:
+ {style::CxGridPropImageStyle}
+ 'imageStyle' ('eventTopic' eventTopic=STRING)? '{'
+ configs+=StyleConfig*
+ '}';
+
+StyleConfig returns style::CxGridStyleConfig:
+ NumericToResourceStyleConfig | StringToResourceStyleConfig;
+
+NumericToResourceStyleConfig returns style::CxGridStyleConfigNumericToResource:
+ 'number' compare=StyleCompare value=LDouble 'then' resourceThemePath=THEME_RESOURCE;
+
+StringToResourceStyleConfig returns style::CxGridStyleConfigStringToResource:
+ 'string' compare=StyleCompare value=STRING 'then' resourceThemePath=THEME_RESOURCE;
+
+enum StyleCompare returns style::CxGridCompare:
+ Equal="equal" | GreaterEqual="greater equal" | GreaterThan="greater than" | LowerEqual="lower equal" |
+ LowerThan="lower than" | NotEqual="not equal";
+
+terminal ID:
+ '^'? ('a'..'z' | 'A'..'Z' | '$' | '_') ('a'..'z' | 'A'..'Z' | '$' | '_' | '0'..'9')*;
+
+terminal INT returns ecore::EInt:
+ '0'..'9' ('0'..'9' | '_')*;
+
+terminal THEME_RESOURCE:
+ 'theme:/' ('a'..'z' | 'A'..'Z' | '$' | '_' | '.' | '/' | '0'..'9')*;
+
+LInt returns ecore::EInt:
+ ('+' | '-')? INT;
+
+LDouble returns ecore::EDouble:
+ LInt ('.' INT)?;
+
+terminal EVENT_TOPIC:
+ "'" (ID) ('/' ID)* ('/*')? "'";
+
+ // ----------------- grid ends ------------------------
+SignedNumber returns ecore::EDouble:
+ '-'? Number;
+
+TableQualifiedNameWithWildCard:
+ QualifiedName ('.' '*')?;
+
+QualifiedName:
+ ValidID (=> '.' ValidID)*;
+
+ValidID:
+ ID;
+
+TRANSLATABLESTRING:
+ STRING;
+
+TRANSLATABLEID:
+ ID;
+
+enum TrendIconEnum:
+ RISING='rising' | BADRISING='bad-rising' | SLOPING='sloping' | GOODSLOPING='good-sloping' | STAGNATING='stagnating';
+
+enum RowHeaderMode:
+ HIDDEN='hidden' | EXPLICIT_DEFAULTS_ID='explicit' | INDEX='indexed';
+
+enum AxisEnum returns datamart::AxisEnum:
+ DEFAULT='default' | COLUMNS='columns' | ROWS='rows' | PAGES='pages' | SECTIONS='sections' | CHAPTERS='chapters'
+ /* | AXIS(<index>)*/;
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceRuntimeModule.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceRuntimeModule.java
new file mode 100644
index 0000000..b187320
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceRuntimeModule.java
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+import org.eclipse.osbp.dsl.xtext.types.bundles.BundleSpaceTypeProviderFactory;
+import org.eclipse.osbp.dsl.xtext.types.bundles.BundleSpaceTypeScopeProvider;
+import org.eclipse.osbp.xtext.builder.types.loader.api.ITypeLoaderFactory;
+import org.eclipse.osbp.xtext.builder.types.loader.api.ITypeLoaderProvider;
+import org.eclipse.osbp.xtext.builder.types.loader.runtime.TypeLoaderFactory;
+import org.eclipse.osbp.xtext.builder.types.loader.runtime.TypeLoaderProvider;
+
+@SuppressWarnings("restriction")
+public class TableDSLBundleSpaceRuntimeModule extends TableDSLRuntimeModule {
+ // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
+ public Class<? extends org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory> bindIJvmTypeProvider$Factory() {
+ return BundleSpaceTypeProviderFactory.class;
+ }
+
+ // contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
+ public Class<? extends org.eclipse.xtext.common.types.xtext.AbstractTypeScopeProvider> bindAbstractTypeScopeProvider() {
+ return BundleSpaceTypeScopeProvider.class;
+ }
+
+ public Class<? extends ITypeLoaderFactory> bindITypeLoaderFactory() {
+ return TypeLoaderFactory.class;
+ }
+
+ public Class<? extends ITypeLoaderProvider> ITypeLoaderProvider() {
+ return TypeLoaderProvider.class;
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceStandaloneSetup.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceStandaloneSetup.java
new file mode 100644
index 0000000..9644197
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLBundleSpaceStandaloneSetup.java
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+import org.eclipse.osbp.xtext.builder.xbase.setups.XbaseBundleSpaceStandaloneSetup;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+@SuppressWarnings("restriction")
+public class TableDSLBundleSpaceStandaloneSetup extends TableDSLStandaloneSetup {
+ public static void doSetup() {
+ new TableDSLBundleSpaceStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+
+ @Override
+ public Injector createInjectorAndDoEMFRegistration() {
+ XbaseBundleSpaceStandaloneSetup.doSetup();
+
+ Injector injector = createInjector();
+ register(injector);
+ return injector;
+ }
+
+ @Override
+ public Injector createInjector() {
+ return Guice.createInjector(new TableDSLBundleSpaceRuntimeModule());
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLRuntimeModule.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLRuntimeModule.java
new file mode 100644
index 0000000..976d956
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLRuntimeModule.java
@@ -0,0 +1,87 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+import javax.inject.Singleton;
+
+import org.eclipse.xtext.conversion.IValueConverterService;
+import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.generator.IOutputConfigurationProvider;
+import org.eclipse.xtext.scoping.IScopeProvider;
+import org.eclipse.osbp.dsl.xtext.lazyresolver.LazyJvmTypeLinker;
+import org.eclipse.osbp.dsl.xtext.lazyresolver.SemanticLoadingResource;
+import org.eclipse.osbp.dsl.xtext.lazyresolver.linker.LazyJvmTypeTransientValueService;
+
+import com.google.inject.Binder;
+
+import org.eclipse.osbp.xtext.i18n.DSLOutputConfigurationProvider;
+import org.eclipse.osbp.xtext.table.generator.OutputConfigurationProvider;
+import org.eclipse.osbp.xtext.table.jvmmodel.TableModelGenerator;
+import org.eclipse.osbp.xtext.table.scoping.TableScopeProvider;
+import org.eclipse.osbp.xtext.table.valueconverter.TableQualifiedNameProvider;
+import org.eclipse.osbp.xtext.table.valueconverter.TableValueConverterService;
+
+/**
+ * Use this class to register components to be used at runtime / without the Equinox extension registry.
+ */
+public class TableDSLRuntimeModule extends org.eclipse.osbp.xtext.table.AbstractTableDSLRuntimeModule {
+ @Override
+ public Class<? extends IGenerator> bindIGenerator() {
+ return TableModelGenerator.class;
+ }
+
+ public Class<? extends IScopeProvider> bindIScopeProvider() {
+ return TableScopeProvider.class;
+ }
+
+ public Class<? extends IOutputConfigurationProvider> bindIOutputConfigurationProvider() {
+ return OutputConfigurationProvider.class;
+ }
+
+// /**
+// * Only required, if fqn can not be created by appending the names of the
+// * semantic elements up the hierarchy.
+// */
+// public Class<? extends org.eclipse.xtext.naming.IQualifiedNameProvider> bindIQualifiedNameProvider() {
+// return TableQualifiedNameProvider.class;
+// }
+//
+ @Override
+ public Class<? extends IValueConverterService> bindIValueConverterService() {
+ return TableValueConverterService.class;
+ }
+
+ public Class<? extends org.eclipse.xtext.xbase.scoping.batch.XbaseBatchScopeProvider> bindXbaseBatchScopeProvider() {
+ return TableScopeProvider.class;
+ }
+
+// @Override
+// public void configure(Binder binder) {
+// super.configure(binder);
+// binder.bind(IOutputConfigurationProvider.class).to(DSLOutputConfigurationProvider.class).in(Singleton.class);
+// }
+
+ public Class<? extends org.eclipse.xtext.resource.XtextResource> bindXtextResource() {
+ return SemanticLoadingResource.class;
+ }
+
+ public Class<? extends org.eclipse.xtext.linking.ILinker> bindILinker() {
+ return LazyJvmTypeLinker.class;
+ }
+
+ public Class<? extends org.eclipse.xtext.serializer.sequencer.ITransientValueService> bindSerializerITransientValueService() {
+ return LazyJvmTypeTransientValueService.class;
+ }
+
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLStandaloneSetup.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLStandaloneSetup.java
new file mode 100644
index 0000000..ff63d6a
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/TableDSLStandaloneSetup.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+/**
+ * Initialization support for running Xtext languages
+ * without equinox extension registry
+ */
+public class TableDSLStandaloneSetup extends TableDSLStandaloneSetupGenerated{
+
+ public static void doSetup() {
+ new TableDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
+ }
+}
+
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/XcoreResourceFactory.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/XcoreResourceFactory.java
new file mode 100644
index 0000000..a41338f
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/XcoreResourceFactory.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xcore.resource.XcoreResource;
+
+public class XcoreResourceFactory implements Resource.Factory {
+ @Override
+ public Resource createResource(URI uri) {
+ XcoreResource resource = new XcoreResource();
+ resource.setURI(uri);
+ return resource;
+ }
+
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/formatting/TableDSLFormatter.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/formatting/TableDSLFormatter.xtend
new file mode 100644
index 0000000..8a53df5
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/formatting/TableDSLFormatter.xtend
@@ -0,0 +1,58 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.formatting
+
+import com.google.inject.Inject;
+import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
+import org.eclipse.xtext.formatting.impl.FormattingConfig
+//import org.eclipse.osbp.xtext.table.services.TableDSLGrammarAccess
+import org.eclipse.osbp.utils.xtext.GenericFormatter
+import org.eclipse.xtext.xbase.services.XtypeGrammarAccess
+import org.eclipse.xtext.ParserRule
+import org.eclipse.xtext.GrammarUtil
+
+/**
+ * This class contains custom formatting description.
+ *
+ * see : http://www.eclipse.org/Xtext/documentation.html#formatting
+ * on how and when to use it
+ *
+ * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
+ */
+class TableDSLFormatter extends AbstractDeclarativeFormatter {
+
+// @Inject extension TableDSLGrammarAccess
+ @Inject XtypeGrammarAccess grammarAccess
+
+ override protected void configureFormatting(FormattingConfig c) {
+ val genericFormatter = new GenericFormatter()
+ var ParserRule nestedFieldDef = GrammarUtil.findRuleForName( grammar.grammar, "NestedField" ) as ParserRule
+ var ParserRule propertyStyleDef = GrammarUtil.findRuleForName( grammar.grammar, "PropertyStyle" ) as ParserRule
+ var ParserRule rangeElemetDef = GrammarUtil.findRuleForName( grammar.grammar, "TableRangeElement" ) as ParserRule
+ // TableRangeElement includes "TableTextColor", "TableCellColor", "TableIcon", "TableTrend" and "TableTooltip"!
+
+ // dsl-specific formatting:
+ c.setNoLinewrap().before( nestedFieldDef )
+ c.setNoLinewrap().before( propertyStyleDef )
+ c.setNoLinewrap().before( rangeElemetDef )
+
+ // common formatting:
+ genericFormatter.formatFirstLevelBlocks( c, grammar.grammar, "Table", "TableImport" )
+ genericFormatter.genericFormatting( c, grammar, grammarAccess )
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/OutputConfigurationProvider.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/OutputConfigurationProvider.java
new file mode 100644
index 0000000..924020e
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/OutputConfigurationProvider.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Florian Pirchner - Initial implementation
+ */
+
+package org.eclipse.osbp.xtext.table.generator;
+
+import java.util.Set;
+
+import org.eclipse.xtext.generator.OutputConfiguration;
+
+import org.eclipse.osbp.xtext.i18n.DSLOutputConfigurationProvider;
+
+public class OutputConfigurationProvider extends DSLOutputConfigurationProvider {
+
+ public Set<OutputConfiguration> getOutputConfigurations() {
+ Set<OutputConfiguration> configs = super.getOutputConfigurations();
+
+ OutputConfiguration binOutput = new OutputConfiguration("xmi");
+ binOutput.setDescription("xmi");
+ binOutput.setOutputDirectory("./modelsbin");
+ binOutput.setOverrideExistingResources(true);
+ binOutput.setCreateOutputDirectory(true);
+ binOutput.setCleanUpDerivedResources(true);
+ binOutput.setSetDerivedProperty(true);
+ binOutput.setKeepLocalHistory(true);
+ configs.add(binOutput);
+
+ return configs;
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableDSLGenerator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableDSLGenerator.xtend
new file mode 100644
index 0000000..7cf01de
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableDSLGenerator.xtend
@@ -0,0 +1,37 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.generator
+
+import com.google.inject.Inject
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
+
+/**
+ * Generates code from your model files on save.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration
+ */
+class TableDSLGenerator implements IGenerator {
+
+ @Inject TableGridSourceGenerator delegate
+
+ override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+ delegate.doGenerate(resource, fsa)
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.xtend
new file mode 100644
index 0000000..7c1c028
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.xtend
@@ -0,0 +1,103 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.generator
+
+import java.io.StringWriter
+import java.io.Writer
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.emf.ecore.util.EcoreUtil
+import org.eclipse.emf.ecore.xmi.XMLResource
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl
+import org.eclipse.osbp.dsl.semantic.common.types.LPackage
+import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropPriceStyle
+import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropQuantityStyle
+import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropStyle
+import org.eclipse.osbp.xtext.table.TableGrid
+import org.eclipse.osbp.xtext.table.TableModel
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.generator.IGenerator
+
+import static extension org.eclipse.osbp.infogrid.model.gridsource.util.Util.*
+
+/**
+ * Generates code from your model files on save.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration
+ */
+class TableGridSourceGenerator implements IGenerator {
+
+ override void doGenerate(Resource resource, IFileSystemAccess fsa) {
+ resource.toBinary(fsa)
+ }
+
+ def toBinary(Resource input, IFileSystemAccess fsa) {
+ val TableModel lModel = input.contents.get(0) as TableModel
+
+ lModel.packages.forEach [
+ val packageName = it.name
+ it.tables.forEach [
+ val tableName = it.name
+ if (it.tabletype instanceof TableGrid) {
+ generateXMI(it.tabletype as TableGrid, packageName, tableName, fsa);
+ }
+ ]
+ ]
+ }
+
+ def generateXMI(TableGrid grid, String packageName, String tableName, IFileSystemAccess fsa) {
+ val XMLResource outputRes = new XMLResourceImpl
+
+ val ds = grid.source
+
+ ds.id = packageName + "." + tableName + "Grid"
+
+ // set required inputs using the dto defined in the grid table
+ ds.rootTypeFQN = '''«(ds.dtoSource.eContainer as LPackage).name».«ds.dtoSource.name»'''
+
+ // set required properties
+ for (prop : ds.properties) {
+ prop.dotPath = prop.calcDotPath
+
+ // prepare dot path in styles
+ prop.style.prepare
+ }
+
+ val copy = EcoreUtil.copy(ds)
+ outputRes.contents += copy
+
+ // create a writer
+ val Writer writer = new StringWriter
+ outputRes.save(writer, null)
+
+ fsa.generateFile(ds.id + ".gridsource_xmi", "xmi", writer.toString)
+ }
+
+ def dispatch void prepare(CxGridPropStyle style) {
+ }
+
+ def dispatch void prepare(CxGridPropPriceStyle style) {
+ style.valuePropertyDotPath = style.valuePropertyPath.calcDotPath
+ style.currencyPropertyDotPath = style.currencyPropertyPath.calcDotPath
+ }
+
+ def dispatch void prepare(CxGridPropQuantityStyle style) {
+ style.valuePropertyDotPath = style.valuePropertyPath.calcDotPath
+ style.uomPropertyDotPath = style.uomPropertyPath.calcDotPath
+ }
+
+}
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
new file mode 100644
index 0000000..1fab8e3
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
@@ -0,0 +1,2864 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.jvmmodel
+
+import com.github.wolfie.refresher.Refresher
+import com.vaadin.data.Property.ValueChangeListener
+import com.vaadin.ui.Button
+import com.vaadin.ui.Component
+import com.vaadin.ui.VerticalLayout
+import java.util.ArrayList
+import java.util.Comparator
+import java.util.Date
+import java.util.HashMap
+import java.util.HashSet
+import java.util.Locale
+import java.util.Map
+import java.util.Set
+import javax.annotation.PreDestroy
+import javax.inject.Inject
+import javax.inject.Named
+import org.drools.event.process.ProcessCompletedEvent
+import org.eclipse.e4.core.contexts.IContextFunction
+import org.eclipse.e4.core.contexts.IEclipseContext
+import org.eclipse.e4.core.services.events.IEventBroker
+import org.eclipse.e4.ui.model.application.MApplication
+import org.eclipse.e4.ui.workbench.IPresentationEngine
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.osbp.bpm.api.IBPMTaskClient
+import org.eclipse.osbp.bpm.api.IBPMTaskEventNotification
+import org.eclipse.osbp.bpm.api.IBlipBPMWorkloadModifiableItem
+import org.eclipse.osbp.dsl.common.datatypes.IDto
+import org.eclipse.osbp.dsl.entity.xtext.extensions.ModelExtensions
+import org.eclipse.osbp.dsl.semantic.common.types.LDataType
+import org.eclipse.osbp.dsl.semantic.common.types.LReference
+import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage
+import org.eclipse.osbp.dsl.semantic.entity.LEntity
+import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute
+import org.eclipse.osbp.ecview.^extension.strategy.AbstractLayoutingStrategy
+import org.eclipse.osbp.infogrid.api.IGridSourceFacade
+import org.eclipse.osbp.osgi.hybrid.api.AbstractHybridVaaclipseView
+import org.eclipse.osbp.runtime.common.types.ITypeProviderService
+import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider
+import org.eclipse.osbp.ui.api.datamart.DerivedOlapException
+import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator
+import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService
+import org.eclipse.osbp.ui.api.themes.IThemeResourceService
+import org.eclipse.osbp.ui.api.user.IUser
+import org.eclipse.osbp.utils.annotation.CommonUtils
+import org.eclipse.osbp.utils.common.EntityUtils
+import org.eclipse.osbp.utils.constants.GeneratorConstants
+import org.eclipse.osbp.utils.vaadin.PropertyLookup
+import org.eclipse.osbp.vaaclipse.common.ecview.api.IECViewSessionHelper
+import org.eclipse.osbp.xtext.action.ActionPackage
+import org.eclipse.osbp.xtext.action.ChartActionEnum
+import org.eclipse.osbp.xtext.action.ReportActionEnum
+import org.eclipse.osbp.xtext.action.SelectWorkloadActionEnum
+import org.eclipse.osbp.xtext.action.WorkflowActionEnum
+import org.eclipse.osbp.xtext.cubedsl.CubeLevel
+import org.eclipse.osbp.xtext.datamart.common.DatamartDefinitionUtil
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedCellSet
+import org.eclipse.osbp.xtext.datamart.common.sql.OperativeDtoContainer
+import org.eclipse.osbp.xtext.datamartdsl.AxisEnum
+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
+import org.eclipse.osbp.xtext.datamartdsl.DatamartProperty
+import org.eclipse.osbp.xtext.datamartdsl.DatamartTask
+import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer
+import org.eclipse.osbp.xtext.table.Table
+import org.eclipse.osbp.xtext.table.TableAggregation
+import org.eclipse.osbp.xtext.table.TableAllColumns
+import org.eclipse.osbp.xtext.table.TableAxis
+import org.eclipse.osbp.xtext.table.TableBrokerDatamart
+import org.eclipse.osbp.xtext.table.TableCellColor
+import org.eclipse.osbp.xtext.table.TableColumn
+import org.eclipse.osbp.xtext.table.TableDSLFactory
+import org.eclipse.osbp.xtext.table.TableDatamart
+import org.eclipse.osbp.xtext.table.TableDateDayInterval
+import org.eclipse.osbp.xtext.table.TableDateDayLookup
+import org.eclipse.osbp.xtext.table.TableDerived
+import org.eclipse.osbp.xtext.table.TableDtoDatasource
+import org.eclipse.osbp.xtext.table.TableGrid
+import org.eclipse.osbp.xtext.table.TableHierarchy
+import org.eclipse.osbp.xtext.table.TableIcon
+import org.eclipse.osbp.xtext.table.TableMeasure
+import org.eclipse.osbp.xtext.table.TableNumberInterval
+import org.eclipse.osbp.xtext.table.TableNumberLookup
+import org.eclipse.osbp.xtext.table.TableOption
+import org.eclipse.osbp.xtext.table.TableOrdinal
+import org.eclipse.osbp.xtext.table.TablePackage
+import org.eclipse.osbp.xtext.table.TablePreorder
+import org.eclipse.osbp.xtext.table.TableProperty
+import org.eclipse.osbp.xtext.table.TableSelection
+import org.eclipse.osbp.xtext.table.TableStringLookup
+import org.eclipse.osbp.xtext.table.TableTable
+import org.eclipse.osbp.xtext.table.TableTask
+import org.eclipse.osbp.xtext.table.TableTextColor
+import org.eclipse.osbp.xtext.table.TableTooltip
+import org.eclipse.osbp.xtext.table.TableTrend
+import org.eclipse.osbp.xtext.table.common.CellSetFilterTable
+import org.eclipse.osbp.xtext.table.common.CellSetIndexedContainer
+import org.eclipse.osbp.xtext.table.common.CheckboxSelectionCellSetFilterTable
+import org.eclipse.osbp.xtext.table.common.TableFilterDecorator
+import org.eclipse.xtext.Constants
+import org.eclipse.xtext.EcoreUtil2
+import org.eclipse.xtext.common.types.JvmDeclaredType
+import org.eclipse.xtext.common.types.JvmField
+import org.eclipse.xtext.common.types.JvmGenericType
+import org.eclipse.xtext.common.types.JvmOperation
+import org.eclipse.xtext.common.types.JvmTypeReference
+import org.eclipse.xtext.common.types.JvmVisibility
+import org.eclipse.xtext.naming.IQualifiedNameProvider
+import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
+import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
+import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
+import org.jbpm.task.event.entity.TaskEventType
+import org.jbpm.task.event.entity.TaskUserEvent
+import org.osgi.service.event.EventHandler
+import org.slf4j.Logger
+import org.eclipse.osbp.ui.api.layout.IViewLayoutManager
+import org.eclipse.osbp.ui.api.datamart.IDataMart
+
+/**
+ * <p>
+ * This inferrer infers models of extension .table and generates code to be used by a e4 application as view. Underlying components
+ * are from the vaadin component repository
+ * </p>
+ *
+ * @author Joerg Riegel
+ */
+/**
+ * <p>Helper class for a Treemap in order to make double values comparable.</p>
+ *
+ */
+class DoubleComparator implements Comparator<Double> {
+ override compare(Double arg0, Double arg1) {
+ if (arg0 < arg1) {
+ return -1
+ } else if (arg0 > arg1) {
+ return 1
+ } else {
+ return 0
+ }
+ }
+}
+
+class DateComparator implements Comparator<Date> {
+ override compare(Date o1, Date o2) {
+ return o1.compareTo(o2);
+ }
+}
+
+/**
+ * <p>Container class for a Hashmap value. It carries look and feel information for table cells.</p>
+ *
+ */
+class FormatProperty {
+ public String formatter = null
+ public String tooltipPattern = null
+ public boolean hideLabelLookup = false
+ public boolean hideLabelInterval = false
+ public boolean hideImageLabel = false
+ public boolean collapsed = false;
+ public boolean hasImage = false
+ public boolean hasImageParameter = false
+ public String imagePathParameter = null
+ public String imagePath = null
+ public boolean hasImageResize = false;
+ public String imageResizeString = null
+ public String iconName = null;
+}
+
+class IdProperty {
+ public boolean collapsed = false;
+}
+
+/**
+ * <p>Infers a JVM model from the source model.</p>
+ *
+ * <p>The JVM model should contain all elements that would appear in the Java code
+ * which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
+ */
+class TableDSLJvmModelInferrer extends AbstractModelInferrer {
+
+ @Inject extension JvmTypesBuilder
+ @Inject extension IQualifiedNameProvider
+ @Inject extension DatamartDSLJvmModelInferrer datamartInferrer
+ @Inject extension ModelExtensions
+ @Inject extension CommonUtils
+ @Inject
+ @Named(Constants.FILE_EXTENSIONS) String fileExtension
+
+ var customformatCounter = 0
+
+ val CONVERT_METHOD_PREFIX = "getStringTo"
+
+ def String getFileExtension() {
+ }
+
+ /**
+ * <p>infer method dispatches the necessary routines to build fields, setter, getter, constructors and methods of the generated code.</p>
+ *
+ */
+ def dispatch void infer(TablePackage pkg, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
+ // create table classes
+ for (table : pkg.tables) {
+ val tableoption = table.tabletype
+ var clsName = ""
+ if (tableoption.embedded) {
+ clsName = pkg.name.toString.concat(".").concat(table.name).concat(fileExtension.toFirstUpper).
+ concat("Embedded")
+ }
+ else if (table.tabletype instanceof TableGrid) {
+ clsName = pkg.name.toString.concat(".").concat(table.name).concat("Grid")
+ }
+ else if (table.tabletype instanceof TableSelection) {
+ clsName = pkg.name.toString.concat(".").concat(table.name).concat("Select")
+ }
+ else {
+ clsName = pkg.name.toString.concat(".").concat(table.name).concat(fileExtension.toFirstUpper)
+ }
+ val cls = table.toClass(clsName)
+ if (tableoption.embedded) {
+ cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IViewEmbeddedProvider))
+ } else {
+ cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(AbstractHybridVaaclipseView))
+ }
+ cls.superTypes.add(_typeReferenceBuilder.typeRef(IUser.UserLocaleListener))
+ if (table.task) {
+ cls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IBPMTaskEventNotification))
+ }
+ acceptor.accept(cls,
+ [
+ documentation = GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION
+ it.toFields(table)
+ it.toConstructor(table)
+ it.toGetterSetter(table)
+ it.toOperations(pkg, table)
+ it.toStringToNumberConverter(table)
+ ])
+ if (tableoption.embedded) {
+
+ // the context function class
+ var contextClassName = table.name.concat(fileExtension.toFirstUpper).concat("Embedded") +
+ "ContextFunction"
+ val contextCls = pkg.toClass(contextClassName)
+ val tableClsName = clsName
+ contextCls.getSuperTypes().add(_typeReferenceBuilder.typeRef(IContextFunction))
+ contextCls.simpleName = contextCls.simpleName.toFirstUpper
+ acceptor.accept(contextCls,
+ [
+ var annotationRef = _annotationTypesBuilder.annotationRef(
+ typeof(org.osgi.service.component.annotations.Component))
+ annotationRef.addAnnAttr(table, "service",
+ _typeReferenceBuilder.typeRef(IContextFunction) as JvmTypeReference)
+ var propContent = '''«IContextFunction.SERVICE_CONTEXT_KEY»=«table.name.toFirstUpper»'''
+ annotationRef.addAnnAttr(table, "property", propContent)
+ annotations += annotationRef
+ packageName = pkg.fullyQualifiedName.toString
+ documentation = GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION
+ it.toContextOperations(table, tableClsName)
+ ])
+ }
+ }
+ }
+
+ /**
+ * <p>create an injectable context function to be used by an e4 application.</p>
+ *
+ */
+ def void toContextOperations(JvmGenericType type, Table table, String clsName) {
+ var JvmOperation operation
+
+ // compute override
+ type.members += table.toMethod("compute", _typeReferenceBuilder.typeRef(Object),
+ [
+ annotations += _annotationTypesBuilder.annotationRef(Override)
+ visibility = JvmVisibility.PUBLIC
+ parameters += table.toParameter("context", _typeReferenceBuilder.typeRef(IEclipseContext))
+ parameters += table.toParameter("contextKey", _typeReferenceBuilder.typeRef(String))
+ body = [
+ append(
+ '''
+ MApplication application = context.get(MApplication.class);
+ IEclipseContext appCtx = application.getContext();
+ IViewEmbeddedProvider provider = ContextInjectionFactory.make(«clsName».class, appCtx);
+ appCtx.set(IViewEmbeddedProvider.class, provider);
+ return provider;''')]
+ ])
+ }
+
+ /**
+ * <p>build the constructors to be used by an e4 application.</p>
+ *
+ */
+ def void toConstructor(JvmDeclaredType type, Table table) {
+ if (!table.tabletype.embedded) {
+ type.members += table.toConstructor(
+ [
+ annotations += _annotationTypesBuilder.annotationRef(Inject)
+ parameters += table.toParameter("parent", _typeReferenceBuilder.typeRef(VerticalLayout))
+ parameters += table.toParameter("context", _typeReferenceBuilder.typeRef(IEclipseContext))
+ parameters += table.toParameter("app", _typeReferenceBuilder.typeRef(MApplication))
+ body = [
+ append(
+ '''
+ super(parent,context,app);''')]
+ ])
+ }
+ }
+
+ def TableDatamart getDataMartTable(Table table) {
+ return table.tabletype.dataMartTable
+ }
+
+ def TableDatamart getDataMartTable(TableOption option) {
+ switch option {
+ TableTable: return option.source
+ }
+ return null
+ }
+
+ def TableDtoDatasource getDtoGridTable(Table table) {
+ return table.tabletype.dtoGridTable
+ }
+
+ def TableDtoDatasource getDtoGridTable(TableOption option) {
+ switch option {
+ TableGrid: return option.source as TableDtoDatasource
+ }
+ return null
+ }
+
+ def String getSourceDataMartRefName(Table table) {
+ if (table.dataMartTable != null && table.dataMartTable.datamartRef != null &&
+ table.dataMartTable.datamartRef.name != null) {
+ return table.dataMartTable.datamartRef.name.toString
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * <p>build the class variables.</p>
+ *
+ */
+ def void toFields(JvmDeclaredType type, Table table) {
+ var JvmField field = null
+
+ // create logger
+ field = table.toField("log", _typeReferenceBuilder.typeRef(Logger))[
+ setInitializer([append('''org.slf4j.LoggerFactory.getLogger("tables")''')])]
+ field.static = true
+ field.visibility = JvmVisibility::PRIVATE
+ type.members += field
+ field = table.toField("context", _typeReferenceBuilder.typeRef(IEclipseContext))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("user", _typeReferenceBuilder.typeRef(IUser))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("coordinateSystem", _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer)))
+ type.members += field
+ field = table.toField("filterGenerator", _typeReferenceBuilder.typeRef(IDatamartFilterGenerator))
+ type.members += field
+ field = table.toField("layoutManager", _typeReferenceBuilder.typeRef(IViewLayoutManager))
+ type.members += field
+ field = table.toField("dslMetadataService", _typeReferenceBuilder.typeRef(IDSLMetadataService)) [annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("locale", _typeReferenceBuilder.typeRef(Locale))
+ type.members += field
+ // the package name of the referenced datamart
+ if (getSourceDataMartRefName(table) != null) {
+ var packageName = (table.dataMartTable.datamartRef.eContainer as DatamartPackage).fullyQualifiedName.
+ toString
+ field = table.toField("datamartClass",
+ _typeReferenceBuilder.typeRef('''«packageName».«getSourceDataMartRefName(table)»Datamart'''))
+ type.members += field
+ }
+ if(table.tabletype instanceof TableGrid) {
+ field = table.toField("gridSourceService", _typeReferenceBuilder.typeRef(IGridSourceFacade))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("ecviewPropsProvider", _typeReferenceBuilder.typeRef(IECViewSessionHelper))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("bundleSpaceTypeProvider", _typeReferenceBuilder.typeRef(ITypeProviderService))[annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("grid", _typeReferenceBuilder.typeRef("org.eclipse.osbp.infogrid.vaaclipse.SingleInfoGridComponent"))
+ type.members += field
+ }
+ field = table.toField("filterChangeListener", _typeReferenceBuilder.typeRef(ValueChangeListener))
+ type.members += field
+ field = table.toField("tableSelectDelay", _typeReferenceBuilder.typeRef(Refresher))
+ type.members += field
+ field = table.toField("tableRefresher", _typeReferenceBuilder.typeRef(Refresher))
+ type.members += field
+ field = table.toField("dataComponent", _typeReferenceBuilder.typeRef(Component))
+ type.members += field
+ field = table.toField("propertyLookupMap",
+ _typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(PropertyLookup)))
+ type.members += field
+ field = table.toField("dataSourceContainer", _typeReferenceBuilder.typeRef(CellSetIndexedContainer))
+ type.members += field
+ field = table.toField("operativeDtoContainer", _typeReferenceBuilder.typeRef(OperativeDtoContainer))
+ type.members += field
+ field = table.toField("tables",
+ _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(CellSetFilterTable)))
+ type.members += field
+ field = table.toField("eventBroker", _typeReferenceBuilder.typeRef(IEventBroker))[
+ annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("renderingEngine", _typeReferenceBuilder.typeRef(IPresentationEngine))[
+ annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("themeResourceService", _typeReferenceBuilder.typeRef(IThemeResourceService))[
+ annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("refreshView", _typeReferenceBuilder.typeRef(EventHandler))
+ type.members += field
+ field = table.toField("delegatedTask", _typeReferenceBuilder.typeRef(EventHandler))
+ type.members += field
+ if (!table.tabletype.embedded) {
+ field = table.toField("dispatchAction", _typeReferenceBuilder.typeRef(EventHandler))
+ type.members += field
+ }
+ field = table.toField("tableFilterDecorator", _typeReferenceBuilder.typeRef(TableFilterDecorator))
+ type.members += field
+ if (table.task) {
+ field = table.toField("taskClient", _typeReferenceBuilder.typeRef(IBPMTaskClient))[
+ annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("currentTaskId", _typeReferenceBuilder.typeRef(Long))
+ type.members += field
+ field = table.toField("taskButtons",
+ _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Button)))
+ type.members += field
+ }
+ if (table.tabletype instanceof TableSelection) {
+ field = table.toField("taskClient", _typeReferenceBuilder.typeRef(IBPMTaskClient))[
+ annotations += _annotationTypesBuilder.annotationRef(Inject)]
+ type.members += field
+ field = table.toField("selectTable", _typeReferenceBuilder.typeRef(CheckboxSelectionCellSetFilterTable))
+ type.members += field
+ }
+ if (!table.tabletype.embedded && table.tabletype.toolbar != null && table.tabletype.toolbar.eContainer != null) {
+ var packageName = (table.tabletype.toolbar.eContainer as ActionPackage).fullyQualifiedName.toString
+ field = table.toField("toolbarClass",
+ _typeReferenceBuilder.typeRef('''«packageName».«table.tabletype.toolbar.name.toString.toFirstUpper»Action'''))
+ type.members += field
+ }
+ }
+
+ /**
+ * <p>build the getters and setters from class variables.</p>
+ *
+ */
+ def void toGetterSetter(JvmDeclaredType type, Table table) {
+ var JvmOperation operation = null
+ operation = table.toGetter("coordinateSystem",
+ _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer)))
+ operation.visibility = JvmVisibility::PUBLIC
+ type.members += operation
+ }
+
+ /**
+ * <p>build the methods.</p>
+ *
+ */
+ def void toOperations(JvmDeclaredType type, TablePackage pkg, Table table) {
+
+ // create view
+ type.members += table.toMethod("getCellSet", _typeReferenceBuilder.typeRef(DerivedCellSet),
+ [
+ body = [append(
+ '''
+ operativeDtoContainer = null;
+ «IF (table.dataMartTable != null)»
+ DerivedCellSet cellSet = datamartClass.getResults(
+ «IF table.task»taskClient, «ENDIF»user,
+ filterGenerator.getFilter(«(table.dataMartTable.datamartRef.source instanceof DatamartCube).booleanValue.toString»)
+ «IF !table.task»«IF ((table.tabletype instanceof TableSelection) || table.tabletype.embedded)», null, null«ELSE», getTaskOperativeDtoClass(), getTaskInitialOperativeDtos()«ENDIF»«ENDIF»
+ );
+ «ELSE»
+ DerivedCellSet cellSet = null;
+ «ENDIF»
+ if (cellSet != null) {
+ operativeDtoContainer = cellSet.getOperativeDtoContainer();
+ }
+ return cellSet;
+ ''')]
+ ])
+
+ // create view
+ type.members += table.toMethod("createView", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ parameters += table.toParameter("parent", _typeReferenceBuilder.typeRef(VerticalLayout))
+ if (table.tabletype.embedded) {
+ annotations += _annotationTypesBuilder.annotationRef(Override)
+ }
+ body = [append('''«table.createView(pkg)»''')]
+ ])
+
+ // create components
+ type.members += table.toMethod("createComponents", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ body = [append('''«table.createComponents»''')]
+ ])
+
+ switch (table.tabletype) {
+ TableTable: {
+ // create tab
+ type.members += table.toMethod("createTabSheet", _typeReferenceBuilder.typeRef(Component),
+ [
+ exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException)
+ parameters += table.toParameter("cellSet", _typeReferenceBuilder.typeRef(DerivedCellSet))
+ parameters += table.toParameter("axisNo", _typeReferenceBuilder.typeRef(Integer))
+ body = [append('''«table.createTabSheet»''')]
+ ])
+
+ // create table
+ type.members += table.toMethod("createTable", _typeReferenceBuilder.typeRef(Component),
+ [
+ exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException)
+ parameters += table.toParameter("cellSet", _typeReferenceBuilder.typeRef(DerivedCellSet))
+ body = [append('''«table.createTable»''')]
+ ])
+
+ // create table
+ type.members += table.toMethod("dataRefresh", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ body = [append('''«table.dataRefresh»''')]
+ ])
+ }
+ TableGrid: {
+ // create tab
+ type.members += table.toMethod("createDtoGrid", _typeReferenceBuilder.typeRef(Component),
+ [
+ exceptions += _typeReferenceBuilder.typeRef(DerivedOlapException)
+ val gridDtoFqn = (table.tabletype as TableGrid).source.dtoSource.fullyQualifiedName?.toString
+ body = [append('''
+ IEclipseContext childContext = context.createChild();
+ childContext.set(Locale.class, user.getLocale());
+ childContext.set("gridSourceId", "«pkg.name.toString.concat(".").concat(table.name).concat("Grid")»");
+ if ("«gridDtoFqn»".equals(getTaskOperativeDtoFqn())) {
+ childContext.set("inputdata", getTaskInitialOperativeDtos());
+ }
+ grid = ContextInjectionFactory.make(SingleInfoGridComponent.class, childContext);
+ return grid;''')]
+ ])
+ }
+ }
+
+ // setup-Method
+ type.members += table.toMethod("setup", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PROTECTED
+ body = [append('''«table.setup»''')]
+ ])
+
+ // subscribe to eventBroker
+ type.members += table.toMethod("subscribe", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PROTECTED
+ body = [append('''«table.subscribe»''')]
+ ])
+
+ // unsubscribe from eventBroker
+ type.members += table.toMethod("unsubscribe", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PROTECTED
+ annotations += _annotationTypesBuilder.annotationRef(PreDestroy)
+ body = [append('''«table.unsubscribe»''')]
+ ])
+ // locale notification
+ type.members += table.toMethod("localeChanged", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ annotations += _annotationTypesBuilder.annotationRef(Override)
+ parameters += table.toParameter("locale", _typeReferenceBuilder.typeRef(Locale))
+ body = [append('''«table.localeChanged»''')]
+ ])
+
+ if (table.task) {
+
+ // unsubscribe from eventBroker
+ type.members += table.toMethod("notifyTaskEvent", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ parameters += table.toParameter("type", _typeReferenceBuilder.typeRef(TaskEventType))
+ parameters += table.toParameter("event", _typeReferenceBuilder.typeRef(TaskUserEvent))
+ annotations += _annotationTypesBuilder.annotationRef(Override)
+ body = [append('''«table.notifyTaskEvent»''')]
+ ])
+
+ // unsubscribe from eventBroker
+ type.members += table.toMethod("notifyProcessCompletedEvent", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ parameters += table.toParameter("event", _typeReferenceBuilder.typeRef(ProcessCompletedEvent))
+ annotations += _annotationTypesBuilder.annotationRef(Override)
+ body = [append('''«table.notifyTaskEvent»''')]
+ ])
+ }
+ if (!table.tabletype.embedded) {
+
+ // react on refresh due to modified entities
+ // unsubscribe from eventBroker
+ type.members += table.toMethod("refreshViewDueToModifiedEntityId", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ parameters += table.toParameter("entity", _typeReferenceBuilder.typeRef(String))
+ parameters += table.toParameter("id", _typeReferenceBuilder.typeRef(Object))
+ visibility = JvmVisibility.PUBLIC
+ body = [
+ append(
+ '''
+ super.refreshViewDueToModifiedEntityId(entity, id);
+ «table.callDataRefreshMethod»
+ ''')]
+ ])
+ }
+
+ // any select table modifying workload dto methods
+ if (table.tabletype instanceof TableSelection) {
+ type.members += table.toMethod("selectItemsFromWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ body = [append('''«table.selectItemsFromWorkloadDto»''')]
+ ])
+ type.members += table.toMethod("addAllItemsToWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ body = [append('''«table.addAllItemsToWorkloadDto»''')]
+ ])
+ type.members += table.toMethod("addOrRemoveItemToWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PROTECTED
+ parameters += table.toParameter("task", _typeReferenceBuilder.typeRef(IBlipBPMWorkloadModifiableItem))
+ parameters += table.toParameter("workloadDto", _typeReferenceBuilder.typeRef(IDto))
+ parameters += table.toParameter("selection", _typeReferenceBuilder.typeRef(Integer))
+ parameters += table.toParameter("selected", _typeReferenceBuilder.typeRef(boolean))
+ body = [append('''«table.addOrRemoveItemToWorkloadDto»''')]
+ ])
+ type.members += table.toMethod("removeAllItemsFromWorkloadDto", _typeReferenceBuilder.typeRef(Void::TYPE),
+ [
+ visibility = JvmVisibility.PUBLIC
+ body = [append('''«table.removeAllItemsFromWorkloadDto»''')]
+ ])
+ }
+ }
+
+ def getCallDataRefreshMethod(Table table) {
+ switch (table.tabletype) {
+ TableTable: {
+ "dataRefresh();"
+ }
+ TableGrid: {
+ ""
+ }
+ }
+ }
+
+ def notifyTaskEvent(Table table) {
+ '''
+ «table.callDataRefreshMethod»'''
+ }
+
+ /**
+ * <p>build the methods.</p>
+ *
+ */
+ def void toStringToNumberConverter(JvmDeclaredType type, Table table) {
+
+ // create getStringToInt
+ type.members += table.toMethod('''«CONVERT_METHOD_PREFIX»Int''', _typeReferenceBuilder.typeRef(int),
+ [
+ parameters += table.toParameter("value", _typeReferenceBuilder.typeRef(String))
+ body = [append('''return Double.valueOf(value).intValue();''')]
+ ])
+
+ // create getStringToDouble
+ type.members += table.toMethod('''«CONVERT_METHOD_PREFIX»Double''', _typeReferenceBuilder.typeRef(double),
+ [
+ parameters += table.toParameter("value", _typeReferenceBuilder.typeRef(String))
+ body = [append('''return Double.valueOf(value);''')]
+ ])
+ }
+
+ /**
+ * <p>build the main method to be called from e4.</p>
+ *
+ tablePageLabel = new Label();
+ tablePageLabel.setContentMode(ContentMode.HTML);
+ tablePageLabel.addStyleName("pagelabel");
+ tablePageLabel.setId("tablePageLabel");
+
+ «"Page".bindComponent("tablePageLabel", "Value")»
+ tableItemsLabel = new Label();
+ tableItemsLabel.setContentMode(ContentMode.HTML);
+ tableItemsLabel.addStyleName("pagelabel");
+ tableItemsLabel.setId("tableItemsLabel");
+ «"Items per page".bindComponent("tableItemsLabel", "Value")»
+ */
+ def String createView(Table table, TablePackage pkg) {
+
+ var body = '''
+ «IF table.task»
+ taskClient.subscribeTaskEventNotification(this);
+ taskClient.subscribeProcessCompletedEventNotification(this);
+ currentTaskId = -1L;
+ «ENDIF»
+ tables = new ArrayList<CellSetFilterTable>();
+ tableFilterDecorator = new TableFilterDecorator(dslMetadataService);
+ // the timeout to begin the filter process after the last key pressed
+ tableFilterDecorator.setTextChangeTimeout(500);
+ '''
+ if(table.tabletype instanceof TableGrid) {
+ val gridDtoFqn = (table.tabletype as TableGrid).source.dtoSource.fullyQualifiedName.toString
+ val entity = EntityUtils.getEntityFromDto((table.tabletype as TableGrid).source.dtoSource)
+ body = '''
+ «body»
+ persistenceService.registerPersistenceUnit("«entity?.persistenceUnit»",
+ «entity?.fullyQualifiedName».class);
+ log.debug("PersistenceService registered");
+ IEclipseContext childContext = context.createChild();
+ childContext.set(Locale.class, user.getLocale());
+ childContext.set("gridSourceId", "«pkg.name.toString.concat(".").concat(table.name).concat("Grid")»");
+ if ("«gridDtoFqn»".equals(getTaskOperativeDtoFqn())) {
+ childContext.set("inputdata", getTaskInitialOperativeDtos());
+ }
+ grid = ContextInjectionFactory.make(SingleInfoGridComponent.class, childContext);'''
+ }
+ body = '''
+ «body»
+ coordinateSystem = new ArrayList<Integer>();
+ filterGenerator = new DatamartFilterGenerator();
+ filterGenerator.setDslMetadataService(dslMetadataService);
+ layoutManager = new ViewLayoutManager();
+ tableSelectDelay = new Refresher();
+ tableRefresher = new Refresher();
+ propertyLookupMap = new HashMap<String,PropertyLookup>();
+ '''
+
+ // the package name of the referenced datamart
+ if (getSourceDataMartRefName(table) != null) {
+ body = '''
+ «body»
+ datamartClass = new «getSourceDataMartRefName(table)»Datamart();'''
+ }
+ if (!table.tabletype.embedded && table.tabletype.toolbar != null) {
+ body = '''
+ «body»
+ toolbarClass = new «table.tabletype.toolbar.name.toString.toFirstUpper»Action(UUID.randomUUID().toString());
+ toolbarClass.createToolbar(getContext(), renderingEngine, themeResourceService);'''
+ }
+ body = '''
+ «body»
+ parent.setPrimaryStyleName("osbp");
+ parent.setId("parent");
+ parent.setSizeFull();
+ layoutManager.init(parent);
+ refreshView = «table.refreshView»
+ «IF !table.tabletype.embedded && table.tabletype.toolbar != null»dispatchAction = «table.dispatchAction»«ENDIF»
+ '''
+
+ if (table.tabletype.polling) {
+ body = '''
+ «body»
+ tableRefresher.setRefreshInterval(«table.tabletype.pollingTime»*1000);
+ tableRefresher.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {
+ @Override
+ public void refresh(final Refresher source) {
+ «table.callDataRefreshMethod»
+ }
+ });
+ layoutManager.addExtension(tableRefresher);
+ '''
+ }
+
+ if (table.dataMartTable instanceof TableDatamart && table.dataMartTable != null && (
+ (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartEntity ||
+ (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartCube
+ )) {
+ body = '''
+ «body»
+ filterChangeListener = new ValueChangeListener() {
+ @Override
+ public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
+ «table.callDataRefreshMethod»
+ }
+ };
+ filterGenerator.createFilter(datamartClass, user, filterChangeListener, layoutManager);
+ '''
+ }
+
+ body = '''
+ «body»setup();
+ user.addUserLocaleListener(this);
+ '''
+ return body
+ }
+
+ def boolean isTask(Table table) {
+ return table.dataMartTable instanceof TableDatamart &&
+ (table.dataMartTable as TableDatamart).datamartRef.source instanceof DatamartTask;
+ }
+
+ def dataRefresh(Table table) {
+ '''
+ try {
+ // if no current ui found
+ if (UI.getCurrent() == null) {
+ for(CellSetFilterTable table:tables) {
+ UI.setCurrent(table.getUI());
+ break;
+ }
+ }
+ if(dataSourceContainer== null || !dataSourceContainer.updateContainer(getCellSet())) {
+ log.debug("cannot update container - full refresh");
+ «IF table.tabletype.embedded»
+ createComponents();
+ «ELSE»
+ renderData();
+ «ENDIF»
+ }
+ for(CellSetFilterTable table:tables) {
+ table.sanitizeSelection();
+ «table.notifyBPMNChart»
+ }
+ }
+ catch (Exception e) {
+ log.error("dataRefresh", e);
+ }'''
+ }
+
+ /**
+ * <p>create a handler for external triggered refresh requests.</p>
+ *
+ */
+ def String refreshView(Table table) {
+ var body = ""
+ var updateFiler = ""
+ switch (table.tabletype) {
+ TableTable: {
+ updateFiler = "filterGenerator.updateFilter(datamartClass, user, filterChangeListener);"
+ }
+ TableGrid: {
+ }
+ }
+ body = '''
+ «body»
+ new EventHandler() {
+ @Override
+ public void handleEvent(Event event) {
+ // data could be changed externally - update filters
+ «updateFiler»
+ «table.callDataRefreshMethod»
+ }
+ };
+ '''
+ return body
+ }
+
+ /**
+ * <p>create a handler for external triggered task actions.</p>
+ *
+ */
+ def String dispatchAction(Table table) {
+ var body = ""
+ body = '''
+ «body»
+ new EventHandler() {
+ @Override
+ public void handleEvent(Event event) {
+ EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(EventUtils.DATA);
+ log.debug("dispatch action received in «table.name» for "+msg.getName());
+ «IF table.isTask»
+ currentTaskId = msg.getLong();
+ taskClient.operations(msg.getLong(), user, null, Operation.valueOf(msg.getName()));
+ «ELSEIF (table.tabletype instanceof TableSelection)»
+ switch(msg.getName()) {
+ case "«SelectWorkloadActionEnum.WORKLOAD_SELECT_ACTION_ADD_ALL.literal»":
+ addAllItemsToWorkloadDto();
+ break;
+ case "«SelectWorkloadActionEnum.WORKLOAD_SELECT_ACTION_REMOVE_ALL.literal»":
+ removeAllItemsFromWorkloadDto();
+ break;
+ }
+ «ELSE»
+ switch(msg.getName()) {
+ case "«ReportActionEnum.REPORT_ACTION_PRINT_ON_SERVER_PDF.literal»":
+ break;
+ case "«ReportActionEnum.REPORT_ACTION_DOWNLOAD_PDF.literal»":
+ break;
+ case "«ChartActionEnum.CHART_ACTION_DOWNLOAD.literal»":
+ break;
+ case "«WorkflowActionEnum.WORKFLOW_ACTION_START.literal»":
+ break;
+ }
+ «ENDIF»
+ }
+ };
+ '''
+ return body
+ }
+
+ /**
+ * <p>create a handler for user changed.</p>
+ *
+ */
+ def String delegatedTask(Table table) {
+ var body = ""
+ body = '''
+ «body»
+ new EventHandler() {
+ @Override
+ public void handleEvent(Event event) {
+ EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(EventUtils.DATA);
+ datamartClass.operations(msg.getLong(), user, msg.getName(), Operation.Delegate);
+ }
+ };
+ '''
+ return body
+ }
+
+ /**
+ * <p>build the data components.</p>
+ *
+ */
+ def String createComponents(Table table) {
+ var body = "resetListeningForEntityIdsModifications();"
+ if (table.dataMartTable != null) {
+ var generateModifyLister = ''''''
+ if (table.dataMartTable != null && table.dataMartTable.datamartRef != null &&
+ (table.dataMartTable.datamartRef.source instanceof DatamartEntity)) {
+ generateModifyLister = '''datamartClass.addEntityIdsToModifyListener(this, cellSet);'''
+ }
+ body = '''
+ try {
+ // get the results
+ final DerivedCellSet cellSet = getCellSet();
+ if (cellSet == null) {
+ «IF !table.tabletype.embedded»promptSecurityMessage(dslMetadataService.translate(locale.toLanguageTag(), "securityMessage"), layoutManager.getDataArea());«ENDIF»
+ return;
+ } else {
+ layoutManager.getDataArea().removeAllComponents();
+ }
+ «IF !table.tabletype.embedded»
+ resetListeningForEntityIdsModifications();
+ «generateModifyLister»
+ «ENDIF»
+ getCoordinateSystem().clear();
+ // generate a new result component
+ if (cellSet != null) {
+ // create a multidimensional coordinate system against the cellSet
+ for (int axis = 0; axis < cellSet.getAxes().size(); axis++) {
+ getCoordinateSystem().add(0);
+ }
+ // remove any previous component
+ if (dataComponent != null) {
+ layoutManager.getDataArea().removeComponent(dataComponent);
+ dataComponent = null;
+ }
+ if (cellSet.getAxes().size() < 2) {
+ log.error("at least 2 axes from referenced datamart «table.dataMartTable.datamartRef.name» are needed to render «table.
+ name»");
+ }
+ dataComponent = createTabSheet(cellSet, cellSet.getAxes().size());
+ if (dataComponent != null) {
+ dataComponent.setSizeFull();
+ dataComponent.setId("dataComponent");
+ layoutManager.getDataArea().addComponent(dataComponent);
+ «IF (table.tabletype instanceof TableSelection)»
+ selectItemsFromWorkloadDto();
+ «ENDIF»
+ layoutManager.getDataArea().setExpandRatio(dataComponent, 1);
+ «table.selectAlways»
+ }
+ }
+ else {
+ log.error("referenced datamart «table.dataMartTable.datamartRef.name» generates no results");
+ }
+ } catch (DerivedOlapException e) {
+ log.error("createComponents", e);
+ }
+ '''
+ } else {
+ body = '''
+ «body»
+ // generate a new result component
+ try {
+ // remove any previous component
+ if (dataComponent != null) {
+ layoutManager.getDataArea().removeComponent(dataComponent);
+ dataComponent = null;
+ }
+ dataComponent = createDtoGrid();
+ dataComponent.setSizeFull();
+ dataComponent.setId("dataComponent");
+ layoutManager.getDataArea().addComponent(dataComponent);
+ layoutManager.getDataArea().setExpandRatio(dataComponent, 1);
+ «table.selectAlways»
+ } catch (DerivedOlapException e) {
+ log.error("createComponents", e);
+ }
+ '''
+ }
+ return body
+ }
+
+ def String getSelectAlways(Table table) {
+ var body = ""
+ if (table.tabletype instanceof TableTable && (table.tabletype as TableTable).selectalways) {
+ body = '''
+ «body»
+ tableSelectDelay.setRefreshInterval(1000);
+ if (tableSelectDelay.getListeners(null).size()==0) {
+ tableSelectDelay.addListener(new com.github.wolfie.refresher.Refresher.RefreshListener() {
+ @Override
+ public void refresh(final Refresher source) {
+ // refresh only once
+ source.setRefreshInterval(0);
+ for(CellSetFilterTable table:tables) {
+ if (table.getItemIds().size()>0) {
+ table.select(table.getItemIds().iterator().next());
+ }
+ }
+ }
+ });
+ layoutManager.addExtension(tableSelectDelay);
+ }'''
+ }
+ return body
+ }
+
+ /**
+ * <p>if more than 2 axes (dimensions) are found in the cellSet, build recursive tabsheets as long as the remaining axes are more than 2.</p>
+ *
+ */
+ def String createTabSheet(Table table) {
+ var body = ""
+ body = '''
+ «body»
+ tables.clear();
+ // either create a recursive tabsheet or a table
+ Component component = null;
+ if (axisNo == 2) {
+ component = createTable(cellSet);
+ }
+ else {
+ Integer axis = axisNo-1;
+ TabSheet tabsheet = new TabSheet();
+ tabsheet.setSizeFull();
+ DerivedAxis tabAxis = cellSet.getAxes().get(axis);
+ // create a tab page for all tab axis members
+ int tabNo = 0;
+ for (DerivedPosition column : tabAxis.getPositions()) {
+ // create the title for the axis
+ String title = null;
+ for (DerivedMember member : column.getMembers()) {
+ if (title == null) {
+ title = dslMetadataService.translate(locale.toLanguageTag(), member.getCaption());
+ }
+ else {
+ title += " / "+dslMetadataService.translate(locale.toLanguageTag(), member.getCaption());
+ }
+ }
+ // position the data to this coordinate
+ getCoordinateSystem().set(axis, tabNo);
+ component = createTabSheet(cellSet, axis);
+ // set the caption
+ if (component != null) {
+ component.setCaption(title);
+ tabsheet.addComponent(component);
+ if (component instanceof CellSetFilterTable) {
+ tabsheet.addComponent(((CellSetFilterTable)component));
+ }
+ }
+ tabNo++;
+ }
+ component = tabsheet;
+ }
+ return component;'''
+ return body
+ }
+
+ /**
+ * <p>build the table component.</p>
+ *
+ */
+ def String createTable(Table table) {
+ var body = ""
+ var TableAxis category_axis = null
+ var TableAxis data_axis = null
+ var idMap = <String, IdProperty>newHashMap
+ var formatMap = <String, FormatProperty>newHashMap
+ var intervalStyleMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var intervalIconMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var intervalTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var numberLookupStyleMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var numberLookupIconMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var numberLookupTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var stringLookupStyleMap = <String, Map<String, Map<String, String>>>newHashMap
+ var stringLookupIconMap = <String, Map<String, Map<String, String>>>newHashMap
+ var stringLookupTooltipMap = <String, Map<String, Map<String, String>>>newHashMap
+ var dateLookupStyleMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var dateLookupIconMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var dateLookupTooltipMap = <String, Map<Double, Map<String, String>>>newHashMap
+ var blobLookupMap = <String, String>newHashMap()
+
+ var rowStyle = ""
+
+ for (element : table.dataMartTable.elements) {
+ if (element instanceof TableAxis) {
+ var axis = element as TableAxis
+ if (axis.axis.getName.equals('COLUMNS')) {
+ data_axis = axis
+ }
+ if (axis.axis.getName.equals('ROWS')) {
+ category_axis = axis
+ }
+ }
+ }
+
+ if (category_axis == null) {
+ category_axis = TableDSLFactory.eINSTANCE.createTableAxis();
+ category_axis.axis = AxisEnum.ROWS;
+ table.dataMartTable.elements.add(category_axis);
+ }
+ if (data_axis == null) {
+ data_axis = TableDSLFactory.eINSTANCE.createTableAxis();
+ data_axis.axis = AxisEnum.COLUMNS;
+ table.dataMartTable.elements.add(data_axis);
+ }
+ var constructTable = "final CellSetFilterTable table = new CellSetFilterTable();"
+ var multiSelect = false;
+ if (table.tabletype instanceof TableSelection) {
+ constructTable = '''
+ final CheckboxSelectionCellSetFilterTable table = new CheckboxSelectionCellSetFilterTable();
+ selectTable = table;
+ '''
+ multiSelect = (table.tabletype as TableSelection).multiSelection
+ }
+ body = '''
+ «body»«constructTable»
+ VerticalLayout tableLayout = new VerticalLayout();
+ «IF table.tabletype.embedded && 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, Operation.Start);
+ eventBroker.send(EventBrokerMsg.MENU_CLOSE, null);
+ }
+ });
+ 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");
+ table.setRowHeaderMode(RowHeaderMode.«IF (table.tabletype as TableTable).headerMode != null»«(table.tabletype as TableTable).
+ headerMode.name()»«ELSE»HIDDEN«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)
+ table.initIdMap(idMap)
+ if (category_axis.hasDetails) {
+ category_axis.initPropertyLookups(formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap,
+ numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap,
+ stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap)
+ }
+ if (data_axis.hasDetails) {
+ data_axis.initPropertyLookups(formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap,
+ numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap,
+ stringLookupIconMap, stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap)
+ }
+ if (intervalStyleMap.keySet.size + numberLookupStyleMap.keySet.size + stringLookupStyleMap.keySet.size +
+ dateLookupStyleMap.keySet.size > 0 || category_axis.hasRowHeight) {
+ body = '''
+ «body»// add styles to page for the axis's custom styles
+ Styles styles = Page.getCurrent().getStyles();
+ '''
+ }
+ if (category_axis.hasRowHeight) {
+ customformatCounter = customformatCounter + 1
+ rowStyle = '''rowcustomformat«customformatCounter»'''
+ body = '''«body»styles.add(".v-table-row-«rowStyle» {height: «category_axis.rowHeight»px;}");
+'''
+ }
+ body = '''«body»«createStyles(intervalStyleMap, numberLookupStyleMap, stringLookupStyleMap, dateLookupStyleMap)» '''
+
+ // all detail value information if present is mapped to methods of TableCellGenerator
+ body = '''«body»«generatePropertyLookups(idMap, formatMap, intervalStyleMap, intervalIconMap, intervalTooltipMap,
+ numberLookupStyleMap, numberLookupIconMap, numberLookupTooltipMap, stringLookupStyleMap, stringLookupIconMap,
+ stringLookupTooltipMap, dateLookupStyleMap, dateLookupIconMap, dateLookupTooltipMap, blobLookupMap)»'''
+ body = '''
+ «body»dataSourceContainer = new CellSetIndexedContainer(dslMetadataService, locale, themeResourceService, propertyLookupMap, cellSet, coordinateSystem, «table.isDatamartCrossJoined»);
+ table.setContainerDataSource(dataSourceContainer);
+ dataSourceContainer.addExtras(table);
+ '''
+ if (category_axis.hasRowHeight) {
+ body = '''
+ «body»dataSourceContainer.setRowStyle("«rowStyle»");
+ '''
+ }
+ if (table.tabletype instanceof TableTable) {
+ if (table.dataMartTable instanceof TableDatamart) {
+ for (element : (table.dataMartTable as TableDatamart).elements) {
+ if (element instanceof TableAxis) {
+ if ((element as TableAxis).preOrder != null) {
+
+ // create a ordering refresh event if applicable
+ body = '''«body»«(element as TableAxis).preOrder.preOrder(element as TableAxis)»'''
+ }
+ }
+ }
+
+ }
+ }
+
+ // if (!(table.tabletype as TableTable).pageable) {
+ // body = '''
+ // «body»if (cellSet.getAxes().get(«category_axis.axis.name.ordinal»).getPositions().size() > 15) {
+ // table.setPageLength(15);
+ // }
+ // else
+ // {
+ // table.setPageLength(0);
+ // }
+ // '''
+ // }
+ // send a selection event if modeled
+ body = '''«body»«table.sendEvent»
+ '''
+ if (table.tabletype instanceof TableSelection) {
+ body = '''«body»
+ selectItemsFromWorkloadDto();
+ '''
+ }
+ body = '''«body»return tableLayout;'''
+ return body
+ }
+
+ def boolean isDatamartCrossJoined(Table table) {
+ return (table.dataMartTable as TableDatamart).datamartRef.isCrossJoined();
+ }
+
+ def String modifyOddStyle(String style) {
+ var start = style.indexOf("background-color:");
+ var end = 0;
+ if (start >= 0) {
+ var pos = style.indexOf("(", start);
+ if (pos >= 0) {
+ var newrgb = "";
+ end = style.indexOf(")", pos);
+ var rgb = style.substring(pos + 1, end);
+ var colors = rgb.split(",")
+ for (color : colors) {
+ var colorValue = Integer.parseInt(color)
+ var diff = 15
+ if (diff > colorValue) {
+ diff = colorValue
+ }
+ colorValue = colorValue - diff
+ newrgb = '''«newrgb»«IF newrgb.length > 0»,«ENDIF»«colorValue.toString»'''
+ }
+ return '''«style.substring(0, start)»background-color: rgb(«newrgb»)«style.substring(end + 1)»'''
+ }
+ }
+ return style
+ }
+
+ /**
+ * <p>collected styles from the model are applied to code. Styles aside from the CSS are created at runtime.</p>
+ *
+ */
+ def String createStyles(
+ HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap
+ ) {
+ var stylePrefix = ".v-table-cell-content-"
+ var body = ""
+ for (format : intervalStyleMap.keySet) {
+ for (interval : intervalStyleMap.get(format).keySet) {
+ for (style : intervalStyleMap.get(format).get(interval).keySet) {
+ body = '''«body»styles.add("«stylePrefix»«style» {«intervalStyleMap.get(format).get(interval).get(
+ style)»}");
+ '''
+ body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle(
+ intervalStyleMap.get(format).get(interval).get(style))»}");
+ '''
+ }
+ }
+ }
+ for (format : numberLookupStyleMap.keySet) {
+ for (interval : numberLookupStyleMap.get(format).keySet) {
+ for (style : numberLookupStyleMap.get(format).get(interval).keySet) {
+ body = '''«body»styles.add("«stylePrefix»«style» {«numberLookupStyleMap.get(format).get(interval).
+ get(style)»}");
+ '''
+ body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle(
+ numberLookupStyleMap.get(format).get(interval).get(style))»}");
+ '''
+ }
+ }
+ }
+ for (format : stringLookupStyleMap.keySet) {
+ for (interval : stringLookupStyleMap.get(format).keySet) {
+ for (style : stringLookupStyleMap.get(format).get(interval).keySet) {
+ body = '''«body»styles.add("«stylePrefix»«style» {«stringLookupStyleMap.get(format).get(interval).
+ get(style)»}");
+ '''
+ body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle(
+ stringLookupStyleMap.get(format).get(interval).get(style))»}");
+ '''
+ }
+ }
+ }
+ for (format : dateLookupStyleMap.keySet) {
+ for (interval : dateLookupStyleMap.get(format).keySet) {
+ for (style : dateLookupStyleMap.get(format).get(interval).keySet) {
+ body = '''«body»styles.add("«stylePrefix»«style» {«dateLookupStyleMap.get(format).get(interval).
+ get(style)»}");
+ '''
+ body = '''«body»styles.add("«stylePrefix»«style»-odd {«modifyOddStyle(
+ dateLookupStyleMap.get(format).get(interval).get(style))»}");
+ '''
+ }
+ }
+ }
+ return body
+ }
+
+ /**
+ * <p>In order to customize the cellGenerator, methods must be called inferred from the model.</p>
+ *
+ */
+ def String generatePropertyLookups(
+ HashMap<String, IdProperty> idMap,
+ HashMap<String, FormatProperty> formatMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalTooltipMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupTooltipMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupIconMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupTooltipMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupTooltipMap,
+ HashMap<String, String> blobLookupMap
+ ) {
+ var properties = <String>newHashSet
+ properties.addAll(formatMap.keySet)
+ properties.addAll(intervalStyleMap.keySet)
+ properties.addAll(intervalIconMap.keySet)
+ properties.addAll(intervalTooltipMap.keySet)
+ properties.addAll(numberLookupStyleMap.keySet)
+ properties.addAll(numberLookupIconMap.keySet)
+ properties.addAll(numberLookupTooltipMap.keySet)
+ properties.addAll(stringLookupStyleMap.keySet)
+ properties.addAll(stringLookupIconMap.keySet)
+ properties.addAll(stringLookupTooltipMap.keySet)
+ properties.addAll(dateLookupStyleMap.keySet)
+ properties.addAll(dateLookupIconMap.keySet)
+ properties.addAll(dateLookupTooltipMap.keySet)
+ properties.addAll(blobLookupMap.keySet)
+ properties.addAll(idMap.keySet)
+ var body = ""
+
+ if (properties.size > 0) {
+ body = '''«body»// add propertyLookups for column and row property supplements
+ '''
+ }
+
+ // all detail value information if present is mapped to methods of PropertyLookup
+ // styles and icons can be mapped to value ranges
+ for (property : properties) {
+ var hadProperty = false
+ if(property != null) {
+ hadProperty = true
+ body = '''«body»propertyLookupMap.put("«property.toString.toUpperCase»", new PropertyLookup(themeResourceService, dslMetadataService, locale)'''
+
+ // apply all collapsed id columns
+ if (idMap.containsKey(property)) {
+ body = '''
+ «body»
+ .setCollapseColumn(«idMap.get(property).collapsed.booleanValue.toString»)
+ '''
+ }
+
+ // apply all found formatter information
+ if (formatMap.containsKey(property)) {
+ if (formatMap.get(property).formatter != null) {
+ body = '''
+ «body»
+ .setFormat("«formatMap.get(property).formatter»")
+ '''
+ }
+ if (formatMap.get(property).tooltipPattern != null) {
+ body = '''
+ «body»
+ .setTooltipPattern("«formatMap.get(property).tooltipPattern»")
+ '''
+ }
+ if (intervalIconMap.size > 0) {
+ body = '''
+ «body»
+ .setHideLabel(«formatMap.get(property).hideLabelInterval.booleanValue.toString»)
+ '''
+ } else if (numberLookupIconMap.size + stringLookupIconMap.size + dateLookupIconMap.size > 0) {
+ body = '''
+ «body»
+ .setHideLabel(«formatMap.get(property).hideLabelLookup.booleanValue.toString»)
+ '''
+ } else {
+ body = '''
+ «body»
+ .setHideLabel(«formatMap.get(property).hideImageLabel.booleanValue.toString»)
+ '''
+ }
+ body = '''
+ «body»
+ .setCollapseColumn(«formatMap.get(property).collapsed.booleanValue.toString»)
+ '''
+ if (formatMap.get(property).hasImage) {
+ body = '''
+ «body»
+ .setImageService("«formatMap.get(property).imagePath»", «formatMap.get(property).hasImageParameter.booleanValue.
+ toString»)
+ '''
+ if (formatMap.get(property).hasImageResize) {
+ body = '''
+ «body»
+ .setResizeString("«formatMap.get(property).imageResizeString»")'''
+ }
+ }
+ if (formatMap.get(property).iconName != null) {
+ body = '''
+ «body»
+ .setColumnIcon("«formatMap.get(property).iconName»")
+ '''
+ }
+ }
+
+ // apply all interval styles information
+ if (intervalStyleMap.containsKey(property)) {
+ for (interval : intervalStyleMap.get(property).keySet) {
+ for (style : intervalStyleMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addStyleInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», "«style»")
+ '''
+ }
+ }
+ }
+
+ // apply all interval icons information
+ if (intervalIconMap.containsKey(property)) {
+ for (interval : intervalIconMap.get(property).keySet) {
+ for (style : intervalIconMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addResourceInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», "«intervalIconMap.
+ get(property).get(interval).get(style)»")
+ '''
+ }
+ }
+ }
+
+ // apply all interval tooltip information
+ if (intervalTooltipMap.containsKey(property)) {
+ for (interval : intervalTooltipMap.get(property).keySet) {
+ for (style : intervalTooltipMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addTooltipInterval(«IF style.startsWith("date")»ExtendedDate.add(new Date(), (long)«interval * -1», TimeUnit.DAYS)«ELSE»«interval»«ENDIF», dslMetadataService.translate(locale.toLanguageTag(), "«intervalTooltipMap.
+ get(property).get(interval).get(style)»"))
+ '''
+ }
+ }
+ }
+
+ // styles and icons can be mapped to discrete double values (lookups)
+ // apply all lookup styles information
+ if (numberLookupStyleMap.containsKey(property)) {
+ for (interval : numberLookupStyleMap.get(property).keySet) {
+ for (style : numberLookupStyleMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addStyleLookup(«interval», "«style»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup icons information
+ if (numberLookupIconMap.containsKey(property)) {
+ for (interval : numberLookupIconMap.get(property).keySet) {
+ for (style : numberLookupIconMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addResourceLookup(«interval», "«numberLookupIconMap.get(property).get(interval).get(style)»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup tooltip information
+ if (numberLookupTooltipMap.containsKey(property)) {
+ for (interval : numberLookupTooltipMap.get(property).keySet) {
+ for (style : numberLookupTooltipMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addTooltipLookup(«interval», dslMetadataService.translate(locale.toLanguageTag(), "«numberLookupTooltipMap.get(property).
+ get(interval).get(style)»"))
+ '''
+ }
+ }
+ }
+
+ // styles and icons can be mapped to discrete string values (lookups)
+ // apply all lookup styles information
+ if (stringLookupStyleMap.containsKey(property)) {
+ for (interval : stringLookupStyleMap.get(property).keySet) {
+ for (style : stringLookupStyleMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addStyleLookup("«interval»", "«style»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup icons information
+ if (stringLookupIconMap.containsKey(property)) {
+ for (interval : stringLookupIconMap.get(property).keySet) {
+ for (style : stringLookupIconMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addResourceLookup("«interval»", "«stringLookupIconMap.get(property).get(interval).get(style)»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup tooltip information
+ if (stringLookupTooltipMap.containsKey(property)) {
+ for (interval : stringLookupTooltipMap.get(property).keySet) {
+ for (style : stringLookupTooltipMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addTooltipLookup("«interval»", dslMetadataService.translate(locale.toLanguageTag(), "«stringLookupTooltipMap.get(property).
+ get(interval).get(style)»"))
+ '''
+ }
+ }
+ }
+
+ // styles and icons can be mapped to discrete date values (lookups)
+ // apply all lookup styles information
+ if (dateLookupStyleMap.containsKey(property)) {
+ for (interval : dateLookupStyleMap.get(property).keySet) {
+ for (style : dateLookupStyleMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addStyleLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), "«style»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup icons information
+ if (dateLookupIconMap.containsKey(property)) {
+ for (interval : dateLookupIconMap.get(property).keySet) {
+ for (style : dateLookupIconMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addResourceLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), "«dateLookupIconMap.get(property).
+ get(interval).get(style)»")
+ '''
+ }
+ }
+ }
+
+ // apply all lookup tooltip information
+ if (dateLookupTooltipMap.containsKey(property)) {
+ for (interval : dateLookupTooltipMap.get(property).keySet) {
+ for (style : dateLookupTooltipMap.get(property).get(interval).keySet) {
+ body = '''
+ «body»
+ .addTooltipLookup(ExtendedDate.add(new Date(),«interval * -1»,TimeUnit.DAYS), dslMetadataService.translate(locale.toLanguageTag(), "«dateLookupTooltipMap.
+ get(property).get(interval).get(style)»"))
+ '''
+ }
+ }
+ }
+
+ // apply all lookup blob information
+ if (blobLookupMap.containsKey(property)) {
+ body = '''
+ «body»
+ .setBlob(true, «blobLookupMap.get(property)»)
+ '''
+ }
+ }
+ if(hadProperty) {
+ body = '''«body»);
+'''
+ }
+ }
+ return body
+ }
+
+ /**
+ * <p>infer the model's setting for cell configuration including blobs.</p>
+ *
+ */
+ def initBlobLookup(Table table, Map<String, String> blobMap) {
+ var datamartSource = table.dataMartTable.datamartRef.source
+ if (datamartSource instanceof DatamartEntity) {
+ for (property : (datamartSource as DatamartEntity).properties) {
+ if(property.propertyRef.properties.exists[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]) { // try entity properties
+ var resolution = property.propertyRef.properties.findFirst[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]
+ blobMap.put(property.getPropertyName(), resolution?.value)
+ } else if (property.propertyRef.type instanceof LDataType){ // try data type properties
+ if((property.propertyRef.type as LDataType).properties.exists[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]) {
+ var resolution = (property.propertyRef.type as LDataType).properties.findFirst[key.toLowerCase.equals(AbstractLayoutingStrategy.PROPERTY_BLOB)]
+ blobMap.put(property.getPropertyName(), resolution?.value)
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>infer the model's setting for cell configuration including styles and images.</p>
+ *
+ */
+ def initPropertyLookups(
+ TableAxis axis,
+ HashMap<String, FormatProperty> formatMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> intervalTooltipMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> numberLookupTooltipMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupStyleMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupIconMap,
+ HashMap<String, Map<String, Map<String, String>>> stringLookupTooltipMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupStyleMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupIconMap,
+ HashMap<String, Map<Double, Map<String, String>>> dateLookupTooltipMap
+ ) {
+ for (value : axis.values) {
+
+ // create formatter map
+ var prop = new FormatProperty
+ if (value.formatter != null) {
+ prop.formatter = value.formatter.format
+ }
+ if (value.tooltipPattern != null) {
+ prop.tooltipPattern = value.tooltipPattern.tooltipPattern
+ }
+ prop.hideLabelLookup = value.hideLabelLookup
+ prop.collapsed = value.collapsed
+ prop.hasImage = value.hasImage
+ prop.iconName = value.iconName
+ if (value.hasImage && value.image != null) {
+ prop.hasImageParameter = value.image.hasParameter
+ prop.imagePath = value.image.imagePathPattern
+ prop.hideImageLabel = value.image.hideImageLabel
+ prop.hasImageResize = value.image.resize
+ prop.imageResizeString = value.image.resizeString
+ if (value.image.hasParameter) {
+ switch (value.image.imagePathParameter) {
+ TableColumn:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableColumn).valueRef.
+ columnRef.literal
+ TableMeasure:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableMeasure).valueRef.
+ measureRef.name
+ TableDerived:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableDerived).valueRef.
+ derivedRef.name
+ TableHierarchy:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableHierarchy).valueRef.
+ levelName
+ TableProperty:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableProperty).valueRef.
+ getPropertyName()
+ TableAggregation:
+ prop.imagePathParameter = (value.image.imagePathParameter as TableAggregation).valueRef.
+ aggregation.name()
+ }
+ }
+ }
+ switch value.column {
+ TableOrdinal: formatMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', prop)
+ TableAllColumns: formatMap.put('''?«axis.axis.literal»''', prop)
+ TableMeasure: formatMap.put('''«(value.column as TableMeasure).valueRef.measureRef.name»''', prop)
+ TableDerived: formatMap.put('''«(value.column as TableDerived).valueRef.derivedRef.name»''', prop)
+ TableHierarchy: formatMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''', prop)
+ TableProperty: formatMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', prop)
+ TableAggregation: formatMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', prop)
+ TableColumn: formatMap.put('''«(value.column as TableColumn).valueRef.columnRef.literal»''', prop)
+ }
+
+ // create styles interval map
+ var valueMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (interval : value.intervals) {
+ switch interval {
+ TableNumberInterval:
+ if ((interval as TableNumberInterval).numberRange instanceof TableTextColor ||
+ (interval as TableNumberInterval).numberRange instanceof TableCellColor) {
+ var key = new Double((interval as TableNumberInterval).numberIntervalValue)
+ var styleAspect = ""
+ var Map<String, String> styleMap = null
+ if (valueMap.containsKey(key)) {
+ styleMap = valueMap.get(key)
+ styleAspect = styleMap.get(styleMap.keySet.get(0))
+ } else {
+ styleMap = <String, String>newHashMap
+ styleAspect = ""
+ customformatCounter = customformatCounter + 1
+ }
+ switch (interval as TableNumberInterval).numberRange {
+ TableTextColor: styleAspect = '''«styleAspect»color: «((interval as TableNumberInterval).
+ numberRange as TableTextColor).rgb.toRGB»;'''
+ TableCellColor: styleAspect = '''«styleAspect»background-color: «((interval as TableNumberInterval).
+ numberRange as TableCellColor).rgb.toRGB»;'''
+ }
+ if (styleAspect.length > 0) {
+ styleMap.put('''numbercustomformat«customformatCounter»''', styleAspect)
+ valueMap.put(key, styleMap)
+ }
+ }
+ TableDateDayInterval:
+ if ((interval as TableDateDayInterval).dateRange instanceof TableTextColor ||
+ (interval as TableDateDayInterval).dateRange instanceof TableCellColor) {
+ var key = new Double((interval as TableDateDayInterval).dateIntervalValue)
+ var styleAspect = ""
+ var Map<String, String> styleMap = null
+ if (valueMap.containsKey(key)) {
+ styleMap = valueMap.get(key)
+ styleAspect = styleMap.get(styleMap.keySet.get(0))
+ } else {
+ styleMap = <String, String>newHashMap
+ styleAspect = ""
+ customformatCounter = customformatCounter + 1
+ }
+ switch (interval as TableDateDayInterval).dateRange {
+ TableTextColor: styleAspect = '''«styleAspect»color: «((interval as TableDateDayInterval).
+ dateRange as TableTextColor).rgb.toRGB»;'''
+ TableCellColor: styleAspect = '''«styleAspect»background-color: «((interval as TableDateDayInterval).
+ dateRange as TableCellColor).rgb.toRGB»;'''
+ }
+ if (styleAspect.length > 0) {
+ styleMap.put('''datecustomformat«customformatCounter»''', styleAspect)
+ valueMap.put(key, styleMap)
+ }
+ }
+ }
+ }
+ if (valueMap.size > 0) {
+ switch value.column {
+ TableOrdinal: intervalStyleMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', valueMap)
+ TableAllColumns: intervalStyleMap.put('''?«axis.axis.literal»''', valueMap)
+ TableMeasure: intervalStyleMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueMap)
+ TableDerived: intervalStyleMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueMap)
+ TableHierarchy: intervalStyleMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''',
+ valueMap)
+ TableProperty: intervalStyleMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueMap)
+ TableAggregation: intervalStyleMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueMap)
+ TableColumn: intervalStyleMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueMap)
+ }
+ }
+
+ // create icon interval map
+ var valueIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (interval : value.intervals) {
+ switch interval {
+ TableNumberInterval: {
+ var key = new Double((interval as TableNumberInterval).numberIntervalValue)
+ var iconAspect = ""
+ var Map<String, String> iMap = <String, String>newHashMap
+ switch (interval as TableNumberInterval).numberRange {
+ TableIcon: iconAspect = '''«((interval as TableNumberInterval).numberRange as TableIcon).
+ icon»'''
+ TableTrend: iconAspect = '''trend_«((interval as TableNumberInterval).numberRange as TableTrend).
+ icon.literal»'''
+ }
+ if (iconAspect.length > 0) {
+ iMap.put("numbericon", iconAspect)
+ valueIconMap.put(key, iMap)
+ }
+
+ }
+ TableDateDayInterval: {
+ var key = new Double((interval as TableDateDayInterval).dateIntervalValue)
+ var iconAspect = ""
+ var Map<String, String> iMap = <String, String>newHashMap
+ switch (interval as TableDateDayInterval).dateRange {
+ TableIcon: iconAspect = '''«((interval as TableDateDayInterval).dateRange as TableIcon).
+ icon»'''
+ TableTrend: iconAspect = '''trend_«((interval as TableDateDayInterval).dateRange as TableTrend).
+ icon.literal»'''
+ }
+ if (iconAspect.length > 0) {
+ iMap.put("dateicon", iconAspect)
+ valueIconMap.put(key, iMap)
+ }
+
+ }
+ }
+ }
+ if (valueIconMap.size > 0) {
+ switch value.column {
+ TableOrdinal: intervalIconMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''', valueIconMap)
+ TableAllColumns: intervalIconMap.put('''?«axis.axis.literal»''', valueIconMap)
+ TableMeasure: intervalIconMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueIconMap)
+ TableDerived: intervalIconMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueIconMap)
+ TableHierarchy: intervalIconMap.put('''«(value.column as TableHierarchy).valueRef.levelName»''',
+ valueIconMap)
+ TableProperty: intervalIconMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueIconMap)
+ TableAggregation: intervalIconMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueIconMap)
+ TableColumn: intervalIconMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueIconMap)
+ }
+ }
+
+ // create tooltip interval map
+ var valueTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (interval : value.intervals) {
+ switch interval {
+ TableNumberInterval: {
+ var key = new Double((interval as TableNumberInterval).numberIntervalValue)
+ var tooltipAspect = ""
+ var Map<String, String> tMap = <String, String>newHashMap
+ switch (interval as TableNumberInterval).numberRange {
+ TableTooltip: tooltipAspect = '''«((interval as TableNumberInterval).numberRange as TableTooltip).
+ tooltip»'''
+ }
+ if (tooltipAspect.length > 0) {
+ tMap.put("numbertooltip", tooltipAspect)
+ valueTooltipMap.put(key, tMap)
+ }
+ }
+ TableDateDayInterval: {
+ var key = new Double((interval as TableDateDayInterval).dateIntervalValue)
+ var tooltipAspect = ""
+ var Map<String, String> tMap = <String, String>newHashMap
+ switch (interval as TableDateDayInterval).dateRange {
+ TableTooltip: tooltipAspect = '''«((interval as TableDateDayInterval).dateRange as TableTooltip).
+ tooltip»'''
+ }
+ if (tooltipAspect.length > 0) {
+ tMap.put("datetooltip", tooltipAspect)
+ valueTooltipMap.put(key, tMap)
+ }
+ }
+ }
+ }
+ if (valueTooltipMap.size > 0) {
+ switch value.column {
+ TableOrdinal: intervalTooltipMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ valueTooltipMap)
+ TableAllColumns: intervalTooltipMap.put('''?«axis.axis.literal»''', valueTooltipMap)
+ TableMeasure: intervalTooltipMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', valueTooltipMap)
+ TableDerived: intervalTooltipMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', valueTooltipMap)
+ TableHierarchy: intervalTooltipMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', valueTooltipMap)
+ TableProperty: intervalTooltipMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', valueTooltipMap)
+ TableAggregation: intervalTooltipMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', valueTooltipMap)
+ TableColumn: intervalTooltipMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', valueTooltipMap)
+ }
+ }
+
+ // create styles lookup map
+ var numberValueLookupStyleMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ var stringValueLookupStyleMap = <String, Map<String, String>>newHashMap()
+ var dateValueLookupStyleMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (lookup : value.lookups) {
+ if (lookup instanceof TableNumberLookup &&
+ ((lookup as TableNumberLookup).discrete instanceof TableTextColor ||
+ (lookup as TableNumberLookup).discrete instanceof TableCellColor)) {
+ var key = new Double((lookup as TableNumberLookup).lookupValue)
+ var styleAspect = ""
+ var Map<String, String> styleMap = null
+ if (numberValueLookupStyleMap.containsKey(key)) {
+ styleMap = numberValueLookupStyleMap.get(key)
+ styleAspect = styleMap.get(styleMap.keySet.get(0))
+ } else {
+ styleMap = <String, String>newHashMap
+ styleAspect = ""
+ customformatCounter = customformatCounter + 1
+ }
+ switch (lookup as TableNumberLookup).discrete {
+ TableTextColor: styleAspect = '''«styleAspect»color: «((lookup as TableNumberLookup).
+ discrete as TableTextColor).rgb.toRGB»;'''
+ TableCellColor: styleAspect = '''«styleAspect»background-color: «((lookup as TableNumberLookup).
+ discrete as TableCellColor).rgb.toRGB»;'''
+ }
+ if (styleAspect.length > 0) {
+ styleMap.put('''customformat«customformatCounter»''', styleAspect)
+ numberValueLookupStyleMap.put(key, styleMap)
+ }
+ }
+ if (lookup instanceof TableStringLookup) {
+ var key = new String((lookup as TableStringLookup).lookupValue)
+ var styleAspect = ""
+ var Map<String, String> styleMap = null
+ if (stringValueLookupStyleMap.containsKey(key)) {
+ styleMap = stringValueLookupStyleMap.get(key)
+ styleAspect = styleMap.get(styleMap.keySet.get(0))
+ } else {
+ styleMap = <String, String>newHashMap
+ styleAspect = ""
+ customformatCounter = customformatCounter + 1
+ }
+ switch lookup.discrete {
+ TableTextColor: styleAspect = '''«styleAspect»color: «(lookup.discrete as TableTextColor).
+ rgb.toRGB»;'''
+ TableCellColor: styleAspect = '''«styleAspect»background-color: «(lookup.discrete as TableCellColor).
+ rgb.toRGB»;'''
+ }
+ if (styleAspect.length > 0) {
+ styleMap.put('''customformat«customformatCounter»''', styleAspect)
+ stringValueLookupStyleMap.put(key, styleMap)
+ }
+ }
+ if (lookup instanceof TableDateDayLookup &&
+ ((lookup as TableDateDayLookup).discrete instanceof TableTextColor ||
+ (lookup as TableDateDayLookup).discrete instanceof TableCellColor)) {
+ var key = new Double((lookup as TableDateDayLookup).lookupValue)
+ var styleAspect = ""
+ var Map<String, String> styleMap = null
+ if (dateValueLookupStyleMap.containsKey(key)) {
+ styleMap = dateValueLookupStyleMap.get(key)
+ styleAspect = styleMap.get(styleMap.keySet.get(0))
+ } else {
+ styleMap = <String, String>newHashMap
+ styleAspect = ""
+ customformatCounter = customformatCounter + 1
+ }
+ switch (lookup as TableDateDayLookup).discrete {
+ TableTextColor: styleAspect = '''«styleAspect»color: «((lookup as TableDateDayLookup).
+ discrete as TableTextColor).rgb.toRGB»;'''
+ TableCellColor: styleAspect = '''«styleAspect»background-color: «((lookup as TableDateDayLookup).
+ discrete as TableCellColor).rgb.toRGB»;'''
+ }
+ if (styleAspect.length > 0) {
+ styleMap.put('''customformat«customformatCounter»''', styleAspect)
+ dateValueLookupStyleMap.put(key, styleMap)
+ }
+ }
+ }
+ if (numberValueLookupStyleMap.size > 0) {
+ switch value.column {
+ TableOrdinal: numberLookupStyleMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ numberValueLookupStyleMap)
+ TableAllColumns: numberLookupStyleMap.put('''?«axis.axis.literal»''',
+ numberValueLookupStyleMap)
+ TableMeasure: numberLookupStyleMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupStyleMap)
+ TableDerived: numberLookupStyleMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupStyleMap)
+ TableHierarchy: numberLookupStyleMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupStyleMap)
+ TableProperty: numberLookupStyleMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', numberValueLookupStyleMap)
+ TableAggregation: numberLookupStyleMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ numberValueLookupStyleMap)
+ TableColumn: numberLookupStyleMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupStyleMap)
+ }
+ }
+ if (stringValueLookupStyleMap.size > 0) {
+ switch value.column {
+ TableOrdinal: stringLookupStyleMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ stringValueLookupStyleMap)
+ TableAllColumns: stringLookupStyleMap.put('''?«axis.axis.literal»''',
+ stringValueLookupStyleMap)
+ TableMeasure: stringLookupStyleMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupStyleMap)
+ TableDerived: stringLookupStyleMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupStyleMap)
+ TableHierarchy: stringLookupStyleMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupStyleMap)
+ TableProperty: stringLookupStyleMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', stringValueLookupStyleMap)
+ TableAggregation: stringLookupStyleMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ stringValueLookupStyleMap)
+ TableColumn: stringLookupStyleMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupStyleMap)
+ }
+ }
+ if (dateValueLookupStyleMap.size > 0) {
+ switch value.column {
+ TableOrdinal: dateLookupStyleMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ dateValueLookupStyleMap)
+ TableAllColumns: dateLookupStyleMap.put('''?«axis.axis.literal»''', dateValueLookupStyleMap)
+ TableMeasure: dateLookupStyleMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupStyleMap)
+ TableDerived: dateLookupStyleMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupStyleMap)
+ TableHierarchy: dateLookupStyleMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupStyleMap)
+ TableProperty: dateLookupStyleMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupStyleMap)
+ TableAggregation: dateLookupStyleMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', dateValueLookupStyleMap)
+ TableColumn: dateLookupStyleMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupStyleMap)
+ }
+ }
+
+ // create icon lookup map
+ var numberValueLookupIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ var stringValueLookupIconMap = <String, Map<String, String>>newHashMap()
+ var dateValueLookupIconMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (lookup : value.lookups) {
+ if (lookup instanceof TableNumberLookup/* && (lookup.discrete instanceof TableTextColor || lookup.discrete instanceof TableCellColor || lookup.discrete instanceof TableIcon)*/) {
+ var key = new Double((lookup as TableNumberLookup).lookupValue)
+ var iconAspect = ""
+ var Map<String, String> iMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»'''
+ TableTrend: iconAspect = '''trend_«(lookup.discrete as TableTrend).icon.literal»'''
+ }
+ if (iconAspect.length > 0) {
+ iMap.put("icon", iconAspect)
+ numberValueLookupIconMap.put(key, iMap)
+ }
+ }
+ if (lookup instanceof TableStringLookup) {
+ var key = (lookup as TableStringLookup).lookupValue
+ var iconAspect = ""
+ var Map<String, String> iMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»'''
+ }
+ if (iconAspect.length > 0) {
+ iMap.put("icon", iconAspect)
+ stringValueLookupIconMap.put(key, iMap)
+ }
+ }
+ if (lookup instanceof TableDateDayLookup) {
+ var key = new Double((lookup as TableDateDayLookup).lookupValue)
+ var iconAspect = ""
+ var Map<String, String> iMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableIcon: iconAspect = '''«(lookup.discrete as TableIcon).icon»'''
+ TableTrend: iconAspect = '''trend_«(lookup.discrete as TableTrend).icon.literal»'''
+ }
+ if (iconAspect.length > 0) {
+ iMap.put("icon", iconAspect)
+ dateValueLookupIconMap.put(key, iMap)
+ }
+ }
+ }
+ if (numberValueLookupIconMap.size > 0) {
+ switch value.column {
+ TableOrdinal: numberLookupIconMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ numberValueLookupIconMap)
+ TableAllColumns: numberLookupIconMap.put('''?«axis.axis.literal»''', numberValueLookupIconMap)
+ TableMeasure: numberLookupIconMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupIconMap)
+ TableDerived: numberLookupIconMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupIconMap)
+ TableHierarchy: numberLookupIconMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupIconMap)
+ TableProperty: numberLookupIconMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', numberValueLookupIconMap)
+ TableAggregation: numberLookupIconMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ numberValueLookupIconMap)
+ TableColumn: numberLookupIconMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupIconMap)
+ }
+ }
+ if (stringValueLookupIconMap.size > 0) {
+ switch value.column {
+ TableOrdinal: stringLookupIconMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ stringValueLookupIconMap)
+ TableAllColumns: stringLookupIconMap.put('''?«axis.axis.literal»''', stringValueLookupIconMap)
+ TableMeasure: stringLookupIconMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupIconMap)
+ TableDerived: stringLookupIconMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupIconMap)
+ TableHierarchy: stringLookupIconMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupIconMap)
+ TableProperty: stringLookupIconMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', stringValueLookupIconMap)
+ TableAggregation: stringLookupIconMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ stringValueLookupIconMap)
+ TableColumn: stringLookupIconMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupIconMap)
+ }
+ }
+ if (dateValueLookupIconMap.size > 0) {
+ switch value.column {
+ TableOrdinal: dateLookupIconMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ dateValueLookupIconMap)
+ TableAllColumns: dateLookupIconMap.put('''?«axis.axis.literal»''', dateValueLookupIconMap)
+ TableMeasure: dateLookupIconMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupIconMap)
+ TableDerived: dateLookupIconMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupIconMap)
+ TableHierarchy: dateLookupIconMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupIconMap)
+ TableProperty: dateLookupIconMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupIconMap)
+ TableAggregation: dateLookupIconMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''', dateValueLookupIconMap)
+ TableColumn: dateLookupIconMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupIconMap)
+ }
+ }
+
+ // create tooltip lookup map
+ var numberValueLookupTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ var stringValueLookupTooltipMap = <String, Map<String, String>>newHashMap()
+ var dateValueLookupTooltipMap = <Double, Map<String, String>>newTreeMap(new DoubleComparator())
+ for (lookup : value.lookups) {
+ if (lookup instanceof TableNumberLookup/* && (lookup.discrete instanceof TableTextColor || lookup.discrete instanceof TableCellColor || lookup.discrete instanceof TableIcon)*/) {
+ var key = new Double((lookup as TableNumberLookup).lookupValue)
+ var tooltipAspect = ""
+ var Map<String, String> tMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»'''
+ }
+ if (tooltipAspect.length > 0) {
+ tMap.put("tooltip", tooltipAspect)
+ numberValueLookupTooltipMap.put(key, tMap)
+ }
+ }
+ if (lookup instanceof TableStringLookup) {
+ var key = (lookup as TableStringLookup).lookupValue
+ var tooltipAspect = ""
+ var Map<String, String> tMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»'''
+ }
+ if (tooltipAspect.length > 0) {
+ tMap.put("tooltip", tooltipAspect)
+ stringValueLookupTooltipMap.put(key, tMap)
+ }
+ }
+ if (lookup instanceof TableDateDayLookup) {
+ var key = new Double((lookup as TableDateDayLookup).lookupValue)
+ var tooltipAspect = ""
+ var Map<String, String> tMap = <String, String>newHashMap
+ switch lookup.discrete {
+ TableTooltip: tooltipAspect = '''«(lookup.discrete as TableTooltip).tooltip»'''
+ }
+ if (tooltipAspect.length > 0) {
+ tMap.put("tooltip", tooltipAspect)
+ dateValueLookupTooltipMap.put(key, tMap)
+ }
+ }
+ }
+ if (numberValueLookupTooltipMap.size > 0) {
+ switch value.column {
+ TableOrdinal: numberLookupTooltipMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ numberValueLookupTooltipMap)
+ TableAllColumns: numberLookupTooltipMap.put('''?«axis.axis.literal»''',
+ numberValueLookupTooltipMap)
+ TableMeasure: numberLookupTooltipMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', numberValueLookupTooltipMap)
+ TableDerived: numberLookupTooltipMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', numberValueLookupTooltipMap)
+ TableHierarchy: numberLookupTooltipMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', numberValueLookupTooltipMap)
+ TableProperty: numberLookupTooltipMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''',
+ numberValueLookupTooltipMap)
+ TableAggregation: numberLookupTooltipMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ numberValueLookupTooltipMap)
+ TableColumn: numberLookupTooltipMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', numberValueLookupTooltipMap)
+ }
+ }
+ if (stringValueLookupTooltipMap.size > 0) {
+ switch value.column {
+ TableOrdinal: stringLookupTooltipMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ stringValueLookupTooltipMap)
+ TableAllColumns: stringLookupTooltipMap.put('''?«axis.axis.literal»''',
+ stringValueLookupTooltipMap)
+ TableMeasure: stringLookupTooltipMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', stringValueLookupTooltipMap)
+ TableDerived: stringLookupTooltipMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', stringValueLookupTooltipMap)
+ TableHierarchy: stringLookupTooltipMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', stringValueLookupTooltipMap)
+ TableProperty: stringLookupTooltipMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''',
+ stringValueLookupTooltipMap)
+ TableAggregation: stringLookupTooltipMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ stringValueLookupTooltipMap)
+ TableColumn: stringLookupTooltipMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', stringValueLookupTooltipMap)
+ }
+ }
+ if (dateValueLookupTooltipMap.size > 0) {
+ switch value.column {
+ TableOrdinal: dateLookupTooltipMap.put(
+ '''#«axis.axis.literal»«(value.column as TableOrdinal).valueRef.toString»''',
+ dateValueLookupTooltipMap)
+ TableAllColumns: dateLookupTooltipMap.put('''?«axis.axis.literal»''',
+ dateValueLookupTooltipMap)
+ TableMeasure: dateLookupTooltipMap.put(
+ '''«(value.column as TableMeasure).valueRef.measureRef.name»''', dateValueLookupTooltipMap)
+ TableDerived: dateLookupTooltipMap.put(
+ '''«(value.column as TableDerived).valueRef.derivedRef.name»''', dateValueLookupTooltipMap)
+ TableHierarchy: dateLookupTooltipMap.put(
+ '''«(value.column as TableHierarchy).valueRef.levelName»''', dateValueLookupTooltipMap)
+ TableProperty: dateLookupTooltipMap.put(
+ '''«(value.column as TableProperty).valueRef.getPropertyName()»''', dateValueLookupTooltipMap)
+ TableAggregation: dateLookupTooltipMap.put(
+ '''«(value.column as TableAggregation).valueRef.aggregation.name()»''',
+ dateValueLookupTooltipMap)
+ TableColumn: dateLookupTooltipMap.put(
+ '''«(value.column as TableColumn).valueRef.columnRef.literal»''', dateValueLookupTooltipMap)
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>helper method to get a property name or its alias if present of a entity's property object.</p>
+ *
+ */
+ def String propertyName(DatamartProperty property) {
+ return property.getPropertyName(null);
+ }
+
+ /**
+ * <p>helper method to get a level name of a hierarchy's level object.</p>
+ *
+ */
+ def String getLevelName(CubeLevel level) {
+ return level.name
+ }
+
+ /**
+ * <p>generate code for the pre-ordering refresh event.</p>
+ *
+ */
+ def String preOrder(TablePreorder preorder, TableAxis axis) {
+ var name = ""
+ switch (preorder.column) {
+ TableOrdinal: name = '''#«axis.axis.literal»«(preorder.column as TableOrdinal).valueRef.toString»'''
+ TableAllColumns: name = '''?«axis.axis.literal»'''
+ TableMeasure: name = '''«(preorder.column as TableMeasure).valueRef.measureRef.name»'''
+ TableDerived: name = '''«(preorder.column as TableDerived).valueRef.derivedRef.name»'''
+ TableHierarchy: name = '''«(preorder.column as TableHierarchy).valueRef.levelName»'''
+ TableProperty: name = '''«(preorder.column as TableProperty).valueRef.getPropertyName()»'''
+ TableAggregation: name = '''«(preorder.column as TableAggregation).valueRef.aggregation.name()»'''
+ TableColumn: name = '''«(preorder.column as TableColumn).valueRef.columnRef.literal»'''
+ }
+ var body = '''dataSourceContainer.setSort(table, "«name»", «preorder.ascending.booleanValue.toString»);
+ '''
+ return body
+ }
+
+ def String setup(Table table) {
+ var body = ""
+ body = '''
+ «body»
+ subscribe();
+ '''
+ var filterIdMap = <String, String>newHashMap
+ if (table.dataMartTable != null && table.dataMartTable.datamartRef != null &&
+ table.dataMartTable.datamartRef.name != null) {
+ datamartInferrer.createFilterMap(table.dataMartTable.datamartRef, filterIdMap)
+ }
+ for (filter : filterIdMap.keySet) {
+
+ // synchronize by id
+ if (filterIdMap.get(filter).contains(IDataMart.filterIdPlaceholder)) {
+ if (table.dataMartTable.datamartRef.source instanceof DatamartEntity) {
+ var entity = (table.dataMartTable.datamartRef.source as DatamartEntity).entityRef
+ for (f : entity.features) {
+ if (f instanceof LReference && !(f as LReference).toMany) {
+ body =
+ '''
+ «body»«table.setupIdEvent(
+ table.dataMartTable.datamartRef.buildTopic((f as LReference).name), filter,
+ datamartInferrer.getEntityAlias(entity), (f as LReference).name)»'''
+ }
+ }
+ }
+ }
+ // synchronize by filter
+ else {
+ body = '''«body»«table.setupEvent(filterIdMap.get(filter), filter)»'''
+ }
+ }
+ return body
+ }
+
+ // subscribe to view refresh
+ def subscribe(Table table) {
+ var subscribers = '''
+ eventBroker.subscribe(EventBrokerMsg.REFRESH_VIEW+"«table.name»Table", refreshView);
+ «IF table.dataMartTable instanceof TableDatamart && !table.tabletype.embedded && table.tabletype.toolbar != null»
+ eventBroker.subscribe(EventBrokerMsg.ACTION_BUTTON_EXECUTE_PREFIX+"«table.tabletype.toolbar.name»Action"+(String)getContext().get("«table.tabletype.toolbar.name»_TOOLBAR_ID"), dispatchAction);
+ «ENDIF»
+ '''
+ if (!table.tabletype.embedded) {
+
+ // get all entities requested in this report
+ var entites = findRequestedEntities(table)
+ for (LEntity entity : entites) {
+ subscribers = subscribers.concat(
+ '''
+ eventBroker.subscribe(EventBrokerMsg.REFRESH_VIEW+"«(entity.eContainer as LTypedPackage).name.replace('.', '/')»/«entity.
+ name»Entity", fModifiedEntityIdsListener);
+ ''')
+ }
+ }
+ return subscribers
+ }
+
+ def Set<LEntity> findRequestedEntities(Table table) {
+ var entities = new HashSet<LEntity>()
+ switch (table.tabletype) {
+ TableTable: {
+ entities.addAll(table.dataMartTable.datamartRef.findAllEntities())
+ }
+ TableGrid: {
+ // TODO gridsource roottype -> dto -> entity
+ // entities.add(table.dtoGridTable.)
+ }
+ }
+ return entities
+ }
+
+ def unsubscribe(Table table) {
+ var unsubscribers = '''
+ eventBroker.unsubscribe(refreshView);
+ «IF table.dataMartTable instanceof TableDatamart && !table.tabletype.embedded && table.tabletype.toolbar != null»
+ eventBroker.unsubscribe(dispatchAction);
+ «ENDIF»
+ «IF !table.tabletype.embedded»
+ eventBroker.unsubscribe(fModifiedEntityIdsListener);
+ «ENDIF»
+ «IF table.task»
+ taskClient.unsubscribeTaskEventNotification(this);
+ «ENDIF»
+ '''
+ return unsubscribers
+ }
+
+ // subscribe to id changes
+ def String setupIdEvent(Table table, String eventId, String filter, String entityName, String referenceName) {
+ var body = ""
+ body = '''
+ «body»
+ eventBroker.subscribe("«eventId»",
+ new org.osgi.service.event.EventHandler() {
+ @Override
+ public void handleEvent(org.osgi.service.event.Event event) {
+ final EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA);
+ filterGenerator.setId("«filter»", " where «entityName».«referenceName»='"+msg.getName()+"'");
+ «table.callDataRefreshMethod»
+ }
+ });
+ '''
+ return body
+ }
+
+ def notifyBPMNChart(Table table) {
+ '''
+ // sync bpmn view
+ if(table.getValue() == null) {
+ eventBroker.send(EventBrokerMsg.BPMNCHART_EVENT, new EventBrokerMsg(null, null));
+ }
+ else {
+ eventBroker.send(EventBrokerMsg.BPMNCHART_EVENT, new EventBrokerMsg(dataSourceContainer.getProcessId((int) table.getValue()), dataSourceContainer.getTaskName((int) table.getValue())));
+ }
+ '''
+ }
+
+ // subscribe to filter changes
+ def String setupEvent(Table table, String eventId, String filter) {
+ var body = ""
+ body = '''
+ «body»
+ eventBroker.subscribe("«eventId»",
+ new org.osgi.service.event.EventHandler() {
+ @Override
+ public void handleEvent(org.osgi.service.event.Event event) {
+ final EventBrokerMsg msg = (EventBrokerMsg)event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA);
+ «IF table.task»
+ dataSourceContainer.updateContainer(datamartClass.getResultsByTaskId(taskClient, user, msg.getLong()));
+ «ELSE»
+ filterGenerator.selectItem("«filter»", msg.getName());
+ «ENDIF»
+ }
+ });
+ eventBroker.subscribe("«eventId»/clear",
+ new org.osgi.service.event.EventHandler() {
+ @Override
+ public void handleEvent(org.osgi.service.event.Event event) {
+ «IF table.task»
+ dataSourceContainer.clearContainer();
+ «ELSE»
+ filterGenerator.resetItem("«filter»");
+ «ENDIF»
+ }
+ });
+ '''
+ return body
+ }
+
+ def String sendEvent(Table table) {
+ var body = "";
+ body = '''
+ «body»
+ table.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
+ try {
+ Object msg = null;
+ Object id = null;
+ String target = null;
+ Object value = table.getValue();
+ int selection = -1;
+ if (value instanceof Integer) {
+ selection = (Integer)value;
+ }
+ else {
+ if ((value instanceof Collection<?>) && (((Collection<?>)value).size() == 1)) {
+ value = ((Collection<?>)value).iterator().next();
+ if (value instanceof Integer) {
+ selection = (Integer)value;
+ }
+ }
+ }
+ «IF table.tabletype.embedded && table.isTask»
+ for(Button b:taskButtons) {
+ b.setEnabled(table.getValue() != null);
+ }
+ «ENDIF»
+ '''
+ if (table.tabletype instanceof TableTable) {
+ if (table.dataMartTable instanceof TableDatamart) {
+ body = '''
+ «body»
+ «IF !table.tabletype.embedded»
+ dataSourceContainer.registerSelection(getPart().getTransientData(), selection);
+ «ENDIF»
+ '''
+ switch ((table.dataMartTable as TableDatamart).datamartRef.source) {
+ DatamartTask:
+ body = '''
+ «body»
+ «IF !table.tabletype.embedded»
+ if (table.getValue() != null) {
+ getPart().getTransientData().put("taskSummary", taskClient.getUserTask(dataSourceContainer.getTaskId(selection), user));
+ }
+ else {
+ getPart().getTransientData().put("taskSummary", null);
+ }
+ «ENDIF»
+ «table.notifyBPMNChart»
+ '''
+ DatamartEntity: {
+ var datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity
+ var entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity
+ var alias = DatamartDefinitionUtil.getEntityIdAliasName(entity)
+ if(alias != null) {
+ body = '''
+ «body»
+ if (selection >= 0) {
+ id = dataSourceContainer.getStringValueByProperty(selection, "«alias.toLowerCase»");
+ }
+ if ((id != null) && (operativeDtoContainer != null) && (operativeDtoContainer.getOperativeDtoIdColumn() != null)) {
+ msg = operativeDtoContainer.getOperativeDtoForId(id);
+ }
+ if (msg == null) {
+ msg = new EventBrokerMsg((String) id, "«(((table.dataMartTable.datamartRef.source) as DatamartEntity).entityRef as EObject).fullyQualifiedName»");
+ }
+ target = EventBrokerMsg.AUTOWIRED_ENTITY_PREFIX+"«(((table.dataMartTable as TableDatamart).datamartRef.
+ source) as DatamartEntity).entityRef.name»";
+ eventBroker.send(target, msg);'''
+ }
+ }
+ }
+ }
+ }
+ for (element : table.dataMartTable.elements) {
+ if (element instanceof TableAxis) {
+ var axis = element as TableAxis
+ for (event : axis.events) {
+ for (datamart : event.brokerDatamarts) {
+ if (datamart.filter != null) {
+ body = '''
+ «body»
+ if(selection<0) {
+ target = "«datamart.filter»/clear";
+ msg = new EventBrokerMsg(null, "*");
+ eventBroker.send(target, msg);
+ }
+ else {
+ '''
+ } else if (datamart.reference != null) {
+ body = '''
+ «body»
+ if(selection<0) {
+ target = "«datamart.datamartDef.buildTopic(datamart.reference.name)»/clear";
+ msg = new EventBrokerMsg(null, "*");
+ eventBroker.send(target, msg);
+ }
+ else {
+ '''
+ }
+ if (event.source instanceof TableOrdinal) {
+ body = '''
+ «body»
+ target = "«datamart.filter»";
+ msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByOrdinal(selection, «(event.
+ source as TableOrdinal).valueRef»));
+ eventBroker.send(target, msg);
+ }
+ '''
+ }
+ else if (event.source instanceof TableAggregation) {
+ body = '''
+ «body»
+ target = "«datamart.filter»";
+ msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByAggregate(selection));
+ eventBroker.send(target, msg);
+ }
+ '''
+ } else if (event.source instanceof TableProperty) {
+ if (datamart.filter != null) {
+ body = '''
+ «body»
+ target = "«datamart.filter»";
+ msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByProperty(selection, "«(event.
+ source as TableProperty).valueRef.propertyRef.name»"));
+ eventBroker.send(target, msg);
+ }
+ '''
+ } else if (datamart.reference != null) {
+ body = '''
+ «body»
+ target = "«datamart.datamartDef.buildTopic(datamart.reference.name)»";
+ msg = new EventBrokerMsg(null, dataSourceContainer.getStringValueByProperty(selection, "«(event.
+ source as TableProperty).valueRef.propertyRef.name»"));
+ eventBroker.send(target, msg);
+ }
+ '''
+ }
+ } else if (event.source instanceof TableTask) {
+ body = '''
+ «body»
+ target = "«datamart.filter»";
+ msg = new EventBrokerMsg(null, null, dataSourceContainer.getTaskId(selection));
+ eventBroker.send(target, msg);
+ }
+ '''
+ }
+
+ }
+
+ }
+ }
+ }
+ body = '''
+ «body»
+ } catch (Exception e) {
+ Notification.show("sendEvent() caused "+e.getLocalizedMessage()+"!",
+ Type.ERROR_MESSAGE);
+ }
+ }
+ });
+ '''
+ return body
+ }
+
+ def getMsgValue(LEntityAttribute attribute, String string) '''«CONVERT_METHOD_PREFIX»«attribute.typeName.
+ toFirstUpper»(«string»)'''
+
+ def String buildTopic(DatamartDefinition datamart, String referenceName) {
+ var topic = ""
+ if (datamart.source instanceof DatamartEntity) {
+ var entity = (datamart.source as DatamartEntity).entityRef
+ var eObj = datamart.eContainer
+ while (!(eObj instanceof DatamartPackage)) {
+ eObj = eObj.eContainer
+ }
+ if (eObj != null) {
+ var pckName = (eObj as DatamartPackage).fullyQualifiedName.toString.replace(".", "/")
+ topic = pckName.concat("/").concat(datamart.name).concat("/").concat(entity.name).concat("/").
+ concat(referenceName)
+ }
+ }
+ return topic
+ }
+
+ /**
+ * <p>helper method to convert a rgb string to a hex string.</p>
+ *
+ */
+ def StringtoHex(String rgb) {
+ var colorHex = "#"
+ for (color : rgb.split(",")) {
+ var i = new Integer(color);
+ colorHex = '''«colorHex»«String.format("%02x", i)»'''
+ }
+ return colorHex
+ }
+
+ /**
+ * <p>helper method to convert a rgb string to a rgb syntax.</p>
+ *
+ */
+ def String toRGB(String rgb) {
+ return '''rgb(«rgb»)'''
+ }
+
+ def void initIdMap(Table table, HashMap<String, IdProperty> map) {
+ map.clear
+ if (table.dataMartTable instanceof TableDatamart) {
+ var datamart = (table.dataMartTable as TableDatamart).datamartRef
+ if (datamart.source instanceof DatamartEntity) {
+ var entity = datamart.source as DatamartEntity
+ entity.iterateIdMap(map)
+ }
+ }
+ }
+
+ def void iterateIdMap(DatamartEntity entity, HashMap<String, IdProperty> map) {
+ var prop = new IdProperty()
+ prop.collapsed = true
+ map.put(DatamartDefinitionUtil.getEntityIdAliasName(entity.entityRef), prop)
+ for (navigation : entity.navigations) {
+ navigation.datamartEntity.iterateIdMap(map)
+ }
+ }
+
+ def getEntity(TableBrokerDatamart datamart) {
+ if (datamart.datamartDef.source instanceof DatamartEntity) {
+ return (datamart.datamartDef.source as DatamartEntity).entityRef
+ }
+ return null
+ }
+
+ def localeChanged(Table table)
+ '''
+ this.locale = locale;
+ if(tableFilterDecorator != null) {
+ tableFilterDecorator.setLocale(locale);
+ }
+ for(CellSetFilterTable table:tables) {
+ table.setLocale(locale);
+ «IF table.tabletype instanceof TableTable &&
+ (table.dataMartTable as TableDatamart).datamartRef.description &&
+ (table.dataMartTable as TableDatamart).datamartRef.descriptionValue != null»
+ table.setDescription(dslMetadataService.translate(locale.toLanguageTag(), "«(table.dataMartTable as TableDatamart).datamartRef.descriptionValue»"));
+ «ENDIF»
+ }
+ if(filterGenerator != null) {
+ filterGenerator.setLocale(locale);
+ }
+ if(dataSourceContainer != null) {
+ dataSourceContainer.setLocale(locale);
+ }
+ if(layoutManager != null) {
+ layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), "«table.name»"));
+ }
+ '''
+
+ def selectItemsFromWorkloadDto(Table table) {
+ var datamartEntity = null as DatamartEntity
+ var entity = null as LEntity
+ var alias = null as String
+ var dtoFqn = null as String
+ if (table.dataMartTable instanceof TableDatamart) {
+ switch ((table.dataMartTable as TableDatamart).datamartRef.source) {
+ DatamartEntity: {
+ datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity
+ entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity
+ alias = DatamartDefinitionUtil.getEntityIdAliasName(entity).toLowerCase
+ dtoFqn = EntityUtils.getDtoFQNForLEntity(entity)
+ }
+ }
+ }
+ '''
+ IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO);
+ TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY);
+ IDto workloadDto = taskClient.getWorkloadDto(taskSummary);
+ List<IDto> operativeDtos = task.getOperativeDtos(workloadDto);
+ if (operativeDtos != null) {
+ Set<String> ids = new TreeSet<String>();
+ for (IDto operativeDto : operativeDtos) {
+ ids.add(String.valueOf(((«dtoFqn»)operativeDto).getId()));
+ }
+ for (Object selection : dataSourceContainer.getAllItemIds()) {
+ String idValue = dataSourceContainer.getStringValueByProperty((Integer)selection,"«alias»");
+ if (idValue.endsWith(".0")) {
+ idValue = idValue.substring(0, idValue.length()-2);
+ }
+ if (ids.contains(idValue)) {
+ selectTable.setCheckBox(selection, true);
+ }
+ }
+ }
+ '''
+ }
+
+ def addAllItemsToWorkloadDto(Table table) {
+ '''
+ IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO);
+ TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY);
+ IDto workloadDto = taskClient.getWorkloadDto(taskSummary);
+ if ((taskClient != null) && (task != null) && (workloadDto != null)) {
+ Object values = selectTable.getValue();
+ for (Object selection : dataSourceContainer.getAllItemIds()) {
+ boolean selected = false;
+ if (values instanceof Integer) {
+ selected = (values == selection);
+ }
+ else {
+ if ((values instanceof Collection<?>) && !((Collection<?>)values).isEmpty()) {
+ selected = ((Collection<?>)values).contains(selection);
+ }
+ }
+ addOrRemoveItemToWorkloadDto(task, workloadDto, (Integer)selection, selected);
+ }
+ taskClient.setWorkloadDto(taskSummary, workloadDto);
+ }
+ '''
+ }
+
+ def addOrRemoveItemToWorkloadDto(Table table) {
+ var datamartEntity = null as DatamartEntity
+ var entity = null as LEntity
+ var alias = null as String
+ var dtoFqn = null as String
+ if (table.dataMartTable instanceof TableDatamart) {
+ switch ((table.dataMartTable as TableDatamart).datamartRef.source) {
+ DatamartEntity: {
+ datamartEntity = ((table.dataMartTable as TableDatamart).datamartRef.source) as DatamartEntity
+ entity = EcoreUtil2.resolve(datamartEntity.entityRef, table.eResource) as LEntity
+ alias = DatamartDefinitionUtil.getEntityIdAliasName(entity).toLowerCase
+ dtoFqn = EntityUtils.getDtoFQNForLEntity(entity)
+ }
+ }
+ }
+ '''
+ IDto operativeDto = null;
+ String idValue = null;
+ try {
+ idValue = dataSourceContainer.getStringValueByProperty(selection,"«alias»");
+ IDTOServiceWithMutablePersistence<«dtoFqn»> dtoService = (IDTOServiceWithMutablePersistence<«dtoFqn»>) DtoServiceAccess
+ .getService(«dtoFqn».class);
+ operativeDto = dtoService.get((int) Double.parseDouble(idValue));
+ }
+ catch (Exception e) {
+ log.error("try to retrive the dto", e);
+ }
+ if (operativeDto == null) {
+ log.warn("«dtoFqn» for selection="+selection+" «alias»='"+idValue+"' could not be found!");
+ }
+ else {
+ try {
+ if (selected) {
+ task.addOperativeDto(workloadDto, operativeDto);
+ }
+ else {
+ task.removeOperativeDto(workloadDto, operativeDto);
+ }
+ }
+ catch (Exception e) {
+ log.error("try to add/remove operative dto", e);
+ }
+ }
+ '''
+ }
+
+ def removeAllItemsFromWorkloadDto(Table table) {
+ '''
+ IBlipBPMWorkloadModifiableItem task = (IBlipBPMWorkloadModifiableItem)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_START_INFO);
+ TaskSummary taskSummary = (TaskSummary)getTransientDataVariable(IBlipBPMConstants.VARIABLE_TASK_JBPM_SUMMARY);
+ IDto workloadDto = taskClient.getWorkloadDto(taskSummary);
+ if ((taskClient != null) && (task != null) && (workloadDto != null)) {
+ task.removeAllOperativeDtos(workloadDto);
+ }
+ '''
+ }
+}
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
new file mode 100644
index 0000000..0080227
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
@@ -0,0 +1,250 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.jvmmodel
+
+import com.vaadin.data.Container
+import com.vaadin.data.Property.ValueChangeListener
+import com.vaadin.server.Page
+import com.vaadin.server.Page.Styles
+import com.vaadin.shared.ui.label.ContentMode
+import com.vaadin.ui.Button
+import com.vaadin.ui.Button.ClickEvent
+import com.vaadin.ui.CustomTable
+import com.vaadin.ui.CustomTable.Align
+import com.vaadin.ui.CustomTable.RowHeaderMode
+import com.vaadin.ui.HorizontalLayout
+import com.vaadin.ui.Label
+import com.vaadin.ui.Notification
+import com.vaadin.ui.Notification.Type
+import com.vaadin.ui.TabSheet
+import com.vaadin.ui.UI
+import java.util.ArrayList
+import java.util.Collection
+import java.util.Date
+import java.util.HashMap
+import java.util.Iterator
+import java.util.List
+import java.util.Locale
+import java.util.Map
+import java.util.Set
+import java.util.TreeSet
+import java.util.UUID
+import java.util.concurrent.Executors
+import java.util.concurrent.TimeUnit
+import javax.inject.Inject
+import org.drools.SystemEventListenerFactory
+import org.drools.event.process.ProcessCompletedEvent
+import org.eclipse.bpmn2.Task
+import org.eclipse.e4.core.contexts.ContextInjectionFactory
+import org.eclipse.e4.core.di.extensions.EventUtils
+import org.eclipse.e4.core.services.events.IEventBroker
+import org.eclipse.e4.ui.model.application.MApplication
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.resource.Resource
+import org.eclipse.osbp.bpm.api.AbstractBlipBPMFunctionProvider
+import org.eclipse.osbp.bpm.api.IBlipBPMConstants
+import org.eclipse.osbp.bpm.api.IBlipBPMStartInfo
+import org.eclipse.osbp.bpm.api.IBlipBPMWorkloadModifiableItem
+import org.eclipse.osbp.dsl.common.datatypes.IDto
+import org.eclipse.osbp.dsl.dto.lib.impl.DtoServiceAccess
+import org.eclipse.osbp.dsl.dto.lib.services.IDTOServiceWithMutablePersistence
+import org.eclipse.osbp.eventbroker.EventBrokerMsg
+import org.eclipse.osbp.preferences.ProductConfiguration
+import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider
+import org.eclipse.osbp.ui.api.datamart.DerivedOlapException
+import org.eclipse.osbp.ui.api.themes.IThemeResourceService
+import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType
+import org.eclipse.osbp.utils.constants.ExtendedDate
+import org.eclipse.osbp.utils.vaadin.SelectUserWindow
+import org.eclipse.osbp.utils.vaadin.ViewLayoutManager
+import org.eclipse.osbp.xtext.basic.generator.BasicDslGeneratorUtils
+import org.eclipse.osbp.xtext.blip.BlipItem
+import org.eclipse.osbp.xtext.datamart.common.AEntityDatamart
+import org.eclipse.osbp.xtext.datamart.common.DatamartFilterGenerator
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedAxis
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedHierarchy
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedLevel
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedMember
+import org.eclipse.osbp.xtext.datamart.common.olap.DerivedPosition
+import org.eclipse.osbp.xtext.datamart.common.sql.OperativeDtoContainer
+import org.eclipse.osbp.xtext.i18n.I18NModelGenerator
+import org.eclipse.osbp.xtext.table.common.CellSetFilterTable
+import org.eclipse.osbp.xtext.table.common.CellSetIndexedContainer
+import org.eclipse.osbp.xtext.table.common.CellSetPagedFilterTable
+import org.eclipse.osbp.xtext.table.common.CheckboxSelectionCellSetFilterTable
+import org.eclipse.osbp.xtext.table.common.TableFilterDecorator
+import org.eclipse.osbp.xtext.table.common.TableFilterGenerator
+import org.eclipse.osbp.xtext.table.generator.TableGridSourceGenerator
+import org.eclipse.xtext.generator.IFileSystemAccess
+import org.eclipse.xtext.xbase.compiler.GeneratorConfig
+import org.eclipse.xtext.xbase.compiler.ImportManager
+import org.jbpm.task.Status
+import org.jbpm.task.event.TaskEventListener
+import org.jbpm.task.event.entity.TaskUserEvent
+import org.jbpm.task.query.TaskSummary
+import org.jbpm.task.service.Operation
+import org.jbpm.task.service.PermissionDeniedException
+import org.jbpm.task.service.mina.MinaTaskClientConnector
+import org.jbpm.task.service.mina.MinaTaskClientHandler
+import org.osgi.service.event.Event
+import org.osgi.service.event.EventHandler
+import org.vaadin.hene.popupbutton.PopupButton
+
+class TableModelGenerator extends I18NModelGenerator {
+ @Inject TableGridSourceGenerator delegate
+ @Inject extension BasicDslGeneratorUtils
+
+ override createAppendable(EObject context, ImportManager importManager, GeneratorConfig config) {
+ // required to initialize the needed builder to avoid deprecated methods
+ builder = context.eResource
+ // ---------
+ importManager.addImportFor(
+ _typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(String)).
+ type)
+ importManager.addImportFor(
+ _typeReferenceBuilder.typeRef(Map, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(String)).type)
+ importManager.addImportFor(_typeReferenceBuilder.typeRef(Collection, _typeReferenceBuilder.typeRef(String)).type)
+ addImportFor(importManager, _typeReferenceBuilder
+ , ValueChangeListener
+ , Label
+ , List
+ , Set
+ , TreeSet
+ , Iterator
+ , ArrayList
+ , Page
+ , Styles
+ , DerivedAxis
+ , DerivedPosition
+ , DerivedMember
+ , HorizontalLayout
+ , TabSheet
+ , Notification
+ , ClickEvent
+ , Button
+ , Type
+ , Align
+ , OperativeDtoContainer
+ , DerivedHierarchy
+ , DerivedLevel
+ , DerivedOlapException
+ , IEventBroker
+ , PopupButton
+ , CellSetFilterTable
+ , CellSetPagedFilterTable
+ , CheckboxSelectionCellSetFilterTable
+ , CustomTable
+ , RowHeaderMode
+ , Container
+ , CellSetIndexedContainer
+ , TableFilterDecorator
+ , TableFilterGenerator
+ , Date
+ , ExtendedDate
+ , TimeUnit
+ , EventHandler
+ , Event
+ , EventUtils
+ , ContentMode
+ , EventBrokerMsg
+ , Status
+ , Operation
+ , Executors
+ , TaskSummary
+ , TaskEventListener
+ , TaskUserEvent
+ , ProcessCompletedEvent
+ , PermissionDeniedException
+ , SelectUserWindow
+ , MinaTaskClientConnector
+ , MinaTaskClientHandler
+ , SystemEventListenerFactory
+ , UUID
+ , ProductConfiguration
+ , AEntityDatamart
+ , IViewEmbeddedProvider
+ , MApplication
+ , ContextInjectionFactory
+ , UI
+ , Locale
+ , IThemeResourceService
+ , ThemeResourceType
+ , AbstractBlipBPMFunctionProvider
+ , IBlipBPMConstants
+ , IBlipBPMStartInfo
+ , IBlipBPMWorkloadModifiableItem
+ , IDto
+ , Task
+ , BlipItem
+ , IDTOServiceWithMutablePersistence
+ , DtoServiceAccess
+ , DatamartFilterGenerator
+ , ViewLayoutManager
+ )
+ super.createAppendable(context, importManager, config)
+ }
+
+ override doGenerate(Resource resource, IFileSystemAccess fsa) {
+ // i18n
+ super.addTranslatables("save,cancel,securityMessage,Page,Items per page,showAll,endDate,startDate,setFilter,clearFilter,lesser_than,greater_than,equal_to,ok,reset,[x]")
+ try {
+ super.doGenerate(resource, fsa)
+ }
+ catch (Throwable e) {
+ System.err.println(e);
+ }
+
+ delegate.doGenerate(resource, fsa)
+
+ // val filename = resource.URI.lastSegment
+ // for (dm : resource.contents.filter(typeof(CCTableModel))) {
+ // val plantUML = dm.toPlantUML.toString
+ // if (fsa instanceof IFileSystemAccessExtension3) {
+ // val out = new ByteArrayOutputStream()
+ // new SourceStringReader(plantUML).generateImage(out)
+ // (fsa as IFileSystemAccessExtension3).generateFile(filename + ".png",
+ // new ByteArrayInputStream(out.toByteArray))
+ // } else {
+ // fsa.generateFile(filename + ".txt", plantUML)
+ // }
+ // }
+ }
+
+// def dispatch CharSequence toPlantUML(CCTableModel it) '''
+// @startuml
+// «FOR pkg: packages»
+// «FOR table : pkg.tables»
+// «table.toPlantUML»
+// «ENDFOR»
+// «ENDFOR»
+// @enduml
+// '''
+//
+// def dispatch CharSequence toPlantUML(CCTable it) '''
+// class «name»Table {
+// «IF description»«descriptionValue»«ENDIF»
+// «IF polling»polling every «pollingTime» seconds«ENDIF»
+// }
+//
+// class «(source as CCTableDatamart).datamartRef.name»Class {
+// Datamart
+// }
+// «name»Table -- «(source as CCTableDatamart).datamartRef.name»Class : using
+//
+// '''
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/scoping/TableDSLScopeProvider.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/scoping/TableDSLScopeProvider.xtend
new file mode 100644
index 0000000..4e5a9cc
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/scoping/TableDSLScopeProvider.xtend
@@ -0,0 +1,424 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.scoping
+
+import java.util.ArrayList
+import javax.inject.Inject
+import org.eclipse.emf.ecore.EObject
+import org.eclipse.emf.ecore.EReference
+import org.eclipse.osbp.dsl.common.xtext.extensions.ModelExtensions
+import org.eclipse.osbp.dsl.entity.xtext.extensions.EntityTypesBuilder
+import org.eclipse.osbp.dsl.semantic.common.types.LReference
+import org.eclipse.osbp.infogrid.model.gridsource.CxGridSourcePackage
+import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridStylePackage
+import org.eclipse.osbp.xtext.cubedsl.CubeDimensionEntity
+import org.eclipse.osbp.xtext.cubedsl.CubeHierarchy
+import org.eclipse.osbp.xtext.cubedsl.CubeLevel
+import org.eclipse.osbp.xtext.datamartdsl.AxisEnum
+import org.eclipse.osbp.xtext.datamartdsl.DatamartAxis
+import org.eclipse.osbp.xtext.datamartdsl.DatamartCube
+import org.eclipse.osbp.xtext.datamartdsl.DatamartDerivedMeasure
+import org.eclipse.osbp.xtext.datamartdsl.DatamartEntity
+import org.eclipse.osbp.xtext.datamartdsl.DatamartHierarchy
+import org.eclipse.osbp.xtext.datamartdsl.DatamartMeasure
+import org.eclipse.osbp.xtext.datamartdsl.DatamartMember
+import org.eclipse.osbp.xtext.datamartdsl.DatamartOwner
+import org.eclipse.osbp.xtext.datamartdsl.DatamartProperty
+import org.eclipse.osbp.xtext.datamartdsl.DatamartSetAggregation
+import org.eclipse.osbp.xtext.datamartdsl.DatamartSetAggregationFunction
+import org.eclipse.osbp.xtext.datamartdsl.DatamartTask
+import org.eclipse.osbp.xtext.datamartdsl.jvmmodel.DatamartDSLJvmModelInferrer
+import org.eclipse.osbp.xtext.datamartdsl.scoping.DatamartDSLScopeProvider
+import org.eclipse.osbp.xtext.gridsource.scoping.GridSourceScopeProvider
+import org.eclipse.osbp.xtext.table.TableAxis
+import org.eclipse.osbp.xtext.table.TableBrokerDatamart
+import org.eclipse.osbp.xtext.table.TableDSLPackage
+import org.eclipse.osbp.xtext.table.TableDatamart
+import org.eclipse.xtext.resource.EObjectDescription
+import org.eclipse.xtext.resource.IEObjectDescription
+import org.eclipse.xtext.scoping.IScope
+import org.eclipse.xtext.scoping.impl.MapBasedScope
+import org.eclipse.xtext.xbase.annotations.typesystem.XbaseWithAnnotationsBatchScopeProvider
+
+class TableScopeProvider extends XbaseWithAnnotationsBatchScopeProvider {
+ @Inject extension ModelExtensions
+ @Inject extension EntityTypesBuilder
+ @Inject extension DatamartDSLScopeProvider datamartScopeProvider
+ @Inject extension DatamartDSLJvmModelInferrer datamartInferrer
+ @Inject GridSourceScopeProvider gridScopeProvider
+
+ @Override
+ override IScope getScope(EObject context, EReference reference) {
+
+ // if context is part of the grid source semantic model
+ if (context.eClass.EPackage == CxGridSourcePackage.eINSTANCE ||
+ context.eClass.EPackage == CxGridStylePackage.eINSTANCE) {
+ return gridScopeProvider.getScope(context, reference)
+ }
+
+ if (reference == TableDSLPackage.Literals.TABLE_AXIS__AXIS) {
+ return getScope_Table_Axis_axis(context)
+ } else if (reference == TableDSLPackage.Literals.TABLE_MEASURE__VALUE_REF ||
+ reference == TableDSLPackage.Literals.TABLE_DERIVED__VALUE_REF ||
+ reference == TableDSLPackage.Literals.TABLE_PROPERTY__VALUE_REF ||
+ reference == TableDSLPackage.Literals.TABLE_COLUMN__VALUE_REF ||
+ reference == TableDSLPackage.Literals.TABLE_HIERARCHY__VALUE_REF) {
+ return getScope_Table_valueRef(context, reference)
+ } else if (reference == TableDSLPackage.Literals.TABLE_AGGREGATION__VALUE_REF) {
+ return getScope_Table_Aggregation_valueRef(context)
+ } else if (reference == TableDSLPackage.Literals.TABLE_BROKER_DATAMART__REFERENCE) {
+ return getScope_Table_Broker_reference(context)
+ } else {
+ return super.getScope(context, reference)
+ }
+ }
+
+ def getScope_Table_Broker_reference(EObject object) {
+ var result = <IEObjectDescription>newArrayList
+ if (object instanceof TableBrokerDatamart) {
+ var datamart = (object as TableBrokerDatamart).datamartDef
+ if (datamart.source instanceof DatamartEntity) {
+ var entity = (datamart.source as DatamartEntity).entityRef
+ for (f : entity.features) {
+ if (f instanceof LReference && !(f as LReference).toMany) {
+ result.add(EObjectDescription.create((f as LReference).name, (f as LReference)))
+ }
+ }
+ }
+ }
+ return MapBasedScope.createScope(IScope.NULLSCOPE, result)
+ }
+
+ def IScope getScope_Table_Axis_axis(EObject object) {
+ var result = <IEObjectDescription>newArrayList
+ var eObj = object
+ while (!(eObj instanceof TableDatamart)) {
+ eObj = eObj.eContainer
+ }
+ if (eObj != null) {
+ var datamart = (eObj as TableDatamart).datamartRef
+ if (datamart != null && datamart.source != null) {
+ if (datamart.source instanceof DatamartCube) {
+ for (axis : (datamart.source as DatamartCube).axisslicer) {
+ if (axis instanceof DatamartAxis) {
+ var literal = (axis as DatamartAxis).name.literal
+ result.add(EObjectDescription.create(literal, (axis as DatamartAxis)))
+ }
+ }
+ } else if (datamart.source instanceof DatamartEntity) {
+ getEntityAxes(datamart.source as DatamartEntity, result)
+
+ // user must not supply any axes, but we need it with tables
+ if (!result.containsName(AxisEnum.COLUMNS.literal)) {
+ result.add(
+ EObjectDescription.create(AxisEnum.COLUMNS.literal, (datamart.source as DatamartEntity)))
+ }
+ if (!result.containsName(AxisEnum.ROWS.literal)) {
+ result.add(
+ EObjectDescription.create(AxisEnum.ROWS.literal, (datamart.source as DatamartEntity)))
+ }
+ } else if (datamart.source instanceof DatamartTask) {
+ result.add(EObjectDescription.create(AxisEnum.COLUMNS.literal, (datamart.source as DatamartTask)))
+ result.add(EObjectDescription.create(AxisEnum.ROWS.literal, (datamart.source as DatamartTask)))
+ }
+ }
+ }
+ return MapBasedScope.createScope(IScope.NULLSCOPE, result)
+ }
+
+ def void getEntityAxes(DatamartEntity entity, ArrayList<IEObjectDescription> result) {
+ for (navigation : entity.navigations) {
+ if (navigation instanceof DatamartMember) {
+ (navigation as DatamartMember).datamartEntity.getEntityAxes(result)
+ for (property : (navigation as DatamartMember).datamartEntity.properties) {
+ if (!result.containsName(property.axis.literal)) {
+ result.add(EObjectDescription.create(property.axis.literal, property as DatamartAxis))
+ }
+ }
+ }
+ if (navigation instanceof DatamartOwner) {
+ (navigation as DatamartOwner).datamartEntity.getEntityAxes(result)
+ for (property : (navigation as DatamartOwner).datamartEntity.properties) {
+ if (!result.containsName(property.axis.literal)) {
+ result.add(EObjectDescription.create(property.axis.literal, property as DatamartAxis))
+ }
+ }
+ }
+ }
+ for (property : entity.properties) {
+ if (property.axis != null) {
+ if (!result.containsName(property.axis.literal)) {
+ result.add(EObjectDescription.create(property.axis.literal, property as DatamartAxis))
+ }
+ } else {
+ if (!result.containsName(property.axis.literal)) {
+ result.add(EObjectDescription.create(property.axis.literal, property as DatamartAxis))
+ }
+ }
+ }
+ }
+
+ def boolean containsName(ArrayList<IEObjectDescription> list, String name) {
+ for (obj : list) {
+ var oname = obj.name.toString
+ if (oname.equals(name)) {
+ return true
+ }
+ }
+ return false
+ }
+
+ def void getEntityProperties(DatamartEntity entity, ArrayList<IEObjectDescription> result,
+ String requestedAxisName) {
+ for (navigation : entity.navigations) {
+ if (navigation instanceof DatamartMember) {
+ (navigation as DatamartMember).datamartEntity.getEntityProperties(result, requestedAxisName)
+ for (property : (navigation as DatamartMember).datamartEntity.properties) {
+ if (property.axis.literal.equals(requestedAxisName)) {
+ result.add(
+ EObjectDescription.create(datamartInferrer.getPropertyName(property),
+ property as DatamartProperty))
+ }
+ }
+ }
+ if (navigation instanceof DatamartOwner) {
+ (navigation as DatamartOwner).datamartEntity.getEntityProperties(result, requestedAxisName)
+ for (property : (navigation as DatamartOwner).datamartEntity.properties) {
+ if (property.axis.literal.equals(requestedAxisName)) {
+ result.add(
+ EObjectDescription.create(datamartInferrer.getPropertyName(property),
+ property as DatamartProperty))
+ }
+ }
+ }
+ }
+ for (property : entity.properties) {
+ if (property.axis != null) {
+ if (property.axis.literal.equals(requestedAxisName)) {
+ result.add(
+ EObjectDescription.create(datamartInferrer.getPropertyName(property),
+ property as DatamartProperty))
+ }
+ } else {
+ result.add(
+ EObjectDescription.create(datamartInferrer.getPropertyName(property),
+ property as DatamartProperty))
+
+ }
+ }
+ }
+
+ def void getTaskColumns(DatamartTask task, ArrayList<IEObjectDescription> result, String requestedAxisName) {
+ for (column : task.columns) {
+ if (AxisEnum.COLUMNS.literal.equals(requestedAxisName)) {
+ result.add(EObjectDescription.create(column.columnRef.literal, column))
+ }
+ }
+ }
+
+ def IScope getScope_Table_valueRef(EObject object, EReference reference) {
+ var result = <IEObjectDescription>newArrayList
+ var eObj = object
+ var requestedAxisName = ""
+ while (!(eObj instanceof TableDatamart)) {
+ eObj = eObj.eContainer
+ if (eObj instanceof TableAxis) {
+ requestedAxisName = (eObj as TableAxis).axis.literal
+ }
+ }
+ if (eObj != null) {
+ var datamart = (eObj as TableDatamart).datamartRef
+ if (datamart != null && datamart.source != null) {
+ if (datamart.source instanceof DatamartCube) {
+ for (axis : (datamart.source as DatamartCube).axisslicer) {
+ if (axis instanceof DatamartAxis) {
+ if ((axis as DatamartAxis).name.literal.equals(requestedAxisName)) {
+ var hasMeasures = false
+ var hasHierarchy = false
+ var hasAggregation = false
+ var isCrossjoined = false
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartMeasure ||
+ element instanceof DatamartDerivedMeasure) {
+ hasMeasures = true
+ }
+ }
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartHierarchy) {
+ if (hasHierarchy) {
+ isCrossjoined = true
+ } else {
+ hasHierarchy = true
+ }
+ }
+ if (element instanceof DatamartSetAggregation) {
+ if (hasAggregation) {
+ isCrossjoined = true
+ } else {
+ hasAggregation = true
+ }
+ hasAggregation = true
+ }
+ }
+ if (hasMeasures && (hasHierarchy || hasAggregation)) {
+ isCrossjoined = true
+ }
+ if (/*!isCrossjoined*/1 == 1) {
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartMeasure &&
+ reference == TableDSLPackage.Literals.TABLE_MEASURE__VALUE_REF) {
+ if ((element as DatamartMeasure).measureRef != null) {
+ result.add(
+ EObjectDescription.create(
+ (element as DatamartMeasure).measureRef.name,
+ element))
+ }
+ }
+ if (element instanceof DatamartDerivedMeasure &&
+ reference == TableDSLPackage.Literals.TABLE_DERIVED__VALUE_REF) {
+ if ((element as DatamartDerivedMeasure).derivedRef != null) {
+ result.add(
+ EObjectDescription.create(
+ (element as DatamartDerivedMeasure).derivedRef.name,
+ element))
+ }
+ }
+ if (element instanceof DatamartHierarchy && !hasMeasures &&
+ reference == TableDSLPackage.Literals.TABLE_HIERARCHY__VALUE_REF) {
+ if ((element as DatamartHierarchy).hierarchyRef != null) {
+ var hierarchy = element as DatamartHierarchy
+ if (hierarchy.levelRef != null) {
+ if (hierarchy.all) { // detailed was modeled - we must add the complete hierarchy
+ var dimEntity = (hierarchy.levelRef as CubeLevel).eContainer as CubeDimensionEntity
+ for (cubeLevel : dimEntity.hierarchLevels) {
+ result.add(
+ EObjectDescription.create(cubeLevel.name,
+ cubeLevel))
+ }
+ } else {
+ result.add(
+ EObjectDescription.create(hierarchy.levelRef.name,
+ (hierarchy.levelRef as CubeLevel)))
+ }
+
+ } else if ((hierarchy.hierarchyRef as CubeHierarchy).allMemberName) {
+ result.add(
+ EObjectDescription.create(
+ (hierarchy.hierarchyRef as CubeHierarchy).
+ allMemberNameValue.toString,
+ (hierarchy.hierarchyRef as CubeHierarchy)))
+ } else if ((hierarchy.defaultMember)) {
+ result.add(
+ EObjectDescription.create(
+ (hierarchy.hierarchyRef as CubeHierarchy).
+ defaultMemberValue.toString,
+ (hierarchy.hierarchyRef as CubeHierarchy)))
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } else if (datamart.source instanceof DatamartEntity) {
+ getEntityProperties(datamart.source as DatamartEntity, result, requestedAxisName)
+ } else if (datamart.source instanceof DatamartTask) {
+ getTaskColumns(datamart.source as DatamartTask, result, requestedAxisName)
+ }
+ }
+
+ }
+ return MapBasedScope.createScope(IScope.NULLSCOPE, result)
+ }
+
+ def IScope getScope_Table_Aggregation_valueRef(EObject object) {
+ var result = <IEObjectDescription>newArrayList
+ var requestedAxisName = ""
+ var eObj = object
+ while (!(eObj instanceof TableDatamart)) {
+ eObj = eObj.eContainer
+ if (eObj instanceof TableAxis) {
+ requestedAxisName = (eObj as TableAxis).axis.literal
+ }
+ }
+ if (eObj != null) {
+ var datamart = (eObj as TableDatamart).datamartRef
+ if (datamart != null && datamart.source != null) {
+ if (datamart.source instanceof DatamartCube) {
+ for (axis : (datamart.source as DatamartCube).axisslicer) {
+ if (axis instanceof DatamartAxis) {
+ if ((axis as DatamartAxis).name.literal.equals(requestedAxisName)) {
+ var hasMeasures = false
+ var hasHierarchy = false
+ var hasAggregation = false
+ var isCrossjoined = false
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartMeasure ||
+ element instanceof DatamartDerivedMeasure) {
+ hasMeasures = true
+ }
+ }
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartHierarchy) {
+ if (hasHierarchy) {
+ isCrossjoined = true
+ } else {
+ hasHierarchy = true
+ }
+ }
+ if (element instanceof DatamartSetAggregation) {
+ if (hasAggregation) {
+ isCrossjoined = true
+ } else {
+ hasAggregation = true
+ }
+ hasAggregation = true
+ }
+ }
+ if (hasMeasures && (hasHierarchy || hasAggregation)) {
+ isCrossjoined = true
+ }
+ if (!hasMeasures && !isCrossjoined) {
+ for (element : (axis as DatamartAxis).elements) {
+ if (element instanceof DatamartSetAggregation) {
+ if ((element as DatamartSetAggregation).left != null) {
+ if ((element as DatamartSetAggregation).left.aggregation != null) {
+ var aggregation = ((element as DatamartSetAggregation).left.
+ aggregation) as DatamartSetAggregationFunction
+
+ // with EObjectDescription.create, we use our own name computation for scoping - it must return a created scope
+ result.add(
+ EObjectDescription.create(aggregation.aggregation.literal,
+ aggregation))
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // with EObjectDescription.create, we use our own name computation for scoping - it must return a created scope
+ return MapBasedScope.createScope(IScope.NULLSCOPE, result)
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/validation/TableDSLValidator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/validation/TableDSLValidator.xtend
new file mode 100644
index 0000000..a9a20a0
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/validation/TableDSLValidator.xtend
@@ -0,0 +1,94 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ *
+ * This copyright notice shows up in the generated Java code
+ *
+ */
+
+package org.eclipse.osbp.xtext.table.validation
+
+import java.util.List
+import org.eclipse.xtext.common.types.JvmGenericType
+import org.eclipse.xtext.validation.Check
+import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage
+import org.eclipse.xtext.common.types.util.TypeReferences
+import org.vaadin.hene.popupbutton.PopupButton
+import org.eclipse.osbp.xtext.table.TableDSLPackage
+import org.tepi.filtertable.FilterTable
+import org.eclipse.osbp.xtext.table.TablePackage
+import org.eclipse.osbp.xtext.table.TableModel
+
+//import org.eclipse.xtext.validation.Check
+
+/**
+ * Custom validation rules.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#validation
+ */
+class TableDSLValidator extends AbstractTableDSLValidator {
+
+// public static val INVALID_NAME = 'invalidName'
+//
+// @Check
+// def checkGreetingStartsWithCapital(Greeting greeting) {
+// if (!Character.isUpperCase(greeting.name.charAt(0))) {
+// warning('Name should start with a capital',
+// MyDslPackage.Literals.GREETING__NAME,
+// INVALID_NAME)
+// }
+// }
+
+ public static val String CODE__MISSING__L_RUNTIME_COMMON = "0_108"
+ public static val String CODE__MISSING__DATATYPE_LIB = "0_109"
+ public static val String CODE__MISSING__XBASE_LIB = "0_111"
+ public static val String CODE__MISSING__JDK_1_5 = "0_112"
+
+ @Check
+ def checkClassPath(TableModel tableModel) {
+ var typeReferences = services.typeReferences
+ val listType = typeReferences.findDeclaredType(List, tableModel) as JvmGenericType
+ if (listType == null || listType.getTypeParameters().isEmpty()) {
+ error("Couldn't find a JDK 1.5 or higher on the project's classpath.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ CODE__MISSING__JDK_1_5);
+ }
+ if (typeReferences.findDeclaredType(PopupButton, tableModel) == null) {
+ error("Couldn't find a the mandatory library 'popupbutton.osgi' on the project's classpath.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ "");
+ }
+ if (typeReferences.findDeclaredType(FilterTable, tableModel) == null) {
+ error("Couldn't find a the mandatory library 'filteringtable.osgi' on the project's classpath.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ "");
+ }
+ if (typeReferences.findDeclaredType(
+ "org.eclipse.osbp.runtime.common.annotations.Dispose", tableModel) == null) {
+ error("Couldn't find the mandatory library 'org.eclipse.osbp.runtime.common' on the project's classpath.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ CODE__MISSING__L_RUNTIME_COMMON);
+ }
+ if (typeReferences.findDeclaredType(
+ "org.eclipse.osbp.dsl.common.datatypes.IDatatypeConstants", tableModel) == null) {
+ warning("Couldn't find the optional library 'org.eclipse.osbp.dsl.datatype.lib' on the project's classpath. This may cause resolving problems.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ CODE__MISSING__DATATYPE_LIB);
+ }
+ if (typeReferences.findDeclaredType("javax.validation.Valid", tableModel) == null) {
+ error("Couldn't find the library 'javax.validation' on the project's classpath. This may cause resolving problems.",
+ tableModel, TableDSLPackage.Literals.TABLE_MODEL__PACKAGES,
+ CODE__MISSING__DATATYPE_LIB);
+ }
+ }
+
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableQualifiedNameProvider.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableQualifiedNameProvider.java
new file mode 100644
index 0000000..9b9645a
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableQualifiedNameProvider.java
@@ -0,0 +1,68 @@
+/**
+ *
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ */
+ package org.eclipse.osbp.xtext.table.valueconverter;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.xtext.naming.IQualifiedNameConverter;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider;
+
+import com.google.inject.Inject;
+
+import org.eclipse.osbp.xtext.table.Table;
+import org.eclipse.osbp.xtext.table.TablePackage;
+
+@SuppressWarnings("restriction")
+public class TableQualifiedNameProvider extends XbaseQualifiedNameProvider {
+
+ @Inject
+ private IQualifiedNameConverter qualifiedNameConverter;
+
+ @Override
+ public QualifiedName getFullyQualifiedName(EObject obj) {
+ if (obj == null) {
+ return QualifiedName.create("");
+ }
+ if (obj instanceof Table) {
+ Table table = (Table) obj;
+ if (table.getName() == null) {
+ return null;
+ }
+ return qualifiedNameConverter.toQualifiedName(table.getName());
+ }
+ return super.getFullyQualifiedName(obj);
+ }
+
+ // this method evaluates the cross referenced name of an object without causing cyclic lazy linking errors
+ private String getCrossReferenceName(EObject obj, EStructuralFeature feature) {
+ List<INode> nodes = NodeModelUtils.findNodesForFeature(obj, feature);
+ if (nodes.size() == 0) {
+ return null;
+ }
+ return NodeModelUtils.getTokenText(nodes.get(0));
+ }
+
+ private String getPackageName(EObject obj) {
+ EObject o = obj.eContainer();
+ while(!(o instanceof TablePackage)) {
+ o = o.eContainer();
+ }
+ return ((TablePackage)o).getName();
+ }
+}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableValueConverterService.java b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableValueConverterService.java
new file mode 100644
index 0000000..61ec23b
--- /dev/null
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/valueconverter/TableValueConverterService.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christophe Loetz - Initial implementation
+ */
+package org.eclipse.osbp.xtext.table.valueconverter;
+
+import org.eclipse.osbp.xtext.basic.valueconverter.TRANSLATABLESTRINGValueConverter;
+import org.eclipse.xtext.conversion.IValueConverter;
+import org.eclipse.xtext.conversion.ValueConverter;
+import org.eclipse.xtext.xbase.conversion.XbaseValueConverterService;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * Adds a value conversion for the QualifiedNameWithWildCard rule.
+ */
+@SuppressWarnings("restriction")
+@Singleton
+public class TableValueConverterService extends XbaseValueConverterService {
+
+ @Inject
+ private TRANSLATABLESTRINGValueConverter converter;
+
+ @ValueConverter(rule = "QualifiedNameWithWildCard")
+ public IValueConverter<String> getQualifiedNameWithWildCard() {
+ return getQualifiedNameValueConverter();
+ }
+
+ @ValueConverter(rule = "TRANSLATABLESTRING")
+ public IValueConverter<String> getTranslatableStringValueConverter() {
+ return converter;
+ }
+
+}

Back to the top