Class DataNodeTransferHandler

  • All Implemented Interfaces:
    java.io.Serializable

    public class DataNodeTransferHandler
    extends javax.swing.TransferHandler
    Handles transferable exports to and from from the DataNodeJTree.
    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

      • Fields inherited from class javax.swing.TransferHandler

        COPY, COPY_OR_MOVE, LINK, MOVE, NONE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canImport​(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavors)
      If we are configured to import data, return true, on the grounds that the DataNodeFactory should be able to have a go at turning almost anything into a DataNode.
      protected java.awt.datatransfer.Transferable createTransferable​(javax.swing.JComponent comp)  
      int getSourceActions​(javax.swing.JComponent comp)  
      javax.swing.Icon getVisualRepresentation​(java.awt.datatransfer.Transferable trans)  
      boolean importData​(javax.swing.JComponent comp, java.awt.datatransfer.Transferable trans)
      Attempts to import a transferable into the tree.
      void pasteSystemSelection​(javax.swing.JComponent comp)
      Pastes the system selection into the tree window.
      void setNodeMaker​(DataNodeFactory nodeMaker)
      Sets the DataNodeFactory which will be used by this handler to perform import of Transferables (convert them into DataNodes).
      • Methods inherited from class javax.swing.TransferHandler

        canImport, exportAsDrag, exportDone, exportToClipboard, getCopyAction, getCutAction, getDragImage, getDragImageOffset, getPasteAction, importData, setDragImage, setDragImageOffset
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DataNodeTransferHandler

        public DataNodeTransferHandler()
    • Method Detail

      • getSourceActions

        public int getSourceActions​(javax.swing.JComponent comp)
        Overrides:
        getSourceActions in class javax.swing.TransferHandler
      • getVisualRepresentation

        public javax.swing.Icon getVisualRepresentation​(java.awt.datatransfer.Transferable trans)
        Overrides:
        getVisualRepresentation in class javax.swing.TransferHandler
      • createTransferable

        protected java.awt.datatransfer.Transferable createTransferable​(javax.swing.JComponent comp)
        Overrides:
        createTransferable in class javax.swing.TransferHandler
      • setNodeMaker

        public void setNodeMaker​(DataNodeFactory nodeMaker)
        Sets the DataNodeFactory which will be used by this handler to perform import of Transferables (convert them into DataNodes). By default this is set to null; unless it is set to a non-null value, no node import will be permitted.
      • canImport

        public boolean canImport​(javax.swing.JComponent comp,
                                 java.awt.datatransfer.DataFlavor[] flavors)
        If we are configured to import data, return true, on the grounds that the DataNodeFactory should be able to have a go at turning almost anything into a DataNode. However, only do it if the drop position would not be over a node in the tree, since that might convey a false impression of what's going to happen (the node will get appended to the root).
        Overrides:
        canImport in class javax.swing.TransferHandler
      • importData

        public boolean importData​(javax.swing.JComponent comp,
                                  java.awt.datatransfer.Transferable trans)
        Attempts to import a transferable into the tree.
        Overrides:
        importData in class javax.swing.TransferHandler
      • pasteSystemSelection

        public void pasteSystemSelection​(javax.swing.JComponent comp)
        Pastes the system selection into the tree window. This behaviour is seen in JTextComponent and subclasses (see javax.swing.text.DefaultCaret for the implementation), but not elsewhere in the JFC; however I think it's quite useful, it means you can grab a text string and middle-click it on top of a window to load that URL (or whatever) in.

        This implementation only works with string-like contents of the selection. Short strings it feeds to the data node factory as Strings, and long ones it ignores.

        Parameters:
        comp - the component into which to paste