Browse Source

HolonView allow only Hollons to move

Tom Troppmann 3 years ago
parent
commit
37e3b305fc
2 changed files with 9 additions and 5 deletions
  1. 2 2
      src/classes/Holon.java
  2. 7 3
      src/ui/view/outliner/HolonView.java

+ 2 - 2
src/classes/Holon.java

@@ -77,8 +77,8 @@ public class Holon {
 	}
 	
 	//TODO This can maybe cached
-	public int getLevel() {
-		return parent != null ? parent.getLevel() +  1 : 0;
+	public int getLayer() {
+		return parent != null ? parent.getLayer() +  1 : 0;
 	}
 	
 	

+ 7 - 3
src/ui/view/outliner/HolonView.java

@@ -195,6 +195,7 @@ public class HolonView extends JPanel{
 		        if(!support.isDataFlavorSupported(holonFlavor) &&  !support.isDataFlavorSupported(elementFlavor)) {
 		            return false;
 		        }
+		        
 		        JTree.DropLocation location = (JTree.DropLocation)support.getDropLocation();
 		        TreePath pathDrop = location.getPath();
 		        DefaultMutableTreeNode node = (DefaultMutableTreeNode) pathDrop.getLastPathComponent();
@@ -202,12 +203,14 @@ public class HolonView extends JPanel{
 		        if(!(node.getUserObject() instanceof HolonInfo)) {
 		        	return false;
 		        }
-		        //Dont allow Cycles
+		        
 		        JTree tree = (JTree) support.getComponent();
 		        TreePath pathDrag = tree.getSelectionPath();
+		        //Dont allow Cycles
 		        if(pathDrag.isDescendant(pathDrop)) {
 		        	return false;
 		        }
+	
 		        return true;
 	    }
 		@Override 
@@ -251,8 +254,9 @@ public class HolonView extends JPanel{
 	        if(path != null) {
 	        	DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
 	        	Object userObject =	node.getUserObject();
-	        	if(userObject instanceof HolonNode) {
-	        		return ((HolonNode) userObject).getTransferable(this);
+	        	//Only allow Hollon to move
+	        	if(userObject instanceof HolonInfo) {
+	        		return ((HolonInfo) userObject).getTransferable(this);
 	        		
 	        	}
 	        }