From 17d467c13f8efe0b5d851b0493ead9df124f84cf Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 25 Feb 2019 17:51:59 +0200 Subject: [PATCH] Added proper equals() implementations for validation compilation request Fix to use of old value from cache while validating derived properties. gitlab #252 Change-Id: I2adf76401dac90ddecc0bf2b3c222da6e242c2d2 --- .../DerivedPropertiesSection.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java index 0f7bff396..5f96c2ba9 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/componentTypeEditor/DerivedPropertiesSection.java @@ -330,12 +330,7 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { SCLContext sclContext = SCLContext.getCurrent(); Object oldGraph = sclContext.get("graph"); try { - CompileSCLMonitorRequest compileSCLMonitorRequest = new CompileSCLMonitorRequest(graph, context) { - @Override - protected String getExpressionText(ReadGraph graph) throws DatabaseException { - return expression; - } - }; + CompileSCLMonitorRequest compileSCLMonitorRequest = new ValidationCompilationRequest(graph, context, expression); Function1 exp = graph.syncRequest(compileSCLMonitorRequest); sclContext.put("graph", graph); //return exp.apply(context.getParent(graph)); @@ -422,4 +417,29 @@ public class DerivedPropertiesSection implements ComponentTypeViewerSection { return 100.0; } + private static final class ValidationCompilationRequest extends CompileSCLMonitorRequest { + private final String expression; + + private ValidationCompilationRequest(ReadGraph graph, Variable context, String expression) + throws DatabaseException { + super(graph, context); + this.expression = expression; + } + + @Override + protected String getExpressionText(ReadGraph graph) throws DatabaseException { + return expression; + } + + @Override + public int hashCode() { + return super.hashCode() + 37 * expression.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return super.equals(obj) && ((ValidationCompilationRequest)obj).expression.equals(expression); + } + } + } \ No newline at end of file -- 2.43.2