List of usage examples for com.google.gwt.user.rebind SourceWriter println
void println(String s);
From source file:com.gwtplatform.mvp.rebind.ProviderBundleGenerator.java
License:Apache License
private void writeStaticFields(SourceWriter sourceWriter, List<JClassType> presenters) { int i = 0;/*w ww . j a v a2 s.c om*/ for (JClassType presenter : presenters) { sourceWriter .println(String.format(PUBLIC_STATIC_INT, presenter.getSimpleSourceName().toUpperCase(), i)); sourceWriter.println(); i++; } }
From source file:com.gwtplatform.mvp.rebind.ProxyEventMethod.java
License:Apache License
/** * Writes the call required to ensure the proxy handles this event. * * @param writer The {@link SourceWriter}. *///w w w. j a v a2 s . com public void writeAddHandler(SourceWriter writer) { writer.println("getEventBus().addHandler( " + eventTypeName + ".getType(), this );"); }
From source file:com.gwtplatform.mvp.rebind.ProxyEventMethod.java
License:Apache License
/** * Writes the definition of the method responsible of handling this event. * * @param writer The {@link SourceWriter}. */// w w w. ja va 2 s. c o m public void writeHandlerMethod(SourceWriter writer) { writer.println(""); writer.println("@Override"); writer.println("public final void " + handlerMethodName + "( final " + eventTypeName + " event ) {"); writer.indent(); writer.println("getPresenter( new NotifyingAsyncCallback<" + presenterInspector.getPresenterClassName() + ">(getEventBus()) {"); writer.indent(); writer.println("@Override"); writer.println("public void success(final " + presenterInspector.getPresenterClassName() + " presenter) {"); writer.indent(); writer.println("Scheduler.get().scheduleDeferred( new Command() {"); writer.indent(); writer.println("@Override"); writer.println("public void execute() {"); writer.indent(); writer.println("presenter." + functionName + "( event );"); writer.outdent(); writer.println("}"); writer.outdent(); writer.println("} );"); writer.outdent(); writer.println("}"); writer.outdent(); writer.println("} );"); writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.ProxyOutputterBase.java
License:Apache License
/** * Writes a local ginjector variable to the source writer. *//* w w w .j ava2s. co m*/ private void writeGinjectorAssignation(SourceWriter writer, String ginjectorClassName) { writer.println("ginjector = (" + ginjectorClassName + ")baseGinjector;"); }
From source file:com.gwtplatform.mvp.rebind.ProxyPlaceOutputter.java
License:Apache License
public void endWrappedProxy(SourceWriter writer) { writer.outdent(); writer.println("}"); }
From source file:com.gwtplatform.mvp.rebind.ProxyPlaceOutputter.java
License:Apache License
@Override void writeSubclassDelayedBind(SourceWriter writer) { writer.println(WRAPPED_CLASS_NAME + " wrappedProxy = GWT.create(" + WRAPPED_CLASS_NAME + ".class);"); writer.println("wrappedProxy.delayedBind( ginjector ); "); writer.println("setProxy(wrappedProxy); "); writer.println("String[] nameToken = " + createInitNameTokens() + "; "); writer.println("String[] gatekeeperParams = " + getGatekeeperParamsString() + ";"); writer.println("setPlace(" + getPlaceInstantiationString() + ");"); }
From source file:com.intrinsarc.backbone.gwt.generators.StateDispatcherGenerator.java
License:Apache License
protected void writeToStringMethod(TreeLogger logger, String proxyClassName, JClassType T, SourceWriter writer) { writer.println( "private java.util.List<IEvent> dDispatch_IEventRequired = new java.util.ArrayList<IEvent>();"); writer.println(/*from www . ja va 2 s.co m*/ "public void setDDispatch(IEvent event, int index) { PortHelper.fill(this.dDispatch_IEventRequired, event, index); }"); writer.println( "public void addDDispatch(IEvent event) { PortHelper.fill(this.dDispatch_IEventRequired, event, -1); }"); writer.println( "public void removeDDispatch(IEvent event) { PortHelper.remove(this.dDispatch_IEventRequired, event); }"); writer.println("private ITerminal dStart_ITerminalRequired;"); writer.println("public void setDStart(ITerminal start) { dStart_ITerminalRequired = start; }"); writer.println( "private java.util.List<ITerminal> dEnd_ITerminalRequired = new java.util.ArrayList<ITerminal>();"); writer.println( "public void setDEnd(ITerminal end, int index) { PortHelper.fill(this.dEnd_ITerminalRequired, end, index); }"); writer.println("private boolean currentEntered;"); writer.println("private IEvent current;"); writer.println("private boolean primed;"); writer.println(" private void findNextState()"); writer.println(" {"); writer.println(" // possibly still in start or end?"); writer.println(" if (dStart_ITerminalRequired != null && !primed)"); writer.println(" {"); writer.println(" dStart_ITerminalRequired.moveToNextState(); primed = true;"); writer.println(" }"); writer.println(" if (dEnd_ITerminalRequired != null)"); writer.println(" for (ITerminal end : dEnd_ITerminalRequired)"); writer.println(" if (end.isCurrent())"); writer.println(" end.moveToNextState();"); writer.println(" // find the next state"); writer.println(" current = null;"); writer.println(" for (IEvent e : dDispatch_IEventRequired)"); writer.println(" if (e.isCurrent())"); writer.println(" {"); writer.println(" current = e;"); writer.println(" break;"); writer.println(" }"); writer.println(" }"); writer.println(); writer.println("public IEvent getDEvents_Provided(Class<?> required)"); writer.println("{"); writer.println(" return new " + T.getQualifiedSourceName() + "()"); writer.println(" {"); Set<JMethod> all = new LinkedHashSet<JMethod>(); getAllMethods(all, T); for (JMethod method : all) { String ret = method.getReturnType().getQualifiedBinaryName(); boolean isVoid = ret.equals("void"); writer.print(" public " + ret + " " + method.getName() + "("); int lp = 0; String params = ""; String cparams = ""; for (JParameter p : method.getParameters()) { if (lp != 0) { params += ", "; cparams += ", "; } lp++; params += p.getType().getQualifiedBinaryName() + " param" + lp; cparams += " param" + lp; } writer.println(params + ")"); writer.println(" {"); writer.println(" findNextState();"); writer.println(" if (current != null)"); writer.println(" {"); String cast = "(" + T.getQualifiedSourceName() + ")"; if (!isVoid) { writer.println( " " + ret + " v = (" + cast + "current)." + method.getName() + "(" + cparams + ");"); writer.println(" findNextState();"); writer.println(" return v;"); writer.println(" }"); if (ret.equals("boolean")) writer.println(" return false;"); else if (ret.equals("int") || ret.equals("short") || ret.equals("long") || ret.equals("float") || ret.equals("double") || ret.equals("byte") || ret.equals("char")) writer.println(" return 0;"); else if (ret.equals("long")) writer.println(" return 0;"); else writer.println(" return null;"); } else { writer.println(" (" + cast + "current)." + method.getName() + "(" + cparams + ");"); writer.println(" findNextState();"); writer.println(" }"); } writer.println(" }"); } writer.println("\n public String toString() { return \"State dispatcher: current state =\" + current; }"); writer.println(" };\n"); writer.println("}\n"); }
From source file:com.intrinsarc.backbone.gwt.generators.TerminalGenerator.java
License:Apache License
protected void writeToStringMethod(TreeLogger logger, String proxyClassName, JClassType T, SourceWriter writer) { writer.println("private ITransition out_ITransitionRequired;"); writer.println("public void setOut(ITransition out) { out_ITransitionRequired = out; }"); writer.println("private boolean current;"); writer.println();//from www. j av a2s. c om writer.println("public boolean isCurrent() { return current; }"); writer.println( "public void moveToNextState() { if (out_ITransitionRequired != null) current = !out_ITransitionRequired.enter(); }"); writer.println(""); writer.println("public ITransition getIn(Class<?> required)"); writer.println("{"); writer.println(" return new ITransition()"); writer.println(" {"); writer.println(" public boolean enter()"); writer.println(" {"); writer.println(" current = true;"); writer.println(" return true;"); writer.println(" }"); writer.println(" };"); writer.println("};"); }
From source file:com.jawspeak.gwt.verysimpletemplate.rebind.VerySimpleGwtTemplateGenerator.java
License:Apache License
private void generateClass(TreeLogger logger, GeneratorContext context) throws SecurityException, ClassNotFoundException, IOException, CouldNotParseTemplateException { PrintWriter printWriter = context.tryCreate(logger, packageName, generatedClassName); if (printWriter == null) { return; // null means the source code was already generated }/*from w w w .j a v a2 s . c o m*/ ClassSourceFileComposerFactory composer = new ClassSourceFileComposerFactory(packageName, generatedClassName); composer.addImplementedInterface(typeName); SourceWriter sourceWriter = composer.createSourceWriter(context, printWriter); generateMethodsForEachHtmlTemplate(logger, sourceWriter); sourceWriter.println("}"); context.commit(logger, printWriter); }
From source file:com.jawspeak.gwt.verysimpletemplate.rebind.VerySimpleGwtTemplateGenerator.java
License:Apache License
private void generateMethodsForEachHtmlTemplate(TreeLogger logger, SourceWriter sourceWriter) throws SecurityException, ClassNotFoundException, IOException, CouldNotParseTemplateException { String folderPrefix = packageName.replace(".", "/"); for (Method method : Class.forName(typeName).getMethods()) { String methodName = method.getName(); if (!methodName.startsWith("get")) { break; }//w ww.ja v a 2s . c o m String path = folderPrefix + "/" + methodName.substring(3) + ".html"; String template = Utility.getFileFromClassPath(path); String parameters = getParameters(method); sourceWriter.println("public VerySimpleGwtTemplate " + methodName + "(" + parameters + ") {"); sourceWriter.indent(); sourceWriter.println("VerySimpleGwtTemplate template = new VerySimpleGwtTemplate(\"" + Generator.escape(template) + "\");"); for (Map.Entry<String, String> entry : getTemplateReplaceables(template).entrySet()) { // TODO(jwolter): look for the getter method, and throw an exception if it doesn't exist // TODO(jwolter): look at the getter's return type, and do nice null checking then "" + or call toString() // TODO(jwolter): allow an arbitrary way to "pipe" subsequent options to the setter, so that you can for a date i.e. call a date formatter on it. // TODO(jwolter): basically look at the features of FreeMarker, and see how to integrate the best ones in here. Or adopt to FreemarkerGWT. // as for now, we simply turn each value into a String by prepending a "" + to the value. // also for the time being, remember you can have a $${token} that will not get replaced, so you can set it manually. So, // you should only have ${token}'s that you are comfortable getting them set literally as Strings. sourceWriter .println("template.set(\"" + entry.getKey() + "\", " + "\"\" + " + entry.getValue() + ");"); } sourceWriter.println("return template;"); sourceWriter.outdent(); sourceWriter.println("}"); } sourceWriter.outdent(); }