本文整理汇总了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;
}
}
示例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());
}
}
示例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;
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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);
}
示例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;
}
}