Search in sources :

Example 11 with AbstractJClass

use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.

the class EComponentWithViewSupportHolder method createTextWatcherHolder.

private TextWatcherHolder createTextWatcherHolder(JFieldRef idRef, TypeMirror viewParameterType) {
    JDefinedClass onTextChangeListenerClass = getCodeModel().anonymousClass(getClasses().TEXT_WATCHER);
    AbstractJClass viewClass = getClasses().TEXT_VIEW;
    if (viewParameterType != null) {
        viewClass = getJClass(viewParameterType.toString());
    }
    JBlock onViewChangedBody = getOnViewChangedBodyInjectionBlock().blockSimple();
    JVar viewVariable = onViewChangedBody.decl(FINAL, viewClass, "view", cast(viewClass, findViewById(idRef)));
    //
    onViewChangedBody._if(viewVariable.ne(JExpr._null()))._then().invoke(viewVariable, "addTextChangedListener").arg(_new(onTextChangeListenerClass));
    return new TextWatcherHolder(this, viewVariable, onTextChangeListenerClass);
}
Also used : JDefinedClass(com.helger.jcodemodel.JDefinedClass) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JVar(com.helger.jcodemodel.JVar)

Example 12 with AbstractJClass

use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.

the class EActivityHolder method setSetContentView.

private void setSetContentView() {
    getOnCreate();
    AbstractJClass layoutParamsClass = getClasses().VIEW_GROUP_LAYOUT_PARAMS;
    setContentViewLayout = setContentViewMethod(new AbstractJType[] { getCodeModel().INT }, new String[] { "layoutResID" });
    setContentViewMethod(new AbstractJType[] { getClasses().VIEW, layoutParamsClass }, new String[] { "view", "params" });
    setContentViewMethod(new AbstractJType[] { getClasses().VIEW }, new String[] { "view" });
}
Also used : AbstractJType(com.helger.jcodemodel.AbstractJType) AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Example 13 with AbstractJClass

use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.

the class EApplicationHolder method createSingleton.

private void createSingleton() {
    AbstractJClass annotatedComponent = generatedClass._extends();
    staticInstanceField = generatedClass.field(PRIVATE | STATIC, annotatedComponent, "INSTANCE" + generationSuffix());
    // Static singleton getter and setter
    JMethod getInstance = generatedClass.method(PUBLIC | STATIC, annotatedComponent, GET_APPLICATION_INSTANCE);
    getInstance.body()._return(staticInstanceField);
    JMethod setInstance = generatedClass.method(PUBLIC | STATIC, getCodeModel().VOID, "setForTesting");
    setInstance.javadoc().append("Visible for testing purposes");
    JVar applicationParam = setInstance.param(annotatedComponent, "application");
    setInstance.body().assign(staticInstanceField, applicationParam);
}
Also used : AbstractJClass(com.helger.jcodemodel.AbstractJClass) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 14 with AbstractJClass

use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.

the class RestHolder method setExtends.

@Override
protected void setExtends() {
    String annotatedComponentQualifiedName = annotatedElement.getQualifiedName().toString();
    AbstractJClass annotatedComponent = getCodeModel().directClass(annotatedComponentQualifiedName);
    generatedClass._implements(narrow(annotatedComponent));
}
Also used : AbstractJClass(com.helger.jcodemodel.AbstractJClass)

Example 15 with AbstractJClass

use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.

the class RoboGuiceHandler method beforeCreateMethod.

private void beforeCreateMethod(EActivityHolder holder, JFieldVar scope, JFieldVar scopedObjects, JFieldVar eventManager) {
    JBlock body = holder.getInitBody();
    AbstractJClass keyWildCard = getJClass(RoboGuiceClasses.KEY).narrow(getCodeModel().wildcard());
    AbstractJClass scopedHashMap = getClasses().HASH_MAP.narrow(keyWildCard, getClasses().OBJECT);
    body.assign(scopedObjects, JExpr._new(scopedHashMap));
    JVar injector = body.decl(getJClass(RoboGuiceClasses.ROBO_INJECTOR), "injector_", getJClass(RoboGuiceClasses.ROBO_GUICE).staticInvoke("getInjector").arg(_this()));
    body.assign(scope, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.CONTEXT_SCOPE).dotclass()));
    body.assign(eventManager, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.EVENT_MANAGER).dotclass()));
    body.add(injector.invoke("injectMembersWithoutViews").arg(_this()));
    fireEvent(eventManager, body, getJClass(RoboGuiceClasses.ON_CREATE_EVENT), holder.getInitSavedInstanceParam());
}
Also used : JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JVar(com.helger.jcodemodel.JVar)

Aggregations

AbstractJClass (com.helger.jcodemodel.AbstractJClass)125 JVar (com.helger.jcodemodel.JVar)48 JMethod (com.helger.jcodemodel.JMethod)36 JBlock (com.helger.jcodemodel.JBlock)35 JInvocation (com.helger.jcodemodel.JInvocation)31 TypeMirror (javax.lang.model.type.TypeMirror)24 IJExpression (com.helger.jcodemodel.IJExpression)23 JDefinedClass (com.helger.jcodemodel.JDefinedClass)19 VariableElement (javax.lang.model.element.VariableElement)14 JFieldVar (com.helger.jcodemodel.JFieldVar)13 GenerationProcess (com.github.sviperll.adt4j.model.util.GenerationProcess)9 ExecutableElement (javax.lang.model.element.ExecutableElement)9 JAnnotationUse (com.helger.jcodemodel.JAnnotationUse)8 JConditional (com.helger.jcodemodel.JConditional)8 JTypeVar (com.helger.jcodemodel.JTypeVar)8 DeclaredType (javax.lang.model.type.DeclaredType)8 VisitorDefinition (com.github.sviperll.adt4j.model.config.VisitorDefinition)6 JFieldRef (com.helger.jcodemodel.JFieldRef)6 ArrayList (java.util.ArrayList)6 BundleHelper (org.androidannotations.helper.BundleHelper)6