List of usage examples for com.google.gwt.user.rebind SourceWriter outdent
void outdent();
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter// ww w . ja v a 2s . c om * @param asyncMethod * @param asyncReturnType * @param parameters * @throws UnableToCompleteException */ private void generateProxyWrapperMethodCall(SourceWriter srcWriter, JMethod syncMethod, JMethod asyncMethod, JType asyncReturnType, List<JParameter> parameters) throws UnableToCompleteException { if (asyncReturnType != JPrimitiveType.VOID) { logger.log(TreeLogger.ERROR, "UseSynchronizer Token only can be used with void return type on Async interface."); throw new UnableToCompleteException(); } UseSynchronizerToken synchronizerTokenAnnot = syncMethod.getAnnotation(UseSynchronizerToken.class); boolean blocksScreen = synchronizerTokenAnnot.blocksUserInteraction(); JParameter parameter = parameters.get(parameters.size() - 1); srcWriter.println("final String methodDesc = \"" + JClassUtils.getMethodDescription(syncMethod) + "\";"); srcWriter.println("if (__startMethodCall(methodDesc, " + blocksScreen + ")){"); srcWriter.indent(); srcWriter.println("__syncTokenService.getSynchronizerToken(methodDesc,"); srcWriter.println("new AsyncCallback<String>(){"); srcWriter.indent(); srcWriter.println("public void onSuccess(String result){"); srcWriter.indent(); srcWriter.println("__updateMethodToken(methodDesc, result);"); generateProxyMethodCall(srcWriter, asyncMethod, parameters, "methodDesc", blocksScreen); srcWriter.outdent(); srcWriter.println("}"); srcWriter.println("public void onFailure(Throwable caught){"); srcWriter.indent(); srcWriter.println("try{"); srcWriter.println(parameter.getName() + ".onFailure(caught);"); srcWriter.println("}finally{"); srcWriter.println("__endMethodCall(methodDesc, " + blocksScreen + ");"); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("});"); srcWriter.outdent(); srcWriter.println("}"); if (synchronizerTokenAnnot.notifyCallsWhenProcessing()) { srcWriter.println("else{"); srcWriter.indent(); String sensitiveErrMsg = Crux.class.getName() + ".getMessages().methodIsAlreadyBeingProcessed()"; srcWriter.println(Crux.class.getName() + ".getErrorHandler().handleError(" + sensitiveErrMsg + ", new " + SensitiveMethodAlreadyBeingProcessedException.class.getName() + "(" + sensitiveErrMsg + ")" + ");"); srcWriter.outdent(); srcWriter.println("}"); } }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter/*w w w . j a v a2 s . c om*/ */ private void generateProxyWrapperStartMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("private boolean __startMethodCall(String methodDesc, boolean blocksScreen){"); srcWriter.indent(); srcWriter.println("boolean ret = !__syncProcessingMethods.containsKey(methodDesc);"); srcWriter.println("if (ret){"); srcWriter.indent(); srcWriter.println("__syncProcessingMethods.put(methodDesc, true);"); srcWriter.println("if (blocksScreen) Screen.blockToUser();"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.println("return ret;"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter/*from w ww. ja va2s.c o m*/ */ private void generateProxyWrapperUpdateTokenMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("private void __updateMethodToken(String methodDesc, String token){"); srcWriter.indent(); srcWriter.println("__syncProcessingMethods.put(methodDesc, false);"); srcWriter.println("if (this.__hasParameters){"); srcWriter.indent(); srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"&" + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);"); srcWriter.outdent(); srcWriter.println("}else{"); srcWriter.indent(); srcWriter.println("super.setServiceEntryPoint(__baseEntrypoint + \"?" + CruxSynchronizerTokenService.CRUX_SYNC_TOKEN_PARAM + "=\" + token);"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter/*w ww . j a va2s .co m*/ */ private void generateSetServiceEntryPointMethod(SourceWriter srcWriter) { srcWriter.println(); srcWriter.println("public void setServiceEntryPoint(String entryPoint){"); srcWriter.indent(); srcWriter.println("__baseEntrypoint = entryPoint;"); srcWriter.println("super.setServiceEntryPoint(entryPoint);"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.core.rebind.rpc.CruxProxyCreator.java
License:Apache License
/** * @param srcWriter// w w w .j a v a 2s. c om */ private void generateWrapperProxyContructor(SourceWriter srcWriter) { srcWriter.println("public " + getProxyWrapperSimpleName() + "() {"); srcWriter.indent(); srcWriter.println("super();"); srcWriter.println( "this.__hasParameters = (getServiceEntryPoint()!=null?getServiceEntryPoint().indexOf('?')>0:false);"); if (this.hasSyncTokenMethod) { srcWriter.println("this.__baseEntrypoint = getServiceEntryPoint();"); srcWriter.println( "this.__syncTokenService = (CruxSynchronizerTokenServiceAsync)GWT.create(CruxSynchronizerTokenService.class);"); } srcWriter.println("String locale = Screen.getLocale();"); srcWriter.println("if (locale != null && locale.trim().length() > 0){"); srcWriter.indent(); srcWriter.println("if (this.__hasParameters){"); srcWriter.indent(); srcWriter.println("setServiceEntryPoint(getServiceEntryPoint() + \"&locale=\" + locale);"); srcWriter.outdent(); srcWriter.println("}else{"); srcWriter.indent(); srcWriter.println("setServiceEntryPoint(getServiceEntryPoint() + \"?locale=\" + locale);"); srcWriter.println("this.__hasParameters = true;"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); srcWriter.outdent(); srcWriter.println("}"); }
From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java
License:Apache License
/** * Create a custom font-resource to inject at a stylesheet * @param logger// w ww.j a v a2 s.co m * @param context * @param method */ @Override public String createAssignment(TreeLogger logger, ResourceContext context, JMethod method) throws UnableToCompleteException { SourceWriter sw = new StringSourceWriter(); sw.print("new "); sw.print(method.getReturnType().getQualifiedSourceName()); sw.println("() {"); sw.indent(); writeGetFontName(method, sw); writeGetName(method, sw); writeEnsureInjected(sw); writeGetText(logger, context, method, sw); sw.outdent(); sw.println("}"); return sw.toString(); }
From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java
License:Apache License
private void writeGetFontName(JMethod method, SourceWriter sw) { sw.println("public String getFontName() {"); sw.indent();/*w w w .j a va2s .com*/ sw.print("return \""); sw.print(getFontName(method)); sw.println("\";"); sw.outdent(); sw.println("}"); }
From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java
License:Apache License
protected void writeEnsureInjected(SourceWriter sw) { sw.println("private boolean injected;"); sw.println("public boolean ensureInjected() {"); sw.indent();// w ww . j ava 2 s .co m sw.println("if (!injected) {"); sw.indentln("injected = true;"); sw.indentln(StyleInjector.class.getName() + ".inject(getText());"); sw.indentln("return true;"); sw.println("}"); sw.println("return false;"); sw.outdent(); sw.println("}"); }
From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java
License:Apache License
private void writeGetName(JMethod method, SourceWriter sw) { sw.println("public String getName() {"); sw.indent();/*w ww.j ava 2 s. co m*/ sw.println("return \"" + method.getName() + "\";"); sw.outdent(); sw.println("}"); }
From source file:org.cruxframework.crux.plugin.bootstrap.rebind.font.FontResourceGenerator.java
License:Apache License
private void writeGetText(TreeLogger logger, ResourceContext context, JMethod method, SourceWriter sw) throws UnableToCompleteException { sw.println("public String getText() {"); sw.indent();/*www . j a va 2 s .c o m*/ URL[] urls = ResourceGeneratorUtil.findResources(logger, context, method); sw.print("return \""); sw.print("@font-face{"); sw.print("font-family:'"); sw.print(getFontName(method)); sw.print("';"); sw.print("font-style:normal;"); sw.print("font-weight:400;"); try { String agent = context.getGeneratorContext().getPropertyOracle() .getSelectionProperty(logger, "user.agent").getCurrentValue(); if (agent.equals("ie6") || agent.equals("ie8")) writeSrcIE(logger, context, method, sw, urls); else writeSrc(logger, context, method, sw, urls); } catch (BadPropertyValueException e) { throw new UnableToCompleteException(); } sw.print("}"); sw.println("\";"); sw.outdent(); sw.println("}"); }