Search in sources :

Example 6 with TransferredData

use of com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData in project sldeditor by robward-scisys.

the class TreeTransferHandler method exportDone.

/*
     * (non-Javadoc)
     * 
     * @see javax.swing.TransferHandler#exportDone(javax.swing.JComponent, java.awt.datatransfer.Transferable, int)
     */
@Override
protected void exportDone(JComponent source, Transferable data, int action) {
    if (!(source instanceof JTree) || (data == null)) {
        return;
    }
    JTree tree = (JTree) source;
    NodeInterface destinationTreeNode = (NodeInterface) tree.getLastSelectedPathComponent();
    DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
    DataFlavor destDataFlavour = destinationTreeNode.getDataFlavour();
    TransferredData transferredData = null;
    try {
        transferredData = (TransferredData) data.getTransferData(destDataFlavour);
    } catch (UnsupportedFlavorException e) {
        ConsoleManager.getInstance().exception(this, e);
    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }
    if (action == MOVE) {
        DataFlavourManager.deleteNodes(model, transferredData);
    }
    if (action != NONE) {
        DataFlavourManager.displayMessages(destinationTreeNode, transferredData, action);
    }
    setDragging(false);
}
Also used : JTree(javax.swing.JTree) TransferredData(com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) NodeInterface(com.sldeditor.common.NodeInterface) DataFlavor(java.awt.datatransfer.DataFlavor)

Aggregations

TransferredData (com.sldeditor.datasource.extension.filesystem.dataflavour.TransferredData)6 NodeInterface (com.sldeditor.common.NodeInterface)5 DataFlavor (java.awt.datatransfer.DataFlavor)4 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)4 IOException (java.io.IOException)4 TreePath (javax.swing.tree.TreePath)4 JTree (javax.swing.JTree)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 Test (org.junit.Test)2 SLDDataFlavour (com.sldeditor.datasource.extension.filesystem.dataflavour.SLDDataFlavour)1 TransferableDataItem (com.sldeditor.datasource.extension.filesystem.node.TransferableDataItem)1 FileTreeNode (com.sldeditor.datasource.extension.filesystem.node.file.FileTreeNode)1 Transferable (java.awt.datatransfer.Transferable)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 HashMap (java.util.HashMap)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1