Revision 38043 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/DnDJTree.java

View differences:

DnDJTree.java
59 59
*/
60 60

  
61 61

  
62
import java.awt.Color;
63
import java.awt.Graphics;
62 64
import java.awt.Point;
65
import java.awt.Rectangle;
63 66
import java.awt.datatransfer.Transferable;
64 67
import java.awt.datatransfer.UnsupportedFlavorException;
65 68
import java.awt.dnd.DnDConstants;
......
118 121
  //private ArrayList treeListeners=new ArrayList();
119 122
  //private ArrayList dropListeners=new ArrayList();
120 123
 // private TreeModel model1;
124
  
125
  protected Rectangle separatorRectangle = new Rectangle();
126
  private int MARGIN = 0;
127

  
128
private int separatorPos;
129

  
130
private boolean bUpSelected;	
131
	
132
	
121 133
  /** Constructor
122 134
  @param root The root node of the tree
123 135
  @param parent Parent JFrame of the JTree */
......
394 406

  
395 407

  
396 408
	  if (destParent.equals(oldParent)){ // Es un cambio de orden entre capas en el mismo nivel.
409
		  // Para no cambiar el api, podemos guardar la posici?n del nodo tocado
410
		  // como una propiedad de la capa (que luego borraremos)
411
		  lpd.setProperty("GO_UP", new Boolean(bUpSelected));
397 412
		  callListeners(oldPos,newPos,lpd);
398 413
	  }else{ // Es un cambio entre capas agrupadas.
399 414
		  // Para no cambiar el api, podemos guardar la posici?n del nodo tocado
......
475 490

  
476 491

  
477 492
    // if destination path is okay accept drop...
493
        if (destinationPath == null){
494
			return;
495
		}
478 496

  
497
	DefaultMutableTreeNode dragedTreeNode = (DefaultMutableTreeNode) destinationPath.getLastPathComponent();		
498
	if (dragedTreeNode.getUserObject() instanceof TocItemBranch){
499
		FLayer draggedLayer = ((TocItemBranch)dragedTreeNode.getUserObject()).getLayer(); 
500
		if (draggedLayer != null){	
501
			Graphics graphics = this.getGraphics();
502
			int increment = (int)separatorRectangle.getHeight();
503

  
504
			graphics.clearRect(0, separatorPos, getWidth(), 1);			
505

  
506
			bUpSelected = false;
507
			separatorRectangle = getPathBounds(destinationPath);	
508
			separatorPos = separatorRectangle.y + increment - 1;
509
 			if (cursorLocationBis.y < separatorPos - increment/2) {
510
				increment = 0;
511
				bUpSelected = true;
512
 			}
513
			else
514
				increment = separatorRectangle.height;
515
 			separatorPos = separatorRectangle.y + increment - 1;
516

  
517
 			System.out.println("bUpSelected=" + bUpSelected + " separatorPos =" + separatorPos 
518
 					+ " cursor=" + cursorLocationBis.y);
519
			graphics.setColor(Color.red);	
520
			graphics.drawLine(MARGIN, separatorPos , getWidth() - MARGIN, separatorPos);
521
		}	
522
	}
523
		
479 524
    if (testSameComponent(e))
480 525
    {
481 526
        String msg = testDropTarget(destinationPath, SelectedTreePath);

Also available in: Unified diff