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);
}
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) {
}
}
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();
}
}
Aggregations