blob: ab237eb0f168db535534a1717af728eb123774a9 [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.ComponentContainer;
import com.vaadin.ui.UI;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.inject.Inject;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.dsl.common.datatypes.IDto;
import org.eclipse.osbp.dsl.common.xtext.extensions.AnnotationExtension;
import org.eclipse.osbp.dsl.semantic.entity.LEntity;
import org.eclipse.osbp.ecview.core.common.context.IViewContext;
import org.eclipse.osbp.ecview.dsl.derivedstate.UiModelGrammarUtil;
import org.eclipse.osbp.ecview.semantic.uimodel.UiBeanSlot;
import org.eclipse.osbp.ecview.semantic.uimodel.UiEmbeddable;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileEmbeddable;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileNavBarAction;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileNavigationPage;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileNavigationPageAssignment;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileNavigationRoot;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileNavigationRootAssigment;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileView;
import org.eclipse.osbp.ecview.semantic.uimodel.UiModel;
import org.eclipse.osbp.ecview.semantic.uimodel.UiTable;
import org.eclipse.osbp.ecview.semantic.uimodel.UiTypeProvider;
import org.eclipse.osbp.ecview.semantic.uimodel.UiView;
import org.eclipse.osbp.ecview.semantic.uisemantics.UxAction;
import org.eclipse.osbp.mobile.vaadin.ecview.api.IMobileUiParticipant;
import org.eclipse.osbp.mobile.vaadin.ecview.api.IMobileUiParticipantHandle;
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.common.EntityUtils;
import org.eclipse.osbp.xtext.dialogdsl.Dialog;
import org.eclipse.osbp.xtext.dialogdsl.DialogPackage;
import org.eclipse.osbp.xtext.dialogdsl.common.AbstractMobileView;
import org.eclipse.osbp.xtext.dialogdsl.constants.DialogConstants;
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.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.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.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
@SuppressWarnings("all")
public class DialogDslMobileViewCreator {
/**
* 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 AnnotationExtension _annotationExtension;
private JvmAnnotationReferenceBuilder _annotationTypesBuilder;
private JvmTypeReferenceBuilder _typeReferenceBuilder;
private HashMap<String, List<String>> actionMap;
public void createMobileUI(final DialogPackage pckg, final Dialog dialog, final IJvmDeclaredTypeAcceptor acceptor, final JvmAnnotationReferenceBuilder annotationTypesBuilder, final JvmTypeReferenceBuilder typeReferenceBuilder, final String binderClassName) {
this._annotationTypesBuilder = annotationTypesBuilder;
this._typeReferenceBuilder = typeReferenceBuilder;
UiView _uiView = dialog.getUiView();
final UiMobileView uiMobileView = ((UiMobileView) _uiView);
if ((((uiMobileView != null) && (uiMobileView.getName() != null)) && (!uiMobileView.getName().isEmpty()))) {
StringConcatenation _builder = new StringConcatenation();
CharSequence _fQNView = this.getFQNView(dialog, pckg);
_builder.append(_fQNView);
JvmGenericType cls = this._jvmTypesBuilder.toClass(dialog, _builder.toString());
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
it.getSuperTypes().add(this._typeReferenceBuilder.typeRef(AbstractMobileView.class));
this.toFields(it, dialog, pckg);
this.toOperations(it, dialog, pckg, binderClassName);
};
acceptor.<JvmGenericType>accept(cls, _function);
this.toUiProvider(cls, dialog, pckg, acceptor);
this.toActionOperations(cls, uiMobileView, acceptor);
}
}
/**
* build the inner class UiProvider.
*
* @param type
* @param uiMobileView
* @param acceptor
*/
public void toActionOperations(final JvmGenericType type, final UiMobileView uiMobileView, final IJvmDeclaredTypeAcceptor acceptor) {
this.createActionMap(uiMobileView);
boolean _isEmpty = this.actionMap.isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
this.toInitializeMethod(type, uiMobileView);
this.toDisposeMethod(type, uiMobileView);
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
boolean _tripleNotEquals = (_get != null);
if (_tripleNotEquals) {
this.toSaveObserver(type, uiMobileView, acceptor);
this.toSaveFields(type, uiMobileView);
this.toRegSaveHandler(type, uiMobileView);
this.toUnRegSaveHandler(type, uiMobileView);
}
}
}
/**
* build the inner class UiProvider.
*
* @param type
* @param uiMobileView
* @param acceptor
*/
public void toSaveObserver(final JvmDeclaredType type, final UiMobileView uiMobileView, final IJvmDeclaredTypeAcceptor acceptor) {
final String dto = this.getJvmTypeRef(uiMobileView).getQualifiedName();
final JvmGenericType cls = this._jvmTypesBuilder.toClass(uiMobileView, "SaveActionObserver");
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmGenericType>operator_add(_members, cls);
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
it.getSuperTypes().add(this._typeReferenceBuilder.typeRef(AdapterImpl.class));
it.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members_1 = cls.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it_1) -> {
EList<JvmAnnotationReference> _annotations = it_1.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(uiMobileView, "msg", this._typeReferenceBuilder.typeRef(Notification.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_2) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("// if the navigation bar button was clicked");
_builder.newLine();
_builder.append("if (msg.getFeature() == org.eclipse.osbp.mobile.vaadin.ecview.model.VaadinMobilePackage.Literals.VM_NAVIGATION_BAR_BUTTON__LAST_CLICK_TIME) {");
_builder.newLine();
{
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
for(final String saveId : _get) {
{
boolean _isTable = this.isTable(uiMobileView, this.getNavPageContainer(saveId));
if (_isTable) {
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.append("YTable yTable = findTable(\"");
String _navPageContainer = this.getNavPageContainer(saveId);
_builder.append(_navPageContainer, "\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(dto, "\t");
_builder.append(" dto = (");
_builder.append(dto, "\t");
_builder.append(") yTable.getSelection();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("((IDTOService<");
_builder.append(dto, "\t");
_builder.append(">) dtoService).update(dto);");
_builder.newLineIfNotEmpty();
_builder.append("} catch (Exception e) {");
_builder.newLine();
_builder.append("\t");
_builder.append("e.printStackTrace();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
}
}
}
_builder.append("}");
_builder.newLine();
it_2.append(_builder);
};
this._jvmTypesBuilder.setBody(it_1, _function_2);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "notifyChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method);
};
acceptor.<JvmGenericType>accept(cls, _function);
}
/**
* @param type
* @param uiMobileView
*/
public void toSaveFields(final JvmGenericType type, final UiMobileView uiMobileView) {
JvmField field = null;
field = this._jvmTypesBuilder.toField(uiMobileView, "observer", this._typeReferenceBuilder.typeRef("SaveActionObserver"));
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
}
/**
* @param type
* @param uiMobileView
*/
public void toDisposeMethod(final JvmGenericType type, final UiMobileView uiMobileView) {
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);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
{
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
boolean _tripleNotEquals = (_get != null);
if (_tripleNotEquals) {
_builder.append("unregisterSaveHandler();");
_builder.newLine();
}
}
_builder.append("super.dispose();");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "dispose", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
/**
* @param type
* @param uiMobileView
*/
public void toUnRegSaveHandler(final JvmGenericType type, final UiMobileView uiMobileView) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
this._jvmTypesBuilder.setDocumentation(it, "Unregister an observer at the EObject for the save-navigationBarAction");
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
{
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
for(final String saveId : _get) {
_builder.append("unregisterHandler(\"");
_builder.append(saveId);
_builder.append("\", observer);");
_builder.newLineIfNotEmpty();
}
}
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "unregisterSaveHandler", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
/**
* @param type
* @param uiMobileView
*/
public void toRegSaveHandler(final JvmGenericType type, final UiMobileView uiMobileView) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
this._jvmTypesBuilder.setDocumentation(it, "Register an observer at the EObject for the save-navigationBarAction");
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("try {");
_builder.newLine();
_builder.append("\t");
_builder.append("// access the navigation bar action and register a listener at it");
_builder.newLine();
_builder.append("\t");
_builder.append("if (observer === null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("observer = new SaveActionObserver();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
{
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
for(final String saveId : _get) {
_builder.append("registerHandler(\"");
_builder.append(saveId, "\t");
_builder.append("\", observer);");
_builder.newLineIfNotEmpty();
}
}
_builder.append("} catch (Exception e) {");
_builder.newLine();
_builder.append("\t");
_builder.append("e.printStackTrace();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "registerSaveHandler", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
/**
* @param type
* @param uMobileView
*/
public void toInitializeMethod(final JvmGenericType type, final UiMobileView uiMobileView) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(uiMobileView, "parent", this._typeReferenceBuilder.typeRef(ComponentContainer.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(uiMobileView, "fragment", 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("\t");
_builder.append("super.initialize(parent, fragment);");
_builder.newLine();
{
List<String> _get = this.actionMap.get(this._dialogConstants.ACTION_SAVE);
boolean _tripleNotEquals = (_get != null);
if (_tripleNotEquals) {
_builder.append("\t\t\t\t\t\t");
_builder.append("registerSaveHandler();");
_builder.newLine();
_builder.append("\t\t\t\t\t\t");
}
}
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "initialize", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
/**
* <p>build the class variables.</p>
*
* @param type
* @param dialog
* @param pckg
*/
public void toFields(final JvmDeclaredType type, final Dialog dialog, final DialogPackage pckg) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmField> _function = (JvmField it) -> {
it.setVisibility(JvmVisibility.PRIVATE);
it.setStatic(true);
it.setFinal(true);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("1L");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_1);
};
JvmField _field = this._jvmTypesBuilder.toField(dialog, "serialVersionUID", this._typeReferenceBuilder.typeRef(long.class), _function);
this._jvmTypesBuilder.<JvmField>operator_add(_members, _field);
final Procedure1<JvmField> _function_1 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("LoggerFactory.getLogger(\"mobileDialog\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_2);
};
JvmField field = this._jvmTypesBuilder.toField(dialog, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function_1);
field.setFinal(true);
field.setStatic(true);
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
}
/**
* <p>build the inner class UiProvider.</p>
*
* @param type
* @param dialog
* @param pckg
* @param acceptor
*/
public void toUiProvider(final JvmDeclaredType type, final Dialog dialog, final DialogPackage pckg, final IJvmDeclaredTypeAcceptor acceptor) {
JvmGenericType cls = this._jvmTypesBuilder.toClass(dialog, "UiProvider");
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmGenericType>operator_add(_members, cls);
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
it.getSuperTypes().add(
this._typeReferenceBuilder.typeRef(IMobileUiParticipant.class));
it.setStatic(true);
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Component.class);
StringConcatenation _builder = new StringConcatenation();
_builder.append("uriFragment=");
CharSequence _fQNView = this.getFQNView(dialog, pckg);
_builder.append(_fQNView);
String propContent = _builder.toString();
this._annotationExtension.addAnnAttr(annotationRef, dialog, "property", propContent);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
this.toUiProviderConstructor(it, dialog);
this.toUiProviderOperations(it, dialog, pckg);
};
acceptor.<JvmGenericType>accept(cls, _function);
}
/**
* @param type
* @param dialog
*/
public void toUiProviderConstructor(final JvmGenericType type, final Dialog dialog) {
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();");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(dialog, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
}
/**
* @param type
* @param dialog
* @param pckg
*/
public void toUiProviderOperations(final JvmGenericType type, final Dialog dialog, final DialogPackage pckg) {
EList<JvmMember> _members = type.getMembers();
JvmField _field = this._jvmTypesBuilder.toField(dialog, "handle", this._typeReferenceBuilder.typeRef(IMobileUiParticipantHandle.class));
this._jvmTypesBuilder.<JvmField>operator_add(_members, _field);
EList<JvmMember> _members_1 = 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);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
CharSequence _fQNView = this.getFQNView(dialog, pckg);
_builder.append(_fQNView);
_builder.append("\";");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "getFragmentName", this._typeReferenceBuilder.typeRef(String.class), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "ui", this._typeReferenceBuilder.typeRef(UI.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(dialog, "fragment", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("handle = new ");
String _name = dialog.getName();
_builder.append(_name);
_builder.append(this._dialogConstants.MOBILE_VIEW_PREFIX);
_builder.append("();");
_builder.newLineIfNotEmpty();
_builder.append("return handle;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(dialog, "createHandle",
this._typeReferenceBuilder.typeRef(IMobileUiParticipantHandle.class), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_1);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "handle", this._typeReferenceBuilder.typeRef(IMobileUiParticipantHandle.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("this.handle = handle;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(dialog, "setHandle",
this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_2);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (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_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return handle;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(dialog, "getHandle",
this._typeReferenceBuilder.typeRef(IMobileUiParticipantHandle.class), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_3);
}
/**
* <p>build the methods.</p>
*
* @param type
* @param dialog
* @param pckg
*/
public void toOperations(final JvmDeclaredType type, final Dialog dialog, final DialogPackage pckg, final String binderClassName) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EObject _eContainer = dialog.getUiView().eContainer();
final UiModel uiModel = ((UiModel) _eContainer);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _packageName = uiModel.getPackageName();
_builder.append(_packageName);
_builder.append(".");
String _name = dialog.getUiView().getName();
_builder.append(_name);
_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);
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);
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
String _createRenderingParams = this.createRenderingParams(dialog, binderClassName);
_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);
_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);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(dialog, "viewContext", this._typeReferenceBuilder.typeRef(IViewContext.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(dialog, "fragment", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
it_1.append(this.setBeanToViewContext(dialog, binderClassName));
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(dialog, "doInitialize", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PROTECTED);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
{
JvmTypeReference _jvmTypeRef = this.getJvmTypeRef(dialog);
boolean _notEquals = (!Objects.equal(_jvmTypeRef, null));
if (_notEquals) {
_builder.append("return ");
String _qualifiedName = this.getJvmTypeRef(dialog).getQualifiedName();
_builder.append(_qualifiedName);
_builder.append(".class;");
} else {
_builder.append("return null;");
}
}
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(dialog, "getDtoClass", this._typeReferenceBuilder.typeRef(Class.class), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
}
/**
* Method to set a default instance into the view context (for each defined datasource object in the uimodel)
* @param dialog
* @return
*/
public String setBeanToViewContext(final Dialog dialog, final String binderClassName) {
String body = "";
JvmTypeReference _jvmTypeRef = this.getJvmTypeRef(dialog);
boolean _tripleNotEquals = (_jvmTypeRef != null);
if (_tripleNotEquals) {
LEntity _entityFromDto = EntityUtils.getEntityFromDto(this.getJvmTypeRef(dialog).getType());
final LEntity entity = ((LEntity) _entityFromDto);
StringConcatenation _builder = new StringConcatenation();
_builder.append(body);
_builder.newLineIfNotEmpty();
_builder.append(binderClassName);
_builder.append(".getPersistenceService().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();
body = _builder.toString();
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = ((UiMobileView) _uiView).getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("viewContext.setBean(\"");
String _name = uiBeanSlot.getName();
_builder_1.append(_name);
_builder_1.append("\", new ");
JvmTypeReference _jvmType = uiBeanSlot.getJvmType();
String _qualifiedName = null;
if (_jvmType!=null) {
_qualifiedName=_jvmType.getQualifiedName();
}
String _replace = _qualifiedName.replace("$", ".");
_builder_1.append(_replace);
_builder_1.append("());");
body = _builder_1.toString();
}
}
return body;
}
/**
* Method to get the referenced jvmType within mobile navigationPage
*
* @param dialog
* @return
*/
public JvmTypeReference getJvmTypeRef(final Dialog dialog) {
UiView _uiView = dialog.getUiView();
UiMobileView uiMobileView = ((UiMobileView) _uiView);
UiEmbeddable uiMobileContent = uiMobileView.getContent();
if ((uiMobileContent instanceof UiMobileNavigationRoot)) {
UiMobileNavigationRoot uiMobileNavRoot = ((UiMobileNavigationRoot) uiMobileContent);
EList<UiMobileNavigationRootAssigment> _contents = uiMobileNavRoot.getContents();
for (final UiMobileNavigationRootAssigment uiMobileNavRootAssigment : _contents) {
{
UiMobileEmbeddable uiMobileElement = uiMobileNavRootAssigment.getElement();
if ((uiMobileElement instanceof UiMobileNavigationPage)) {
UiMobileNavigationPage uiMobileNavPage = ((UiMobileNavigationPage) uiMobileElement);
EList<UiMobileNavigationPageAssignment> _contents_1 = uiMobileNavPage.getContents();
for (final UiMobileNavigationPageAssignment uiMobileNavPageAssigment : _contents_1) {
{
UiEmbeddable element = uiMobileNavPageAssigment.getElement();
if ((element instanceof UiTypeProvider)) {
return ((UiTypeProvider) element).getJvmType();
}
}
}
}
}
}
}
return null;
}
/**
* Method to get the referenced jvmType within mobile navigationPage
*
* @param uiMobileView
* @return
*/
public JvmTypeReference getJvmTypeRef(final UiMobileView uiMobileView) {
UiEmbeddable uiMobileContent = uiMobileView.getContent();
if ((uiMobileContent instanceof UiMobileNavigationRoot)) {
UiMobileNavigationRoot uiMobileNavRoot = ((UiMobileNavigationRoot) uiMobileContent);
EList<UiMobileNavigationRootAssigment> _contents = uiMobileNavRoot.getContents();
for (final UiMobileNavigationRootAssigment uiMobileNavRootAssigment : _contents) {
{
UiMobileEmbeddable uiMobileElement = uiMobileNavRootAssigment.getElement();
if ((uiMobileElement instanceof UiMobileNavigationPage)) {
UiMobileNavigationPage uiMobileNavPage = ((UiMobileNavigationPage) uiMobileElement);
EList<UiMobileNavigationPageAssignment> _contents_1 = uiMobileNavPage.getContents();
for (final UiMobileNavigationPageAssignment uiMobileNavPageAssigment : _contents_1) {
{
UiEmbeddable element = uiMobileNavPageAssigment.getElement();
if ((element instanceof UiTypeProvider)) {
return ((UiTypeProvider) element).getJvmType();
}
}
}
}
}
}
}
return null;
}
/**
* @param uiView
*/
public void createActionMap(final UiMobileView view) {
if ((this.actionMap == null)) {
this.actionMap = CollectionLiterals.<String, List<String>>newHashMap();
}
Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(view.eAllContents());
for (final EObject uiElement : _iterable) {
if ((uiElement instanceof UiMobileNavBarAction)) {
final UiMobileNavBarAction uiAction = ((UiMobileNavBarAction)uiElement);
UxAction uxActionRef = uiAction.getActionReference();
String actionID = uiAction.getActionID();
QualifiedName fqn = this._iQualifiedNameProvider.getFullyQualifiedName(uiAction);
String key = "";
if ((uxActionRef != null)) {
key = uxActionRef.getName();
} else {
if ((actionID != null)) {
key = actionID;
}
}
List<String> actionList = this.actionMap.get(key);
if ((actionList == null)) {
actionList = CollectionLiterals.<String>newArrayList();
}
actionList.add(fqn.toString());
this.actionMap.put(key, actionList);
}
}
}
/**
* @param uiView
* @return
*/
public String getUiModelPackageName(final UiView uiView) {
EObject parent = uiView.eContainer();
while ((!(parent instanceof UiModel))) {
parent = parent.eContainer();
}
UiModel uiModel = ((UiModel) parent);
return uiModel.getPackageName();
}
/**
* @param navbarActionPath
* @return
*/
public String getNavPageContainer(final String navbarActionPath) {
String[] navbarActionSplit = navbarActionPath.split("\\.");
final String[] _converted_navbarActionSplit = (String[])navbarActionSplit;
int _size = ((List<String>)Conversions.doWrapArray(_converted_navbarActionSplit)).size();
boolean _greaterThan = (_size > 2);
if (_greaterThan) {
String out = "";
final String[] _converted_navbarActionSplit_1 = (String[])navbarActionSplit;
final String[] _converted_navbarActionSplit_2 = (String[])navbarActionSplit;
int _size_1 = ((List<String>)Conversions.doWrapArray(_converted_navbarActionSplit_2)).size();
int _minus = (_size_1 - 2);
List<String> navbarActionPathSubList = ((List<String>)Conversions.doWrapArray(_converted_navbarActionSplit_1)).subList(0, _minus);
for (final String element : navbarActionPathSubList) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(out);
_builder.append(".");
_builder.append(element);
out = _builder.toString();
}
int _length = out.length();
boolean _greaterThan_1 = (_length > 1);
if (_greaterThan_1) {
return out.substring(1);
}
return out;
}
return navbarActionPath;
}
/**
* @param uiMobileView
* @param id
* @return
*/
public boolean isTable(final UiMobileView uiMobileView, final String id) {
TreeIterator<EObject> contents = uiMobileView.eAllContents();
while (contents.hasNext()) {
{
EObject expected = contents.next();
if ((expected instanceof UiTable)) {
String tableId = UiModelGrammarUtil.getPathId(((UiEmbeddable)expected));
boolean _equals = id.equals(tableId);
if (_equals) {
return true;
}
}
}
}
return false;
}
public CharSequence getFQNView(final Dialog dialog, final DialogPackage pckg) {
StringConcatenation _builder = new StringConcatenation();
String _name = pckg.getName();
_builder.append(_name);
_builder.append(".");
String _name_1 = dialog.getName();
_builder.append(_name_1);
_builder.append(this._dialogConstants.MOBILE_VIEW_PREFIX);
return _builder;
}
public String localeChanged(final Dialog dialog) {
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 = dialog.getUiView().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 Dialog dialog, final String binderClassName) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Map<String, Object> params = super.createRenderingParams(user);");
String body = _builder.toString();
boolean _isStateful = dialog.isStateful();
if (_isStateful) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body);
_builder_1.newLineIfNotEmpty();
_builder_1.append("Map<String, Object> services = new HashMap<String, Object>();");
_builder_1.newLine();
_builder_1.append("params.put(IViewContext.PARAM_SERVICES, services);");
_builder_1.newLine();
_builder_1.append("org.eclipse.osbp.vaaclipse.addons.softwarefactory.service.OSBPI18nService i18nService = new org.eclipse.osbp.vaaclipse.addons.softwarefactory.service.OSBPI18nService();");
_builder_1.newLine();
_builder_1.append("i18nService.setDSLMetadataService(");
_builder_1.append(binderClassName);
_builder_1.append(".getDSLMetadataService());");
_builder_1.newLineIfNotEmpty();
_builder_1.append("services.put(II18nService.class.getName(), i18nService); ");
_builder_1.newLine();
_builder_1.append("services.put(IThemeResourceService.class.getName(), ");
_builder_1.append(binderClassName);
_builder_1.append(".getThemeResourceService());");
_builder_1.newLineIfNotEmpty();
_builder_1.append("services.put(IDSLMetadataService.class.getName(), ");
_builder_1.append(binderClassName);
_builder_1.append(".getDSLMetadataService());");
_builder_1.newLineIfNotEmpty();
_builder_1.append("IConfiguration config = new IConfiguration() {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("@Override");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public void beforeUiRendering(IContext viewContext) {");
_builder_1.newLine();
body = _builder_1.toString();
EList<UiBeanSlot> slots = dialog.getUiView().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_2 = new StringConcatenation();
_builder_2.append(body);
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("IStateMachineParticipant ");
String _name = slot.getName();
_builder_2.append(_name, "\t\t");
_builder_2.append(" = new ");
String _qualifiedName = slot.getJvmType().getQualifiedName();
_builder_2.append(_qualifiedName, "\t\t");
_builder_2.append("();");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_1 = slot.getName();
_builder_2.append(_name_1, "\t\t");
_builder_2.append(".setLocale(user.getLocale());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("viewContext.createBeanSlot(\"");
String _name_2 = slot.getName();
_builder_2.append(_name_2, "\t\t");
_builder_2.append("\", ");
String _qualifiedName_1 = slot.getJvmType().getQualifiedName();
_builder_2.append(_qualifiedName_1, "\t\t");
_builder_2.append(".class).setValue(");
String _name_3 = slot.getName();
_builder_2.append(_name_3, "\t\t");
_builder_2.append(");");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
} else {
boolean _containsSuperType = this.containsSuperType(slot.getJvmType().getType(), IStateMachine.class.getName());
if (_containsSuperType) {
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body);
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
_builder_3.append("IStateMachine ");
String _name_4 = slot.getName();
_builder_3.append(_name_4, "\t\t");
_builder_3.append(" = new ");
String _qualifiedName_2 = slot.getJvmType().getQualifiedName();
_builder_3.append(_qualifiedName_2, "\t\t");
_builder_3.append("();");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
String _name_5 = slot.getName();
_builder_3.append(_name_5, "\t\t");
_builder_3.append(".setUser(user);");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
String _name_6 = slot.getName();
_builder_3.append(_name_6, "\t\t");
_builder_3.append(".setLocale(user.getLocale());");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
_builder_3.append("viewContext.setLocale(user.getLocale());");
_builder_3.newLine();
_builder_3.append("\t\t");
String _name_7 = slot.getName();
_builder_3.append(_name_7, "\t\t");
_builder_3.append(".setDslMetadataService(");
_builder_3.append(binderClassName, "\t\t");
_builder_3.append(".getDSLMetadataService());");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
String _name_8 = slot.getName();
_builder_3.append(_name_8, "\t\t");
_builder_3.append(".setThemeResourceService(");
_builder_3.append(binderClassName, "\t\t");
_builder_3.append(".getThemeResourceService());");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
String _name_9 = slot.getName();
_builder_3.append(_name_9, "\t\t");
_builder_3.append(".setReportProvider(");
_builder_3.append(binderClassName, "\t\t");
_builder_3.append(".getReportProvider());");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
_builder_3.append("viewContext.createBeanSlot(\"");
String _name_10 = slot.getName();
_builder_3.append(_name_10, "\t\t");
_builder_3.append("\", ");
String _qualifiedName_3 = slot.getJvmType().getQualifiedName();
_builder_3.append(_qualifiedName_3, "\t\t");
_builder_3.append(".class).setValue(");
String _name_11 = slot.getName();
_builder_3.append(_name_11, "\t\t");
_builder_3.append(");");
_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_12 = slot.getName();
_builder_4.append(_name_12, "\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();
_builder_4.append("\t\t");
_builder_4.append(binderClassName, "\t\t");
_builder_4.append(".getPersistenceService().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_1 = this.containsSuperType(slot_1.getJvmType().getType(), IStateMachineParticipant.class.getName());
if (_containsSuperType_1) {
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_13 = slot_1.getName();
_builder_7.append(_name_13, "\t\t");
_builder_7.append("\").getValue()).init();");
_builder_7.newLineIfNotEmpty();
body = _builder_7.toString();
boolean _containsSuperType_2 = this.containsSuperType(slot_1.getJvmType().getType(), IDataProvider.class.getName());
if (_containsSuperType_2) {
for (final UiBeanSlot innerslot : slots) {
boolean _containsSuperType_3 = this.containsSuperType(innerslot.getJvmType().getType(), IDto.class.getName());
if (_containsSuperType_3) {
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_14 = innerslot.getName();
_builder_8.append(_name_14, "\t\t");
_builder_8.append("\") != null) {");
_builder_8.newLineIfNotEmpty();
_builder_8.append("\t\t\t");
_builder_8.append("((IDataProvider)context.getBeanSlot(\"");
String _name_15 = slot_1.getName();
_builder_8.append(_name_15, "\t\t\t");
_builder_8.append("\").getValue()).addDatasource(\"");
String _name_16 = innerslot.getName();
_builder_8.append(_name_16, "\t\t\t");
_builder_8.append("\", context.getBeanSlot(\"");
String _name_17 = innerslot.getName();
_builder_8.append(_name_17, "\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_4 = this.containsSuperType(slot_2.getJvmType().getType(), IStateMachine.class.getName());
if (_containsSuperType_4) {
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_18 = slot_2.getName();
_builder_9.append(_name_18, "\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();
} else {
StringConcatenation _builder_11 = new StringConcatenation();
_builder_11.append(body);
_builder_11.newLineIfNotEmpty();
_builder_11.append("Map<String, Object> services = new HashMap<String, Object>();");
_builder_11.newLine();
_builder_11.append("params.put(IViewContext.PARAM_SERVICES, services);");
_builder_11.newLine();
_builder_11.append("org.eclipse.osbp.vaaclipse.addons.softwarefactory.service.OSBPI18nService i18nService = new org.eclipse.osbp.vaaclipse.addons.softwarefactory.service.OSBPI18nService();");
_builder_11.newLine();
_builder_11.append("i18nService.setDSLMetadataService(");
_builder_11.append(binderClassName);
_builder_11.append(".getDSLMetadataService());");
_builder_11.newLineIfNotEmpty();
_builder_11.append("services.put(II18nService.class.getName(), i18nService); ");
_builder_11.newLine();
_builder_11.append("services.put(IThemeResourceService.class.getName(), ");
_builder_11.append(binderClassName);
_builder_11.append(".getThemeResourceService());");
_builder_11.newLineIfNotEmpty();
_builder_11.append("services.put(IDSLMetadataService.class.getName(), ");
_builder_11.append(binderClassName);
_builder_11.append(".getDSLMetadataService());");
_builder_11.newLineIfNotEmpty();
_builder_11.append("return params;");
_builder_11.newLine();
body = _builder_11.toString();
}
return body;
}
public boolean containsSuperType(final JvmType type, final String fqn) {
if ((!(type instanceof JvmDeclaredType))) {
return false;
}
return new RawSuperTypes().collectNames(type).contains(fqn);
}
}