]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Removed immediate text edit activation on element select. (fixes #3880)
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Nov 2012 12:10:20 +0000 (12:10 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 27 Nov 2012 12:10:20 +0000 (12:10 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26460 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextElementNoBounds.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements/HoverTextNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/VariableInformationTab.java

index c7f768574a01aeed7c77ac8e4ced9b74ceb56dcd..1aa2651cd43475430c39598384e8bb2033b2f286 100644 (file)
@@ -15,8 +15,10 @@ import java.awt.Color;
 import java.awt.Font;\r
 import java.awt.geom.AffineTransform;\r
 \r
+import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.diagram.elements.ITextListener;\r
@@ -102,7 +104,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif
                                                if(!VariableNameUtils.isValid(component, node.getText(), false)) {\r
                                                        node.setColor(Color.RED);\r
                                                } else {\r
-                                                       node.setColor(Color.BLACK);\r
+                                                       node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
                                                }\r
 \r
 \r
@@ -118,10 +120,10 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif
                                                Object o = e.getHint(ElementHints.KEY_OBJECT);\r
                                                if(o != null && o instanceof Resource) {\r
                                                        final Resource element = (Resource)o;\r
-                                                       SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                                                       SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
 \r
                                                                @Override\r
-                                                               public void perform(WriteGraph graph) throws DatabaseException {\r
+                                                               public void run(ReadGraph graph) throws DatabaseException {\r
                                                                        component = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent);\r
                                                                }\r
                                                        });\r
@@ -133,7 +135,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif
                                                TextNode node = (TextNode) e.getHint(SG_NODE);\r
                                                if (node != null) {\r
                                                        if(VariableNameUtils.isValid(component, node.getText(), false))\r
-                                                               node.setColor(Color.BLACK);\r
+                                                               node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
                                                        endEdit(node);\r
                                                }\r
                                        }\r
@@ -148,7 +150,7 @@ public class HoverTextElementNoBounds extends TextElementNoBounds implements Lif
                                                        text = textBeforeEdit;\r
                                                        node.setText(text);\r
                                                        if(VariableNameUtils.isValid(component, text, false))\r
-                                                               node.setColor(Color.BLACK);\r
+                                                               node.setColor(ElementUtils.getTextColor(e, Color.BLACK));\r
                                                } else {\r
                                                        Object o = e.getHint(ElementHints.KEY_OBJECT);\r
                                                        final String textAfterEdit = text;\r
index 8bef287fc0a03c25c4e99881ac63d22f4b07bbdb..76717577f307a3506649395c6a4ef9025b32bdec 100644 (file)
@@ -61,12 +61,6 @@ public class HoverTextNode extends TextNode implements ISelectionPainterNode {
         super.render(g, false);\r
         g.setTransform(ot);\r
     }\r
-\r
-    @Override\r
-    public void init() {\r
-        super.init();\r
-        addEventHandler(this);\r
-    }\r
     \r
     @Override\r
     public void remove() {\r
@@ -88,5 +82,5 @@ public class HoverTextNode extends TextNode implements ISelectionPainterNode {
         }\r
         return false;\r
     }\r
-\r
+    \r
 }\r
index cbd30d5d0d7edb1e99c184672cd41c469fa3896d..506e7a75c1f198a98858a3800a0e0202c893d0e9 100644 (file)
@@ -50,9 +50,9 @@ import org.simantics.sysdyn.ui.properties.widgets.ValveTextLocationGroup;
 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
 import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
 import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.utils.AdaptionUtils;\r
 import org.simantics.utils.datastructures.Pair;\r
 import org.simantics.utils.datastructures.Triple;\r
+import org.simantics.utils.ui.AdaptionUtils;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 import org.simantics.utils.ui.validators.DoubleValidator;\r
 \r
@@ -309,6 +309,14 @@ public class VariableInformationTab extends LabelPropertyTabContributor implemen
                         \r
                         @Override\r
                         public void run() {\r
+                            try {\r
+                                if(sample.getWidget().isDisposed())\r
+                                    return;\r
+                            } catch (SWTException e) {\r
+                                // Widget is disposed, the GUI probably did'n function as fast as the user commanded.\r
+                                // Thus do nothing.\r
+                                return;\r
+                            }\r
                             if(result.first != null) {\r
                                 FontData fd = toSwtFontData(result.first);\r
                                 sample.setFont(new Font(device, fd));\r