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=ebaa5fc0a30d5151cbdb206f560b9aaae617d0be;hb=68ce0966a57f5153b133c6283fdbae10f683b745;hp=9c62924153681a788159cb40c0420468bc415387;hpb=7fe2a02ad295ec7406f44e8f86b7d25deedceb8b;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 9c6292415..ebaa5fc0a 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 @@ -25,7 +25,7 @@ import org.simantics.db.Statement; import org.simantics.db.WriteGraph; import org.simantics.db.common.primitiverequest.Adapter; import org.simantics.db.common.procedure.adapter.TransientCacheListener; -import org.simantics.db.common.request.UnaryRead; +import org.simantics.db.common.request.BinaryRead; import org.simantics.db.common.request.UniqueRead; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.common.utils.Logger; @@ -583,6 +583,7 @@ public class Functions { } } + @Deprecated public static AbstractEventHandler emptyOnClick(ReadGraph graph) throws DatabaseException { return new EventHandler() { @Override @@ -592,6 +593,7 @@ public class Functions { }; } + @Deprecated public static AbstractEventHandler writeEventHandler(ReadGraph graph, final Variable variable, final Function fn) { final Session session = graph.getSession(); @@ -624,15 +626,11 @@ public class Functions { return (String)response; } return null; - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } - return null; - } }); @@ -649,6 +647,7 @@ public class Functions { }; } + @Deprecated public static AbstractEventHandler readEventHandler(ReadGraph graph, final Variable variable, final Function fn) { final Session session = graph.getSession(); @@ -681,15 +680,11 @@ public class Functions { return (String)response; } return null; - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } - return null; - } }); @@ -706,6 +701,7 @@ public class Functions { }; } + @Deprecated public static AbstractEventHandler readEventHandler2(ReadGraph graph, final Function fn) { final Session session = graph.getSession(); @@ -732,15 +728,11 @@ public class Functions { return (CommandResult)response; } return null; - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } - return null; - } }); @@ -764,12 +756,12 @@ public class Functions { final List effects = ServerSCLHandlerValueRequest.getEffects(graph, anyFunction); - final Function1 fn = anyFunction.getValue(graph); - String expression = anyFunction.getPropertyValue(graph, "expression"); + Function1 fn = anyFunction.getValue(graph); + //String expression = anyFunction.getPropertyValue(graph, "expression"); final Session session = graph.getSession(); - return new AbstractResponseHandler(expression) { + return new AbstractResponseHandler(fn) { private String formatError(RequestProcessor proc, Throwable t) { @@ -830,10 +822,7 @@ public class Functions { Object oldGraph = sclContext.put("graph", graph); Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer); try { - Object response = fn.apply(parameters); - return response; - } catch (Throwable t) { - return new org.simantics.document.server.serverResponse.Error(formatError(graph, t)); + return fn.apply(parameters); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); @@ -854,10 +843,7 @@ public class Functions { Object oldPrinter = sclContext.put(SCLReportingHandler.REPORTING_HANDLER, printer); try { - Object response = fn.apply(parameters); - return response; - } catch (Throwable t) { - return new org.simantics.document.server.serverResponse.Error(formatError(graph, t)); + return fn.apply(parameters); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); @@ -899,6 +885,7 @@ public class Functions { }; } + @Deprecated public static AbstractEventHandler writeEventHandler2(ReadGraph graph, final Function fn) { final Session session = graph.getSession(); @@ -925,15 +912,11 @@ public class Functions { return (CommandResult)response; } return null; - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put("graph", oldGraph); sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } - return null; - } }); @@ -950,6 +933,8 @@ public class Functions { }; } + + @Deprecated public static AbstractEventHandler eventHandler2(ReadGraph graph, final Function fn) { return new AbstractEventHandler() { @@ -969,14 +954,10 @@ public class Functions { return (CommandResult)response; } return null; - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } - return null; - } catch (Throwable e) { Logger.defaultLogError(e); return new org.simantics.document.server.serverResponse.Error(e.getMessage()); @@ -987,6 +968,7 @@ public class Functions { }; } + @Deprecated public static AbstractEventHandler eventHandler(ReadGraph graph, final Function fn) { return new AbstractEventHandler() { @@ -1013,8 +995,6 @@ public class Functions { if(response instanceof String) { result = (String)response; } - } catch (Throwable t) { - t.printStackTrace(); } finally { sclContext.put(SCLReportingHandler.REPORTING_HANDLER, oldPrinter); } @@ -1276,11 +1256,11 @@ public class Functions { return true; } } else { - Variable parentCp = graph.sync(new UnaryRead(conn) { + Variable parentCp = graph.sync(new BinaryRead(widget, conn) { @Override public Variable perform(ReadGraph graph) throws DatabaseException { DocumentationResource DOC = DocumentationResource.getInstance(graph); - Collection descs = parameter.getConnectionPointDescriptors(graph, null); + Collection descs = parameter2.getConnectionPointDescriptors(graph, parameter, null); for(VariableConnectionPointDescriptor desc : descs) { if (DOC.Relations_partN.equals(desc.getConnectionPointResource(graph))) { @@ -1332,5 +1312,33 @@ public class Functions { LOGGER.debug("", e); return e.getMessage(); } + + static class StandardDocumentProperties implements DocumentProperties { + + @Override + public Collection getKeys(ReadGraph graph, Variable context) throws DatabaseException { + + DocumentationResource DOC = DocumentationResource.getInstance(graph); + StandardGraphPropertyVariable asd = new StandardGraphPropertyVariable(graph, context, DOC.Properties_primitiveProperties); + Map ps = primitiveProperties.getVariables(graph, asd, null); + return ps.keySet(); + + } + + @Override + public Object getValue(ReadGraph graph, Variable context, String key) throws DatabaseException { + + DocumentationResource DOC = DocumentationResource.getInstance(graph); + StandardGraphPropertyVariable asd = new StandardGraphPropertyVariable(graph, context, DOC.Properties_primitiveProperties); + Map ps = primitiveProperties.getVariables(graph, asd, null); + return ps.get(key).getValue(graph); + + } + + } + + public static DocumentProperties primitiveProperties() throws DatabaseException { + return new StandardDocumentProperties(); + } } \ No newline at end of file