blob: 9bf16b6359c1a62dd63bbc4c8adada0333e01aab [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 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*
* This copyright notice shows up in the generated Java code
*/
package org.eclipse.osbp.xtext.menu.jvmmodel;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.function.Consumer;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.contexts.IContextFunction;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.bpm.api.IBPMEngine;
import org.eclipse.osbp.runtime.common.event.IEventDispatcher;
import org.eclipse.osbp.ui.api.contextfunction.IUserMenuProvider;
import org.eclipse.osbp.ui.api.contextfunction.IVaadinDialogProvider;
import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider;
import org.eclipse.osbp.ui.api.menu.IMenuItemHandler;
import org.eclipse.osbp.ui.api.metadata.IDSLMetadataService;
import org.eclipse.osbp.ui.api.perspective.IPerspectiveProvider;
import org.eclipse.osbp.ui.api.themes.IThemeResourceService;
import org.eclipse.osbp.ui.api.user.IUser;
import org.eclipse.osbp.ui.api.useraccess.IUserAccessService;
import org.eclipse.osbp.utils.annotation.CommonUtils;
import org.eclipse.osbp.utils.vaadin.bpmn.BpmnWindow;
import org.eclipse.osbp.vaaclipse.api.VaadinExecutorService;
import org.eclipse.osbp.xtext.menu.MenuCategory;
import org.eclipse.osbp.xtext.menu.MenuEntry;
import org.eclipse.osbp.xtext.menu.MenuPackage;
import org.eclipse.osbp.xtext.menu.MenuTree;
import org.eclipse.osbp.xtext.menu.common.UserMenuItem;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.Constants;
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.JvmTypeReference;
import org.eclipse.xtext.common.types.JvmVisibility;
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.AbstractModelInferrer;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Pair;
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;
import org.vaadin.hene.popupbutton.PopupButton;
@SuppressWarnings("all")
public class MenuDslJvmModelInferrer extends AbstractModelInferrer {
@Inject
@Extension
private JvmTypesBuilder _jvmTypesBuilder;
@Inject
@Extension
private IQualifiedNameProvider _iQualifiedNameProvider;
@Inject
@Named(Constants.FILE_EXTENSIONS)
private String fileExtension;
@Inject
@Extension
private CommonUtils _commonUtils;
private String contextClassName = "";
private String clsName = "";
protected void _infer(final MenuPackage pkg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
String _firstUpper = StringExtensions.toFirstUpper(pkg.eResource().getURI().lastSegment().replace(("." + this.fileExtension), ""));
String _firstUpper_1 = StringExtensions.toFirstUpper(this.fileExtension);
String _plus = (_firstUpper + _firstUpper_1);
this.clsName = _plus;
String _name = pkg.getName();
String _plus_1 = (_name + ".");
String _plus_2 = (_plus_1 + this.clsName);
final JvmGenericType cls = this._jvmTypesBuilder.toClass(pkg, _plus_2);
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IUserMenuProvider.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IUser.UserLocaleListener.class));
cls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(PopupButton.PopupVisibilityListener.class));
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
this.toFields(it, pkg);
this.toInjectedFields(it, pkg);
this.toConstructor(it, pkg);
this.toOperations(it, pkg);
};
acceptor.<JvmGenericType>accept(cls, _function);
String _name_1 = pkg.getName();
String _plus_3 = (_name_1 + ".");
String _plus_4 = (_plus_3 + this.clsName);
String _plus_5 = (_plus_4 + "ContextFunction");
this.contextClassName = _plus_5;
final JvmGenericType contextCls = this._jvmTypesBuilder.toClass(pkg, this.contextClassName);
contextCls.getSuperTypes().add(this._typeReferenceBuilder.typeRef(IContextFunction.class));
contextCls.setSimpleName(StringExtensions.toFirstUpper(contextCls.getSimpleName()));
final Procedure1<JvmGenericType> _function_1 = (JvmGenericType it) -> {
JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Component.class);
JvmTypeReference _typeRef = this._typeReferenceBuilder.typeRef(IContextFunction.class);
this._commonUtils.addAnnAttr(annotationRef, pkg, "service", ((JvmTypeReference) _typeRef));
StringConcatenation _builder = new StringConcatenation();
_builder.append(IContextFunction.SERVICE_CONTEXT_KEY);
_builder.append("=Menu");
String propContent = _builder.toString();
this._commonUtils.addAnnAttr(annotationRef, pkg, "property", propContent);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, annotationRef);
it.setPackageName(this._iQualifiedNameProvider.getFullyQualifiedName(pkg).toString());
this.toContextOperations(it, pkg);
};
acceptor.<JvmGenericType>accept(contextCls, _function_1);
}
public void toContextOperations(final JvmGenericType type, final MenuPackage pkg) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(pkg, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(pkg, "contextKey", this._typeReferenceBuilder.typeRef(String.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("MApplication application = context.get(MApplication.class);");
_builder.newLine();
_builder.append("IEclipseContext appCtx = application.getContext();");
_builder.newLine();
_builder.append("IUserMenuProvider provider = ContextInjectionFactory.make(");
_builder.append(this.clsName);
_builder.append(".class, appCtx);");
_builder.newLineIfNotEmpty();
_builder.append("appCtx.set(IUserMenuProvider.class, provider);");
_builder.newLine();
_builder.append("return provider;");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(pkg, "compute", this._typeReferenceBuilder.typeRef(Object.class), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
}
public void toInjectedFields(final JvmDeclaredType type, final MenuPackage pkg) {
final Consumer<MenuCategory> _function = (MenuCategory it) -> {
this.createInjects(it, type, pkg);
};
pkg.getCategories().forEach(_function);
}
public void createInjects(final MenuCategory category, final JvmDeclaredType type, final MenuPackage pkg) {
JvmField field = null;
if ((category.isHasTable() || category.isHasDialog())) {
String name = "";
ArrayList<String> list = CollectionLiterals.<String>newArrayList();
boolean _isHasTable = category.isHasTable();
if (_isHasTable) {
name = category.getTable().getName();
} else {
boolean _isHasDialog = category.isHasDialog();
if (_isHasDialog) {
name = category.getDialog().getName();
}
}
if (((name != null) && (!name.isEmpty()))) {
list.add(StringExtensions.toFirstUpper(name));
final JvmAnnotationReference annotationRef = this._annotationTypesBuilder.annotationRef(Named.class);
this._commonUtils.addStringValuesToAnnotation(annotationRef, list);
final Procedure1<JvmField> _function = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, StringExtensions.toFirstLower(name), this._typeReferenceBuilder.typeRef(IViewEmbeddedProvider.class), _function);
if ((field != null)) {
field.setVisibility(JvmVisibility.PRIVATE);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
}
}
}
}
public void toConstructor(final JvmDeclaredType type, final MenuPackage pkg) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmConstructor> _function = (JvmConstructor it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(pkg, _function);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
}
public void toFields(final JvmGenericType type, final MenuPackage pkg) {
JvmField field = null;
final Procedure1<JvmField> _function = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("org.slf4j.LoggerFactory.getLogger(\"menu\")");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_1);
};
field = this._jvmTypesBuilder.toField(pkg, "log", this._typeReferenceBuilder.typeRef(Logger.class), _function);
field.setStatic(true);
EList<JvmMember> _members = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members, field);
final Procedure1<JvmField> _function_1 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "themeResourceService", this._typeReferenceBuilder.typeRef(IThemeResourceService.class), _function_1);
EList<JvmMember> _members_1 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_1, field);
final Procedure1<JvmField> _function_2 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "userAccessService", this._typeReferenceBuilder.typeRef(IUserAccessService.class), _function_2);
EList<JvmMember> _members_2 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
final Procedure1<JvmField> _function_3 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "dslMetadataService", this._typeReferenceBuilder.typeRef(IDSLMetadataService.class), _function_3);
EList<JvmMember> _members_3 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_3, field);
final Procedure1<JvmField> _function_4 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "eventDispatcher", this._typeReferenceBuilder.typeRef(IEventDispatcher.class), _function_4);
EList<JvmMember> _members_4 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_4, field);
final Procedure1<JvmField> _function_5 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "perspectiveProvider", this._typeReferenceBuilder.typeRef(IPerspectiveProvider.class), _function_5);
EList<JvmMember> _members_5 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_5, field);
final Procedure1<JvmField> _function_6 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "user", this._typeReferenceBuilder.typeRef(IUser.class), _function_6);
EList<JvmMember> _members_6 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_6, field);
field = this._jvmTypesBuilder.toField(pkg, "locale", this._typeReferenceBuilder.typeRef(Locale.class));
EList<JvmMember> _members_7 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_7, field);
final Procedure1<JvmField> _function_7 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
};
field = this._jvmTypesBuilder.toField(pkg, "bpmEngine", this._typeReferenceBuilder.typeRef(IBPMEngine.class), _function_7);
EList<JvmMember> _members_8 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_8, field);
field = this._jvmTypesBuilder.toField(pkg, "selectedMap", this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(Accordion.class), this._typeReferenceBuilder.typeRef(com.vaadin.ui.Component.class)));
EList<JvmMember> _members_9 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_9, field);
field = this._jvmTypesBuilder.toField(pkg, "menuComponent", this._typeReferenceBuilder.typeRef(VerticalLayout.class));
EList<JvmMember> _members_10 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_10, field);
field = this._jvmTypesBuilder.toField(pkg, "reloadModelText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_11 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_11, field);
field = this._jvmTypesBuilder.toField(pkg, "designerText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_12 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_12, field);
field = this._jvmTypesBuilder.toField(pkg, "designmodeText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_13 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_13, field);
field = this._jvmTypesBuilder.toField(pkg, "undoText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_14 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_14, field);
field = this._jvmTypesBuilder.toField(pkg, "redoText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_15 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_15, field);
field = this._jvmTypesBuilder.toField(pkg, "newText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_16 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_16, field);
field = this._jvmTypesBuilder.toField(pkg, "changeText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_17 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_17, field);
field = this._jvmTypesBuilder.toField(pkg, "exportText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_18 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_18, field);
field = this._jvmTypesBuilder.toField(pkg, "downloadText", this._typeReferenceBuilder.typeRef(String.class));
EList<JvmMember> _members_19 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_19, field);
final Procedure1<JvmField> _function_8 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "context", this._typeReferenceBuilder.typeRef(IEclipseContext.class), _function_8);
EList<JvmMember> _members_20 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_20, field);
final Procedure1<JvmField> _function_9 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "ReloadModelHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "reloadModelHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_9);
EList<JvmMember> _members_21 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_21, field);
final Procedure1<JvmField> _function_10 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "DesignModeHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "designModeHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_10);
EList<JvmMember> _members_22 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_22, field);
final Procedure1<JvmField> _function_11 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "DesignerUndoHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "designerUndoHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_11);
EList<JvmMember> _members_23 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_23, field);
final Procedure1<JvmField> _function_12 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "DesignerRedoHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "designerRedoHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_12);
EList<JvmMember> _members_24 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_24, field);
final Procedure1<JvmField> _function_13 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "NewPerspectiveHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "newPerspectiveHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_13);
EList<JvmMember> _members_25 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_25, field);
final Procedure1<JvmField> _function_14 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "ChangePerspectiveHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "changePerspectiveHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_14);
EList<JvmMember> _members_26 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_26, field);
final Procedure1<JvmField> _function_15 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "ExportPerspectiveHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "exportPerspectiveHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_15);
EList<JvmMember> _members_27 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_27, field);
final Procedure1<JvmField> _function_16 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Optional.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
EList<JvmAnnotationReference> _annotations_2 = it.getAnnotations();
JvmAnnotationReference _annotationRef_2 = this._annotationTypesBuilder.annotationRef(Named.class, "DownloadPerspectiveHandler");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_2, _annotationRef_2);
};
field = this._jvmTypesBuilder.toField(pkg, "downloadPerspectiveHandler", this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), _function_16);
EList<JvmMember> _members_28 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_28, field);
field = this._jvmTypesBuilder.toField(pkg, "tabs",
this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(TabSheet.Tab.class), this._typeReferenceBuilder.typeRef(Pair.class, this._typeReferenceBuilder.typeRef(String.class), this._typeReferenceBuilder.typeRef(String.class))));
EList<JvmMember> _members_29 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_29, field);
field = this._jvmTypesBuilder.toField(pkg, "items",
this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(UserMenuItem.class), this._typeReferenceBuilder.typeRef(String.class)));
EList<JvmMember> _members_30 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_30, field);
final Procedure1<JvmField> _function_17 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Named.class, "UserFilter");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
};
field = this._jvmTypesBuilder.toField(pkg, "userFilter", this._typeReferenceBuilder.typeRef(IVaadinDialogProvider.class), _function_17);
EList<JvmMember> _members_31 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_31, field);
final Procedure1<JvmField> _function_18 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Named.class, "KeyBindingDialog");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
};
field = this._jvmTypesBuilder.toField(pkg, "keyBinding", this._typeReferenceBuilder.typeRef(IVaadinDialogProvider.class), _function_18);
EList<JvmMember> _members_32 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_32, field);
final Procedure1<JvmField> _function_19 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Named.class, "SystemSettings");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
};
field = this._jvmTypesBuilder.toField(pkg, "systemSettings", this._typeReferenceBuilder.typeRef(IVaadinDialogProvider.class), _function_19);
EList<JvmMember> _members_33 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_33, field);
final Procedure1<JvmField> _function_20 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmAnnotationReference> _annotations_1 = it.getAnnotations();
JvmAnnotationReference _annotationRef_1 = this._annotationTypesBuilder.annotationRef(Named.class, "ReportPrinterDialog");
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations_1, _annotationRef_1);
};
field = this._jvmTypesBuilder.toField(pkg, "reportPrinter", this._typeReferenceBuilder.typeRef(IVaadinDialogProvider.class), _function_20);
EList<JvmMember> _members_34 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_34, field);
final Procedure1<JvmField> _function_21 = (JvmField it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Inject.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
};
field = this._jvmTypesBuilder.toField(pkg, "executorService", this._typeReferenceBuilder.typeRef(VaadinExecutorService.class), _function_21);
EList<JvmMember> _members_35 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_35, field);
final Procedure1<JvmField> _function_22 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_23 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("new HashMap<>()");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_23);
};
field = this._jvmTypesBuilder.toField(pkg, "enabledUpdaters", this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(MenuBar.MenuItem.class), this._typeReferenceBuilder.typeRef(Runnable.class)), _function_22);
EList<JvmMember> _members_36 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_36, field);
final Procedure1<JvmField> _function_23 = (JvmField it) -> {
final Procedure1<ITreeAppendable> _function_24 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("new HashMap<>()");
it_1.append(_builder);
};
this._jvmTypesBuilder.setInitializer(it, _function_24);
};
field = this._jvmTypesBuilder.toField(pkg, "menuItems", this._typeReferenceBuilder.typeRef(HashMap.class, this._typeReferenceBuilder.typeRef(IMenuItemHandler.class), this._typeReferenceBuilder.typeRef(MenuBar.MenuItem.class)), _function_23);
EList<JvmMember> _members_37 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_37, field);
field = this._jvmTypesBuilder.toField(pkg, "bpmnWindow", this._typeReferenceBuilder.typeRef(BpmnWindow.class));
EList<JvmMember> _members_38 = type.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_38, field);
}
public void toOperations(final JvmDeclaredType type, final MenuPackage pkg) {
EList<JvmMember> _members = type.getMembers();
final Procedure1<JvmOperation> _function = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(PostConstruct.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
final Procedure1<ITreeAppendable> _function_1 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _init = this.init(pkg);
_builder.append(_init);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_1);
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(pkg, "init", this._typeReferenceBuilder.typeRef(Void.TYPE), _function);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members, _method);
EList<JvmMember> _members_1 = type.getMembers();
final Procedure1<JvmOperation> _function_1 = (JvmOperation it) -> {
final Procedure1<ITreeAppendable> _function_2 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _createMenu = this.createMenu(pkg);
_builder.append(_createMenu);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_2);
};
JvmOperation _method_1 = this._jvmTypesBuilder.toMethod(pkg, "createMenu", this._typeReferenceBuilder.typeRef(VerticalLayout.class), _function_1);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_1, _method_1);
EList<JvmMember> _members_2 = type.getMembers();
final Procedure1<JvmOperation> _function_2 = (JvmOperation it) -> {
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(pkg, "accordion", this._typeReferenceBuilder.typeRef(Accordion.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
EList<JvmFormalParameter> _parameters_1 = it.getParameters();
JvmFormalParameter _parameter_1 = this._jvmTypesBuilder.toParameter(pkg, "open", this._typeReferenceBuilder.typeRef(boolean.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
final Procedure1<ITreeAppendable> _function_3 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _setIcon = this.setIcon(pkg);
_builder.append(_setIcon);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_3);
};
JvmOperation _method_2 = this._jvmTypesBuilder.toMethod(pkg, "setIcon", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_2);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method_2);
EList<JvmMember> _members_3 = type.getMembers();
final Procedure1<JvmOperation> _function_3 = (JvmOperation it) -> {
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(pkg, "popup", this._typeReferenceBuilder.typeRef(PopupButton.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_4 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _menu = this.getMenu(pkg);
_builder.append(_menu);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_4);
};
JvmOperation _method_3 = this._jvmTypesBuilder.toMethod(pkg, "getMenu", this._typeReferenceBuilder.typeRef(VerticalLayout.class), _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _method_3);
EList<JvmMember> _members_4 = type.getMembers();
final Procedure1<JvmOperation> _function_4 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(pkg, "locale", this._typeReferenceBuilder.typeRef(Locale.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_5 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
CharSequence _localeChanged = this.localeChanged(pkg);
_builder.append(_localeChanged);
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_5);
};
JvmOperation _method_4 = this._jvmTypesBuilder.toMethod(pkg, "localeChanged", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_4);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _method_4);
EList<JvmMember> _members_5 = type.getMembers();
final Procedure1<JvmOperation> _function_5 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
EList<JvmAnnotationReference> _annotations = it.getAnnotations();
JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class);
this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
EList<JvmFormalParameter> _parameters = it.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(pkg, "event", this._typeReferenceBuilder.typeRef(PopupButton.PopupVisibilityEvent.class));
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
final Procedure1<ITreeAppendable> _function_6 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if(event.isPopupVisible()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("registerEnablementUpdaters();");
_builder.newLine();
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("unregisterEnablementUpdaters();");
_builder.newLine();
_builder.append("}");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_6);
};
JvmOperation _method_5 = this._jvmTypesBuilder.toMethod(pkg, "popupVisibilityChange", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_5);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_5, _method_5);
EList<JvmMember> _members_6 = type.getMembers();
final Procedure1<JvmOperation> _function_6 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
final Procedure1<ITreeAppendable> _function_7 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("for(IMenuItemHandler handler:menuItems.keySet()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("if (!enabledUpdaters.containsKey(menuItems.get(handler))) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Runnable runnable = new Runnable() {");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("public void run() {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("boolean can = handler.canExecute();");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if(menuItems.get(handler).isEnabled() != can) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("menuItems.get(handler).setEnabled(can);");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("};");
_builder.newLine();
_builder.append("\t\t");
_builder.append("this.enabledUpdaters.put(menuItems.get(handler), runnable);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("executorService.invokeLaterAlways(runnable);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_7);
};
JvmOperation _method_6 = this._jvmTypesBuilder.toMethod(pkg, "registerEnablementUpdaters", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_6);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_6, _method_6);
EList<JvmMember> _members_7 = type.getMembers();
final Procedure1<JvmOperation> _function_7 = (JvmOperation it) -> {
it.setVisibility(JvmVisibility.PUBLIC);
final Procedure1<ITreeAppendable> _function_8 = (ITreeAppendable it_1) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("for(IMenuItemHandler handler:menuItems.keySet()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("Runnable runnable = enabledUpdaters.remove(menuItems.get(handler));");
_builder.newLine();
_builder.append("\t");
_builder.append("if (runnable != null) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("executorService.removeAlwaysRunnable(runnable);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
it_1.append(_builder);
};
this._jvmTypesBuilder.setBody(it, _function_8);
};
JvmOperation _method_7 = this._jvmTypesBuilder.toMethod(pkg, "unregisterEnablementUpdaters", this._typeReferenceBuilder.typeRef(Void.TYPE), _function_7);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_7, _method_7);
}
public CharSequence init(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("bpmnWindow = new BpmnWindow(bpmEngine, context);");
_builder.newLine();
_builder.append("tabs = new HashMap<>();");
_builder.newLine();
_builder.append("items = new HashMap<>();");
_builder.newLine();
_builder.append("user.addUserLocaleListener(this);");
_builder.newLine();
_builder.append("locale = user.getLocale();");
_builder.newLine();
_builder.append("menuComponent = createMenu();");
_builder.newLine();
_builder.append("localeChanged(locale);");
return _builder;
}
public CharSequence getMenu(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("popup.addPopupVisibilityListener(this);");
_builder.newLine();
_builder.append("return menuComponent;");
_builder.newLine();
return _builder;
}
public CharSequence createMenu(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("selectedMap = new HashMap<Accordion,Component>();");
_builder.newLine();
_builder.append("VerticalLayout tabRoot = new VerticalLayout();");
_builder.newLine();
_builder.append("tabRoot.setSizeFull();");
_builder.newLine();
{
boolean _isHasDesigner = pkg.isHasDesigner();
if (_isHasDesigner) {
_builder.append("if (designModeHandler != null && userAccessService.isSuperuser()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("MenuBar menubar = new MenuBar();");
_builder.newLine();
_builder.append("\t");
_builder.append("tabRoot.addComponent(menubar);");
_builder.newLine();
_builder.append("\t");
_builder.append("MenuItem designer = menubar.addItem(designerText, null, null);");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(reloadModelHandler, designer.addItem(reloadModelText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("reloadModelHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("MenuItem mode = designer.addItem(designmodeText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("designModeHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("});");
_builder.newLine();
_builder.append("\t");
_builder.append("mode.setCheckable(true);");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(designerUndoHandler, designer.addItem(undoText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("designerUndoHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(designerRedoHandler, designer.addItem(redoText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("designerRedoHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("designer.addSeparator();");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(newPerspectiveHandler, designer.addItem(newText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("newPerspectiveHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(changePerspectiveHandler, designer.addItem(changeText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("changePerspectiveHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(exportPerspectiveHandler, designer.addItem(exportText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("exportPerspectiveHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("\t");
_builder.append("menuItems.put(downloadPerspectiveHandler, designer.addItem(downloadText, null, new MenuBar.Command() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("public void menuSelected(MenuItem selectedItem) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("downloadPerspectiveHandler.execute(selectedItem);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}));");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
}
String _createRootMenu = this.createRootMenu(pkg);
_builder.append(_createRootMenu);
_builder.newLineIfNotEmpty();
_builder.append("return tabRoot;");
_builder.newLine();
return _builder;
}
public String createRootMenu(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("ItemDescriptionGenerator generator = new ItemDescriptionGenerator() { ");
_builder.newLine();
_builder.append("\t");
_builder.append("public String generateDescription(Component source, Object itemId, Object propertyId) {");
_builder.newLine();
_builder.append("\t ");
_builder.append("return ((UserMenuItem)itemId).getI18nDescription();");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
_builder.append("MPerspective perspective = context.get(MPerspective.class);");
_builder.newLine();
_builder.append("ValueChangeListener valueChangeListener = new ValueChangeListener() {");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void valueChange(ValueChangeEvent event) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("UserMenuItem item = (UserMenuItem) ((Tree)event.getProperty()).getValue();");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(item != null) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("if(item.getType() == UserMenuItemType.PROCESS) {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("bpmEngine.registerProcess(item.getCallId());");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("if(bpmEngine.processHasErrors()) {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("String errorMessage = bpmEngine.getKnowledgeBuilderErrors().stream().map(e->e.toString()).collect(Collectors.joining(\"\\n\"));");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("Notification.show(errorMessage, Type.ERROR_MESSAGE);");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("bpmnWindow.showBpmn(item.getCallId());");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("} ");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("else if(item.getType() == UserMenuItemType.PERSPECTIVE) {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("bpmnWindow.closeBpmn();");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("log.debug(\"start perspective \"+item.getCallId());");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("perspectiveProvider.openPerspective(item.getCallId());");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("((Tree)event.getProperty()).select(null);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.CLOSE, \"UserMenu\", \"");
String _string = this._iQualifiedNameProvider.getFullyQualifiedName(pkg).toString();
_builder.append(_string, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("eventDispatcher.sendEvent(evnt);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("};");
_builder.newLine();
_builder.append("Accordion accordion = new Accordion();");
_builder.newLine();
_builder.append("tabRoot.addComponent(accordion);");
_builder.newLine();
{
String _height = pkg.getHeight();
boolean _tripleNotEquals = (_height != null);
if (_tripleNotEquals) {
_builder.append("accordion.setHeight(\"");
String _height_1 = pkg.getHeight();
_builder.append(_height_1);
_builder.append("\");");
}
}
_builder.newLineIfNotEmpty();
_builder.append("accordion.setWidth(");
{
String _width = pkg.getWidth();
boolean _tripleNotEquals_1 = (_width != null);
if (_tripleNotEquals_1) {
_builder.append("\"");
String _width_1 = pkg.getWidth();
_builder.append(_width_1);
_builder.append("\"");
} else {
_builder.append("\"400px\"");
}
}
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("accordion.addStyleName(\"os-accordion-level0\");");
_builder.newLine();
CharSequence _selectedHandler = this.selectedHandler("accordion");
_builder.append(_selectedHandler);
_builder.newLineIfNotEmpty();
_builder.newLine();
{
EList<MenuCategory> _categories = pkg.getCategories();
for(final MenuCategory category : _categories) {
{
boolean _isHasUserFilter = category.isHasUserFilter();
if (_isHasUserFilter) {
_builder.append("if(userAccessService.isSuperuser()) {");
_builder.newLine();
} else {
_builder.append("if(dslMetadataService.isMenuCategoryAuthorized(\"");
QualifiedName _fullyQualifiedName = this._iQualifiedNameProvider.getFullyQualifiedName(category);
_builder.append(_fullyQualifiedName);
_builder.append("\", userAccessService)) {");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("VerticalLayout tab");
String _firstUpper = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper, "\t");
_builder.append(" = new VerticalLayout();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("Tree category");
String _firstUpper_1 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_1, "\t");
_builder.append(" = new Tree();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("if(dslMetadataService.isOsbee()) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("category");
String _firstUpper_2 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_2, "\t\t");
_builder.append(".setDragMode(TreeDragMode.NODE);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("category");
String _firstUpper_3 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_3, "\t");
_builder.append(".addValueChangeListener(valueChangeListener);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("category");
String _name = category.getName();
_builder.append(_name, "\t");
_builder.append(".setItemDescriptionGenerator(generator);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("tab");
String _firstUpper_4 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_4, "\t");
_builder.append(".addComponent(category");
String _firstUpper_5 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_5, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("category");
String _firstUpper_6 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_6, "\t");
_builder.append(".setWidth(");
{
String _width_2 = pkg.getWidth();
boolean _tripleNotEquals_2 = (_width_2 != null);
if (_tripleNotEquals_2) {
_builder.append("\"");
String _width_3 = pkg.getWidth();
_builder.append(_width_3, "\t");
_builder.append("\"");
} else {
_builder.append("\"400px\"");
}
}
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("category");
String _firstUpper_7 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_7, "\t");
_builder.append(".addStyleName(\"os-menutree-level0\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("accordion.addTab(tab");
String _firstUpper_8 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_8, "\t");
_builder.append(", \"");
String _name_1 = category.getName();
_builder.append(_name_1, "\t");
_builder.append("\", themeResourceService.getThemeResource(\"");
String _collapsedImage = pkg.getCollapsedImage();
_builder.append(_collapsedImage, "\t");
_builder.append("\", ThemeResourceType.ICON));");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("tabs.put(accordion.getTab(tab");
String _firstUpper_9 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_9, "\t");
_builder.append("), new Pair(\"");
String _name_2 = category.getName();
_builder.append(_name_2, "\t");
_builder.append("\",\"\"));");
_builder.newLineIfNotEmpty();
{
boolean _isHasTable = category.isHasTable();
if (_isHasTable) {
_builder.append("\t");
String _firstLower = StringExtensions.toFirstLower(category.getTable().getName());
_builder.append(_firstLower, "\t");
_builder.append(".createView(tab");
String _firstUpper_10 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_10, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("tab");
String _firstUpper_11 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_11, "\t");
_builder.append(".setData(");
String _firstLower_1 = StringExtensions.toFirstLower(category.getTable().getName());
_builder.append(_firstLower_1, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
boolean _isHasDialog = category.isHasDialog();
if (_isHasDialog) {
_builder.append("\t");
String _firstLower_2 = StringExtensions.toFirstLower(category.getDialog().getName());
_builder.append(_firstLower_2, "\t");
_builder.append(".createView(tab");
String _firstUpper_12 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_12, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("tab");
String _firstUpper_13 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_13, "\t");
_builder.append(".setData(");
String _firstLower_3 = StringExtensions.toFirstLower(category.getDialog().getName());
_builder.append(_firstLower_3, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
boolean _isHasUserFilter_1 = category.isHasUserFilter();
if (_isHasUserFilter_1) {
_builder.append("\t");
_builder.append("userFilter.createView(tab");
String _firstUpper_14 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_14, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
boolean _isHasKeyBinding = category.isHasKeyBinding();
if (_isHasKeyBinding) {
_builder.append("\t");
_builder.append("keyBinding.createView(tab");
String _firstUpper_15 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_15, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
boolean _isHasSystemSettings = category.isHasSystemSettings();
if (_isHasSystemSettings) {
_builder.append("\t");
_builder.append("systemSettings.createView(tab");
String _firstUpper_16 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_16, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
} else {
boolean _isHasReportPrinter = category.isHasReportPrinter();
if (_isHasReportPrinter) {
_builder.append("\t");
_builder.append("reportPrinter.createView(tab");
String _firstUpper_17 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_17, "\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
}
}
}
}
}
}
}
{
EList<MenuTree> _trees = category.getTrees();
for(final MenuTree tree : _trees) {
_builder.append("\t");
_builder.append("if(dslMetadataService.isMenuTreeAuthorized(\"");
QualifiedName _fullyQualifiedName_1 = this._iQualifiedNameProvider.getFullyQualifiedName(tree);
_builder.append(_fullyQualifiedName_1, "\t");
_builder.append("\", userAccessService)) {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("UserMenuItem ");
String _name_3 = tree.getName();
_builder.append(_name_3, "\t\t");
_builder.append(" = new UserMenuItem(dslMetadataService, \"");
String _name_4 = tree.getName();
_builder.append(_name_4, "\t\t");
_builder.append("\", \"");
String _name_5 = tree.getName();
_builder.append(_name_5, "\t\t");
_builder.append("\", UserMenuItemType.NONE, \"");
String _tooltip = tree.getTooltip();
_builder.append(_tooltip, "\t\t");
_builder.append("\", null);");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("items.put(");
String _name_6 = tree.getName();
_builder.append(_name_6, "\t\t");
_builder.append(", \"");
String _name_7 = tree.getName();
_builder.append(_name_7, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_18 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_18, "\t\t");
_builder.append(".addItem(");
String _name_8 = tree.getName();
_builder.append(_name_8, "\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_19 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_19, "\t\t");
_builder.append(".setChildrenAllowed(");
String _name_9 = tree.getName();
_builder.append(_name_9, "\t\t");
_builder.append(", true);");
_builder.newLineIfNotEmpty();
{
EList<MenuEntry> _entries = tree.getEntries();
for(final MenuEntry entry : _entries) {
{
boolean _isHasProcess = entry.isHasProcess();
if (_isHasProcess) {
_builder.append("\t");
_builder.append("\t");
_builder.append("if(bpmEngine != null && userAccessService.isGranted(Group.PROCESS, Action.STARTABLE, \"");
String _name_10 = entry.getProcess().getName();
_builder.append(_name_10, "\t\t");
_builder.append("\")) {");
_builder.newLineIfNotEmpty();
} else {
_builder.append("\t");
_builder.append("\t");
_builder.append("if(dslMetadataService.isPerspectiveAuthorized(\"");
QualifiedName _fullyQualifiedName_2 = this._iQualifiedNameProvider.getFullyQualifiedName(entry.getPerspective());
_builder.append(_fullyQualifiedName_2, "\t\t");
_builder.append("\", userAccessService)) {");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("UserMenuItem ");
String _name_11 = tree.getName();
_builder.append(_name_11, "\t\t\t");
String _name_12 = entry.getName();
_builder.append(_name_12, "\t\t\t");
_builder.append(" = new UserMenuItem(dslMetadataService, \"");
String _name_13 = entry.getName();
_builder.append(_name_13, "\t\t\t");
_builder.append("\", ");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
{
boolean _isHasProcess_1 = entry.isHasProcess();
if (_isHasProcess_1) {
_builder.append("\"");
String _name_14 = entry.getProcess().getName();
_builder.append(_name_14, "\t\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
} else {
boolean _isHasPerspective = entry.isHasPerspective();
if (_isHasPerspective) {
_builder.append("\"");
QualifiedName _fullyQualifiedName_3 = this._iQualifiedNameProvider.getFullyQualifiedName(entry.getPerspective());
_builder.append(_fullyQualifiedName_3, "\t\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
} else {
_builder.append("\"\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
}
}
}
_builder.append(", UserMenuItemType.");
{
boolean _isHasProcess_2 = entry.isHasProcess();
if (_isHasProcess_2) {
_builder.append("PROCESS, \"");
String _descriptionValue = entry.getProcess().getDescriptionValue();
_builder.append(_descriptionValue, "\t\t\t");
_builder.append("\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
} else {
boolean _isHasPerspective_1 = entry.isHasPerspective();
if (_isHasPerspective_1) {
_builder.append("PERSPECTIVE, \"");
String _descriptionValue_1 = entry.getPerspective().getDescriptionValue();
_builder.append(_descriptionValue_1, "\t\t\t");
_builder.append("\"");
} else {
_builder.append("NONE, \"\"");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
}
}
}
_builder.append(", \"");
String _icon = entry.getIcon();
_builder.append(_icon, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("items.put(");
String _name_15 = tree.getName();
_builder.append(_name_15, "\t\t\t");
String _name_16 = entry.getName();
_builder.append(_name_16, "\t\t\t");
_builder.append(", \"");
String _name_17 = entry.getName();
_builder.append(_name_17, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_20 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_20, "\t\t\t");
_builder.append(".addItem(");
String _name_18 = tree.getName();
_builder.append(_name_18, "\t\t\t");
String _name_19 = entry.getName();
_builder.append(_name_19, "\t\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_21 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_21, "\t\t\t");
_builder.append(".setParent(");
String _name_20 = tree.getName();
_builder.append(_name_20, "\t\t\t");
String _name_21 = entry.getName();
_builder.append(_name_21, "\t\t\t");
_builder.append(", ");
String _name_22 = tree.getName();
_builder.append(_name_22, "\t\t\t");
_builder.append(");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_22 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_22, "\t\t\t");
_builder.append(".setChildrenAllowed(");
String _name_23 = tree.getName();
_builder.append(_name_23, "\t\t\t");
String _name_24 = entry.getName();
_builder.append(_name_24, "\t\t\t");
_builder.append(", false);");
_builder.newLineIfNotEmpty();
{
boolean _isHasIcon = entry.isHasIcon();
if (_isHasIcon) {
_builder.append("\t");
_builder.append("\t");
_builder.append("\t");
_builder.append("category");
String _firstUpper_23 = StringExtensions.toFirstUpper(category.getName());
_builder.append(_firstUpper_23, "\t\t\t");
_builder.append(".setItemIcon(");
String _name_25 = tree.getName();
_builder.append(_name_25, "\t\t\t");
String _name_26 = entry.getName();
_builder.append(_name_26, "\t\t\t");
_builder.append(", themeResourceService.getThemeResource(\"");
String _icon_1 = entry.getIcon();
_builder.append(_icon_1, "\t\t\t");
_builder.append("\", ThemeResourceType.ICON));");
_builder.newLineIfNotEmpty();
}
}
_builder.append("\t");
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("\t");
_builder.newLine();
}
}
_builder.append("\t");
_builder.append("}");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
}
}
return _builder.toString();
}
public CharSequence setIcon(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Tab tab = accordion.getTab(selectedMap.get(accordion));");
_builder.newLine();
_builder.append("if (tab != null) {");
_builder.newLine();
_builder.append("\t");
_builder.append("if(open) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("tab.setIcon(themeResourceService.getThemeResource(\"");
String _expandedImage = pkg.getExpandedImage();
_builder.append(_expandedImage, "\t\t");
_builder.append("\", ThemeResourceType.ICON));");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("} else {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("tab.setIcon(themeResourceService.getThemeResource(\"");
String _collapsedImage = pkg.getCollapsedImage();
_builder.append(_collapsedImage, "\t\t");
_builder.append("\", ThemeResourceType.ICON));");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
public CharSequence selectedHandler(final String accName) {
StringConcatenation _builder = new StringConcatenation();
_builder.append(accName);
_builder.append(".addSelectedTabChangeListener(new SelectedTabChangeListener() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void selectedTabChange(SelectedTabChangeEvent event) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("setIcon(");
_builder.append(accName, "\t\t");
_builder.append(", false);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("selectedMap.put(");
_builder.append(accName, "\t\t");
_builder.append(", ");
_builder.append(accName, "\t\t");
_builder.append(".getSelectedTab());");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("setIcon(");
_builder.append(accName, "\t\t");
_builder.append(", true);");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("Component component = ");
_builder.append(accName, "\t\t");
_builder.append(".getSelectedTab();");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("if(component instanceof AbstractOrderedLayout) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("if(((AbstractOrderedLayout)component).getData() instanceof IViewEmbeddedProvider) {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("IViewEmbeddedProvider view = ((IViewEmbeddedProvider)((AbstractOrderedLayout)component).getData());");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("view.createComponents();");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("// eventDispatcher");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("EventDispatcherEvent evnt = new EventDispatcherEvent(perspective, EventDispatcherCommand.SELECT, userAccessService.getUser().getClass().getCanonicalName(), \"Menu\");");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("evnt.addItem(EventDispatcherDataTag.DTO, userAccessService.getUser());");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("eventDispatcher.sendEvent(evnt);");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("});");
_builder.newLine();
return _builder;
}
public CharSequence localeChanged(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("this.locale = locale;");
_builder.newLine();
_builder.append("for(TabSheet.Tab tab: tabs.keySet()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("tab.setCaption(dslMetadataService.translate(locale.toLanguageTag(),tabs.get(tab).getKey()));");
_builder.newLine();
_builder.append("\t");
_builder.append("tab.setDescription(dslMetadataService.translate(locale.toLanguageTag(),tabs.get(tab).getValue()));");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("for(UserMenuItem item: items.keySet()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("item.setLocale(locale);");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("reloadModelText = dslMetadataService.translate(locale.toLanguageTag(),\"reloadmodel\");");
_builder.newLine();
_builder.append("designerText = dslMetadataService.translate(locale.toLanguageTag(),\"designer\");");
_builder.newLine();
_builder.append("designmodeText = dslMetadataService.translate(locale.toLanguageTag(),\"designermode\");");
_builder.newLine();
_builder.append("undoText = dslMetadataService.translate(locale.toLanguageTag(),\"undo\");");
_builder.newLine();
_builder.append("redoText = dslMetadataService.translate(locale.toLanguageTag(),\"redo\");");
_builder.newLine();
_builder.append("newText = dslMetadataService.translate(locale.toLanguageTag(),\"new\");");
_builder.newLine();
_builder.append("changeText = dslMetadataService.translate(locale.toLanguageTag(),\"change\");");
_builder.newLine();
_builder.append("exportText = dslMetadataService.translate(locale.toLanguageTag(),\"export\");");
_builder.newLine();
_builder.append("downloadText = dslMetadataService.translate(locale.toLanguageTag(),\"download\");");
_builder.newLine();
return _builder;
}
public CharSequence popupVisibilityChange(final MenuPackage pkg) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("if(event.isPopupVisible()) {");
_builder.newLine();
_builder.append("\t");
_builder.append("registerEnablementUpdaters();");
_builder.newLine();
_builder.append("} else {");
_builder.newLine();
_builder.append("\t");
_builder.append("unregisterEnablementUpdaters();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
return _builder;
}
public void infer(final EObject pkg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (pkg instanceof MenuPackage) {
_infer((MenuPackage)pkg, acceptor, isPreIndexingPhase);
return;
} else if (pkg != null) {
_infer(pkg, acceptor, isPreIndexingPhase);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(pkg, acceptor, isPreIndexingPhase).toString());
}
}
}