Browse Source

Fixes missing Edges, on copied CpsUpperNodes

Andreas T. Meyer-Berg 6 years ago
parent
commit
ac44d8b3cb

+ 1 - 1
src/ui/controller/ClipboardController.java

@@ -60,7 +60,7 @@ public class ClipboardController {
         for (AbstractCpsObject abs : model.getSelectedCpsObjects()) {
             queue.add(abs);
         }
-
+        
         while (!queue.isEmpty()) {
 
             u = queue.pop();

+ 9 - 1
src/ui/controller/NodeController.java

@@ -446,7 +446,15 @@ class NodeController {
 	 * @param replace
 	 */
     void addObjectInUpperNode(AbstractCpsObject object, CpsUpperNode upperNode, boolean replace) {
-        object.setSav("" + upperNode.getId());
+        if(object == null){
+        		new Error("object == null while adding to "+upperNode.toString()).printStackTrace();
+        		return;
+        	}
+        if(upperNode == null){
+    		new Error("object == null while adding "+object.toString()).printStackTrace();
+    		return;
+    	}
+    	object.setSav("" + upperNode.getId());
 		upperNode.getNodesIdx().put(object.getId(), upperNode.getNodes().size());
 		upperNode.getNodes().add(object);
 		

+ 9 - 0
src/ui/view/MyCanvas.java

@@ -521,6 +521,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			}
 			triggerUpdateController();
 		}
+
+		stopEditing();
 	}
 
 	@Override
@@ -548,11 +550,15 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				setConsoleTextAfterSelect(cps);
 
 				dragging = true;
+
 				if (e.isControlDown() && tempCps != null) {
 					if (model.getSelectedCpsObjects().contains(tempCps)) {
 						controller.deleteSelectedObject(tempCps);
+							//TODO: RemoveDepth
 					} else {
 						controller.addSelectedObject(tempCps);
+						if(tempCps instanceof CpsUpperNode)
+							controller.getObjectsInDepth();
 					}
 
 				}
@@ -629,6 +635,9 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				&& MouseEvent.BUTTON3 != e.getButton()) {
 			model.getSelectedCpsObjects().clear();
 			controller.addSelectedObject(tempCps);
+			model.setSelectedCpsObject(tempCps);
+			if(tempCps instanceof CpsUpperNode)
+				controller.getObjectsInDepth();
 		}
 
 		dragged = false;

+ 5 - 0
src/ui/view/UpperNodeCanvas.java

@@ -587,6 +587,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
     @Override
     public void mouseClicked(MouseEvent e) {
         triggerUpdateController();
+        stopEditing();
     }
 
     @Override
@@ -629,6 +630,8 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                             controller.deleteSelectedObject(tempCps);
                         } else {
                             controller.addSelectedObject(tempCps);
+                            if(tempCps instanceof CpsUpperNode)
+    							controller.getObjectsInDepth();
                         }
                     }
 
@@ -749,6 +752,8 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         if (!e.isControlDown() && !dragged && tempCps != null && MouseEvent.BUTTON3 != e.getButton()) {
             model.getSelectedCpsObjects().clear();
             controller.addSelectedObject(tempCps);
+            if(tempCps instanceof CpsUpperNode)
+				controller.getObjectsInDepth();
         }
 
         dragged = false;