com.mucommander.ui.dnd
Class FileDropTargetListener

java.lang.Object
  extended by com.mucommander.ui.dnd.FileDropTargetListener
All Implemented Interfaces:
java.awt.dnd.DropTargetListener, java.util.EventListener

public class FileDropTargetListener
extends java.lang.Object
implements java.awt.dnd.DropTargetListener

Provides file(s) 'drop' support to components that add a DropTarget using this DropTargetListener. A FolderPanel instance has to be specified at creation time, this instance will be used to change the current folder, or copy/move files to the current folder.

There are 2 different modes this class can operate in. The mode to be used has to be specified when this class is instanciated.

In 'folder change mode', when a file or string representing a file path is dropped, the associated FolderPanel's current folder is changed:

If more than one file (or file path) is dropped, only the first one is taken into account.

In the normal mode, files (or file paths) that are dropped can also be moved or copied to the associated FolderPanel's current folder, on top of the change current folder action. The actual drop action performed (move, copy or change current folder) depends on the keyboard modifiers typed by the user when dragging the files. When the mouse cursor enters the drop-enabled component's area, it is changed to symbolize the action to be performed. The default drop action (when no modifier is down) is copy.

Drop events originating from the same FolderPanel are on purpose not accepted as spring-loaded folders are not (yet) supported which would make the drop operation ambiguous and confusing.

Author:
Maxence Bernard

Constructor Summary
FileDropTargetListener(FolderPanel folderPanel, boolean changeFolderOnlyMode)
          Creates a new FileDropTargetListener using the provided FolderPanel that will be used to either change the current folder or copy/move when files are dropped, depending on the specified operating mode and drop action.
 
Method Summary
 void dragEnter(java.awt.dnd.DropTargetDragEvent event)
           
 void dragExit(java.awt.dnd.DropTargetEvent event)
           
 void dragOver(java.awt.dnd.DropTargetDragEvent event)
           
 void drop(java.awt.dnd.DropTargetDropEvent event)
           
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDropTargetListener

public FileDropTargetListener(FolderPanel folderPanel,
                              boolean changeFolderOnlyMode)
Creates a new FileDropTargetListener using the provided FolderPanel that will be used to either change the current folder or copy/move when files are dropped, depending on the specified operating mode and drop action.

Parameters:
folderPanel - the FolderPanel instance used to change the current folder or copy/move when files are dropped
changeFolderOnlyMode - if true, the FolderPanel's current folder can only be changed when file(s) are dropped, files cannot be copied or moved.
Method Detail

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent event)
Specified by:
dragOver in interface java.awt.dnd.DropTargetListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent event)
Specified by:
dragExit in interface java.awt.dnd.DropTargetListener

drop

public void drop(java.awt.dnd.DropTargetDropEvent event)
Specified by:
drop in interface java.awt.dnd.DropTargetListener


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard