Search in sources :

Example 21 with MainView

use of org.freeplane.view.swing.map.MainView 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 22 with MainView

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

the class GlassPaneNodeSelector method mouseClicked.

public void mouseClicked(MouseEvent e) {
    if (e.getButton() != 1) {
        return;
    }
    final Component component = findMapComponent(e);
    if (!(component instanceof MainView)) {
        return;
    }
    MainView mainView = (MainView) component;
    final NodeModel model = mainView.getNodeView().getModel();
    switch(e.getClickCount()) {
        case 1:
            final MapController mapController = Controller.getCurrentModeController().getMapController();
            mapController.setFolded(model, !model.isFolded());
            break;
        case 2:
            nodeSelector.nodeSelected(model);
            break;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MainView(org.freeplane.view.swing.map.MainView) Component(java.awt.Component) MapController(org.freeplane.features.map.MapController)

Example 23 with MainView

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

the class GlassPaneNodeSelector method findMapComponent.

// A basic implementation of redispatching events.
private Component findMapComponent(MouseEvent e) {
    final Component glassPane = e.getComponent();
    final Point glassPanePoint = e.getPoint();
    final Container container = SwingUtilities.getRootPane(glassPane).getContentPane();
    Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, container);
    Component component = SwingUtilities.getDeepestComponentAt(container, containerPoint.x, containerPoint.y);
    if (component instanceof MainView || component instanceof MapView || component instanceof JScrollBar) {
        return component;
    }
    return SwingUtilities.getAncestorOfClass(MapView.class, component);
}
Also used : Container(java.awt.Container) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) Point(java.awt.Point) Component(java.awt.Component) JScrollBar(javax.swing.JScrollBar)

Example 24 with MainView

use of org.freeplane.view.swing.map.MainView 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 25 with MainView

use of org.freeplane.view.swing.map.MainView 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)

Aggregations

MainView (org.freeplane.view.swing.map.MainView)26 NodeView (org.freeplane.view.swing.map.NodeView)11 NodeModel (org.freeplane.features.map.NodeModel)10 ModeController (org.freeplane.features.mode.ModeController)9 MapView (org.freeplane.view.swing.map.MapView)9 Point (java.awt.Point)7 MapController (org.freeplane.features.map.MapController)6 Controller (org.freeplane.features.mode.Controller)5 Component (java.awt.Component)4 ResourceController (org.freeplane.core.resources.ResourceController)4 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 Dimension (java.awt.Dimension)3 Rectangle (java.awt.Rectangle)3 MTextController (org.freeplane.features.text.mindmapmode.MTextController)3 Color (java.awt.Color)2 Cursor (java.awt.Cursor)2 Transferable (java.awt.datatransfer.Transferable)2 JPopupMenu (javax.swing.JPopupMenu)2 LinkController (org.freeplane.features.link.LinkController)2 LocationController (org.freeplane.features.nodelocation.LocationController)2