Search in sources :

Example 36 with AWorkspaceTreeNode

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

the class InputController method initActionKeyMap.

/**
 *******
 * Keyboard events
 */
private void initActionKeyMap() {
    actionKeyMap.put(new HotKeyIdentifier("copy", KeyStroke.getKeyStroke(KeyEvent.VK_C, /*KeyEvent.CTRL_DOWN_MASK*/
    Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())), NodeCopyAction.KEY);
    actionKeyMap.put(new HotKeyIdentifier("cut", KeyStroke.getKeyStroke(KeyEvent.VK_X, /*KeyEvent.CTRL_DOWN_MASK*/
    Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())), NodeCutAction.KEY);
    actionKeyMap.put(new HotKeyIdentifier("paste", KeyStroke.getKeyStroke(KeyEvent.VK_V, /*KeyEvent.CTRL_DOWN_MASK*/
    Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new KeyEventAcceptor() {

        public boolean accept(KeyEvent e) {
            TreePath path = ((JTree) e.getSource()).getSelectionPath();
            if (path == null) {
                return false;
            }
            AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
            if (DnDController.isDropAllowed(node)) {
                return true;
            }
            return false;
        }
    }), NodePasteAction.KEY);
    actionKeyMap.put(new HotKeyIdentifier("delete", KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), new KeyEventAcceptor() {

        public boolean accept(KeyEvent e) {
            TreePath path = ((JTree) e.getSource()).getSelectionPath();
            if (path == null) {
                return false;
            }
            AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
            if (!node.isSystem() && node.isTransferable()) {
                return true;
            }
            return false;
        }
    }), NodeRemoveAction.KEY);
    actionKeyMap.put(new HotKeyIdentifier("rename", KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), new KeyEventAcceptor() {

        public boolean accept(KeyEvent event) {
            TreePath path = ((JTree) event.getSource()).getSelectionPath();
            if (path == null) {
                return false;
            }
            AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
            if (!node.isSystem()) {
                return true;
            }
            return false;
        }
    }), NodeRenameAction.KEY);
    actionKeyMap.put(new HotKeyIdentifier("refresh", KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)), NodeRefreshAction.KEY);
}
Also used : KeyEvent(java.awt.event.KeyEvent) JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) TreePath(javax.swing.tree.TreePath)

Example 37 with AWorkspaceTreeNode

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

the class VirtualFolderDropHandler method processWorkspaceNodeDrop.

/**
 *********************************************************************************
 * CONSTRUCTORS
 *********************************************************************************
 */
/**
 *********************************************************************************
 * METHODS
 *********************************************************************************
 */
private void processWorkspaceNodeDrop(AWorkspaceTreeNode targetNode, List<AWorkspaceTreeNode> nodes, int dropAction) {
    try {
        for (AWorkspaceTreeNode node : nodes) {
            AWorkspaceTreeNode newNode = null;
            if (node instanceof DefaultFileNode) {
                newNode = createFSNodeLinks(targetNode, ((DefaultFileNode) node).getFile());
            } else {
                if (dropAction == DnDConstants.ACTION_COPY) {
                    newNode = node.clone();
                } else if (dropAction == DnDConstants.ACTION_MOVE) {
                    AWorkspaceTreeNode parent = node.getParent();
                    targetNode.getModel().cutNodeFromParent(node);
                    parent.refresh();
                    newNode = node;
                }
            }
            if (newNode == null) {
                continue;
            }
            targetNode.getModel().addNodeTo(newNode, targetNode);
        // WorkspaceController.getController().getExpansionStateHandler().addPathKey(this.getKey());
        }
    // WorkspaceUtils.saveCurrentConfiguration();
    } catch (Exception e) {
        LogUtils.warn(e);
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) DefaultFileNode(org.freeplane.plugin.workspace.nodes.DefaultFileNode)

Example 38 with AWorkspaceTreeNode

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

the class ProjectModel method removeFromIndexRecursively.

/**
 * @param node
 */
private void removeFromIndexRecursively(AWorkspaceTreeNode node) {
    List<AWorkspaceTreeNode> removes = new ArrayList<AWorkspaceTreeNode>();
    this.hashStringKeyIndex.remove(node.getKey());
    if (node.getChildCount() > 0) {
        int[] indices = new int[node.getChildCount()];
        for (int i = 0; i < node.getChildCount(); i++) {
            AWorkspaceTreeNode childNode = node.getChildAt(i);
            removeFromIndexRecursively(childNode);
            removes.add(childNode);
            indices[i] = i;
        }
        fireTreeNodesRemoved(this, node.getTreePath(), indices, removes.toArray());
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) ArrayList(java.util.ArrayList)

Example 39 with AWorkspaceTreeNode

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

the class ProjectModel method cutNodeFromParent.

/**
 * @param node
 */
public void cutNodeFromParent(AWorkspaceTreeNode node) {
    AWorkspaceTreeNode parent = node.getParent();
    removeFromIndexRecursively(node);
    parent.removeChild(node);
    fireTreeNodesRemoved(this, parent.getTreePath(), null, new Object[] { node });
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)

Example 40 with AWorkspaceTreeNode

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

the class FolderVirtualNode method getTransferable.

public WorkspaceTransferable getTransferable() {
    WorkspaceTransferable transferable = new WorkspaceTransferable();
    try {
        List<AWorkspaceTreeNode> objectList = new ArrayList<AWorkspaceTreeNode>();
        objectList.add(this);
        transferable.addData(WorkspaceTransferable.WORKSPACE_NODE_FLAVOR, objectList);
        return transferable;
    } catch (Exception e) {
        LogUtils.warn(e);
    }
    return null;
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) ArrayList(java.util.ArrayList) 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