X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2FFunctions.java;h=d0ec54557353555349b5e66f222002b8c86f15ed;hb=fc2c84b45f73743c48cd525e85355362444d67a5;hp=25bec0c919248d5efc14c54d921f3b3f5ea5fbba;hpb=efec7759cf9f153cf368f2ece6fed67f0d1632b1;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java index 25bec0c91..d0ec54557 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/Functions.java @@ -51,6 +51,7 @@ import org.simantics.document.server.io.CommandContext; import org.simantics.document.server.io.CommandContextImpl; import org.simantics.document.server.io.CommandContextMutable; import org.simantics.document.server.io.CommandResult; +import org.simantics.document.server.io.IConsole; import org.simantics.document.server.request.ServerSCLHandlerValueRequest; import org.simantics.document.server.request.ServerSCLValueRequest; import org.simantics.document.server.serverResponse.ServerResponse; @@ -674,7 +675,9 @@ public class Functions { @Override public CommandResult handle(final CommandContext parameters) { - final SCLReportingHandler printer = (SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER); + IConsole console = parameters.getValue("__console__"); + SCLReportingHandler printer = (console != null) ? new ConsoleSCLReportingHandler(console) + : (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER); try { @@ -727,7 +730,15 @@ public class Functions { }); } else { - result = fn.apply(parameters); + + SCLContext sclContext = SCLContext.getCurrent(); + Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer); + try { + result = fn.apply(parameters); + } finally { + sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); + } + } if (result instanceof org.simantics.document.server.serverResponse.Error) { @@ -970,9 +981,7 @@ public class Functions { } public static String printContext(CommandContext context) { - String str = context.toString(); - System.err.println(str); - return str; + return context.toString(); } @SCLValue(type = "AbstractEventHandler") @@ -1164,4 +1173,5 @@ public class Functions { return graph.syncRequest(new PathExistsRequest(context)); } + } \ No newline at end of file