Search in sources :

Example 46 with AWorkspaceTreeNode

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

the class NodeRenameAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode targetNode = this.getNodeFromActionEvent(e);
    String oldName = targetNode.getName();
    NodeRenameDialogPanel panel;
    // if (targetNode instanceof IMutableLinkNode) {
    // panel = new NodeRenameDialogPanel(oldName, true);
    // }
    // else {
    panel = new NodeRenameDialogPanel(oldName);
    if (targetNode instanceof DefaultFileNode) {
        panel.setCheckboxSelected(true);
    }
    // }
    int okButton = JOptionPane.showConfirmDialog(UITools.getFrame(), panel, TextUtils.getText("confirm_rename_file_action"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    String newName = panel.getText();
    if (okButton != JOptionPane.OK_OPTION || oldName.equals(newName)) {
        return;
    }
    if (newName != null) {
        if (targetNode instanceof IMutableLinkNode) {
            if (((IMutableLinkNode) targetNode).changeName(newName, panel.applyChangesForLink())) {
                targetNode.refresh();
            } else {
                JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file"), TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
                targetNode.setName(oldName);
            }
        } else {
            try {
                targetNode.getModel().changeNodeName(targetNode, newName);
                targetNode.refresh();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(UITools.getFrame(), TextUtils.getText("error_rename_file") + " (" + ex.getMessage() + ")", TextUtils.getText("error_rename_file_title"), JOptionPane.ERROR_MESSAGE);
            }
        }
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) IMutableLinkNode(org.freeplane.plugin.workspace.model.IMutableLinkNode) NodeRenameDialogPanel(org.freeplane.plugin.workspace.components.dialog.NodeRenameDialogPanel) DefaultFileNode(org.freeplane.plugin.workspace.nodes.DefaultFileNode)

Example 47 with AWorkspaceTreeNode

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

the class FileSystemManager method iterateDirectory.

private void iterateDirectory(AWorkspaceTreeNode parent, File directory, FileFilter filter, final boolean orderDescending) {
    boolean orderDesc = orderDescending;
    for (File file : sortFiles(directory.listFiles(new DirectoryFilter(filter)), orderDesc, true)) {
        AWorkspaceTreeNode newParent = createFileNode(parent, FileReadManager.DIRECTORY_HANDLE, file);
        iterateDirectory(newParent, file, filter, orderDesc);
    }
    for (File file : sortFiles(directory.listFiles(new FilesOnlyFilter(filter)), orderDesc, true)) {
        createFileNode(parent, file);
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) File(java.io.File)

Example 48 with AWorkspaceTreeNode

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

the class InputController method keyPressed.

public void keyPressed(KeyEvent e) {
    KeyStroke currentStroke = KeyStroke.getKeyStrokeForEvent(e);
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
        TreePath path = ((JTree) e.getSource()).getSelectionPath();
        if (path == null) {
            return;
        }
        AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
        if (node instanceof IWorkspaceNodeActionListener) {
            ((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT, 0, 0, e.getComponent()));
            e.consume();
        }
    } else {
        for (HotKeyIdentifier id : actionKeyMap.keySet()) {
            if (currentStroke.equals(id.getKeyStroke())) {
                if (id.accept(e)) {
                    AFreeplaneAction action = WorkspaceController.getAction(actionKeyMap.get(id));
                    if (action != null) {
                        action.actionPerformed(new ActionEvent(e.getSource(), 0, null));
                    } else {
                        LogUtils.info("No action set for: " + id.getKeyStroke());
                    }
                }
                e.consume();
                break;
            }
        }
    }
}
Also used : JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) TreePath(javax.swing.tree.TreePath) IWorkspaceNodeActionListener(org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) ActionEvent(java.awt.event.ActionEvent) KeyStroke(javax.swing.KeyStroke)

Example 49 with AWorkspaceTreeNode

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

the class NodeCopyAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    AWorkspaceTreeNode[] targetNodes = getSelectedNodes(e);
    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;
    }
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(transferable, new CopyClipboardOwner(transferable));
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) IWorkspaceTransferableCreator(org.freeplane.plugin.workspace.dnd.IWorkspaceTransferableCreator) WorkspaceTransferable(org.freeplane.plugin.workspace.dnd.WorkspaceTransferable)

Example 50 with AWorkspaceTreeNode

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

the class ActionCreator method getNode.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public AWorkspaceTreeNode getNode(XMLElement data) {
    String type = data.getAttribute("type", null);
    if (type == null || !creatorTable.containsKey(type)) {
        return null;
    }
    AWorkspaceNodeCreator creator = creatorTable.get(type);
    AWorkspaceTreeNode node = creator.getNode(data);
    return node;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) AWorkspaceNodeCreator(org.freeplane.plugin.workspace.model.AWorkspaceNodeCreator)

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