Search in sources :

Example 31 with IMapSelection

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

the class Filter method selectVisibleNode.

private void selectVisibleNode() {
    final IMapSelection mapSelection = Controller.getCurrentController().getSelection();
    final Collection<NodeModel> selectedNodes = mapSelection.getSelection();
    final NodeModel[] array = new NodeModel[selectedNodes.size()];
    boolean next = false;
    for (NodeModel node : selectedNodes.toArray(array)) {
        if (next) {
            if (!node.isVisible()) {
                mapSelection.toggleSelected(node);
            }
        } else
            next = true;
    }
    NodeModel selected = mapSelection.getSelected();
    if (!selected.isVisible()) {
        if (mapSelection.getSelection().size() > 1) {
            mapSelection.toggleSelected(selected);
        } else
            mapSelection.selectAsTheOnlyOneSelected(selected.getVisibleAncestorOrSelf());
    }
    mapSelection.setSiblingMaxLevel(mapSelection.getSelected().getNodeLevel(false));
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 32 with IMapSelection

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

the class FindAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel start = selection.getSelected();
    if (editor == null) {
        editor = new FilterConditionEditor(FilterController.getCurrentFilterController());
        editor.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(5, 0, 5, 0)));
    } else {
        editor.mapChanged(start.getMap());
    }
    editor.addAncestorListener(new AncestorListener() {

        public void ancestorAdded(final AncestorEvent event) {
            final Component component = event.getComponent();
            final Window windowAncestor = SwingUtilities.getWindowAncestor(component);
            if (windowAncestor.isFocused())
                editor.focusInputField(true);
            else {
                windowAncestor.addWindowFocusListener(new WindowFocusListener() {

                    public void windowLostFocus(WindowEvent e) {
                    }

                    public void windowGainedFocus(WindowEvent e) {
                        windowAncestor.removeWindowFocusListener(this);
                        editor.focusInputField(true);
                    }
                });
                windowAncestor.toFront();
            }
            editor.removeAncestorListener(this);
        }

        public void ancestorMoved(final AncestorEvent event) {
        }

        public void ancestorRemoved(final AncestorEvent event) {
        }
    });
    final int run = UITools.showConfirmDialog(start, editor, TextUtils.getText("FindAction.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    final Container parent = editor.getParent();
    if (parent != null) {
        parent.remove(editor);
    }
    if (run != JOptionPane.OK_OPTION) {
        return;
    }
    final ASelectableCondition condition = editor.getCondition();
    findFirst(condition);
}
Also used : Window(java.awt.Window) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) IMapSelection(org.freeplane.features.map.IMapSelection) WindowEvent(java.awt.event.WindowEvent) AncestorListener(javax.swing.event.AncestorListener) Component(java.awt.Component) AncestorEvent(javax.swing.event.AncestorEvent) WindowFocusListener(java.awt.event.WindowFocusListener) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition)

Example 33 with IMapSelection

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

the class QuickFindAllAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ASelectableCondition condition = filterEditor.getCondition();
    if (condition == null) {
        return;
    }
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final MapController mapController = Controller.getCurrentModeController().getMapController();
    final NodeModel selected = selection.getSelected();
    final NodeModel rootNode = selected.getMap().getRootNode();
    boolean nodeFound = condition.checkNode(rootNode);
    if (nodeFound) {
        selection.selectAsTheOnlyOneSelected(rootNode);
    }
    NodeModel next = rootNode;
    for (; ; ) {
        next = filterController.findNext(next, rootNode, Direction.FORWARD, condition);
        if (next == null) {
            break;
        }
        mapController.displayNode(next);
        if (nodeFound) {
            selection.toggleSelected(next);
        } else {
            selection.selectAsTheOnlyOneSelected(next);
            nodeFound = true;
        }
    }
    if (condition.checkNode(selected))
        selection.makeTheSelected(selected);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) MapController(org.freeplane.features.map.MapController)

Example 34 with IMapSelection

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

the class QuickFindAction method executeAction.

public void executeAction(final boolean reFocusSearchInputField) {
    final ASelectableCondition condition = filterEditor.getCondition();
    if (condition == null) {
        return;
    }
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel selected = selection.getSelected();
    final NodeModel next;
    try {
        filterEditor.setSearchingBusyCursor();
        next = filterController.findNext(selected, null, direction, condition);
    } finally {
        filterEditor.setSearchingDefaultCursor();
    }
    if (next != null) {
        final MapController mapController = Controller.getCurrentModeController().getMapController();
        mapController.displayNode(next);
        selection.selectAsTheOnlyOneSelected(next);
        if (reFocusSearchInputField) {
            // this is called by Enter key listener in FilterConditionEditor
            // => we want to re-focus the search term input field so that one can hit enter
            // again to find the next search result!
            filterEditor.focusInputField(false);
        }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) MapController(org.freeplane.features.map.MapController)

Example 35 with IMapSelection

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

the class StyleEditorPanel method addListeners.

private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(new INodeSelectionListener() {

        public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            if (selection.size() == 1) {
                setStyle(node);
            }
        }

        public void onDeselect(final NodeModel node) {
        }
    });
    mapController.addNodeChangeListener(new INodeChangeListener() {

        public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
                setStyle(node);
            }
        }
    });
    mapController.addMapChangeListener(new AMapChangeListenerAdapter() {

        @Override
        public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty()))
                return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
        }
    });
    final IMapViewManager mapViewManager = controller.getMapViewManager();
    mapViewManager.addMapViewChangeListener(new IMapViewChangeListener() {

        public void beforeViewChange(final Component oldView, final Component newView) {
        }

        public void afterViewCreated(final Component mapView) {
        }

        public void afterViewClose(final Component oldView) {
        }

        public void afterViewChange(final Component oldView, final Component newView) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
                panel.getComponent(i).setEnabled(newView != null);
            }
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) IMapViewChangeListener(org.freeplane.features.ui.IMapViewChangeListener) IMapSelection(org.freeplane.features.map.IMapSelection) ModeController(org.freeplane.features.mode.ModeController) EdgeController(org.freeplane.features.edge.EdgeController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController) IMapViewManager(org.freeplane.features.ui.IMapViewManager) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) Component(java.awt.Component)

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