Search in sources :

Example 1 with IFileSystemRepresentation

use of org.freeplane.plugin.workspace.io.IFileSystemRepresentation in project freeplane by freeplane.

the class FileNodeNewMindmapAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    Controller.getCurrentController().selectMode(MModeController.MODENAME);
    AWorkspaceTreeNode targetNode = this.getNodeFromActionEvent(e);
    if (targetNode instanceof IFileSystemRepresentation) {
        String fileName = JOptionPane.showInputDialog(Controller.getCurrentController().getViewController().getContentPane(), TextUtils.getText("add_new_mindmap"), TextUtils.getText("add_new_mindmap_title"), JOptionPane.OK_CANCEL_OPTION);
        if (fileName != null && fileName.length() > 0) {
            if (!fileName.endsWith(".mm")) {
                fileName += ".mm";
            }
            File file = new File(((IFileSystemRepresentation) targetNode).getFile(), fileName);
            try {
                file = WorkspaceController.getFileSystemMgr().createFile(fileName, ((IFileSystemRepresentation) targetNode).getFile());
                if (createNewMindmap(file)) {
                    targetNode.refresh();
                }
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(UITools.getFrame(), ex.getMessage(), "Error ... ", JOptionPane.ERROR_MESSAGE);
                ex.printStackTrace();
            }
        }
    }
}
Also used : IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) File(java.io.File) XMLParseException(org.freeplane.n3.nanoxml.XMLParseException) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with IFileSystemRepresentation

use of org.freeplane.plugin.workspace.io.IFileSystemRepresentation in project freeplane by freeplane.

the class PhysicalFolderSortOrderAction method actionPerformed.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
/**
 */
public void actionPerformed(ActionEvent e) {
    AWorkspaceTreeNode targetNode = getNodeFromActionEvent(e);
    if (targetNode instanceof IFileSystemRepresentation) {
        if (this.isSelected() == ((IFileSystemRepresentation) targetNode).orderDescending()) {
            ((IFileSystemRepresentation) targetNode).orderDescending(!this.isSelected());
            targetNode.refresh();
        }
    }
}
Also used : IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 3 with IFileSystemRepresentation

use of org.freeplane.plugin.workspace.io.IFileSystemRepresentation in project freeplane by freeplane.

the class FileFolderDropHandler method processFileListDrop.

private void processFileListDrop(AWorkspaceTreeNode targetNode, List<File> files, int dropAction) {
    try {
        File targetDir = ((IFileSystemRepresentation) targetNode).getFile();
        FileSystemManager.copyFiles(files, targetDir, false);
    } catch (Exception e) {
        LogUtils.warn(e);
    }
    targetNode.refresh();
}
Also used : IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) File(java.io.File) IOException(java.io.IOException) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException)

Example 4 with IFileSystemRepresentation

use of org.freeplane.plugin.workspace.io.IFileSystemRepresentation in project freeplane by freeplane.

the class FileFolderDropHandler method processWorkspaceNodeDrop.

/**
 *********************************************************************************
 * CONSTRUCTORS
 *********************************************************************************
 */
/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
private void processWorkspaceNodeDrop(AWorkspaceTreeNode targetNode, List<AWorkspaceTreeNode> nodes, int dropAction) {
    try {
        File targetDir = ((IFileSystemRepresentation) targetNode).getFile();
        if (targetDir != null && targetDir.isDirectory()) {
            List<ITask> opList = new ArrayList<ITask>();
            for (AWorkspaceTreeNode node : nodes) {
                if (node instanceof DefaultFileNode) {
                    File srcFile = ((DefaultFileNode) node).getFile();
                    if (srcFile.equals(targetDir)) {
                        continue;
                    }
                    File destFile = new File(targetDir, srcFile.getName());
                    if (dropAction == DnDConstants.ACTION_COPY) {
                        FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
                    } else if (dropAction == DnDConstants.ACTION_MOVE) {
                        FileSystemManager.buildMoveOperationList(srcFile, destFile, opList);
                        opList.add(getPostOperation(targetNode, node, srcFile, destFile));
                    }
                } else if (node instanceof LinkTypeFileNode) {
                    File srcFile = URIUtils.getAbsoluteFile(((LinkTypeFileNode) node).getLinkURI());
                    if (srcFile.equals(targetDir)) {
                        continue;
                    }
                    File destFile = new File(targetDir, srcFile.getName());
                    FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
                    if (dropAction == DnDConstants.ACTION_MOVE) {
                        opList.add(getPostOperation(targetNode, node, srcFile, destFile));
                    }
                } else if (node instanceof FolderLinkNode) {
                    File srcFile = URIUtils.getAbsoluteFile(((FolderLinkNode) node).getPath());
                    if (srcFile.equals(targetDir)) {
                        continue;
                    }
                    File destFile = new File(targetDir, srcFile.getName());
                    FileSystemManager.buildCopyOperationList(srcFile, destFile, opList);
                    if (dropAction == DnDConstants.ACTION_MOVE) {
                        opList.add(getPostOperation(targetNode, node, srcFile, destFile));
                    }
                }
            }
            FileSystemManager.execOperations(opList);
        }
    } catch (Exception e) {
        LogUtils.warn(e);
    }
}
Also used : IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) ITask(org.freeplane.plugin.workspace.io.ITask) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) LinkTypeFileNode(org.freeplane.plugin.workspace.nodes.LinkTypeFileNode) ArrayList(java.util.ArrayList) File(java.io.File) DefaultFileNode(org.freeplane.plugin.workspace.nodes.DefaultFileNode) IOException(java.io.IOException) SkipTaskException(org.freeplane.plugin.workspace.io.SkipTaskException) FolderLinkNode(org.freeplane.plugin.workspace.nodes.FolderLinkNode)

Example 5 with IFileSystemRepresentation

use of org.freeplane.plugin.workspace.io.IFileSystemRepresentation in project freeplane by freeplane.

the class NodeNewFolderAction method actionPerformed.

/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public void actionPerformed(ActionEvent e) {
    AWorkspaceTreeNode targetNode = null;
    if (e == null || getRootPopupMenu((Component) e.getSource()) == null) {
        targetNode = WorkspaceController.getCurrentProject().getModel().getRoot();
    } else {
        targetNode = getNodeFromActionEvent(e);
    }
    if (targetNode == null) {
        return;
    }
    AWorkspaceProject project = WorkspaceController.getProject(targetNode);
    int mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_PHYSICAL;
    if (targetNode instanceof IFileSystemRepresentation) {
        mode = WorkspaceNewFolderPanel.MODE_VIRTUAL_ONLY;
    }
    WorkspaceNewFolderPanel dialog = new WorkspaceNewFolderPanel(mode, targetNode);
    int response = JOptionPane.showConfirmDialog(UITools.getFrame(), dialog, TextUtils.getText("workspace.action.node.new.folder.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    if (response == JOptionPane.OK_OPTION) {
        String value = dialog.getFolderName();
        if (value == null || value.trim().length() <= 0) {
            // WORKSPACE - ToDo: prepare message, or call this method (with error message) again?
            return;
        }
        if (dialog.isLinkedFolder()) {
            File path = new File(dialog.getLinkPath());
            if (path != null) {
                FolderLinkNode node = new FolderLinkNode();
                node.setName(value);
                URI uri = project.getRelativeURI(path.toURI());
                if (uri == null) {
                    node.setPath(path.toURI());
                } else {
                    node.setPath(uri);
                }
                targetNode.getModel().addNodeTo(node, targetNode);
                node.refresh();
            }
        } else {
            if (targetNode instanceof IFileSystemRepresentation) {
                try {
                    WorkspaceController.getFileSystemMgr().createDirectory(value, ((IFileSystemRepresentation) targetNode).getFile());
                } catch (IOException e1) {
                    JOptionPane.showMessageDialog(UITools.getFrame(), e1.getMessage());
                }
            } else {
                FolderVirtualNode node = new FolderVirtualNode();
                node.setName(value);
                targetNode.getModel().addNodeTo(node, targetNode);
            }
        }
        targetNode.refresh();
        targetNode.getModel().requestSave();
    }
}
Also used : AWorkspaceProject(org.freeplane.plugin.workspace.model.project.AWorkspaceProject) IFileSystemRepresentation(org.freeplane.plugin.workspace.io.IFileSystemRepresentation) FolderVirtualNode(org.freeplane.plugin.workspace.nodes.FolderVirtualNode) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) WorkspaceNewFolderPanel(org.freeplane.plugin.workspace.components.dialog.WorkspaceNewFolderPanel) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) FolderLinkNode(org.freeplane.plugin.workspace.nodes.FolderLinkNode)

Aggregations

IFileSystemRepresentation (org.freeplane.plugin.workspace.io.IFileSystemRepresentation)5 File (java.io.File)4 IOException (java.io.IOException)4 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)4 SkipTaskException (org.freeplane.plugin.workspace.io.SkipTaskException)2 FolderLinkNode (org.freeplane.plugin.workspace.nodes.FolderLinkNode)2 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 XMLParseException (org.freeplane.n3.nanoxml.XMLParseException)1 WorkspaceNewFolderPanel (org.freeplane.plugin.workspace.components.dialog.WorkspaceNewFolderPanel)1 ITask (org.freeplane.plugin.workspace.io.ITask)1 AWorkspaceProject (org.freeplane.plugin.workspace.model.project.AWorkspaceProject)1 DefaultFileNode (org.freeplane.plugin.workspace.nodes.DefaultFileNode)1 FolderVirtualNode (org.freeplane.plugin.workspace.nodes.FolderVirtualNode)1 LinkTypeFileNode (org.freeplane.plugin.workspace.nodes.LinkTypeFileNode)1