当前位置: 首页>>代码示例>>Java>>正文


Java ClassSourceFileComposerFactory.addImport方法代码示例

本文整理汇总了Java中com.google.gwt.user.rebind.ClassSourceFileComposerFactory.addImport方法的典型用法代码示例。如果您正苦于以下问题:Java ClassSourceFileComposerFactory.addImport方法的具体用法?Java ClassSourceFileComposerFactory.addImport怎么用?Java ClassSourceFileComposerFactory.addImport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.rebind.ClassSourceFileComposerFactory的用法示例。


在下文中一共展示了ClassSourceFileComposerFactory.addImport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGetSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Override
protected SourceWriter doGetSourceWriter(JClassType classType) {
	String packageName = classType.getPackage().getName();
	String simpleName = getSimpleUnitName(classType);
	ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(
			packageName, simpleName);
	composer.setSuperclass(TypeOracleImpl.class.getCanonicalName());
	composer.addImport("org.lirazs.gbackbone.reflection.client.*");
	composer.addImport("java.util.*");
	composer.addImport(classType.getPackage().getName() + ".*");

	PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
	if (printWriter == null) {
		return null;
	} else {
		SourceWriter sw = composer.createSourceWriter(context, printWriter);
		return sw;
	}
}
 
开发者ID:liraz,项目名称:gwt-backbone,代码行数:20,代码来源:SourceVisitor.java

示例2: generateImports

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
/**
 * Inject imports
 *
 * @param extensions
 * @param composerFactory
 */
private void generateImports(
    List<JClassType> extensions, ClassSourceFileComposerFactory composerFactory) {
  // imports
  composerFactory.addImport(GWT.class.getCanonicalName());
  composerFactory.addImport(Extension.class.getCanonicalName());
  composerFactory.addImport(ExtensionRegistry.class.getCanonicalName());
  composerFactory.addImport(Inject.class.getCanonicalName());
  composerFactory.addImport(Provider.class.getCanonicalName());
  composerFactory.addImport(List.class.getCanonicalName());
  composerFactory.addImport(ArrayList.class.getCanonicalName());
  composerFactory.addImport(Map.class.getCanonicalName());
  composerFactory.addImport(HashMap.class.getCanonicalName());
  // import for extensions
  for (JClassType jClassType : extensions) {
    composerFactory.addImport(jClassType.getQualifiedSourceName());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ExtensionRegistryGenerator.java

示例3: createModule

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private String createModule(TreeLogger logger, GeneratorContext context, JClassType requestedType,
    String packageName, String requestedName) {
  String moduleName = requestedName + "Module";
  ClassSourceFileComposerFactory moduleFactory =
      new ClassSourceFileComposerFactory(packageName, moduleName);
  moduleFactory.setSuperclass(AbstractGinModule.class.getCanonicalName());
  moduleFactory.addImport(Names.class.getCanonicalName());
  SourceWriter moduleWriter = moduleFactory.createSourceWriter(context,
      context.tryCreate(logger, packageName, moduleName));

  moduleWriter.println("public void configure() {");
  moduleWriter.indent();
  for (JMethod method : requestedType.getMethods()) {
    if (method.getName().startsWith("set")) {
      String name = method.getParameters()[0].getAnnotation(Named.class).value();
      moduleWriter.println("bindConstant().annotatedWith(Names.named(\"" + name + "\")).to(\""
          + Math.pow(Integer.parseInt(name), 2) + "\");");
    }
  }
  moduleWriter.outdent();
  moduleWriter.println("}");
  moduleWriter.commit(logger);
  return moduleName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:25,代码来源:FrameworkGenerator.java

示例4: generateDataProxyFastJSOClasses

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
void generateDataProxyFastJSOClasses()
{
	for( JType type : dataProxyFastFactories )
	{
		String jsoPackage = getDataProxyFastImplPackageName( type );
		String jsoSimpleClassName = getDataProxyFastImplSimpleName( type );

		PrintWriter pw2 = context.tryCreate( logger, jsoPackage, jsoSimpleClassName );
		if( pw2 == null )
			continue;

		ClassSourceFileComposerFactory cf2 = new ClassSourceFileComposerFactory( jsoPackage, jsoSimpleClassName );
		cf2.addImport( "fr.lteconsulting.hexa.client.comm.GenericJSO" );
		cf2.addImport( "com.google.gwt.core.client.JavaScriptObject" );
		cf2.addImport( "com.google.gwt.core.client.GWT" );
		cf2.addImport( "fr.lteconsulting.hexa.client.tools.HexaTools" );
		cf2.addImplementedInterface( type.getParameterizedQualifiedSourceName() );
		cf2.setSuperclass( "GenericJSO" );
		SourceWriter sw2 = cf2.createSourceWriter( context, pw2 );
		generateDataProxyFastJSOImpl( jsoSimpleClassName, type, sw2, logger );
		sw2.commit( logger );
	}
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:24,代码来源:ServiceGenerator.java

示例5: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
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;
}
 
开发者ID:google,项目名称:gwteventbinder,代码行数:26,代码来源:EventBinderGenerator.java

示例6: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
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.addImplementedInterface(eventBinderType.getName());
  composer.addImport(EventHandlerMethod.class.getCanonicalName());
  composer.addImport(LinkedList.class.getCanonicalName());
  composer.addImport(List.class.getCanonicalName());
  composer.addImport(MultiEvent.class.getCanonicalName());

  PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
  return printWriter != null ? composer.createSourceWriter(context, printWriter) : null;
}
 
开发者ID:ekuefler,项目名称:gwt-supereventbus,代码行数:17,代码来源:EventRegistrationGenerator.java

示例7: createSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
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(AbstractDomEventBinder.class.getCanonicalName() + "<" + targetType.getName() + ">");
    composer.addImplementedInterface(eventBinderType.getName());

    composer.addImport(LinkedList.class.getCanonicalName());
    composer.addImport(List.class.getCanonicalName());
    composer.addImport(Element.class.getCanonicalName());
    composer.addImport(HandlerRegistration.class.getCanonicalName());
    composer.addImport(IsWidget.class.getCanonicalName());

    PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
    return (printWriter != null) ? composer.createSourceWriter(context, printWriter) : null;
}
 
开发者ID:rfilippone,项目名称:gwt-dom-event-binder,代码行数:18,代码来源:DomEventBinderGenerator.java

示例8: GinjectorFragmentOutputter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Inject
GinjectorFragmentOutputter(GeneratorContext ctx, GinjectorFragmentContext.Factory ginjectorFragmentContextFactory, ErrorManager errorManager,
                           TreeLogger logger, SourceWriteUtil.Factory sourceWriteUtilFactory, @Assisted GinjectorBindings bindings,
                           @Assisted FragmentPackageName fragmentPackageName, @Assisted("ginjectorPackageName") String ginjectorPackageName,
                           @Assisted("ginjectorClassName") String ginjectorClassName) {

    this.ctx = ctx;
    this.errorManager = errorManager;
    this.logger = logger;
    this.sourceWriteUtil = sourceWriteUtilFactory.create(bindings);

    this.fragmentPackageName = fragmentPackageName;
    this.ginjectorClassName = ginjectorClassName;
    this.nameGenerator = bindings.getNameGenerator();

    fragmentClassName = nameGenerator.getFragmentClassName(ginjectorClassName, fragmentPackageName);
    if (fragmentClassName.contains(".")) {
        errorManager.logError("Internal error: the fragment class name \"%s\" contains a full stop.", fragmentClassName);
    }

    PrintWriter printWriter = ctx.tryCreate(logger, fragmentPackageName.toString(), fragmentClassName);
    if (printWriter == null) {
        // Something is very wrong! We already created this fragment, but the
        // GinjectorBindingsOutputter should only create each fragment once.
        // Something bad will probably happen later on if we continue, so just
        // abort.
        logger.log(TreeLogger.Type.ERROR, "The fragment " + fragmentPackageName + "." + fragmentClassName + " already exists.");
        throw new IllegalStateException("The fragment " + fragmentClassName + " already exists.");
    }

    ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(fragmentPackageName.toString(), fragmentClassName);

    composerFactory.addImport(GWT.class.getCanonicalName());
    composerFactory.addImport(ginjectorPackageName + "." + ginjectorClassName);
    writer = composerFactory.createSourceWriter(ctx, printWriter);

    injectorWriteContext = ginjectorFragmentContextFactory.create(bindings, fragmentPackageName, writer);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:39,代码来源:GinjectorFragmentOutputter.java

示例9: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext context, JClassType classType) {
	String packageName = packageNameFrom(classType);
	String simpleName = simpleNameFrom(classType);
	ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
	composer.addImplementedInterface(classType.getName());
	composer.addImport(classType.getQualifiedSourceName());
	PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
	if (printWriter == null) {
		return null; 
	} else {
		return composer.createSourceWriter(context, printWriter);
	} 
}
 
开发者ID:TOMOTON,项目名称:gwt-dagger2,代码行数:14,代码来源:VersionGenerator.java

示例10: generate

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
    throws UnableToCompleteException {
  JClassType requestedType = context.getTypeOracle().findType(typeName);
  String packageName = requestedType.getPackage().getName();
  String requestedName = requestedType.getSimpleSourceName();
  String newClassName = requestedName + "Impl";

  String moduleName = createModule(logger, context, requestedType, packageName, requestedName);

  String ginjectorName =
      createGinjector(logger, context, packageName, requestedName, newClassName, moduleName);

  ClassSourceFileComposerFactory composerFactory =
      new ClassSourceFileComposerFactory(packageName, newClassName);
  composerFactory.setSuperclass(requestedType.getQualifiedSourceName());
  composerFactory.addImport(GWT.class.getCanonicalName());
  SourceWriter writer = composerFactory
      .createSourceWriter(context, context.tryCreate(logger, packageName, newClassName));
  writer.println("public void initialize() {");
  writer.indent();
  writer.println(
      "((" +  ginjectorName + ") GWT.create(" + ginjectorName + ".class)).injectMembers(this);");
  writer.outdent();
  writer.println("}");
  writer.commit(logger);

  return packageName + "." + newClassName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:30,代码来源:FrameworkGenerator.java

示例11: createGinjector

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private String createGinjector(TreeLogger logger, GeneratorContext context, String packageName,
    String requestedName, String newClassName, String moduleName) {
  String ginjectorName = requestedName + "Ginjector";
  ClassSourceFileComposerFactory ginjectorFactory =
      new ClassSourceFileComposerFactory(packageName, ginjectorName);
  ginjectorFactory.makeInterface();
  ginjectorFactory.addImplementedInterface(Ginjector.class.getCanonicalName());
  ginjectorFactory.addImport(GinModules.class.getCanonicalName());
  ginjectorFactory.addAnnotationDeclaration("@GinModules(" + moduleName + ".class)");
  SourceWriter ginjectorWriter = ginjectorFactory.createSourceWriter(context,
      context.tryCreate(logger, packageName, ginjectorName));
  ginjectorWriter.println("void injectMembers(" + newClassName + " obj);");
  ginjectorWriter.commit(logger);
  return ginjectorName;
}
 
开发者ID:google-code-export,项目名称:google-gin,代码行数:16,代码来源:FrameworkGenerator.java

示例12: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger,
                                     GeneratorContext context,
                                     JClassType originalType,
                                     String packageName,
                                     String generatedClassName)
  throws UnableToCompleteException {

  logger.log(TreeLogger.INFO,
             "Generating writer for " + packageName + "." + generatedClassName,
             null);

  PrintWriter printWriter = context.tryCreate(logger,
                                              packageName,
                                              generatedClassName);
  if (printWriter == null) {
    return null;
  }

  ClassSourceFileComposerFactory classFactory = new ClassSourceFileComposerFactory(packageName,
                                                                                   generatedClassName);

  classFactory.addImplementedInterface(originalType.getName());
  String[] classesToImport = getClassesToImport();
  for (String classToImport : classesToImport) {
    classFactory.addImport(classToImport);
  }

  return classFactory.createSourceWriter(context,
                                         printWriter);
}
 
开发者ID:mvp4g,项目名称:mvp4g,代码行数:31,代码来源:Mvp4gGenerator.java

示例13: writeInterface

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
/**
 * Write an Empty Interface implementing
 * {@link de.knightsoftnet.validators.client.impl.GwtSpecificValidator} with Generic parameter of
 * the bean type.
 */
private void writeInterface(final GeneratorContext context, final TreeLogger logger,
    final BeanHelper bean) {
  final PrintWriter pw = context.tryCreate(logger, bean.getPackage(), bean.getValidatorName());
  if (pw != null) {
    final TreeLogger interfaceLogger = logger.branch(TreeLogger.TRACE,
        "Creating the interface for " + bean.getFullyQualifiedValidatorName());

    final ClassSourceFileComposerFactory factory =
        new ClassSourceFileComposerFactory(bean.getPackage(), bean.getValidatorName());
    factory.addImplementedInterface(
        GwtSpecificValidator.class.getCanonicalName() + " <" + bean.getTypeCanonicalName() + ">");
    factory.addImport(GWT.class.getCanonicalName());
    factory.makeInterface();
    final SourceWriter sw = factory.createSourceWriter(context, pw);

    // static MyValidator INSTANCE = GWT.create(MyValidator.class);
    sw.print("static ");
    sw.print(bean.getValidatorName());
    sw.print(" INSTANCE = GWT.create(");
    sw.print(bean.getValidatorName());
    sw.println(".class);");

    sw.commit(interfaceLogger);
    pw.close();
  }
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:32,代码来源:BeanHelperCache.java

示例14: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger,
                                     GeneratorContext context,
                                     JClassType originalType,
                                     String packageName,
                                     String simpleSourceName)
    throws UnableToCompleteException {

  logger.log(TreeLogger.DEBUG,
             "Generating writer for " + packageName + "." + simpleSourceName,
             null);

  PrintWriter printWriter = context.tryCreate(logger,
                                              packageName,
                                              simpleSourceName);
  if (printWriter == null) {
    return null;
  }

  ClassSourceFileComposerFactory classFactory = new ClassSourceFileComposerFactory(packageName,
                                                                                   simpleSourceName);
  classFactory.addImplementedInterface(originalType.getName());
  // imports
  classFactory.addImport(Name.getSourceNameForClass(SafeHtml.class));
  classFactory.addImport(Name.getSourceNameForClass(SafeHtmlBuilder.class));

  return classFactory.createSourceWriter(context,
                                         printWriter);
}
 
开发者ID:gwt4e,项目名称:gwt4e,代码行数:29,代码来源:TemplateGenerator.java

示例15: getSourceWriter

import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; //导入方法依赖的package包/类
public SourceWriter getSourceWriter(JClassType classType,
		GeneratorContext context, TreeLogger logger) {
	String packageName = classType.getPackage().getName();
	String simpleName = classType.getSimpleSourceName() + "Generated";
	
	ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, simpleName);
	composer.addImplementedInterface(classType.getName());

	// Need to add whatever imports your generated class needs.
	composer.addImport("com.google.gwt.xml.client.*");
	composer.addImport("com.peterfranza.gwt.jaxb.client.parser.*");

	
	PrintWriter printWriter = context.tryCreate(logger, packageName, simpleName);
	if (printWriter == null) {
		return null;
	} else {
		SourceWriter sw = composer.createSourceWriter(context, printWriter);
		return sw;
	}
}
 
开发者ID:pfranza,项目名称:gwtjaxb,代码行数:22,代码来源:JAXBParserGenerator.java


注:本文中的com.google.gwt.user.rebind.ClassSourceFileComposerFactory.addImport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。