com.google.gwt.uibinder.client.UiBinder Java Examples

The following examples show how to use com.google.gwt.uibinder.client.UiBinder. 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: UiBinderLocalizedCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #2
Source File: FakeUiBinderProvider.java    From gwtmockito with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new instance of FakeUiBinder that implements the given interface.
 * This is accomplished by returning a dynamic proxy object that delegates
 * calls to a backing FakeUiBinder.
 *
 * @param type interface to be implemented by the returned type. This must
 *        represent an interface that directly extends {@link UiBinder}.
 */
@Override
public UiBinder<?, ?> getFake(final Class<?> type) {
  return (UiBinder<?, ?>) Proxy.newProxyInstance(
      FakeUiBinderProvider.class.getClassLoader(),
      new Class<?>[] {type},
      new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Exception {
          // createAndBindUi is the only method defined by UiBinder
          for (Field field : getAllFields(args[0].getClass())) {
            if (field.isAnnotationPresent(UiField.class)
                && !field.getAnnotation(UiField.class).provided()) {
              field.setAccessible(true);
              field.set(args[0], GWT.create(field.getType()));
            }
          }
          return GWT.create(getUiRootType(type));
        }
      });
}