Search in sources :

Example 31 with NodeView

use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.

the class DefaultNodeMouseMotionListener method mouseClicked.

public void mouseClicked(final MouseEvent e) {
    final ModeController mc = Controller.getCurrentController().getModeController();
    if (Compat.isMacOsX()) {
        final JPopupMenu popupmenu = mc.getUserInputListenerFactory().getNodePopupMenu();
        if (popupmenu.isShowing()) {
            return;
        }
    }
    final MainView component = (MainView) e.getComponent();
    NodeView nodeView = component.getNodeView();
    if (nodeView == null)
        return;
    final NodeModel node = nodeView.getModel();
    final boolean plainEvent = Compat.isPlainEvent(e);
    final boolean inside = nodeSelector.isInside(e);
    final MapController mapController = mc.getMapController();
    if (e.getButton() == 1) {
        if (plainEvent) {
            if (component.isInFollowLinkRegion(e.getX())) {
                LinkController.getController(mc).loadURL(node, e);
                e.consume();
                return;
            }
            final String link = component.getLink(e.getPoint());
            if (link != null) {
                doubleClickTimer.start(new Runnable() {

                    public void run() {
                        loadLink(link);
                    }
                });
                e.consume();
                return;
            }
            if (inside && e.getClickCount() == 1 && ResourceController.getResourceController().getBooleanProperty(FOLD_ON_CLICK_INSIDE)) {
                final boolean fold = FoldingMark.UNFOLDED.equals(component.foldingMarkType(mapController, node)) && !mapController.hasHiddenChildren(node);
                if (!nodeSelector.shouldSelectOnClick(e)) {
                    doubleClickTimer.start(new Runnable() {

                        public void run() {
                            mapController.setFolded(node, fold);
                        }
                    });
                }
            }
        } else if (Compat.isShiftEvent(e)) {
            if (isInFoldingRegion(e)) {
                if (!mapController.showNextChild(node))
                    mapController.setFolded(node, true);
                e.consume();
            }
        }
    }
    final boolean inFoldingRegion = isInFoldingRegion(e);
    if ((plainEvent && inFoldingRegion || (inFoldingRegion || inside) && Compat.isCtrlShiftEvent(e)) && !nodeSelector.shouldSelectOnClick(e)) {
        boolean fold = FoldingMark.UNFOLDED.equals(component.foldingMarkType(mapController, node)) && !mapController.hasHiddenChildren(node);
        doubleClickTimer.cancel();
        mapController.setFolded(node, fold);
        e.consume();
        return;
    }
    if (inside && e.getButton() == 1 && !e.isAltDown())
        nodeSelector.extendSelection(e);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) JPopupMenu(javax.swing.JPopupMenu) MapController(org.freeplane.features.map.MapController)

Example 32 with NodeView

use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.

the class NodePopupMenuDisplayer method showNodePopupMenu.

public void showNodePopupMenu(final MouseEvent e) {
    if (e.isPopupTrigger()) {
        ModeController mc = Controller.getCurrentController().getModeController();
        final NodeView nodeView = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, e.getComponent());
        if (nodeView == null)
            return;
        if (!nodeView.isSelected()) {
            Controller.getCurrentController().getSelection().selectAsTheOnlyOneSelected(nodeView.getModel());
        }
        final JPopupMenu popupmenu = mc.getUserInputListenerFactory().getNodePopupMenu();
        new NodePopupMenuDisplayer().showMenuAndConsumeEvent(popupmenu, e);
    }
}
Also used : ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) JPopupMenu(javax.swing.JPopupMenu)

Example 33 with NodeView

use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.

the class DefaultNodeKeyListener method keyPressed.

public void keyPressed(final KeyEvent e) {
    final boolean checkForScrollMap = e.isShiftDown() && e.isControlDown() && e.isAltDown();
    final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    if (mapView == null || SwingUtilities.isDescendingFrom(mapView, e.getComponent()))
        return;
    if (checkForScrollMap) {
        switch(e.getKeyCode()) {
            case KeyEvent.VK_UP:
                mapView.scrollBy(0, -10);
                e.consume();
                return;
            case KeyEvent.VK_DOWN:
                mapView.scrollBy(0, 10);
                e.consume();
                return;
            case KeyEvent.VK_LEFT:
                mapView.scrollBy(-10, 0);
                e.consume();
                return;
            case KeyEvent.VK_RIGHT:
                mapView.scrollBy(10, 0);
                e.consume();
        }
        return;
    }
    if ((e.isAltDown() || e.isControlDown() || e.isMetaDown())) {
        return;
    }
    switch(e.getKeyCode()) {
        case KeyEvent.VK_ENTER:
        case KeyEvent.VK_ESCAPE:
        case KeyEvent.VK_SHIFT:
        case KeyEvent.VK_DELETE:
        case KeyEvent.VK_SPACE:
        case KeyEvent.VK_INSERT:
        case KeyEvent.VK_TAB:
            return;
    }
    final boolean continious = e.isShiftDown();
    switch(e.getKeyCode()) {
        case KeyEvent.VK_UP:
            if (mapView.selectUp(continious))
                e.consume();
            return;
        case KeyEvent.VK_DOWN:
            if (mapView.selectDown(continious))
                e.consume();
            return;
        case KeyEvent.VK_LEFT:
            if (mapView.selectLeft(continious))
                e.consume();
            return;
        case KeyEvent.VK_RIGHT:
            if (mapView.selectRight(continious))
                e.consume();
            return;
        case KeyEvent.VK_PAGE_UP:
            if (mapView.selectPageUp(continious))
                e.consume();
            return;
        case KeyEvent.VK_PAGE_DOWN:
            if (mapView.selectPageDown(continious))
                e.consume();
            return;
        case KeyEvent.VK_HOME:
        case KeyEvent.VK_END:
        case KeyEvent.VK_BACK_SPACE:
            if (editHandler != null) {
                editHandler.edit(e, FirstAction.EDIT_CURRENT, false);
            }
            return;
        case KeyEvent.VK_CONTEXT_MENU:
            final ModeController modeController = Controller.getCurrentModeController();
            final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
            final NodeView nodeView = mapView.getNodeView(node);
            final JPopupMenu popupmenu = modeController.getUserInputListenerFactory().getNodePopupMenu();
            if (popupmenu != null) {
                popupmenu.addHierarchyListener(new ControllerPopupMenuListener());
                final MainView mainView = nodeView.getMainView();
                popupmenu.show(mainView, mainView.getX(), mainView.getY());
            }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ControllerPopupMenuListener(org.freeplane.core.ui.ControllerPopupMenuListener) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) ModeController(org.freeplane.features.mode.ModeController) NodeView(org.freeplane.view.swing.map.NodeView) JPopupMenu(javax.swing.JPopupMenu)

Example 34 with NodeView

use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.

the class NodeSelector method extendSelection.

public void extendSelection(final MouseEvent e) {
    final Controller controller = Controller.getCurrentController();
    final NodeView nodeView = getRelatedNodeView(e);
    final NodeModel newlySelectedNode = nodeView.getModel();
    final boolean extend = Compat.isMacOsX() ? e.isMetaDown() : e.isControlDown();
    final boolean range = e.isShiftDown();
    final IMapSelection selection = controller.getSelection();
    if (range && !extend) {
        selection.selectContinuous(newlySelectedNode);
    } else if (extend && !range) {
        selection.toggleSelected(newlySelectedNode);
    }
    if (extend == range) {
        if (selection.isSelected(newlySelectedNode) && selection.size() == 1 && FocusManager.getCurrentManager().getFocusOwner() instanceof MainView)
            return;
        else {
            selection.selectAsTheOnlyOneSelected(newlySelectedNode);
        }
        e.consume();
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) IMapSelection(org.freeplane.features.map.IMapSelection) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) NodeView(org.freeplane.view.swing.map.NodeView)

Example 35 with NodeView

use of org.freeplane.view.swing.map.NodeView in project freeplane by freeplane.

the class ConnectorView method getModeController.

private ModeController getModeController() {
    NodeView nodeView = source;
    if (source == null) {
        nodeView = target;
    }
    final MapView mapView = nodeView.getMap();
    return mapView.getModeController();
}
Also used : MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView)

Aggregations

NodeView (org.freeplane.view.swing.map.NodeView)43 NodeModel (org.freeplane.features.map.NodeModel)20 MapView (org.freeplane.view.swing.map.MapView)17 ModeController (org.freeplane.features.mode.ModeController)14 MainView (org.freeplane.view.swing.map.MainView)11 Point (java.awt.Point)8 INodeView (org.freeplane.features.map.INodeView)8 Controller (org.freeplane.features.mode.Controller)6 JPopupMenu (javax.swing.JPopupMenu)5 ResourceController (org.freeplane.core.resources.ResourceController)5 MapController (org.freeplane.features.map.MapController)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)5 Dimension (java.awt.Dimension)4 MTextController (org.freeplane.features.text.mindmapmode.MTextController)4 Color (java.awt.Color)3 Component (java.awt.Component)3 JComponent (javax.swing.JComponent)3 IMapSelection (org.freeplane.features.map.IMapSelection)3 LocationController (org.freeplane.features.nodelocation.LocationController)3 MLocationController (org.freeplane.features.nodelocation.mindmapmode.MLocationController)3