blob: 5a72fd8b1b622d80b09205889b88858a4835719f [file] [log] [blame]
/**
* 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
*
* ============================================================================
* Initial contribution:
* Loetz GmbH & Co. KG
*
* generated by xtext
*/
package org.eclipse.osbp.xtext.dialogdsl.jvmmodel;
import com.google.common.base.Objects;
import com.vaadin.ui.VerticalLayout;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.IContextFunction;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.core.api.persistence.IPersistenceService;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
import org.eclipse.osbp.dsl.semantic.entity.LEntity;
import org.eclipse.osbp.dsl.semantic.entity.LEntityAttribute;
import org.eclipse.osbp.ecview.semantic.uimodel.UiBeanSlot;
import org.eclipse.osbp.ecview.semantic.uimodel.UiModel;
import org.eclipse.osbp.ecview.semantic.uimodel.UiView;
import org.eclipse.osbp.runtime.common.filter.IDTOServiceWithMutablePersistence;
import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider;
import org.eclipse.osbp.ui.api.customfields.IBlobConverter;
import org.eclipse.osbp.ui.api.customfields.IBlobService;
import org.eclipse.osbp.ui.api.statemachine.IDataProvider;
import org.eclipse.osbp.ui.api.statemachine.IPeripheral;
import org.eclipse.osbp.ui.api.statemachine.IStateMachine;
import org.eclipse.osbp.ui.api.statemachine.IStateMachineParticipant;
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.xtext.action.ActionToolbar;
import org.eclipse.osbp.xtext.action.common.IToolbarAction;
import org.eclipse.osbp.xtext.dialogdsl.Dialog;
import org.eclipse.osbp.xtext.dialogdsl.DialogPackage;
import org.eclipse.osbp.xtext.dialogdsl.common.AbstractECViewDialog;
import org.eclipse.osbp.xtext.dialogdsl.common.AbstractEmbeddedDialog;
import org.eclipse.osbp.xtext.dialogdsl.common.AbstractUIDialog;
import org.eclipse.osbp.xtext.dialogdsl.constants.DialogConstants;
import org.eclipse.osbp.xtext.dialogdsl.mapper.AutowireUiFactory;
import org.eclipse.osbp.xtext.i18n.I18NKeyGenerator;
import org.eclipse.osbp.xtext.strategy.LayoutingStrategy;
import org.eclipse.osbp.xtext.strategy.jvmmodel.StrategyDSLFocusingEnhancerCreator;
import org.eclipse.osbp.xtext.strategy.jvmmodel.StrategyDSLLayoutingStrategyCreator;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.common.types.JvmAnnotationReference;
import org.eclipse.xtext.common.types.JvmConstructor;
import org.eclipse.xtext.common.types.JvmDeclaredType;
import org.eclipse.xtext.common.types.JvmFeature;
import org.eclipse.xtext.common.types.JvmField;
import org.eclipse.xtext.common.types.JvmFormalParameter;
import org.eclipse.xtext.common.types.JvmGenericType;
import org.eclipse.xtext.common.types.JvmMember;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.common.types.JvmType;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.JvmVisibility;
import org.eclipse.xtext.common.types.util.RawSuperTypes;
import org.eclipse.xtext.naming.IQualifiedNameProvider;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.xbase.compiler.output.ITreeAppendable;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.jvmmodel.JvmAnnotationReferenceBuilder;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypeReferenceBuilder;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
/**
* Infers a JVM model from the source model.
* <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.
*/
@SuppressWarnings("all")
public class DialogDslVaaclipseViewCreator {
/**
* convenience API to build and initialize JVM types and their members.
*/
@Inject
@Extension
private JvmTypesBuilder _jvmTypesBuilder;
@Inject
@Extension
private DialogConstants _dialogConstants;
@Inject
@Extension
private IQualifiedNameProvider _iQualifiedNameProvider;
@Inject
@Extension
private StrategyDSLFocusingEnhancerCreator _strategyDSLFocusingEnhancerCreator;
@Inject
@Extension
private StrategyDSLLayoutingStrategyCreator _strategyDSLLayoutingStrategyCreator;
@Inject
@Extension
private CommonUtils _commonUtils;
private JvmAnnotationReferenceBuilder _annotationTypesBuilder;
private JvmTypeReferenceBuilder _typeReferenceBuilder;
public void createVaaclipseUI(final DialogPackage pckg, final Dialog dialog, final IJvmDeclaredTypeAcceptor acceptor, final JvmAnnotationReferenceBuilder annotationTypesBuilder, final JvmTypeReferenceBuilder typeReferenceBuilder) {
this._annotationTypesBuilder = annotationTypesBuilder;
this._typeReferenceBuilder = typeReferenceBuilder;
String uiViewName = this.getUiName(dialog);
if (((uiViewName != null) && (!uiViewName.isEmpty()))) {
StringConcatenation _builder = new StringConcatenation();
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(dialog);
_builder.append(_fullyQualifiedName);
_builder.append(this._dialogConstants.VAACLIPSE_VIEW_PREFIX);
String clsName = _builder.toString();
boolean _isEmbedded = dialog.isEmbedded();
if (_isEmbedded) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(clsName);
_builder_1.append("Embedded");
clsName = _builder_1.toString();
}
JvmGenericType cls = this._jvmTypesBuilder.toClass(dialog, clsName);
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
boolean _isEmbedded_1 = dialog.isEmbedded();
if (_isEmbedded_1) {
EList<JvmTypeReference> _superTypes = it.getSuperTypes();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(AbstractEmbeddedDialog.class,
this._typeReferenceBuilder.typeRef(this.getMainBeanslotType(dialog)));
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef);
EList<JvmTypeReference> _superTypes_1 = it.getSuperTypes();
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(IViewEmbeddedProvider.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_1, _typeRef_1);
} else {
boolean _isStateful = dialog.isStateful();
if (_isStateful) {
EList<JvmTypeReference> _superTypes_2 = it.getSuperTypes();
JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(AbstractUIDialog.class);
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_2, _typeRef_2);
} else {
EList<JvmTypeReference> _superTypes_3 = it.getSuperTypes();
JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(AbstractECViewDialog.class,
this._typeReferenceBuilder.typeRef(this.getMainBeanslotType(dialog)));
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_3, _typeRef_3);
}
}
this.toConstructor(it, dialog);
this.toFields(it, dialog);
this.toOperations(it, dialog, pckg);
};
acceptor.<JvmGenericType>accept(cls, _function);
boolean _isEmbedded_1 = dialog.isEmbedded();
if (_isEmbedded_1) {
StringConcatenation _builder_2 = new StringConcatenation();
String _name = dialog.getName();
_builder_2.append(_name);
_builder_2.append(this._dialogConstants.VAACLIPSE_VIEW_PREFIX);
_builder_2.append("EmbeddedContextFunction");
String contextClassName = _builder_2.toString();
final JvmGenericType contextCls = this._jvmTypesBuilder.toClass(pckg, contextClassName);
final String dialogClsName = clsName;
contextCls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IContextFunction.class));
contextCls.setSimpleName(StringExtensions.toFirstUpper(contextCls.getSimpleName()));
final Procedure1<JvmGenericType> _function_1 = (JvmGenericType it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Component.class);
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IContextFunction.class);
this._commonUtils.addAnnAttr(annotationRef, dialog, "service", ((JvmTypeReference) _typeRef));
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(IContextFunction.SERVICE_CONTEXT_KEY);
_builder_3.append("=");
String _firstUpper = StringExtensions.toFirstUpper(dialog.getName());
_builder_3.append(_firstUpper);
String propContent = _builder_3.toString();
this._commonUtils.addAnnAttr(annotationRef, dialog, "property", propContent);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setPackageName(this._iQualifiedNameProvider.getFullyQualifiedName(pckg).toString());
this.toContextOperations(it, dialog, dialogClsName);
};
acceptor.<JvmGenericType>accept(contextCls, _function_1);
}
}
}
public String getMainBeanslotType(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getDtoFQN(dialog.getDto());
} else {
UiBeanSlot _mainBeanSlot = this.getMainBeanSlot(dialog);
JvmTypeReference _jvmType = null;
if (_mainBeanSlot!=null) {
_jvmType=_mainBeanSlot.getJvmType();
}
return _jvmType.getQualifiedName();
}
}
public String getUiName(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getECViewId(dialog);
} else {
return dialog.getUiView().getName();
}
}
/**
* <p>create an injectable context function to be used by an e4 application.
*
* @param type
* @param dialog
* @param clsName
*/
public void toContextOperations(final JvmGenericType type, final Dialog dialog, final String clsName) {
JvmOperation operation = null;
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(dialog, "contextKey", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("MApplication application = context.get(MApplication.class);");
_builder.newLine();
_builder.append("IEclipseContext appCtx = application.getContext();");
_builder.newLine();
_builder.append("IViewEmbeddedProvider provider = ContextInjectionFactory.make(");
_builder.append(clsName);
_builder.append(".class, appCtx);");
_builder.newLineIfNotEmpty();
_builder.append("appCtx.set(IViewEmbeddedProvider.class, provider);");
_builder.newLine();
_builder.append("return provider;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "compute", this._typeReferenceBuilder.typeRef(Object.class), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
/**
* <p>build the constructors to be used by an e4 application.
*
* @param type
* @param dialog
*/
public void toConstructor(final JvmDeclaredType type, final Dialog dialog) {
boolean _isEmbedded = dialog.isEmbedded();
if (_isEmbedded) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super();");
_builder.newLine();
_builder.append("uuid = UUID.randomUUID().toString();");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(dialog, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
} else {
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmConstructor> _function_1 = (JvmConstructor it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "parent", this._typeReferenceBuilder.typeRef(VerticalLayout.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(dialog, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmFormalParameter> _parameters_2 = it.getParameters();
JvmFormalParameter _parameter_2 = this._jvmTypesBuilder.toParameter(dialog, "app", this._typeReferenceBuilder.typeRef(MApplication.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super(parent,context,app);");
_builder.newLine();
_builder.append("uuid = UUID.randomUUID().toString();");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmConstructor _constructor_1 = this._jvmTypesBuilder.toConstructor(dialog, _function_1);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_1, _constructor_1);
}
}
/**
* <p>build the class variables.
*
* @param type
* @param dialog
*/
public void toFields(final JvmDeclaredType type, final Dialog dialog) {
JvmField field = null;
final Procedure1<JvmField> _function = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("LoggerFactory.getLogger(\"vaaclipseDialog\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_1);
};
field = this._jvmTypesBuilder.toField(dialog, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function);
field.setFinal(true);
field.setStatic(true);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
}
/**
* <p>build the methods.
*
* @param type
* @param dialog
* @param pckg
*/
public void toOperations(final JvmDeclaredType type, final Dialog dialog, final DialogPackage pckg) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _uiModelPackageName = this.getUiModelPackageName(dialog);
_builder.append(_uiModelPackageName);
_builder.append(".");
String _viewName = this.getViewName(dialog);
_builder.append(_viewName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "getViewId", this._typeReferenceBuilder.typeRef(String.class), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
boolean _isStateful = dialog.isStateful();
if (_isStateful) {
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "user", this._typeReferenceBuilder.typeRef(IUser.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(dialog, "blobService", this._typeReferenceBuilder.typeRef(IBlobService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createRenderingParams = this.createRenderingParams(dialog.getUiView());
_builder.append(_createRenderingParams);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(dialog, "createRenderingParams", this._typeReferenceBuilder.typeRef(Map.class,
this._typeReferenceBuilder.typeRef(String.class),
this._typeReferenceBuilder.typeRef(Object.class)), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "locale", this._typeReferenceBuilder.typeRef(Locale.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _localeChanged = this.localeChanged(dialog.getUiView());
_builder.append(_localeChanged);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(dialog, "localeChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
} else {
final UiBeanSlot mainBeanSlot = this.getMainBeanSlot(dialog);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _qualifiedName = mainBeanSlot.getJvmType().getType().getQualifiedName();
_builder.append(_qualifiedName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(dialog, "getBaseDtoName", this._typeReferenceBuilder.typeRef(String.class), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _qualifiedEntityNameForQualifiedDtoName = EntityUtils.getQualifiedEntityNameForQualifiedDtoName(mainBeanSlot.getJvmType().getType().getQualifiedName());
_builder.append(_qualifiedEntityNameForQualifiedDtoName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(dialog, "getBaseEntityName", this._typeReferenceBuilder.typeRef(String.class), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
EList<JvmMember> _members_5 = type.getMembers();
final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "savedDto", this._typeReferenceBuilder.typeRef(mainBeanSlot.getJvmType().getQualifiedName()));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return ");
String _idForDto = this.getIdForDto(mainBeanSlot);
_builder.append(_idForDto);
_builder.append(";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_6);
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(dialog, "getIdForDto", this._typeReferenceBuilder.typeRef(Object.class), _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
EList<JvmMember> _members_6 = type.getMembers();
final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _entityName = this.getEntityName(mainBeanSlot.getJvmType().getType());
_builder.append(_entityName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_7);
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(dialog, "getDataName", this._typeReferenceBuilder.typeRef(String.class), _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
CharSequence layoutNameTemp = "";
LayoutingStrategy _layout = null;
if (dialog!=null) {
_layout=dialog.getLayout();
}
boolean _tripleNotEquals = (_layout != null);
if (_tripleNotEquals) {
LayoutingStrategy _layout_1 = null;
if (dialog!=null) {
_layout_1=dialog.getLayout();
}
layoutNameTemp = this._strategyDSLLayoutingStrategyCreator.getNotDefaultStrategyClassName(_layout_1);
}
final CharSequence layoutName = layoutNameTemp;
EList<JvmMember> _members_7 = type.getMembers();
final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
_builder.append(layoutName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_8);
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(dialog, "getLayoutingStrategyId", this._typeReferenceBuilder.typeRef(String.class), _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
EList<JvmMember> _members_8 = type.getMembers();
final Procedure1<JvmOperation> _function_8 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_9 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _entityFQN = this.getEntityFQN(mainBeanSlot.getJvmType().getType());
_builder.append(_entityFQN);
_builder.append(".");
String _idAttributeName = EntityUtils.getDto(mainBeanSlot.getJvmType().getType()).getIdAttributeName();
_builder.append(_idAttributeName);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_9);
};
JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(dialog, "getPrimaryKey", this._typeReferenceBuilder.typeRef(String.class), _function_8);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
EList<JvmMember> _members_9 = type.getMembers();
final Procedure1<JvmOperation> _function_9 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_10 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return (IDTOServiceWithMutablePersistence<");
String _qualifiedName = mainBeanSlot.getJvmType().getQualifiedName();
_builder.append(_qualifiedName);
_builder.append(">) DtoServiceAccess");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t\t");
_builder.append(".getService(");
String _qualifiedName_1 = mainBeanSlot.getJvmType().getQualifiedName();
_builder.append(_qualifiedName_1, "\t\t\t\t\t");
_builder.append(".class);");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_10);
};
JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(dialog, "getDtoService", this._typeReferenceBuilder.typeRef(IDTOServiceWithMutablePersistence.class,
this._typeReferenceBuilder.typeRef(mainBeanSlot.getJvmType().getQualifiedName())), _function_9);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
EList<JvmMember> _members_10 = type.getMembers();
final Procedure1<JvmOperation> _function_10 = (JvmOperation it) -> {
LEntity _entityFromDto = EntityUtils.getEntityFromDto(mainBeanSlot.getJvmType().getType());
final LEntity entity = ((LEntity) _entityFromDto);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "persistenceService", this._typeReferenceBuilder.typeRef(IPersistenceService.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_11 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_11);
boolean _notEquals = (!Objects.equal(entity, null));
if (_notEquals) {
final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("persistenceService.registerPersistenceUnit(\"");
String _persistenceUnit = null;
if (entity!=null) {
_persistenceUnit=entity.getPersistenceUnit();
}
_builder.append(_persistenceUnit);
_builder.append("\", ");
_builder.newLineIfNotEmpty();
QualifiedName _fullyQualifiedName = null;
if (entity!=null) {
_fullyQualifiedName=this._iQualifiedNameProvider.getFullyQualifiedName(entity);
}
_builder.append(_fullyQualifiedName);
_builder.append(".class);");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"PersistenceService registered\");");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_12);
}
};
JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(dialog, "registerPersistenceUnit", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_10);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
EList<JvmMember> _members_11 = type.getMembers();
final Procedure1<JvmOperation> _function_11 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_12 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
{
ActionToolbar _toolbar = dialog.getToolbar();
boolean _notEquals = (!Objects.equal(_toolbar, null));
if (_notEquals) {
_builder.append("return new ");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(dialog.getToolbar());
_builder.append(_fullyQualifiedName);
_builder.append("Toolbar(uuid);");
} else {
_builder.append("return null;");
}
}
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_12);
};
JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(dialog, "createToobarHelper", this._typeReferenceBuilder.typeRef(IToolbarAction.class), _function_11);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
EList<JvmMember> _members_12 = type.getMembers();
final Procedure1<JvmOperation> _function_12 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_13 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _key = I18NKeyGenerator.key(dialog.getDescriptionValue());
_builder.append(_key);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_13);
};
JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(dialog, "getBindingPropertyName", this._typeReferenceBuilder.typeRef(String.class), _function_12);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12);
}
}
public boolean containsSuperType(final JvmType type, final String fqn) {
if ((!(type instanceof JvmDeclaredType))) {
return false;
}
return new RawSuperTypes().collectNames(type).contains(fqn);
}
/**
* @param type
* @return
*/
public String getEntityName(final JvmType type) {
LEntity entity = EntityUtils.getEntityFromDto(type);
StringConcatenation _builder = new StringConcatenation();
String _name = null;
if (entity!=null) {
_name=entity.getName();
}
_builder.append(_name);
return _builder.toString();
}
public String getEntityFQN(final JvmType type) {
LEntity entity = EntityUtils.getEntityFromDto(type);
StringConcatenation _builder = new StringConcatenation();
QualifiedName _fullyQualifiedName = null;
if (entity!=null) {
_fullyQualifiedName=this._iQualifiedNameProvider.getFullyQualifiedName(entity);
}
_builder.append(_fullyQualifiedName);
return _builder.toString();
}
/**
* @param slot
* @return
*/
public String getIdForDto(final UiBeanSlot slot) {
final JvmType type = slot.getJvmType().getType();
if ((type instanceof JvmDeclaredType)) {
final Iterable<JvmFeature> idList = ((JvmDeclaredType) type).findAllFeaturesByName("id");
boolean _isEmpty = IterableExtensions.isEmpty(idList);
if (_isEmpty) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("null");
return _builder.toString();
} else {
for (final JvmFeature id : idList) {
if ((id instanceof JvmField)) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("savedDto.getId()");
return _builder_1.toString();
}
}
}
}
StringConcatenation _builder_2 = new StringConcatenation();
return _builder_2.toString();
}
/**
* Provides the name of the first found bean slot defined in the ui view
*
* @param dialog
* @return
*/
public UiBeanSlot getMainBeanSlot(final Dialog dialog) {
UiBeanSlot _xifexpression = null;
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
final UiBeanSlot slot = AutowireUiFactory.createBeanSlot(dialog.getDto());
final JvmTypeReference typeRef = this._typeReferenceBuilder.typeRef(AutowireUiFactory.getDtoFQN(dialog.getDto()));
slot.setJvmType(typeRef);
return slot;
} else {
EList<UiBeanSlot> _beanSlots = dialog.getUiView().getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
return uiBeanSlot;
}
}
return _xifexpression;
}
/**
* @param dialog
* @return
*/
public String createDtoServices(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// DTO Services (via DS)");
String body = _builder.toString();
EList<UiBeanSlot> _beanSlots = dialog.getUiView().getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("dto");
String _simpleName = uiBeanSlot.getJvmType().getSimpleName();
_builder_1.append(_simpleName);
_builder_1.append("Service = (IDTOServiceWithMutablePersistence<");
String _simpleName_1 = uiBeanSlot.getJvmType().getSimpleName();
_builder_1.append(_simpleName_1);
_builder_1.append(">)DtoServiceAccess.getService(");
String _simpleName_2 = uiBeanSlot.getJvmType().getSimpleName();
_builder_1.append(_simpleName_2);
_builder_1.append(".class);");
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
}
return body;
}
/**
* <p>build the data components.
*
* @param dialog
* @return
*/
public String removeOldView(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if (viewContext != null){");
_builder.newLine();
_builder.append("\t");
_builder.append("viewContext.dispose();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("if (dataArea.getComponentCount() > 0) {");
_builder.newLine();
_builder.append(" \t");
_builder.append("dataArea.removeAllComponents();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder.toString();
}
/**
* Method to subscribe the view with the event broker to receive events due to the defined in the grammar
*
* @param dialog
* @param pckg
* @return
*/
public String subscribe(final Dialog dialog, final DialogPackage pckg) {
String body = "";
int idx = 0;
EList<UiBeanSlot> _beanSlots = dialog.getUiView().getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
{
LEntity entity = EntityUtils.getEntityFromDto(uiBeanSlot.getJvmType().getType());
boolean _notEquals = (!Objects.equal(entity, null));
if (_notEquals) {
idx++;
if ((idx == 1)) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("persistenceService.registerPersistenceUnit(\"");
String _persistenceUnit = null;
if (entity!=null) {
_persistenceUnit=entity.getPersistenceUnit();
}
_builder.append(_persistenceUnit);
_builder.append("\", ");
QualifiedName _fullyQualifiedName = null;
if (entity!=null) {
_fullyQualifiedName=this._iQualifiedNameProvider.getFullyQualifiedName(entity);
}
_builder.append(_fullyQualifiedName);
_builder.append(".class);");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"PersistenceService registered\");");
body = _builder.toString();
}
}
}
}
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append("eventBroker.subscribe(EventBrokerMsg.DIALOG_STRATEGY_CHANGED,");
_builder.newLine();
_builder.append("\t");
_builder.append("strategyEventHandler);");
_builder.newLine();
body = _builder.toString();
return body;
}
/**
* Method to unsubscribe the view with the event broker to receive events due to the defined in the grammar
*
* @param dialog
* @return
*/
public String unsubscribe(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
{
ActionToolbar _toolbar = dialog.getToolbar();
boolean _notEquals = (!Objects.equal(_toolbar, null));
if (_notEquals) {
_builder.append("eventBroker.unsubscribe(dispatchActionHandler);");
_builder.newLine();
}
}
_builder.append("eventBroker.unsubscribe(strategyEventHandler);");
String unsubscribers = _builder.toString();
return unsubscribers;
}
/**
* @param jvmType
* @return
*/
public String getDtoIdGetter(final JvmTypeReference jvmType) {
return this.getDtoIdGetter(EntityUtils.getEntityFromDto(jvmType.getType()));
}
/**
* @param entity
* @return
*/
public String getDtoIdGetter(final LEntity entity) {
boolean _notEquals = (!Objects.equal(entity, null));
if (_notEquals) {
List<LEntityAttribute> _allAttributes = entity.getAllAttributes();
for (final LEntityAttribute attribute : _allAttributes) {
if ((attribute.isId() || attribute.isUuid())) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("get");
String _firstUpper = Strings.toFirstUpper(attribute.getName());
_builder.append(_firstUpper);
_builder.append("()");
return _builder.toString();
}
}
}
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("getId()");
return _builder_1.toString();
}
/**
* @param dialog
* @return
*/
public String loadBeans(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
String body = _builder.toString();
EList<UiBeanSlot> _beanSlots = dialog.getUiView().getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
{
final String simpleTypeName = uiBeanSlot.getJvmType().getSimpleName();
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("newLoaded");
_builder_1.append(simpleTypeName);
final String variableName = _builder_1.toString();
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append(simpleTypeName);
_builder_2.append(" ");
_builder_2.append(variableName);
_builder_2.append(" = null; ");
_builder_2.newLineIfNotEmpty();
_builder_2.append("Object data = event.getProperty(org.eclipse.e4.core.di.extensions.EventUtils.DATA);");
_builder_2.newLine();
_builder_2.append("if\t(data instanceof ");
_builder_2.append(simpleTypeName);
_builder_2.append(") {");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t");
_builder_2.append(variableName, "\t");
_builder_2.append(" = (");
_builder_2.append(simpleTypeName, "\t");
_builder_2.append(")data;");
_builder_2.newLineIfNotEmpty();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("else if (data instanceof EventBrokerMsg) {");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("EventBrokerMsg msg = (EventBrokerMsg)data;");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("String id = msg.getId();");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("log.debug(\"load bean with id:\"+id);");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("if (id!=null){");
_builder_2.newLine();
_builder_2.append("\t\t");
_builder_2.append("try {");
_builder_2.newLine();
_builder_2.append("\t\t\t");
_builder_2.append(variableName, "\t\t\t");
_builder_2.append(" = dto");
_builder_2.append(simpleTypeName, "\t\t\t");
_builder_2.append("Service.get((int)Double.parseDouble(id));");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("} catch (NumberFormatException e) {");
_builder_2.newLine();
_builder_2.append("\t\t\t");
_builder_2.append(variableName, "\t\t\t");
_builder_2.append(" = dto");
_builder_2.append(simpleTypeName, "\t\t\t");
_builder_2.append("Service.get(id);");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t ");
_builder_2.append("} catch (NullPointerException e) {");
_builder_2.newLine();
_builder_2.append("\t ");
_builder_2.append(variableName, "\t ");
_builder_2.append(" = dto");
_builder_2.append(simpleTypeName, "\t ");
_builder_2.append("Service.get(id);");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("\t");
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("}");
_builder_2.newLine();
_builder_2.append("ecviewComponent.setValue(VIEW_ID, ");
_builder_2.append(variableName);
_builder_2.append(", params);");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
}
}
return body;
}
public String localeChanged(final UiView view) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if(getViewContext() != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("getViewContext().setLocale(locale);");
_builder.newLine();
_builder.append("}");
String body = _builder.toString();
EList<UiBeanSlot> slots = view.getBeanSlots();
for (final UiBeanSlot slot : slots) {
boolean _containsSuperType = this.containsSuperType(slot.getJvmType().getType(), IStateMachineParticipant.class.getName());
if (_containsSuperType) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("if(getViewContext() != null && getViewContext().getBeanSlot(\"");
String _name = slot.getName();
_builder_1.append(_name);
_builder_1.append("\") != null) {");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("((IStateMachineParticipant)getViewContext().getBeanSlot(\"");
String _name_1 = slot.getName();
_builder_1.append(_name_1, "\t");
_builder_1.append("\").getValue()).setLocale(locale);");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
body = _builder_1.toString();
} else {
boolean _containsSuperType_1 = this.containsSuperType(slot.getJvmType().getType(), IStateMachine.class.getName());
if (_containsSuperType_1) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append("if(getViewContext() != null && getViewContext().getBeanSlot(\"");
String _name_2 = slot.getName();
_builder_2.append(_name_2);
_builder_2.append("\") != null) {");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t");
_builder_2.append("((IStateMachine)getViewContext().getBeanSlot(\"");
String _name_3 = slot.getName();
_builder_2.append(_name_3, "\t");
_builder_2.append("\").getValue()).setLocale(locale);");
_builder_2.newLineIfNotEmpty();
_builder_2.append("}");
body = _builder_2.toString();
}
}
}
return body;
}
public String createRenderingParams(final UiView view) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Map<String, Object> params = super.createRenderingParams(user, blobService);");
_builder.newLine();
_builder.append("IConfiguration config = new IConfiguration() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void beforeUiRendering(IContext viewContext) {");
_builder.newLine();
String body = _builder.toString();
EList<UiBeanSlot> slots = view.getBeanSlots();
for (final UiBeanSlot slot : slots) {
if ((this.containsSuperType(slot.getJvmType().getType(), IStateMachineParticipant.class.getName()) ||
this.containsSuperType(slot.getJvmType().getType(), IPeripheral.class.getName()))) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
_builder_1.append("IStateMachineParticipant ");
String _name = slot.getName();
_builder_1.append(_name, "\t\t");
_builder_1.append(" = new ");
String _qualifiedName = slot.getJvmType().getQualifiedName();
_builder_1.append(_qualifiedName, "\t\t");
_builder_1.append("();");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
String _name_1 = slot.getName();
_builder_1.append(_name_1, "\t\t");
_builder_1.append(".setLocale(user.getLocale());");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
_builder_1.append("viewContext.createBeanSlot(\"");
String _name_2 = slot.getName();
_builder_1.append(_name_2, "\t\t");
_builder_1.append("\", ");
String _qualifiedName_1 = slot.getJvmType().getQualifiedName();
_builder_1.append(_qualifiedName_1, "\t\t");
_builder_1.append(".class).setValue(");
String _name_3 = slot.getName();
_builder_1.append(_name_3, "\t\t");
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
} else {
boolean _containsSuperType = this.containsSuperType(slot.getJvmType().getType(), IStateMachine.class.getName());
if (_containsSuperType) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("IStateMachine ");
String _name_4 = slot.getName();
_builder_2.append(_name_4, "\t\t");
_builder_2.append(" = new ");
String _qualifiedName_2 = slot.getJvmType().getQualifiedName();
_builder_2.append(_qualifiedName_2, "\t\t");
_builder_2.append("();");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_5 = slot.getName();
_builder_2.append(_name_5, "\t\t");
_builder_2.append(".setUser(user);");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_6 = slot.getName();
_builder_2.append(_name_6, "\t\t");
_builder_2.append(".setLocale(user.getLocale());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("viewContext.setLocale(user.getLocale());");
_builder_2.newLine();
_builder_2.append("\t\t");
String _name_7 = slot.getName();
_builder_2.append(_name_7, "\t\t");
_builder_2.append(".setDslMetadataService(getDslMetadataService());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_8 = slot.getName();
_builder_2.append(_name_8, "\t\t");
_builder_2.append(".setThemeResourceService(getThemeResourceService());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_9 = slot.getName();
_builder_2.append(_name_9, "\t\t");
_builder_2.append(".setReportProvider(getReportProvider());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_10 = slot.getName();
_builder_2.append(_name_10, "\t\t");
_builder_2.append(".setEclipseContext(getEclipseContext());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_11 = slot.getName();
_builder_2.append(_name_11, "\t\t");
_builder_2.append(".setBlobService(getBlobService());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("viewContext.createBeanSlot(\"");
String _name_12 = slot.getName();
_builder_2.append(_name_12, "\t\t");
_builder_2.append("\", ");
String _qualifiedName_3 = slot.getJvmType().getQualifiedName();
_builder_2.append(_qualifiedName_3, "\t\t");
_builder_2.append(".class).setValue(");
String _name_13 = slot.getName();
_builder_2.append(_name_13, "\t\t");
_builder_2.append(");");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
} else {
boolean _containsSuperType_1 = this.containsSuperType(slot.getJvmType().getType(), IBlobConverter.class.getName());
if (_containsSuperType_1) {
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body);
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
_builder_3.append("viewContext.createBeanSlot(\"");
String _name_14 = slot.getName();
_builder_3.append(_name_14, "\t\t");
_builder_3.append("\", BlobConverter.class).setValue(new BlobConverter(blobService));");
_builder_3.newLineIfNotEmpty();
body = _builder_3.toString();
} else {
final LEntity entity = EntityUtils.getEntityFromDto(slot.getJvmType().getType());
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body);
_builder_4.newLineIfNotEmpty();
_builder_4.append("\t\t");
_builder_4.append("viewContext.createBeanSlot(\"");
String _name_15 = slot.getName();
_builder_4.append(_name_15, "\t\t");
_builder_4.append("\", ");
String _qualifiedName_4 = slot.getJvmType().getQualifiedName();
_builder_4.append(_qualifiedName_4, "\t\t");
_builder_4.append(".class).setValue(new ");
String _qualifiedName_5 = slot.getJvmType().getQualifiedName();
_builder_4.append(_qualifiedName_5, "\t\t");
_builder_4.append("());");
_builder_4.newLineIfNotEmpty();
{
if ((entity != null)) {
_builder_4.append("\t\t");
_builder_4.append("persistenceService.registerPersistenceUnit(\"");
String _persistenceUnit = entity.getPersistenceUnit();
_builder_4.append(_persistenceUnit, "\t\t");
_builder_4.append("\", ");
String _qualifiedEntityNameForQualifiedDtoName = EntityUtils.getQualifiedEntityNameForQualifiedDtoName(slot.getJvmType().getType().getQualifiedName());
_builder_4.append(_qualifiedEntityNameForQualifiedDtoName, "\t\t");
_builder_4.append(".class);");
_builder_4.newLineIfNotEmpty();
}
}
body = _builder_4.toString();
}
}
}
}
StringConcatenation _builder_5 = new StringConcatenation();
_builder_5.append(body);
_builder_5.newLineIfNotEmpty();
_builder_5.append("\t");
_builder_5.append("}");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("@Override");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("public void afterUiRendering(IContext context) {");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("}");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("@Override");
_builder_5.newLine();
_builder_5.append("\t");
_builder_5.append("public void beforeBind(IContext context) {");
_builder_5.newLine();
body = _builder_5.toString();
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append(body);
_builder_6.newLineIfNotEmpty();
_builder_6.append("\t");
_builder_6.append("}");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("@Override");
_builder_6.newLine();
_builder_6.append("\t");
_builder_6.append("public void afterBind(IContext context) {");
_builder_6.newLine();
body = _builder_6.toString();
for (final UiBeanSlot slot_1 : slots) {
boolean _containsSuperType_2 = this.containsSuperType(slot_1.getJvmType().getType(), IStateMachineParticipant.class.getName());
if (_containsSuperType_2) {
StringConcatenation _builder_7 = new StringConcatenation();
_builder_7.append(body);
_builder_7.newLineIfNotEmpty();
_builder_7.append("\t\t");
_builder_7.append("((IStateMachineParticipant)context.getBeanSlot(\"");
String _name_16 = slot_1.getName();
_builder_7.append(_name_16, "\t\t");
_builder_7.append("\").getValue()).init();");
_builder_7.newLineIfNotEmpty();
body = _builder_7.toString();
boolean _containsSuperType_3 = this.containsSuperType(slot_1.getJvmType().getType(), IDataProvider.class.getName());
if (_containsSuperType_3) {
for (final UiBeanSlot innerslot : slots) {
boolean _containsSuperType_4 = this.containsSuperType(innerslot.getJvmType().getType(), IDto.class.getName());
if (_containsSuperType_4) {
StringConcatenation _builder_8 = new StringConcatenation();
_builder_8.append(body);
_builder_8.newLineIfNotEmpty();
_builder_8.append("\t\t");
_builder_8.append("if (context.getBeanSlot(\"");
String _name_17 = innerslot.getName();
_builder_8.append(_name_17, "\t\t");
_builder_8.append("\") != null) {");
_builder_8.newLineIfNotEmpty();
_builder_8.append("\t\t\t");
_builder_8.append("((IDataProvider)context.getBeanSlot(\"");
String _name_18 = slot_1.getName();
_builder_8.append(_name_18, "\t\t\t");
_builder_8.append("\").getValue()).addDatasource(\"");
String _name_19 = innerslot.getName();
_builder_8.append(_name_19, "\t\t\t");
_builder_8.append("\", context.getBeanSlot(\"");
String _name_20 = innerslot.getName();
_builder_8.append(_name_20, "\t\t\t");
_builder_8.append("\").getValueType());");
_builder_8.newLineIfNotEmpty();
_builder_8.append("\t\t");
_builder_8.append("}");
_builder_8.newLine();
body = _builder_8.toString();
}
}
}
}
}
for (final UiBeanSlot slot_2 : slots) {
boolean _containsSuperType_5 = this.containsSuperType(slot_2.getJvmType().getType(), IStateMachine.class.getName());
if (_containsSuperType_5) {
StringConcatenation _builder_9 = new StringConcatenation();
_builder_9.append(body);
_builder_9.newLineIfNotEmpty();
_builder_9.append("\t\t");
_builder_9.append("((IStateMachine)context.getBeanSlot(\"");
String _name_21 = slot_2.getName();
_builder_9.append(_name_21, "\t\t");
_builder_9.append("\").getValue()).start();");
_builder_9.newLineIfNotEmpty();
body = _builder_9.toString();
}
}
StringConcatenation _builder_10 = new StringConcatenation();
_builder_10.append(body);
_builder_10.newLineIfNotEmpty();
_builder_10.append("\t");
_builder_10.append("}");
_builder_10.newLine();
_builder_10.append("};");
_builder_10.newLine();
_builder_10.append("params.put(IViewContext.PARAM_CONFIGURATION, config);");
_builder_10.newLine();
_builder_10.append("return params;");
_builder_10.newLine();
body = _builder_10.toString();
return body;
}
/**
* Method to set a default instance into the view context (for each defined datasource object in the uimodel)
*/
public String setBeanToViewContext(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
String body = _builder.toString();
EList<UiBeanSlot> _beanSlots = dialog.getUiView().getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.append("viewContext.setBean(\"");
String _name = uiBeanSlot.getName();
_builder_1.append(_name);
_builder_1.append("\",");
String _name_1 = uiBeanSlot.getName();
_builder_1.append(_name_1);
_builder_1.append(");");
body = _builder_1.toString();
}
return body;
}
public String getViewName(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getECViewName(dialog);
} else {
return dialog.getUiView().getName();
}
}
public String getUiModelPackageName(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getECViewPackage(dialog);
} else {
EObject parent = dialog.getUiView().eContainer();
while ((!(parent instanceof UiModel))) {
parent = parent.eContainer();
}
UiModel uiModel = ((UiModel) parent);
return uiModel.getPackageName();
}
}
}