]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
concurrency bug fixes
authorniemisto <niemisto@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 17 Mar 2010 08:46:38 +0000 (08:46 +0000)
committerniemisto <niemisto@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 17 Mar 2010 08:46:38 +0000 (08:46 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15041 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ConnectBase.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java

index f3df5fff915f6b862c78ea72756c4de3ac3178ae..a5c2d023b105c7926d634785aeea93bcd36d72bd 100644 (file)
@@ -182,12 +182,14 @@ public class EditorCanvas extends Canvas {
                        if(e.isConsumed())\r
                                return;\r
                        currentPosition = e.getPoint();\r
-                       dragEvent.currentModifiers = \r
-                               Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown());\r
-                       dragEvent.current = editor.screenToDiagram(e.getPoint());\r
+                       if(dragEvent != null) { // TODO why this is needed?\r
+                       dragEvent.currentModifiers = \r
+                               Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown());\r
+                       dragEvent.current = editor.screenToDiagram(e.getPoint());\r
+                       }\r
                        editor.handleEvent(dragEvent);\r
 \r
-                       if(dragEvent.phase == DragEventPhase.dragBegin) {\r
+                       if(dragEvent != null && dragEvent.phase == DragEventPhase.dragBegin) {\r
                                dragEvent.phase = DragEventPhase.dragUpdate;\r
                                editor.handleEvent(dragEvent);\r
                        }\r
index ec9a1c6e98ba3a5f43129b7fa94cec6c3d56ee61..d1cde772c46fe606647659f82124e558a53c812f 100644 (file)
@@ -46,12 +46,10 @@ public abstract class ConnectBase extends DragEventHandler {
                for(IElement element : event.pickedElements) {\r
                        Connectable connectable = element.getInterface(Connectable.class);\r
                        if(connectable != null && isAllowedTail(connectable)) {\r
-                           System.out.println("allowed");\r
                                this.from = connectable;\r
                                return true;\r
                        }\r
                }\r
-               System.out.println("not allowed");\r
                return false;\r
        }\r
        \r
index 4ac87e303c614c4c87b3b2530b4f4ac9c46bab8a..42ae0175c9971cdef916d9cb057b47a804a03ce0 100644 (file)
@@ -96,35 +96,48 @@ public class SysdynDiagramEditor extends ResourceEditorPart {
                mapping.addMappingListener(new IMappingListener() {\r
                        \r
                        @Override\r
-                       public void rangeModified() {                       \r
-                               session.asyncRequest(new WriteRequest() {\r
-                                       \r
-                                       @Override\r
-                                       public void perform(WriteGraph graph)\r
-                                                       throws DatabaseException {\r
-                                           try {\r
-                                               mapping.updateDomain(graph);\r
-                                           } catch(Exception e) {\r
-                                               e.printStackTrace();\r
-                                           }\r
-                                       }\r
-                                       \r
-                               });\r
+                       public void rangeModified() {\r
+                           SwingUtilities.invokeLater(new Runnable() {\r
+\r
+                    @Override\r
+                    public void run() {\r
+                        try {\r
+                            session.syncRequest(new WriteRequest() {                                \r
+                                @Override\r
+                                public void perform(WriteGraph graph)\r
+                                        throws DatabaseException {\r
+                                    mapping.updateDomain(graph);\r
+                                }                                \r
+                            });\r
+                        } catch (DatabaseException e) {\r
+                            // TODO Auto-generated catch block\r
+                            e.printStackTrace();\r
+                        }                        \r
+                    }\r
+                               \r
+                           });                         \r
                        }\r
                        \r
                        @Override\r
                        public void domainModified() {\r
-                           session.asyncRequest(new ReadRequest() {\r
-                    \r
+                           SwingUtilities.invokeLater(new Runnable() {\r
+\r
                     @Override\r
-                    public void run(ReadGraph graph) throws DatabaseException {\r
+                    public void run() {\r
                         try {\r
-                            mapping.updateRange(graph);\r
-                        } catch(Exception e) {\r
+                            session.syncRequest(new ReadRequest() {                            \r
+                                @Override\r
+                                public void run(ReadGraph graph) throws DatabaseException {\r
+                                    mapping.updateRange(graph);\r
+                                }\r
+                            });\r
+                        } catch (DatabaseException e) {\r
+                            // TODO Auto-generated catch block\r
                             e.printStackTrace();\r
-                        }\r
+                        }          \r
                     }\r
-                });                        \r
+                    \r
+                           });                             \r
                        }\r
                                                \r
                });\r