catch up with branch daily
Signed-off-by: Ralf Mollik <ramollik@compex-commerce.com>
diff --git a/org.eclipse.osbp.xtext.table.tests/xtend-gen/org/eclipse/osbp/xtext/table/tests/TableDSLParsingTest.java b/org.eclipse.osbp.xtext.table.tests/xtend-gen/org/eclipse/osbp/xtext/table/tests/TableDSLParsingTest.java
index 831cc82..cdec989 100644
--- a/org.eclipse.osbp.xtext.table.tests/xtend-gen/org/eclipse/osbp/xtext/table/tests/TableDSLParsingTest.java
+++ b/org.eclipse.osbp.xtext.table.tests/xtend-gen/org/eclipse/osbp/xtext/table/tests/TableDSLParsingTest.java
@@ -1,22 +1,22 @@
/**
- *
* 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 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * 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.tests;
import com.google.inject.Inject;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.osbp.xtext.table.TableModel;
import org.eclipse.osbp.xtext.table.tests.TableDSLInjectorProvider;
import org.eclipse.xtend2.lib.StringConcatenation;
@@ -43,10 +43,7 @@
_builder.newLine();
final TableModel result = this.parseHelper.parse(_builder);
Assert.assertNotNull(result);
- Resource _eResource = result.eResource();
- EList<Resource.Diagnostic> _errors = _eResource.getErrors();
- boolean _isEmpty = _errors.isEmpty();
- Assert.assertTrue(_isEmpty);
+ Assert.assertTrue(result.eResource().getErrors().isEmpty());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
diff --git a/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF b/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
index 1c7d043..5cdc017 100644
--- a/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
+++ b/org.eclipse.osbp.xtext.table/META-INF/MANIFEST.MF
@@ -92,6 +92,7 @@
javax.validation.constraints,
org.apache.log4j,
org.eclipse.osbp.bpm.api;version="0.9.0",
+ org.eclipse.osbp.ecview.dsl.extensions;version="0.9.0",
org.eclipse.osbp.ecview.extension.strategy;version="0.9.0",
org.eclipse.osbp.ui.api.contextfunction;version="0.9.0",
org.eclipse.osbp.ui.api.datamart;version="0.9.0",
diff --git a/org.eclipse.osbp.xtext.table/emf-gen/org/eclipse/osbp/xtext/table/TableDSLPackage.java b/org.eclipse.osbp.xtext.table/emf-gen/org/eclipse/osbp/xtext/table/TableDSLPackage.java
index bce1b29..ba4da1d 100644
--- a/org.eclipse.osbp.xtext.table/emf-gen/org/eclipse/osbp/xtext/table/TableDSLPackage.java
+++ b/org.eclipse.osbp.xtext.table/emf-gen/org/eclipse/osbp/xtext/table/TableDSLPackage.java
@@ -700,6 +700,15 @@
int TABLE_GRID_PROPERTY__EDITABLE = CxGridSourcePackage.CX_GRID_PROPERTY__EDITABLE;
/**
+ * The feature id for the '<em><b>Source FQN</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int TABLE_GRID_PROPERTY__SOURCE_FQN = CxGridSourcePackage.CX_GRID_PROPERTY__SOURCE_FQN;
+
+ /**
* The number of structural features of the '<em>Table Grid Property</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
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
index cc862ca..20bccb4 100644
--- 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
@@ -37,7 +37,7 @@
('{' (tables+=Table)* '}')?;
Table:
- {Table} 'table' name=ID (description?='describedBy' descriptionValue=TRANSLATABLESTRING)?
+ {Table} 'table' name=TRANSLATABLEID (description?='describedBy' descriptionValue=TRANSLATABLESTRING)?
'as' tabletype=TableOption;
TableOption:
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
index 55bf5c3..7f58c07 100644
--- 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
@@ -16,6 +16,7 @@
package org.eclipse.osbp.xtext.table;
import org.eclipse.osbp.dsl.common.xtext.scoping.ScopingInfoProvider;
+import org.eclipse.osbp.xtext.i18n.DSLOutputConfigurationProvider;
import org.eclipse.osbp.xtext.oxtype.imports.IShouldImportProvider;
import org.eclipse.osbp.xtext.oxtype.imports.OXTypeRewritableImportSection;
import org.eclipse.osbp.xtext.oxtype.linker.JvmTypeAwareLinker;
@@ -27,7 +28,6 @@
import org.eclipse.osbp.xtext.oxtype.scoping.OXDelegatingNamespaceScopeProvider;
import org.eclipse.osbp.xtext.oxtype.serializer.JvmTypeAwareTransientValueService;
import org.eclipse.osbp.xtext.table.formatting.TableDSLFormatter;
-import org.eclipse.osbp.xtext.table.generator.OutputConfigurationProvider;
import org.eclipse.osbp.xtext.table.imports.ShouldImportProvider;
import org.eclipse.osbp.xtext.table.jvmmodel.TableModelGenerator;
import org.eclipse.osbp.xtext.table.scoping.TableDSLScopeProvider;
@@ -77,7 +77,7 @@
}
public Class<? extends IOutputConfigurationProvider> bindIOutputConfigurationProvider() {
- return OutputConfigurationProvider.class;
+ return DSLOutputConfigurationProvider.class;
}
// /**
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
deleted file mode 100644
index 8df6d20..0000000
--- a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/OutputConfigurationProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * 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/TableGridSourceGenerator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.xtend
index ca6538b..e202f88 100644
--- 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
@@ -21,20 +21,39 @@
import java.io.StringWriter
import java.io.Writer
+import java.util.HashMap
+import java.util.Map
+import javax.inject.Inject
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.LAttribute
+import org.eclipse.osbp.dsl.semantic.common.types.LDataType
import org.eclipse.osbp.dsl.semantic.common.types.LPackage
+import org.eclipse.osbp.dsl.semantic.common.types.LScalarType
+import org.eclipse.osbp.dsl.semantic.dto.LDtoAbstractAttribute
+import org.eclipse.osbp.dsl.semantic.dto.LDtoInheritedAttribute
+import org.eclipse.osbp.dsl.semantic.entity.LBean
+import org.eclipse.osbp.dsl.semantic.entity.LBeanAttribute
+import org.eclipse.osbp.dsl.semantic.entity.LEntity
+import org.eclipse.osbp.ecview.dsl.extensions.TypeHelper
+import org.eclipse.osbp.infogrid.model.gridsource.CxGridSourceFactory
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.infogrid.model.gridsource.style.CxGridStyleFactory
+import org.eclipse.osbp.utils.common.EntityUtils
+import org.eclipse.osbp.xtext.table.TableDtoDatasource
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 org.eclipse.xtext.naming.IQualifiedNameProvider
import static extension org.eclipse.osbp.infogrid.model.gridsource.util.Util.*
+import javax.persistence.metamodel.ListAttribute
+import org.eclipse.osbp.dsl.semantic.common.types.LClass
/**
* Generates code from your model files on save.
@@ -43,6 +62,9 @@
*/
class TableGridSourceGenerator implements IGenerator {
+ @Inject extension IQualifiedNameProvider
+ @Inject extension TypeHelper
+
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
resource.toBinary(fsa)
}
@@ -71,14 +93,48 @@
// 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
+ if (ds.properties !== null && ds.properties.length > 0) {
+ // set required properties
+ for (prop : ds.properties) {
+ prop.dotPath = prop.calcDotPath
+ // set source FQN for column permission checks
+ prop.sourceFQN = prop.path.field.eContainer.fullyQualifiedName.toString
+ // prepare dot path in styles
+ prop.style.prepare
+ }
+ } else {
+ var attributesMap = <String, String>newHashMap
+ var attributesTypeMap = <String, LScalarType>newHashMap
+ var attributesSourceMap = <String, String>newHashMap
+ var sourceFQN = ds.dtoSource.fullyQualifiedName.toString
+ for (attr : ds.dtoSource.attributes) {
+ // filtering out id, uuid, version, transient, CreateAt, CreateBy, UpdateAt and UpdateBy
+ if (ds.allowedAttribute(attr)) {
+ attr.fillAttributes(sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
+ }
+ if (ds.dtoSource.superType !== null) {
+ sourceFQN = ds.dtoSource.superType.fullyQualifiedName.toString
+ for (attr : ds.dtoSource.superType.attributes) {
+ // filtering out id, uuid, version, transient, CreateAt, CreateBy, UpdateAt and UpdateBy
+ if (ds.allowedAttribute(attr)) {
+ attr.fillAttributes(sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
+ }
+ }
+ for (attrKey : attributesMap.keySet){
+ var prop = CxGridSourceFactory.eINSTANCE.createCxGridProperty();
+ prop.dotPath = attributesMap.get(attrKey)
+ prop.style = attributesTypeMap.get(attrKey).propStyle
+ sourceFQN = attributesSourceMap.get(attrKey)
+ if (sourceFQN === null){
+ sourceFQN = ds.rootTypeFQN
+ }
+ prop.sourceFQN = sourceFQN
+ prop.editable = true
+ ds.properties.add(prop)
+ }
}
-
val copy = EcoreUtil.copy(ds)
outputRes.contents += copy
@@ -88,6 +144,53 @@
fsa.generateFile(ds.id + ".gridsource_xmi", "xmi", writer.toString)
}
+
+ protected def boolean allowedAttribute(TableDtoDatasource ds, LDtoAbstractAttribute attr) {
+ var allowedAttr = true
+ var LAttribute attribute = attr
+ if (attr instanceof LDtoInheritedAttribute) {
+ attribute = (attr as LDtoInheritedAttribute).inheritedFeature
+ }
+ var wrappedType = ds.dtoSource.wrappedType
+ if (wrappedType instanceof LClass){
+ allowedAttr = (wrappedType as LClass).isNormalAttribute(attribute)
+ }
+ allowedAttr
+ }
+
+ def CxGridPropStyle getPropStyle(LScalarType type) {
+ if (type instanceof LDataType) {
+ if (type.date) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropDateStyle()
+ } else if (type.asBlob) {
+ // TODO (JCD): Decision to make which style to provide for 'asBlob' types
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle()
+ } else {
+ var jvmType = (type as LDataType).jvmTypeReference?.type
+ if (jvmType !== null) {
+ if (jvmType.string) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle()
+ } else if (jvmType.boolean) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropBooleanStyle()
+ } else if (jvmType.date) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropDateStyle()
+ } else if (jvmType.number) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropNumberStyle()
+ }
+ }
+ }
+ }
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle()
+ }
+
+ def fillAttributes(LDtoAbstractAttribute attr, String sourceFQN, HashMap<String, String> attributesMap, HashMap<String, LScalarType> attributesTypeMap, HashMap<String, String> attributesSourceMap) {
+ var LAttribute attribute = attr
+ if (attr instanceof LDtoInheritedAttribute) {
+ attribute = (attr as LDtoInheritedAttribute).inheritedFeature
+ }
+ var type = attribute.type as LScalarType
+ recurseAttributesMap(sourceFQN, type, attribute, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
def dispatch void prepare(CxGridPropStyle style) {
}
@@ -101,5 +204,35 @@
style.valuePropertyDotPath = style.valuePropertyPath.calcDotPath
style.uomPropertyDotPath = style.uomPropertyPath.calcDotPath
}
+
+ def void recurseAttributesMap(String sourceFQN, LScalarType type, LAttribute attribute, Map<String, String> attributesMap, HashMap<String, LScalarType> attributesTypeMap, HashMap<String, String> attributesSourceMap) {
+ if (type !== null && type instanceof LBean) {
+ var bean = type as LBean
+ for (attr : bean.allAttributes) {
+ if (attr.type instanceof LBean) {
+ recurseAttributesMap(sourceFQN, attr.type, attribute, attributesMap, attributesTypeMap, attributesSourceMap)
+ } else {
+ attr.fillAttributeMaps(sourceFQN, attribute.name, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
+ }
+ } else {
+ attribute.fillAttributeMaps(sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
+ }
+
+ def void fillAttributeMaps(LAttribute attr, String sourceFQN, Map<String, String> attributesMap, HashMap<String, LScalarType> attributesTypeMap, HashMap<String, String> attributesSourceMap){
+ attr.fillAttributeMaps(sourceFQN, null, attributesMap, attributesTypeMap, attributesSourceMap)
+ }
+
+ def void fillAttributeMaps(LAttribute attr, String sourceFQN, String attributeBeanName, Map<String, String> attributesMap, HashMap<String, LScalarType> attributesTypeMap, HashMap<String, String> attributesSourceMap){
+ var attrName = attr.name
+ if (attributeBeanName !== null) {
+ attrName = '''«attributeBeanName».«attrName»'''
+ }
+ attributesMap.put(attr.name, attrName)
+ attributesTypeMap.put(attr.name, attr.type)
+ attributesSourceMap.put(attr.name, sourceFQN)
+ }
+
}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
index ebc36aa..ac10575 100644
--- a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.xtend
@@ -48,6 +48,7 @@
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.xtext.extensions.AnnotationExtension
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.LKeyAndValue
@@ -69,9 +70,8 @@
import org.eclipse.osbp.ui.api.table.ITableRowCheckListener
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.ui.api.useraccess.IUserAccessService
import org.eclipse.osbp.utils.common.EntityUtils
-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.cubedsl.CubeLevel
@@ -120,6 +120,7 @@
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.PropertyLookup
import org.eclipse.osbp.xtext.table.common.TableFilterDecorator
import org.eclipse.xtext.Constants
import org.eclipse.xtext.EcoreUtil2
@@ -133,6 +134,9 @@
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
+import org.osgi.service.component.annotations.Reference
+import org.osgi.service.component.annotations.ReferenceCardinality
+import org.osgi.service.component.annotations.ReferencePolicy
import org.slf4j.Logger
/**
@@ -213,7 +217,8 @@
@Inject extension IQualifiedNameProvider
@Inject extension DatamartDSLJvmModelInferrer datamartInferrer
@Inject extension ModelExtensions
- @Inject extension CommonUtils
+ @Inject extension AnnotationExtension
+
@Inject
@Named(Constants.FILE_EXTENSIONS) String fileExtension
@@ -221,6 +226,8 @@
val CONVERT_METHOD_PREFIX = "getStringTo"
+ var String binderClassName = ""
+
def String getFileExtension() {
}
@@ -229,6 +236,22 @@
*
*/
def dispatch void infer(TablePackage pkg, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
+
+ // the service binder class
+ binderClassName = pkg.fullyQualifiedName.toString + "." +
+ pkg.fullyQualifiedName.lastSegment.toFirstUpper + "ServiceBinder"
+ val clsBinder = pkg.toClass(pkg.name.toString.concat("ServiceBinder"))
+ clsBinder.simpleName = clsBinder.simpleName.toFirstUpper
+ acceptor.accept(clsBinder, [
+ annotations += _annotationTypesBuilder.annotationRef(SuppressWarnings, "serial")
+ annotations += _annotationTypesBuilder.annotationRef(typeof(org.osgi.service.component.annotations.Component))
+
+ packageName = pkg.fullyQualifiedName.toString
+ it.fileHeader = pkg.documentation
+ it.toBinderFields(pkg)
+ it.toBinderOperations(pkg)
+ ])
+
// create table classes
for (table : pkg.tables) {
var clsName = ""
@@ -430,7 +453,7 @@
field = table.toField("mustRefresh", _typeReferenceBuilder.typeRef(boolean)) [initializer = [append('''false''')]]
type.members += field
field = table.toField("attributeLookupMap",
- _typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(PropertyLookup)))
+ _typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(String), _typeReferenceBuilder.typeRef(PropertyLookup)))
type.members += field
field = table.toField("tabSheets",
_typeReferenceBuilder.typeRef(HashMap, _typeReferenceBuilder.typeRef(Component), _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(ArrayList, _typeReferenceBuilder.typeRef(Integer)))))
@@ -745,13 +768,11 @@
childContext.set(Locale.class, user.getLocale());
childContext.set("gridSourceId", "«pkg.name.toString.concat(".").concat(table.name).concat("Grid")»");
LinkedHashMap<String, EventDispatcherEvent> selectionEvntList = new LinkedHashMap<>();
- PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", "«table.fullyQualifiedName»");
- if(perspective != null){evnt.setPerspective(perspective);}
+ MPerspective perspective = eclipseContext.get(MPerspective.class);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", "«table.fullyQualifiedName»");
selectionEvntList.put("«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", evnt);
«FOR entityReferenceFQIdName : entity.uniqueReferenceFQIdName.values»
- evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, "«entityReferenceFQIdName»", "«table.fullyQualifiedName»");
- if(perspective != null){evnt.setPerspective(perspective);}
+ evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«entityReferenceFQIdName»", "«table.fullyQualifiedName»");
selectionEvntList.put("«entityReferenceFQIdName»", evnt);
«ENDFOR»
childContext.set("selectionEvnt", selectionEvntList);
@@ -765,9 +786,8 @@
body = '''
«body»
if(changedFilter != null) {
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, changedFilter.getName(), "«table.fullyQualifiedName»");
- PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);
- if(perspective != null){evnt.setPerspective(perspective);}
+ MPerspective perspective = eclipseContext.get(MPerspective.class);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, changedFilter.getName(), "«table.fullyQualifiedName»");
evnt.addData(changedFilter.getSelectedData());
eventDispatcher.sendEvent(evnt);
}
@@ -782,9 +802,10 @@
body = '''
«body»
switch(event.getCommand()) {
- case SELECT:
- PerspectiveImpl perspective = (PerspectiveImpl) eclipseContext.getActive(MPerspective.class);
- if(event.getPerspective() == null || (perspective != null && event.getPerspective().equals(perspective))){
+ case SELECT:
+ MPerspective perspective = eclipseContext.get(MPerspective.class);
+ ArrayList<String> allowedSenderParts = (ArrayList<String>) eclipseContext.getActive(MPart.class).getTransientData().get(IPerspectiveProvider.EventDispatcherConstants.ACCEPTED_SENDERS);
+ if((event.getPerspective() == null || (perspective != null && event.getPerspective().equals(perspective))) && ((allowedSenderParts != null && allowedSenderParts.contains(event.getSender())) || allowedSenderParts == null)){
if(!event.getSender().equals("«table.fullyQualifiedName»")) {
if(filterGenerator.selectItem(event, getSelectById())) {
«IF table.isEmbedded || table.task»
@@ -822,9 +843,10 @@
}
«ENDFOR»
}
+ /* must be activated if sure that the filter is to be refreshed
if (filterGenerator != null) {
filterGenerator.updateFilter();
- }
+ }*/
break;
'''
body = '''
@@ -842,6 +864,7 @@
«FOR e:findRequestedEntities(table)»
if(event.getTopic().equals("«e.fullyQualifiedName»")){
// TODO: GridRefresh
+ grid.refreshData();
}
«ENDFOR»
}
@@ -1257,7 +1280,8 @@
Button b = new Button(null, new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, "UserMenu", "«table.fullyQualifiedName»");
+ MPerspective perspective = eclipseContext.get(MPerspective.class);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, "UserMenu", "«table.fullyQualifiedName»");
eventDispatcher.sendEvent(evnt);
}
});
@@ -2733,17 +2757,15 @@
body = '''
«body»
«IF entity.primaryKeyAttribute !== null»
- PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);
- EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", "«table.fullyQualifiedName»");
- if(perspective != null){evnt.setPerspective(perspective);}
+ MPerspective perspective = getContext().get(MPerspective.class);
+ EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«entity.baseType.fullyQualifiedName».«entity.idAttributeName»", "«table.fullyQualifiedName»");
evnt.addItem(EventDispatcherDataTag.ID, dataSourceContainer.getValueByProperty(selection, "«alias.toLowerCase»"));
eventDispatcher.sendEvent(evnt);
for (DatamartPrimary<?> primary : datamartInstance.getPrimaryList()){
if (!"«entity.baseType.fullyQualifiedName»".equals(primary.getEntityName())){
Object primaryValue = dataSourceContainer.getValueByProperty(selection, primary.getAlias().toLowerCase());
if (primaryValue != null) {
- evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, primary.getEntityName() + "." + primary.getAttributeName(), "«table.fullyQualifiedName»");
- if(perspective != null){evnt.setPerspective(perspective);}
+ evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, primary.getEntityName() + "." + primary.getAttributeName(), "«table.fullyQualifiedName»");
evnt.addItem(EventDispatcherDataTag.ID, primaryValue);
eventDispatcher.sendEvent(evnt);
}
@@ -2764,11 +2786,10 @@
body = '''
«body»
«IF event.source instanceof TableOrdinal»
- EventDispatcherEvent evnt«evntCnt» = new EventDispatcherEvent(EventDispatcherCommand.SELECT, "«(event.source as TableOrdinal).valueRef»", "«table.fullyQualifiedName»");
+ EventDispatcherEvent evnt«evntCnt» = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«(event.source as TableOrdinal).valueRef»", "«table.fullyQualifiedName»");
«ELSEIF event.source instanceof TableAttribute»
- EventDispatcherEvent evnt«evntCnt» = new EventDispatcherEvent(EventDispatcherCommand.SELECT, "«(event.source as TableAttribute).valueRef.attributeRef.name»", "«table.fullyQualifiedName»");
+ EventDispatcherEvent evnt«evntCnt» = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, "«(event.source as TableAttribute).valueRef.attributeRef.name»", "«table.fullyQualifiedName»");
«ENDIF»
- if(perspective != null){evnt.setPerspective(perspective);}
«IF event.source instanceof TableOrdinal»
evnt«evntCnt».addItem(EventDispatcherDataTag.LIST, dataSourceContainer.getValueByProperty(selection, "«(event.source as TableOrdinal).valueRef»"));
eventDispatcher.sendEvent(evnt«evntCnt»);
@@ -2797,7 +2818,7 @@
// Get the property ID of the resized column
Object columnId = event.getPropertyId();
- user.addToProperties(this.getClass().getEnclosingClass().getCanonicalName() + "." + columnId.toString() + "." + "width", String.valueOf(width));
+ user.addToProperties(this.getClass().getEnclosingClass().getCanonicalName() + "." + columnId.toString() + ".width", String.valueOf(width));
}
});
// Must be immediate to send the resize events immediately
@@ -2808,16 +2829,34 @@
'''table.addColumnReorderListener(new ColumnReorderListener(){
public void columnReorder(ColumnReorderEvent event) {
Object source = event.getSource();
- String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + "." + "columns";
- if (source instanceof CustomTable){
- Object[] visibleColumns = ((CustomTable)source).getVisibleColumns();
+ String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + ".columns";
+ if (source instanceof CellSetFilterTable){
+ Map<Object, Integer> visibleColumnsPositions = new HashMap<>();
+ Object[] visibleColumns = ((CellSetFilterTable)source).getVisibleColumns();
+ for (int i = 0; i < visibleColumns.length; i++) {
+ CellSetIndexedContainer container = ((CellSetFilterTable)source).getCellSetIndexedContainer();
+ Object visibleColumnKey = visibleColumns[i];
+ «positionMembersHashCode»
+ visibleColumnsPositions.put(visibleColumnKey, membersHash);
+ }
if (visibleColumns!=null){
- user.addToProperties(propertyKey, visibleColumns);
+ user.addToProperties(propertyKey, visibleColumnsPositions);
}
}
}
});
'''
+
+ def private getPositionMembersHashCode() '''
+ // creates a hash code by the column position members
+ int membersHash = 0;
+ if (container != null) {
+ List<DerivedMember> members = container.getColumnPosition(visibleColumnKey).getMembers();
+ for (DerivedMember member : members) {
+ membersHash += (member.getUniqueName() != null) ? member.getUniqueName().hashCode() : member.hashCode();
+ }
+ }
+ '''
def columnCollapsedListener()
'''table.addColumnCollapseListener(new ColumnCollapseListener(){
@@ -2825,7 +2864,7 @@
// Get the ID of the column collapse event
Object columnId = event.getPropertyId();
Object source = event.getSource();
- String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + "." + columnId.toString() + "." + "collapsed";
+ String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + "." + columnId.toString() + ".collapsed";
if (source instanceof CustomTable){
if (((CustomTable)source).isColumnCollapsed(columnId)) {
user.addToProperties(propertyKey, "true");
@@ -2839,9 +2878,30 @@
def tableSettingsByUserProperties()
'''
+ // Setting the order of the columns via the visibleColumns list
+ Map<Object, Integer> visibleColumnsMap = user.getColumnUtil().getVisibleColumns(this.getClass().getCanonicalName() + ".columns");
+ if (visibleColumnsMap != null){
+ boolean unmodifiedVisibleColumns = true;
+ for (Object visibleColumnKey : visibleColumnsMap.keySet()) {
+ CellSetIndexedContainer container = dataSourceContainer;
+ «positionMembersHashCode»
+ if (membersHash != visibleColumnsMap.get(visibleColumnKey)) {
+ unmodifiedVisibleColumns = false;
+ break;
+ }
+ }
+ if (unmodifiedVisibleColumns) {
+ try {
+ Object[] visibleColumns = visibleColumnsMap.values().toArray();
+ table.setVisibleColumns(visibleColumns );
+ } catch (IllegalArgumentException e) {
+ // this occurs if a saved column is no longer existing due to model changes
+ }
+ }
+ }
// Setting table columns width from the persisted user properties
for (Object visibleId : table.getVisibleColumns()) {
- String widthStr = user.getColumnUtil().getColumnWidth(this.getClass().getCanonicalName() + "." + visibleId.toString() + "." + "width");
+ String widthStr = user.getColumnUtil().getColumnWidth(this.getClass().getCanonicalName() + "." + visibleId.toString() + ".width");
if (widthStr!= null) {
try {
table.setColumnWidth(visibleId, Integer.parseInt(widthStr));
@@ -2852,7 +2912,7 @@
}
// Setting table collapsed columns from the persisted user properties
for (Object propertyId : table.getContainerDataSource().getContainerPropertyIds()) {
- String collapsedColumn = user.getColumnUtil().getColumnCollapsed(this.getClass().getCanonicalName() + "." + propertyId + "." + "collapsed");
+ String collapsedColumn = user.getColumnUtil().getColumnCollapsed(this.getClass().getCanonicalName() + "." + propertyId + ".collapsed");
try {
if (collapsedColumn != null){
table.setColumnCollapsed(propertyId, true);
@@ -2860,14 +2920,6 @@
} catch (IllegalArgumentException e) {
// this occurs if a saved column is no longer existing due to model changes
}
- Object[] visibleColumns = user.getColumnUtil().getVisibleColumns(this.getClass().getCanonicalName() + "." + "columns");
- if (visibleColumns != null){
- try {
- table.setVisibleColumns(visibleColumns);
- } catch (IllegalArgumentException e) {
- // this occurs if a saved column is no longer existing due to model changes
- }
- }
}
'''
@@ -2950,7 +3002,7 @@
if(dataSourceContainer != null) {
dataSourceContainer.setLocale(locale);
}
- layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), "«IF table.description»«table.descriptionValue»«ELSE»«table.name»«ENDIF»"));
+ layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), "«table.name»"));
}
'''
@@ -3016,4 +3068,60 @@
}
}
}
+
+ def void toBinderFields(JvmDeclaredType type,TablePackage tablePckg) {
+ var JvmField field = null
+ // create logger
+ field = tablePckg.toField("log", _typeReferenceBuilder.typeRef(Logger)) [
+ setInitializer([append('''org.slf4j.LoggerFactory.getLogger("servicebinder")''')])
+ ]
+ field.static = true
+ field.visibility = JvmVisibility::PRIVATE
+ type.members += field
+ // create user service field
+ field = tablePckg.toField("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
+ field.static = true
+ field.visibility = JvmVisibility::PRIVATE
+ type.members += field
+ }
+
+ def void toBinderOperations(JvmDeclaredType type, TablePackage tablePckg) {
+ type.members += tablePckg.toMethod("getUserAccessService", _typeReferenceBuilder.typeRef(IUserAccessService), [
+ visibility = JvmVisibility.PUBLIC
+ static = true
+ body = [
+ append(
+ '''return userAccessService;''')
+ ]
+ ])
+ // bind userAccessService
+ type.members += tablePckg.toMethod("bindUserAccessMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
+ var annotationRef = _annotationTypesBuilder.annotationRef(typeof(Reference))
+ annotationRef.addAnnAttr(tablePckg, "cardinality", ReferenceCardinality.MANDATORY)
+ annotationRef.addAnnAttr(tablePckg, "policy", ReferencePolicy.STATIC)
+ annotations += annotationRef
+ visibility = JvmVisibility.PUBLIC
+ synchronized = true
+ parameters += tablePckg.toParameter("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
+ body = [
+ append(
+ '''
+ «tablePckg.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».userAccessService = userAccessService;
+ log.debug("Datamart UserAccessService bound");''')
+ ]
+ ])
+ // unbind userAccessService
+ type.members += tablePckg.toMethod("unbindUserAccessMethod", _typeReferenceBuilder.typeRef(Void::TYPE), [
+ visibility = JvmVisibility.PUBLIC
+ synchronized = true
+ parameters += tablePckg.toParameter("userAccessService", _typeReferenceBuilder.typeRef(IUserAccessService))
+ body = [
+ append(
+ '''
+ «tablePckg.fullyQualifiedName.lastSegment.toFirstUpper+"ServiceBinder"».userAccessService = null;
+ log.debug("Datamart UserAccessService unbound");''')
+ ]
+ ])
+ }
+
}
diff --git a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
index 1818dce..44b09e0 100644
--- a/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
+++ b/org.eclipse.osbp.xtext.table/src/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.xtend
@@ -34,6 +34,8 @@
import com.vaadin.ui.Notification
import com.vaadin.ui.Notification.Type
import com.vaadin.ui.TabSheet
+import com.vaadin.ui.TabSheet.SelectedTabChangeEvent
+import com.vaadin.ui.TabSheet.SelectedTabChangeListener
import com.vaadin.ui.UI
import java.io.PrintWriter
import java.io.StringWriter
@@ -56,9 +58,10 @@
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.di.Focus
import org.eclipse.e4.ui.model.application.MApplication
+import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective
+import org.eclipse.e4.ui.model.application.ui.basic.MPart
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.osbp.bpm.api.BPMOperation
@@ -83,6 +86,7 @@
import org.eclipse.osbp.ui.api.datamart.DatamartPrimary
import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator
import org.eclipse.osbp.ui.api.e4.IE4Table
+import org.eclipse.osbp.ui.api.perspective.IPerspectiveProvider
import org.eclipse.osbp.ui.api.themes.IThemeResourceService
import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType
import org.eclipse.osbp.utils.constants.ExtendedDate
@@ -115,10 +119,6 @@
import org.osgi.service.event.Event
import org.osgi.service.event.EventHandler
import org.vaadin.hene.popupbutton.PopupButton
-import com.vaadin.ui.TabSheet.SelectedTabChangeListener
-import com.vaadin.ui.TabSheet.SelectedTabChangeEvent
-import org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl
-import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective
class TableModelGenerator extends I18NModelGenerator {
@Inject TableGridSourceGenerator delegate
@@ -226,9 +226,12 @@
StringWriter,
PrintWriter,
LinkedHashMap,
+// ReferenceCardinality,
+// ReferencePolicy,
IDualData,
- PerspectiveImpl,
- MPerspective
+ MPerspective,
+ MPart,
+ IPerspectiveProvider
)
super.createAppendable(context, importManager, config)
}
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
index 0e8664a..8d93a83 100644
--- 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
@@ -62,6 +62,7 @@
import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropStyle
import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropQuantityStyle
import org.eclipse.osbp.infogrid.model.gridsource.style.CxGridPropPriceStyle
+import org.eclipse.osbp.xtext.datamartdsl.DatamartHierarchyLevelSingle
class TableDSLScopeProvider extends AbstractTableDSLScopeProvider {
@Inject extension ModelExtensions
@@ -342,10 +343,9 @@
if ((element as DatamartHierarchy).
hierarchyRef !== null) {
var hierarchy = element as DatamartHierarchy
- if (hierarchy.levelRef !== null) {
+ if ((hierarchy.level instanceof DatamartHierarchyLevelSingle) && (hierarchy.level as DatamartHierarchyLevelSingle).levelRef !== null) {
if (hierarchy.all) { // detailed was modeled - we must add the complete hierarchy
- var dimEntity = (hierarchy.
- levelRef as CubeLevel).
+ var dimEntity = ((hierarchy.level as DatamartHierarchyLevelSingle).levelRef as CubeLevel).
eContainer as CubeDimensionEntity
for (cubeLevel : dimEntity.
hierarchLevels) {
@@ -356,8 +356,8 @@
} else {
result.add(
EObjectDescription.create(
- hierarchy.levelRef.name,
- (hierarchy.
+ (hierarchy.level as DatamartHierarchyLevelSingle).levelRef.name,
+ ((hierarchy.level as DatamartHierarchyLevelSingle).
levelRef as CubeLevel)))
}
diff --git a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.java b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.java
index 7a24a52..04007b1 100644
--- a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.java
+++ b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/generator/TableGridSourceGenerator.java
@@ -19,18 +19,36 @@
import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Consumer;
+import javax.inject.Inject;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
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.LAttribute;
+import org.eclipse.osbp.dsl.semantic.common.types.LClass;
+import org.eclipse.osbp.dsl.semantic.common.types.LDataType;
import org.eclipse.osbp.dsl.semantic.common.types.LPackage;
+import org.eclipse.osbp.dsl.semantic.common.types.LScalarType;
+import org.eclipse.osbp.dsl.semantic.common.types.LType;
+import org.eclipse.osbp.dsl.semantic.dto.LDto;
+import org.eclipse.osbp.dsl.semantic.dto.LDtoAbstractAttribute;
+import org.eclipse.osbp.dsl.semantic.dto.LDtoInheritedAttribute;
+import org.eclipse.osbp.dsl.semantic.entity.LBean;
+import org.eclipse.osbp.dsl.semantic.entity.LBeanAttribute;
+import org.eclipse.osbp.ecview.dsl.extensions.TypeHelper;
import org.eclipse.osbp.infogrid.model.gridsource.CxGridProperty;
+import org.eclipse.osbp.infogrid.model.gridsource.CxGridSourceFactory;
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.infogrid.model.gridsource.style.CxGridStyleFactory;
import org.eclipse.osbp.infogrid.model.gridsource.util.Util;
import org.eclipse.osbp.xtext.table.Table;
import org.eclipse.osbp.xtext.table.TableDtoDatasource;
@@ -39,9 +57,15 @@
import org.eclipse.osbp.xtext.table.TableOption;
import org.eclipse.osbp.xtext.table.TablePackage;
import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.common.types.JvmType;
+import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
+import org.eclipse.xtext.naming.IQualifiedNameProvider;
+import org.eclipse.xtext.xbase.lib.CollectionLiterals;
+import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.eclipse.xtext.xbase.lib.Extension;
/**
* Generates code from your model files on save.
@@ -50,6 +74,14 @@
*/
@SuppressWarnings("all")
public class TableGridSourceGenerator implements IGenerator {
+ @Inject
+ @Extension
+ private IQualifiedNameProvider _iQualifiedNameProvider;
+
+ @Inject
+ @Extension
+ private TypeHelper _typeHelper;
+
@Override
public void doGenerate(final Resource resource, final IFileSystemAccess fsa) {
this.toBinary(resource, fsa);
@@ -86,11 +118,53 @@
String _name_1 = ds.getDtoSource().getName();
_builder.append(_name_1);
ds.setRootTypeFQN(_builder.toString());
- EList<CxGridProperty> _properties = ds.getProperties();
- for (final CxGridProperty prop : _properties) {
- {
- prop.setDotPath(Util.calcDotPath(prop));
- this.prepare(prop.getStyle());
+ if (((ds.getProperties() != null) && (((Object[])Conversions.unwrapArray(ds.getProperties(), Object.class)).length > 0))) {
+ EList<CxGridProperty> _properties = ds.getProperties();
+ for (final CxGridProperty prop : _properties) {
+ {
+ prop.setDotPath(Util.calcDotPath(prop));
+ prop.setSourceFQN(this._iQualifiedNameProvider.getFullyQualifiedName(prop.getPath().getField().eContainer()).toString());
+ this.prepare(prop.getStyle());
+ }
+ }
+ } else {
+ HashMap<String, String> attributesMap = CollectionLiterals.<String, String>newHashMap();
+ HashMap<String, LScalarType> attributesTypeMap = CollectionLiterals.<String, LScalarType>newHashMap();
+ HashMap<String, String> attributesSourceMap = CollectionLiterals.<String, String>newHashMap();
+ String sourceFQN = this._iQualifiedNameProvider.getFullyQualifiedName(ds.getDtoSource()).toString();
+ List<LDtoAbstractAttribute> _attributes = ds.getDtoSource().getAttributes();
+ for (final LDtoAbstractAttribute attr : _attributes) {
+ boolean _allowedAttribute = this.allowedAttribute(ds, attr);
+ if (_allowedAttribute) {
+ this.fillAttributes(attr, sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+ }
+ LDto _superType = ds.getDtoSource().getSuperType();
+ boolean _tripleNotEquals = (_superType != null);
+ if (_tripleNotEquals) {
+ sourceFQN = this._iQualifiedNameProvider.getFullyQualifiedName(ds.getDtoSource().getSuperType()).toString();
+ List<LDtoAbstractAttribute> _attributes_1 = ds.getDtoSource().getSuperType().getAttributes();
+ for (final LDtoAbstractAttribute attr_1 : _attributes_1) {
+ boolean _allowedAttribute_1 = this.allowedAttribute(ds, attr_1);
+ if (_allowedAttribute_1) {
+ this.fillAttributes(attr_1, sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+ }
+ }
+ Set<String> _keySet = attributesMap.keySet();
+ for (final String attrKey : _keySet) {
+ {
+ CxGridProperty prop_1 = CxGridSourceFactory.eINSTANCE.createCxGridProperty();
+ prop_1.setDotPath(attributesMap.get(attrKey));
+ prop_1.setStyle(this.getPropStyle(attributesTypeMap.get(attrKey)));
+ sourceFQN = attributesSourceMap.get(attrKey);
+ if ((sourceFQN == null)) {
+ sourceFQN = ds.getRootTypeFQN();
+ }
+ prop_1.setSourceFQN(sourceFQN);
+ prop_1.setEditable(true);
+ ds.getProperties().add(prop_1);
+ }
}
}
final TableDtoDatasource copy = EcoreUtil.<TableDtoDatasource>copy(ds);
@@ -106,6 +180,76 @@
}
}
+ protected boolean allowedAttribute(final TableDtoDatasource ds, final LDtoAbstractAttribute attr) {
+ boolean _xblockexpression = false;
+ {
+ boolean allowedAttr = true;
+ LAttribute attribute = attr;
+ if ((attr instanceof LDtoInheritedAttribute)) {
+ attribute = ((LDtoInheritedAttribute) attr).getInheritedFeature();
+ }
+ LType wrappedType = ds.getDtoSource().getWrappedType();
+ if ((wrappedType instanceof LClass)) {
+ allowedAttr = ((LClass) wrappedType).isNormalAttribute(attribute);
+ }
+ _xblockexpression = allowedAttr;
+ }
+ return _xblockexpression;
+ }
+
+ public CxGridPropStyle getPropStyle(final LScalarType type) {
+ if ((type instanceof LDataType)) {
+ boolean _isDate = ((LDataType)type).isDate();
+ if (_isDate) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropDateStyle();
+ } else {
+ boolean _isAsBlob = ((LDataType)type).isAsBlob();
+ if (_isAsBlob) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle();
+ } else {
+ JvmTypeReference _jvmTypeReference = ((LDataType) type).getJvmTypeReference();
+ JvmType _type = null;
+ if (_jvmTypeReference!=null) {
+ _type=_jvmTypeReference.getType();
+ }
+ JvmType jvmType = _type;
+ if ((jvmType != null)) {
+ boolean _isString = this._typeHelper.isString(jvmType);
+ if (_isString) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle();
+ } else {
+ boolean _isBoolean = this._typeHelper.isBoolean(jvmType);
+ if (_isBoolean) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropBooleanStyle();
+ } else {
+ boolean _isDate_1 = this._typeHelper.isDate(jvmType);
+ if (_isDate_1) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropDateStyle();
+ } else {
+ boolean _isNumber = this._typeHelper.isNumber(jvmType);
+ if (_isNumber) {
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropNumberStyle();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return CxGridStyleFactory.eINSTANCE.createCxGridPropTextStyle();
+ }
+
+ public void fillAttributes(final LDtoAbstractAttribute attr, final String sourceFQN, final HashMap<String, String> attributesMap, final HashMap<String, LScalarType> attributesTypeMap, final HashMap<String, String> attributesSourceMap) {
+ LAttribute attribute = attr;
+ if ((attr instanceof LDtoInheritedAttribute)) {
+ attribute = ((LDtoInheritedAttribute) attr).getInheritedFeature();
+ }
+ LScalarType _type = attribute.getType();
+ LScalarType type = ((LScalarType) _type);
+ this.recurseAttributesMap(sourceFQN, type, attribute, attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+
protected void _prepare(final CxGridPropStyle style) {
}
@@ -119,6 +263,41 @@
style.setUomPropertyDotPath(Util.calcDotPath(style.getUomPropertyPath()));
}
+ public void recurseAttributesMap(final String sourceFQN, final LScalarType type, final LAttribute attribute, final Map<String, String> attributesMap, final HashMap<String, LScalarType> attributesTypeMap, final HashMap<String, String> attributesSourceMap) {
+ if (((type != null) && (type instanceof LBean))) {
+ LBean bean = ((LBean) type);
+ List<LBeanAttribute> _allAttributes = bean.getAllAttributes();
+ for (final LBeanAttribute attr : _allAttributes) {
+ LScalarType _type = attr.getType();
+ if ((_type instanceof LBean)) {
+ this.recurseAttributesMap(sourceFQN, attr.getType(), attribute, attributesMap, attributesTypeMap, attributesSourceMap);
+ } else {
+ this.fillAttributeMaps(attr, sourceFQN, attribute.getName(), attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+ }
+ } else {
+ this.fillAttributeMaps(attribute, sourceFQN, attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+ }
+
+ public void fillAttributeMaps(final LAttribute attr, final String sourceFQN, final Map<String, String> attributesMap, final HashMap<String, LScalarType> attributesTypeMap, final HashMap<String, String> attributesSourceMap) {
+ this.fillAttributeMaps(attr, sourceFQN, null, attributesMap, attributesTypeMap, attributesSourceMap);
+ }
+
+ public void fillAttributeMaps(final LAttribute attr, final String sourceFQN, final String attributeBeanName, final Map<String, String> attributesMap, final HashMap<String, LScalarType> attributesTypeMap, final HashMap<String, String> attributesSourceMap) {
+ String attrName = attr.getName();
+ if ((attributeBeanName != null)) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append(attributeBeanName);
+ _builder.append(".");
+ _builder.append(attrName);
+ attrName = _builder.toString();
+ }
+ attributesMap.put(attr.getName(), attrName);
+ attributesTypeMap.put(attr.getName(), attr.getType());
+ attributesSourceMap.put(attr.getName(), sourceFQN);
+ }
+
public void prepare(final CxGridPropStyle style) {
if (style instanceof CxGridPropPriceStyle) {
_prepare((CxGridPropPriceStyle)style);
diff --git a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
index 06f1119..3c8da96 100644
--- a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
+++ b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableDSLJvmModelInferrer.java
@@ -47,6 +47,7 @@
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.xtext.extensions.AnnotationExtension;
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.LKeyAndValue;
@@ -70,9 +71,8 @@
import org.eclipse.osbp.ui.api.table.ITableRowCheckListener;
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.ui.api.useraccess.IUserAccessService;
import org.eclipse.osbp.utils.common.EntityUtils;
-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.cubedsl.CubeLevel;
@@ -133,6 +133,7 @@
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.PropertyLookup;
import org.eclipse.osbp.xtext.table.common.TableFilterDecorator;
import org.eclipse.osbp.xtext.table.jvmmodel.DoubleComparator;
import org.eclipse.osbp.xtext.table.jvmmodel.FormatAttribute;
@@ -165,6 +166,9 @@
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
import org.slf4j.Logger;
/**
@@ -193,7 +197,7 @@
@Inject
@Extension
- private CommonUtils _commonUtils;
+ private AnnotationExtension _annotationExtension;
@Inject
@Named(Constants.FILE_EXTENSIONS)
@@ -203,6 +207,8 @@
private final String CONVERT_METHOD_PREFIX = "getStringTo";
+ private String binderClassName = "";
+
public String getFileExtension() {
return null;
}
@@ -211,6 +217,27 @@
* <p>infer method dispatches the necessary routines to build fields, setter, getter, constructors and methods of the generated code.</p>
*/
protected void _infer(final TablePackage pkg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
+ String _string = this._iQualifiedNameProvider.getFullyQualifiedName(pkg).toString();
+ String _plus = (_string + ".");
+ String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(pkg).getLastSegment());
+ String _plus_1 = (_plus + _firstUpper);
+ String _plus_2 = (_plus_1 + "ServiceBinder");
+ this.binderClassName = _plus_2;
+ final JvmGenericType clsBinder = this._jvmTypesBuilder.toClass(pkg, pkg.getName().toString().concat("ServiceBinder"));
+ clsBinder.setSimpleName(StringExtensions.toFirstUpper(clsBinder.getSimpleName()));
+ final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
+ EList<JvmAnnotationReference> _annotations = it.getAnnotations();
+ JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(SuppressWarnings.class, "serial");
+ this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
+ EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
+ JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Component.class);
+ this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
+ it.setPackageName(this._iQualifiedNameProvider.getFullyQualifiedName(pkg).toString());
+ this._jvmTypesBuilder.setFileHeader(it, this._jvmTypesBuilder.getDocumentation(pkg));
+ this.toBinderFields(it, pkg);
+ this.toBinderOperations(it, pkg);
+ };
+ acceptor.<JvmGenericType>accept(clsBinder, _function);
EList<Table> _tables = pkg.getTables();
for (final Table table : _tables) {
{
@@ -253,13 +280,13 @@
if (_isSelection_1) {
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(ITableRowCheckListener.CheckRecipient.class));
}
- final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
+ final Procedure1<JvmGenericType> _function_1 = (JvmGenericType it) -> {
this.toFields(it, table);
this.toConstructor(it, table);
this.toGetterSetter(it, table);
this.toOperations(it, pkg, table);
};
- acceptor.<JvmGenericType>accept(cls, _function);
+ acceptor.<JvmGenericType>accept(cls, _function_1);
boolean _isEmbedded_2 = this.isEmbedded(table);
if (_isEmbedded_2) {
String _concat = table.getName().concat(StringExtensions.toFirstUpper(this.fileExtension)).concat("Embedded");
@@ -269,25 +296,25 @@
final String tableClsName = clsName;
contextCls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IContextFunction.class));
contextCls.setSimpleName(StringExtensions.toFirstUpper(contextCls.getSimpleName()));
- final Procedure1<JvmGenericType> _function_1 = (JvmGenericType it) -> {
+ final Procedure1<JvmGenericType> _function_2 = (JvmGenericType it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(
Component.class);
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IContextFunction.class);
- this._commonUtils.addAnnAttr(annotationRef, table, "service",
+ this._annotationExtension.addAnnAttr(annotationRef, table, "service",
((JvmTypeReference) _typeRef));
StringConcatenation _builder = new StringConcatenation();
_builder.append(IContextFunction.SERVICE_CONTEXT_KEY);
_builder.append("=");
- String _firstUpper = StringExtensions.toFirstUpper(table.getName());
- _builder.append(_firstUpper);
+ String _firstUpper_1 = StringExtensions.toFirstUpper(table.getName());
+ _builder.append(_firstUpper_1);
String propContent = _builder.toString();
- this._commonUtils.addAnnAttr(annotationRef, table, "property", propContent);
+ this._annotationExtension.addAnnAttr(annotationRef, table, "property", propContent);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setPackageName(this._iQualifiedNameProvider.getFullyQualifiedName(pkg).toString());
this.toContextOperations(it, table, tableClsName);
};
- acceptor.<JvmGenericType>accept(contextCls, _function_1);
+ acceptor.<JvmGenericType>accept(contextCls, _function_2);
}
}
}
@@ -1174,9 +1201,9 @@
_builder.newLineIfNotEmpty();
_builder.append("LinkedHashMap<String, EventDispatcherEvent> selectionEvntList = new LinkedHashMap<>();");
_builder.newLine();
- _builder.append("PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);");
+ _builder.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
_builder.newLine();
- _builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, \"");
+ _builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, \"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
_builder.append(_fullyQualifiedName);
_builder.append(".");
@@ -1187,8 +1214,6 @@
_builder.append(_fullyQualifiedName_1);
_builder.append("\");");
_builder.newLineIfNotEmpty();
- _builder.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder.newLine();
_builder.append("selectionEvntList.put(\"");
QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
_builder.append(_fullyQualifiedName_2);
@@ -1200,15 +1225,13 @@
{
Collection<String> _values = this.getUniqueReferenceFQIdName(entity).values();
for(final String entityReferenceFQIdName : _values) {
- _builder.append("evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, \"");
+ _builder.append("evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, \"");
_builder.append(entityReferenceFQIdName);
_builder.append("\", \"");
QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(table);
_builder.append(_fullyQualifiedName_3);
_builder.append("\");");
_builder.newLineIfNotEmpty();
- _builder.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder.newLine();
_builder.append("selectionEvntList.put(\"");
_builder.append(entityReferenceFQIdName);
_builder.append("\", evnt);");
@@ -1238,18 +1261,15 @@
_builder.append("if(changedFilter != null) {");
_builder.newLine();
_builder.append("\t");
- _builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, changedFilter.getName(), \"");
+ _builder.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, changedFilter.getName(), \"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(table);
_builder.append(_fullyQualifiedName, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
- _builder.append("PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder.newLine();
- _builder.append("\t");
_builder.append("evnt.addData(changedFilter.getSelectedData());");
_builder.newLine();
_builder.append("\t");
@@ -1273,13 +1293,16 @@
_builder.append("switch(event.getCommand()) {");
_builder.newLine();
_builder.append("\t");
- _builder.append("case SELECT:");
+ _builder.append("case SELECT: ");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("PerspectiveImpl perspective = (PerspectiveImpl) eclipseContext.getActive(MPerspective.class);");
+ _builder.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("if(event.getPerspective() == null || (perspective != null && event.getPerspective().equals(perspective))){ ");
+ _builder.append("ArrayList<String> allowedSenderParts = (ArrayList<String>) eclipseContext.getActive(MPart.class).getTransientData().get(IPerspectiveProvider.EventDispatcherConstants.ACCEPTED_SENDERS);");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("if((event.getPerspective() == null || (perspective != null && event.getPerspective().equals(perspective))) && ((allowedSenderParts != null && allowedSenderParts.contains(event.getSender())) || allowedSenderParts == null)){");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("if(!event.getSender().equals(\"");
@@ -1411,13 +1434,16 @@
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
+ _builder.append("/* must be activated if sure that the filter is to be refreshed");
+ _builder.newLine();
+ _builder.append("\t\t");
_builder.append("if (filterGenerator != null) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("filterGenerator.updateFilter();");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("}");
+ _builder.append("}*/");
_builder.newLine();
_builder.append("\t\t");
_builder.append("break;");
@@ -1467,6 +1493,10 @@
_builder_2.append("// TODO: GridRefresh");
_builder_2.newLine();
_builder_2.append("\t\t\t");
+ _builder_2.append("\t");
+ _builder_2.append("grid.refreshData();");
+ _builder_2.newLine();
+ _builder_2.append("\t\t\t");
_builder_2.append("}");
_builder_2.newLine();
}
@@ -2319,8 +2349,11 @@
_builder_1.append(" \t");
_builder_1.append("taskClient.operations(dataSourceContainer.getTaskId((int)table.getValue()), user, null, BPMOperation.Start);");
_builder_1.newLine();
+ _builder_1.append(" \t");
+ _builder_1.append("MPerspective perspective = eclipseContext.get(MPerspective.class);");
+ _builder_1.newLine();
_builder_1.append("\t\t");
- _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.CLOSE, \"UserMenu\", \"");
+ _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, \"UserMenu\", \"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(table);
_builder_1.append(_fullyQualifiedName, "\t\t");
_builder_1.append("\");");
@@ -5727,10 +5760,10 @@
boolean _tripleNotEquals = (_primaryKeyAttribute != null);
if (_tripleNotEquals) {
_builder_1.append("\t\t");
- _builder_1.append("PerspectiveImpl perspective = (PerspectiveImpl) getContext().get(MPerspective.class);");
+ _builder_1.append("MPerspective perspective = getContext().get(MPerspective.class);");
_builder_1.newLine();
_builder_1.append("\t\t");
- _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, \"");
+ _builder_1.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, \"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(this.baseType(entity));
_builder_1.append(_fullyQualifiedName, "\t\t");
_builder_1.append(".");
@@ -5742,9 +5775,6 @@
_builder_1.append("\");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
- _builder_1.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder_1.newLine();
- _builder_1.append("\t\t");
_builder_1.append("evnt.addItem(EventDispatcherDataTag.ID, dataSourceContainer.getValueByProperty(selection, \"");
String _lowerCase = alias.toLowerCase();
_builder_1.append(_lowerCase, "\t\t");
@@ -5773,16 +5803,12 @@
_builder_1.newLine();
_builder_1.append("\t\t");
_builder_1.append("\t\t\t");
- _builder_1.append("evnt = new EventDispatcherEvent(EventDispatcherCommand.SELECT, primary.getEntityName() + \".\" + primary.getAttributeName(), \"");
+ _builder_1.append("evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, primary.getEntityName() + \".\" + primary.getAttributeName(), \"");
QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(table);
_builder_1.append(_fullyQualifiedName_3, "\t\t\t\t\t");
_builder_1.append("\");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
- _builder_1.append(" \t\t");
- _builder_1.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder_1.newLine();
- _builder_1.append("\t\t");
_builder_1.append("\t\t\t");
_builder_1.append("evnt.addItem(EventDispatcherDataTag.ID, primaryValue);");
_builder_1.newLine();
@@ -5826,7 +5852,7 @@
_builder_1.append("\t\t");
_builder_1.append("EventDispatcherEvent evnt");
_builder_1.append(evntCnt, "\t\t");
- _builder_1.append(" = new EventDispatcherEvent(EventDispatcherCommand.SELECT, \"");
+ _builder_1.append(" = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, \"");
TableValueElement _source_2 = event.getSource();
String _valueRef = ((TableOrdinal) _source_2).getValueRef();
_builder_1.append(_valueRef, "\t\t");
@@ -5841,7 +5867,7 @@
_builder_1.append("\t\t");
_builder_1.append("EventDispatcherEvent evnt");
_builder_1.append(evntCnt, "\t\t");
- _builder_1.append(" = new EventDispatcherEvent(EventDispatcherCommand.SELECT, \"");
+ _builder_1.append(" = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, \"");
TableValueElement _source_4 = event.getSource();
String _name = ((TableAttribute) _source_4).getValueRef().getAttributeRef().getName();
_builder_1.append(_name, "\t\t");
@@ -5853,9 +5879,6 @@
}
}
}
- _builder_1.append("\t\t");
- _builder_1.append("if(perspective != null){evnt.setPerspective(perspective);}");
- _builder_1.newLine();
{
TableValueElement _source_5 = event.getSource();
if ((_source_5 instanceof TableOrdinal)) {
@@ -5933,7 +5956,7 @@
_builder.append("Object columnId = event.getPropertyId();");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("user.addToProperties(this.getClass().getEnclosingClass().getCanonicalName() + \".\" + columnId.toString() + \".\" + \"width\", String.valueOf(width));");
+ _builder.append("user.addToProperties(this.getClass().getEnclosingClass().getCanonicalName() + \".\" + columnId.toString() + \".width\", String.valueOf(width));");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
@@ -5958,19 +5981,41 @@
_builder.append("Object source = event.getSource();");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + \".\" + \"columns\";");
+ _builder.append("String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + \".columns\";");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("if (source instanceof CustomTable){");
+ _builder.append("if (source instanceof CellSetFilterTable){");
_builder.newLine();
_builder.append("\t\t\t");
- _builder.append("Object[] visibleColumns = ((CustomTable)source).getVisibleColumns();");
+ _builder.append("Map<Object, Integer> visibleColumnsPositions = new HashMap<>();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("Object[] visibleColumns = ((CellSetFilterTable)source).getVisibleColumns();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("for (int i = 0; i < visibleColumns.length; i++) {");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("CellSetIndexedContainer container = ((CellSetFilterTable)source).getCellSetIndexedContainer();");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ _builder.append("Object visibleColumnKey = visibleColumns[i];");
+ _builder.newLine();
+ _builder.append("\t\t\t\t");
+ CharSequence _positionMembersHashCode = this.getPositionMembersHashCode();
+ _builder.append(_positionMembersHashCode, "\t\t\t\t");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t\t\t");
+ _builder.append("visibleColumnsPositions.put(visibleColumnKey, membersHash);");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("if (visibleColumns!=null){");
_builder.newLine();
_builder.append("\t\t\t\t");
- _builder.append("user.addToProperties(propertyKey, visibleColumns);");
+ _builder.append("user.addToProperties(propertyKey, visibleColumnsPositions);");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
@@ -5986,6 +6031,31 @@
return _builder;
}
+ private CharSequence getPositionMembersHashCode() {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// creates a hash code by the column position members\t\t");
+ _builder.newLine();
+ _builder.append("int membersHash = 0;");
+ _builder.newLine();
+ _builder.append("if (container != null) {");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("List<DerivedMember> members = container.getColumnPosition(visibleColumnKey).getMembers();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (DerivedMember member : members) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("membersHash += (member.getUniqueName() != null) ? member.getUniqueName().hashCode() : member.hashCode();");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+
public CharSequence columnCollapsedListener() {
StringConcatenation _builder = new StringConcatenation();
_builder.append("table.addColumnCollapseListener(new ColumnCollapseListener(){");
@@ -6003,7 +6073,7 @@
_builder.append("Object source = event.getSource();");
_builder.newLine();
_builder.append("\t\t");
- _builder.append("String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + \".\" + columnId.toString() + \".\" + \"collapsed\";");
+ _builder.append("String propertyKey = this.getClass().getEnclosingClass().getCanonicalName() + \".\" + columnId.toString() + \".collapsed\";");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (source instanceof CustomTable){");
@@ -6036,12 +6106,72 @@
public CharSequence tableSettingsByUserProperties() {
StringConcatenation _builder = new StringConcatenation();
+ _builder.append("// Setting the order of the columns via the visibleColumns list");
+ _builder.newLine();
+ _builder.append("Map<Object, Integer> visibleColumnsMap = user.getColumnUtil().getVisibleColumns(this.getClass().getCanonicalName() + \".columns\");");
+ _builder.newLine();
+ _builder.append("if (visibleColumnsMap != null){");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("boolean unmodifiedVisibleColumns = true;");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("for (Object visibleColumnKey : visibleColumnsMap.keySet()) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("CellSetIndexedContainer container = dataSourceContainer;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ CharSequence _positionMembersHashCode = this.getPositionMembersHashCode();
+ _builder.append(_positionMembersHashCode, "\t\t");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t\t");
+ _builder.append("if (membersHash != visibleColumnsMap.get(visibleColumnKey)) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("unmodifiedVisibleColumns = false;");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("break;");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("if (unmodifiedVisibleColumns) {");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("try {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("Object[] visibleColumns = visibleColumnsMap.values().toArray();");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("table.setVisibleColumns(visibleColumns );");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("} catch (IllegalArgumentException e) {");
+ _builder.newLine();
+ _builder.append("\t\t\t");
+ _builder.append("// this occurs if a saved column is no longer existing due to model changes");
+ _builder.newLine();
+ _builder.append("\t\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("}");
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
_builder.append("// Setting table columns width from the persisted user properties");
_builder.newLine();
_builder.append("for (Object visibleId : table.getVisibleColumns()) {");
_builder.newLine();
_builder.append("\t");
- _builder.append("String widthStr = user.getColumnUtil().getColumnWidth(this.getClass().getCanonicalName() + \".\" + visibleId.toString() + \".\" + \"width\");");
+ _builder.append("String widthStr = user.getColumnUtil().getColumnWidth(this.getClass().getCanonicalName() + \".\" + visibleId.toString() + \".width\");");
_builder.newLine();
_builder.append("\t");
_builder.append("if (widthStr!= null) {");
@@ -6071,7 +6201,7 @@
_builder.append("for (Object propertyId : table.getContainerDataSource().getContainerPropertyIds()) {");
_builder.newLine();
_builder.append("\t");
- _builder.append("String collapsedColumn = user.getColumnUtil().getColumnCollapsed(this.getClass().getCanonicalName() + \".\" + propertyId + \".\" + \"collapsed\");");
+ _builder.append("String collapsedColumn = user.getColumnUtil().getColumnCollapsed(this.getClass().getCanonicalName() + \".\" + propertyId + \".collapsed\");");
_builder.newLine();
_builder.append("\t");
_builder.append("try {");
@@ -6094,30 +6224,6 @@
_builder.append("\t");
_builder.append("}");
_builder.newLine();
- _builder.append("\t");
- _builder.append("Object[] visibleColumns = user.getColumnUtil().getVisibleColumns(this.getClass().getCanonicalName() + \".\" + \"columns\");");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("if (visibleColumns != null){");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("try {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("table.setVisibleColumns(visibleColumns);");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("} catch (IllegalArgumentException e) {");
- _builder.newLine();
- _builder.append("\t\t\t");
- _builder.append("// this occurs if a saved column is no longer existing due to model changes");
- _builder.newLine();
- _builder.append("\t\t");
- _builder.append("}");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("}");
- _builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
@@ -6256,16 +6362,8 @@
_builder.newLine();
_builder.append("\t");
_builder.append("layoutManager.setLabelValue(dslMetadataService.translate(locale.toLanguageTag(), \"");
- {
- boolean _isDescription = table.isDescription();
- if (_isDescription) {
- String _descriptionValue_1 = table.getDescriptionValue();
- _builder.append(_descriptionValue_1, "\t");
- } else {
- String _name = table.getName();
- _builder.append(_name, "\t");
- }
- }
+ String _name = table.getName();
+ _builder.append(_name, "\t");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
_builder.append("}");
@@ -6433,6 +6531,91 @@
return _xifexpression;
}
+ public void toBinderFields(final JvmDeclaredType type, final TablePackage tablePckg) {
+ JvmField field = null;
+ final Procedure1<JvmField> _function = (JvmField it) -> {
+ final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("org.slf4j.LoggerFactory.getLogger(\"servicebinder\")");
+ it_1.append(_builder);
+ };
+ this._jvmTypesBuilder.setInitializer(it, _function_1);
+ };
+ field = this._jvmTypesBuilder.toField(tablePckg, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function);
+ field.setStatic(true);
+ field.setVisibility(JvmVisibility.PRIVATE);
+ EList<JvmMember> _members = type.getMembers();
+ this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
+ field = this._jvmTypesBuilder.toField(tablePckg, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
+ field.setStatic(true);
+ field.setVisibility(JvmVisibility.PRIVATE);
+ EList<JvmMember> _members_1 = type.getMembers();
+ this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
+ }
+
+ public void toBinderOperations(final JvmDeclaredType type, final TablePackage tablePckg) {
+ EList<JvmMember> _members = type.getMembers();
+ final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
+ it.setVisibility(JvmVisibility.PUBLIC);
+ it.setStatic(true);
+ final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("return userAccessService;");
+ it_1.append(_builder);
+ };
+ this._jvmTypesBuilder.setBody(it, _function_1);
+ };
+ JvmOperation _method = this._jvmTypesBuilder.toMethod(tablePckg, "getUserAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class), _function);
+ this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
+ EList<JvmMember> _members_1 = type.getMembers();
+ final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
+ JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Reference.class);
+ this._annotationExtension.addAnnAttr(annotationRef, tablePckg, "cardinality", ReferenceCardinality.MANDATORY);
+ this._annotationExtension.addAnnAttr(annotationRef, tablePckg, "policy", ReferencePolicy.STATIC);
+ EList<JvmAnnotationReference> _annotations = it.getAnnotations();
+ this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
+ it.setVisibility(JvmVisibility.PUBLIC);
+ it.setSynchronized(true);
+ EList<JvmFormalParameter> _parameters = it.getParameters();
+ JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(tablePckg, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
+ this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
+ final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
+ StringConcatenation _builder = new StringConcatenation();
+ String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(tablePckg).getLastSegment());
+ String _plus = (_firstUpper + "ServiceBinder");
+ _builder.append(_plus);
+ _builder.append(".userAccessService = userAccessService;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("log.debug(\"Datamart UserAccessService bound\");");
+ it_1.append(_builder);
+ };
+ this._jvmTypesBuilder.setBody(it, _function_2);
+ };
+ JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(tablePckg, "bindUserAccessMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_1);
+ this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
+ EList<JvmMember> _members_2 = type.getMembers();
+ final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
+ it.setVisibility(JvmVisibility.PUBLIC);
+ it.setSynchronized(true);
+ EList<JvmFormalParameter> _parameters = it.getParameters();
+ JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(tablePckg, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class));
+ this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
+ final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
+ StringConcatenation _builder = new StringConcatenation();
+ String _firstUpper = StringExtensions.toFirstUpper(this._iQualifiedNameProvider.getFullyQualifiedName(tablePckg).getLastSegment());
+ String _plus = (_firstUpper + "ServiceBinder");
+ _builder.append(_plus);
+ _builder.append(".userAccessService = null;");
+ _builder.newLineIfNotEmpty();
+ _builder.append("log.debug(\"Datamart UserAccessService unbound\");");
+ it_1.append(_builder);
+ };
+ this._jvmTypesBuilder.setBody(it, _function_3);
+ };
+ JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(tablePckg, "unbindUserAccessMethod", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
+ this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
+ }
+
public void infer(final EObject pkg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (pkg instanceof TablePackage) {
_infer((TablePackage)pkg, acceptor, isPreIndexingPhase);
diff --git a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
index c2eebc0..d7da3c2 100644
--- a/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
+++ b/org.eclipse.osbp.xtext.table/xtend-gen/org/eclipse/osbp/xtext/table/jvmmodel/TableModelGenerator.java
@@ -51,7 +51,7 @@
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
-import org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.osbp.bpm.api.BPMOperation;
@@ -76,6 +76,7 @@
import org.eclipse.osbp.ui.api.datamart.DatamartPrimary;
import org.eclipse.osbp.ui.api.datamart.IDatamartFilterGenerator;
import org.eclipse.osbp.ui.api.e4.IE4Table;
+import org.eclipse.osbp.ui.api.perspective.IPerspectiveProvider;
import org.eclipse.osbp.ui.api.themes.IThemeResourceService;
import org.eclipse.osbp.utils.constants.ExtendedDate;
import org.eclipse.osbp.utils.vaadin.SelectUserWindow;
@@ -222,8 +223,9 @@
PrintWriter.class,
LinkedHashMap.class,
IDualData.class,
- PerspectiveImpl.class,
- MPerspective.class);
+ MPerspective.class,
+ MPart.class,
+ IPerspectiveProvider.class);
_xblockexpression = super.createAppendable(context, importManager, config);
}
return _xblockexpression;