Revision 38051
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/DnDJTree.java | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
|
61 | 61 |
|
62 |
import java.awt.BasicStroke; |
|
62 | 63 |
import java.awt.Color; |
63 | 64 |
import java.awt.Graphics; |
65 |
import java.awt.Graphics2D; |
|
64 | 66 |
import java.awt.Point; |
65 | 67 |
import java.awt.Rectangle; |
66 | 68 |
import java.awt.datatransfer.Transferable; |
... | ... | |
415 | 417 |
// como una propiedad de la capa (que luego borraremos) |
416 | 418 |
FLayer lyrToMove = ((TocItemBranch)newChild.getUserObject()).getLayer(); |
417 | 419 |
lyrToMove.setProperty("DROP_POS", new Integer(newPos)); |
420 |
lyrToMove.setProperty("GO_UP", new Boolean(bUpSelected)); |
|
418 | 421 |
callListeners(lpo,lpd,lyrToMove); |
419 | 422 |
} |
420 | 423 |
} |
... | ... | |
478 | 481 |
|
479 | 482 |
/** DropTaregetListener interface method */ |
480 | 483 |
public void dragExit(DropTargetEvent e) { |
484 |
clearDropMark(); |
|
481 | 485 |
} |
482 | 486 |
|
483 | 487 |
/** DropTaregetListener interface method */ |
... | ... | |
491 | 495 |
|
492 | 496 |
// if destination path is okay accept drop... |
493 | 497 |
if (destinationPath == null){ |
498 |
clearDropMark(); |
|
494 | 499 |
return; |
495 | 500 |
} |
496 | 501 |
|
... | ... | |
498 | 503 |
if (dragedTreeNode.getUserObject() instanceof TocItemBranch){ |
499 | 504 |
FLayer draggedLayer = ((TocItemBranch)dragedTreeNode.getUserObject()).getLayer(); |
500 | 505 |
if (draggedLayer != null){ |
501 |
Graphics graphics = this.getGraphics(); |
|
502 | 506 |
int increment = (int)separatorRectangle.getHeight(); |
503 | 507 |
|
504 |
graphics.clearRect(0, separatorPos, getWidth(), 1);
|
|
508 |
clearDropMark();
|
|
505 | 509 |
|
506 | 510 |
bUpSelected = false; |
507 | 511 |
separatorRectangle = getPathBounds(destinationPath); |
512 |
MARGIN = separatorRectangle.x; |
|
508 | 513 |
separatorPos = separatorRectangle.y + increment - 1; |
509 | 514 |
if (cursorLocationBis.y < separatorPos - increment/2) { |
510 | 515 |
increment = 0; |
... | ... | |
514 | 519 |
increment = separatorRectangle.height; |
515 | 520 |
separatorPos = separatorRectangle.y + increment - 1; |
516 | 521 |
|
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); |
|
522 |
// System.out.println("bUpSelected=" + bUpSelected + " separatorPos =" + separatorPos |
|
523 |
// + " cursor=" + cursorLocationBis.y); |
|
524 |
Graphics graphics = this.getGraphics(); |
|
525 |
graphics.setColor(Color.black); |
|
526 |
BasicStroke stroke = new BasicStroke(2); |
|
527 |
((Graphics2D) graphics).setStroke(stroke); |
|
528 |
graphics.drawLine(MARGIN, separatorPos , separatorRectangle.width, separatorPos); |
|
521 | 529 |
} |
522 | 530 |
} |
523 | 531 |
|
... | ... | |
535 | 543 |
// System.err.println(e.getDropTargetContext().getComponent()); |
536 | 544 |
|
537 | 545 |
// if (testSameComponent(e)) |
546 |
clearDropMark(); |
|
538 | 547 |
e.rejectDrag() ; |
539 | 548 |
/* else |
540 | 549 |
e.acceptDrag(DnDConstants.ACTION_MOVE); */ |
541 | 550 |
// } |
542 | 551 |
/* ****************** END OF CHANGE ******************** */ |
543 | 552 |
} |
553 |
protected void clearDropMark() { |
|
554 |
// Borramos la marca |
|
555 |
if (separatorPos != -1) { |
|
556 |
Graphics graphics = this.getGraphics(); |
|
557 |
graphics.clearRect(0, separatorPos-1, getWidth(), 2); |
|
558 |
separatorPos = 1; |
|
559 |
} |
|
560 |
} |
|
544 | 561 |
|
545 | 562 |
/** DropTaregetListener interface method */ |
546 | 563 |
public void dropActionChanged(DropTargetDragEvent e) { |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/actions/PasteLayersTocMenuEntry.java | ||
---|---|---|
12 | 12 |
|
13 | 13 |
import com.iver.andami.PluginServices; |
14 | 14 |
import com.iver.cit.gvsig.ProjectExtension; |
15 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
15 | 16 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
16 | 17 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
17 | 18 |
import com.iver.cit.gvsig.project.Project; |
... | ... | |
92 | 93 |
} |
93 | 94 |
else |
94 | 95 |
{ |
95 |
JPopupMenu pop = new JPopupMenu(PluginServices.getText(this, "Paste")); |
|
96 |
JMenuItem itUp = new JMenuItem(PluginServices.getText(this, "Paste_above_layer") + " " + lyrOn.getName()); |
|
97 |
JMenuItem itDown = new JMenuItem(PluginServices.getText(this, "Paste_below_layer") + " " + lyrOn.getName()); |
|
96 |
// Cambio: Siempre arriba |
|
97 |
// JPopupMenu pop = new JPopupMenu(PluginServices.getText(this, "Paste")); |
|
98 |
// JMenuItem itUp = new JMenuItem(PluginServices.getText(this, "Paste_above_layer") + " " + lyrOn.getName()); |
|
99 |
// JMenuItem itDown = new JMenuItem(PluginServices.getText(this, "Paste_below_layer") + " " + lyrOn.getName()); |
|
100 |
// |
|
101 |
// itUp.setActionCommand("UP"); |
|
102 |
// itDown.setActionCommand("DOWN"); |
|
103 |
// |
|
104 |
// MyPasteListener lis = new MyPasteListener(pop, item, this.xml, lyrOn, getMapContext()); |
|
105 |
// |
|
106 |
// itUp.addActionListener(lis); |
|
107 |
// itDown.addActionListener(lis); |
|
108 |
// |
|
109 |
// pop.add(itUp); |
|
110 |
// pop.add(itDown); |
|
111 |
// |
|
112 |
// PointerInfo pi = MouseInfo.getPointerInfo(); |
|
113 |
// |
|
114 |
// pop.show(null, pi.getLocation().x, pi.getLocation().y); |
|
115 |
|
|
116 |
MapContext mapContext = getMapContext(); |
|
117 |
mapContext.beginAtomicEvent(); |
|
118 |
try { |
|
119 |
|
|
120 |
FLayers all = mapContext.getLayers(); |
|
121 |
CopyPasteLayersUtiles.getInstance().loadLayersFromXML(xml, all); |
|
122 |
// ponemos las capas en posici?n |
|
123 |
int pos = -1; |
|
124 |
for (int j=0; j < all.getLayersCount(); j++) { |
|
125 |
if (all.getLayer(j).getName().equalsIgnoreCase(lyrOn.getName())) { |
|
126 |
pos = j; |
|
127 |
break; |
|
128 |
} |
|
129 |
} |
|
130 |
int corrected = 2; |
|
131 |
all.moveTo(0, all.getLayersCount()-corrected-pos); |
|
132 |
} catch (Exception ex) { |
|
133 |
ex.printStackTrace(); |
|
134 |
} |
|
135 |
|
|
136 |
mapContext.endAtomicEvent(); |
|
137 |
mapContext.invalidate(); |
|
98 | 138 |
|
99 |
itUp.setActionCommand("UP"); |
|
100 |
itDown.setActionCommand("DOWN"); |
|
101 |
|
|
102 |
MyPasteListener lis = new MyPasteListener(pop, item, this.xml, lyrOn, getMapContext()); |
|
103 |
|
|
104 |
itUp.addActionListener(lis); |
|
105 |
itDown.addActionListener(lis); |
|
106 |
|
|
107 |
pop.add(itUp); |
|
108 |
pop.add(itDown); |
|
109 |
|
|
110 |
PointerInfo pi = MouseInfo.getPointerInfo(); |
|
111 |
|
|
112 |
pop.show(null, pi.getLocation().x, pi.getLocation().y); |
|
113 | 139 |
|
114 | 140 |
return; |
115 | 141 |
} |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toc/impl/DefaultToc.java | ||
---|---|---|
612 | 612 |
if (lpo.getLayersCount() == 0) |
613 | 613 |
lpo.getParentLayer().removeLayer(lpo); |
614 | 614 |
Integer drop_pos = (Integer) ls.getProperty("DROP_POS"); |
615 |
lpd.addLayer(lpd.getLayersCount() - drop_pos - 1, ls); |
|
616 |
ls.getExtendedProperties().remove("DROP_POS"); |
|
615 |
ls.getExtendedProperties().remove("DROP_POS"); |
|
616 |
boolean bUp = (Boolean) ls.getProperty("GO_UP"); |
|
617 |
ls.getExtendedProperties().remove("GO_UP"); |
|
618 |
|
|
619 |
int correct = 1; |
|
620 |
if (bUp) { |
|
621 |
correct = 0; |
|
622 |
} |
|
623 |
|
|
624 |
lpd.addLayer(lpd.getLayersCount() - drop_pos - correct, ls); |
|
625 |
|
|
617 | 626 |
PluginServices.getMainFrame().enableControls(); |
618 | 627 |
/* |
619 | 628 |
* if (lpo.getLayersCount()==0){ lpo.getParentLayer().removeLayer(lpo); |
Also available in: Unified diff