Search in sources :

Example 21 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class MMapController method setFoldingState.

@Override
protected void setFoldingState(final NodeModel node, final boolean folded) {
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final boolean wasFolded = mapViewManager.isFoldedOnCurrentView(node);
    if (wasFolded == folded && mapViewManager.getComponent(node) == null)
        return;
    if (isFoldingPersistent()) {
        IActor foldingActor = new IActor() {

            @Override
            public void undo() {
                unfoldHiddenChildren(node);
                MMapController.super.setFoldingState(node, wasFolded);
            }

            @Override
            public String getDescription() {
                return "setFoldingState";
            }

            @Override
            public void act() {
                unfoldHiddenChildren(node);
                MMapController.super.setFoldingState(node, folded);
            }
        };
        getMModeController().execute(foldingActor, node.getMap());
    } else
        super.setFoldingState(node, folded);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) IActor(org.freeplane.core.undo.IActor)

Example 22 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class LastOpenedList method afterViewChange.

public void afterViewChange(final Component oldView, final Component newView) {
    if (newView == null) {
        updateMenus();
        return;
    }
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final MapModel map = mapViewManager.getModel(newView);
    final String restoreString = getRestoreable(map);
    updateList(map, restoreString);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) MapModel(org.freeplane.features.map.MapModel)

Example 23 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class ImportLinkedBranchAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MapModel map = Controller.getCurrentController().getMap();
    final ModeController modeController = Controller.getCurrentModeController();
    final NodeModel selected = modeController.getMapController().getSelectedNode();
    final IMapViewManager viewController = Controller.getCurrentController().getMapViewManager();
    if (selected == null || NodeLinks.getLink(selected) == null) {
        JOptionPane.showMessageDialog((viewController.getMapViewComponent()), TextUtils.getText("import_linked_branch_no_link"));
        return;
    }
    final URI uri = NodeLinks.getLink(selected);
    try {
        final File file = uri.isAbsolute() && !uri.isOpaque() ? new File(uri) : new File(new URL(map.getURL(), uri.getPath()).getFile());
        final NodeModel node = ((MFileManager) UrlManager.getController()).loadTree(map, file);
        PersistentNodeHook.removeMapExtensions(node);
        ((MMapController) modeController.getMapController()).insertNode(node, selected);
        ((MLinkController) LinkController.getController()).setLink(selected, (URI) null, LinkController.LINK_ABSOLUTE);
        ((MLinkController) LinkController.getController()).setLink(node, (URI) null, LinkController.LINK_ABSOLUTE);
    } catch (final MalformedURLException ex) {
        UITools.errorMessage(TextUtils.format("invalid_url_msg", uri.toString()));
        LogUtils.warn(ex);
        return;
    } catch (final IllegalArgumentException ex) {
        UITools.errorMessage(TextUtils.format("invalid_file_msg", uri.toString()));
        LogUtils.warn(ex);
        return;
    } catch (final Exception ex) {
        UrlManager.getController().handleLoadingException(ex);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) URI(java.net.URI) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) IMapViewManager(org.freeplane.features.ui.IMapViewManager) NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) File(java.io.File)

Example 24 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class MapProxy method close.

// Map: R/W
public boolean close(boolean force, boolean allowInteraction) {
    if (!getDelegate().isSaved() && !force && !allowInteraction)
        throw new RuntimeException("will not close an unsaved map without being told so");
    final IMapViewManager mapViewManager = getMapViewManager();
    changeToThisMap(mapViewManager);
    return mapViewManager.close(force);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager)

Example 25 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager 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

IMapViewManager (org.freeplane.features.ui.IMapViewManager)35 Component (java.awt.Component)13 Controller (org.freeplane.features.mode.Controller)13 MapModel (org.freeplane.features.map.MapModel)12 ModeController (org.freeplane.features.mode.ModeController)11 JComponent (javax.swing.JComponent)7 URL (java.net.URL)5 ResourceController (org.freeplane.core.resources.ResourceController)5 NodeModel (org.freeplane.features.map.NodeModel)5 MapView (org.freeplane.view.swing.map.MapView)5 Point (java.awt.Point)4 JTextComponent (javax.swing.text.JTextComponent)4 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 LinkController (org.freeplane.features.link.LinkController)3 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)3 ViewController (org.freeplane.features.ui.ViewController)3 Color (java.awt.Color)2 Dimension (java.awt.Dimension)2 ComponentAdapter (java.awt.event.ComponentAdapter)2 ComponentEvent (java.awt.event.ComponentEvent)2