use of org.freeplane.features.map.NodeModel 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.NodeModel in project freeplane by freeplane.
the class MoveAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
final NodeModel parent = Controller.getCurrentController().getSelection().getSelected();
clipboardController.move(clipboardController.getClipboardContents(), parent);
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class SelectedPasteAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final MClipboardController clipboardController = (MClipboardController) ClipboardController.getController();
final Collection<IDataFlavorHandler> flavorHandlers = clipboardController.getFlavorHandlers();
if (flavorHandlers.isEmpty()) {
return;
}
final JPanel options = createPane(flavorHandlers);
if (JOptionPane.CANCEL_OPTION == JOptionPane.showConfirmDialog((Component) e.getSource(), options, (String) getValue(Action.NAME), JOptionPane.OK_CANCEL_OPTION)) {
return;
}
final NodeModel parent = Controller.getCurrentController().getSelection().getSelected();
final Transferable clipboardContents = clipboardController.getClipboardContents();
clipboardController.paste(clipboardContents, selectedHandler, parent, false, parent.isNewChildLeft());
selectedHandler = null;
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class CloudShapeAction method setSelected.
@Override
public void setSelected() {
final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
final CloudModel model = CloudModel.getModel(node);
if (model != null) {
if (actionShape.equals(model.getShape())) {
setSelected(true);
return;
}
}
setSelected(false);
}
use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.
the class CloudShapeAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
ModeController controller;
{
controller = Controller.getCurrentModeController();
final NodeModel selected = controller.getMapController().getSelectedNode();
final MCloudController cloudController = (MCloudController) CloudController.getController();
cloudController.setCloud(selected, true);
}
super.actionPerformed(e);
}
Aggregations