com.google.web.bindery.event.shared.binder.EventBinder Java Examples

The following examples show how to use com.google.web.bindery.event.shared.binder.EventBinder. 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 vote down vote up
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: EventBinderGenerator.java    From gwteventbinder with Apache License 2.0 5 votes vote down vote up
private JClassType getTargetType(JClassType interfaceType, TypeOracle typeOracle) {
  JClassType[] superTypes = interfaceType.getImplementedInterfaces();
  JClassType eventBinderType = typeOracle.findType(EventBinder.class.getCanonicalName());
  if (superTypes.length != 1
      || !superTypes[0].isAssignableFrom(eventBinderType)
      || superTypes[0].isParameterized() == null) {
    throw new IllegalArgumentException(
        interfaceType + " must extend EventBinder with a type parameter");
  }
  return superTypes[0].isParameterized().getTypeArgs()[0];
}