dirk_krause.tools
Class DkDropFile

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by dirk_krause.tools.DkDropFile
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DkDropOneDirectory

public abstract class DkDropFile
extends javax.swing.TransferHandler

A transfer handler accepting file names.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport
 
Field Summary
protected  boolean acceptDirectories
          Accept/reject directories
protected  boolean acceptFiles
          Accept/reject regular files
protected  boolean enabled
          While background threads are running we want to disable drag-and-drop
protected  boolean finishedAfterFirst
          We can finish data import after first succeeded filename.
protected  boolean mustAcceptAll
          Is it sufficient to process one name successfully or do we need to process all names successfully?
static java.lang.String[] stringClassNames
          class names to check whether or not a class is the String class
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
DkDropFile()
           
 
Method Summary
 boolean canImport(javax.swing.JComponent c, java.awt.datatransfer.DataFlavor[] flavors)
          Check whether or not the contents is usable.
 boolean getAcceptDirectories()
          Check whether or not this TransferHandler accepts directory names.
 boolean getAcceptFiles()
          Check whether or not this TransferHandler accepts file names for regular files.
 boolean getFinishedAfterFirst()
          Get flag inidicating whether or not we can finish operation after first successful import.
 boolean getMustAcceptAll()
          Check whether the TransferHander must accept all file names successfully for a successfull dnd operation.
 boolean importData(javax.swing.JComponent c, java.awt.datatransfer.Transferable t)
          Import data into component.
 boolean isEnabled()
          Check whether or not drag-and-drop is enabled.
protected abstract  boolean processFilename(java.lang.String fn)
          Process one filename.
 void setAcceptDirectories(boolean f)
          Set flag for accepting directory names.
 void setAcceptFiles(boolean f)
          Set flag for accepting regular file names.
 void setEnabled(boolean f)
          Enable or disable drag-and-drop.
 void setFinishedAfterFirst(boolean b)
          Set flag inidicating whether or not we can finish operation after first successful import.
 void setMustAcceptAll(boolean f)
          Set flag, whether the TransferHandler must accept all file names successfully for a successfull dnd operation.
 
Methods inherited from class javax.swing.TransferHandler
canImport, createTransferable, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getSourceActions, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringClassNames

public static final java.lang.String[] stringClassNames
class names to check whether or not a class is the String class


enabled

protected boolean enabled
While background threads are running we want to disable drag-and-drop


acceptFiles

protected boolean acceptFiles
Accept/reject regular files


acceptDirectories

protected boolean acceptDirectories
Accept/reject directories


mustAcceptAll

protected boolean mustAcceptAll
Is it sufficient to process one name successfully or do we need to process all names successfully?


finishedAfterFirst

protected boolean finishedAfterFirst
We can finish data import after first succeeded filename.

Constructor Detail

DkDropFile

public DkDropFile()
Method Detail

processFilename

protected abstract boolean processFilename(java.lang.String fn)
Process one filename.

Parameters:
fn - The file name to process.
Returns:
A flag indicating whether processing was successfully or not.

isEnabled

public boolean isEnabled()
Check whether or not drag-and-drop is enabled.

Returns:
Check result.

setEnabled

public void setEnabled(boolean f)
Enable or disable drag-and-drop.

Parameters:
f - Enable/disable flag.

getAcceptFiles

public boolean getAcceptFiles()
Check whether or not this TransferHandler accepts file names for regular files.

Returns:
The flag value.

setAcceptFiles

public void setAcceptFiles(boolean f)
Set flag for accepting regular file names.

Parameters:
f - The new flag value.

getAcceptDirectories

public boolean getAcceptDirectories()
Check whether or not this TransferHandler accepts directory names.

Returns:
The flag value.

setAcceptDirectories

public void setAcceptDirectories(boolean f)
Set flag for accepting directory names.

Parameters:
f - The new flag value.

getMustAcceptAll

public boolean getMustAcceptAll()
Check whether the TransferHander must accept all file names successfully for a successfull dnd operation. Otherwise it is sufficient to process at least on name successfully.

Returns:
The flag value.

setMustAcceptAll

public void setMustAcceptAll(boolean f)
Set flag, whether the TransferHandler must accept all file names successfully for a successfull dnd operation.

Parameters:
f - The new flag value.

getFinishedAfterFirst

public boolean getFinishedAfterFirst()
Get flag inidicating whether or not we can finish operation after first successful import.

Returns:
The flag.

setFinishedAfterFirst

public void setFinishedAfterFirst(boolean b)
Set flag inidicating whether or not we can finish operation after first successful import.

Parameters:
b - The flag.

canImport

public boolean canImport(javax.swing.JComponent c,
                         java.awt.datatransfer.DataFlavor[] flavors)
Check whether or not the contents is usable.

Overrides:
canImport in class javax.swing.TransferHandler
Parameters:
c - The component.
flavors - The collection of contents flavors.

importData

public boolean importData(javax.swing.JComponent c,
                          java.awt.datatransfer.Transferable t)
Import data into component.

Overrides:
importData in class javax.swing.TransferHandler
Parameters:
c - The component receiving the data.
t - The contents to import.
Returns:
Flag to indicate success or error.