| /** |
| * 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.ArrayList; |
| import java.util.HashMap; |
| import java.util.List; |
| 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.semantic.entity.LEntity; |
| import org.eclipse.osbp.ecview.core.common.context.IViewContext; |
| import org.eclipse.osbp.ecview.core.extension.model.extension.util.SimpleExtensionModelFactory; |
| 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.persistence.IPersistenceService; |
| 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.dialogdsl.Dialog; |
| import org.eclipse.osbp.xtext.dialogdsl.DialogPackage; |
| 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.TypesFactory; |
| import org.eclipse.xtext.common.types.util.TypeReferences; |
| 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.InputOutput; |
| 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 CommonUtils _commonUtils; |
| |
| @Inject |
| @Extension |
| private EntityUtils _entityUtils; |
| |
| @Inject |
| @Extension |
| private DialogConstants _dialogConstants; |
| |
| @Inject |
| @Extension |
| private IQualifiedNameProvider _iQualifiedNameProvider; |
| |
| @Inject |
| private TypeReferences references; |
| |
| @Inject |
| private TypesFactory typesFactory; |
| |
| private JvmAnnotationReferenceBuilder _annotationTypesBuilder; |
| |
| private JvmTypeReferenceBuilder _typeReferenceBuilder; |
| |
| private HashMap<String, List<String>> actionMap; |
| |
| private final SimpleExtensionModelFactory factory = new SimpleExtensionModelFactory(); |
| |
| /** |
| * @param element |
| * the model to create one or more |
| * {@link JvmDeclaredType declared |
| * types} from. |
| * @param acceptor |
| * each created |
| * {@link JvmDeclaredType type} |
| * without a container should be passed to the acceptor in order |
| * get attached to the current resource. The acceptor's |
| * {@link IJvmDeclaredTypeAcceptor#accept(org.eclipse.xtext.common.types.JvmDeclaredType) |
| * accept(..)} method takes the constructed empty type for the |
| * pre-indexing phase. This one is further initialized in the |
| * indexing phase using the closure you pass to the returned |
| * {@link IPostIndexingInitializing#initializeLater(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) |
| * initializeLater(..)}. |
| * @param isPreIndexingPhase |
| * whether the method is called in a pre-indexing phase, i.e. |
| * when the global index is not yet fully updated. You must not |
| * rely on linking using the index if isPreIndexingPhase is |
| * <code>true</code>. |
| */ |
| public void createMobileUI(final DialogPackage pckg, final Dialog dialog, final IJvmDeclaredTypeAcceptor acceptor, final JvmAnnotationReferenceBuilder annotationTypesBuilder, final JvmTypeReferenceBuilder typeReferenceBuilder) { |
| this._annotationTypesBuilder = annotationTypesBuilder; |
| this._typeReferenceBuilder = typeReferenceBuilder; |
| UiView _uiView = dialog.getUiView(); |
| final UiMobileView uiMobileView = ((UiMobileView) _uiView); |
| boolean _and = false; |
| boolean _and_1 = false; |
| boolean _notEquals = (!Objects.equal(uiMobileView, null)); |
| if (!_notEquals) { |
| _and_1 = false; |
| } else { |
| String _name = uiMobileView.getName(); |
| boolean _notEquals_1 = (!Objects.equal(_name, null)); |
| _and_1 = _notEquals_1; |
| } |
| if (!_and_1) { |
| _and = false; |
| } else { |
| String _name_1 = uiMobileView.getName(); |
| boolean _isEmpty = _name_1.isEmpty(); |
| boolean _not = (!_isEmpty); |
| _and = _not; |
| } |
| if (_and) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("UIView: "); |
| CharSequence _fQNView = this.getFQNView(dialog, pckg); |
| _builder.append(_fQNView, ""); |
| InputOutput.<String>println(_builder.toString()); |
| StringConcatenation _builder_1 = new StringConcatenation(); |
| CharSequence _fQNView_1 = this.getFQNView(dialog, pckg); |
| _builder_1.append(_fQNView_1, ""); |
| JvmGenericType cls = this._jvmTypesBuilder.toClass(dialog, _builder_1.toString()); |
| final Procedure1<JvmGenericType> _function = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(DialogDslMobileViewCreator.this._dialogConstants.MOBILEVIEW_SYPERTYPE); |
| _superTypes.add(_typeRef); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| DialogDslMobileViewCreator.this.toFields(it, dialog, pckg); |
| DialogDslMobileViewCreator.this.toOperations(it, dialog, pckg); |
| } |
| }; |
| 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 _notEquals = (!Objects.equal(_get, null)); |
| if (_notEquals) { |
| 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) { |
| JvmTypeReference _jvmTypeRef = this.getJvmTypeRef(uiMobileView); |
| final String dto = _jvmTypeRef.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 = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(AdapterImpl.class); |
| _superTypes.add(_typeRef); |
| it.setVisibility(JvmVisibility.PRIVATE); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| EList<JvmMember> _members = cls.getMembers(); |
| JvmTypeReference _typeRef_1 = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(Notification.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(uiMobileView, "msg", _typeRef); |
| DialogDslMobileViewCreator.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("// 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 = DialogDslMobileViewCreator.this.actionMap.get(DialogDslMobileViewCreator.this._dialogConstants.ACTION_SAVE); |
| for(final String saveId : _get) { |
| { |
| String _navPageContainer = DialogDslMobileViewCreator.this.getNavPageContainer(saveId); |
| boolean _isTable = DialogDslMobileViewCreator.this.isTable(uiMobileView, _navPageContainer); |
| if (_isTable) { |
| _builder.append("try {"); |
| _builder.newLine(); |
| _builder.append("\t"); |
| _builder.append("YTable yTable = findTable(\""); |
| String _navPageContainer_1 = DialogDslMobileViewCreator.this.getNavPageContainer(saveId); |
| _builder.append(_navPageContainer_1, "\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.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = DialogDslMobileViewCreator.this._jvmTypesBuilder.toMethod(uiMobileView, "notifyChanged", _typeRef_1, _function); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method); |
| } |
| }; |
| acceptor.<JvmGenericType>accept(cls, _function); |
| } |
| |
| /** |
| * @param type |
| * @param uiMobileView |
| */ |
| public void toSaveFields(final JvmGenericType type, final UiMobileView uiMobileView) { |
| JvmField field = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef("SaveActionObserver"); |
| JvmField _field = this._jvmTypesBuilder.toField(uiMobileView, "observer", _typeRef); |
| field = _field; |
| field.setVisibility(JvmVisibility.PRIVATE); |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| int idx = 0; |
| } |
| |
| /** |
| * @param type |
| * @param uiMobileView |
| */ |
| public void toDisposeMethod(final JvmGenericType type, final UiMobileView uiMobileView) { |
| EList<JvmMember> _members = type.getMembers(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| List<String> _get = DialogDslMobileViewCreator.this.actionMap.get(DialogDslMobileViewCreator.this._dialogConstants.ACTION_SAVE); |
| boolean _notEquals = (!Objects.equal(_get, null)); |
| if (_notEquals) { |
| _builder.append("unregisterSaveHandler();"); |
| _builder.newLine(); |
| } |
| } |
| _builder.append("super.dispose();"); |
| _builder.newLine(); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "dispose", _typeRef, _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(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PRIVATE); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setDocumentation(it, "Unregister an observer at the EObject for the save-navigationBarAction"); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| { |
| List<String> _get = DialogDslMobileViewCreator.this.actionMap.get(DialogDslMobileViewCreator.this._dialogConstants.ACTION_SAVE); |
| for(final String saveId : _get) { |
| _builder.append("unregisterHandler(\""); |
| _builder.append(saveId, ""); |
| _builder.append("\", observer);"); |
| _builder.newLineIfNotEmpty(); |
| } |
| } |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "unregisterSaveHandler", _typeRef, _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(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PRIVATE); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setDocumentation(it, "Register an observer at the EObject for the save-navigationBarAction"); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| 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 = DialogDslMobileViewCreator.this.actionMap.get(DialogDslMobileViewCreator.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.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "registerSaveHandler", _typeRef, _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(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(ComponentContainer.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(uiMobileView, "parent", _typeRef); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(String.class); |
| JvmFormalParameter _parameter_1 = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(uiMobileView, "fragment", _typeRef_1); |
| DialogDslMobileViewCreator.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("\t"); |
| _builder.append("super.initialize(parent, fragment);"); |
| _builder.newLine(); |
| { |
| List<String> _get = DialogDslMobileViewCreator.this.actionMap.get(DialogDslMobileViewCreator.this._dialogConstants.ACTION_SAVE); |
| boolean _notEquals = (!Objects.equal(_get, null)); |
| if (_notEquals) { |
| _builder.append("\t\t\t\t\t\t"); |
| _builder.append("registerSaveHandler();"); |
| _builder.newLine(); |
| _builder.append("\t\t\t\t\t\t"); |
| } |
| } |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(uiMobileView, "initialize", _typeRef, _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) { |
| JvmField field = null; |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(long.class); |
| final Procedure1<JvmField> _function = new Procedure1<JvmField>() { |
| public void apply(final JvmField it) { |
| it.setVisibility(JvmVisibility.PRIVATE); |
| it.setStatic(true); |
| it.setFinal(true); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("1L"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field = this._jvmTypesBuilder.toField(dialog, "serialVersionUID", _typeRef, _function); |
| field = _field; |
| EList<JvmMember> _members = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members, field); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(Logger.class); |
| final Procedure1<JvmField> _function_1 = 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(\"mobileDialog\")"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setInitializer(it, _function); |
| } |
| }; |
| JvmField _field_1 = this._jvmTypesBuilder.toField(dialog, "log", _typeRef_1, _function_1); |
| field = _field_1; |
| field.setFinal(true); |
| field.setStatic(true); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmField _field_2 = this._jvmTypesBuilder.toField(dialog, "persistenceService", _typeRef_2); |
| field = _field_2; |
| field.setStatic(true); |
| EList<JvmMember> _members_2 = type.getMembers(); |
| this._jvmTypesBuilder.<JvmField>operator_add(_members_2, 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 = new Procedure1<JvmGenericType>() { |
| public void apply(final JvmGenericType it) { |
| EList<JvmTypeReference> _superTypes = it.getSuperTypes(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef("org.eclipse.osbp.mobile.vaadin.ecview.api.IMobileUiParticipant"); |
| _superTypes.add(_typeRef); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setDocumentation(it, GeneratorConstants.GENERATED_CLASSES_DOCUMENTATION); |
| it.setStatic(true); |
| JvmAnnotationReference annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Component.class); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("uriFragment="); |
| CharSequence _fQNView = DialogDslMobileViewCreator.this.getFQNView(dialog, pckg); |
| _builder.append(_fQNView, ""); |
| String propContent = _builder.toString(); |
| DialogDslMobileViewCreator.this._commonUtils.addAnnAttr(annotationRef, dialog, "property", propContent); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef); |
| DialogDslMobileViewCreator.this.toUiProviderConstructor(it, dialog); |
| DialogDslMobileViewCreator.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 = 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();"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| 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(); |
| JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(String.class); |
| final Procedure1<JvmOperation> _function = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.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 \""); |
| CharSequence _fQNView = DialogDslMobileViewCreator.this.getFQNView(dialog, pckg); |
| _builder.append(_fQNView, ""); |
| _builder.append("\";"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "getFragmentName", _typeRef, _function); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef("org.eclipse.osbp.mobile.vaadin.ecview.api.IMobileUiParticipantHandle"); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(UI.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "ui", _typeRef); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(String.class); |
| JvmFormalParameter _parameter_1 = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "fragment", _typeRef_1); |
| DialogDslMobileViewCreator.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("return new "); |
| String _name = dialog.getName(); |
| _builder.append(_name, ""); |
| _builder.append(DialogDslMobileViewCreator.this._dialogConstants.MOBILE_VIEW_PREFIX, ""); |
| _builder.append("();"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(dialog, "createHandle", _typeRef_1, _function_1); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1); |
| } |
| |
| /** |
| * <p>build the methods.</p> |
| * |
| * @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) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); |
| UiView _uiView = dialog.getUiView(); |
| EObject _eContainer = _uiView.eContainer(); |
| final UiModel uiModel = ((UiModel) _eContainer); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("return \""); |
| String _packageName = uiModel.getPackageName(); |
| _builder.append(_packageName, ""); |
| _builder.append("."); |
| UiView _uiView = dialog.getUiView(); |
| String _name = _uiView.getName(); |
| _builder.append(_name, ""); |
| _builder.append("\";"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method = this._jvmTypesBuilder.toMethod(dialog, "getViewId", _typeRef, _function); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method); |
| EList<JvmMember> _members_1 = type.getMembers(); |
| JvmTypeReference _typeRef_1 = this._typeReferenceBuilder.typeRef(Class.class); |
| final Procedure1<JvmOperation> _function_1 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmAnnotationReference> _annotations = it.getAnnotations(); |
| JvmAnnotationReference _annotationRef = DialogDslMobileViewCreator.this._annotationTypesBuilder.annotationRef(Override.class); |
| DialogDslMobileViewCreator.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 "); |
| JvmTypeReference _jvmTypeRef = DialogDslMobileViewCreator.this.getJvmTypeRef(dialog); |
| String _qualifiedName = _jvmTypeRef.getQualifiedName(); |
| _builder.append(_qualifiedName, ""); |
| _builder.append(".class;"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(dialog, "getDtoClass", _typeRef_1, _function_1); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1); |
| UiView _uiView = dialog.getUiView(); |
| EList<UiBeanSlot> _beanSlots = _uiView.getBeanSlots(); |
| int _size = _beanSlots.size(); |
| boolean _greaterThan = (_size > 0); |
| if (_greaterThan) { |
| EList<JvmMember> _members_2 = type.getMembers(); |
| JvmTypeReference _typeRef_2 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_2 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PROTECTED); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(IViewContext.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "viewContext", _typeRef); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); |
| EList<JvmFormalParameter> _parameters_1 = it.getParameters(); |
| JvmTypeReference _typeRef_1 = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(String.class); |
| JvmFormalParameter _parameter_1 = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "fragment", _typeRef_1); |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1); |
| final Procedure1<ITreeAppendable> _function = new Procedure1<ITreeAppendable>() { |
| public void apply(final ITreeAppendable it) { |
| String _setBeanToViewContext = DialogDslMobileViewCreator.this.setBeanToViewContext(dialog); |
| it.append(_setBeanToViewContext); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(dialog, "doInitialize", _typeRef_2, _function_2); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2); |
| } |
| JvmTypeReference _jvmTypeRef = this.getJvmTypeRef(dialog); |
| JvmType _type = _jvmTypeRef.getType(); |
| LEntity _entityFromDto = EntityUtils.getEntityFromDto(_type); |
| final LEntity entity = ((LEntity) _entityFromDto); |
| EList<JvmMember> _members_3 = type.getMembers(); |
| JvmTypeReference _typeRef_3 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_3 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "persistenceService", _typeRef); |
| DialogDslMobileViewCreator.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("this.persistenceService = persistenceService;"); |
| _builder.newLine(); |
| _builder.append("this.persistenceService.registerPersistenceUnit(\""); |
| String _persistenceUnit = null; |
| if (entity!=null) { |
| _persistenceUnit=entity.getPersistenceUnit(); |
| } |
| _builder.append(_persistenceUnit, ""); |
| _builder.append("\", "); |
| QualifiedName _fullyQualifiedName = null; |
| if (entity!=null) { |
| _fullyQualifiedName=DialogDslMobileViewCreator.this._iQualifiedNameProvider.getFullyQualifiedName(entity); |
| } |
| _builder.append(_fullyQualifiedName, ""); |
| _builder.append(".class);"); |
| _builder.newLineIfNotEmpty(); |
| _builder.append("log.debug(\"PersistenceService bound\");"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(dialog, "bindPersistenceService", _typeRef_3, _function_3); |
| this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3); |
| EList<JvmMember> _members_4 = type.getMembers(); |
| JvmTypeReference _typeRef_4 = this._typeReferenceBuilder.typeRef(Void.TYPE); |
| final Procedure1<JvmOperation> _function_4 = new Procedure1<JvmOperation>() { |
| public void apply(final JvmOperation it) { |
| it.setVisibility(JvmVisibility.PUBLIC); |
| it.setSynchronized(true); |
| EList<JvmFormalParameter> _parameters = it.getParameters(); |
| JvmTypeReference _typeRef = DialogDslMobileViewCreator.this._typeReferenceBuilder.typeRef(IPersistenceService.class); |
| JvmFormalParameter _parameter = DialogDslMobileViewCreator.this._jvmTypesBuilder.toParameter(dialog, "persistenceService", _typeRef); |
| DialogDslMobileViewCreator.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("this.persistenceService = null;"); |
| _builder.newLine(); |
| _builder.append("log.debug(\"PersistenceService unbound\");"); |
| it.append(_builder); |
| } |
| }; |
| DialogDslMobileViewCreator.this._jvmTypesBuilder.setBody(it, _function); |
| } |
| }; |
| JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(dialog, "unbindPersistenceService", _typeRef_4, _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) { |
| StringConcatenation _builder = new StringConcatenation(); |
| String 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) { |
| boolean _equals = Objects.equal(this.actionMap, null); |
| if (_equals) { |
| HashMap<String, List<String>> _newHashMap = CollectionLiterals.<String, List<String>>newHashMap(); |
| this.actionMap = _newHashMap; |
| } |
| TreeIterator<EObject> _eAllContents = view.eAllContents(); |
| Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_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 = ""; |
| boolean _notEquals = (!Objects.equal(uxActionRef, null)); |
| if (_notEquals) { |
| String _name = uxActionRef.getName(); |
| key = _name; |
| } else { |
| boolean _notEquals_1 = (!Objects.equal(actionID, null)); |
| if (_notEquals_1) { |
| key = actionID; |
| } |
| } |
| List<String> actionList = this.actionMap.get(key); |
| boolean _equals_1 = Objects.equal(actionList, null); |
| if (_equals_1) { |
| ArrayList<String> _newArrayList = CollectionLiterals.<String>newArrayList(); |
| actionList = _newArrayList; |
| } |
| String _string = fqn.toString(); |
| actionList.add(_string); |
| this.actionMap.put(key, actionList); |
| } |
| } |
| } |
| |
| /** |
| * @param uiView |
| * @return |
| */ |
| public String getUiModelPackageName(final UiView uiView) { |
| EObject parent = uiView.eContainer(); |
| while ((!(parent instanceof UiModel))) { |
| EObject _eContainer = parent.eContainer(); |
| 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)); |
| QualifiedName tableId2 = this._iQualifiedNameProvider.getFullyQualifiedName(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; |
| } |
| } |