Search in sources :

Example 1 with IWorkspaceView

use of org.freeplane.plugin.workspace.components.IWorkspaceView in project freeplane by freeplane.

the class WorkspaceTransferHandler method drop.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
/* DropTarget Methods */
public final void drop(DropTargetDropEvent event) {
    IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
    if (view == null) {
        return;
    }
    TreePath targetPath = view.getPathForLocation(event.getLocation().x, event.getLocation().y);
    if (targetPath != null) {
        AWorkspaceTreeNode targetNode = (AWorkspaceTreeNode) targetPath.getLastPathComponent();
        if (processDrop(targetNode, event)) {
            return;
        }
    }
    event.rejectDrop();
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) TreePath(javax.swing.tree.TreePath) IWorkspaceView(org.freeplane.plugin.workspace.components.IWorkspaceView)

Example 2 with IWorkspaceView

use of org.freeplane.plugin.workspace.components.IWorkspaceView in project freeplane by freeplane.

the class NodeRefreshAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode[] targetNodes = getSelectedNodes(e);
    for (AWorkspaceTreeNode targetNode : targetNodes) {
        if (targetNode == null) {
            targetNode = WorkspaceController.getCurrentModel().getRoot();
        } else {
            targetNode.refresh();
        }
    }
    IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
    if (view != null) {
        view.refreshView();
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) IWorkspaceView(org.freeplane.plugin.workspace.components.IWorkspaceView)

Example 3 with IWorkspaceView

use of org.freeplane.plugin.workspace.components.IWorkspaceView in project freeplane by freeplane.

the class WorkspaceCollapseAction method collapseAll.

private static void collapseAll(WorkspaceTreeModel model) {
    TreeNode root = (TreeNode) model.getRoot();
    IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
    TreePath rootPath = new TreePath(root);
    for (Enumeration<?> e = root.children(); e.hasMoreElements(); ) {
        TreeNode n = (TreeNode) e.nextElement();
        TreePath path = rootPath.pathByAddingChild(n);
        collapseAll(view, model, path);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) IWorkspaceView(org.freeplane.plugin.workspace.components.IWorkspaceView)

Example 4 with IWorkspaceView

use of org.freeplane.plugin.workspace.components.IWorkspaceView in project freeplane by freeplane.

the class VirtualFolderDropHandler method processDrop.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
@SuppressWarnings("unchecked")
public boolean processDrop(AWorkspaceTreeNode targetNode, Transferable transferable, int dropAction) {
    try {
        if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR)) {
            processWorkspaceNodeDrop(targetNode, (List<AWorkspaceTreeNode>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR), dropAction);
        } else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR)) {
            processFileListDrop(targetNode, (List<File>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR), dropAction);
        } else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR)) {
            ArrayList<URI> uriList = new ArrayList<URI>();
            String uriString = (String) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR);
            if (!uriString.startsWith("file://")) {
                return false;
            }
            String[] uriArray = uriString.split("\r\n");
            for (String singleUri : uriArray) {
                try {
                    uriList.add(URIUtils.createURI(singleUri));
                } catch (Exception e) {
                    LogUtils.info("org.freeplane.plugin.workspace.mindmapmode.VirtualFolderDropHandler.processDrop(targetNode, transferable, dropAction)@1:" + e.getMessage());
                }
            }
            processUriListDrop(targetNode, uriList, dropAction);
        }
        targetNode.refresh();
        IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
        if (view != null) {
            view.expandPath(targetNode.getTreePath());
            WorkspaceController.getCurrentModeExtension().getView().refreshView();
        }
    } catch (Exception e) {
        LogUtils.warn("org.freeplane.plugin.workspace.mindmapmode.VirtualFolderDropHandler.processDrop(targetNode, transferable, dropAction)@2", e);
    }
    return true;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IWorkspaceView(org.freeplane.plugin.workspace.components.IWorkspaceView) URI(java.net.URI)

Example 5 with IWorkspaceView

use of org.freeplane.plugin.workspace.components.IWorkspaceView in project freeplane by freeplane.

the class FileFolderDropHandler method processDrop.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
@SuppressWarnings("unchecked")
public boolean processDrop(AWorkspaceTreeNode targetNode, Transferable transferable, int dropAction) {
    try {
        if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR)) {
            processWorkspaceNodeDrop(targetNode, (List<AWorkspaceTreeNode>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR), dropAction);
        } else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR)) {
            processFileListDrop(targetNode, (List<File>) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_FILE_LIST_FLAVOR), dropAction);
        } else if (transferable.isDataFlavorSupported(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR)) {
            ArrayList<URI> uriList = new ArrayList<URI>();
            String uriString = (String) transferable.getTransferData(WorkspaceTransferable.WORKSPACE_URI_LIST_FLAVOR);
            if (!uriString.startsWith("file://")) {
                return false;
            }
            String[] uriArray = uriString.split("\r\n");
            for (String singleUri : uriArray) {
                try {
                    uriList.add(URIUtils.createURI(singleUri));
                } catch (Exception e) {
                    LogUtils.info("org.freeplane.plugin.workspace.mindmapmode.FolderFileDropHandler.processDrop(targetNode, transferable, dropAction)@1" + e.getMessage());
                }
            }
            processUriListDrop(targetNode, uriList, dropAction);
        }
        targetNode.refresh();
        IWorkspaceView view = WorkspaceController.getCurrentModeExtension().getView();
        if (view != null) {
            view.expandPath(targetNode.getTreePath());
            WorkspaceController.getCurrentModeExtension().getView().refreshView();
        }
    } catch (Exception e) {
        LogUtils.warn("org.freeplane.plugin.workspace.mindmapmode.FolderFileDropHandler.processDrop(targetNode, transferable, dropAction)@2", e);
    }
    return true;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IWorkspaceView(org.freeplane.plugin.workspace.components.IWorkspaceView) URI(java.net.URI) IOException(java.io.IOException) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException)

Aggregations

IWorkspaceView (org.freeplane.plugin.workspace.components.IWorkspaceView)5 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)4 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 TreePath (javax.swing.tree.TreePath)2 IOException (java.io.IOException)1 TreeNode (javax.swing.tree.TreeNode)1 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)1