List of usage examples for com.google.gwt.user.rebind SourceWriter println
void println();
From source file:de.knightsoftnet.validators.rebind.GwtSpecificValidatorCreator.java
License:Apache License
@Override protected void writeClassBody(final SourceWriter sw) throws UnableToCompleteException { this.writeFields(sw); sw.println(); this.writeValidateClassGroups(sw); sw.println();/*from ww w . j a va 2 s. c o m*/ this.writeExpandDefaultAndValidateClassGroups(sw); sw.println(); this.writeExpandDefaultAndValidatePropertyGroups(sw); sw.println(); this.writeExpandDefaultAndValidateValueGroups(sw); sw.println(); this.writeValidatePropertyGroups(sw); sw.println(); this.writeValidateValueGroups(sw); sw.println(); this.writeGetBeanMetadata(sw); sw.println(); this.writeGetDescriptor(sw); sw.println(); this.writePropertyValidators(sw); sw.println(); this.writeValidateAllNonInheritedProperties(sw); sw.println(); // Write the wrappers after we know which are needed this.writeWrappers(sw); sw.println(); }
From source file:de.knightsoftnet.validators.rebind.GwtSpecificValidatorCreator.java
License:Apache License
private void writePropertyValidators(final SourceWriter sw) throws UnableToCompleteException { for (final PropertyDescriptor p : this.beanHelper.getBeanDescriptor().getConstrainedProperties()) { if (this.beanHelper.hasField(p)) { this.writeValidatePropertyMethod(sw, p, true); sw.println(); }/*from www . j av a2 s. c om*/ if (this.beanHelper.hasGetter(p)) { this.writeValidatePropertyMethod(sw, p, false); sw.println(); } } }
From source file:de.knightsoftnet.validators.rebind.ValidatorCreator.java
License:Apache License
@Override protected void writeClassBody(final SourceWriter sourceWriter) { this.writeConstructor(sourceWriter); sourceWriter.println(); this.writeCreateValidationGroupsMetadata(sourceWriter); sourceWriter.println();/*from ww w . jav a 2 s .c o m*/ this.writeValidate(sourceWriter); sourceWriter.println(); this.writeValidateProperty(sourceWriter); sourceWriter.println(); this.writeValidateValue(sourceWriter); sourceWriter.println(); this.writeGetConstraintsForClass(sourceWriter); sourceWriter.println(); this.writeGwtValidate(sourceWriter); }
From source file:fr.putnami.pwt.core.model.rebind.ModelCreator.java
License:Open Source License
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter printWriter = this.getPrintWriter(logger, context, this.proxyModelQualifiedName); if (printWriter == null) { return this.proxyModelQualifiedName; }/*from w w w . jav a2s . c om*/ JField[] fields = this.beanType.getFields(); JMethod[] methods = this.beanType.getMethods(); this.parentType = this.beanType.getSuperclass(); this.imports.add(this.parentType); this.listPublicFields(fields); this.listGetters(methods); this.listSetters(methods); this.createSubModels(logger, context); SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); srcWriter.println(); this.generateSingleton(logger, srcWriter); srcWriter.println(); srcWriter.println(); this.generateStaticInitializer(logger, srcWriter); srcWriter.println(); this.generateConstructor(logger, srcWriter); srcWriter.println(); this.generateCreate(logger, srcWriter); srcWriter.println(); this.generateInternalSet(logger, srcWriter); srcWriter.println(); this.generateInternalGet(logger, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyModelQualifiedName; }
From source file:fr.putnami.pwt.core.mvp.rebind.ProxyViewCreator.java
License:Open Source License
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter printWriter = context.tryCreate(logger, this.packageName, this.viewProxySimpleName); if (printWriter == null) { return this.viewProxyQualifiedName; }// w w w. ja v a 2 s .co m SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); this.generateProxy(logger, srcWriter); srcWriter.println(); this.generateTokenPrefixes(logger, srcWriter); srcWriter.println(); if (this.placeTokenizerClass == null) { this.generateInternalTokenizer(logger, srcWriter); } else { this.generateDelegateTokenizer(logger, srcWriter); } this.generateActivityFactory(logger, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.viewProxyQualifiedName; }
From source file:fr.putnami.pwt.core.mvp.rebind.ProxyViewCreator.java
License:Open Source License
private void generateProxy(TreeLogger logger, SourceWriter srcWriter) { String viewName = this.activityDescrition.view().getSimpleName(); srcWriter.println(); srcWriter.println("private static %s view;", viewName); srcWriter.println();//w ww . ja v a 2 s. co m srcWriter.println("@Override"); srcWriter.println("public void loadView(final ViewProxy.Callback callback) {"); srcWriter.indent(); if (this.activityDescrition.asyncView()) { srcWriter.println("GWT.runAsync(%s.class, new RunAsyncCallback() {", viewName); srcWriter.indent(); srcWriter.println("public void onFailure(Throwable reason) {"); srcWriter.indent(); srcWriter.println("if (ApplicationUnreachableException.HTTP_DOWNLOAD_FAILURE_EXCEPTION" + ".equals(reason.getClass().getSimpleName())) {"); srcWriter.indent(); srcWriter.println("reason = new ApplicationUnreachableException(reason);"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.println("GWT.reportUncaughtException(reason);"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.println("public void onSuccess() {"); srcWriter.indent(); srcWriter.println("if(view == null || %s){", this.activityDescrition.scope() == Scope.PROTOTYPE); srcWriter.indent(); srcWriter.println("view = GWT.create(%s.class);", viewName); srcWriter.outdent(); srcWriter.println("}"); this.generateProxyResult(logger, srcWriter); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("});"); } else { srcWriter.println("if(view == null || %s){", this.activityDescrition.scope() == Scope.PROTOTYPE); srcWriter.indent(); srcWriter.println("view = GWT.create(%s.class);", viewName); srcWriter.outdent(); srcWriter.println("}"); this.generateProxyResult(logger, srcWriter); } srcWriter.outdent(); srcWriter.println("}"); }
From source file:fr.putnami.pwt.core.service.rebind.ServiceBinderCreator.java
License:Open Source License
public String create(TreeLogger logger, GeneratorContext context) throws UnableToCompleteException, NotFoundException { PrintWriter printWriter = this.getPrintWriter(logger, context); if (printWriter == null) { return this.proxyModelQualifiedName; }//from w ww . ja v a 2 s. c o m this.serializerTypeName = this.createSerializer(logger, context); this.collectImports(); SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); srcWriter.println(); this.generateSerializer(srcWriter); srcWriter.println(); this.generateServiceImplementation(logger, srcWriter); this.generateServiceImplementationWithCallback(logger, srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyModelQualifiedName; }
From source file:fr.putnami.pwt.core.widget.rebind.UiBinderLocalizedCreator.java
License:Open Source License
public String create(TreeLogger logger, GeneratorContext context) { Resource templateResource = this.getTemplateResource(context); if (templateResource == null) { throw new NullPointerException("no template found"); }// w ww . j a v a 2 s. c o m this.binderProxySimpleName = this.targetType.getSimpleSourceName() + "_" + this.binderType.getSimpleSourceName() + UiBinderLocalizedCreator.PROXY_SUFFIX; if (this.locale != null) { this.binderProxySimpleName += "_" + this.locale.toString(); } this.binderProxyQualifiedName = this.targetType.getPackage().getName() + "." + this.binderProxySimpleName; PrintWriter printWriter = this.getPrintWriter(logger, context, this.binderProxyQualifiedName); if (printWriter == null) { return this.binderProxyQualifiedName; } SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.println(); srcWriter.indent(); this.generateProxy(logger, srcWriter); srcWriter.println(); srcWriter.outdent(); srcWriter.commit(logger); return this.binderProxyQualifiedName; }
From source file:fr.putnami.pwt.plugin.rest.rebind.RestServiceBinderCreator.java
License:Open Source License
public String create(TreeLogger logger, GeneratorContext context) { PrintWriter printWriter = this.getPrintWriter(logger, context); if (printWriter == null) { return this.proxyModelQualifiedName; }/* w w w . j a v a2s. co m*/ this.collectImports(); SourceWriter srcWriter = this.getSourceWriter(printWriter, context); srcWriter.indent(); srcWriter.println(); this.generateCreateService(srcWriter); srcWriter.println(); this.generateServiceImplementation(logger, srcWriter); this.generateServiceImplementationWithCallback(srcWriter); srcWriter.outdent(); srcWriter.commit(logger); return this.proxyModelQualifiedName; }
From source file:io.reinert.requestor.rebind.JsonAutoBeanGenerator.java
License:Apache License
@Override public String generate(TreeLogger logger, GeneratorContext ctx, String typeName) throws UnableToCompleteException { TypeOracle typeOracle = ctx.getTypeOracle(); assert typeOracle != null; JClassType intfType = typeOracle.findType(typeName); if (intfType == null) { logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null); throw new UnableToCompleteException(); }/*from www. j a v a 2 s. c om*/ if (intfType.isInterface() == null) { logger.log(TreeLogger.ERROR, intfType.getQualifiedSourceName() + " is not an interface", null); throw new UnableToCompleteException(); } // TODO: check if type was already generated and reuse it TreeLogger typeLogger = logger.branch(TreeLogger.ALL, "Generating Json SerDes powered by AutoBeans...", null); final SourceWriter sourceWriter = getSourceWriter(typeLogger, ctx, intfType); if (sourceWriter != null) { sourceWriter.println(); ArrayDeque<JClassType> annotatedTypes = new ArrayDeque<JClassType>(); ArrayList<Json> jsonAnnotations = new ArrayList<Json>(); final ArrayDeque<String> allTypesAndWrappers = new ArrayDeque<String>(); for (JClassType type : typeOracle.getTypes()) { Json annotation = type.getAnnotation(Json.class); if (annotation != null && type.isInterface() != null) { annotatedTypes.add(type); jsonAnnotations.add(annotation); final String listWrapperTypeName = generateListWrapperInterface(sourceWriter, type); sourceWriter.println(); final String setWrapperTypeName = generateSetWrapperInterface(sourceWriter, type); sourceWriter.println(); // Add current type name for single de/serialization allTypesAndWrappers.add(type.getQualifiedSourceName()); allTypesAndWrappers.add(listWrapperTypeName); allTypesAndWrappers.add(setWrapperTypeName); } } final ArrayDeque<String> serdesFields = new ArrayDeque<String>(); final ArrayDeque<String> providerFields = new ArrayDeque<String>(); if (!allTypesAndWrappers.isEmpty()) { generateFactoryInterface(sourceWriter, allTypesAndWrappers); sourceWriter.println(); generateFactoryField(sourceWriter); sourceWriter.println(); int i = 0; for (JClassType annotatedType : annotatedTypes) { final String providerFieldName = generateProviderField(sourceWriter, annotatedType); providerFields.add(providerFieldName); final String serdesFieldName = generateSerdesClassAndField(logger, typeOracle, sourceWriter, annotatedType, jsonAnnotations.get(i++)); serdesFields.add(serdesFieldName); } } generateFields(sourceWriter); generateConstructor(sourceWriter, serdesFields, providerFields); generateMethods(sourceWriter); sourceWriter.commit(typeLogger); } return typeName + "Impl"; }