List of usage examples for com.google.gwt.user.rebind SourceWriter print
void print(String s);
From source file:com.gwtent.gen.reflection.GeneratorHelper.java
License:Apache License
public static void addAnnotations_AnnotationImpl(com.google.gwt.core.ext.typeinfo.TypeOracle typeOracle, String dest, SourceWriter source, Annotation[] annotations, TreeLogger logger) { if (annotations.length <= 0) return;/*from w ww .java 2s.com*/ for (Annotation annotation : annotations) { if (ignore.contains(ReflectionUtils.getQualifiedSourceName(annotation.annotationType()))) { continue; } JClassType classType = typeOracle .findType(ReflectionUtils.getQualifiedSourceName(annotation.annotationType())); if (classType != null) { source.print( dest + ".addAnnotation(" + createAnnotationValues(typeOracle, annotation, logger) + ");"); } else { logger.log(Type.ERROR, "Annotation (" + ReflectionUtils.getQualifiedSourceName(annotation.annotationType()) + ") not exists in compiled client source code, please ensure this class is exists and included in your module(.gwt.xml) file. GWTENT reflection process will ignore it and continue. "); } } }
From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java
License:Apache License
@Override public void createSource(SourceWriter source, JClassType classType) { //ClassType -->> the interface name created automatically Map<JClassType, String> typeNameMap = new HashMap<JClassType, String>(); genAllClasses(source, typeNameMap);//from w ww .j a v a2 s . co m // source.println("public " + getSimpleUnitName(classType) + "(){"); // source.indent(); // // for (String classname : allGeneratedClassNames){ // source.println("new " + classname + "();"); // } // source.outdent(); // source.println("}"); source.println("public com.gwtent.reflection.client.Type doGetType(String name) {"); source.indent(); //source.println("com.gwtent.reflection.client.Type resultType = super.doGetType(name);"); //source.println("if (resultType != null) {return resultType;}"); for (JClassType type : typeNameMap.keySet()) { source.println("if (name.equals( \"" + type.getQualifiedSourceName() + "\")){return GWT.create(" + typeNameMap.get(type) + ".class);}"); } source.println(); source.println("return null;"); source.outdent(); source.print("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterInspector.java
License:Apache License
/** * Writes the assignation into the {@code provider} field of * {@link com.gwtplatform.mvp.client.proxy.ProxyImpl ProxyImpl}. *///w w w . ja va 2 s . c om public void writeProviderAssignation(SourceWriter writer) { if (customProviderAnnotation != null) { JClassType customProvider = oracle.findType(customProviderAnnotation.value().getName()); writer.println("presenter = new " + customProvider.getQualifiedSourceName() + "( ginjector." + getPresenterMethodName + "() );"); } else if (proxyStandardAnnotation != null) { writer.println("presenter = new StandardProvider<" + presenterClassName + ">( ginjector." + getPresenterMethodName + "() );"); } else if (proxyCodeSplitAnnotation != null) { writer.println("presenter = new CodeSplitProvider<" + presenterClassName + ">( ginjector." + getPresenterMethodName + "() );"); } else { assert proxyCodeSplitBundleAnnotation != null; writer.print("presenter = new CodeSplitBundleProvider<" + presenterClassName + ", " + bundleClassName + ">(ginjector." + getPresenterMethodName + "(), "); if (ginjectorInspector.isGenerated()) { writer.print(bundleClassName + "." + presenterClass.getSimpleSourceName().toUpperCase() + ");"); } else { writer.print(proxyCodeSplitBundleAnnotation.id() + ");"); } } }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodStaticReturningString(SourceWriter writer) { writer.println();//from w w w . j a v a 2 s. c o m writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {"); writer.indent(); writer.print("String title = " + presenterInspector.getPresenterClassName() + "."); writePresenterMethodCall(writer); writer.println(); writer.println("event.getHandler().onSetPlaceTitle( title );"); writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodStaticWithHandler(SourceWriter writer) { writer.println();//from w w w .j a v a 2 s . c o m writer.println("protected void getPlaceTitle(GetPlaceTitleEvent event) {"); writer.indent(); writer.print(presenterInspector.getPresenterClassName() + "."); writePresenterMethodCall(writer); writer.println(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodNonStaticReturnString(SourceWriter writer) { writer.println();/* w w w. j a v a 2 s .c o m*/ writer.println("protected void getPlaceTitle(final GetPlaceTitleEvent event) {"); writer.indent(); writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName() + ">(getEventBus()){"); writer.indent(); writer.indent(); writer.println("public void success(" + presenterInspector.getPresenterClassName() + " p ) {"); writer.indent(); writer.print("String title = p."); writePresenterMethodCall(writer); writer.println(); writer.println("event.getHandler().onSetPlaceTitle( title );"); writer.outdent(); writer.println(" }"); writer.println("public void failure(Throwable t) { event.getHandler().onSetPlaceTitle(null); }"); writer.outdent(); writer.println("} );"); writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writeProxyMethodNonStaticWithHandler(SourceWriter writer) { writer.println();/*from w ww . ja v a 2s . co m*/ writer.println("protected void getPlaceTitle(final GetPlaceTitleEvent event) {"); writer.indent(); writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName() + ">(getEventBus()){"); writer.indent(); writer.indent(); writer.print("public void success(" + presenterInspector.getPresenterClassName() + " p ) { p."); writePresenterMethodCall(writer); writer.println(" }"); writer.println("public void failure(Throwable t) { event.getHandler().onSetPlaceTitle(null); }"); writer.outdent(); writer.println("} );"); writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.PresenterTitleMethod.java
License:Apache License
private void writePresenterMethodCall(SourceWriter writer) { writer.print(functionName + "( "); for (int i = 0; i < 3; ++i) { if (gingectorParamIndex == i) { if (i > 0) { writer.print(", "); }// w w w . jav a 2s. c o m writer.print("ginjector"); } else if (placeRequestParamIndex == i) { if (i > 0) { writer.print(", "); } writer.print("event.getRequest()"); } else if (setPlaceTitleHandlerParamIndex == i) { if (i > 0) { writer.print(", "); } writer.print("event.getHandler()"); } } writer.print(");"); }
From source file:com.gwtplatform.mvp.rebind.ProviderBundleGenerator.java
License:Apache License
private void writeConstructor(SourceWriter sourceWriter, List<JClassType> presenters) { sourceWriter.print("@" + Inject.class.getSimpleName()); sourceWriter.println();/* w w w . j a v a2 s .c o m*/ sourceWriter.print("public " + getClassName() + "("); sourceWriter.println(); sourceWriter.indent(); sourceWriter.indent(); int i = 0; for (JClassType presenter : presenters) { String name = presenter.getSimpleSourceName(); sourceWriter.print(String.format(CTOR_PARAM, name, name.toLowerCase())); if (i == presenters.size() - 1) { sourceWriter.print(") {"); } else { sourceWriter.print(","); } sourceWriter.println(); i++; } sourceWriter.outdent(); sourceWriter.print("super(" + presenters.size() + ");"); sourceWriter.println(); for (JClassType presenter : presenters) { String name = presenter.getSimpleSourceName(); sourceWriter.print(String.format(ARRAY_SETTER, name.toUpperCase(), name.toLowerCase())); sourceWriter.println(); } sourceWriter.outdent(); sourceWriter.print("}"); sourceWriter.println(); sourceWriter.outdent(); }
From source file:com.gwtplatform.mvp.rebind.TabInfoMethod.java
License:Apache License
/** * Writes the {@code getTabDataInternal} method definition in the generated proxy. * * @param writer The {@code SourceWriter} *//* w w w .j ava2 s . co m*/ public void writeGetTabDataInternalMethod(SourceWriter writer) throws UnableToCompleteException { if (returnString) { // Presenter static method returning a string assert tabPriority != null; writer.println(); writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName() + " ginjector) {"); writer.indent(); writer.print("return new TabDataBasic("); writer.print(presenterInspector.getPresenterClassName() + "."); writeTabInfoFunctionCall(writer); writer.println(", " + tabPriority + ");"); writer.outdent(); writer.println("}"); } else { // Presenter static method returning tab data writer.println(); writer.println("protected TabData getTabDataInternal(" + ginjectorInspector.getGinjectorClassName() + " ginjector) {"); writer.indent(); writer.print("return "); writer.print(presenterInspector.getPresenterClassName() + "."); writeTabInfoFunctionCall(writer); writer.println(";"); writer.outdent(); writer.println("}"); } }