use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MClipboardController method cut.
Transferable cut(final List<NodeModel> collection) {
Controller.getCurrentModeController().getMapController().sortNodesByDepth(collection);
final MindMapNodesSelection transferable = copy(new SummaryGroupEdgeListAdder(collection).addSummaryEdgeNodes(), true);
((MMapController) Controller.getCurrentModeController().getMapController()).deleteNodes(collection);
setClipboardContents(transferable);
return transferable;
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MClipboardController method pasteStringWithoutRedisplay.
private void pasteStringWithoutRedisplay(final TextFragment[] textFragments, NodeModel parent, final boolean asSibling, final boolean isLeft) {
final MapModel map = parent.getMap();
int insertionIndex;
if (asSibling) {
NodeModel target = parent;
parent = parent.getParentNode();
final NodeModel childNode = target;
insertionIndex = parent.getIndex(childNode);
} else {
insertionIndex = parent.getChildCount();
}
final ArrayList<NodeModel> parentNodes = new ArrayList<NodeModel>();
final ArrayList<Integer> parentNodesDepths = new ArrayList<Integer>();
parentNodes.add(parent);
parentNodesDepths.add(new Integer(-1));
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
for (int i = 0; i < textFragments.length; ++i) {
final TextFragment textFragment = textFragments[i];
String text = textFragment.text;
final String link = textFragment.link;
URI uri = null;
if (link != null) {
try {
URI linkUri = new URI(link);
uri = linkUri;
File absoluteFile = UrlManager.getController().getAbsoluteFile(map, uri);
if (absoluteFile != null) {
// if ("file".equals(linkUri.getScheme())) {
final File mapFile = map.getFile();
uri = LinkController.toLinkTypeDependantURI(mapFile, absoluteFile);
if (link.equals(text)) {
text = uri.toString();
}
}
} catch (Exception e) {
}
}
final NodeModel node = mapController.newNode(text, map);
if (uri != null) {
NodeLinks.createLinkExtension(node).setHyperLink(uri);
}
for (int j = parentNodes.size() - 1; j >= 0; --j) {
if (textFragment.depth > ((Integer) parentNodesDepths.get(j)).intValue()) {
for (int k = j + 1; k < parentNodes.size(); ++k) {
final NodeModel n = (NodeModel) parentNodes.get(k);
if (n.getParentNode() == null) {
mapController.insertNode(n, parent, insertionIndex++);
}
parentNodes.remove(k);
parentNodesDepths.remove(k);
}
final NodeModel target = (NodeModel) parentNodes.get(j);
node.setLeft(isLeft);
if (target != parent) {
target.setFolded(true);
target.insert(node, target.getChildCount());
}
parentNodes.add(node);
parentNodesDepths.add(new Integer(textFragment.depth));
break;
}
}
}
{
for (int k = 0; k < parentNodes.size(); ++k) {
final NodeModel n = (NodeModel) parentNodes.get(k);
if (map.getRootNode() != n && n.getParentNode() == null) {
mapController.insertNode(n, parent, insertionIndex++);
}
}
}
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class MTextController method edit.
public void edit(final FirstAction action, final boolean editLong) {
final Controller controller = Controller.getCurrentController();
final IMapSelection selection = controller.getSelection();
if (selection == null)
return;
final NodeModel selectedNode = selection.getSelected();
if (selectedNode == null)
return;
if (FirstAction.EDIT_CURRENT.equals(action)) {
edit(selectedNode, selectedNode, false, false, editLong);
} else if (!Controller.getCurrentModeController().isBlocked()) {
final int mode = FirstAction.ADD_CHILD.equals(action) ? MMapController.NEW_CHILD : MMapController.NEW_SIBLING_BEHIND;
((MMapController) Controller.getCurrentModeController().getMapController()).addNewNode(mode);
}
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class ViewerController method pasteImage.
public boolean pasteImage(URI uri, final NodeModel targetNode, final PasteMode mode, final boolean isLeft) {
if (uri == null || getViewerFactory(uri) == null) {
return false;
}
File file = new File(uri.getPath());
boolean isFile = uri.getScheme().equals("file");
if (isFile) {
if (!file.exists()) {
return false;
}
final File mapFile = targetNode.getMap().getFile();
if (mapFile == null && LinkController.getLinkType() == LinkController.LINK_RELATIVE_TO_MINDMAP) {
JOptionPane.showMessageDialog(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(), TextUtils.getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
return false;
}
if (LinkController.getLinkType() != LinkController.LINK_ABSOLUTE) {
uri = LinkController.toLinkTypeDependantURI(mapFile, file);
}
}
final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
final NodeModel node;
if (mode.equals(PasteMode.INSIDE)) {
node = targetNode;
} else {
node = mapController.newNode(file.getName(), targetNode.getMap());
mapController.insertNode(node, targetNode, mode.equals(PasteMode.AS_SIBLING), isLeft, isLeft);
}
final ExternalResource preview = new ExternalResource(uri);
undoableDeactivateHook(node);
undoableActivateHook(node, preview);
ProgressIcons.updateExtendedProgressIcons(node, file.getName());
return true;
}
use of org.freeplane.features.map.mindmapmode.MMapController in project freeplane by freeplane.
the class FreeNode method undoableToggleHook.
@Override
public void undoableToggleHook(NodeModel node, IExtension extension) {
if (node.isRoot())
return;
final NodeModel[] selecteds = getSelectedNodes();
((MLocationController) LocationController.getController()).moveNodePosition(node, LocationModel.DEFAULT_HGAP, LocationModel.DEFAULT_SHIFT_Y);
super.undoableToggleHook(node, extension);
if (isFreeNode(node)) {
MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
mapController.moveNode(node, 0);
}
Controller.getCurrentController().getSelection().replaceSelection(selecteds);
}
Aggregations