Search in sources :

Example 1 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class Slide method applySelection.

private void applySelection() {
    if (selectedNodeIds.isEmpty())
        return;
    ArrayList<NodeModel> selectedNodes = getSelectedNodes(true);
    final boolean displaysAllSlideNodes = displaysAllSlideNodes();
    final boolean selectsAllVisibleNodes = displaysAllSlideNodes && showsOnlySpecificNodes && mapViewManager.isSpotlightEnabled();
    final boolean replacesSelectionBySelectedNodes = !(selectsAllVisibleNodes || showsOnlySpecificNodes || selectedNodes.isEmpty());
    if (!replacesSelectionBySelectedNodes && !foldsNodes() && displaysAllSlideNodes) {
        for (NodeModel node : selectedNodes) {
            displayOnCurrentView(node);
            if (showsDescendants)
                displayDescendantsOnCurrentView(node);
        }
    }
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    if (replacesSelectionBySelectedNodes) {
        NodeModel[] nodes = selectedNodes.toArray(new NodeModel[] {});
        selection.replaceSelection(nodes);
    }
    if (showsOnlySpecificNodes) {
        final NodeModel firstNode = selectedNodes.get(0);
        selection.selectAsTheOnlyOneSelected(firstNode);
    }
    if (selectsAllVisibleNodes) {
        if (showsAncestors) {
            final NodeModel rootNode = selection.getSelected().getMap().getRootNode();
            selection.selectBranch(rootNode, true);
        } else
            for (NodeModel node : selectedNodes) selection.selectBranch(node, true);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 2 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class Slide method placeSelectedNode.

private void placeSelectedNode() {
    if (placedNodeId != null) {
        NodeModel placedNode = getCurrentPlacedNode();
        final IMapSelection selection = Controller.getCurrentController().getSelection();
        if (placedNode != null && placedNode != selection.getSelected()) {
            displayOnCurrentView(placedNode);
        }
        final boolean slowMotion = ResourceController.getResourceController().getBooleanProperty(PRESENTATION_SLOW_MOTION_KEY, false);
        if (slowMotion)
            selection.slowlyMoveNodeTo(placedNode, placedNodePosition);
        else
            selection.moveNodeTo(placedNode, placedNodePosition);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 3 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class SlideEditorController method createPlacesSelectedNodeToggleButton.

private JToggleButton createPlacesSelectedNodeToggleButton() {
    final JToggleButton checkBoxOnlySpecificNodes = createToggleButtonWithIconAndLabel("PlaceSelectedNodeOnSlide.icon", "slide.placenode");
    checkBoxOnlySpecificNodes.setAlignmentX(Component.CENTER_ALIGNMENT);
    checkBoxOnlySpecificNodes.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String centeredNodeId = slide.getPlacedNodeId();
            final IMapSelection selection = Controller.getCurrentController().getSelection();
            if (centeredNodeId == null) {
                final NodeModel selected = selection.getSelected();
                if (selected != null) {
                    UndoableSlide.of(slide).setPlacedNodeId(selected.getID());
                    setNodePlacementControlsEnabled(true, slide.getPlacedNodePosition());
                } else {
                    UndoableSlide.of(slide).setPlacedNodeId(null);
                    setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                }
            } else {
                UndoableSlide.of(slide).setPlacedNodeId(null);
                setNodePlacementControlsEnabled(false, slide.getPlacedNodePosition());
                final MapModel map = Controller.getCurrentController().getMap();
                final NodeModel node = map.getNodeForID(centeredNodeId);
                if (node != null)
                    selection.selectAsTheOnlyOneSelected(node);
            }
            checkBoxOnlySpecificNodes.setSelected(slide.getPlacedNodeId() != null);
        }
    });
    return checkBoxOnlySpecificNodes;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 4 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class MoveToRootAction method actionPerformed.

public void actionPerformed(final ActionEvent event) {
    Controller ctrl = Controller.getCurrentController();
    final IMapSelection selection = ctrl.getSelection();
    if (selection != null) {
        final NodeView selectedComponent = (NodeView) ctrl.getMapViewManager().getSelectedComponent();
        if (!selectedComponent.focused() && java.awt.EventQueue.getCurrentEvent() instanceof KeyEvent)
            selectedComponent.requestFocusInWindow();
        else
            selection.selectRoot();
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) IMapSelection(org.freeplane.features.map.IMapSelection) NodeView(org.freeplane.view.swing.map.NodeView)

Example 5 with IMapSelection

use of org.freeplane.features.map.IMapSelection in project freeplane by freeplane.

the class PersistentNodeHook method getSelectedNodes.

protected NodeModel[] getSelectedNodes() {
    final IMapSelection mapSelection = Controller.getCurrentController().getSelection();
    if (mapSelection != null) {
        final Collection<NodeModel> selection = mapSelection.getSelection();
        final int size = selection.size();
        final NodeModel[] nodes = new NodeModel[size];
        final Iterator<NodeModel> iterator = selection.iterator();
        int i = 0;
        while (iterator.hasNext()) {
            nodes[i++] = iterator.next();
        }
        return nodes;
    } else
        return new NodeModel[] {};
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Aggregations

IMapSelection (org.freeplane.features.map.IMapSelection)47 NodeModel (org.freeplane.features.map.NodeModel)33 Controller (org.freeplane.features.mode.Controller)12 ModeController (org.freeplane.features.mode.ModeController)12 ResourceController (org.freeplane.core.resources.ResourceController)7 MapController (org.freeplane.features.map.MapController)7 Component (java.awt.Component)6 MapModel (org.freeplane.features.map.MapModel)4 Container (java.awt.Container)3 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 MTextController (org.freeplane.features.text.mindmapmode.MTextController)3 NodeView (org.freeplane.view.swing.map.NodeView)3 Point (java.awt.Point)2 Window (java.awt.Window)2 WindowEvent (java.awt.event.WindowEvent)2 ArrayList (java.util.ArrayList)2 JComponent (javax.swing.JComponent)2 JPopupMenu (javax.swing.JPopupMenu)2 JRootPane (javax.swing.JRootPane)2