| /** |
| * |
| * 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.vaadin.data.Property.ValueChangeEvent |
| import com.vaadin.data.Property.ValueChangeListener |
| import com.vaadin.ui.AbstractOrderedLayout |
| import com.vaadin.ui.Accordion |
| import com.vaadin.ui.Button |
| import com.vaadin.ui.Button.ClickEvent |
| import com.vaadin.ui.Button.ClickListener |
| 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.SelectedTabChangeEvent |
| import com.vaadin.ui.TabSheet.SelectedTabChangeListener |
| import com.vaadin.ui.TabSheet.Tab |
| 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.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.Action |
| import org.eclipse.osbp.ui.api.useraccess.AbstractAuthorization.Permission |
| 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.menu.common.UserMenuItem.UserMenuItemType |
| import org.eclipse.xtext.generator.IFileSystemAccess |
| import org.eclipse.xtext.xbase.compiler.GeneratorConfig |
| import org.eclipse.xtext.xbase.compiler.ImportManager |
| import org.osgi.service.event.Event |
| import org.osgi.service.event.EventHandler |
| import org.vaadin.hene.popupbutton.PopupButton |
| import org.eclipse.osbp.ui.api.themes.IThemeResourceService.ThemeResourceType |
| |
| class MenuModelGenerator extends I18NModelGenerator { |
| @Inject extension BasicDslGeneratorUtils |
| |
| override doGenerate(Resource input, IFileSystemAccess fsa) { |
| addTranslatables("startProcessText,answerYesText,answerNoText") |
| super.doGenerate(input, fsa) |
| } |
| |
| def parseResource(Resource resource) { |
| var str = "" |
| var TreeIterator<EObject> it = resource.allContents |
| while(it.hasNext()) { |
| var EObject current = it.next(); |
| if (current instanceof MenuPackage) { |
| for(entry:(current as MenuPackage).entries) { |
| str = str + entry.iterateEntry() |
| } |
| } |
| } |
| return str |
| } |
| |
| def String iterateEntry(MenuEntry entry) { |
| var str = "" |
| if (entry.hasTable) { |
| str = str + " " |
| str = str + |
| ''' |
| <reference bind="bind«entry.table.name.toFirstUpper»" cardinality="0..1" interface="org.eclipse.osbp.xtext.table.common.IViewEmbeddedProvider" name="«entry.table.name.toFirstUpper»" policy="dynamic" target="(type=«entry.table.name.toFirstUpper»)" unbind="unbind«entry.table.name.toFirstUpper»"/> |
| ''' |
| } |
| if (entry.subentries != null && entry.subentries.size > 0) { |
| for(e:entry.subentries) { |
| str = str + e.iterateEntry() |
| } |
| } |
| return str |
| } |
| |
| override createAppendable(EObject context, ImportManager importManager, GeneratorConfig config) { |
| // required to initialize the needed builder to avoid deprecated methods |
| builder = context.eResource |
| // --------- |
| addImportFor(importManager, _typeReferenceBuilder |
| , VerticalLayout |
| , HorizontalLayout |
| , Label |
| , Image |
| , PopupButton |
| , YesNoDialog |
| , Event |
| , EventUtils |
| , EventHandler |
| , EventBrokerMsg |
| , IUserMenuProvider |
| , SelectedTabChangeListener |
| , SelectedTabChangeEvent |
| , Notification |
| , IBlipBPMFunctionProvider |
| , com.vaadin.server.Resource |
| , Tab |
| , Button |
| , Accordion |
| , IUserAccessService |
| , IBPMEngine |
| , Permission |
| , Action |
| , IThemeResourceService |
| , ThemeResourceType |
| , Tree |
| , ValueChangeListener |
| , ValueChangeEvent |
| , UserMenuItem |
| , UserMenuItemType |
| , ClickListener |
| , ClickEvent |
| , IViewEmbeddedProvider |
| , MApplication |
| , ContextInjectionFactory |
| , Pair |
| , UI |
| , AbstractOrderedLayout |
| ) |
| super.createAppendable(context, importManager, config) |
| } |
| } |