Java Code Examples for com.google.gwt.user.rebind.SourceWriter#println()

The following examples show how to use com.google.gwt.user.rebind.SourceWriter#println() . 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: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String create(TreeLogger logger, GeneratorContext context) {
	PrintWriter printWriter = context.tryCreate(logger, this.packageName, this.viewProxySimpleName);
	if (printWriter == null) {
		return this.viewProxyQualifiedName;
	}

	SourceWriter srcWriter = this.getSourceWriter(printWriter, context);

	srcWriter.indent();
	this.generateProxy(logger, srcWriter);
	srcWriter.println();
	this.generateTokenPrefixes(logger, srcWriter);
	srcWriter.println();
	if (this.placeTokenizerClass == null) {
		this.generateInternalTokenizer(logger, srcWriter);
	} else {
		this.generateDelegateTokenizer(logger, srcWriter);
	}
	this.generateActivityFactory(logger, srcWriter);
	srcWriter.outdent();

	srcWriter.commit(logger);
	return this.viewProxyQualifiedName;
}
 
Example 2
Source File: UiBinderLocalizedCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void generateProxy(TreeLogger logger, SourceWriter srcWriter) {

		srcWriter.println("@UiTemplate(\"%s\")", this.templateName);
		srcWriter.println("interface Binder extends UiBinder<%s, %s> {", this.widgetType.getSimpleSourceName(),
			this.targetType.getSimpleSourceName());
		srcWriter.indent();
		srcWriter.println("UiBinder<%s, %s> BINDER = GWT.create(Binder.class);", this.widgetType.getSimpleSourceName(),
			this.targetType.getSimpleSourceName());
		srcWriter.outdent();
		srcWriter.println("}");
		srcWriter.println();
		srcWriter.println("@Override");
		srcWriter
			.println("public %s createAndBindUi(%s owner) {", this.widgetType.getSimpleSourceName(), this.targetType
				.getSimpleSourceName());
		srcWriter.indent();
		srcWriter.println("return Binder.BINDER.createAndBindUi(owner);");
		srcWriter.outdent();
		srcWriter.println("}");
	}
 
Example 3
Source File: ServiceBinderCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void writeCommandDefinition(TreeLogger logger, SourceWriter srcWriter, JMethod method,
	JParameter callbackParameter) throws UnableToCompleteException {
	srcWriter.print("CommandDefinition commandDefinition  = new CommandDefinition(");
	srcWriter.print("\"%s\", ", this.serviceType.getQualifiedSourceName());
	srcWriter.print("\"%s\", ", method.getName());
	if (callbackParameter != null) {
		JParameterizedType parameterizedCallback = callbackParameter.getType().isParameterized();
		if (parameterizedCallback != null) {
			srcWriter.print("\"%s\" ", parameterizedCallback.getTypeArgs()[0].getQualifiedSourceName());
		} else {
			logger.branch(TreeLogger.ERROR, "Callback argument type for method " + method.getName()
				+ " is not parametrized", null);
			throw new UnableToCompleteException();
		}

	} else {
		srcWriter.print("\"%s\" ", method.getReturnType().getQualifiedSourceName());
	}
	for (JParameter parameter : method.getParameters()) {
		if (!parameter.equals(callbackParameter)) {
			srcWriter.print(", \"%s\"", parameter.getType().getQualifiedSourceName());
		}
	}
	srcWriter.println(");");
}
 
Example 4
Source File: JsonGwtJacksonGenerator.java    From requestor with Apache License 2.0 5 votes vote down vote up
private void generateConstructor(SourceWriter srcWriter, ArrayList<String> serdes) {
    srcWriter.println("public GeneratedJsonSerdesImpl() {");
    for (String s : serdes) {
        srcWriter.println("    serdesList.add(%s);", s);
    }
    srcWriter.println("}");
    srcWriter.println();
}
 
Example 5
Source File: ApplicationMetaDataGenerator.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void generateFields(SourceWriter sourceWriter) {
    sourceWriter.println("private static Map<Class<?>, List<PropertyBinding>> registry = new HashMap<Class<?>,List<PropertyBinding>>();");
    sourceWriter.println("private static Map<Class<?>, AddressBinding> addressing= new HashMap<Class<?>, AddressBinding>();");
    sourceWriter.println("private static Map<Class<?>, Mutator> mutators = new HashMap<Class<?>, Mutator>();");
    sourceWriter.println("private static Map<Class<?>, EntityFactory> factories = new HashMap<Class<?>, EntityFactory>();");
    sourceWriter.println("private static "+BEAN_FACTORY_NAME+" beanFactory = com.google.gwt.core.client.GWT.create("+BEAN_FACTORY_NAME+".class);");
}
 
Example 6
Source File: InjectPresenterCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void writePresent(SourceWriter srcWriter) {
	for (JMethod presenterMethod : this.presenterMethods) {
		if (presenterMethod.getParameters().length == 0) {
			srcWriter.println("super.%s();", presenterMethod.getName());
		} else if (presenterMethod.getParameters().length > 0) {
			JType placeType = presenterMethod.getParameters()[0].getType();
			srcWriter.println("if(place instanceof %s){", placeType.getSimpleSourceName());
			srcWriter.indent();
			srcWriter.println("super.%s((%s) place);", presenterMethod.getName(), placeType.getSimpleSourceName());
			srcWriter.outdent();
			srcWriter.println("}");
		}
	}
}
 
Example 7
Source File: AbstractInjectorCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void writeConstructor(TreeLogger logger, GeneratorContext context, SourceWriter srcWriter) {
	srcWriter.println("public %s() {", this.proxyName);
	srcWriter.indent();
	for (InjectorWritterConstructor delegate : Iterables.filter(this.delegates, InjectorWritterConstructor.class)) {
		delegate.writeConstructor(srcWriter);
	}
	srcWriter.outdent();
	srcWriter.println("}");
}
 
Example 8
Source File: UiBinderLocalizedCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String create(TreeLogger logger, GeneratorContext context) {
	Resource templateResource = this.getTemplateResource(context);
	if (templateResource == null) {
		throw new NullPointerException("no template found");
	}
	this.binderProxySimpleName =
		this.targetType.getSimpleSourceName() + "_" + this.binderType.getSimpleSourceName()
			+ UiBinderLocalizedCreator.PROXY_SUFFIX;
	if (this.locale != null) {
		this.binderProxySimpleName += "_" + this.locale.toString();
	}
	this.binderProxyQualifiedName = this.targetType.getPackage().getName() + "." + this.binderProxySimpleName;

	PrintWriter printWriter = this.getPrintWriter(logger, context, this.binderProxyQualifiedName);
	if (printWriter == null) {
		return this.binderProxyQualifiedName;
	}

	SourceWriter srcWriter = this.getSourceWriter(printWriter, context);

	srcWriter.println();
	srcWriter.indent();
	this.generateProxy(logger, srcWriter);
	srcWriter.println();
	srcWriter.outdent();

	srcWriter.commit(logger);

	return this.binderProxyQualifiedName;
}
 
Example 9
Source File: TextBinderGenerator.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Generate method bind
 */
private void composeBindMethod(TreeLogger logger, SourceWriter sourceWriter) {

	logger.log(TreeLogger.INFO, "");
	String line = "public void bind("
			+ parameterizedType1.getQualifiedSourceName() + " text, "
			+ parameterizedType2.getQualifiedSourceName() + " obj){";
	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

	line = "  System.out.println(\"Implement it now:)\");";
	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

	ArrayList<JField> fields = new ArrayList<JField>();

	JClassType curtype = parameterizedType2;
	do {

		for (JField filed : curtype.getFields()) {
			fields.add(filed);
		}
		curtype = curtype.getSuperclass();
	} while (!curtype.getName().equals("Object"));

	for (JField field : fields) {
		String name = field.getName();
		String Name = name.substring(0, 1).toUpperCase() + name.substring(1);
		line = " text.setText(\"" + name + "\", obj.get" + Name
				+ "().toString() );";
		sourceWriter.println(line);
		logger.log(TreeLogger.INFO, line);

	}
	line = "}";

	sourceWriter.println(line);
	logger.log(TreeLogger.INFO, line);

}
 
Example 10
Source File: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void generateProxyResult(TreeLogger logger, SourceWriter srcWriter) {
	if (this.viewDecoratorClass == null) {
		srcWriter.println("callback.showView(view);");
	} else {
		String decoratorName = this.viewDecoratorClass.getSimpleName();
		srcWriter.println("%s decorator = %s.get();", decoratorName, decoratorName);
		srcWriter.println("decorator.setView(view);");
		srcWriter.println("callback.showView(decorator);");
	}
}
 
Example 11
Source File: JsonAutoBeanGenerator.java    From requestor with Apache License 2.0 5 votes vote down vote up
private void generateMethods(SourceWriter srcWriter) {
    srcWriter.println("@Override");
    srcWriter.println("public List<Serdes<?>> getSerdes() {");
    srcWriter.println("    return serdesList;");
    srcWriter.println("}");
    srcWriter.println();
    srcWriter.println("@Override");
    srcWriter.println("public List<Provider<?>> getProviders() {");
    srcWriter.println("    return providersList;");
    srcWriter.println("}");
    srcWriter.println();
}
 
Example 12
Source File: InjectDecoratorPresenterCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void writeMethods(SourceWriter srcWriter) {
	srcWriter.println("public void presentDecoratedView(Place place) {");
	srcWriter.indent();
	srcWriter.println("if (view instanceof Presenter) {");
	srcWriter.indent();
	srcWriter.println("Presenter presenter = (Presenter) view;");
	srcWriter.println("presenter.present(place, this);");
	srcWriter.outdent();
	srcWriter.println("}");
	srcWriter.outdent();
	srcWriter.println("}");
}
 
Example 13
Source File: ProxyViewCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void generateDelegateTokenizer(TreeLogger logger, SourceWriter srcWriter) {
	srcWriter.println("@Override");
	srcWriter.println("public %s getPlace(String token) {", this.placeType.getSimpleSourceName());
	srcWriter.indent();
	srcWriter.println("return new %s().getPlace(token);", this.placeTokenizerClass.getSimpleName());
	srcWriter.outdent();
	srcWriter.println("}");
	srcWriter.println("@Override");
	srcWriter.println("public String getToken(%s place) {", this.placeType.getSimpleSourceName());
	srcWriter.indent();
	srcWriter.println("return new %s().getToken(place);", this.placeTokenizerClass.getSimpleName());
	srcWriter.outdent();
	srcWriter.println("}");
}
 
Example 14
Source File: JsonAutoBeanGenerator.java    From requestor with Apache License 2.0 5 votes vote down vote up
private void generateFactoryInterface(SourceWriter w, Iterable<String> typeNames) {
    w.println("interface %s extends AutoBeanFactory {", factoryTypeName);
    for (String typeName : typeNames) {
        w.println("    AutoBean<%s> %s();", typeName, replaceDotByUpperCase(firstCharToLowerCase(typeName)));
    }
    w.println("}");
}
 
Example 15
Source File: ModelCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void appendNullValidator(SourceWriter w, JField field) {
	Null nullAnnotation = field.getAnnotation(Null.class);
	if (nullAnnotation != null) {
		w.println(", new NullValidator(\"%s\")", nullAnnotation.message());
	}
}
 
Example 16
Source File: InjectResourceCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void writeConstructor(SourceWriter srcWriter) {
	srcWriter.println("%s = GWT.create(%s.class);",
		this.resourceField.getName(), this.resourceField.getType().getQualifiedSourceName());
}
 
Example 17
Source File: JsonAutoBeanGenerator.java    From requestor with Apache License 2.0 4 votes vote down vote up
private void generateFields(SourceWriter srcWriter) {
    // Initialize a field with binary name of the remote service interface
    srcWriter.println("private final ArrayList<Serdes<?>> serdesList = new ArrayList<Serdes<?>>();");
    srcWriter.println("private final ArrayList<Provider<?>> providersList = new ArrayList<Provider<?>>();");
    srcWriter.println();
}
 
Example 18
Source File: ModelCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void appendFutureValidator(SourceWriter w, JField field) {
	Future futureAnnotation = field.getAnnotation(Future.class);
	if (futureAnnotation != null) {
		w.println(", new FutureValidator(\"%s\")", futureAnnotation.message());
	}
}
 
Example 19
Source File: ModelCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void appendFalseValidator(SourceWriter w, JField field) {
	AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class);
	if (falseAnnotation != null) {
		w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message());
	}
}
 
Example 20
Source File: InjectDecoratorPresenterCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void writePresent(SourceWriter srcWriter) {
	srcWriter.println("presentDecoratedView(place);");
}