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