Search in sources :

Example 31 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class UrlManager method loadOtherURI.

private void loadOtherURI(URI uri, final boolean hasFreeplaneFileExtension) {
    try {
        if (!uri.isAbsolute()) {
            URI absoluteUri = getAbsoluteUri(uri);
            if (absoluteUri == null) {
                final MapModel map = Controller.getCurrentController().getMap();
                if (map.getURL() == null)
                    UITools.errorMessage(TextUtils.getText("map_not_saved"));
                else
                    UITools.errorMessage(TextUtils.format("link_not_found", String.valueOf(uri)));
                return;
            }
            uri = absoluteUri;
        }
        // DOCEAR: mindmaps can be linked in a mindmap --> therefore project-relative-paths are possible
        if (!asList(FILE_SCHEME, SMB_SCHEME, FREEPLANE_SCHEME).contains(uri.getScheme())) {
            try {
                uri = uri.toURL().openConnection().getURL().toURI().normalize();
            } catch (Exception e) {
            // ignore all exceptions due to unknown protocols
            }
        }
        try {
            if (hasFreeplaneFileExtension) {
                FreeplaneUriConverter freeplaneUriConverter = new FreeplaneUriConverter();
                final URL url = freeplaneUriConverter.freeplaneUrl(uri);
                final ModeController modeController = Controller.getCurrentModeController();
                modeController.getMapController().newMap(url);
                return;
            }
            Controller.getCurrentController().getViewController().openDocument(uri);
        } catch (final Exception e) {
            LogUtils.warn("link " + uri + " not found", e);
            UITools.errorMessage(TextUtils.format("link_not_found", uri.toString()));
        }
        return;
    } catch (final MalformedURLException ex) {
        LogUtils.warn("URL " + uri + " not found", ex);
        UITools.errorMessage(TextUtils.format("link_not_found", uri));
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) URI(java.net.URI) XMLParseException(org.freeplane.n3.nanoxml.XMLParseException) XMLException(org.freeplane.n3.nanoxml.XMLException) URISyntaxException(java.net.URISyntaxException) HeadlessException(java.awt.HeadlessException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) URL(java.net.URL)

Example 32 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class UrlManager method load.

/**
 *@deprecated -- use {@link MapIO#load(URL url, MapModel map)}
 */
@Deprecated
public InputStreamReader load(final URL url, final MapModel map) throws IOException, XMLException {
    InputStreamReader urlStreamReader;
    setURL(map, url);
    InputStream inputStream = getLocation(url).openStream();
    urlStreamReader = new InputStreamReader(inputStream);
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.getMapController().getMapReader().createNodeTreeFromXml(map, urlStreamReader, Mode.FILE);
    return urlStreamReader;
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) ModeController(org.freeplane.features.mode.ModeController)

Example 33 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class OpenAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
    MFileManager.getController(modeController).open();
    Controller.getCurrentController().getMapViewManager().setMapTitles();
}
Also used : MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController)

Example 34 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class SaveAll method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    final Component initialMapView = controller.getMapViewManager().getMapViewComponent();
    final Map<String, MapModel> mapViews = getMapViews();
    final Iterator<Entry<String, MapModel>> iterator = mapViews.entrySet().iterator();
    while (iterator.hasNext()) {
        final Entry<String, MapModel> entry = iterator.next();
        controller.getMapViewManager().changeToMapView(entry.getKey());
        final ModeController modeController = controller.getModeController();
        if (modeController instanceof MModeController) {
            ((MModeController) modeController).save();
        }
    }
    if (initialMapView != null) {
        controller.getMapViewManager().changeToMapView(initialMapView);
    }
}
Also used : Entry(java.util.Map.Entry) MapModel(org.freeplane.features.map.MapModel) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) Controller(org.freeplane.features.mode.Controller) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) Component(java.awt.Component) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 35 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class AddOnsController method registerInstalledAddOn.

public void registerInstalledAddOn(final AddOnProperties addOn) {
    installedAddOns.add(addOn);
    final ResourceController resourceController = ResourceController.getResourceController();
    if (addOn.getDefaultProperties() != null)
        resourceController.addDefaults(addOn.getDefaultProperties());
    if (addOn.getTranslations() != null)
        registerAddOnResources(addOn, resourceController);
    if (addOn.getPreferencesXml() != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        if (modeController instanceof MModeController) {
            ((MModeController) modeController).getOptionPanelBuilder().load(new StringReader(addOn.getPreferencesXml()));
        }
    }
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController) StringReader(java.io.StringReader) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)185 NodeModel (org.freeplane.features.map.NodeModel)80 Controller (org.freeplane.features.mode.Controller)43 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)36 MapController (org.freeplane.features.map.MapController)31 MapModel (org.freeplane.features.map.MapModel)30 IActor (org.freeplane.core.undo.IActor)28 ResourceController (org.freeplane.core.resources.ResourceController)21 MMapController (org.freeplane.features.map.mindmapmode.MMapController)21 Point (java.awt.Point)16 TextController (org.freeplane.features.text.TextController)16 Component (java.awt.Component)13 MapView (org.freeplane.view.swing.map.MapView)13 LinkController (org.freeplane.features.link.LinkController)12 NodeView (org.freeplane.view.swing.map.NodeView)12 Color (java.awt.Color)11 File (java.io.File)11 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)11 IMapSelection (org.freeplane.features.map.IMapSelection)10 ViewController (org.freeplane.features.ui.ViewController)10