]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Element label is updated when changed in equation view
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 26 Mar 2010 13:17:16 +0000 (13:17 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 26 Mar 2010 13:17:16 +0000 (13:17 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15230 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/TextElement.java

index 97aff786b3cc58c4dba8b71cb8f9743a4026f0e5..4cbde6415604d8b7c3068e810787db97176605dd 100644 (file)
@@ -17,6 +17,10 @@ import java.awt.font.FontRenderContext;
 import java.awt.geom.AffineTransform;\r
 import java.awt.geom.Rectangle2D;\r
 import java.util.List;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.h2d.action.IAction;\r
 import org.simantics.h2d.editor.IDiagramEditor;\r
 import org.simantics.h2d.element.IElement;\r
@@ -30,7 +34,9 @@ import org.simantics.h2d.node.ITextListener;
 import org.simantics.h2d.node.TextNode;\r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.objmap.annotations.UpdateMethod;\r
 import org.simantics.scenegraph.g2d.G2DParentNode;\r
+import org.simantics.sysdyn.SysdynResource;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
 public class TextElement extends RectangularElement implements Movable, Connectable, IEventHandler {\r
@@ -210,23 +216,29 @@ public class TextElement extends RectangularElement implements Movable, Connecta
     }  \r
 \r
     boolean oldHasEquation = false;\r
+\r
     boolean hasEquation = true;\r
-    /*\r
-    boolean hasEquation = false;\r
+    String oldLabel = label;\r
 \r
     @UpdateMethod\r
-    boolean readHasExpression(ReadGraph g, Resource resource) {\r
-        SysdynResource sr = SysdynResource.getInstance(g);\r
-        try {\r
-            hasEquation = \r
-                !g.getObjects(resource, sr.HasExpression).isEmpty();\r
-            if(oldHasEquation != hasEquation) \r
-                update();            \r
-        } catch (DatabaseException e) {\r
-            // TODO Auto-generated catch block\r
-            e.printStackTrace();\r
-        }       \r
+    boolean updateCheck(ReadGraph g, Resource resource) {\r
+//        SysdynResource sr = SysdynResource.getInstance(g);\r
+        boolean update = false;\r
+//        try {\r
+//            hasEquation = \r
+//                !g.getObjects(resource, sr.HasExpression).isEmpty();\r
+//            if(oldHasEquation != hasEquation) \r
+//                update = true;\r
+            if(!label.equals(oldLabel)) {\r
+                oldLabel = label; \r
+                update = true;\r
+            }\r
+            if(update) \r
+                update();\r
+//        } catch (DatabaseException e) {\r
+//            e.printStackTrace();\r
+//        }       \r
         return false;\r
     }\r
-    */\r
+    \r
 }\r