Search in sources :

Example 11 with MFileManager

use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.

the class MMapIO method install.

public static void install(MModeController modeController) {
    MFileManager urlManager = (MFileManager) modeController.getExtension(UrlManager.class);
    MMapController mapController = (MMapController) modeController.getMapController();
    final MMapIO mapIO = new MMapIO(urlManager, mapController);
    modeController.addExtension(MapIO.class, mapIO);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager)

Example 12 with MFileManager

use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.

the class UserPropertiesUpdater method importOldDefaultStyle.

void importOldDefaultStyle() {
    final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
    MFileManager fm = MFileManager.getController(modeController);
    final String standardTemplateName = fm.getStandardTemplateName();
    final File userDefault;
    final File absolute = new File(standardTemplateName);
    if (absolute.isAbsolute())
        userDefault = absolute;
    else {
        final File userTemplates = fm.defaultUserTemplateDir();
        userDefault = new File(userTemplates, standardTemplateName);
    }
    if (userDefault.exists()) {
        return;
    }
    userDefault.getParentFile().mkdirs();
    if (!userDefault.getParentFile().exists()) {
        return;
    }
    MapModel defaultStyleMap = new MapModel();
    final File allUserTemplates = fm.defaultStandardTemplateDir();
    final File standardTemplate = new File(allUserTemplates, "standard.mm");
    try {
        fm.loadCatchExceptions(standardTemplate.toURL(), defaultStyleMap);
    } catch (Exception e) {
        LogUtils.warn(e);
        try {
            fm.loadCatchExceptions(ResourceController.getResourceController().getResource("/styles/viewer_standard.mm"), defaultStyleMap);
        } catch (Exception e2) {
            defaultStyleMap.createNewRoot();
            LogUtils.severe(e);
        }
    }
    final NodeStyleController nodeStyleController = NodeStyleController.getController(modeController);
    updateDefaultStyle(nodeStyleController, defaultStyleMap);
    updateNoteStyle(nodeStyleController, defaultStyleMap);
    try {
        fm.writeToFile(defaultStyleMap, userDefault);
    } catch (IOException e) {
    }
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MapModel(org.freeplane.features.map.MapModel) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Example 13 with MFileManager

use of org.freeplane.features.url.mindmapmode.MFileManager in project freeplane by freeplane.

the class CopyMapStylesAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController();
    final MFileManager fileManager = MFileManager.getController(modeController);
    final JFileChooser fileChooser = fileManager.getFileChooser(true);
    fileChooser.setMultiSelectionEnabled(false);
    final int returnVal = fileChooser.showOpenDialog(controller.getMapViewManager().getMapViewComponent());
    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    File file = fileChooser.getSelectedFile();
    if (!file.exists()) {
        return;
    }
    try {
        final URL url = Compat.fileToUrl(file);
        final MapModel map = controller.getMap();
        MapStyle mapStyleController = MapStyle.getController(modeController);
        mapStyleController.copyStyle(url, map, true);
    } catch (MalformedURLException e1) {
        e1.printStackTrace();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) JFileChooser(javax.swing.JFileChooser) MapStyle(org.freeplane.features.styles.MapStyle) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) File(java.io.File) URL(java.net.URL)

Aggregations

MFileManager (org.freeplane.features.url.mindmapmode.MFileManager)13 Controller (org.freeplane.features.mode.Controller)6 ModeController (org.freeplane.features.mode.ModeController)5 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)5 URL (java.net.URL)4 ResourceController (org.freeplane.core.resources.ResourceController)4 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4 MLogicalStyleController (org.freeplane.features.styles.mindmapmode.MLogicalStyleController)4 TextController (org.freeplane.features.text.TextController)4 MTextController (org.freeplane.features.text.mindmapmode.MTextController)4 File (java.io.File)3 AttributeController (org.freeplane.features.attribute.AttributeController)3 MAttributeController (org.freeplane.features.attribute.mindmapmode.MAttributeController)3 CloudController (org.freeplane.features.cloud.CloudController)3 MCloudController (org.freeplane.features.cloud.mindmapmode.MCloudController)3 EdgeController (org.freeplane.features.edge.EdgeController)3 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)3 IconController (org.freeplane.features.icon.IconController)3 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)3