Search in sources :

Example 1 with NodeAndMapReference

use of org.freeplane.features.url.NodeAndMapReference in project freeplane by freeplane.

the class MMapController method newDocumentationMap.

public void newDocumentationMap(final String file) {
    final NodeAndMapReference nodeAndMapReference = new NodeAndMapReference(file);
    final ResourceController resourceController = ResourceController.getResourceController();
    final File userDir = new File(resourceController.getFreeplaneUserDirectory());
    final File baseDir = new File(resourceController.getInstallationBaseDir());
    final String languageCode = resourceController.getLanguageCode();
    final File localFile = ConfigurationUtils.getLocalizedFile(new File[] { userDir, baseDir }, nodeAndMapReference.getMapReference(), languageCode);
    if (localFile == null) {
        String errorMessage = TextUtils.format("invalid_file_msg", file);
        UITools.errorMessage(errorMessage);
        return;
    }
    try {
        final URL endUrl = localFile.toURL();
        try {
            if (endUrl.getFile().endsWith(".mm")) {
                Controller.getCurrentController().selectMode(MModeController.MODENAME);
                newDocumentationMap(endUrl);
                if (nodeAndMapReference.hasNodeReference())
                    select(nodeAndMapReference.getNodeReference());
            } else {
                Controller.getCurrentController().getViewController().openDocument(endUrl);
            }
        } catch (final Exception e1) {
            LogUtils.severe(e1);
        }
    } catch (final MalformedURLException e1) {
        LogUtils.warn(e1);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ResourceController(org.freeplane.core.resources.ResourceController) NodeAndMapReference(org.freeplane.features.url.NodeAndMapReference) File(java.io.File) URL(java.net.URL) XMLException(org.freeplane.n3.nanoxml.XMLException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ResourceController (org.freeplane.core.resources.ResourceController)1 NodeAndMapReference (org.freeplane.features.url.NodeAndMapReference)1 XMLException (org.freeplane.n3.nanoxml.XMLException)1