blob: 6534c9eaf123382548c5978f28b367d1f7ec73d0 [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 java.util.Set;
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.dsl.dto.lib.services.IDTOServiceWithMutablePersistence;
import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage;
import org.eclipse.osbp.dsl.semantic.dto.LDto;
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.eventbroker.EventBrokerMsg;
import org.eclipse.osbp.persistence.IPersistenceService;
import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider;
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.utils.annotation.CommonUtils;
import org.eclipse.osbp.utils.common.EntityUtils;
import org.eclipse.osbp.utils.constants.GeneratorConstants;
import org.eclipse.osbp.xtext.action.ActionButton;
import org.eclipse.osbp.xtext.action.ActionDialog;
import org.eclipse.osbp.xtext.action.ActionToolbar;
import org.eclipse.osbp.xtext.action.ActionType;
import org.eclipse.osbp.xtext.action.DialogActionEnum;
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.messagedsl.MessageItem;
import org.eclipse.osbp.xtext.messagedsl.jvmmodel.MessageDslJvmModelInferrer;
import org.eclipse.osbp.xtext.strategy.jvmmodel.StrategyDSLFocusingEnhancerCreator;
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.JvmPrimitiveType;
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 strategyFocusingEnhancerCreator;
@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);
boolean _and = false;
boolean _notEquals = (!Objects.equal(uiViewName, null));
if (!_notEquals) {
_and = false;
} else {
boolean _isEmpty = uiViewName.isEmpty();
boolean _not = (!_isEmpty);
_and = _not;
}
if (_and) {
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 = new Procedure1<JvmGenericType>() {
public void apply(final JvmGenericType it) {
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION);
boolean _isEmbedded = dialog.isEmbedded();
if (_isEmbedded) {
EList<JvmTypeReference> _superTypes = it.getSuperTypes();
String _mainBeanslotType = DialogDslVaaclipseViewCreator.this.getMainBeanslotType(dialog);
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(_mainBeanslotType);
JvmTypeReference _typeRef_1 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(AbstractEmbeddedDialog.class, _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _typeRef_1);
EList<JvmTypeReference> _superTypes_1 = it.getSuperTypes();
JvmTypeReference _typeRef_2 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(IViewEmbeddedProvider.class);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_1, _typeRef_2);
} else {
boolean _isPure = dialog.isPure();
if (_isPure) {
EList<JvmTypeReference> _superTypes_2 = it.getSuperTypes();
JvmTypeReference _typeRef_3 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(AbstractUIDialog.class);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_2, _typeRef_3);
} else {
EList<JvmTypeReference> _superTypes_3 = it.getSuperTypes();
String _mainBeanslotType_1 = DialogDslVaaclipseViewCreator.this.getMainBeanslotType(dialog);
JvmTypeReference _typeRef_4 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(_mainBeanslotType_1);
JvmTypeReference _typeRef_5 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(AbstractECViewDialog.class, _typeRef_4);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes_3, _typeRef_5);
}
}
DialogDslVaaclipseViewCreator.this.toConstructor(it, dialog);
DialogDslVaaclipseViewCreator.this.toFields(it, dialog);
DialogDslVaaclipseViewCreator.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;
EList<JvmTypeReference> _superTypes = contextCls.getSuperTypes();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IContextFunction.class);
_superTypes.add(_typeRef);
String _simpleName = contextCls.getSimpleName();
String _firstUpper = StringExtensions.toFirstUpper(_simpleName);
contextCls.setSimpleName(_firstUpper);
final Procedure1<JvmGenericType> _function_1 = new Procedure1<JvmGenericType>() {
public void apply(final JvmGenericType it) {
JvmAnnotationReference annotationRef = DialogDslVaaclipseViewCreator.this._annotationTypesBuilder.annotationRef(Component.class);
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(IContextFunction.class);
DialogDslVaaclipseViewCreator.this._commonUtils.addAnnAttr(annotationRef, dialog, "service", ((JvmTypeReference) _typeRef));
StringConcatenation _builder = new StringConcatenation();
_builder.append(IContextFunction.SERVICE_CONTEXT_KEY, "");
_builder.append("=");
String _name = dialog.getName();
String _firstUpper = StringExtensions.toFirstUpper(_name);
_builder.append(_firstUpper, "");
String propContent = _builder.toString();
DialogDslVaaclipseViewCreator.this._commonUtils.addAnnAttr(annotationRef, dialog, "property", propContent);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
QualifiedName _fullyQualifiedName = DialogDslVaaclipseViewCreator.this._iQualifiedNameProvider.getFullyQualifiedName(pckg);
String _string = _fullyQualifiedName.toString();
it.setPackageName(_string);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION);
DialogDslVaaclipseViewCreator.this.toContextOperations(it, dialog, dialogClsName);
}
};
acceptor.<JvmGenericType>accept(contextCls, _function_1);
}
}
}
public String getMainBeanslotType(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
LDto _dto = dialog.getDto();
return AutowireUiFactory.getDtoFQN(_dto);
} else {
UiBeanSlot _mainBeanSlot = this.getMainBeanSlot(dialog);
JvmTypeReference _jvmType = _mainBeanSlot.getJvmType();
return _jvmType.getQualifiedName();
}
}
public String getUiName(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getECViewId(dialog);
} else {
UiView _uiView = dialog.getUiView();
return _uiView.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();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Object.class);
final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = DialogDslVaaclipseViewCreator.this._annotationTypesBuilder.annotationRef(Override.class);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(IEclipseContext.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "context", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmTypeReference _typeRef_1 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(String.class);
JvmFormalParameter _parameter_1 = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "contextKey", _typeRef_1);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
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.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "compute", _typeRef, _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 = new Procedure1<JvmConstructor>() {
public void apply(final JvmConstructor it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super();");
_builder.newLine();
_builder.append("uuid = UUID.randomUUID().toString();");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
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 = new Procedure1<JvmConstructor>() {
public void apply(final JvmConstructor it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = DialogDslVaaclipseViewCreator.this._annotationTypesBuilder.annotationRef(Inject.class);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(VerticalLayout.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "parent", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmTypeReference _typeRef_1 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(IEclipseContext.class);
JvmFormalParameter _parameter_1 = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "context", _typeRef_1);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
EList<JvmFormalParameter> _parameters_2 = it.getParameters();
JvmTypeReference _typeRef_2 = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(MApplication.class);
JvmFormalParameter _parameter_2 = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "app", _typeRef_2);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_2, _parameter_2);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("super(parent,context,app);");
_builder.newLine();
_builder.append("uuid = UUID.randomUUID().toString();");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
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;
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Logger.class);
final Procedure1<JvmField> _function = new Procedure1<JvmField>() {
public void apply(final JvmField it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("LoggerFactory.getLogger(\"vaaclipseDialog\")");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setInitializer(it, _function);
}
};
JvmField _field = this._jvmTypesBuilder.toField(dialog, "log", _typeRef, _function);
field = _field;
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();
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _uiModelPackageName = DialogDslVaaclipseViewCreator.this.getUiModelPackageName(dialog);
_builder.append(_uiModelPackageName, "");
_builder.append(".");
String _viewName = DialogDslVaaclipseViewCreator.this.getViewName(dialog);
_builder.append(_viewName, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "getViewId", _typeRef, _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
boolean _isStateful = dialog.isStateful();
if (_isStateful) {
EList<JvmMember> _members_1 = type.getMembers();
JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(String.class);
JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(Object.class);
JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Map.class, _typeRef_1, _typeRef_2);
final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
UiView _uiView = dialog.getUiView();
String _createRenderingParams = DialogDslVaaclipseViewCreator.this.createRenderingParams(_uiView);
_builder.append(_createRenderingParams, "");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(dialog, "createRenderingParams", _typeRef_3, _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(Locale.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "locale", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
UiView _uiView = dialog.getUiView();
String _localeChanged = DialogDslVaaclipseViewCreator.this.localeChanged(_uiView);
_builder.append(_localeChanged, "");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(dialog, "localeChanged", _typeRef_4, _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
} else {
final UiBeanSlot mainBeanSlot = this.getMainBeanSlot(dialog);
EList<JvmMember> _members_3 = type.getMembers();
JvmTypeReference _typeRef_5 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _name = mainBeanSlot.getName();
_builder.append(_name, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(dialog, "getMainBeanSlot", _typeRef_5, _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
JvmTypeReference _typeRef_6 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
JvmType _type = _jvmType.getType();
String _qualifiedName = _type.getQualifiedName();
_builder.append(_qualifiedName, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(dialog, "getBaseDtoName", _typeRef_6, _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
EList<JvmMember> _members_5 = type.getMembers();
JvmTypeReference _typeRef_7 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_5 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
String _qualifiedName = _jvmType.getQualifiedName();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(_qualifiedName);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "savedDto", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return ");
String _idForDtoString = DialogDslVaaclipseViewCreator.this.getIdForDtoString(mainBeanSlot);
_builder.append(_idForDtoString, "");
_builder.append(";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(dialog, "getIdForDtoString", _typeRef_7, _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
EList<JvmMember> _members_6 = type.getMembers();
JvmTypeReference _typeRef_8 = this._typeReferenceBuilder.typeRef(Object.class);
final Procedure1<JvmOperation> _function_6 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
String _qualifiedName = _jvmType.getQualifiedName();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(_qualifiedName);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "savedDto", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return ");
String _idForDto = DialogDslVaaclipseViewCreator.this.getIdForDto(mainBeanSlot);
_builder.append(_idForDto, "");
_builder.append(";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(dialog, "getIdForDto", _typeRef_8, _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
EList<JvmMember> _members_7 = type.getMembers();
JvmTypeReference _typeRef_9 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_7 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
JvmType _type = _jvmType.getType();
String _eventTopicSuffix = DialogDslVaaclipseViewCreator.this.getEventTopicSuffix(_type);
_builder.append(_eventTopicSuffix, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(dialog, "getEventTopicSuffix", _typeRef_9, _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
EList<JvmMember> _members_8 = type.getMembers();
JvmTypeReference _typeRef_10 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_8 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
JvmType _type = _jvmType.getType();
String _entityName = DialogDslVaaclipseViewCreator.this.getEntityName(_type);
_builder.append(_entityName, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_8 = this._jvmTypesBuilder.toMethod(dialog, "getDataName", _typeRef_10, _function_8);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_8, _method_8);
EList<JvmMember> _members_9 = type.getMembers();
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
String _qualifiedName = _jvmType.getQualifiedName();
JvmTypeReference _typeRef_11 = this._typeReferenceBuilder.typeRef(_qualifiedName);
JvmTypeReference _typeRef_12 = this._typeReferenceBuilder.typeRef(IDTOServiceWithMutablePersistence.class, _typeRef_11);
final Procedure1<JvmOperation> _function_9 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return (IDTOServiceWithMutablePersistence<");
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
String _qualifiedName = _jvmType.getQualifiedName();
_builder.append(_qualifiedName, "");
_builder.append(">) DtoServiceAccess");
_builder.newLineIfNotEmpty();
_builder.append("\t\t\t\t\t");
_builder.append(".getService(");
JvmTypeReference _jvmType_1 = mainBeanSlot.getJvmType();
String _qualifiedName_1 = _jvmType_1.getQualifiedName();
_builder.append(_qualifiedName_1, "\t\t\t\t\t");
_builder.append(".class);");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_9 = this._jvmTypesBuilder.toMethod(dialog, "getDtoService", _typeRef_12, _function_9);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_9, _method_9);
EList<JvmMember> _members_10 = type.getMembers();
JvmTypeReference _typeRef_13 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_10 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
JvmTypeReference _jvmType = mainBeanSlot.getJvmType();
JvmType _type = _jvmType.getType();
LEntity _entityFromDto = EntityUtils.getEntityFromDto(_type);
final LEntity entity = ((LEntity) _entityFromDto);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(IPersistenceService.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "persistenceService", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
boolean _notEquals = (!Objects.equal(entity, null));
if (_notEquals) {
final Procedure1<ITreeAppendable> _function_1 = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
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=DialogDslVaaclipseViewCreator.this._iQualifiedNameProvider.getFullyQualifiedName(entity);
}
_builder.append(_fullyQualifiedName, "");
_builder.append(".class);");
_builder.newLineIfNotEmpty();
_builder.append("log.debug(\"PersistenceService registered\");");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function_1);
}
}
};
JvmOperation _method_10 = this._jvmTypesBuilder.toMethod(dialog, "registerPersistenceUnit", _typeRef_13, _function_10);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_10, _method_10);
EList<JvmMember> _members_11 = type.getMembers();
JvmTypeReference _typeRef_14 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_11 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(Exception.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "ex", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _saveErrorMessage = DialogDslVaaclipseViewCreator.this.saveErrorMessage(dialog);
_builder.append(_saveErrorMessage, "");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_11 = this._jvmTypesBuilder.toMethod(dialog, "showSaveErrorMessage", _typeRef_14, _function_11);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_11, _method_11);
EList<JvmMember> _members_12 = type.getMembers();
JvmTypeReference _typeRef_15 = this._typeReferenceBuilder.typeRef(Void.TYPE);
final Procedure1<JvmOperation> _function_12 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmTypeReference _typeRef = DialogDslVaaclipseViewCreator.this._typeReferenceBuilder.typeRef(Exception.class);
JvmFormalParameter _parameter = DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.toParameter(dialog, "ex", _typeRef);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
String _deleteErrorMessage = DialogDslVaaclipseViewCreator.this.deleteErrorMessage(dialog);
_builder.append(_deleteErrorMessage, "");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_12 = this._jvmTypesBuilder.toMethod(dialog, "showDeleteErrorMessage", _typeRef_15, _function_12);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_12, _method_12);
EList<JvmMember> _members_13 = type.getMembers();
JvmTypeReference _typeRef_16 = this._typeReferenceBuilder.typeRef(IToolbarAction.class);
final Procedure1<JvmOperation> _function_13 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
{
ActionToolbar _toolbar = dialog.getToolbar();
boolean _notEquals = (!Objects.equal(_toolbar, null));
if (_notEquals) {
_builder.append("return new ");
ActionToolbar _toolbar_1 = dialog.getToolbar();
QualifiedName _fullyQualifiedName = DialogDslVaaclipseViewCreator.this._iQualifiedNameProvider.getFullyQualifiedName(_toolbar_1);
_builder.append(_fullyQualifiedName, "");
_builder.append("Action(uuid);");
} else {
_builder.append("return null;");
}
}
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_13 = this._jvmTypesBuilder.toMethod(dialog, "createToobarHelper", _typeRef_16, _function_13);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_13, _method_13);
EList<JvmMember> _members_14 = type.getMembers();
JvmTypeReference _typeRef_17 = this._typeReferenceBuilder.typeRef(String.class);
final Procedure1<JvmOperation> _function_14 = new Procedure1<JvmOperation>() {
public void apply(final JvmOperation it) {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = DialogDslVaaclipseViewCreator.this._annotationTypesBuilder.annotationRef(Override.class);
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() {
public void apply(final ITreeAppendable it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("return \"");
String _descriptionValue = dialog.getDescriptionValue();
String _key = I18NKeyGenerator.key(_descriptionValue);
_builder.append(_key, "");
_builder.append("\";");
it.append(_builder);
}
};
DialogDslVaaclipseViewCreator.this._jvmTypesBuilder.setBody(it, _function);
}
};
JvmOperation _method_14 = this._jvmTypesBuilder.toMethod(dialog, "getBindingPropertyName", _typeRef_17, _function_14);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_14, _method_14);
}
}
public String appendBeanSlots(final UiView view) {
StringConcatenation _builder = new StringConcatenation();
String body = _builder.toString();
EList<UiBeanSlot> slots = view.getBeanSlots();
for (final UiBeanSlot slot : slots) {
JvmTypeReference _jvmType = slot.getJvmType();
JvmType _type = _jvmType.getType();
String _name = IDataProvider.class.getName();
boolean _containsSuperType = this.containsSuperType(_type, _name);
if (_containsSuperType) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("IDataProvider dataProvider = new ");
JvmTypeReference _jvmType_1 = slot.getJvmType();
String _qualifiedName = _jvmType_1.getQualifiedName();
_builder_1.append(_qualifiedName, "");
_builder_1.append("();");
_builder_1.newLineIfNotEmpty();
_builder_1.append("dataProvider.setViewContext(viewContext);");
_builder_1.newLine();
_builder_1.append(body, "");
_builder_1.append("viewContext.createBeanSlot(\"");
String _name_1 = slot.getName();
_builder_1.append(_name_1, "");
_builder_1.append("\", ");
JvmTypeReference _jvmType_2 = slot.getJvmType();
String _qualifiedName_1 = _jvmType_2.getQualifiedName();
_builder_1.append(_qualifiedName_1, "");
_builder_1.append(".class).setValue(dataProvider);");
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
} else {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body, "");
_builder_2.append("viewContext.createBeanSlot(\"");
String _name_2 = slot.getName();
_builder_2.append(_name_2, "");
_builder_2.append("\", ");
JvmTypeReference _jvmType_3 = slot.getJvmType();
String _qualifiedName_2 = _jvmType_3.getQualifiedName();
_builder_2.append(_qualifiedName_2, "");
_builder_2.append(".class).setValue(new ");
JvmTypeReference _jvmType_4 = slot.getJvmType();
String _qualifiedName_3 = _jvmType_4.getQualifiedName();
_builder_2.append(_qualifiedName_3, "");
_builder_2.append("());");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
}
}
return body;
}
public boolean containsSuperType(final JvmType type, final String fqn) {
if ((!(type instanceof JvmDeclaredType))) {
return false;
}
RawSuperTypes _rawSuperTypes = new RawSuperTypes();
Set<String> _collectNames = _rawSuperTypes.collectNames(type);
return _collectNames.contains(fqn);
}
/**
* @param type
* @param dialog
* @return
*/
public String saveErrorMessage(final Dialog dialog) {
String _xblockexpression = null;
{
MessageItem messageItem = this.getDialogSaveMessageItem(dialog);
_xblockexpression = this.showSaveException(messageItem);
}
return _xblockexpression;
}
/**
* @param dialog
* @return
*/
public String deleteErrorMessage(final Dialog dialog) {
String _xblockexpression = null;
{
MessageItem messageItem = this.getDialogDeleteMessageItem(dialog);
_xblockexpression = this.showDeleteException(messageItem);
}
return _xblockexpression;
}
/**
* @param type
* @return
*/
public String getEventTopicSuffix(final JvmType type) {
LEntity entity = EntityUtils.getEntityFromDto(type);
boolean _notEquals = (!Objects.equal(entity, null));
if (_notEquals) {
StringConcatenation _builder = new StringConcatenation();
EObject _eContainer = entity.eContainer();
String _name = ((LTypedPackage) _eContainer).getName();
String _name_1 = entity.getName();
String _entityIdModifiedCategory = EventBrokerMsg.getEntityIdModifiedCategory(_name, _name_1);
_builder.append(_entityIdModifiedCategory, "");
return _builder.toString();
}
StringConcatenation _builder_1 = new StringConcatenation();
return _builder_1.toString();
}
/**
* @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();
}
/**
* @param slot
* @return
*/
public String getIdForDtoString(final UiBeanSlot slot) {
JvmTypeReference _jvmType = slot.getJvmType();
final JvmType type = _jvmType.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)) {
JvmField idField = ((JvmField) id);
JvmTypeReference _type = idField.getType();
final JvmType idType = _type.getType();
if ((idType instanceof JvmPrimitiveType)) {
String _simpleName = Integer.TYPE.getSimpleName();
String _simpleName_1 = ((JvmPrimitiveType)idType).getSimpleName();
boolean _equals = _simpleName.equals(_simpleName_1);
if (_equals) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("new Integer(savedDto.getId()).toString()");
return _builder_1.toString();
}
} else {
String _simpleName_2 = String.class.getSimpleName();
String _simpleName_3 = idType.getSimpleName();
boolean _equals_1 = _simpleName_2.equals(_simpleName_3);
if (_equals_1) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append("savedDto.getId()");
return _builder_2.toString();
}
}
}
}
}
}
StringConcatenation _builder_3 = new StringConcatenation();
return _builder_3.toString();
}
/**
* @param slot
* @return
*/
public String getIdForDto(final UiBeanSlot slot) {
JvmTypeReference _jvmType = slot.getJvmType();
final JvmType type = _jvmType.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) {
LDto _dto = dialog.getDto();
final UiBeanSlot slot = AutowireUiFactory.createBeanSlot(_dto);
LDto _dto_1 = dialog.getDto();
String _dtoFQN = AutowireUiFactory.getDtoFQN(_dto_1);
final JvmTypeReference typeRef = this._typeReferenceBuilder.typeRef(_dtoFQN);
slot.setJvmType(typeRef);
return slot;
} else {
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = _uiView.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();
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = _uiView.getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("dto");
JvmTypeReference _jvmType = uiBeanSlot.getJvmType();
String _simpleName = _jvmType.getSimpleName();
_builder_1.append(_simpleName, "");
_builder_1.append("Service = (IDTOServiceWithMutablePersistence<");
JvmTypeReference _jvmType_1 = uiBeanSlot.getJvmType();
String _simpleName_1 = _jvmType_1.getSimpleName();
_builder_1.append(_simpleName_1, "");
_builder_1.append(">)DtoServiceAccess.getService(");
JvmTypeReference _jvmType_2 = uiBeanSlot.getJvmType();
String _simpleName_2 = _jvmType_2.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;
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = _uiView.getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
{
JvmTypeReference _jvmType = uiBeanSlot.getJvmType();
JvmType _type = _jvmType.getType();
LEntity entity = EntityUtils.getEntityFromDto(_type);
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_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("eventBroker.subscribe(EventBrokerMsg.AUTOWIRED_ENTITY_PREFIX+\"");
String _name = entity.getName();
_builder_1.append(_name, "");
_builder_1.append("\", tableSelectionHandler);");
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
}
}
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("\t");
_builder.append(body, "\t");
_builder.newLineIfNotEmpty();
{
ActionToolbar _toolbar = dialog.getToolbar();
boolean _notEquals = (!Objects.equal(_toolbar, null));
if (_notEquals) {
_builder.append("\tString uuid = (String)getContext().get(\"");
ActionToolbar _toolbar_1 = dialog.getToolbar();
String _name = _toolbar_1.getName();
_builder.append(_name, "");
_builder.append("_TOOLBAR_ID\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("eventBroker.subscribe(EventBrokerMsg.ACTION_BUTTON_EXECUTE_PREFIX+\"");
ActionToolbar _toolbar_2 = dialog.getToolbar();
String _name_1 = _toolbar_2.getName();
_builder.append(_name_1, "\t");
_builder.append("Action\"+uuid, dispatchActionHandler);");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("eventBroker.subscribe(EventBrokerMsg.DIALOG_STRATEGY_CHANGED,");
_builder.newLine();
_builder.append("\t\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(tableSelectionHandler);");
_builder.newLine();
_builder.append("eventBroker.unsubscribe(strategyEventHandler);");
String unsubscribers = _builder.toString();
return unsubscribers;
}
/**
* @param jvmType
* @return
*/
public String getDtoIdGetter(final JvmTypeReference jvmType) {
JvmType _type = jvmType.getType();
LEntity _entityFromDto = EntityUtils.getEntityFromDto(_type);
return this.getDtoIdGetter(_entityFromDto);
}
/**
* @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) {
boolean _or = false;
boolean _isId = attribute.isId();
if (_isId) {
_or = true;
} else {
boolean _isUuid = attribute.isUuid();
_or = _isUuid;
}
if (_or) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("get");
String _name = attribute.getName();
String _firstUpper = Strings.toFirstUpper(_name);
_builder.append(_firstUpper, "");
_builder.append("()");
return _builder.toString();
}
}
}
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("getId()");
return _builder_1.toString();
}
/**
* @param body
* @param type
* @param dtoName
*/
public String addEntityIdModificationSendForDto(final String body, final JvmType type, final String dtoName) {
LEntity entity = EntityUtils.getEntityFromDto(type);
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.newLineIfNotEmpty();
_builder.append("eventBroker.send(EventBrokerMsg.REFRESH_VIEW+\"");
EObject _eContainer = null;
if (entity!=null) {
_eContainer=entity.eContainer();
}
String _name = ((LTypedPackage) _eContainer).getName();
String _name_1 = null;
if (entity!=null) {
_name_1=entity.getName();
}
String _entityIdModifiedCategory = EventBrokerMsg.getEntityIdModifiedCategory(_name, _name_1);
_builder.append(_entityIdModifiedCategory, "");
_builder.append("\", new EventBrokerMsg(");
_builder.append(dtoName, "");
_builder.append(".");
String _dtoIdGetter = this.getDtoIdGetter(entity);
_builder.append(_dtoIdGetter, "");
_builder.append(", \"");
String _name_2 = null;
if (entity!=null) {
_name_2=entity.getName();
}
_builder.append(_name_2, "");
_builder.append("\"));");
_builder.newLineIfNotEmpty();
return _builder.toString();
}
/**
* @param dialog
* @return
*/
public String loadBeans(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
String body = _builder.toString();
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = _uiView.getBeanSlots();
for (final UiBeanSlot uiBeanSlot : _beanSlots) {
{
JvmTypeReference _jvmType = uiBeanSlot.getJvmType();
final String simpleTypeName = _jvmType.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 showDeleteException(final MessageItem messageItem) {
return this.showException(messageItem, "Delete of this element is not allowed!");
}
public String showSaveException(final MessageItem messageItem) {
return this.showException(messageItem, "Save of this element is not allowed!");
}
public String showException(final MessageItem messageItem, final String alternateMessage) {
boolean _notEquals = (!Objects.equal(messageItem, null));
if (_notEquals) {
String messageClassName = MessageDslJvmModelInferrer.getFQMessageClass(messageItem);
String messageItemName = MessageDslJvmModelInferrer.getMethodName(messageItem);
StringConcatenation _builder = new StringConcatenation();
_builder.append("org.eclipse.osbp.xtext.messagedsl.common.Message errorMsg = ");
_builder.append(messageClassName, "");
_builder.append(".");
_builder.append(messageItemName, "");
_builder.append("(ex, ex.getMessage());");
_builder.newLineIfNotEmpty();
_builder.append("Notification.show(errorMsg.getShowMessage());");
_builder.newLine();
_builder.append("log.error(errorMsg.getLogMessage());");
return _builder.toString();
} else {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("Notification.show(\"");
_builder_1.append(alternateMessage, "");
_builder_1.append("\");");
_builder_1.newLineIfNotEmpty();
_builder_1.append("log.error(ex.getClass().getSimpleName() + \" - ");
_builder_1.append(alternateMessage, "");
_builder_1.append(": \" + ex.getMessage());");
return _builder_1.toString();
}
}
public MessageItem getDialogDeleteMessageItem(final Dialog dialog) {
return this.dialogMessageItem(dialog, DialogActionEnum.DIALOG_ACTION_DELETE_VALUE);
}
public MessageItem getDialogSaveMessageItem(final Dialog dialog) {
return this.dialogMessageItem(dialog, DialogActionEnum.DIALOG_ACTION_SAVE_VALUE);
}
public MessageItem dialogMessageItem(final Dialog dialog, final int dialogActionOrdinal) {
ActionToolbar _toolbar = dialog.getToolbar();
boolean _notEquals = (!Objects.equal(_toolbar, null));
if (_notEquals) {
ActionToolbar _toolbar_1 = dialog.getToolbar();
EList<ActionButton> _actions = _toolbar_1.getActions();
for (final ActionButton action : _actions) {
ActionType _actionType = action.getActionType();
if ((_actionType instanceof ActionDialog)) {
ActionType _actionType_1 = action.getActionType();
ActionDialog osActionDialog = ((ActionDialog) _actionType_1);
DialogActionEnum _action = osActionDialog.getAction();
int _ordinal = _action.ordinal();
boolean _equals = (dialogActionOrdinal == _ordinal);
if (_equals) {
MessageItem _message = action.getMessage();
return ((MessageItem) _message);
}
}
}
}
return null;
}
public String localeChanged(final UiView view) {
String body = "";
EList<UiBeanSlot> slots = view.getBeanSlots();
for (final UiBeanSlot slot : slots) {
JvmTypeReference _jvmType = slot.getJvmType();
JvmType _type = _jvmType.getType();
String _name = IStateMachineParticipant.class.getName();
boolean _containsSuperType = this.containsSuperType(_type, _name);
if (_containsSuperType) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(body, "");
_builder.newLineIfNotEmpty();
_builder.append("if(getViewContext() != null && getViewContext().getBeanSlot(\"");
String _name_1 = slot.getName();
_builder.append(_name_1, "");
_builder.append("\") != null) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("((IStateMachineParticipant)getViewContext().getBeanSlot(\"");
String _name_2 = slot.getName();
_builder.append(_name_2, "\t");
_builder.append("\").getValue()).setLocale(locale);");
_builder.newLineIfNotEmpty();
_builder.append("}");
body = _builder.toString();
} else {
JvmTypeReference _jvmType_1 = slot.getJvmType();
JvmType _type_1 = _jvmType_1.getType();
String _name_3 = IStateMachine.class.getName();
boolean _containsSuperType_1 = this.containsSuperType(_type_1, _name_3);
if (_containsSuperType_1) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("if(getViewContext() != null && getViewContext().getBeanSlot(\"");
String _name_4 = slot.getName();
_builder_1.append(_name_4, "");
_builder_1.append("\") != null) {");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t");
_builder_1.append("((IStateMachine)getViewContext().getBeanSlot(\"");
String _name_5 = slot.getName();
_builder_1.append(_name_5, "\t");
_builder_1.append("\").getValue()).setLocale(locale);");
_builder_1.newLineIfNotEmpty();
_builder_1.append("}");
body = _builder_1.toString();
}
}
}
return body;
}
public String createRenderingParams(final UiView view) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Map<String, Object> params = super.createRenderingParams();");
_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) {
boolean _or = false;
JvmTypeReference _jvmType = slot.getJvmType();
JvmType _type = _jvmType.getType();
String _name = IStateMachineParticipant.class.getName();
boolean _containsSuperType = this.containsSuperType(_type, _name);
if (_containsSuperType) {
_or = true;
} else {
JvmTypeReference _jvmType_1 = slot.getJvmType();
JvmType _type_1 = _jvmType_1.getType();
String _name_1 = IPeripheral.class.getName();
boolean _containsSuperType_1 = this.containsSuperType(_type_1, _name_1);
_or = _containsSuperType_1;
}
if (_or) {
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append(body, "");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
_builder_1.append("IStateMachineParticipant ");
String _name_2 = slot.getName();
_builder_1.append(_name_2, "\t\t");
_builder_1.append(" = new ");
JvmTypeReference _jvmType_2 = slot.getJvmType();
String _qualifiedName = _jvmType_2.getQualifiedName();
_builder_1.append(_qualifiedName, "\t\t");
_builder_1.append("();");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
String _name_3 = slot.getName();
_builder_1.append(_name_3, "\t\t");
_builder_1.append(".setViewContext((IViewContext)viewContext);");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
String _name_4 = slot.getName();
_builder_1.append(_name_4, "\t\t");
_builder_1.append(".setLocale(getUser().getLocale());");
_builder_1.newLineIfNotEmpty();
_builder_1.append("\t\t");
_builder_1.append("viewContext.createBeanSlot(\"");
String _name_5 = slot.getName();
_builder_1.append(_name_5, "\t\t");
_builder_1.append("\", ");
JvmTypeReference _jvmType_3 = slot.getJvmType();
String _qualifiedName_1 = _jvmType_3.getQualifiedName();
_builder_1.append(_qualifiedName_1, "\t\t");
_builder_1.append(".class).setValue(");
String _name_6 = slot.getName();
_builder_1.append(_name_6, "\t\t");
_builder_1.append(");");
_builder_1.newLineIfNotEmpty();
body = _builder_1.toString();
} else {
JvmTypeReference _jvmType_4 = slot.getJvmType();
JvmType _type_2 = _jvmType_4.getType();
String _name_7 = IStateMachine.class.getName();
boolean _containsSuperType_2 = this.containsSuperType(_type_2, _name_7);
if (_containsSuperType_2) {
StringConcatenation _builder_2 = new StringConcatenation();
_builder_2.append(body, "");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("IStateMachine ");
String _name_8 = slot.getName();
_builder_2.append(_name_8, "\t\t");
_builder_2.append(" = new ");
JvmTypeReference _jvmType_5 = slot.getJvmType();
String _qualifiedName_2 = _jvmType_5.getQualifiedName();
_builder_2.append(_qualifiedName_2, "\t\t");
_builder_2.append("();");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_9 = slot.getName();
_builder_2.append(_name_9, "\t\t");
_builder_2.append(".setLocale(getUser().getLocale());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_10 = slot.getName();
_builder_2.append(_name_10, "\t\t");
_builder_2.append(".setUser(getUser());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_11 = slot.getName();
_builder_2.append(_name_11, "\t\t");
_builder_2.append(".setDslMetadataService(getDslMetadataService());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_12 = slot.getName();
_builder_2.append(_name_12, "\t\t");
_builder_2.append(".setThemeResourceService(getThemeResourceService());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
String _name_13 = slot.getName();
_builder_2.append(_name_13, "\t\t");
_builder_2.append(".setReportProvider(getReportProvider());");
_builder_2.newLineIfNotEmpty();
_builder_2.append("\t\t");
_builder_2.append("viewContext.createBeanSlot(\"");
String _name_14 = slot.getName();
_builder_2.append(_name_14, "\t\t");
_builder_2.append("\", ");
JvmTypeReference _jvmType_6 = slot.getJvmType();
String _qualifiedName_3 = _jvmType_6.getQualifiedName();
_builder_2.append(_qualifiedName_3, "\t\t");
_builder_2.append(".class).setValue(");
String _name_15 = slot.getName();
_builder_2.append(_name_15, "\t\t");
_builder_2.append(");");
_builder_2.newLineIfNotEmpty();
body = _builder_2.toString();
} else {
StringConcatenation _builder_3 = new StringConcatenation();
_builder_3.append(body, "");
_builder_3.newLineIfNotEmpty();
_builder_3.append("\t\t");
_builder_3.append("viewContext.createBeanSlot(\"");
String _name_16 = slot.getName();
_builder_3.append(_name_16, "\t\t");
_builder_3.append("\", ");
JvmTypeReference _jvmType_7 = slot.getJvmType();
String _qualifiedName_4 = _jvmType_7.getQualifiedName();
_builder_3.append(_qualifiedName_4, "\t\t");
_builder_3.append(".class).setValue(new ");
JvmTypeReference _jvmType_8 = slot.getJvmType();
String _qualifiedName_5 = _jvmType_8.getQualifiedName();
_builder_3.append(_qualifiedName_5, "\t\t");
_builder_3.append("());");
_builder_3.newLineIfNotEmpty();
body = _builder_3.toString();
}
}
}
StringConcatenation _builder_4 = new StringConcatenation();
_builder_4.append(body, "");
_builder_4.newLineIfNotEmpty();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("@Override");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public void afterUiRendering(IContext context) {");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("}");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("@Override");
_builder_4.newLine();
_builder_4.append("\t");
_builder_4.append("public void beforeBind(IContext context) {");
_builder_4.newLine();
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 afterBind(IContext context) {");
_builder_5.newLine();
body = _builder_5.toString();
for (final UiBeanSlot slot_1 : slots) {
JvmTypeReference _jvmType_9 = slot_1.getJvmType();
JvmType _type_3 = _jvmType_9.getType();
String _name_17 = IStateMachineParticipant.class.getName();
boolean _containsSuperType_3 = this.containsSuperType(_type_3, _name_17);
if (_containsSuperType_3) {
StringConcatenation _builder_6 = new StringConcatenation();
_builder_6.append(body, "");
_builder_6.newLineIfNotEmpty();
_builder_6.append("\t\t");
_builder_6.append("((IStateMachineParticipant)context.getBeanSlot(\"");
String _name_18 = slot_1.getName();
_builder_6.append(_name_18, "\t\t");
_builder_6.append("\").getValue()).init();");
_builder_6.newLineIfNotEmpty();
body = _builder_6.toString();
}
}
for (final UiBeanSlot slot_2 : slots) {
JvmTypeReference _jvmType_10 = slot_2.getJvmType();
JvmType _type_4 = _jvmType_10.getType();
String _name_19 = IStateMachine.class.getName();
boolean _containsSuperType_4 = this.containsSuperType(_type_4, _name_19);
if (_containsSuperType_4) {
StringConcatenation _builder_7 = new StringConcatenation();
_builder_7.append(body, "");
_builder_7.newLineIfNotEmpty();
_builder_7.append("\t\t");
_builder_7.append("((IStateMachine)context.getBeanSlot(\"");
String _name_20 = slot_2.getName();
_builder_7.append(_name_20, "\t\t");
_builder_7.append("\").getValue()).start();");
_builder_7.newLineIfNotEmpty();
body = _builder_7.toString();
}
}
StringConcatenation _builder_8 = new StringConcatenation();
_builder_8.append(body, "");
_builder_8.newLineIfNotEmpty();
_builder_8.append("\t");
_builder_8.append("}");
_builder_8.newLine();
_builder_8.append("};");
_builder_8.newLine();
_builder_8.append("params.put(IViewContext.PARAM_CONFIGURATION, config);");
_builder_8.newLine();
_builder_8.append("return params;");
_builder_8.newLine();
body = _builder_8.toString();
return body;
}
/**
* <p>create a handler for the load bean event.
*/
public String tableSelectionHandler(final Dialog dialog) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("tableSelectionHandler = new EventHandler() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void handleEvent(Event event) {");
_builder.newLine();
_builder.append("\t\t");
String _loadBeans = this.loadBeans(dialog);
_builder.append(_loadBeans, "\t\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
return _builder.toString();
}
/**
* 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();
UiView _uiView = dialog.getUiView();
EList<UiBeanSlot> _beanSlots = _uiView.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 {
UiView _uiView = dialog.getUiView();
return _uiView.getName();
}
}
public String getUiModelPackageName(final Dialog dialog) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
return AutowireUiFactory.getECViewPackage(dialog);
} else {
UiView _uiView = dialog.getUiView();
EObject parent = _uiView.eContainer();
while ((!(parent instanceof UiModel))) {
EObject _eContainer = parent.eContainer();
parent = _eContainer;
}
UiModel uiModel = ((UiModel) parent);
return uiModel.getPackageName();
}
}
}