Changes between Version 5 and Version 6 of BASE_DND_R0


Ignore:
Timestamp:
03/12/09 20:21:11 (16 years ago)
Author:
peko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BASE_DND_R0

    v5 v6  
    5757= Design = 
    5858 
     59== General things == 
     60 
     61 * Drag and Drop should be able to transfer things from Source to Target. 
     62  * Both Source and Target should be able to export and import different types of data, called !DataFlavor. 
     63  * As of Java 1.4, dragging and dropping things is done through the so called !TransferHandler. 
     64   * it is responsible for initiating a drag, accepting a drop and changing the UI correspondingly (changing the mouse cursor depending on the action performed - COPY, MOVE, LINK.) 
     65   * the !TransferHandler need a JComponent in order to detect drag and drop gestures. It is usually enough for a simple Java application, since it transfers text, images, files etc. almost on the fly. 
     66   * the drag and drop mechanism in Java is quite complicated since it can be done in two ways which is sometimes misleading. 
     67 * We need to define three things in order to be able to perform Drad and Drop. The things below are enough to create a library that can provide drag and drop. 
     68  * SophieTransferHandler 
     69  * Transferable 
     70  * DataFlavor 
     71 
     72== SophieTransferHandler == 
     73 * a class representing a !TransferHandler similar to the one described above. It can wrap the one in Java and use part of the methods. 
     74   * It will be responsible for: 
     75    * initiating a drag. 
     76    * accepting a drop. 
     77    * changing the cursor. 
     78    * dropping something. 
     79 * Wrapping the !TransferHandler in Java will help us with the cursor and the drag and drop gestures. 
     80 * We need to following methods to perform a drag and drop operation: 
     81  * protected abstract boolean canDropIn(Transferable transferable); - should tell whether a drop is acceptable provided a Transferable with a !DataFlavor. 
     82  * protected abstract boolean dropIn(Transferable transferable, DropLocation dropLocation, int dropAction); - should perform the actual drop. The Data is contained in the Transferable. 
     83  * protected abstract Transferable createTransferable(); - creates the actual Transferable. 
     84  * protected abstract void transferDone(Transferable data, int action); - invoked after the transfer has been performed. 
     85  * The !SophieTransferHandler should be provided a JComponent and set such so that Drad and Drop gestures are recognized from it. 
     86 * Transferring of data will be done by creating Transferables. 
     87 * !SophieTransferHandler should be extended and defined for most UI components that support drag and drop (Palettes, BookDesktop etc.) - for example in an inner class and an !AutoProperty that depends on the JComponent of a Palette one can create a handler and latter change the Palette's model if a drop operation is performed. 
     88 
     89== Transferables == 
     90 * provides information about the drag operation. 
     91  * type of data transferred - through !DataFlavor constants. 
     92  * may provide more than one type of data, depending on the number of !DataFlavors supported. 
     93 * contains the data transferred - obtained through the !DataFlavor. 
     94 * We should define several Transferables: 
     95  * !FileTransferable - responsible for Transferring of files. Transferring of files between the OS and Sophie will not create such but it will be useful for transferring inside Sophie. 
     96  * !ResourceTransferable - it should have some implementing classes for pages, frames etc. 
     97  * we may later need to define more. 
     98 
     99== DataFlavor == 
     100 * Used to unify the types of data a drag and drop operation should deal with. 
     101 * There are some !DataFlavors defined in the Java library. 
     102 * For some things we need to define !DataFlavors. 
     103  * !FrameResources. 
     104  * !BookResources. 
     105  * and other depending on what other drag and drop operations will be implemented. 
     106   
     107 ''' Note: Some !DataFlavors are not created properly in different platforms despite the idea of being so. For example dragging and dropping of files works fine on windows (the system uses the DataFlavor.javaFileListFlavor flavor) while it does not in gnome (creating different flavor usually with text/uri-list mime type). So be careful when using the Transferables and !DataFlavors.''' 
     108 
    59109= Implementation = 
    60110^(Implementation results should be described and linked here (from the wiki or the repository))^