Search in sources :

Example 26 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class ImportExplorerFavoritesAction method addNode.

/**
 */
private NodeModel addNode(final NodeModel target, final String nodeContent) {
    final NodeModel node = ((MMapController) Controller.getCurrentModeController().getMapController()).addNewNode(target, target.getChildCount(), target.isNewChildLeft());
    ((MTextController) TextController.getController()).setNodeText(node, nodeContent);
    return node;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MTextController(org.freeplane.features.text.mindmapmode.MTextController)

Example 27 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class ImportFolderStructureAction method addNode.

/**
 */
private NodeModel addNode(final NodeModel target, final String nodeContent, final String link) {
    final NodeModel node = ((MMapController) Controller.getCurrentModeController().getMapController()).addNewNode(target, target.getChildCount(), target.isNewChildLeft());
    ((MTextController) TextController.getController()).setNodeText(node, nodeContent);
    ((MLinkController) LinkController.getController()).setLink(node, link, LinkController.LINK_ABSOLUTE);
    return node;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MTextController(org.freeplane.features.text.mindmapmode.MTextController)

Example 28 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController 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 29 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class ImportLinkedBranchWithoutRootAction 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();
    if (selected == null || NodeLinks.getLink(selected) == null) {
        JOptionPane.showMessageDialog(Controller.getCurrentController().getMapViewManager().getMapViewComponent(), TextUtils.getText("import_linked_branch_no_link"));
        return;
    }
    try {
        final URI uri = NodeLinks.getLink(selected);
        final URL url = map.getURL();
        final File file = uri.isAbsolute() && !uri.isOpaque() ? new File(uri) : new File(new URL(url, uri.getPath()).getFile());
        final NodeModel node = ((MFileManager) UrlManager.getController()).loadTree(map, file);
        map.setURL(url);
        for (final NodeModel child : Controller.getCurrentModeController().getMapController().childrenUnfolded(node)) {
            child.setParent(null);
            ((MMapController) modeController.getMapController()).insertNode(child, selected);
        }
        ((MLinkController) LinkController.getController()).setLink(selected, (URI) null, LinkController.LINK_ABSOLUTE);
    } catch (final Exception ex) {
        UrlManager.getController().handleLoadingException(ex);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) URI(java.net.URI) File(java.io.File) URL(java.net.URL)

Example 30 with MMapController

use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.

the class MFileManager method newMapFromTemplate.

/**
 *@deprecated -- use MMapIO
 */
@Deprecated
public MapModel newMapFromTemplate(final File startFile) {
    return AccessController.doPrivileged(new PrivilegedAction<MapModel>() {

        @Override
        public MapModel run() {
            final File file;
            if (startFile == null) {
                file = getLastCurrentDir();
            } else if (startFile.isDirectory()) {
                final JFileChooser chooser = getFileChooser(true);
                chooser.setCurrentDirectory(startFile);
                final int returnVal = chooser.showOpenDialog(Controller.getCurrentController().getMapViewManager().getMapViewComponent());
                if (returnVal != JFileChooser.APPROVE_OPTION) {
                    return null;
                }
                file = chooser.getSelectedFile();
            } else {
                file = startFile;
            }
            try {
                final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
                mapController.newUntitledMap(Compat.fileToUrl(file));
                final Controller controller = Controller.getCurrentController();
                final MapModel map = controller.getMap();
                final Object rootText = map.getRootNode().getUserObject();
                if (rootText instanceof TranslatedObject) {
                    map.getRootNode().setText(rootText.toString());
                }
                controller.getModeController().getMapController().setSaved(map, true);
                return map;
            } catch (Exception e) {
                handleLoadingException(e);
            }
            return null;
        }
    });
}
Also used : JFileChooser(javax.swing.JFileChooser) MMapController(org.freeplane.features.map.mindmapmode.MMapController) TranslatedObject(org.freeplane.core.resources.TranslatedObject) TranslatedObject(org.freeplane.core.resources.TranslatedObject) MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) MapModel(org.freeplane.features.map.MapModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) AccessController(java.security.AccessController) ResourceController(org.freeplane.core.resources.ResourceController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) File(java.io.File) XMLException(org.freeplane.n3.nanoxml.XMLException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) XMLParseException(org.freeplane.n3.nanoxml.XMLParseException) MapConversionException(org.freeplane.features.url.MapConversionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

MMapController (org.freeplane.features.map.mindmapmode.MMapController)38 NodeModel (org.freeplane.features.map.NodeModel)26 ModeController (org.freeplane.features.mode.ModeController)16 Controller (org.freeplane.features.mode.Controller)13 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)11 LinkController (org.freeplane.features.link.LinkController)9 MapModel (org.freeplane.features.map.MapModel)9 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)9 File (java.io.File)7 MNodeStyleController (org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController)7 TextController (org.freeplane.features.text.TextController)7 ResourceController (org.freeplane.core.resources.ResourceController)6 MapController (org.freeplane.features.map.MapController)6 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)6 MTextController (org.freeplane.features.text.mindmapmode.MTextController)6 IOException (java.io.IOException)5 MalformedURLException (java.net.MalformedURLException)5 URL (java.net.URL)5 IActor (org.freeplane.core.undo.IActor)5 IconController (org.freeplane.features.icon.IconController)4