| /** |
| * 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 |
| * |
| * 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.google.common.base.Objects; |
| import com.vaadin.data.Property; |
| import com.vaadin.ui.AbstractOrderedLayout; |
| import com.vaadin.ui.Accordion; |
| import com.vaadin.ui.Button; |
| import com.vaadin.ui.HorizontalLayout; |
| import com.vaadin.ui.Image; |
| import com.vaadin.ui.Label; |
| import com.vaadin.ui.Notification; |
| import com.vaadin.ui.TabSheet; |
| import com.vaadin.ui.Tree; |
| import com.vaadin.ui.UI; |
| import com.vaadin.ui.VerticalLayout; |
| import javax.inject.Inject; |
| import org.eclipse.e4.core.contexts.ContextInjectionFactory; |
| import org.eclipse.e4.core.di.extensions.EventUtils; |
| import org.eclipse.e4.ui.model.application.MApplication; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.common.util.TreeIterator; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.resource.Resource; |
| import org.eclipse.osbp.bpm.api.IBPMEngine; |
| import org.eclipse.osbp.bpm.api.IBlipBPMFunctionProvider; |
| import org.eclipse.osbp.eventbroker.EventBrokerMsg; |
| import org.eclipse.osbp.ui.api.contextfunction.IUserMenuProvider; |
| import org.eclipse.osbp.ui.api.contextfunction.IViewEmbeddedProvider; |
| import org.eclipse.osbp.ui.api.themes.IThemeResourceService; |
| import org.eclipse.osbp.ui.api.useraccess.AbstractAuthorization; |
| import org.eclipse.osbp.ui.api.useraccess.IUserAccessService; |
| import org.eclipse.osbp.utils.vaadin.YesNoDialog; |
| import org.eclipse.osbp.xtext.basic.generator.BasicDslGeneratorUtils; |
| import org.eclipse.osbp.xtext.i18n.I18NModelGenerator; |
| import org.eclipse.osbp.xtext.menu.MenuEntry; |
| import org.eclipse.osbp.xtext.menu.MenuPackage; |
| import org.eclipse.osbp.xtext.menu.common.UserMenuItem; |
| import org.eclipse.osbp.xtext.table.Table; |
| import org.eclipse.xtend2.lib.StringConcatenation; |
| import org.eclipse.xtext.generator.IFileSystemAccess; |
| import org.eclipse.xtext.xbase.compiler.GeneratorConfig; |
| import org.eclipse.xtext.xbase.compiler.ImportManager; |
| import org.eclipse.xtext.xbase.compiler.output.TreeAppendable; |
| import org.eclipse.xtext.xbase.lib.Extension; |
| import org.eclipse.xtext.xbase.lib.Pair; |
| import org.eclipse.xtext.xbase.lib.StringExtensions; |
| import org.osgi.service.event.Event; |
| import org.osgi.service.event.EventHandler; |
| import org.vaadin.hene.popupbutton.PopupButton; |
| |
| @SuppressWarnings("all") |
| public class MenuModelGenerator extends I18NModelGenerator { |
| @Inject |
| @Extension |
| private BasicDslGeneratorUtils _basicDslGeneratorUtils; |
| |
| public void doGenerate(final Resource input, final IFileSystemAccess fsa) { |
| this.addTranslatables("startProcessText,answerYesText,answerNoText"); |
| super.doGenerate(input, fsa); |
| } |
| |
| public String parseResource(final Resource resource) { |
| String str = ""; |
| TreeIterator<EObject> it = resource.getAllContents(); |
| while (it.hasNext()) { |
| { |
| EObject current = it.next(); |
| if ((current instanceof MenuPackage)) { |
| EList<MenuEntry> _entries = ((MenuPackage) current).getEntries(); |
| for (final MenuEntry entry : _entries) { |
| String _iterateEntry = this.iterateEntry(entry); |
| String _plus = (str + _iterateEntry); |
| str = _plus; |
| } |
| } |
| } |
| } |
| return str; |
| } |
| |
| public String iterateEntry(final MenuEntry entry) { |
| String str = ""; |
| boolean _isHasTable = entry.isHasTable(); |
| if (_isHasTable) { |
| str = (str + "\t"); |
| StringConcatenation _builder = new StringConcatenation(); |
| _builder.append("<reference bind=\"bind"); |
| Table _table = entry.getTable(); |
| String _name = _table.getName(); |
| String _firstUpper = StringExtensions.toFirstUpper(_name); |
| _builder.append(_firstUpper, ""); |
| _builder.append("\" cardinality=\"0..1\" interface=\"org.eclipse.osbp.xtext.table.common.IViewEmbeddedProvider\" name=\""); |
| Table _table_1 = entry.getTable(); |
| String _name_1 = _table_1.getName(); |
| String _firstUpper_1 = StringExtensions.toFirstUpper(_name_1); |
| _builder.append(_firstUpper_1, ""); |
| _builder.append("\" policy=\"dynamic\" target=\"(type="); |
| Table _table_2 = entry.getTable(); |
| String _name_2 = _table_2.getName(); |
| String _firstUpper_2 = StringExtensions.toFirstUpper(_name_2); |
| _builder.append(_firstUpper_2, ""); |
| _builder.append(")\" unbind=\"unbind"); |
| Table _table_3 = entry.getTable(); |
| String _name_3 = _table_3.getName(); |
| String _firstUpper_3 = StringExtensions.toFirstUpper(_name_3); |
| _builder.append(_firstUpper_3, ""); |
| _builder.append("\"/>"); |
| _builder.newLineIfNotEmpty(); |
| String _plus = (str + _builder); |
| str = _plus; |
| } |
| boolean _and = false; |
| EList<MenuEntry> _subentries = entry.getSubentries(); |
| boolean _notEquals = (!Objects.equal(_subentries, null)); |
| if (!_notEquals) { |
| _and = false; |
| } else { |
| EList<MenuEntry> _subentries_1 = entry.getSubentries(); |
| int _size = _subentries_1.size(); |
| boolean _greaterThan = (_size > 0); |
| _and = _greaterThan; |
| } |
| if (_and) { |
| EList<MenuEntry> _subentries_2 = entry.getSubentries(); |
| for (final MenuEntry e : _subentries_2) { |
| String _iterateEntry = this.iterateEntry(e); |
| String _plus_1 = (str + _iterateEntry); |
| str = _plus_1; |
| } |
| } |
| return str; |
| } |
| |
| public TreeAppendable createAppendable(final EObject context, final ImportManager importManager, final GeneratorConfig config) { |
| TreeAppendable _xblockexpression = null; |
| { |
| Resource _eResource = context.eResource(); |
| this.setBuilder(_eResource); |
| this._basicDslGeneratorUtils.addImportFor(this, importManager, this._typeReferenceBuilder, VerticalLayout.class, HorizontalLayout.class, Label.class, Image.class, PopupButton.class, YesNoDialog.class, Event.class, EventUtils.class, EventHandler.class, EventBrokerMsg.class, IUserMenuProvider.class, TabSheet.SelectedTabChangeListener.class, TabSheet.SelectedTabChangeEvent.class, Notification.class, IBlipBPMFunctionProvider.class, com.vaadin.server.Resource.class, TabSheet.Tab.class, Button.class, Accordion.class, IUserAccessService.class, IBPMEngine.class, AbstractAuthorization.Permission.class, AbstractAuthorization.Action.class, IThemeResourceService.class, IThemeResourceService.ThemeResourceType.class, Tree.class, Property.ValueChangeListener.class, Property.ValueChangeEvent.class, UserMenuItem.class, UserMenuItem.UserMenuItemType.class, Button.ClickListener.class, Button.ClickEvent.class, IViewEmbeddedProvider.class, MApplication.class, ContextInjectionFactory.class, Pair.class, UI.class, AbstractOrderedLayout.class); |
| _xblockexpression = super.createAppendable(context, importManager, config); |
| } |
| return _xblockexpression; |
| } |
| } |