Search in sources :

Example 21 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class VirtualFolderDropHandler method processFileListDrop.

private void processFileListDrop(AWorkspaceTreeNode targetNode, List<File> files, int dropAction) {
    try {
        for (File srcFile : files) {
            AWorkspaceTreeNode node = createFSNodeLinks(targetNode, srcFile);
            targetNode.getModel().addNodeTo(node, targetNode);
            node.refresh();
        }
    // WorkspaceUtils.saveCurrentConfiguration();
    } catch (Exception e) {
        LogUtils.warn(e);
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) File(java.io.File)

Example 22 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class FileSystemManager method createFileNode.

private AWorkspaceTreeNode createFileNode(final AWorkspaceTreeNode parent, String fileExtension, final File file) {
    List<IFileTypeHandler> handlers = getFileTypeHandlers().list(fileExtension);
    if (handlers == null) {
        fileExtension = FileReadManager.DEFAULT_HANDLE;
        handlers = getFileTypeHandlers().list(fileExtension);
    }
    if (handlers != null && handlers.size() == 1) {
        // WORKSPACE - ToDo: what if there is more than one handler for a single type?
        IFileTypeHandler nodeCreator = handlers.get(0);
        AWorkspaceTreeNode newParent = nodeCreator.createFileNode(parent, fileExtension, file);
        return newParent;
    }
    return parent;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 23 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class FileNodeDeleteAction method actionPerformed.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode node = this.getNodeFromActionEvent(e);
    int yesorno = JOptionPane.showConfirmDialog(UITools.getFrame(), TextUtils.format("workspace.action.file.delete.confirm.text", node.getName()), TextUtils.getText("workspace.action.file.delete.confirm.title"), JOptionPane.YES_NO_OPTION);
    if (yesorno == JOptionPane.OK_OPTION) {
        deleteFile(node);
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 24 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class FileNodeDeleteAction method deleteFile.

private void deleteFile(final AWorkspaceTreeNode node) {
    if (node instanceof DefaultFileNode) {
        ((DefaultFileNode) node).delete();
    } else if (node instanceof LinkTypeFileNode) {
        File file = URIUtils.getAbsoluteFile(((LinkTypeFileNode) node).getLinkURI());
        if (file != null) {
            if (!file.delete()) {
            // show message?
            }
        }
    }
    AWorkspaceTreeNode parent = node.getParent();
    node.getModel().removeNodeFromParent(node);
    parent.refresh();
    parent.getModel().requestSave();
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) LinkTypeFileNode(org.freeplane.plugin.workspace.nodes.LinkTypeFileNode) File(java.io.File) DefaultFileNode(org.freeplane.plugin.workspace.nodes.DefaultFileNode)

Example 25 with AWorkspaceTreeNode

use of org.freeplane.plugin.workspace.model.AWorkspaceTreeNode in project freeplane by freeplane.

the class NodeCutAction method actionPerformed.

public void actionPerformed(final ActionEvent event) {
    AWorkspaceTreeNode[] targetNodes = getSelectedNodes(event);
    WorkspaceTransferable transferable = null;
    for (AWorkspaceTreeNode targetNode : targetNodes) {
        if (targetNode instanceof IWorkspaceTransferableCreator) {
            if (transferable == null) {
                transferable = ((IWorkspaceTransferableCreator) targetNode).getTransferable();
            } else {
                transferable.merge(((IWorkspaceTransferableCreator) targetNode).getTransferable());
            }
        }
    }
    if (transferable == null) {
        return;
    }
    transferable.setAsCopy(false);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, new CutClipboardOwner(transferable));
// AWorkspaceTreeNode parent = targetNode.getParent();
// 
// targetNode.getModel().cutNodeFromParent(targetNode);
// if(parent != null) {
// parent.refresh();
// //parent.getModel().requestSave();
// }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) IWorkspaceTransferableCreator(org.freeplane.plugin.workspace.dnd.IWorkspaceTransferableCreator) WorkspaceTransferable(org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)

Aggregations

AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)51 File (java.io.File)13 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 WorkspaceTransferable (org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)7 TreePath (javax.swing.tree.TreePath)6 DefaultFileNode (org.freeplane.plugin.workspace.nodes.DefaultFileNode)6 JTree (javax.swing.JTree)5 IOException (java.io.IOException)4 IWorkspaceView (org.freeplane.plugin.workspace.components.IWorkspaceView)4 IFileSystemRepresentation (org.freeplane.plugin.workspace.io.IFileSystemRepresentation)4 LinkTypeFileNode (org.freeplane.plugin.workspace.nodes.LinkTypeFileNode)4 Vector (java.util.Vector)3 IWorkspaceNodeActionListener (org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener)3 WorkspaceActionEvent (org.freeplane.plugin.workspace.event.WorkspaceActionEvent)3 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)3 AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)3 FolderLinkNode (org.freeplane.plugin.workspace.nodes.FolderLinkNode)3 List (java.util.List)2 WorkspacePopupMenu (org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)2