Java Code Examples for com.google.gwt.user.rebind.ClassSourceFileComposerFactory#addImport()
The following examples show how to use
com.google.gwt.user.rebind.ClassSourceFileComposerFactory#addImport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventBinderGenerator.java From gwteventbinder with Apache License 2.0 | 6 votes |
private SourceWriter createSourceWriter( TreeLogger logger, GeneratorContext context, JClassType eventBinderType, JClassType targetType) { String simpleName = getSimpleGeneratedClassName(eventBinderType); String packageName = eventBinderType.getPackage().getName(); ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName); composer.setSuperclass(AbstractEventBinder.class.getCanonicalName() + "<" + targetType.getQualifiedSourceName() + ">"); composer.addImplementedInterface(eventBinderType.getName()); composer.addImport(EventBinder.class.getCanonicalName()); composer.addImport(EventBus.class.getCanonicalName()); composer.addImport(GenericEvent.class.getCanonicalName()); composer.addImport(GenericEventHandler.class.getCanonicalName()); composer.addImport(HandlerRegistration.class.getCanonicalName()); composer.addImport(LinkedList.class.getCanonicalName()); composer.addImport(List.class.getCanonicalName()); PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName); return (printWriter != null) ? composer.createSourceWriter(context, printWriter) : null; }
Example 2
Source File: InjectPresenterCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(Place.class.getName()); composerFactory.addImport(Presenter.class.getName()); for (JMethod presenterMethod : this.presenterMethods) { if (presenterMethod.getParameters().length > 0) { JType placeType = presenterMethod.getParameters()[0].getType(); composerFactory.addImport(placeType.getQualifiedSourceName()); if (placeType instanceof JParameterizedType) { JParameterizedType parameterizedType = (JParameterizedType) placeType; for (JType paramType : parameterizedType.getTypeArgs()) { composerFactory.addImport(paramType.getQualifiedSourceName()); } } } } composerFactory.addImplementedInterface(Presenter.class.getSimpleName()); composerFactory.addImport(AcceptsOneWidget.class.getName()); }
Example 3
Source File: UiBinderLocalizedCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) { String packageName = this.binderType.getPackage().getName(); String className = this.binderProxySimpleName; ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(UiBinder.class.getName()); composerFactory.addImport(UiBinderLocalized.class.getName()); composerFactory.addImport(UiTemplate.class.getName()); composerFactory.addImport(this.binderType.getQualifiedSourceName()); composerFactory.addImport(this.widgetType.getQualifiedSourceName()); composerFactory.addImport(this.targetType.getQualifiedSourceName()); composerFactory.addImplementedInterface(UiBinderLocalized.class.getSimpleName() + "<" + this.widgetType.getSimpleSourceName() + "," + this.targetType.getSimpleSourceName() + ">"); composerFactory.addImplementedInterface(UiBinder.class.getSimpleName() + "<" + this.widgetType.getSimpleSourceName() + "," + this.targetType.getSimpleSourceName() + ">"); composerFactory.addImplementedInterface(this.binderType.getSimpleSourceName()); return composerFactory.createSourceWriter(ctx, printWriter); }
Example 4
Source File: InjectMvpDescriptionCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(EntryPoint.class.getName()); composerFactory.addImport(MvpController.class.getName()); composerFactory.addImport(ActivityFactory.class.getName()); composerFactory.addImport(EntryPoint.class.getName()); composerFactory.addImport(AcceptsOneWidget.class.getName()); composerFactory.addImport(IsWidget.class.getName()); composerFactory.addImport(RootPanel.class.getName()); composerFactory.addImplementedInterface(EntryPoint.class.getName()); }
Example 5
Source File: SuspendServiceOnPresentCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { if (this.hasService) { composerFactory.addImport(CommandController.class.getName()); composerFactory.addImport(CallbackAdapter.class.getName()); composerFactory.addImport(List.class.getName()); composerFactory.addImport(CommandResponse.class.getName()); } }
Example 6
Source File: ProductConfigGenerator.java From core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Generate source code for new class. Class extends * <code>HashMap</code>. * * @param logger Logger object * @param context Generator context */ private void generateClass(TreeLogger logger, GeneratorContext context) throws Throwable { // get print writer that receives the source code PrintWriter printWriter = context.tryCreate(logger, packageName, className); // print writer if null, source code has ALREADY been generated, return if (printWriter == null) { return; } // init composer, set class properties, create source writer ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); // Imports composerFactory.addImport("org.jboss.as.console.client.Console"); composerFactory.addImport("org.jboss.as.console.client.ProductConfig"); composerFactory.addImport("java.util.*"); // Interfaces composerFactory.addImplementedInterface("org.jboss.as.console.client.ProductConfig"); // SourceWriter SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter); // ctor generateConstructor(sourceWriter); // Methods generateMethods(logger, sourceWriter, context); // close generated class sourceWriter.outdent(); sourceWriter.println("}"); // commit generated class context.commit(logger, printWriter); }
Example 7
Source File: ProxyViewCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) { ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(this.packageName, this.viewProxySimpleName); composerFactory.setSuperclass(this.placeType.getSimpleSourceName()); composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(RunAsyncCallback.class.getName()); composerFactory.addImport(ViewProxy.class.getName()); composerFactory.addImport(Place.class.getName()); composerFactory.addImport(ViewPlace.class.getName()); composerFactory.addImport(Activity.class.getName()); composerFactory.addImport(ViewActivity.class.getName()); composerFactory.addImport(ApplicationUnreachableException.class.getName()); composerFactory.addImport(this.placeType.getQualifiedSourceName()); composerFactory.addImport(this.activityDescrition.view().getCanonicalName()); if (this.placeTokenizerClass != null) { composerFactory.addImport(this.placeTokenizerClass.getCanonicalName()); } if (this.viewDecoratorClass != null) { composerFactory.addImport(this.viewDecoratorClass.getCanonicalName()); } composerFactory.addImplementedInterface( ViewProxy.class.getSimpleName() + "<" + this.placeType.getSimpleSourceName() + ">"); return composerFactory.createSourceWriter(ctx, printWriter); }
Example 8
Source File: InjectErrorHandlerCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(EventBus.class.getName()); composerFactory.addImport(HandlerRegistrationCollection.class.getName()); composerFactory.addImport(StopActivityEvent.class.getName()); composerFactory.addImport(ErrorManager.class.getName()); composerFactory.addImport(List.class.getName()); composerFactory.addImport(Lists.class.getName()); composerFactory.addImport(Lists.class.getName()); composerFactory.addImport(Lists.class.getName()); }
Example 9
Source File: RestServiceBinderCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private SourceWriter getSourceWriter(PrintWriter printWriter, GeneratorContext ctx) { String packageName = this.handlerType.getPackage().getName(); String className = this.proxyModelQualifiedName.indexOf('.') == -1 ? this.proxyModelQualifiedName : this.proxyModelQualifiedName.substring( this.proxyModelQualifiedName.lastIndexOf('.') + 1, this.proxyModelQualifiedName.length()); ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); composerFactory.addImport(AbstractServiceBinder.class.getName()); composerFactory.addImport(Arrays.class.getName()); composerFactory.addImport(Lists.class.getName()); composerFactory.addImport(MethodCallbackAdapter.class.getName()); composerFactory.addImport(Method.class.getName()); composerFactory.addImport(CompositeMethodCallback.class.getName()); composerFactory.addImport(CallbackAdapter.class.getName()); composerFactory.addImport(REST.class.getName()); composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(this.serviceType.getQualifiedSourceName()); composerFactory.addImport(this.serviceBinderType.getQualifiedSourceName()); for (JType jType : this.imports) { if (jType.isPrimitive() != null) { continue; } composerFactory.addImport(jType.getQualifiedSourceName()); } composerFactory.setSuperclass(AbstractServiceBinder.class.getSimpleName() + "<" + this.handlerType.getSimpleSourceName() + ", " + this.serviceType.getSimpleSourceName() + ">"); composerFactory.addImplementedInterface(this.serviceType.getSimpleSourceName()); composerFactory.addImplementedInterface(this.serviceBinderType.getSimpleSourceName()); return composerFactory.createSourceWriter(ctx, printWriter); }
Example 10
Source File: InitializeFormCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(MessageHelper.class.getName()); composerFactory.addImport(ConstantsWithLookup.class.getName()); composerFactory.addImport(this.beanType.getQualifiedSourceName()); }
Example 11
Source File: InjectMayStopActivityCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(EventBus.class.getName()); composerFactory.addImport(HandlerRegistrationCollection.class.getName()); composerFactory.addImport(MayStopActivityEvent.class.getName()); composerFactory.addImport(StopActivityEvent.class.getName()); }
Example 12
Source File: InjectTemplateCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(UiBinderLocalized.class.getName()); composerFactory.addImport(Widget.class.getName()); composerFactory.addImport(UiTemplate.class.getName()); }
Example 13
Source File: InjectThemeCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(EntryPoint.class.getName()); composerFactory.addImport(Theme.class.getName()); composerFactory.addImport(ThemeController.class.getName()); composerFactory.addImport(CssLink.class.getName()); composerFactory.addImplementedInterface(EntryPoint.class.getName()); }
Example 14
Source File: JsonGwtJacksonGenerator.java From requestor with Apache License 2.0 | 4 votes |
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) { JPackage serviceIntfPkg = intfType.getPackage(); String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName(); PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName()); if (printWriter == null) { return null; } ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, getTypeSimpleName()); String[] imports = new String[]{ // java ArrayList.class.getCanonicalName(), Collection.class.getCanonicalName(), HashSet.class.getCanonicalName(), Iterator.class.getCanonicalName(), LinkedHashSet.class.getCanonicalName(), LinkedList.class.getCanonicalName(), List.class.getCanonicalName(), Set.class.getCanonicalName(), TreeSet.class.getCanonicalName(), // com.github.nmorel.gwtjackson ObjectMapper.class.getCanonicalName(), ObjectReader.class.getCanonicalName(), ObjectWriter.class.getCanonicalName(), // com.google.gwt GWT.class.getCanonicalName(), // io.reinert.requestor DeserializationContext.class.getCanonicalName(), Deserializer.class.getCanonicalName(), JsonObjectSerdes.class.getCanonicalName(), JsonRecordReader.class.getCanonicalName(), JsonRecordWriter.class.getCanonicalName(), UnableToDeserializeException.class.getName(), UnableToSerializeException.class.getName(), Serdes.class.getCanonicalName(), Serializer.class.getCanonicalName(), SerializationContext.class.getCanonicalName() }; for (String imp : imports) { composerFactory.addImport(imp); } composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName()); return composerFactory.createSourceWriter(ctx, printWriter); }
Example 15
Source File: InjectSecuritedCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(SessionController.class.getName()); }
Example 16
Source File: InjectServiceCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(ServiceProxy.class.getName()); composerFactory.addImport(this.serviceName); }
Example 17
Source File: InjectStopActivityCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(EventBus.class.getName()); composerFactory.addImport(HandlerRegistrationCollection.class.getName()); composerFactory.addImport(StopActivityEvent.class.getName()); }
Example 18
Source File: ApplicationMetaDataGenerator.java From core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Generate source code for new class. Class extends * <code>HashMap</code>. * * @param logger Logger object * @param context Generator context */ private void generateClass(TreeLogger logger, GeneratorContext context) { // get print writer that receives the source code PrintWriter printWriter = context.tryCreate(logger, packageName, className); // print writer if null, source code has ALREADY been generated, return if (printWriter == null) return; // init composer, set class properties, create source writer ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); // Imports composerFactory.addImport("org.jboss.as.console.client.Console"); composerFactory.addImport("org.jboss.as.console.client.widgets.forms.*"); composerFactory.addImport("java.util.*"); // Interfaces composerFactory.addImplementedInterface("org.jboss.as.console.client.widgets.forms.ApplicationMetaData"); // SourceWriter SourceWriter sourceWriter = composerFactory.createSourceWriter(context, printWriter); // fields generateFields(sourceWriter); // ctor generateConstructor(logger, context, sourceWriter); // Methods generateMethods(sourceWriter); // close generated class sourceWriter.outdent(); sourceWriter.println("}"); // commit generated class context.commit(logger, printWriter); }
Example 19
Source File: InjectModelCreator.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void initComposer(ClassSourceFileComposerFactory composerFactory) { composerFactory.addImport(GWT.class.getName()); composerFactory.addImport(Model.class.getName()); composerFactory.addImport(this.beanType.getQualifiedSourceName()); }
Example 20
Source File: Mvp4gRunAsyncGenerator.java From mvp4g with Apache License 2.0 | 4 votes |
private RebindResult create(JClassType originalType, TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { Date start = new Date(); String packageName = originalType.getPackage() .getName(); String originalClassName = originalType.getSimpleSourceName(); String generatedClassName = originalClassName + "Impl"; String generatedClassQualifiedName = packageName + "." + generatedClassName; // check weather there is a usual version or not. if (checkAlreadyGenerated(logger, context, generatedClassQualifiedName)) { // Log logger.log(TreeLogger.INFO, "reuse already generated files", null); // stop generating return new RebindResult(RebindMode.USE_EXISTING, generatedClassQualifiedName); } logger.log(TreeLogger.INFO, "Generating writer for " + packageName + "." + generatedClassName, null); PrintWriter printWriter = context.tryCreate(logger, packageName, generatedClassName); ClassSourceFileComposerFactory classFactory = new ClassSourceFileComposerFactory(packageName, generatedClassName); classFactory.addImplementedInterface(originalType.getName()); String[] classesToImport = getClassesToImport(); for (String classToImport : classesToImport) { classFactory.addImport(classToImport); } if (printWriter != null) { SourceWriter sourceWriter = classFactory.createSourceWriter(context, printWriter); logger.log(TreeLogger.INFO, "Generating source for " + generatedClassQualifiedName + " ", null); writeClass(sourceWriter, getRunAsync(originalType)); sourceWriter.commit(logger); } Date end = new Date(); logger.log(TreeLogger.INFO, "Mvp4g Module Cretor: " + (end.getTime() - start.getTime()) + "ms."); return new RebindResult(RebindMode.USE_ALL_NEW_WITH_NO_CACHING, generatedClassQualifiedName); }