Fixed an issue when removing multiple WirePointHandles at once
authorFabian Stemmler <stemmler@in.tum.de>
Mon, 15 Jul 2019 13:11:38 +0000 (15:11 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Mon, 15 Jul 2019 13:11:38 +0000 (15:11 +0200)
Also changed click priority: WireHandles have a higher priority than
ComponentHandles now.

net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/HandleManager.java
net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/handles/WirePointHandle.java

index f999c96..91b0e3b 100644 (file)
@@ -123,13 +123,6 @@ public class HandleManager
                                        for(int i = 0; i < diff; i++)
                                                addWirePointHandle(w);
                                }
                                        for(int i = 0; i < diff; i++)
                                                addWirePointHandle(w);
                                }
-                               else
-                               {
-                                       for(int i = 0; i > diff; i--)
-                                       {
-                                               removeLastWirePointHandle(wire);
-                                       }
-                               }
                                
                                List<WirePointHandle> wpHandles = pointHandlesPerWire.get(w);
                                int size = wpHandles.size();
                                
                                List<WirePointHandle> wpHandles = pointHandlesPerWire.get(w);
                                int size = wpHandles.size();
@@ -203,23 +196,25 @@ public class HandleManager
                List<WirePointHandle> wireHandles = pointHandlesPerWire.get(w);
                WirePointHandle h;
                if (wireHandles != null)
                List<WirePointHandle> wireHandles = pointHandlesPerWire.get(w);
                WirePointHandle h;
                if (wireHandles != null)
-                       wireHandles.add(h = new WirePointHandle(w, wireHandles.size()));
+                       wireHandles.add(h = new WirePointHandle(this, w, wireHandles.size()));
                else
                {
                        wireHandles = new ArrayList<>();
                else
                {
                        wireHandles = new ArrayList<>();
-                       h = new WirePointHandle(w, 0);
+                       h = new WirePointHandle(this, w, 0);
                        wireHandles.add(h);
                        pointHandlesPerWire.put(h.parent, wireHandles);
                }
                this.wirePointHandles.add(h);
                addHandle(h);
        }
                        wireHandles.add(h);
                        pointHandlesPerWire.put(h.parent, wireHandles);
                }
                this.wirePointHandles.add(h);
                addHandle(h);
        }
-
-       private void removeLastWirePointHandle(GUIWire owner)
+       
+       void destroyWirePointHandle(GUIWire owner, WirePointHandle h)
        {
        {
-               Handle h = pointHandlesPerWire.get(owner).remove(0);
-               wirePointHandles.remove(h);
+               List<WirePointHandle> handles = pointHandlesPerWire.get(owner);
+               int pointIndex = handles.indexOf(h);
+               handles.remove(pointIndex);
                removeHandle(h);
                removeHandle(h);
+               owner.removePathPoint(pointIndex);
        }
 
        private void removeWirePointHandles(GUIWire owner)
        }
 
        private void removeWirePointHandles(GUIWire owner)
@@ -345,9 +340,9 @@ public class HandleManager
                        if (!click(handlePerPin.values(), clicked, entryState, stateMask))
                                if (!click(handlePerInterfacePin.values(), clicked, entryState, stateMask))
                                        if (!click(getWirePointHandles(), clicked, entryState, stateMask))
                        if (!click(handlePerPin.values(), clicked, entryState, stateMask))
                                if (!click(handlePerInterfacePin.values(), clicked, entryState, stateMask))
                                        if (!click(getWirePointHandles(), clicked, entryState, stateMask))
-                                               if (!click(handlePerComp.values(), clicked, entryState, stateMask))
-                                                       if (!click(getWireHandles(), clicked, entryState, stateMask))
-                                                               entryState.clickedEmpty(clicked, stateMask);
+                                               if (!click(getWireHandles(), clicked, entryState, stateMask))
+                                                       if (!click(handlePerComp.values(), clicked, entryState, stateMask))
+                                                                       entryState.clickedEmpty(clicked, stateMask);
                entryState.clicked(clicked, stateMask);
        }
 
                entryState.clicked(clicked, stateMask);
        }
 
index 2457579..0779247 100644 (file)
@@ -11,14 +11,16 @@ import net.mograsim.logic.model.model.wires.GUIWire;
 public class WirePointHandle extends Handle
 {
        private final static int END_OFFSET = 4;
 public class WirePointHandle extends Handle
 {
        private final static int END_OFFSET = 4;
+       private final HandleManager manager;
        private boolean selected = false;
        public final GUIWire parent;
        
        private int pointIndex;
 
        private boolean selected = false;
        public final GUIWire parent;
        
        private int pointIndex;
 
-       public WirePointHandle(GUIWire parent, int pointIndex)
+       public WirePointHandle(HandleManager manager, GUIWire parent, int pointIndex)
        {
                super();
        {
                super();
+               this.manager = manager;
                this.parent = parent;
                this.pointIndex = pointIndex;
                setSize(END_OFFSET, END_OFFSET);
                this.parent = parent;
                this.pointIndex = pointIndex;
                setSize(END_OFFSET, END_OFFSET);
@@ -63,7 +65,7 @@ public class WirePointHandle extends Handle
        @Override
        public void reqDelete()
        {
        @Override
        public void reqDelete()
        {
-               parent.removePathPoint(pointIndex);
+               manager.destroyWirePointHandle(parent, this);
        }
        
        @Override
        }
        
        @Override