- ArrayList<JSONObject> result = new ArrayList<JSONObject>(graph.syncRequest(new DocumentRequest(var)));
- Collections.sort(result, new Comparator<JSONObject>() {
+ IConsoleSupport cs = Simantics.getSession().getService(IConsoleSupport.class);
+ Variable root = ProxyVariables.proxyVariableRoot(graph, var);
+ if(root == null) return Collections.emptyList();
+ Variable session = root.getParent(graph);
+ String guid = session.getName(graph);
+ IConsole console = cs.getConsole(guid);
+ SCLReportingHandler printer = (console != null) ? new ConsoleSCLReportingHandler(console)
+ : (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
+ SCLContext sclContext = SCLContext.getCurrent();
+ Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer);