Search in sources :

Example 1 with TreeView

use of org.freeplane.plugin.workspace.components.TreeView in project freeplane by freeplane.

the class InputController method mouseClicked.

/**
 *********************************************************************************
 * REQUIRED METHODS FOR INTERFACES
 *********************************************************************************
 */
public void mouseClicked(MouseEvent e) {
    if (e.isConsumed()) {
        return;
    }
    TreePath path = ((JTree) e.getSource()).getClosestPathForLocation(e.getX(), e.getY());
    ((TreeView) WorkspaceController.getCurrentModeExtension().getView()).addSelectionPath(path);
    if (path != null) {
        AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
        // encode buttons
        int eventType = 0;
        if (e.getButton() == MouseEvent.BUTTON1) {
            eventType += WorkspaceActionEvent.MOUSE_LEFT;
        }
        if (e.getButton() == MouseEvent.BUTTON3) {
            eventType += WorkspaceActionEvent.MOUSE_RIGHT;
        }
        if (e.getClickCount() % 2 == 0) {
            eventType += WorkspaceActionEvent.MOUSE_DBLCLICK;
        } else {
            eventType += WorkspaceActionEvent.MOUSE_CLICK;
        }
        if (e.isPopupTrigger()) {
            eventType += WorkspaceActionEvent.POPUP_TRIGGER;
        }
        WorkspaceActionEvent event = new WorkspaceActionEvent(node, eventType, e.getX(), e.getY(), e.getComponent());
        List<IWorkspaceNodeActionListener> nodeEventListeners = WorkspaceController.getCurrentModeExtension().getIOController().getNodeActionListeners(node.getClass(), eventType);
        if (nodeEventListeners != null) {
            for (IWorkspaceNodeActionListener listener : nodeEventListeners) {
                if (event.isConsumed()) {
                    break;
                }
                listener.handleAction(event);
            }
        }
        if (!event.isConsumed() && node instanceof IWorkspaceNodeActionListener) {
            ((IWorkspaceNodeActionListener) node).handleAction(event);
        }
    } else {
        if (e.getButton() == MouseEvent.BUTTON3) {
            // WorkspaceController.getController().getPopups().showWorkspacePopup(e.getComponent(), e.getX(), e.getY());
            ((AWorkspaceTreeNode) WorkspaceController.getCurrentModel().getRoot()).showPopup(e.getComponent(), e.getX(), e.getY());
        }
    }
}
Also used : JTree(javax.swing.JTree) AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) TreePath(javax.swing.tree.TreePath) IWorkspaceNodeActionListener(org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) TreeView(org.freeplane.plugin.workspace.components.TreeView)

Example 2 with TreeView

use of org.freeplane.plugin.workspace.components.TreeView in project freeplane by freeplane.

the class MModeWorkspaceController method getWorkspaceView.

private TreeView getWorkspaceView() {
    if (this.view == null) {
        this.view = new TreeView();
        this.view.setMinimumSize(new Dimension(100, 40));
        this.view.setPreferredSize(new Dimension(150, 40));
        this.view.addProjectSelectionListener(getProjectSelectionListener());
        getModel();
    }
    return this.view;
}
Also used : TreeView(org.freeplane.plugin.workspace.components.TreeView) Dimension(java.awt.Dimension)

Aggregations

TreeView (org.freeplane.plugin.workspace.components.TreeView)2 Dimension (java.awt.Dimension)1 JTree (javax.swing.JTree)1 TreePath (javax.swing.tree.TreePath)1 IWorkspaceNodeActionListener (org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener)1 WorkspaceActionEvent (org.freeplane.plugin.workspace.event.WorkspaceActionEvent)1 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)1