Search in sources :

Example 1 with WorkspacePopupMenu

use of org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu in project freeplane by freeplane.

the class AWorkspaceAction method getSelectedNodes.

protected AWorkspaceTreeNode[] getSelectedNodes(ActionEvent e) {
    JTree tree = null;
    if (e.getSource() instanceof JTree) {
        tree = (JTree) e.getSource();
    } else {
        WorkspacePopupMenu pop = getRootPopupMenu((Component) e.getSource());
        if (pop == null) {
            return null;
        }
        tree = (JTree) pop.getInvoker();
    }
    AWorkspaceTreeNode[] nodes = new AWorkspaceTreeNode[tree.getSelectionPaths().length];
    int i = 0;
    for (TreePath path : tree.getSelectionPaths()) {
        nodes[i++] = (AWorkspaceTreeNode) path.getLastPathComponent();
    }
    return nodes;
}
Also used : JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) TreePath(javax.swing.tree.TreePath) WorkspacePopupMenu(org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)

Example 2 with WorkspacePopupMenu

use of org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu in project freeplane by freeplane.

the class AWorkspaceAction method getNodeFromActionEvent.

protected AWorkspaceTreeNode getNodeFromActionEvent(ActionEvent e) {
    JTree tree = null;
    TreePath path = null;
    if (e.getSource() instanceof JTree) {
        tree = (JTree) e.getSource();
        path = tree.getSelectionPath();
    } else {
        WorkspacePopupMenu pop = getRootPopupMenu((Component) e.getSource());
        if (pop == null) {
            return null;
        }
        tree = (JTree) pop.getInvoker();
        int x = pop.getInvokerLocation().x;
        int y = pop.getInvokerLocation().y;
        path = tree.getClosestPathForLocation(x, y);
    }
    if (path == null) {
        return null;
    }
    return (AWorkspaceTreeNode) path.getLastPathComponent();
}
Also used : JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) TreePath(javax.swing.tree.TreePath) WorkspacePopupMenu(org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)

Example 3 with WorkspacePopupMenu

use of org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu in project freeplane by freeplane.

the class LinkTypeFileNode method initializePopup.

public void initializePopup() {
    if (popupMenu == null) {
        popupMenu = new WorkspacePopupMenu();
        WorkspacePopupMenuBuilder.addActions(popupMenu, new String[] { "workspace.action.node.cut", "workspace.action.node.copy", "workspace.action.node.paste", WorkspacePopupMenuBuilder.SEPARATOR, "workspace.action.node.rename", "workspace.action.node.remove", "workspace.action.file.delete", WorkspacePopupMenuBuilder.SEPARATOR, "workspace.action.node.refresh" });
    }
}
Also used : WorkspacePopupMenu(org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)

Example 4 with WorkspacePopupMenu

use of org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu in project freeplane by freeplane.

the class DefaultFileNode method initializePopup.

public void initializePopup() {
    if (popupMenu == null) {
        popupMenu = new WorkspacePopupMenu();
        WorkspacePopupMenuBuilder.addActions(popupMenu, new String[] { "workspace.action.node.cut", "workspace.action.node.copy", "workspace.action.node.paste", WorkspacePopupMenuBuilder.SEPARATOR, "workspace.action.node.rename", "workspace.action.file.delete", WorkspacePopupMenuBuilder.SEPARATOR, "workspace.action.node.refresh" });
    }
}
Also used : WorkspacePopupMenu(org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)

Example 5 with WorkspacePopupMenu

use of org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu in project freeplane by freeplane.

the class AWorkspaceTreeNode method showPopup.

public void showPopup(Component component, int x, int y) {
    final WorkspacePopupMenu popupMenu = getContextMenu();
    if (popupMenu == null) {
        return;
    }
    popupMenu.setInvokerLocation(new Point(x, y));
    if (popupMenu != null) {
        popupMenu.show(component, x, y);
    }
}
Also used : Point(java.awt.Point) WorkspacePopupMenu(org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)

Aggregations

WorkspacePopupMenu (org.freeplane.plugin.workspace.components.menu.WorkspacePopupMenu)12 JTree (javax.swing.JTree)3 TreePath (javax.swing.tree.TreePath)2 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)2 Point (java.awt.Point)1