blob: 78ed220bda552051ba44dd5de2ae8258be3bb05f [file] [log] [blame]
/**
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* ============================================================================
* Initial contribution:
* Loetz GmbH & Co. KG
*
* generated by xtext
*/
package org.eclipse.osbp.xtext.dialogdsl.jvmmodel;
import java.util.Arrays;
import javax.inject.Inject;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.ecview.semantic.uimodel.UiIDEView;
import org.eclipse.osbp.ecview.semantic.uimodel.UiMobileView;
import org.eclipse.osbp.ecview.semantic.uimodel.UiView;
import org.eclipse.osbp.xtext.dialogdsl.Dialog;
import org.eclipse.osbp.xtext.dialogdsl.DialogPackage;
import org.eclipse.osbp.xtext.dialogdsl.jvmmodel.DialogDslMobileViewCreator;
import org.eclipse.osbp.xtext.dialogdsl.jvmmodel.DialogDslVaaclipseViewCreator;
import org.eclipse.osbp.xtext.dialogdsl.mapper.AutowireUiFactory;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer;
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.InputOutput;
/**
* Infers a JVM model from the source model.
*
* The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.
*/
@SuppressWarnings("all")
public class DialogDslJvmModelInferrer extends AbstractModelInferrer {
/**
* convenience API to build and initialize JVM types and their members.
*/
@Inject
@Extension
private DialogDslVaaclipseViewCreator _dialogDslVaaclipseViewCreator;
@Inject
@Extension
private DialogDslMobileViewCreator _dialogDslMobileViewCreator;
@Inject
private AutowireUiFactory autowireFactory;
protected void _infer(final DialogPackage pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("isPreIndexingPhase: ");
_builder.append(isPreIndexingPhase, "");
InputOutput.<String>println(_builder.toString());
if ((!isPreIndexingPhase)) {
EList<Dialog> _dialogs = pckg.getDialogs();
for (final Dialog dialog : _dialogs) {
boolean _isAutowire = dialog.isAutowire();
if (_isAutowire) {
this._dialogDslVaaclipseViewCreator.createVaaclipseUI(pckg, dialog, acceptor, this._annotationTypesBuilder, this._typeReferenceBuilder);
} else {
UiView uiview = dialog.getUiView();
boolean isIDEView = (uiview instanceof UiIDEView);
boolean isMobileView = (uiview instanceof UiMobileView);
if (isIDEView) {
this._dialogDslVaaclipseViewCreator.createVaaclipseUI(pckg, dialog, acceptor, this._annotationTypesBuilder, this._typeReferenceBuilder);
}
if (isMobileView) {
this._dialogDslMobileViewCreator.createMobileUI(pckg, dialog, acceptor, this._annotationTypesBuilder, this._typeReferenceBuilder);
}
}
}
}
}
public void infer(final EObject pckg, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPreIndexingPhase) {
if (pckg instanceof DialogPackage) {
_infer((DialogPackage)pckg, acceptor, isPreIndexingPhase);
return;
} else if (pckg != null) {
_infer(pckg, acceptor, isPreIndexingPhase);
return;
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(pckg, acceptor, isPreIndexingPhase).toString());
}
}
}