Search in sources :

Example 26 with IMapSelection

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

the class ControlGroupChangeListener method propertyChange.

public void propertyChange(final PropertyChangeEvent evt) {
    if (internalChange) {
        return;
    }
    final boolean enabled;
    if (evt.getSource().equals(mSet)) {
        enabled = mSet.getBooleanValue();
    } else {
        assert properties.contains(evt.getSource());
        enabled = true;
    }
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final Collection<NodeModel> nodes = selection.getSelection();
    if (enabled)
        internalChange = true;
    for (final NodeModel node : nodes) {
        applyValue(enabled, node, evt);
    }
    if (enabled && !mSet.getBooleanValue())
        mSet.setValue(true);
    internalChange = false;
    setStyle(selection.getSelected());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection)

Example 27 with IMapSelection

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

the class NewSummaryAction method addNewSummaryNodeStartEditing.

private boolean addNewSummaryNodeStartEditing() {
    final ModeController modeController = Controller.getCurrentModeController();
    final IMapSelection selection = modeController.getController().getSelection();
    final List<NodeModel> sortedSelection = selection.getSortedSelection(false);
    final NodeModel firstNode = sortedSelection.get(0);
    final NodeModel lastNode = sortedSelection.get(sortedSelection.size() - 1);
    final boolean isLeft = firstNode.isLeft();
    // different sides
    if (isLeft != lastNode.isLeft()) {
        return false;
    }
    final NodeModel parentNode = firstNode.getParentNode();
    if (parentNode == null)
        return false;
    final NodeModel lastParent = lastNode.getParentNode();
    if (lastParent == null)
        return false;
    if (parentNode.equals(lastParent))
        return addNewSummaryNodeStartEditing(firstNode, lastNode);
    else {
        final NodeRelativePath nodeRelativePath = new NodeRelativePath(firstNode, lastNode);
        NodeModel commonAncestor = nodeRelativePath.commonAncestor();
        if (commonAncestor == firstNode || commonAncestor == lastNode)
            return false;
        final NodeModel newFirstNode = nodeRelativePath.beginPathElement(1);
        final NodeModel newLastNode = nodeRelativePath.endPathElement(1);
        return addNewSummaryNodeStartEditing(newFirstNode, newLastNode);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) NodeRelativePath(org.freeplane.features.map.NodeRelativePath) ModeController(org.freeplane.features.mode.ModeController)

Example 28 with IMapSelection

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

the class MoveSelectedNodeAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final Component mapView = Controller.getCurrentController().getMapViewManager().getMapViewComponent();
    final JRootPane rootPane = SwingUtilities.getRootPane(mapView);
    if (!rootPane.isValid()) {
        rootPane.revalidate();
    }
    if (ResourceController.getResourceController().getBooleanProperty(MOVE_SLOWLY_PROPERTY))
        selection.slowlyMoveNodeTo(selection.getSelected(), nodePosition);
    else
        selection.moveNodeTo(selection.getSelected(), nodePosition);
}
Also used : IMapSelection(org.freeplane.features.map.IMapSelection) JRootPane(javax.swing.JRootPane) Component(java.awt.Component)

Example 29 with IMapSelection

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

the class ApplicationViewController method removeSplitPane.

@Override
public void removeSplitPane() {
    saveSplitPanePosition();
    mMindMapComponent = null;
    mSplitPane.setLeftComponent(null);
    mSplitPane.setRightComponent(null);
    mSplitPane.setLeftComponent(mapPane);
    setSplitPaneLayoutManager();
    final Controller controller = Controller.getCurrentModeController().getController();
    final IMapSelection selection = controller.getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel node = selection.getSelected();
    EventQueue.invokeLater(new Runnable() {

        public void run() {
            final Component component = controller.getMapViewManager().getComponent(node);
            if (component != null) {
                component.requestFocus();
            }
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ResourceController(org.freeplane.core.resources.ResourceController) FrameController(org.freeplane.features.ui.FrameController) Controller(org.freeplane.features.mode.Controller) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 30 with IMapSelection

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

the class ControllerProxy method selectMultipleNodes.

public void selectMultipleNodes(final Collection<Node> toSelect) {
    final IMapSelection selection = Controller.getCurrentController().getSelection();
    final Iterator<Node> it = toSelect.iterator();
    if (!it.hasNext()) {
        return;
    }
    selection.selectAsTheOnlyOneSelected(((NodeProxy) it.next()).getDelegate());
    while (it.hasNext()) {
        final NodeModel nodeModel = ((NodeProxy) it.next()).getDelegate();
        Controller.getCurrentController().getSelection().toggleSelected(nodeModel);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) Node(org.freeplane.plugin.script.proxy.Proxy.Node)

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