Changeset 6157


Ignore:
Timestamp:
2003-12-08T14:33:53+13:00 (20 years ago)
Author:
jmt12
Message:

Added functionality so that an invalid drop changes the cursor - but oh god do I have to design a new cursor rather than the behemoth Swing uses

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/tree/DragTree.java

    r5885 r6157  
    5050    /** The last tree path the drag was hovered over. */
    5151    private TreePath previous_path = null;
     52
     53    static private Cursor NO_DRAG_CURSOR = null;
     54
    5255    static private final Color TRANSPARENT_COLOR = new Color(0,0,0,0);
    5356    /** The distance from the edge of the current view within the scroll bar which if entered causes the view to scroll. */
     
    7376
    7477    public void init(String name, String background_name, boolean mixed_selection) {
     78    if(NO_DRAG_CURSOR == null) {
     79        NO_DRAG_CURSOR = DragSource.DefaultMoveNoDrop;
     80        //Image image = (Utility.getImage("no_drag_cursor.gif")).getImage();
     81        //Point hot_spot = new Point(1,1);
     82        //NO_DRAG_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(image, hot_spot, "No_Drag_Cursor");
     83    }
     84
    7585    // Init
    7686    this.name = name;
     
    207217    }
    208218    if (!isValidDrag()) {
     219        try {
     220        event.startDrag(NO_DRAG_CURSOR, new StringSelection("dummy"), this);
     221        //dragging = true;
     222        }
     223        catch(Exception error) {
     224        error.printStackTrace();
     225        }
    209226        return;
    210227    }
     
    249266        label = null;
    250267        try {
    251         event.startDrag(new Cursor(Cursor.DEFAULT_CURSOR), group.image_ghost, new Point(5,5), new StringSelection("dummy"), this);
     268        event.startDrag(new Cursor(Cursor.DEFAULT_CURSOR), group.image_ghost, group.mouse_offset, new StringSelection("dummy"), this);
    252269        //dragging = true;
    253270        }
     
    278295    }
    279296    pt_last = pt;
    280     if(!DragSource.isDragImageSupported()) {
     297    if(!DragSource.isDragImageSupported() && group.image_ghost != null) {
    281298        // Erase the last ghost image and cue line
    282299        paintImmediately(ra_ghost.getBounds());
     
    344361        ///ystem.err.println("Valid drop.");
    345362        TreePath[] selection = group.getSelection();
    346         if(target != null) {
     363        if(target != null && selection != null) {
    347364            FileNode[] source_nodes = new FileNode[selection.length];
    348365            for(int i = 0; i < source_nodes.length; i++) {
     
    361378    paintImmediately(ra_ghost.getBounds());
    362379    event.getDropTargetContext().dropComplete(true);
     380    group.image_ghost = null;
    363381    }
    364382
Note: See TracChangeset for help on using the changeset viewer.