Search in sources :

Example 11 with NodeModel

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++);
            }
        }
    }
}
Also used : MMapController(org.freeplane.features.map.mindmapmode.MMapController) ArrayList(java.util.ArrayList) MapModel(org.freeplane.features.map.MapModel) URI(java.net.URI) Hint(org.freeplane.features.map.MapWriter.Hint) XMLException(org.freeplane.n3.nanoxml.XMLException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) BadLocationException(javax.swing.text.BadLocationException) CloneEncryptedNodeException(org.freeplane.features.map.CloneEncryptedNodeException) IOException(java.io.IOException) NodeModel(org.freeplane.features.map.NodeModel) File(java.io.File)

Example 12 with NodeModel

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 13 with NodeModel

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;
}
Also used : JPanel(javax.swing.JPanel) NodeModel(org.freeplane.features.map.NodeModel) Transferable(java.awt.datatransfer.Transferable) IDataFlavorHandler(org.freeplane.features.clipboard.mindmapmode.MClipboardController.IDataFlavorHandler) Component(java.awt.Component)

Example 14 with NodeModel

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) CloudModel(org.freeplane.features.cloud.CloudModel)

Example 15 with NodeModel

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);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ModeController(org.freeplane.features.mode.ModeController)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)408 ModeController (org.freeplane.features.mode.ModeController)89 MapModel (org.freeplane.features.map.MapModel)47 Controller (org.freeplane.features.mode.Controller)44 MapStyleModel (org.freeplane.features.styles.MapStyleModel)39 IMapSelection (org.freeplane.features.map.IMapSelection)34 MapController (org.freeplane.features.map.MapController)33 Point (java.awt.Point)32 MMapController (org.freeplane.features.map.mindmapmode.MMapController)31 IStyle (org.freeplane.features.styles.IStyle)31 IActor (org.freeplane.core.undo.IActor)30 NodeView (org.freeplane.view.swing.map.NodeView)22 ArrayList (java.util.ArrayList)20 Color (java.awt.Color)16 URI (java.net.URI)16 ResourceController (org.freeplane.core.resources.ResourceController)16 Component (java.awt.Component)15 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15 File (java.io.File)14