From 0844c7cae800b3dcf386f59ec3d532819dc5952b Mon Sep 17 00:00:00 2001 From: niemisto Date: Wed, 17 Mar 2010 08:46:38 +0000 Subject: [PATCH] concurrency bug fixes git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@15041 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/h2d/canvas/EditorCanvas.java | 10 ++-- .../sysdyn/ui/actions/ConnectBase.java | 2 - .../sysdyn/ui/editor/SysdynDiagramEditor.java | 55 ++++++++++++------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java b/org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java index f3df5fff..a5c2d023 100644 --- a/org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java +++ b/org.simantics.h2d/src/org/simantics/h2d/canvas/EditorCanvas.java @@ -182,12 +182,14 @@ public class EditorCanvas extends Canvas { if(e.isConsumed()) return; currentPosition = e.getPoint(); - dragEvent.currentModifiers = - Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()); - dragEvent.current = editor.screenToDiagram(e.getPoint()); + if(dragEvent != null) { // TODO why this is needed? + dragEvent.currentModifiers = + Modifiers.modifierString(e.getButton(), e.isControlDown(), e.isAltDown(), e.isShiftDown()); + dragEvent.current = editor.screenToDiagram(e.getPoint()); + } editor.handleEvent(dragEvent); - if(dragEvent.phase == DragEventPhase.dragBegin) { + if(dragEvent != null && dragEvent.phase == DragEventPhase.dragBegin) { dragEvent.phase = DragEventPhase.dragUpdate; editor.handleEvent(dragEvent); } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ConnectBase.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ConnectBase.java index ec9a1c6e..d1cde772 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ConnectBase.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/actions/ConnectBase.java @@ -46,12 +46,10 @@ public abstract class ConnectBase extends DragEventHandler { for(IElement element : event.pickedElements) { Connectable connectable = element.getInterface(Connectable.class); if(connectable != null && isAllowedTail(connectable)) { - System.out.println("allowed"); this.from = connectable; return true; } } - System.out.println("not allowed"); return false; } diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java index 4ac87e30..42ae0175 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynDiagramEditor.java @@ -96,35 +96,48 @@ public class SysdynDiagramEditor extends ResourceEditorPart { mapping.addMappingListener(new IMappingListener() { @Override - public void rangeModified() { - session.asyncRequest(new WriteRequest() { - - @Override - public void perform(WriteGraph graph) - throws DatabaseException { - try { - mapping.updateDomain(graph); - } catch(Exception e) { - e.printStackTrace(); - } - } - - }); + public void rangeModified() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + try { + session.syncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) + throws DatabaseException { + mapping.updateDomain(graph); + } + }); + } catch (DatabaseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + }); } @Override public void domainModified() { - session.asyncRequest(new ReadRequest() { - + SwingUtilities.invokeLater(new Runnable() { + @Override - public void run(ReadGraph graph) throws DatabaseException { + public void run() { try { - mapping.updateRange(graph); - } catch(Exception e) { + session.syncRequest(new ReadRequest() { + @Override + public void run(ReadGraph graph) throws DatabaseException { + mapping.updateRange(graph); + } + }); + } catch (DatabaseException e) { + // TODO Auto-generated catch block e.printStackTrace(); - } + } } - }); + + }); } }); -- 2.47.1