Search in sources :

Example 1 with WorkspaceActionEvent

use of org.freeplane.plugin.workspace.event.WorkspaceActionEvent in project freeplane by freeplane.

the class ProjectModel method valueForPathChanged.

public void valueForPathChanged(TreePath path, Object newValue) {
    AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
    if (node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_CHANGED, newValue));
        nodeChanged(node);
    } else {
        node.setName(newValue.toString());
    }
}
Also used : AWorkspaceTreeNode(org.freeplane.plugin.workspace.model.AWorkspaceTreeNode) IWorkspaceNodeActionListener(org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent)

Example 2 with WorkspaceActionEvent

use of org.freeplane.plugin.workspace.event.WorkspaceActionEvent in project freeplane by freeplane.

the class WorkspaceModel method valueForPathChanged.

public void valueForPathChanged(TreePath path, Object newValue) {
    if (path == null || getRoot().equals(path.getLastPathComponent())) {
        return;
    }
    AWorkspaceTreeNode node = (AWorkspaceTreeNode) path.getLastPathComponent();
    if (node instanceof IWorkspaceNodeActionListener) {
        ((IWorkspaceNodeActionListener) node).handleAction(new WorkspaceActionEvent(node, WorkspaceActionEvent.WSNODE_CHANGED, newValue));
        ((ProjectModel) node.getModel()).nodeChanged(node);
    } else {
        node.setName(newValue.toString());
    }
}
Also used : IWorkspaceNodeActionListener(org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) ProjectModel(org.freeplane.plugin.workspace.model.project.ProjectModel)

Example 3 with WorkspaceActionEvent

use of org.freeplane.plugin.workspace.event.WorkspaceActionEvent 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 4 with WorkspaceActionEvent

use of org.freeplane.plugin.workspace.event.WorkspaceActionEvent in project freeplane by freeplane.

the class AActionNode method handleAction.

public void handleAction(WorkspaceActionEvent event) {
    if (event.getType() == WorkspaceActionEvent.WSNODE_OPEN_DOCUMENT) {
        AFreeplaneAction action = Controller.getCurrentController().getAction(getType());
        if (action == null) {
            LogUtils.severe("No action '" + getType() + "' found");
            return;
        }
        action.actionPerformed(new ActionEvent(this, 0, "execute"));
    } else if (event.getType() == WorkspaceActionEvent.MOUSE_RIGHT_CLICK) {
        showPopup((Component) event.getBaggage(), event.getX(), event.getY());
    }
}
Also used : AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) WorkspaceActionEvent(org.freeplane.plugin.workspace.event.WorkspaceActionEvent) Component(java.awt.Component)

Example 5 with WorkspaceActionEvent

use of org.freeplane.plugin.workspace.event.WorkspaceActionEvent 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)

Aggregations

WorkspaceActionEvent (org.freeplane.plugin.workspace.event.WorkspaceActionEvent)5 IWorkspaceNodeActionListener (org.freeplane.plugin.workspace.event.IWorkspaceNodeActionListener)4 AWorkspaceTreeNode (org.freeplane.plugin.workspace.model.AWorkspaceTreeNode)3 ActionEvent (java.awt.event.ActionEvent)2 JTree (javax.swing.JTree)2 TreePath (javax.swing.tree.TreePath)2 AFreeplaneAction (org.freeplane.core.ui.AFreeplaneAction)2 Component (java.awt.Component)1 KeyStroke (javax.swing.KeyStroke)1 TreeView (org.freeplane.plugin.workspace.components.TreeView)1 ProjectModel (org.freeplane.plugin.workspace.model.project.ProjectModel)1