public ImportLinkedBranchWithoutRootAction() {
super("ImportLinkedBranchWithoutRootAction");
}
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)) {
((MMapController) modeController.getMapController()).insertNode(child, selected);
}
((MLinkController) LinkController.getController()).setLink(selected, (URI) null, LinkController.LINK_ABSOLUTE);
}